* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
/* ============ デジタル庁デザインシステム準拠（Visit Japan Web系） ============ */
:root {
  --bg: #f8f8fb;
  --card: #ffffff;
  --ink: #1a1a1c;
  --sub: #626264;
  --primary: #0017c1;          /* デジ庁ブルー */
  --primary-hover: #00118f;
  --primary-light: #e8f1fe;
  --line: #d8d8db;
  --line-light: #e8e8eb;
  --focus: #ffd43d;            /* デジ庁の黄色フォーカスリング */
  --danger: #ec0000;
  --success: #197a4b;
  --kokkai: #6f42c1;
  --news: #626264;
  --party: #a35b00;
  --font-ui: "Noto Sans JP", "Hiragino Sans", "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
  --font-num: "Inter", "Segoe UI", sans-serif;
}
html { background: var(--bg); }
body {
  font-family: var(--font-ui); color: var(--ink); line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "palt";
  letter-spacing: 0.02em;
}
::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-thumb { background: #c9c9ce; border-radius: 8px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

/* ================= トップバー ================= */
#topbar {
  position: sticky; top: 0; z-index: 20;
  height: 58px;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px;
}
.tb-left { display: flex; align-items: center; gap: 10px; }
.tb-logo {
  width: 34px; height: 34px; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary);
  border-radius: 6px;
}
.wordmark { font-size: 17px; font-weight: 700; letter-spacing: 0.02em; }
.beta {
  font-size: 10.5px; font-weight: 700; color: var(--primary);
  border: 1px solid var(--primary); border-radius: 3px; padding: 0 6px;
}
.tb-right { color: var(--sub); font-size: 11.5px; letter-spacing: 0.04em; }

/* ================= アプリシェル ================= */
#app { display: flex; min-height: calc(100vh - 58px); }

/* ---- 左ナビ ---- */
#sidebar {
  width: 252px; flex-shrink: 0;
  background: var(--card);
  border-right: 1px solid var(--line);
  padding: 14px 10px;
  display: flex; flex-direction: column; gap: 3px;
  position: sticky; top: 58px; height: calc(100vh - 58px); overflow-y: auto;
}
#new-chat {
  font: inherit; font-weight: 700; font-size: 14px; color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  background: var(--primary);
  border: none; border-radius: 8px; padding: 11px 14px; cursor: pointer;
  transition: background 0.12s;
  margin-bottom: 8px;
}
#new-chat:hover { background: var(--primary-hover); }

.side-section {
  font-size: 11.5px; font-weight: 700; color: var(--sub); letter-spacing: 0.08em;
  margin: 12px 8px 4px;
}
.side-divider { border-top: 1px solid var(--line-light); margin: 10px 4px 2px; }

#mode-list { display: flex; flex-direction: column; gap: 2px; }
.mode-item {
  font: inherit; font-size: 14px; color: var(--ink); text-align: left;
  display: flex; align-items: center; gap: 12px;
  background: transparent; border: none; border-left: 3px solid transparent;
  border-radius: 0 8px 8px 0;
  padding: 10px 12px; cursor: pointer; transition: background 0.12s;
}
.mode-item svg { flex-shrink: 0; color: var(--sub); }
.mode-item:hover { background: var(--bg); }
.mode-item.active { background: var(--primary-light); color: var(--primary); font-weight: 700; border-left-color: var(--primary); }
.mode-item.active svg { color: var(--primary); }

.side-history { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 2px; }
.side-history .empty { color: var(--sub); font-size: 12.5px; padding: 6px 8px; }
.history-item {
  border-left: 3px solid transparent; border-radius: 0 8px 8px 0;
  padding: 8px 12px; cursor: pointer;
  transition: background 0.12s;
}
.history-item:hover { background: var(--bg); }
.history-item.active { background: var(--primary-light); border-left-color: var(--primary); }
.history-item.active .q { color: var(--primary); font-weight: 700; }
.history-item .q {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
  overflow: hidden; font-size: 13px; color: var(--ink); line-height: 1.5;
}
.history-item .hmeta { display: flex; gap: 6px; align-items: center; margin-top: 3px; }
.history-item .date { color: var(--sub); font-size: 11px; font-family: var(--font-num); }
.history-item .tag {
  font-size: 10px; color: var(--primary); border: 1px solid var(--primary);
  border-radius: 3px; padding: 0 4px;
}
.history-item .stat { color: var(--sub); font-size: 11px; margin-left: auto; }

