/* Article-Brief viewer — sidebar + main + LLM drawer (drawer Phase 2).
   Reads static/data/report-index.json + briefs/<slug>.json. */

:root {
  --bg: #f5f6f8;
  --card: #fff;
  --ink: #1a1d22;
  --ink-2: #4b5360;
  --ink-3: #8891a0;
  --line: #e3e6eb;
  --line-2: #edeff2;
  --brand: #2d6af7;
  --hot: #e8602e;
  --hot-soft: #fff1ea;
  --winner: #1f9d6c;
  --winner-soft: #e6f5ee;
  --cold: #6f7786;
  --cold-soft: #eceef2;
  --blocked: #c93852;
  --blocked-soft: #fde9ee;
  --shipped: #8152d9;
  --shipped-soft: #f1ebfb;
  --parked: #2a6a9b;
  --parked-soft: #e6f0f8;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, "Segoe UI", "Noto Sans TC", sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.7;
  font-size: 15px;
}

/* ── Top bar ──────────────────────────────────────────── */
.top {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--card);
  border-bottom: 1px solid var(--line);
  padding: 12px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}
.top .title { font-size: 15px; font-weight: 600; letter-spacing: -0.005em; }
.top .title .snapshot {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 9px;
  border-radius: 4px;
  background: var(--line-2);
  color: var(--ink-2);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0;
}
.top .progress {
  font-size: 13px;
  color: var(--ink-2);
}
.top .progress b {
  color: var(--ink);
  font-weight: 600;
}

/* ── Wrap (sidebar + toggle + main) ───────────────────── */
.wrap {
  display: grid;
  grid-template-columns: 320px 0 1fr;
  max-width: 1440px;
  margin: 0 auto;
  gap: 0;
  position: relative;
  transition: grid-template-columns 0.2s ease;
}
.wrap.sidebar-closed { grid-template-columns: 0 0 1fr; }
@media (max-width: 900px) {
  .wrap { grid-template-columns: 1fr; }
  .sidebar { max-height: 40vh; }
  .sidebar-toggle-btn { display: none; }
}

/* Sidebar collapse toggle button — sits at the seam between sidebar and main */
.sidebar-toggle-btn {
  position: sticky;
  top: 60px;
  align-self: start;
  z-index: 4;
  width: 22px;
  height: 44px;
  padding: 0;
  margin-left: -11px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 0 8px 8px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink-3);
  font-size: 11px;
  font-family: inherit;
  transition: background 0.12s, color 0.12s, transform 0.2s;
  box-shadow: 2px 0 6px rgba(0,0,0,0.04);
}
.sidebar-toggle-btn:hover { background: var(--line-2); color: var(--ink); }
.wrap.sidebar-closed .sidebar-toggle-btn { margin-left: 0; }
.wrap.sidebar-closed .sidebar-toggle-btn .tgl-icon { transform: scaleX(-1); display: inline-block; }

/* ── Sidebar ──────────────────────────────────────────── */
.sidebar {
  position: sticky;
  top: 55px;
  height: calc(100vh - 55px);
  overflow-y: auto;
  padding: 16px 14px;
  border-right: 1px solid var(--line);
  background: var(--card);
  transition: padding 0.2s, opacity 0.15s;
}
.wrap.sidebar-closed .sidebar {
  padding: 0;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
  border-right: 0;
}
.sidebar-search {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  background: #fafbfc;
  margin-bottom: 14px;
}
.sidebar-search:focus {
  outline: none;
  border-color: var(--ink-3);
  background: #fff;
}
.wave-group { margin-bottom: 14px; }
.wave-head {
  margin: 4px 4px 6px;
  padding: 4px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  gap: 8px;
  align-items: center;
  cursor: pointer;
  user-select: none;
  border-radius: 6px;
  transition: background 0.1s;
}
.wave-head:hover { background: var(--line-2); color: var(--ink); }
.wave-head .chev { display: inline-block; transition: transform 0.15s; font-size: 10px; }
.wave-group.open .wave-head .chev { transform: rotate(90deg); }
.wave-head .label { flex: 1; }
.wave-head .count {
  font-weight: 500;
  font-size: 11px;
  letter-spacing: 0;
  color: var(--ink-3);
  text-transform: none;
  background: var(--line-2);
  padding: 2px 7px;
  border-radius: 10px;
}
.wave-body { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 4px; overflow: hidden; transition: max-height 0.2s ease; }
.wave-group.collapsed .wave-body { max-height: 0; }
.wave-group.open .wave-body { max-height: none; }
.brief-card {
  display: grid;
  grid-template-columns: 16px 8px 1fr auto;  /* +16px for checkbox column */
  gap: 8px;
  align-items: center;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.1s, border-color 0.1s;
}
.batch-select-cb {
  cursor: pointer; margin: 0;
  width: 14px; height: 14px;
}
.llm-done-icon {
  color: #f59e0b; font-size: 13px; margin-right: 2px;
  display: inline-block; cursor: help;
}
.advisor-done-icon {
  font-size: 12px; margin-right: 4px;
  display: inline-block; cursor: help; opacity: 0.85;
}
.batch-select-action {
  color: var(--brand); text-decoration: underline; font-size: 11px;
}
.batch-select-action:hover { opacity: 0.8; }
.brief-card:hover {
  background: #fafbfc;
  border-color: var(--line);
}
.brief-card.current {
  background: var(--line-2);
  border-color: var(--ink-3);
}
.brief-card .pool-dot {
  width: 8px; height: 8px; border-radius: 50%;
  margin-top: 3px;
}
.brief-card .pool-dot.hot { background: var(--hot); }
.brief-card .pool-dot.winner { background: var(--winner); }
.brief-card .pool-dot.cold { background: var(--cold); }
.brief-card .pool-dot.blocked { background: var(--blocked); }
.brief-card .pool-dot.shipped { background: var(--shipped); }
.brief-card .pool-dot.parked { background: var(--parked); }
.brief-card .pool-dot.unknown { background: var(--ink-3); }