/* ================= コンテンツ ================= */
#content { flex: 1; min-width: 0; }
main { width: 100%; max-width: 1060px; margin: 0 auto; padding: 28px 28px 48px; }
#app-foot { color: #949497; font-size: 11px; text-align: center; padding: 40px 0 0; letter-spacing: 0.06em; }

/* ---- コンテンツ先頭のブランドヒーロー（Genspark式） ---- */
#hero-brand {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  margin: 34px auto 34px; text-align: center;
}
.hb-logo {
  width: 52px; height: 52px; color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--primary);
  border-radius: 14px;
}
.hb-title { font-size: 28px; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap; }
.hb-ws { font-weight: 800; }

/* ---- 今日の政策トピック ---- */
#topics { max-width: 860px; margin: 30px auto 0; }
.topics-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 14px; }
.topics-head h2 { font-size: 22px; font-weight: 700; letter-spacing: 0.02em; }
#topics-date { color: var(--sub); font-size: 12.5px; font-family: var(--font-num); font-weight: 500; }
#topics-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(350px, 1fr)); gap: 14px; }
.topic-card {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 18px 20px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  display: flex; gap: 14px;
  position: relative;
}
.topic-card:hover { border-color: var(--primary); background: #fdfdff; }
.topic-card::after {
  content: ""; position: absolute; right: 16px; top: 50%;
  width: 9px; height: 9px; border-top: 2px solid var(--primary); border-right: 2px solid var(--primary);
  transform: translateY(-50%) rotate(45deg);
}
.topic-card .t-left { display: flex; flex-direction: column; align-items: center; gap: 7px; flex-shrink: 0; }
.topic-card .t-icon {
  width: 42px; height: 42px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 11px;
  color: var(--cat-c, var(--primary)); background: var(--cat-bg, var(--primary-light));
}
.topic-card .t-rank {
  font-family: var(--font-num); font-weight: 800; font-size: 15px; line-height: 1;
  color: #b3b6bd;
  font-feature-settings: "tnum";
}
.topic-card .t-cat {
  font-size: 10.5px; font-weight: 700; letter-spacing: 0.06em;
  color: var(--cat-c, var(--primary)); background: var(--cat-bg, var(--primary-light));
  border-radius: 4px; padding: 1px 7px;
}
/* カテゴリ配色 */
.cat-pol { --cat-c: #0017c1; --cat-bg: #e8effa; }
.cat-eco { --cat-c: #b45309; --cat-bg: #fdf0e0; }
.cat-soc { --cat-c: #d9376e; --cat-bg: #fdecf2; }
.cat-gov { --cat-c: #0e7490; --cat-bg: #e5f5f9; }
.cat-dip { --cat-c: #6f42c1; --cat-bg: #f1e9fe; }
.cat-env { --cat-c: #15803d; --cat-bg: #e7f6ec; }
.topic-card { border-top: 3px solid var(--cat-c, var(--primary)); }
.topic-card .t-body { display: flex; flex-direction: column; gap: 6px; min-width: 0; padding-right: 16px; }
.topic-card .t-head { display: flex; align-items: center; gap: 8px; }
.topic-card .t-label {
  font-size: 10px; font-weight: 700; color: var(--danger); border: 1px solid var(--danger);
  border-radius: 3px; padding: 0 5px; letter-spacing: 0.06em;
}
.topic-card .t-source { color: var(--sub); font-size: 11px; margin-left: auto; }
.topic-card .t-title { font-size: 16px; font-weight: 700; line-height: 1.55; }
.topic-card .t-summary { font-size: 13px; color: var(--sub); line-height: 1.7; }
.topic-card .t-primary { font-size: 11.5px; color: var(--success); font-weight: 700; }
.topic-card .t-primary a { color: var(--success); text-decoration: underline; }
.topic-card .t-cta { font-size: 12.5px; font-weight: 700; color: var(--primary); margin-top: 2px; }

/* ---- 入力 ---- */
#ask { max-width: 860px; margin: 0 auto; }
#ask form {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 20px 14px;
  transition: border-color 0.15s;
}
#ask form:focus-within { border-color: var(--primary); }
.ask-input { display: flex; gap: 12px; align-items: flex-start; }
.ask-icon {
  width: 38px; height: 38px; flex-shrink: 0; color: var(--sub);
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--bg); border: 1px solid var(--line-light); border-radius: 50%;
  margin-top: 2px;
}
#ask textarea {
  flex: 1; font: inherit; font-size: 15px;
  border: 1px solid var(--line); outline: none; resize: vertical; background: #fff;
  border-radius: 8px; padding: 10px 14px;
  min-height: 48px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
#ask textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
.ask-row {
  display: flex; align-items: center; gap: 10px; margin-top: 12px; flex-wrap: wrap;
  border-top: 1px solid var(--line-light); padding-top: 12px;
}
#mode-indicator {
  font-size: 12.5px; font-weight: 700; color: var(--primary);
  border: 1px solid var(--primary); background: var(--primary-light);
  border-radius: 6px; padding: 5px 12px; white-space: nowrap;
}
#quality-toggle {
  display: inline-flex; border: 1px solid var(--line); background: var(--card);
  border-radius: 8px; padding: 2px; gap: 2px;
}
.q-item {
  font: inherit; font-size: 12.5px; font-weight: 700; color: var(--sub);
  background: transparent; border: none; border-radius: 6px;
  padding: 4px 14px; cursor: pointer; transition: all 0.12s;
}
.q-item.active { background: var(--primary); color: #fff; }
.examples { display: flex; gap: 8px; flex-wrap: wrap; flex: 1; justify-content: center; }
.chip {
  font-size: 12.5px; font-weight: 500; color: var(--primary); background: #fff;
  border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; cursor: pointer;
  transition: all 0.12s;
}
.chip:hover { border-color: var(--primary); background: var(--primary-light); }
#go {
  width: 44px; height: 44px; flex-shrink: 0; align-self: flex-end;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; background: var(--primary);
  border: none; border-radius: 8px; cursor: pointer;
  transition: background 0.12s;
}
#go:hover { background: var(--primary-hover); }
#go:disabled { opacity: 0.4; cursor: wait; }

/* ---- 工程表示 ---- */
#work { max-width: 860px; margin: 20px auto 0; }
.step {
  display: flex; align-items: baseline; gap: 10px;
  padding: 10px 14px; margin-bottom: -1px;
  background: var(--card); border: 1px solid var(--line-light);
  font-size: 13.5px;
}
.step:first-child { border-radius: 8px 8px 0 0; }
.step:last-child { border-radius: 0 0 8px 8px; margin-bottom: 0; }
.step .icon { width: 18px; text-align: center; }
.step.running .icon::after { content: "⏳"; }
.step.done .icon::after { content: "✓"; color: var(--success); font-weight: 700; }
.step.error .icon::after { content: "!"; color: var(--danger); font-weight: 700; }
.step .found { color: var(--sub); font-size: 12px; margin-left: auto; white-space: nowrap; font-family: var(--font-num); }
.step .sublist { color: var(--sub); font-size: 12px; display: block; }

/* ---- 結果 ---- */
#result { margin-top: 24px; display: grid; grid-template-columns: 1fr 285px; gap: 20px; }
#report {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 40px 46px; min-width: 0;
}
#report h1, #report h2:first-child { font-size: 23px; font-weight: 700; letter-spacing: 0.01em; margin-bottom: 18px; line-height: 1.5; }
#report h2 {
  font-size: 18px; font-weight: 700; margin: 32px 0 12px; padding: 4px 0 4px 14px;
  border-left: 4px solid var(--primary);
}
#report h3 { font-size: 15.5px; font-weight: 700; margin: 20px 0 8px; }
#report p, #report li { margin-bottom: 10px; font-size: 15px; line-height: 1.85; }
#report strong { font-weight: 700; background: linear-gradient(transparent 70%, #ffe58a 70%); }
#report ul, #report ol { padding-left: 22px; }
#report table { border-collapse: collapse; margin: 12px 0; font-size: 13.5px; }
#report th { background: var(--primary-light); }
#report th, #report td { border: 1px solid var(--line); padding: 7px 11px; }

/* 出典チップ */
sup.cite a {
  color: var(--primary); text-decoration: none; font-weight: 600;
  background: var(--primary-light);
  border-radius: 4px; padding: 0px 6px; font-size: 10.5px;
  white-space: nowrap;
}
sup.cite a:hover { background: var(--primary); color: #fff; }
sup.cite a.k { color: var(--kokkai); background: #efe7fb; }
sup.cite a.k:hover { background: var(--kokkai); color: #fff; }

/* ---- 出典一覧 ---- */
#sources h2 { font-size: 13px; font-weight: 700; color: var(--sub); margin-bottom: 8px; letter-spacing: 0.05em; }
.source-card {
  display: block; background: var(--card); border: 1px solid var(--line-light);
  border-radius: 8px; padding: 9px 12px; margin-bottom: 6px;
  font-size: 12.5px; text-decoration: none; color: var(--ink);
  transition: border-color 0.12s;
}
.source-card:hover { border-color: var(--primary); }
.source-card .n { font-weight: 700; color: var(--primary); margin-right: 6px; font-family: var(--font-num); }
.source-card.kokkai .n { color: var(--kokkai); }
.source-card .domain { color: var(--sub); display: block; font-size: 11px; margin-top: 2px; }
.badge {
  font-size: 10px; border-radius: 3px; padding: 0 4px; margin-left: 6px;
  color: var(--primary); border: 1px solid var(--primary);
}
.badge.kokkai-b { color: var(--kokkai); border-color: var(--kokkai); }
.badge.subsidy { color: var(--success); border-color: var(--success); }
.source-card.subsidy .n { color: var(--success); }
.badge.official { color: var(--primary); border-color: var(--primary); }
.badge.news { color: var(--news); border-color: var(--news); }
.badge.party { color: var(--party); border-color: var(--party); }
#meta { grid-column: 1 / -1; color: var(--sub); font-size: 12px; text-align: right; font-family: var(--font-num); }

/* ---- 共有・書き出し ---- */
#share-row {
  grid-column: 1 / -1; display: flex; align-items: center; gap: 8px;
  background: var(--card); border: 1px solid var(--line); border-radius: 10px;
  padding: 10px 14px; font-size: 12.5px;
}
#share-row #share-url {
  flex: 1; font: inherit; font-size: 12px; border: 1px solid var(--line-light);
  border-radius: 6px; padding: 5px 10px; background: var(--bg); color: var(--sub);
}
#share-row #copy-url, #share-row #doc-link {
  font: inherit; font-size: 12.5px; font-weight: 700; border: 1px solid var(--primary);
  color: var(--primary); background: #fff;
  border-radius: 6px; padding: 6px 14px; cursor: pointer;
  text-decoration: none; white-space: nowrap;
  transition: all 0.12s;
}
#share-row #copy-url:hover, #share-row #doc-link:hover { background: var(--primary); color: #fff; }



/* ---- 調査中パネル（Genspark式: 動いていることが見える） ---- */
#work {
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  overflow: hidden; margin-top: 20px;
}
.work-head {
  display: flex; align-items: center; gap: 10px;
  padding: 13px 16px; font-size: 13.5px; font-weight: 700;
}
.work-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--primary);
  animation: work-pulse 1.1s ease-in-out infinite; flex: 0 0 auto;
}
#work.done .work-dot { background: var(--success); animation: none; }
@keyframes work-pulse {
  0%, 100% { transform: scale(0.7); opacity: 0.45; }
  50% { transform: scale(1.15); opacity: 1; }
}
#work-title { flex: 1; min-width: 0; }
#work-timer { color: var(--sub); font-size: 12px; font-family: var(--font-num); font-weight: 500; }
#work-toggle {
  font: inherit; font-size: 12px; font-weight: 700; color: var(--primary);
  background: none; border: none; cursor: pointer; padding: 2px 4px;
}
#work-toggle:hover { text-decoration: underline; }
.work-bar { height: 3px; background: var(--line-light); overflow: hidden; }
.work-bar > span {
  display: block; height: 100%; width: 38%; background: var(--primary);
  animation: work-slide 1.5s ease-in-out infinite;
}
#work.done .work-bar > span { width: 100%; animation: none; background: var(--success); }
@keyframes work-slide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(300%); }
}
#work-body { padding: 6px 16px 14px; }
#work.collapsed #work-body { display: none; }

/* 工程の行 */
#timeline .step {
  border: none; background: none; padding: 7px 0; margin: 0;
  border-bottom: 1px solid var(--line-light);
  animation: step-in 0.25s ease-out;
}
#timeline .step:last-child { border-bottom: none; }
@keyframes step-in {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: none; }
}
.step.running .icon::after { content: ""; }
.step.running .icon {
  display: inline-block; width: 13px; height: 13px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--primary);
  animation: spin 0.7s linear infinite; position: relative; top: 2px;
}
@keyframes spin { to { transform: rotate(360deg); } }
.step.running .label { color: var(--primary); font-weight: 700; }

/* 探しに行ったサイト */
#visited { margin-top: 12px; border-top: 1px solid var(--line-light); padding-top: 11px; }
.visited-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; font-weight: 700; color: var(--sub); margin-bottom: 8px;
}
#visited-count { font-family: var(--font-num); color: var(--primary); }
#visited-list { display: flex; flex-wrap: wrap; gap: 6px; }
.site-chip {
  display: inline-flex; align-items: center; gap: 5px; max-width: 260px;
  font-size: 11.5px; line-height: 1.4; padding: 4px 9px;
  border: 1px solid var(--line-light); border-radius: 999px;
  background: var(--bg); color: var(--sub); text-decoration: none;
  animation: chip-in 0.25s ease-out;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
a.site-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.site-chip .site-n { font-family: var(--font-num); font-weight: 700; color: var(--primary); }
.site-chip.official { border-color: #b9c8f5; }
@keyframes chip-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}


/* 本文執筆中のスケルトン */
.skeleton { display: flex; flex-direction: column; gap: 13px; padding: 6px 0; }
.sk-line {
  height: 13px; border-radius: 4px;
  background: linear-gradient(90deg, var(--line-light) 25%, #f3f3f6 37%, var(--line-light) 63%);
  background-size: 400% 100%;
  animation: sk-shimmer 1.4s ease-in-out infinite;
}
.sk-line.w40 { width: 40%; }
.sk-line.w60 { width: 60%; height: 20px; }
.sk-line.w70 { width: 70%; }
.sk-line.w80 { width: 80%; }
@keyframes sk-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

/* ---- 追い質問（チャット形式） ---- */
#chat {
  grid-column: 1 / 2;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px;
  padding: 20px 24px 18px;
}
.chat-title {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; font-weight: 700; color: var(--sub);
  letter-spacing: 0.05em; margin-bottom: 14px;
}
#chat-log { display: flex; flex-direction: column; gap: 12px; }
#chat-log:not(:empty) { margin-bottom: 16px; }
.chat-q {
  align-self: flex-end; max-width: 84%;
  background: var(--primary-light); border: 1px solid #cfe0fb;
  border-radius: 12px 12px 4px 12px; padding: 9px 14px;
  font-size: 14px; font-weight: 500; white-space: pre-wrap;
}
.chat-a { border-left: 3px solid var(--primary); padding: 2px 0 2px 15px; font-size: 14.5px; }
.chat-a p, .chat-a li { margin-bottom: 8px; line-height: 1.85; }
.chat-a > :last-child { margin-bottom: 0; }
.chat-a ul, .chat-a ol { padding-left: 20px; }
.chat-a h3 { font-size: 14.5px; font-weight: 700; margin: 14px 0 6px; }
.chat-a strong { font-weight: 700; background: linear-gradient(transparent 70%, #ffe58a 70%); }
.chat-a table { border-collapse: collapse; margin: 10px 0; font-size: 13px; }
.chat-a th { background: var(--primary-light); }
.chat-a th, .chat-a td { border: 1px solid var(--line); padding: 6px 10px; }
.chat-meta { color: var(--sub); font-size: 11px; font-family: var(--font-num); margin-top: 6px; }
#chat-work { margin: 2px 0 14px; }
.chat-input {
  display: flex; align-items: flex-end; gap: 8px;
  border: 1px solid var(--line); border-radius: 10px;
  padding: 7px 7px 7px 14px; background: #fff;
}
.chat-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
#chat-question {
  flex: 1; border: none; outline: none; resize: none; background: transparent;
  font: inherit; font-size: 14px; line-height: 1.7; color: var(--ink);
  max-height: 140px; padding: 4px 0;
}
#chat-go {
  flex: 0 0 auto; width: 34px; height: 34px; border: none; border-radius: 50%;
  background: var(--primary); color: #fff; display: grid; place-items: center; cursor: pointer;
  transition: background 0.12s;
}
#chat-go:hover { background: var(--primary-hover); }
#chat-go:disabled { background: #b9b9be; cursor: default; }
.chat-hint { color: var(--sub); font-size: 11.5px; margin-top: 8px; }
.source-card.added { border-color: var(--primary); }
.badge.added-b { color: #fff; background: var(--primary); border-color: var(--primary); }

/* ---- レスポンシブ ---- */
@media (max-width: 900px) {
  #app { flex-direction: column; }
  #sidebar { width: 100%; height: auto; position: static; border-right: none; border-bottom: 1px solid var(--line); }
  .side-history { max-height: 180px; }
  #result { grid-template-columns: 1fr; }
  #chat { grid-column: 1 / -1; padding: 18px 16px; }
  #report { padding: 24px; }
  .tb-right { display: none; }
}


/* ============ チャットUI（会話が主役） ============ */
#content { display: flex; flex-direction: column; min-height: calc(100vh - 58px); }
main { flex: 1; padding-bottom: 20px; }
#sidebar #profile {
  width: 100%; font: inherit; font-size: 13px; padding: 7px 9px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--card); color: var(--ink);
}
.side-note { color: var(--sub); font-size: 11px; margin-top: 6px; line-height: 1.6; }
.hb-sub { color: var(--sub); font-size: 13.5px; line-height: 1.8; max-width: 560px; }