.brief-card .meta { min-width: 0; }
.brief-card .h1 {
  font-size: 13px;
  font-weight: 500;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.brief-card .sub {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brief-card .ai {
  display: flex; flex-direction: column; align-items: flex-end; gap: 3px;
  flex: 0 0 auto;
}
.brief-card .ai .ai-num {
  font-size: 10px;
  color: var(--ink-2);
  background: var(--line-2);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.brief-card .score-tag {
  font-size: 10px; font-weight: 700;
  color: var(--hot);
  background: var(--hot-soft);
  padding: 2px 6px; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.brief-card .aid {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--line-2);
  padding: 0 5px;
  border-radius: 3px;
  font-size: 10px;
  color: var(--ink-2);
}

/* Inbound badge — flags inbound coverage at sidebar level (orphan / low / ok). */
.brief-card .link-badge {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
}
.brief-card .link-badge.orphan {
  background: var(--blocked-soft, rgba(220, 38, 38, 0.10));
  color: var(--blocked, #dc2626);
}
.brief-card .link-badge.low {
  background: var(--parked-soft, rgba(234, 179, 8, 0.12));
  color: var(--parked, #b45309);
}
.brief-card .link-badge.ok {
  background: var(--shipped-soft, rgba(22, 163, 74, 0.10));
  color: var(--shipped, #16a34a);
}

/* Tier badge — link-equity classification A/B/C/D/X. Click → /links-report. */
.brief-card .tier-badge {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
  text-decoration: none;
  cursor: pointer;
}
.brief-card .tier-badge:hover { transform: translateY(-1px); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }
.brief-card .tier-badge.tier-A { background: rgba(220, 38, 38, 0.12); color: #c33; }
.brief-card .tier-badge.tier-B { background: rgba(234, 179, 8, 0.15); color: #b46500; }
.brief-card .tier-badge.tier-C { background: rgba(234, 200, 8, 0.10); color: #806300; }
.brief-card .tier-badge.tier-D { background: rgba(120, 120, 120, 0.10); color: #555; }
.brief-card .tier-badge.tier-X { background: rgba(22, 163, 74, 0.10); color: #2e7d32; }

/* HTML preview / edit pane — tab-style: when active it REPLACES the
   markdown body in the same slot, not appended below. Only one of
   .diff-body-md / .diff-html-pane is visible at a time, controlled by
   the parent .diff-body-stack[data-view] attribute. */
.diff-body-stack[data-view="md"]   .diff-html-pane { display: none; }
.diff-body-stack[data-view="md"]   .diff-body-md   { display: block; }
.diff-body-stack[data-view="html"] .diff-body-md   { display: none; }
.diff-body-stack[data-view="html"] .diff-html-pane { display: block; }

.diff-html-pane {
  border: 1px solid #c7d2fe;
  border-radius: 6px;
  background: #f8fafc;
  overflow: hidden;
}
.diff-html-pane.mode-edit { border-color: #fcd34d; background: #fffef0; }
.diff-html-pane-head {
  display: flex; align-items: center; gap: 8px;
  padding: 5px 10px;
  background: #eef2ff;
  border-bottom: 1px solid #e0e7ff;
  font-size: 11px; color: #4338ca;
}
.diff-html-pane.mode-edit .diff-html-pane-head { background: #fef3c7; border-color: #fde68a; color: #92400e; }
.diff-html-pane-mode { flex: 1; font-weight: 500; }
.diff-html-pane-head button {
  background: #fff; border: 1px solid #c7d2fe; color: #4338ca;
  padding: 2px 8px; font-size: 11px; border-radius: 4px; cursor: pointer;
  font-family: inherit;
}
.diff-html-pane-head button:hover { background: #e0e7ff; }
.diff-html-pane-close {
  background: #fff !important; padding: 2px 8px !important; line-height: 1; font-size: 11px !important;
}
.diff-html-pane-body {
  padding: 12px 16px;
  font-family: -apple-system, system-ui, sans-serif;
  font-size: 13.5px; line-height: 1.65; color: #1f2937;
  background: #fff;
  outline: none;
  max-height: 460px; overflow-y: auto;
}
.diff-html-pane.mode-edit .diff-html-pane-body { background: #fffef0; }
.diff-html-pane.mode-edit .diff-html-pane-body:focus { box-shadow: inset 0 0 0 2px #fcd34d; }
.diff-html-pane-body.show-source {
  background: #1e1e2e !important; color: #e5e7eb;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px;
  white-space: pre-wrap; word-break: break-word;
}
.diff-html-pane-body h1, .diff-html-pane-body h2, .diff-html-pane-body h3 {
  margin: 12px 0 5px; line-height: 1.35; color: #0f172a;
}
.diff-html-pane-body h1 { font-size: 20px; font-weight: 700; }
.diff-html-pane-body h2 { font-size: 16px; font-weight: 600; }
.diff-html-pane-body h3 { font-size: 14.5px; font-weight: 600; }
.diff-html-pane-body p  { margin: 6px 0 8px; }
.diff-html-pane-body ul, .diff-html-pane-body ol { margin: 6px 0 10px; padding-left: 24px; }
.diff-html-pane-body li { margin: 2px 0; }
.diff-html-pane-body a  { color: #1d4ed8; text-decoration: underline; }
.diff-html-pane-body code { background: #f3f4f6; padding: 1px 5px; border-radius: 3px; font-size: 12.5px; }
.diff-html-pane-body table { border-collapse: collapse; margin: 8px 0; }
.diff-html-pane-body th, .diff-html-pane-body td {
  border: 1px solid #e5e7eb; padding: 5px 10px; font-size: 13px;
}
/* Highlight the active toggle so user sees which pane mode is open. */
.diff-html-toggle.active {
  background: #4338ca !important; color: #fff !important; border-color: #4338ca !important;
}

/* Outbound suggestion progress badge — supports the "持續部署 outbound"
   workflow: editors open one article at a time, accept 1-2 outbound
   suggestions, move on. Badge surfaces "are there candidates here?" */
.brief-card .outbound-progress-badge {
  display: inline-block;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 3px;
  margin-right: 4px;
  vertical-align: middle;
  background: rgba(180, 83, 9, 0.10);
  color: #b45309;
}
.brief-card .outbound-progress-badge .op-icon {
  margin-right: 2px;
}

/* Page-type icon — marks supplemental-crawled pages (product / about / etc.)
   so they're visually distinct from real advisor-brief articles. */
.brief-card .page-type-icon {
  display: inline-block;
  font-size: 13px;
  margin-right: 4px;
  vertical-align: middle;
  opacity: 0.85;
  cursor: help;
}

/* Link-health banner at sidebar top — at-a-glance project link state. */
.link-health-banner {
  cursor: pointer;
  user-select: none;
  margin: 8px 12px 12px;
  padding: 10px 12px;
  border: 1px solid var(--line-2);
  border-left: 3px solid var(--blocked, #dc2626);
  border-radius: 6px;
  background: var(--bg-1, #fff);
  transition: background 0.15s ease;
}
.link-health-banner:hover { background: var(--line-2); }
.link-health-banner.active {
  background: var(--blocked-soft, rgba(220, 38, 38, 0.08));
  border-color: var(--blocked, #dc2626);
}
.link-health-banner .lhb-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: var(--ink-2);
}
.link-health-banner .lhb-num {
  font-size: 18px;
  font-weight: 700;
  color: var(--blocked, #dc2626);
}
.link-health-banner .lhb-label { color: var(--ink); }
.link-health-banner .lhb-frac { color: var(--ink-3); font-size: 11px; }
.link-health-banner .lhb-sub {
  margin-top: 4px;
  font-size: 11px;
  color: var(--ink-3);
}

/* When orphan filter is active, hide non-orphan cards. */
#sidebar-body.orphan-filter .brief-card:not(:has(.link-badge.orphan)) {
  display: none;
}

/* Sidebar filter toolbar (under the search input). */
.sidebar-filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 12px 8px;
}
.sf-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--ink-2);
  background: var(--bg-1, #fff);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}
.sf-pill:hover { background: var(--line-2); }
.sf-pill.active {
  background: var(--accent-soft, rgba(37, 99, 235, 0.1));
  border-color: var(--accent, #2563eb);
  color: var(--accent, #2563eb);
  font-weight: 600;
}

/* When "has suggestion" filter is active, hide cards without ⚡ or 👤. */
#sidebar-body.has-suggestion-filter .brief-card:not(:has(.llm-done-icon)):not(:has(.advisor-done-icon)) {
  display: none;
}

/* how-to-read section (mirrors mockup.html Card 1 "這頁怎麼讀") */
.how-to-read .how-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--line-2);
}
.how-to-read .how-item:first-of-type { padding-top: 4px; }
.how-to-read .how-item:last-of-type { padding-bottom: 4px; border-bottom: 0; }
.how-head { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; margin-bottom: 4px; }
.how-item .tag {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  background: var(--line-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.how-item .tag.good { background: var(--winner-soft); color: var(--winner); }
.how-item .tag.warn { background: var(--hot-soft);    color: var(--hot); }
.how-item .tag.bad  { background: var(--blocked-soft); color: var(--blocked); }
.how-item .tag.info { background: var(--parked-soft); color: var(--parked); }
.how-item .reading { font-size: 14px; font-weight: 500; color: var(--ink); line-height: 1.45; }
.how-item .meaning { font-size: 13px; color: var(--ink-2); margin: 3px 0 0 0; padding-left: 0; line-height: 1.65; }

/* article_id chip shared */
.aid {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--line-2);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--ink-2);
}

/* Sidebar top batch bar — triggers 6-page batch LLM generation */
.batch-bar {
  margin: 0 2px 14px;
  padding: 10px 12px;
  border: 1px dashed var(--hot);
  border-radius: 8px;
  background: var(--hot-soft);
}
.btn-llm-batch {
  width: 100%;
  padding: 8px 10px;
  font: 500 13px inherit;
  border: 1px solid var(--hot);
  background: var(--card);
  color: var(--hot);
  border-radius: 6px;
  cursor: pointer;
}
.btn-llm-batch:hover:not(:disabled) { background: #ffe5d4; }
.btn-llm-batch:disabled { opacity: 0.55; cursor: wait; }
.batch-hint {
  font-size: 10px;
  color: var(--ink-3);
  margin-top: 6px;
  text-align: center;
}
.batch-hint code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  background: var(--card);
  padding: 1px 5px;
  border-radius: 3px;
}

/* Takeaway 下方的 LLM 觸發按鈕 */
.takeaway-actions { margin-top: 12px; display: flex; justify-content: flex-end; }
.btn-llm-generate {
  font-family: inherit;
  font-size: 12px;
  font-weight: 600;
  padding: 7px 14px;
  border-radius: 7px;
  border: 1px solid var(--hot);
  background: var(--card);
  color: var(--hot);
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.btn-llm-generate:hover:not(:disabled) { background: var(--hot-soft); }
.btn-llm-generate:disabled { opacity: 0.6; cursor: wait; }

/* Sticky LLM progress bar — bottom-right floating */
.llm-progress-bar {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 440px;
  max-width: calc(100vw - 40px);
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
  z-index: 200;
  font-size: 13px;
  animation: llm-slide-up 0.2s ease;
}
@keyframes llm-slide-up {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}
.llm-progress-bar .llm-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 8px;
}
.llm-progress-bar .llm-title {
  font-weight: 600;
  color: var(--ink);
  flex: 1;
}
.llm-progress-bar .llm-jobid {
  color: var(--ink-3);
  font-size: 11px;
}
.llm-progress-bar .llm-jobid code {
  background: var(--line-2);
  padding: 1px 6px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--ink-2);
}
.llm-progress-bar .llm-close {
  background: transparent;
  border: 0;
  cursor: pointer;
  color: var(--ink-3);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.llm-progress-bar .llm-close:hover { background: var(--line-2); color: var(--ink); }

.llm-progress-bar .llm-hint {
  font-size: 11px;
  color: var(--ink-3);
  margin-bottom: 6px;
  line-height: 1.45;
}
.llm-progress-bar .llm-cli-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
  margin-bottom: 10px;
}
.llm-progress-bar .llm-cli {
  flex: 1;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  overflow-x: auto;
  white-space: nowrap;
  color: var(--ink);
}
.llm-progress-bar .llm-copy-btn {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 6px;
  padding: 4px 10px;
  cursor: pointer;
  font-size: 11px;
  font-family: inherit;
}
.llm-progress-bar .llm-copy-btn:hover { background: var(--line-2); }

.llm-progress-bar .llm-bar-track {
  background: var(--line-2);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 6px;
}
.llm-progress-bar .llm-bar-fill {
  background: var(--hot);
  height: 100%;
  transition: width 0.3s ease, background 0.3s;
}
.llm-progress-bar .llm-bar-fill.ok   { background: var(--winner); }
.llm-progress-bar .llm-bar-fill.fail { background: var(--blocked); }

.llm-progress-bar .llm-status {
  font-size: 12px;
  color: var(--ink-2);
  font-weight: 500;
}
.llm-progress-bar .llm-status code {
  background: var(--line-2);
  padding: 0 5px;
  border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
}

/* Subtitle divider inside the merged 📝 建議改動 section */
.sug-subtitle {
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin: 0 0 10px;
  padding-bottom: 6px;
  border-bottom: 1px dashed var(--line-2);
}

/* TODO checkboxes (derived from rule_suggestions; state in localStorage) */
.todo-list { list-style: none; padding: 0; margin: 0; }
.todo-item {
  display: grid;
  grid-template-columns: 24px 1fr;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px dashed var(--line-2);
}
.todo-item:last-child { border-bottom: 0; }
.todo-item.done .todo-title-text { text-decoration: line-through; color: var(--ink-3); }
.todo-item.done .todo-sub { opacity: 0.5; }
.todo-check { cursor: pointer; padding-top: 2px; }
.todo-check input { opacity: 0; position: absolute; width: 18px; height: 18px; cursor: pointer; }
.todo-check .check-fake {
  display: block; width: 18px; height: 18px;
  border: 2px solid var(--line); border-radius: 4px; background: var(--card);
  transition: background 0.1s, border-color 0.1s;
}
.todo-check input:checked + .check-fake {
  background: var(--winner); border-color: var(--winner);
}
.todo-check input:checked + .check-fake::after {
  content: "✓"; color: #fff; font-size: 12px; font-weight: bold;
  display: block; text-align: center; line-height: 14px;
}
.todo-body { min-width: 0; }
.todo-head {
  display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap;
  margin-bottom: 3px;
}
.todo-pri {
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  padding: 2px 7px; border-radius: 4px; color: #fff; background: var(--ink);
}
.todo-pri.hot { background: var(--hot); }
.todo-pri.parked { background: var(--parked); }
.todo-pri.cold { background: var(--cold); }
.todo-title-text { font-size: 14px; font-weight: 600; color: var(--ink); flex: 1; min-width: 200px; }
.todo-effort { font-size: 11px; color: var(--ink-3); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.todo-sub { font-size: 12px; color: var(--ink-2); line-height: 1.55; }
.todo-verify {
  font-size: 12px;
  color: var(--ink-2);
  margin-top: 6px;
  padding: 5px 10px;
  border-left: 2px solid var(--winner);
  background: #fafbfc;
  border-radius: 0 4px 4px 0;
  line-height: 1.55;
}
.todo-verify b {
  color: var(--winner);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-right: 6px;
  display: inline-block;
  vertical-align: baseline;
}

/* Rule-based auto suggestions (mirrors mockup Card 1 TODO list style) */
.suggestions-section .rule-card, .rule-suggestions .rule-card {
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  margin-bottom: 10px;
}
.rule-card[data-priority="P1"] { border-left: 3px solid var(--hot); }
.rule-card[data-priority="P2"] { border-left: 3px solid var(--parked); }
.rule-card[data-priority="P3"] { border-left: 3px solid var(--cold); }
.rule-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.rule-pri {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 2px 8px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
}
.rule-pri.hot { background: var(--hot); }
.rule-pri.parked { background: var(--parked); }
.rule-pri.cold { background: var(--cold); }
.rule-title { font-size: 14px; font-weight: 600; color: var(--ink); flex: 1; min-width: 200px; }
.rule-effort { font-size: 11px; color: var(--ink-3); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.rule-reason, .rule-action { font-size: 12.5px; color: var(--ink-2); margin: 3px 0; line-height: 1.6; }
.rule-reason b, .rule-action b {
  display: inline-block;
  min-width: 52px;
  font-size: 10px;
  font-weight: 600;
  color: var(--ink-3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-right: 6px;
  vertical-align: baseline;
}

/* ── Main ─────────────────────────────────────────────── */
.main {
  padding: 28px 36px 80px;
  min-width: 0;
}
.empty {
  text-align: center;
  color: var(--ink-3);
  padding: 80px 20px;
  font-size: 14px;
}

.breadcrumb {
  font-size: 12px;
  color: var(--ink-3);
  margin-bottom: 10px;
}
.breadcrumb a {
  color: var(--brand);
  text-decoration: none;
}
.breadcrumb a:hover { text-decoration: underline; }
.pool-badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.pool-badge.hot { background: var(--hot-soft); color: var(--hot); }
.pool-badge.winner { background: var(--winner-soft); color: var(--winner); }
.pool-badge.cold { background: var(--cold-soft); color: var(--cold); }
.pool-badge.blocked { background: var(--blocked-soft); color: var(--blocked); }
.pool-badge.shipped { background: var(--shipped-soft); color: var(--shipped); }
.pool-badge.parked { background: var(--parked-soft); color: var(--parked); }

/* ── 頁首 2 欄 (左: H1/URL/locale · 右: effort/impact/actions card) ── */
.brief-head-2col {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 20px;
  align-items: start;
  margin: 6px 0 18px;
}
.brief-head-left { min-width: 0; }
.brief-head-right { min-width: 260px; }
@media (max-width: 780px) {
  .brief-head-2col { grid-template-columns: 1fr; }
}

.effort-card {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fafbfc;
  font-size: 13px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.effort-row {
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.effort-row .effort-label {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  min-width: 60px;
}
.effort-row .effort-value { font-weight: 500; color: var(--ink); }
.effort-row .effort-value b {
  display: inline-block;
  padding: 1px 9px;
  border-radius: 4px;
  background: var(--ink);
  color: #fff;
  font-size: 12px;
  letter-spacing: 0.04em;
  margin-right: 4px;
}
.effort-row .effort-value.good { color: var(--winner); }
.effort-actions {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.btn-sm { padding: 5px 10px !important; font-size: 12px !important; }
.btn-action {
  font-family: inherit;
  padding: 5px 10px;
  font-size: 12px;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink-2);
  border-radius: 6px;
  cursor: pointer;
}
.btn-action:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-action:hover:not(:disabled) { border-color: var(--ink-3); background: var(--line-2); }

/* Locale chips (mockup parity) */
.locale-bar { display: flex; gap: 6px; margin: 10px 0 0; flex-wrap: wrap; }
.locale-chip {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 11px; border-radius: 999px;
  background: #fff; border: 1px solid var(--line);
  color: var(--ink-2); font-size: 12px; text-decoration: none;
  transition: all 0.12s;
}
.locale-chip:hover { background: var(--line-2); color: var(--ink); border-color: var(--ink-3); }
.locale-chip.current { background: var(--ink); color: #fff; border-color: var(--ink); }
.locale-chip.missing { color: var(--ink-3); background: #fafbfc; cursor: not-allowed; opacity: 0.55; }
.locale-chip .ext { font-size: 10px; opacity: 0.7; }

.brief-h1 {
  font-size: 24px;
  margin: 4px 0 2px;
  letter-spacing: -0.01em;
  line-height: 1.3;
}
/* subline: the page's original H1 shown below the advisor-voice headline */
.brief-subline {
  font-size: 14px;
  color: var(--ink-3);
  margin: 0 0 10px;
  font-weight: 400;
  line-height: 1.4;
}

/* URL chip: path text + open-external + copy buttons (mockup line 354-358 parity) */
.brief-url {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--ink-3);
  margin: 0;
}
.brief-url .url-path {
  background: transparent;
  padding: 1px 0;
  color: inherit;
  border-bottom: 1px dashed transparent;
}
.brief-url .url-path:hover { border-bottom-color: var(--brand); color: var(--brand); }
.brief-url .url-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 4px;
  color: var(--ink-3);
  text-decoration: none;
  font-size: 11px;
  border: 0; background: transparent; padding: 0;
  cursor: pointer; font-family: inherit;
  transition: background 0.1s, color 0.1s;
}
.brief-url .url-icon:hover { background: var(--line-2); color: var(--brand); }
.brief-url .url-copy.copied { color: var(--winner); }

/* Footnote (mockup line 572 parity) */
.footnote {
  font-size: 12px;
  color: var(--ink-3);
  padding: 14px 22px;
  background: #fafbfc;
  border: 1px solid var(--line-2);
  border-radius: 10px;
  margin-top: 18px;
  line-height: 1.7;
}
.footnote code {
  background: var(--line-2);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
  color: var(--ink-2);
}

/* Takeaway */
.takeaway-box {
  background: var(--hot-soft);
  border-left: 3px solid var(--hot);
  border-radius: 0 10px 10px 0;
  padding: 14px 18px;
  margin: 12px 0 20px;
}
.takeaway-box .label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--hot);
  margin-bottom: 4px;
}
.takeaway-box .text { font-size: 15px; font-weight: 500; color: var(--ink); }
.takeaway-box .text.placeholder { font-style: italic; color: var(--ink-3); font-weight: 400; }

/* Metrics */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 0;
  background: #fafbfc;
  border: 1px solid var(--line);
  border-radius: 12px;
  margin-bottom: 22px;
  overflow: hidden;
}
@media (max-width: 700px) { .metrics-grid { grid-template-columns: repeat(2, 1fr); } }
.metric-box {
  padding: 14px 18px;
  border-right: 1px solid var(--line-2);
}
.metric-box:last-child { border-right: 0; }
.metric-box .label {
  font-size: 11px;
  color: var(--ink-3);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.metric-box .value {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin: 2px 0;
}
.metric-box .value.good { color: var(--winner); }
.metric-box .value.warn { color: var(--hot); }
.metric-box .value.bad { color: var(--blocked); }
.metric-box .value.muted { color: var(--ink-3); font-weight: 500; }
.metric-box .sub { font-size: 12px; color: var(--ink-3); }

/* Body 2-column grid (mockup .body parity: how-to-read 左 / todo 右) */
.body-2col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow: hidden;
  margin-bottom: 18px;
}
.body-2col > section {
  border-radius: 0 !important;
  border: 0 !important;
  margin-bottom: 0 !important;
}
.body-2col > section + section {
  border-left: 1px solid var(--line-2) !important;
}
@media (max-width: 780px) {
  .body-2col { grid-template-columns: 1fr; }
  .body-2col > section + section {
    border-left: 0 !important;
    border-top: 1px solid var(--line-2) !important;
  }
}

/* Link-flow 3-col (mockup parity) */
.link-flow {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0;          /* removed: padding lives on summary + body now */
  margin-bottom: 18px;
}
/* <summary> is the click target for the <details>. Remove the default ▶
   marker; we render our own toggle hint in the summary. */
.link-flow > summary { list-style: none; cursor: pointer; }
.link-flow > summary::-webkit-details-marker { display: none; }

.link-flow-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px;
  padding: 14px 22px;
  user-select: none;
}
.link-flow[open] .link-flow-head { border-bottom: 1px solid var(--line); }
.link-flow-head:hover { background: var(--line-2); }
.link-flow[open] .link-flow-head:hover { background: transparent; }

.link-flow-head h3 {
  margin: 0; font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--ink-3);
}
.link-flow-counts { display: flex; gap: 12px; flex: 1; }
.lf-count {
  font-size: 12px; color: var(--ink-2);
  padding: 2px 8px; border-radius: 4px; background: var(--line-2);
}
.lf-count b { color: var(--ink); font-weight: 700; }
.lf-count.existing      { background: #fff1ea; }   /* hot soft  → 已連入 */
.lf-count.todo-in       { background: #e8efff; }   /* brand soft → 建議連入 */
.lf-count.existing-out  { background: #e6f5ee; }   /* winner soft → 連出 */
.lf-count.todo-out      { background: #fff3e0; }   /* parked soft → 建議連出 */
.link-flow-toggle-hint {
  font-size: 11px; color: var(--ink-3);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.link-flow-body { padding: 14px 22px 18px; }
.link-flow-body .hint { font-size: 12px; color: var(--ink-3); display: block; margin-bottom: 10px; }
.link-flow-body .hint code {
  background: var(--line-2); padding: 1px 5px; border-radius: 3px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 11px;
}
.link-cols {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}
@media (min-width: 1280px) { .link-cols { grid-template-columns: repeat(4, 1fr); } }
@media (max-width: 900px) { .link-cols { grid-template-columns: 1fr; } }
.link-col {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
}
.link-col-title {
  font-size: 13px; font-weight: 600; margin: 0 0 4px;
  display: flex; align-items: center; gap: 6px;
}
.link-col-title .mini {
  font-size: 11px; font-weight: 500; padding: 1px 6px;
  border-radius: 4px; background: var(--line-2); color: var(--ink-2);
}
.link-col-title.existing      { color: var(--winner); }
.link-col-title.existing .mini{ background: var(--winner-soft); color: var(--winner); }
.link-col-title.todo-in       { color: var(--hot); }
.link-col-title.todo-in .mini { background: var(--hot-soft); color: var(--hot); }
.link-col-title.existing-out  { color: var(--shipped); }
.link-col-title.existing-out .mini { background: var(--shipped-soft); color: var(--shipped); }
.link-col-title.todo-out      { color: var(--parked, #b45309); }
.link-col-title.todo-out .mini { background: var(--parked-soft, #fff3e0); color: var(--parked, #b45309); }
.link-col-sub { font-size: 12px; color: var(--ink-3); margin: 0 0 10px; }
.link-item { padding: 8px 0; border-bottom: 1px dashed var(--line-2); }
.link-item:last-child { border-bottom: 0; }
.link-item .link-title { font-size: 13px; font-weight: 500; color: var(--ink); margin: 0; }
.link-item .link-path {
  font-size: 11px; color: var(--ink-3); display: block; margin-top: 1px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace; word-break: break-all;
}
.link-item .link-why { font-size: 12px; color: var(--ink-2); margin: 4px 0 0; }
.link-item .anchor-hint {
  display: inline-block; margin-top: 5px; font-size: 11px;
  padding: 2px 7px; background: var(--line-2); border-radius: 4px;
  color: var(--ink-2); font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.link-item .anchor-hint b { color: var(--ink); }

/* Section */
.section {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 18px 22px;
  margin-bottom: 18px;
}
.section h3 {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--ink-3);
  display: flex;
  justify-content: space-between;
  align-items: baseline;
}
.section h3 .total {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0;
  text-transform: none;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}

/* AI friendliness signals */
.signals { display: flex; flex-direction: column; gap: 10px; }
.signal {
  display: grid;
  grid-template-columns: 110px 1fr 42px;
  gap: 12px;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-2);
}
.signal:last-child { border-bottom: 0; }
.signal .sig-name { font-size: 13px; color: var(--ink-2); }
.signal .sig-bar {
  background: var(--line-2);
  height: 6px;
  border-radius: 3px;
  overflow: hidden;
}
.signal .sig-fill {
  background: linear-gradient(90deg, var(--blocked) 0%, var(--hot) 40%, var(--winner) 80%);
  height: 100%;
  border-radius: 3px;
}
.signal .sig-score {
  font-size: 13px;
  font-weight: 600;
  text-align: right;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.signal .sig-evidence {
  grid-column: 1 / -1;
  font-size: 11px;
  color: var(--ink-3);
  padding-left: 0;
  margin-top: -2px;
}

/* Suggestions */
.suggestion-card {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--card);
  margin-bottom: 10px;
}
.suggestion-card .sug-head {
  display: flex;
  gap: 10px;
  align-items: baseline;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.sug-file { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 12px; font-weight: 600; color: var(--ink); }
.sug-method {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 4px;
  background: var(--winner-soft);
  color: var(--winner);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
}
.sug-method.filename, .sug-method.h1_substring { background: var(--hot-soft); color: var(--hot); }
.sug-method.embedding { background: var(--shipped-soft); color: var(--shipped); }
.sug-score { font-size: 11px; color: var(--ink-3); font-family: ui-monospace, "SF Mono", Menlo, monospace; }
.sug-reason { font-size: 13px; color: var(--ink-2); margin: 4px 0 8px; }

.sug-content-wrap { border-top: 1px solid var(--line-2); padding-top: 10px; margin-top: 8px; }
.sug-content-wrap > summary { font-size: 12px; color: var(--ink-3); cursor: pointer; font-weight: 500; padding: 4px 0; list-style: none; }
.sug-content-wrap > summary::-webkit-details-marker { display: none; }
.sug-content-wrap > summary::before { content: "▸ "; display: inline-block; transition: transform 0.15s; }
.sug-content-wrap[open] > summary::before { transform: rotate(90deg); }
.sug-content-wrap > summary:hover { color: var(--ink); }
.sug-content { margin-top: 12px; padding: 14px 16px; background: var(--bg); border-radius: 8px; border-left: 3px solid var(--brand); }
.sug-content.md-body { font-size: 13px; line-height: 1.7; }

/* Outbound links */
.outbound ul { list-style: none; padding: 0; margin: 0; }
.outbound li {
  padding: 8px 0;
  border-bottom: 1px dashed var(--line-2);
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.outbound li:last-child { border-bottom: 0; }
.outbound li a {
  color: var(--ink);
  text-decoration: none;
  font-size: 14px;
  border-bottom: 1px dashed transparent;
  width: fit-content;
}
.outbound li a:hover { color: var(--brand); border-bottom-color: var(--brand); }
.outbound li .path {
  font-size: 11px;
  color: var(--ink-3);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  word-break: break-all;
}

/* Content markdown render */
.md-body { font-size: 14px; line-height: 1.75; }
.md-body h1 { font-size: 19px; margin: 0 0 14px; letter-spacing: -0.01em; }
.md-body h2 { font-size: 16px; margin: 22px 0 10px; letter-spacing: -0.005em; }
.md-body h3 { font-size: 14px; margin: 16px 0 6px; color: var(--ink-2); }
.md-body p { margin: 0 0 10px; }
.md-body a { color: var(--brand); text-decoration: none; border-bottom: 1px solid transparent; }
.md-body a:hover { border-bottom-color: var(--brand); }
.md-body ul, .md-body ol { padding-left: 22px; margin: 4px 0 10px; }
.md-body li { margin: 3px 0; }
.md-body table { width: 100%; border-collapse: collapse; margin: 8px 0 14px; font-size: 13px; }
.md-body th, .md-body td { border: 1px solid var(--line); padding: 8px 10px; text-align: left; vertical-align: top; }
.md-body th { background: #f0f3f7; font-weight: 600; }
.md-body hr { border: 0; border-top: 1px solid var(--line-2); margin: 16px 0; }
.md-body blockquote {
  margin: 10px 0;
  padding: 10px 14px;
  background: var(--line-2);
  border-left: 3px solid var(--ink-3);
  border-radius: 0 6px 6px 0;
}

/* ─────────────────────────────────────────────────────────
   Notes modal (per-article, localStorage) — mirrors mockup.html .notes-modal
   ──────────────────────────────────────────────────────── */
.notes-count-badge { font-size: 10px; color: var(--ink-3); margin-left: 2px; }

.notes-modal,
.download-modal {
  position: fixed; inset: 0; background: rgba(26, 29, 34, 0.55);
  display: none; align-items: center; justify-content: center;
  z-index: 110; padding: 20px;
}
.notes-modal.open,
.download-modal.open { display: flex; }

.notes-modal-content {
  background: #fff; border-radius: 14px; width: 100%; max-width: 560px;
  max-height: 80vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.notes-modal-head {
  padding: 16px 22px; border-bottom: 1px solid var(--line-2);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.notes-modal-head h2 { margin: 0; font-size: 16px; letter-spacing: -0.005em; }
.notes-modal-head p { margin: 3px 0 0; font-size: 12px; color: var(--ink-3); }
.notes-modal-close,
.download-modal-close {
  background: transparent; border: 0; font-size: 22px; cursor: pointer;
  color: var(--ink-3); padding: 4px 10px; border-radius: 6px; line-height: 1;
}
.notes-modal-close:hover,
.download-modal-close:hover { background: var(--line-2); color: var(--ink); }

.notes-modal-body { flex: 1; overflow-y: auto; padding: 16px 22px 18px; }

.notes-input-simple {
  display: flex; flex-direction: column; gap: 8px;
  margin-bottom: 18px; padding-bottom: 18px;
  border-bottom: 1px solid var(--line-2);
}
.notes-input-simple textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; font-family: inherit; font-size: 14px;
  line-height: 1.55; resize: vertical; min-height: 72px; outline: none;
  color: var(--ink); background: #fafbfc;
  box-sizing: border-box;
}
.notes-input-simple textarea:focus { border-color: var(--ink-2); background: #fff; }
.notes-input-simple button {
  align-self: flex-end; padding: 6px 16px; background: var(--ink); color: #fff;
  border: 0; border-radius: 6px; font-size: 13px; cursor: pointer;
}
.notes-input-simple button:hover:not(:disabled) { background: var(--ink-2); }
.notes-input-simple button:disabled { opacity: 0.4; cursor: not-allowed; }

.notes-list-simple { display: flex; flex-direction: column; gap: 14px; }
.note-item-simple { position: relative; padding-right: 28px; }
.note-item-simple .note-text {
  font-size: 14px; color: var(--ink); line-height: 1.65;
  white-space: pre-wrap; word-break: break-word;
}
.note-item-simple .note-time-simple { font-size: 11px; color: var(--ink-3); margin-top: 5px; }
.note-item-simple .note-del {
  position: absolute; top: -2px; right: 0;
  background: transparent; border: 0; color: var(--ink-3); cursor: pointer;
  padding: 3px 7px; font-size: 14px; border-radius: 4px;
  opacity: 0; transition: opacity 0.12s; line-height: 1;
}
.note-item-simple:hover .note-del { opacity: 1; }
.note-item-simple .note-del:hover { background: var(--blocked-soft, #ffeae0); color: var(--blocked); }
.notes-empty-simple {
  color: var(--ink-3); font-size: 13px; text-align: center; padding: 24px 0;
}

/* ─────────────────────────────────────────────────────────
   Download modal — mirrors mockup.html .download-modal
   ──────────────────────────────────────────────────────── */
.download-modal-content {
  background: #fff; border-radius: 14px; width: 100%; max-width: 480px;
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}
.download-modal-head {
  padding: 16px 22px; border-bottom: 1px solid var(--line-2);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.download-modal-head h2 { margin: 0; font-size: 16px; }
.download-modal-head p { margin: 3px 0 0; font-size: 12px; color: var(--ink-3); }
.download-modal-body { padding: 18px 22px; }

.download-option-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px;
  background: #fafbfc; font-size: 13px; color: var(--ink); cursor: pointer;
}
.download-option-row input { margin: 0; cursor: pointer; }
.download-option-row .hint { color: var(--ink-3); font-size: 11px; }

.download-options-grid { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 14px; }
.download-btn {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 16px; border: 1px solid var(--line); background: #fff;
  border-radius: 10px; cursor: pointer; text-align: left;
  width: 100%; font-family: inherit;
}
.download-btn:hover { border-color: var(--ink-2); background: #fafbfc; }
.download-btn .dl-icon { font-size: 22px; line-height: 1; }
.download-btn .dl-title { font-weight: 600; font-size: 14px; color: var(--ink); }
.download-btn .dl-desc { font-size: 12px; color: var(--ink-3); margin-top: 2px; }

/* ─────────────────────────────────────────────────────────
   Graph modal (d3 force-directed link network) — mockup .graph-modal
   ──────────────────────────────────────────────────────── */
.graph-modal {
  position: fixed; inset: 0; background: rgba(15, 23, 42, 0.85);
  display: none; align-items: stretch; justify-content: stretch;
  z-index: 100;
  /* Lighthouse mode: full-screen takeover, no padding around the content */
  padding: 0;
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.graph-modal.open { display: flex; }
.graph-modal-content {
  background: #fff; border-radius: 0; width: 100vw; max-width: 100vw;
  height: 100vh; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: none;
}
.graph-modal-head {
  padding: 18px 22px; border-bottom: 1px solid var(--line-2);
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
}
.graph-modal-head h2 { margin: 0; font-size: 17px; letter-spacing: -0.01em; }
.graph-modal-head p { margin: 3px 0 0; font-size: 12px; color: var(--ink-3); }
.graph-modal-close {
  background: transparent; border: 0; font-size: 22px; cursor: pointer;
  color: var(--ink-3); padding: 4px 10px; border-radius: 6px; line-height: 1;
}
.graph-modal-close:hover { background: var(--line-2); color: var(--ink); }

.graph-legend {
  padding: 12px 22px; border-bottom: 1px solid var(--line-2);
  display: flex; flex-wrap: wrap; gap: 16px; font-size: 12px;
  background: #fafbfc; color: var(--ink-2);
}
.graph-legend .item { display: inline-flex; align-items: center; gap: 6px; }
.graph-legend .swatch { width: 11px; height: 11px; border-radius: 50%; }
.graph-legend .swatch.center        { background: var(--ink); }
.graph-legend .swatch.existing-in   { background: var(--winner); }
.graph-legend .swatch.suggested-in  { background: var(--hot); }
.graph-legend .swatch.existing-out  { background: var(--brand); }
.graph-legend .swatch.suggested-out { background: var(--shipped); }
.graph-legend .line-sample { display: inline-block; width: 22px; height: 0; border-top: 2px solid var(--ink-2); }
.graph-legend .line-sample.dashed { border-top-style: dashed; }

/* Body row: graph fills remaining width, inspector pinned to the right. */
.graph-body {
  flex: 1; display: flex; min-height: 0; background: #fafbfc;
}
.graph-svg-wrap {
  flex: 1; background: #fafbfc; position: relative; overflow: hidden;
}
.graph-svg-wrap svg {
  width: 100%; height: 100%; cursor: grab; display: block;
}
.graph-svg-wrap svg:active { cursor: grabbing; }

/* Right-side inspector: always visible, never off-screen. Replaces the
   floating tooltip. Pinned width 360px on desktop; collapses to bottom
   sheet under 720px for mobile (future). */
.graph-inspector {
  width: 360px; flex-shrink: 0;
  border-left: 1px solid var(--line-2);
  background: #fff;
  overflow-y: auto;
  padding: 18px 20px;
  font-size: 13px; line-height: 1.55; color: var(--ink);
}
.graph-inspector-empty {
  color: var(--ink-3); font-size: 13px; padding: 24px 8px;
  text-align: center; border: 1px dashed var(--line-2); border-radius: 8px;
  background: #fafbfc;
}
.graph-inspector-section {
  margin-bottom: 16px; padding-bottom: 14px;
  border-bottom: 1px solid var(--line-2);
}
.graph-inspector-section:last-child { border-bottom: none; }
.graph-inspector-label {
  font-size: 11px; color: var(--ink-3); text-transform: uppercase;
  letter-spacing: 0.04em; margin-bottom: 4px;
}
.graph-inspector-title {
  font-weight: 600; font-size: 15px; line-height: 1.35;
  margin-bottom: 6px; color: var(--ink);
}
.graph-inspector-path {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; color: var(--ink-2); word-break: break-all;
  background: #f3f4f6; padding: 6px 8px; border-radius: 4px;
  margin-bottom: 10px;
}
.graph-inspector-row {
  display: flex; gap: 8px; margin: 6px 0;
}
.graph-inspector-key {
  color: var(--ink-3); min-width: 86px; flex-shrink: 0;
}
.graph-inspector-value {
  color: var(--ink); word-break: break-word;
}
.graph-inspector-anchor {
  font-style: italic; color: var(--ink-2);
  background: #fef3c7; padding: 2px 6px; border-radius: 3px;
  font-size: 12px;
}
.graph-inspector-cta {
  display: inline-block; margin-top: 10px;
  padding: 8px 14px; background: var(--brand); color: #fff;
  text-decoration: none; border-radius: 6px; font-size: 13px;
  font-weight: 500;
}
.graph-inspector-cta:hover { opacity: 0.9; }
.graph-inspector-trust {
  font-size: 11px; color: var(--ink-3); margin-top: 8px;
  display: flex; align-items: center; gap: 4px;
}
.graph-inspector-trust::before { content: "🔒"; }

.graph-node-label {
  font-size: 10.5px; font-weight: 500; fill: var(--ink);
  pointer-events: none; text-anchor: middle;
}
.graph-node circle {
  stroke: #fff; stroke-width: 2px; cursor: pointer;
  transition: stroke-width 0.12s;
}
.graph-node circle:hover { stroke-width: 4px; }
.graph-link { fill: none; stroke-opacity: 0.55; }
.graph-link.inbound-existing  { stroke: var(--winner); stroke-width: 2px; }
.graph-link.inbound-suggested { stroke: var(--hot);    stroke-width: 2px; stroke-dasharray: 5 4; }
.graph-link.outbound-existing { stroke: var(--brand);  stroke-width: 2px; }
.graph-link.outbound-suggested { stroke: var(--shipped); stroke-width: 2px; stroke-dasharray: 5 4; }

.graph-hint {
  position: absolute; bottom: 12px; left: 14px; font-size: 11px;
  color: var(--ink-3); background: rgba(255, 255, 255, 0.85);
  padding: 6px 10px; border-radius: 6px; pointer-events: none;
}
.graph-empty {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: var(--ink-3); font-size: 13px; padding: 20px; text-align: center;
}

/* ─────────────────────────────────────────────────────────
   Suggestion preview tabs（變更列表 / Side-by-Side / raw）
   ──────────────────────────────────────────────────────── */
.preview-tabs {
  display: flex; gap: 2px; margin: 10px 0 12px;
  border-bottom: 1px solid var(--line-2);
}
.preview-tab {
  padding: 8px 14px; border: 0; background: transparent;
  font-family: inherit; font-size: 12.5px; color: var(--ink-3);
  cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px; font-weight: 500;
}
.preview-tab:hover { color: var(--ink-2); }
.preview-tab.active { color: var(--ink); border-bottom-color: var(--ink); font-weight: 600; }
.preview-count {
  display: inline-block; background: var(--line-2); color: var(--ink-2);
  padding: 1px 7px; border-radius: 10px; font-size: 11px; margin-left: 4px;
}
.preview-tab.active .preview-count { background: var(--ink); color: #fff; }

.preview-body { margin-top: 4px; }
.preview-pane { display: none; }
.preview-pane.active { display: block; }
.preview-empty { font-size: 13px; color: var(--ink-3); padding: 14px 0; text-align: center; }

/* Change card (inside 變更列表) — collapsible <details>. */
.change-card {
  border: 1px solid var(--line); border-radius: 10px;
  margin: 0 0 10px; background: var(--card);
  overflow: hidden;
}
/* Hide native disclosure marker; we render our own in the head row. */
.change-card > summary { list-style: none; cursor: pointer; }
.change-card > summary::-webkit-details-marker { display: none; }

.change-head {
  display: flex; gap: 10px; align-items: center;
  flex-wrap: wrap; padding: 10px 14px;
  user-select: none;
}
.change-head:hover { background: var(--line-2); }
.change-card[open] .change-head { border-bottom: 1px solid var(--line); }
.change-card[open] .change-head:hover { background: transparent; }
/* Disclosure indicator on the right side via ::after */
.change-head::after {
  content: "▶";
  margin-left: auto;
  font-size: 10px; color: var(--ink-3);
  transition: transform 0.15s;
}
.change-card[open] .change-head::after { content: "▼"; }
.change-body { padding: 12px 14px 14px; }
.change-body > .change-intro:first-child { margin-top: 0; }
.change-n {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px; font-weight: 700; color: var(--ink);
  background: var(--line-2); padding: 2px 7px; border-radius: 4px;
}
.change-type {
  font-size: 10px; letter-spacing: 0.04em; text-transform: uppercase;
  font-weight: 600; padding: 2px 8px; border-radius: 4px;
}
.change-type.rewrite { background: var(--hot-soft);    color: var(--hot); }
.change-type.add     { background: var(--winner-soft); color: var(--winner); }
.change-type.link    { background: #e8efff;            color: var(--brand); }
.change-type.edit    { background: var(--line-2);      color: var(--ink-2); }
.change-title { font-size: 13px; color: var(--ink); font-weight: 600; }
/* Location badge — monospace pill on the head row.
   Comes from `**Location:**` in the LLM markdown (Gemini 3.x emits
   it; Gemini 2.5-flash doesn't). 📍 = modify existing element,
   ➕ = insert new section/段落. */
.change-location {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 11px; font-weight: 500;
  padding: 2px 8px; border-radius: 4px;
  background: #fafbfc; border: 1px solid var(--line);
  color: var(--ink-2);
  max-width: 320px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}

/* Toolbar above the change list — count + 全部展開/收合. */
.changes-toolbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 4px 0 10px; border-bottom: 1px dashed var(--line);
  margin-bottom: 10px;
}
.changes-count {
  font-size: 11px; color: var(--ink-3);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.changes-toolbar-buttons { display: flex; gap: 6px; }
.changes-toggle-all {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  font-size: 11px; padding: 3px 9px; border-radius: 4px;
  cursor: pointer; font-family: inherit;
}
.changes-toggle-all:hover { background: var(--line-2); color: var(--ink); }

/* Location anchor lint — appears next to the location badge when the
   LLM-cited section header isn't found in brief.headings. Helps the
   editor catch hallucinated anchors before applying the change. */
.change-location-warn {
  font-size: 11px; color: var(--hot);
  background: var(--hot-soft); border: 1px solid var(--hot);
  padding: 1px 7px; border-radius: 4px;
  cursor: help;
}

/* Pair-level collapse — only renders when a Change has >1 Current/New
   pair (e.g. Change 1 = H1 + Title rewrites under one header). The
   diff itself looks identical to the single-pair case; only the
   <details>/<summary> wrapper is added. */
.change-pair {
  border-left: 2px solid var(--line);
  padding-left: 8px;
  margin: 6px 0;
}
.change-pair > summary { list-style: none; cursor: pointer; padding: 4px 0; }
.change-pair > summary::-webkit-details-marker { display: none; }
.change-pair-head {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 11px; color: var(--ink-3);
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  user-select: none;
}
.change-pair-head:hover { color: var(--ink); }
.pair-marker {
  background: var(--line-2); padding: 2px 8px; border-radius: 4px;
  color: var(--ink-2); font-weight: 600;
}
.pair-toggle-hint { font-size: 10px; }
.change-intro { font-size: 13px; color: var(--ink-2); }
.change-intro .md-body { font-size: 13px; }
.change-payload {
  margin-top: 8px; border-left: 3px solid var(--winner);
  background: #fafbfc; border-radius: 0 8px 8px 0;
  padding: 10px 14px 2px;
}
.change-payload-head {
  font-size: 10px; font-weight: 600; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--winner); margin-bottom: 6px;
}
.change-payload-body { font-size: 13px; line-height: 1.65; }

/* Change diff — Current vs New side-by-side, used by LLM-generated briefs.
   Falls back to .change-payload when only a single payload block exists. */
.change-diff {
  margin-top: 10px;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  align-items: stretch;
}
@media (max-width: 880px) {
  .change-diff { grid-template-columns: 1fr; }
}
.diff-col {
  border: 1px solid var(--line); border-radius: 8px;
  background: var(--card); display: flex; flex-direction: column;
  overflow: hidden;
}
.diff-current { border-left: 3px solid var(--hot);    background: #fffaf7; }
.diff-proposed { border-left: 3px solid var(--winner); background: #f7fcfa; }
.diff-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 10px; border-bottom: 1px solid var(--line);
  background: rgba(255,255,255,0.55);
}
.diff-tag {
  font-size: 10px; letter-spacing: 0.06em; font-weight: 700;
  padding: 2px 8px; border-radius: 4px;
}
.diff-tag.current  { background: var(--hot-soft);    color: var(--hot); }
.diff-tag.proposed { background: var(--winner-soft); color: var(--winner); }
.diff-body {
  padding: 10px 12px; font-size: 13px; line-height: 1.6;
  flex: 1; overflow-x: auto;
}
.diff-body pre,
.diff-body code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 12px;
}
.diff-body pre {
  background: rgba(0,0,0,0.04); border-radius: 6px;
  padding: 8px 10px; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;
}
.diff-copy {
  border: 1px solid var(--line); background: var(--card); color: var(--ink-2);
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 4px;
  cursor: pointer; transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.diff-copy:hover { background: var(--winner-soft); color: var(--winner); border-color: var(--winner); }
.diff-copy.copied { background: var(--winner); color: #fff; border-color: var(--winner); }
/* Two-button group for copy modes (內文 vs 含 fence). Tight pill cluster
   on the right of the New head, doesn't crowd narrow viewports. */
.diff-copy-group {
  display: inline-flex; gap: 4px;
}
.diff-copy-group .diff-copy {
  padding: 3px 7px; font-size: 10px;
}
.diff-sub {
  font-size: 10px; color: var(--ink-3); font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.change-pair-count {
  font-size: 10px; color: var(--ink-3); font-style: italic;
}
/* Multiple diff blocks within a single change card stack vertically */
.change-card .change-diff + .change-diff { margin-top: 10px; }

/* Side-by-Side 兩欄 */
.sbs-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 14px;
  align-items: start;
}
@media (max-width: 960px) {
  .sbs-grid { grid-template-columns: 1fr; }
}
.sbs-col {
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--card); overflow: hidden;
}
.sbs-col-title {
  margin: 0; padding: 8px 14px;
  font-size: 11px; font-weight: 600; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--ink-3);
  background: #fafbfc; border-bottom: 1px solid var(--line-2);
}
.sbs-col-title.change { color: var(--hot); }
.sbs-md {
  padding: 14px 18px; font-size: 13px; line-height: 1.7;
  max-height: 640px; overflow-y: auto;
}

/* ─────────────────────────────────────────────────────────
   Wave badge + opportunity chip — used in sidebar cards,
   top-bar progress strip, and brief breadcrumb.
   ──────────────────────────────────────────────────────── */
.wave-badge {
  display: inline-block;
  font-size: 10px; font-weight: 700; letter-spacing: 0.04em;
  padding: 1px 7px; border-radius: 4px; color: #fff;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  margin-right: 6px; vertical-align: middle;
}
.wave-badge.w1 { background: var(--hot); }
.wave-badge.w2 { background: var(--brand); }
.wave-badge.w3 { background: var(--shipped); }

.opp-chip {
  display: inline-block;
  font-size: 11px; font-weight: 600;
  color: var(--hot); background: var(--hot-soft);
  padding: 1px 8px; border-radius: 4px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  vertical-align: middle;
}

/* Top progress strip — wave counts small-pill */
#progress .wave-badge { margin-right: 2px; padding: 1px 6px; font-size: 10px; }
#progress b { margin-right: 2px; }