#conversation { display: flex; flex-direction: column; gap: 20px; margin-top: 10px; }
.msg-user {
  align-self: flex-end; max-width: 78%;
  background: var(--primary-light); border: 1px solid #cfe0fb;
  border-radius: 14px 14px 4px 14px; padding: 11px 16px;
  font-size: 14.5px; font-weight: 500; white-space: pre-wrap; line-height: 1.7;
}
.msg-ai {
  align-self: stretch; background: var(--card); border: 1px solid var(--line);
  border-radius: 12px; padding: 0; overflow: hidden;
}
.msg-ai .answer { padding: 20px 26px; font-size: 15px; }
.msg-ai .answer:empty { display: none; }
.answer p, .answer li { margin-bottom: 10px; line-height: 1.85; }
.answer > :last-child { margin-bottom: 0; }
.answer ul, .answer ol { padding-left: 22px; }
.answer h3 { font-size: 15px; font-weight: 700; margin: 18px 0 8px; }
.answer strong { font-weight: 700; background: linear-gradient(transparent 70%, #ffe58a 70%); }
.answer table { border-collapse: collapse; margin: 12px 0; font-size: 13.5px; }
.answer th { background: var(--primary-light); }
.answer th, .answer td { border: 1px solid var(--line); padding: 7px 11px; }
.turn-meta { color: var(--sub); font-size: 11px; font-family: var(--font-num); margin-top: 12px; }

/* 1ターンの工程パネル */
.turn-work { border-bottom: 1px solid var(--line-light); }
.turn-work.collapsed .work-body { display: none; }
.turn-work .work-head { display: flex; align-items: center; gap: 10px; padding: 11px 16px; font-size: 13px; font-weight: 700; }
.turn-work .work-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--primary); animation: work-pulse 1.1s ease-in-out infinite; flex: 0 0 auto; }
.turn-work.done .work-dot { background: var(--success); animation: none; }
.turn-work .work-title { flex: 1; min-width: 0; }
.turn-work .work-timer { color: var(--sub); font-size: 12px; font-family: var(--font-num); font-weight: 500; }
.turn-work .work-toggle { font: inherit; font-size: 12px; font-weight: 700; color: var(--primary); background: none; border: none; cursor: pointer; }
.turn-work .work-toggle:hover { text-decoration: underline; }
.turn-work .work-bar { height: 3px; background: var(--line-light); overflow: hidden; }
.turn-work .work-bar > span { display: block; height: 100%; width: 38%; background: var(--primary); animation: work-slide 1.5s ease-in-out infinite; }
.turn-work.done .work-bar > span { width: 100%; animation: none; background: var(--success); }
.turn-work .work-body { padding: 4px 16px 12px; }
.turn-work .timeline .step { border: none; background: none; padding: 7px 0; margin: 0; border-bottom: 1px solid var(--line-light); animation: step-in 0.25s ease-out; }
.turn-work .timeline .step:last-child { border-bottom: none; }
.turn-work .visited { margin-top: 10px; border-top: 1px solid var(--line-light); padding-top: 10px; }
.turn-work .visited-head { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 700; color: var(--sub); margin-bottom: 8px; }
.turn-work .visited-count { font-family: var(--font-num); color: var(--primary); }
.turn-work .visited-list { display: flex; flex-wrap: wrap; gap: 6px; }

/* 次の一手 */
.suggest { padding: 0 20px 18px; display: flex; flex-direction: column; gap: 8px; }
.suggest-row { display: flex; flex-wrap: wrap; align-items: center; gap: 7px; }
.suggest-label { font-size: 11px; font-weight: 700; color: var(--sub); letter-spacing: 0.04em; }
.suggest-chip {
  font: inherit; font-size: 12.5px; padding: 7px 13px; cursor: pointer;
  border: 1px solid var(--line); border-radius: 999px; background: var(--card); color: var(--ink);
  display: inline-flex; align-items: center; gap: 6px; transition: all 0.12s;
}
.suggest-chip:hover { border-color: var(--primary); color: var(--primary); background: var(--primary-light); }
.suggest-chip.deliver { border-color: var(--primary); color: var(--primary); font-weight: 700; }
.suggest-chip.deliver:hover { background: var(--primary); color: #fff; }

/* 成果物カード */
.deliverable { border: 1px solid var(--primary); border-radius: 12px; background: var(--card); overflow: hidden; }
.deliv-head { display: flex; align-items: center; gap: 8px; padding: 11px 16px; background: var(--primary-light); color: var(--primary); font-weight: 700; font-size: 13.5px; }
.deliv-title { flex: 1; }
.deliv-status { font-size: 11px; font-weight: 500; color: var(--sub); font-family: var(--font-num); }
.deliv-body { padding: 22px 26px; font-size: 14.5px; }
.deliv-body h1, .deliv-body h2 { font-size: 17px; font-weight: 700; margin: 20px 0 10px; padding-left: 12px; border-left: 4px solid var(--primary); }
.deliv-body h1:first-child, .deliv-body h2:first-child { margin-top: 0; }
.deliv-body h3 { font-size: 15px; font-weight: 700; margin: 16px 0 6px; }
.deliv-body p, .deliv-body li { margin-bottom: 9px; line-height: 1.85; }
.deliv-body ul, .deliv-body ol { padding-left: 22px; }
.deliv-body strong { font-weight: 700; background: linear-gradient(transparent 70%, #ffe58a 70%); }
.deliv-body table { border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.deliv-body th { background: var(--primary-light); }
.deliv-body th, .deliv-body td { border: 1px solid var(--line); padding: 6px 10px; }
.deliv-foot { padding: 12px 16px; border-top: 1px solid var(--line-light); }
.deliv-foot a {
  font-size: 12.5px; font-weight: 700; color: var(--primary); text-decoration: none;
  border: 1px solid var(--primary); border-radius: 6px; padding: 6px 14px;
}
.deliv-foot a:hover { background: var(--primary); color: #fff; }

/* 出典パネル */
#sources-panel { margin-top: 24px; }
#sources-toggle {
  font: inherit; font-size: 12.5px; font-weight: 700; color: var(--sub);
  background: none; border: none; cursor: pointer; padding: 4px 0;
}
#sources-toggle:hover { color: var(--primary); }
#sources-count { color: var(--primary); font-family: var(--font-num); }
#source-list { margin-top: 10px; display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 6px; }

/* 入力欄（下部固定） */
#composer {
  position: sticky; bottom: 0; z-index: 10;
  background: linear-gradient(180deg, rgba(248,248,251,0) 0%, var(--bg) 22%);
  padding: 14px 28px 18px;
}
#composer form { max-width: 1060px; margin: 0 auto; }
#composer .ask-input {
  display: flex; align-items: flex-end; gap: 10px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px 10px 10px 14px;
  box-shadow: 0 2px 14px rgba(20, 20, 40, 0.06);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#composer .ask-input:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light); }
#composer .ask-icon {
  width: 30px; height: 30px; flex: 0 0 auto; color: var(--sub);
  display: inline-flex; align-items: center; justify-content: center;
  background: transparent; border: none; margin: 0 0 3px 0;
}
#composer textarea {
  flex: 1; min-width: 0; font: inherit; font-size: 15px; line-height: 1.7;
  border: none; outline: none; resize: none; background: transparent; color: var(--ink);
  padding: 6px 0; max-height: 160px;
}
#composer #go {
  width: 38px; height: 38px; border-radius: 50%; flex: 0 0 auto; align-self: flex-end;
}
.composer-note { color: var(--sub); font-size: 11px; text-align: center; margin-top: 8px; }

@media (max-width: 900px) {
  #composer { padding: 10px 14px 14px; }
  .msg-ai .answer, .deliv-body { padding: 16px; }
}

/* ---- 固定資料（プロジェクトのナレッジ） ---- */
#pinned-panel {
  margin-top: 22px; border: 1px solid var(--primary); border-radius: 10px;
  background: var(--primary-light); padding: 12px 14px;
}
.pinned-head {
  display: flex; align-items: center; gap: 6px;
  font-size: 12.5px; font-weight: 700; color: var(--primary); margin-bottom: 9px;
}
#pinned-count { font-family: var(--font-num); }
#pinned-list { display: flex; flex-direction: column; gap: 5px; }
.pinned-item {
  display: flex; align-items: center; gap: 9px;
  background: var(--card); border: 1px solid var(--line-light); border-radius: 7px;
  padding: 8px 11px; font-size: 12.5px;
}
.pinned-item a { color: var(--ink); text-decoration: none; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pinned-item a:hover { color: var(--primary); text-decoration: underline; }
.pin-meta { color: var(--sub); font-size: 11px; font-family: var(--font-num); white-space: nowrap; }
.pin-remove {
  font: inherit; font-size: 11px; color: var(--sub); background: none;
  border: 1px solid var(--line); border-radius: 5px; padding: 3px 8px; cursor: pointer;
}
.pin-remove:hover { color: var(--danger); border-color: var(--danger); }
.suggest-chip.pin { border-style: dashed; }
.suggest-chip.pin.done { border-style: solid; background: var(--primary); color: #fff; border-color: var(--primary); }

/* ---- プロジェクト ---- */
.side-projects { display: flex; flex-direction: column; gap: 2px; margin-bottom: 4px; }
.side-projects .empty { color: var(--sub); font-size: 12.5px; padding: 6px 8px; }
.project-item {
  padding: 8px 10px; border-radius: 7px; cursor: pointer;
  display: flex; flex-direction: column; gap: 3px;
}
.project-item:hover { background: var(--bg); }
.project-item.active { background: var(--primary-light); }
.project-item .q { font-size: 13px; font-weight: 700; }
#project-bar {
  display: flex; align-items: center; gap: 10px; margin-top: 6px;
  padding: 9px 14px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--card); font-size: 12.5px; width: fit-content;
}
.pb-label { color: var(--sub); font-weight: 700; font-size: 11px; letter-spacing: 0.04em; }
#project-name { font-weight: 700; }
#project-add {
  font: inherit; font-size: 11.5px; font-weight: 700; color: var(--primary);
  background: none; border: 1px solid var(--primary); border-radius: 999px;
  padding: 3px 11px; cursor: pointer;
}
#project-add:hover { background: var(--primary); color: #fff; }

/* ================= 会員ゲート ================= */
#auth {
  min-height: calc(100vh - 58px);
  display: flex; align-items: flex-start; justify-content: center;
  padding: 56px 20px 40px;
}
.auth-card {
  width: 100%; max-width: 420px;
  background: var(--card); border: 1px solid var(--line); border-radius: 14px;
  padding: 32px 30px 26px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}
.auth-brand {
  display: flex; align-items: center; gap: 8px;
  font-size: 21px; font-weight: 700; letter-spacing: 0.02em; color: var(--ink);
}
.auth-brand svg { color: var(--primary); }
.auth-lead { color: var(--sub); font-size: 12.5px; line-height: 1.85; margin: 12px 0 22px; }
.auth-tabs { display: flex; gap: 4px; background: var(--bg); border-radius: 9px; padding: 4px; margin-bottom: 20px; }
.auth-tabs button {
  flex: 1; border: 0; background: transparent; border-radius: 6px;
  padding: 9px 0; font-family: inherit; font-size: 13px; font-weight: 600;
  color: var(--sub); cursor: pointer;
}
.auth-tabs button.on { background: var(--card); color: var(--primary); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08); }
#auth-form { display: flex; flex-direction: column; gap: 14px; }
#auth-form label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink); }
#auth-form input, #auth-form select {
  font-family: inherit; font-size: 14px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 8px; padding: 11px 12px; background: var(--card);
  font-weight: 400;
}
#auth-form input:focus, #auth-form select:focus { border-color: var(--primary); }
#auth-go {
  margin-top: 6px; border: 0; border-radius: 8px; background: var(--primary); color: #fff;
  font-family: inherit; font-size: 14.5px; font-weight: 700; padding: 13px 0; cursor: pointer;
}
#auth-go:hover { background: var(--primary-hover); }
#auth-go:disabled { opacity: 0.55; cursor: default; }
#auth-error {
  margin-top: 14px; color: var(--danger); font-size: 12.5px; line-height: 1.7;
  background: #fdecec; border: 1px solid #f5c2c2; border-radius: 8px; padding: 10px 12px;
}
.auth-note { margin-top: 18px; color: #949497; font-size: 11.5px; text-align: center; }

/* サイドバーの会員チップ */
.side-me { margin-top: auto; padding-top: 16px; border-top: 1px solid var(--line-light); }
.me-name { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--ink); }
.me-role {
  font-size: 9.5px; font-weight: 700; letter-spacing: 0.08em;
  background: var(--primary-light); color: var(--primary); border-radius: 4px; padding: 1px 5px;
}
.me-mail {
  font-size: 11px; color: var(--sub); margin-top: 3px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.side-me button {
  margin-top: 9px; border: 1px solid var(--line); background: var(--card); border-radius: 7px;
  font-family: inherit; font-size: 11.5px; color: var(--sub); padding: 6px 11px; cursor: pointer;
}
.side-me button:hover { border-color: var(--primary); color: var(--primary); }
