/* ==========================================================================
   AI Search Intelligence Prototype — Shared Design System
   Scheme A (Mention x Citation + Raw Evidence) + Scheme B (Citation Gap + Remediation)
   ========================================================================== */

:root {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f1f3f9;
  --surface-3: #e8ecf4;
  --border: #e2e6f0;
  --border-strong: #cbd2e1;

  --ink: #0f172a;
  --ink-2: #334155;
  --muted: #64748b;
  --muted-2: #94a3b8;

  --sidebar-bg: #1a222d;
  --sidebar-hover: #253040;
  --sidebar-active: #4fb19d;

  /* Semantic accents — Custom 5-color palette:
     #edce7a, #9ac5e5, #4fb19d, #e5c6c3, #c98c9a */
  --teal: #4fb19d;
  --teal-dark: #2d7d6d;
  --teal-soft: #dff4ef;
  --teal-bg: #f1faf8;

  --indigo: #9ac5e5;
  --indigo-dark: #336f99;
  --indigo-soft: #e3f1fa;
  --indigo-bg: #f2f8fd;

  --amber: #edce7a;
  --amber-dark: #856614;
  --amber-soft: #fbf2d5;
  --amber-bg: #fdf9eb;

  --rose: #c98c9a;
  --rose-dark: #884958;
  --rose-soft: #e5c6c3;
  --rose-bg: #faf0ef;

  --emerald: #4fb19d;
  --emerald-soft: #dff4ef;

  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow: 0 4px 12px rgba(15, 23, 42, 0.05), 0 1px 3px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 32px rgba(15, 23, 42, 0.08);

  --font-sans: 'Inter', 'Noto Sans TC', 'PingFang TC', 'Microsoft JhengHei', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  scroll-padding-top: 76px;
}

:focus-visible {
  outline: 2.5px solid var(--indigo-dark);
  outline-offset: 2px;
}

a {
  color: inherit;
  text-decoration: none;
}

button, select, input, textarea {
  font-family: inherit;
  font-size: inherit;
}

button {
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

button:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

button.primary {
  background: var(--teal);
  color: #0f172a;
  border-color: transparent;
  font-weight: 700;
}

button.primary:hover {
  background: #3ea08c;
}

button.indigo {
  background: var(--indigo);
  color: #0f172a;
  border-color: transparent;
  font-weight: 700;
}

button.indigo:hover {
  background: #84b6dc;
}

button.sm {
  padding: 5px 10px;
  font-size: 12px;
}

/* App Shell */
.app-shell {
  display: grid;
  grid-template-columns: 248px minmax(0, 1fr);
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--sidebar-bg);
  color: #e2e8f0;
  padding: 22px 14px;
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  border-right: 1px solid #1e293b;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 20px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4fb19d, #9ac5e5);
  display: grid;
  place-items: center;
  color: #1a222d;
  font-weight: 800;
  font-size: 16px;
  flex-shrink: 0;
}

.brand-name {
  font-weight: 800;
  font-size: 16px;
  letter-spacing: -0.02em;
  color: #ffffff;
  line-height: 1.2;
}

.brand-sub {
  font-size: 11px;
  color: #94a3b8;
  font-weight: 500;
}

.agency-box {
  background: rgba(79, 177, 157, 0.08);
  border: 1px solid rgba(79, 177, 157, 0.24);
  border-radius: var(--radius);
  padding: 9px 11px;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.agency-mark {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: rgba(154, 197, 229, 0.16);
  color: #9ac5e5;
  font-size: 13px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.agency-info {
  min-width: 0;
}

.agency-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: #7dd3fc;
  line-height: 1.25;
}

.agency-name {
  font-size: 12.5px;
  font-weight: 700;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-switcher {
  position: relative;
  margin-bottom: 22px;
}

.workspace-box {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: var(--radius);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  text-align: left;
  color: inherit;
  font-family: inherit;
}

.workspace-trigger {
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.workspace-trigger:hover {
  background: #253347;
  border-color: #475569;
}

.workspace-trigger[aria-expanded="true"] {
  background: #253347;
  border-color: #4fb19d;
}

.workspace-avatar {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(79, 177, 157, 0.22);
  color: #4fb19d;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.workspace-info {
  flex: 1;
  min-width: 0;
}

.workspace-info b {
  display: block;
  font-size: 13px;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-info small {
  display: block;
  font-size: 11px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-caret {
  font-size: 11px;
  color: #94a3b8;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.workspace-trigger[aria-expanded="true"] .workspace-caret {
  transform: rotate(180deg);
  color: #4fb19d;
}

.workspace-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: #17212e;
  border: 1px solid #334155;
  border-radius: var(--radius);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  z-index: 60;
  overflow: hidden;
}

.workspace-menu-header {
  font-size: 10.5px;
  font-weight: 700;
  color: #64748b;
  letter-spacing: 0.04em;
  padding: 8px 12px 6px;
  border-bottom: 1px solid #1e293b;
}

.workspace-menu-list {
  max-height: 220px;
  overflow-y: auto;
  padding: 4px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.workspace-option {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: #e2e8f0;
  text-align: left;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.12s ease;
}

.workspace-option:hover {
  background: #253040;
}

.workspace-option.is-selected {
  background: rgba(79, 177, 157, 0.14);
}

.workspace-option-avatar {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: rgba(79, 177, 157, 0.2);
  color: #4fb19d;
  font-size: 12px;
  font-weight: 800;
  display: grid;
  place-items: center;
  flex-shrink: 0;
}

.workspace-option-text {
  flex: 1;
  min-width: 0;
}

.workspace-option-text b {
  display: block;
  font-size: 12.5px;
  color: #f8fafc;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-option-text small {
  display: block;
  font-size: 10.5px;
  color: #94a3b8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.workspace-option-check {
  font-size: 12px;
  font-weight: 800;
  color: #4fb19d;
  flex-shrink: 0;
}

.workspace-menu-footer {
  display: block;
  padding: 9px 12px;
  font-size: 11.5px;
  font-weight: 600;
  color: #9ac5e5;
  border-top: 1px solid #1e293b;
  background: #141d29;
  transition: background 0.12s ease;
}

.workspace-menu-footer:hover {
  background: #1e293b;
  color: #ffffff;
}

.sidebar-toast {
  position: fixed;
  right: 22px;
  bottom: 22px;
  background: #0f172a;
  color: #f8fafc;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.25);
  opacity: 0;
  transform: translateY(10px);
  pointer-events: none;
  transition: all 0.2s ease;
  z-index: 100;
}

.sidebar-toast.show {
  opacity: 1;
  transform: translateY(0);
}

.nav-section-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  padding: 0 10px 8px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: #cbd5e1;
  font-weight: 500;
  font-size: 13.5px;
  transition: all 0.15s ease;
}

.nav-item:hover {
  background: var(--sidebar-hover);
  color: #ffffff;
}

.nav-item.active {
  background: rgba(79, 177, 157, 0.16);
  color: #4fb19d;
  font-weight: 700;
  box-shadow: inset 3px 0 0 #4fb19d;
}

.nav-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.nav-icon {
  width: 18px;
  text-align: center;
  font-size: 14px;
  opacity: 0.9;
}

.nav-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(201, 140, 154, 0.25);
  color: #e5c6c3;
}

.nav-badge.teal {
  background: rgba(79, 177, 157, 0.22);
  color: #4fb19d;
}

.sidebar-footer {
  margin-top: auto;
  padding-top: 16px;
  border-top: 1px solid #1e293b;
  font-size: 12px;
  color: #94a3b8;
}

.scheme-pill {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #172136;
  border: 1px solid #28354f;
  border-radius: var(--radius-sm);
  padding: 10px;
  font-size: 11.5px;
  line-height: 1.45;
}

.scheme-pill strong {
  color: #edce7a;
}

/* Main Area */
.main-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.topbar {
  height: 60px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.breadcrumb strong {
  color: var(--ink);
  font-weight: 700;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.page-content {
  max-width: 1360px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 28px 48px;
}

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.page-header h1 {
  font-size: 24px;
  font-weight: 800;
  letter-spacing: -0.025em;
  color: var(--ink);
  margin-bottom: 4px;
}

.page-header p {
  color: var(--muted);
  font-size: 13.5px;
}

.filter-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.filter-bar select,
.filter-row select {
  appearance: none;
  -webkit-appearance: none;
  border: 1px solid var(--border);
  background-color: var(--surface);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 14px;
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 7px 34px 7px 12px;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
}

/* Pills & Tags */
.pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.pill.teal { background: var(--teal-soft); color: var(--teal-dark); }
.pill.indigo { background: var(--indigo-soft); color: var(--indigo-dark); }
.pill.amber { background: var(--amber-soft); color: var(--amber-dark); }
.pill.rose { background: var(--rose-soft); color: var(--rose-dark); }
.pill.gray { background: var(--surface-2); color: var(--ink-2); }
.pill.emerald { background: var(--emerald-soft); color: var(--teal-dark); }
.pill.violet { background: #ecebfb; color: #4b4398; }

/* Grid & Cards */
.grid-4 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 20px;
}

.grid-asym {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(300px, 1fr);
  gap: 16px;
  margin-bottom: 20px;
}

.grid-asym.gap-layout {
  grid-template-columns: minmax(0, 1.95fr) minmax(270px, 0.95fr);
  align-items: start;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  min-width: 0;
}

.card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.card-sub {
  font-size: 12.5px;
  color: var(--muted);
  margin-top: 2px;
}

/* KPI Cards */
.kpi-card {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.kpi-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.kpi-label {
  font-size: 12.5px;
  font-weight: 700;
  color: var(--ink-2);
  display: flex;
  align-items: center;
  gap: 6px;
}

.kpi-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.kpi-info-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.kpi-info-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  cursor: help;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.kpi-info-wrap:hover .kpi-info-btn,
.kpi-info-btn:focus-visible {
  background: var(--ink);
  border-color: var(--ink);
  color: #ffffff;
  outline: none;
}

.kpi-tooltip {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  width: max-content;
  max-width: 240px;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #f8fafc;
  font-size: 12px;
  font-weight: 500;
  line-height: 1.45;
  white-space: normal;
  box-shadow: 0 8px 20px rgba(15, 23, 42, 0.18);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  z-index: 30;
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s ease;
}

.kpi-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: var(--ink);
}

.kpi-info-wrap:hover .kpi-tooltip,
.kpi-info-wrap:focus-within .kpi-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-50%) translateY(0);
}

.kpi-value {
  font-size: 30px;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--ink);
  line-height: 1.15;
}

.kpi-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
}

.delta-up { color: var(--teal-dark); font-weight: 700; }
.delta-down { color: var(--rose-dark); font-weight: 700; }

/* Scheme B Hero Banner */
.gap-hero {
  background: linear-gradient(120deg, #1a222d 0%, #243b46 58%, #2d7d6d 100%);
  color: #ffffff;
  border-radius: var(--radius-lg);
  padding: 22px 24px;
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

.gap-hero-eyebrow {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #edce7a;
  margin-bottom: 6px;
}

.gap-hero h2 {
  font-size: 19px;
  font-weight: 800;
  margin-bottom: 6px;
}

.gap-hero p {
  color: #cbd5e1;
  font-size: 13.5px;
  max-width: 720px;
}

.gap-hero-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn-hero {
  background: #ffffff;
  color: #0f172a;
  border: 0;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 700;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-hero:hover {
  background: #f0fdfa;
}

.btn-hero-ghost {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  font-size: 13px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.btn-hero-ghost:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

th {
  background: var(--surface-2);
  color: var(--ink-2);
  font-weight: 700;
  font-size: 12px;
  white-space: nowrap;
}

tr:last-child td {
  border-bottom: 0;
}

tr.clickable {
  cursor: pointer;
  transition: background 0.12s ease;
}

tr.clickable:hover {
  background: #f8fafc;
}

tr.clickable.selected {
  background: var(--teal-bg);
}

/* Progress bars */
.bar-row {
  margin-bottom: 14px;
}

.bar-row:last-child {
  margin-bottom: 0;
}

.bar-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 13px;
  margin-bottom: 5px;
}

.bar-track {
  height: 8px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow: hidden;
  display: flex;
}

.bar-fill {
  height: 100%;
  border-radius: 999px;
}

/* Citation Gap UX Enhancements */
.gap-table {
  table-layout: fixed;
  width: 100%;
}

.gap-table th,
.gap-table td {
  padding: 11px 12px;
  overflow-wrap: anywhere;
}

.gap-meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
}

.gap-vol {
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.gap-source-item {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  margin-bottom: 6px;
}

.gap-source-item:last-child {
  margin-bottom: 0;
}

.gap-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.gap-actions a {
  display: block;
}

.gap-actions button {
  width: 100%;
  justify-content: center;
}

.domain-item {
  width: 100%;
  text-align: left;
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius);
  padding: 9px 10px;
  margin-bottom: 6px;
  cursor: pointer;
  transition: background 0.14s ease, border-color 0.14s ease;
  display: block;
  font-family: inherit;
}

.domain-item:last-child {
  margin-bottom: 0;
}

.domain-item:hover {
  background: var(--surface-2);
  border-color: var(--border);
}

.domain-item.active {
  background: var(--indigo-bg);
  border-color: var(--indigo);
}

.domain-item-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 8px;
  font-size: 13px;
  margin-bottom: 6px;
}

.domain-item-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.domain-item-stats {
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.filter-chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--indigo-bg);
  color: var(--indigo-dark);
  border: 1px solid var(--indigo);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
}

.filter-chip-btn:hover {
  opacity: 0.85;
}

/* Split Evidence Viewer */
.split-view {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(360px, 1fr);
  gap: 18px;
  align-items: start;
}

.evidence-drawer {
  position: sticky;
  top: 84px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow);
  max-height: calc(100vh - 108px);
  overflow-y: auto;
}

.answer-box {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--ink);
  margin: 12px 0;
}

.answer-box mark.mention {
  background: #dff4ef;
  color: #2d7d6d;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 700;
}

.answer-box mark.competitor {
  background: #fbf2d5;
  color: #856614;
  padding: 1px 4px;
  border-radius: 4px;
  font-weight: 600;
}

.cite-sup {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  color: var(--indigo-dark);
  background: var(--indigo-soft);
  padding: 0 5px;
  border-radius: 4px;
  margin-left: 2px;
}

.source-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}

.source-item {
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface);
}

.source-url {
  font-family: var(--font-mono);
  font-size: 11.5px;
  color: var(--indigo-dark);
  word-break: break-all;
}

/* Code & Brief Blocks */
.code-block {
  background: #0f172a;
  color: #e2e8f0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.6;
  padding: 14px 16px;
  border-radius: var(--radius);
  overflow-x: auto;
  white-space: pre-wrap;
  margin: 10px 0;
}

.brief-box {
  background: var(--amber-bg);
  border: 1px solid #edce7a;
  border-radius: var(--radius);
  padding: 14px 16px;
  font-size: 13px;
  color: #856614;
}

/* Competitor Switcher Pills */
.comp-switcher {
  display: inline-flex;
  background: var(--surface-2);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  gap: 4px;
}

.comp-btn {
  border: 0;
  background: transparent;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--muted);
}

.comp-btn.active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}

/* Callout */
.callout {
  border-left: 3px solid var(--teal);
  background: var(--teal-bg);
  padding: 12px 14px;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-size: 13px;
  color: var(--ink-2);
  margin: 12px 0;
}

.callout.amber {
  border-left-color: var(--amber);
  background: var(--amber-bg);
}

/* KPI Reconciliation Box */
.kpi-reconcile {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  margin-bottom: 20px;
}

.reconcile-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink-2);
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.reconcile-summary::-webkit-details-marker {
  display: none;
}

.reconcile-summary-title {
  display: flex;
  align-items: center;
  gap: 8px;
}

.reconcile-summary-hint {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}

.kpi-reconcile[open] .reconcile-summary {
  border-bottom: 1px solid var(--border);
}

.kpi-reconcile[open] .reconcile-summary-hint::after {
  content: " ▲";
}

.kpi-reconcile:not([open]) .reconcile-summary-hint::after {
  content: " ▼";
}

.reconcile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 16px 18px;
}

.reconcile-item {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
}

.reconcile-item h3 {
  margin: 0 0 6px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}

.reconcile-item p {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--ink-2);
}

/* Responsive */
@media (max-width: 1150px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-asym.gap-layout { grid-template-columns: 1fr; }
  .split-view { grid-template-columns: 1fr; }
  .evidence-drawer { position: static; max-height: none; }
}

@media (max-width: 860px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar {
    position: static;
    height: auto;
    padding: 14px;
  }
  .nav-list {
    flex-direction: row;
    overflow-x: auto;
  }
  .nav-item { white-space: nowrap; }
  .sidebar-footer, .nav-section-label { display: none; }
  .workspace-switcher { margin-bottom: 12px; }
  .grid-asym, .grid-2, .grid-3, .reconcile-grid { grid-template-columns: 1fr; }
  .page-content { padding: 18px 16px 36px; }
  .topbar { padding: 0 16px; }
}

/* ---------- GEO 健檢總覽：趨勢圖、客戶報告開關 ---------- */
.kpi-compare { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--border); font-size: 12px; color: var(--ink-2); }
.check { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--ink-2); white-space: nowrap; cursor: pointer; }
.report-toggle { color: var(--muted); font-weight: 500; }
.gap-hero .report-toggle { color: #cbd5e1; }
.kpi-top .report-toggle { margin-left: auto; }
.report-card.report-off { opacity: 0.55; }
.chart-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 14px; margin-bottom: 10px; }
.segmented { display: inline-flex; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); overflow: hidden; }
.segmented button { border: 0; border-radius: 0; background: var(--surface); padding: 6px 12px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; }
.segmented button + button { border-left: 1px solid var(--border-strong); }
.segmented button[aria-pressed="true"] { background: var(--ink); color: #fff; }
.legend { display: flex; flex-wrap: wrap; gap: 4px 16px; list-style: none; margin: 0 0 6px; padding: 0; font-size: 12px; color: var(--ink-2); }
.swatch { display: inline-block; flex: none; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.chart { position: relative; }
.chart svg { display: block; width: 100%; height: auto; }
.chart-tip { position: absolute; top: 4px; transform: translateX(-50%); min-width: 180px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); box-shadow: var(--shadow); font-size: 12px; pointer-events: none; }
.tip-row { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 4px; margin-top: 3px; }
.tip-row b { font-variant-numeric: tabular-nums; }
.data-table { margin-top: 8px; font-size: 12px; }
.data-table summary { cursor: pointer; color: var(--indigo-dark); font-weight: 600; margin-bottom: 6px; }
tr.target-row td { background: var(--indigo-bg); font-weight: 700; }
#brand-table th, #brand-table td, #topic-table th, #topic-table td { padding: 9px 10px; font-size: 12.5px; white-space: nowrap; }
.trend-delta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; }
.trend-delta #trend-delta { display: contents; }
.tip-event { margin: 4px 0 2px; color: var(--teal-dark); font-weight: 700; }
#trend-real-controls[hidden] { display: none !important; }
.kpi-top .report-toggle { font-size: 11.5px; }

/* ---------- 原文證據頁 ---------- */
.outcome-card { text-align: left; width: 100%; font: inherit; color: inherit; cursor: pointer; }
.outcome-card:hover { border-color: var(--border-strong); background: var(--surface); }
.outcome-card.active { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); background: var(--teal-bg); }
.drawer-label { font-size: 12px; font-weight: 700; color: var(--ink-2); margin-bottom: 6px; }
.legend-inline { margin-left: 8px; font-weight: 500; }
.legend-inline mark { font-size: 11px; margin-right: 4px; }
.answer-raw { white-space: pre-wrap; max-height: 360px; overflow-y: auto; }
.tone-quote { margin: 0 0 8px; padding: 10px 12px; border-left: 3px solid var(--indigo); background: var(--indigo-bg); font-size: 13px; line-height: 1.6; }
.tone-quote mark.mention { background: #dff4ef; color: #2d7d6d; padding: 1px 3px; border-radius: 3px; font-weight: 700; }
.tone-quote mark.competitor { background: #fbf2d5; color: #856614; padding: 1px 3px; border-radius: 3px; }
.tone-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.query-list { margin: 0; padding-left: 22px; font-size: 12.5px; color: var(--ink-2); }
.query-list li { margin-bottom: 3px; font-family: var(--font-mono); }
.evidence-drawer .source-url { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; word-break: normal; }
.legend-inline mark.mention { background: #dff4ef; color: #2d7d6d; padding: 1px 4px; border-radius: 4px; font-weight: 700; }
.legend-inline mark.competitor { background: #fbf2d5; color: #856614; padding: 1px 4px; border-radius: 4px; }

/* ---------- Citation Gap 頁 ---------- */
.comp-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-bottom: 16px; }
.action-table th, .action-table td { padding: 10px 11px; font-size: 13px; vertical-align: top; }
.action-table tr.detail-row td { background: var(--surface-2); }
.detail-grid { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 20px; padding: 4px 2px; }
.page-list, .missing-list { margin: 0; padding-left: 20px; font-size: 12.5px; line-height: 1.7; }
.page-list li { margin-bottom: 4px; }
.page-list .muted-small { display: block; }
.link { color: var(--indigo-dark); font-weight: 600; }
.link:hover { text-decoration: underline; }
.muted-small { font-size: 11.5px; color: var(--muted); }
.muted-num { margin-left: 4px; font-size: 11px; color: var(--muted); }
.site-line { display: flex; justify-content: space-between; gap: 8px; margin-top: 5px; font-size: 12.5px; }
#platform-table th, #platform-table td { padding: 9px 10px; font-size: 12.5px; }
#platform-table tr th:first-child { white-space: nowrap; }
@media (max-width: 1150px) { .detail-grid { grid-template-columns: 1fr; } }
.track-label { font-size: 12.5px; font-weight: 800; color: var(--ink); margin-bottom: 3px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.task-cell { white-space: nowrap; }
.task-cell .pill { display: inline-flex; margin-bottom: 6px; }
.link-btn { display: block; border: 0; background: none; padding: 0; color: var(--muted); font-size: 12px; text-decoration: underline; }
.report-bar { display: flex; justify-content: flex-end; margin: -6px 0 6px; }
.caret { display: inline-block; width: 12px; color: var(--muted); }
.q-list { display: flex; flex-direction: column; gap: 8px; }
.q-item { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); }
.q-item.open { border-color: var(--teal); }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 10px 12px; cursor: pointer; flex-wrap: wrap; }
.q-head:hover { background: var(--teal-bg); }
.q-text { font-weight: 700; font-size: 13px; flex: 1 1 320px; }
.q-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.q-meta .link-btn { display: inline; }
.brief { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; padding: 12px; border-top: 1px solid var(--border); background: var(--surface-2); }
.brief-title { font-size: 13px; font-weight: 800; color: var(--ink); margin-bottom: 8px; }
.brief-table th, .brief-table td { padding: 7px 9px; font-size: 12px; }
@media (max-width: 1150px) { .brief { grid-template-columns: 1fr; } }
.brief-block.wide { grid-column: 1 / -1; }
.site-rank { margin: 0; padding-left: 22px; display: flex; flex-direction: column; gap: 12px; }
.site-rank-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; margin-bottom: 4px; }
.site-bars { display: flex; flex-direction: column; gap: 3px; margin-bottom: 3px; }
.site-bars .bar-track { height: 6px; }
.legend-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 4px; vertical-align: 0; }
.stack { display: flex; flex-direction: column; gap: 20px; }
.stack .site-rank { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 28px; }
@media (max-width: 860px) { .stack .site-rank { grid-template-columns: 1fr; } }
.channel-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.channel-tabs .comp-btn[disabled] { opacity: 0.4; cursor: default; }
.tone-bar { display: flex; height: 12px; border-radius: 999px; overflow: hidden; background: var(--surface-2); gap: 2px; }
.tone-bar span { display: block; height: 100%; }
.tone-legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 10px; font-size: 13px; color: var(--ink-2); }
.tone-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.note-list { margin: 0; padding-left: 20px; font-size: 13px; line-height: 1.8; color: var(--ink-2); }

/* ---------- 第二輪：總覽頁 ---------- */
.tone-link { color: var(--ink-2); text-decoration: none; border-radius: 6px; padding: 2px 6px; margin-left: -6px; }
.tone-link:hover { background: var(--surface-2); color: var(--ink); }
.rank-table th, .rank-table td { padding: 8px 10px; font-size: 12.5px; white-space: nowrap; }
.rank-up { color: var(--teal-dark); font-size: 10px; }
.rank-down { color: var(--rose-dark); font-size: 10px; }
.card-title .kpi-info-wrap, .kpi-label .kpi-info-wrap { margin-left: 4px; vertical-align: 1px; }
/* ---------- 第二輪：Answers & Citations ---------- */
.history-table th, .history-table td { padding: 8px 10px; font-size: 12.5px; }
.compare-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: 14px 0 10px; font-size: 13px; }
.compare-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 12px; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface-2); font-size: 12.5px; }
.compare-grid .pill { margin: 0 4px 4px 0; }
@media (max-width: 1150px) { .compare-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.report-locked { font-size: 11.5px; color: var(--muted); background: var(--surface-2); border-radius: 999px; padding: 3px 9px; white-space: nowrap; }

/* ---------- 第二輪：Actions to Do ---------- */
.task-list { display: flex; flex-direction: column; gap: 10px; }
.task-item { text-align: left; width: 100%; font: inherit; color: inherit; cursor: pointer; padding: 14px 16px; }
.task-item:hover { border-color: var(--border-strong); }
.task-item.selected { border-color: var(--teal); box-shadow: inset 0 0 0 1px var(--teal); background: var(--teal-bg); }
.task-item-tags { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.task-item-title { font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.task-title { font-size: 16px; font-weight: 800; margin: 0; }
.action-drawer.evidence-drawer { position: static; max-height: none; overflow: visible; }
.decision-bar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 12px; margin-bottom: 14px; border-radius: var(--radius-sm); background: var(--surface-2); font-size: 13px; }
.decision-bar .link-btn { display: inline; }
.action-drawer .brief-block { border-top: 1px solid var(--border); padding-top: 14px; margin-top: 14px; }
.fact-line { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; line-height: 1.6; margin-bottom: 6px; }
.fact-line > .pill { flex-shrink: 0; margin-top: 1px; }
.suggest-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; font-size: 13px; margin-bottom: 6px; }
.edit-field { width: 100%; font: inherit; font-size: 13px; padding: 8px 10px; border: 1px solid var(--border-strong); border-radius: var(--radius-sm); background: var(--surface); }
select.edit-field { width: auto; }
.task-item { display: block; }
.fact-line { display: block; }
.fact-line > .pill { margin-right: 8px; }

/* ---------- 第二輪：Entity Intelligence ---------- */
.entity-table th, .entity-table td { padding: 10px 12px; font-size: 13px; vertical-align: top; }
.ent-col { text-align: center; white-space: nowrap; }
.ent-mark { display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; border-radius: 6px; font-weight: 800; font-size: 13px; }
.ent-mark.ok { color: var(--teal-dark); background: var(--teal-soft); }
.ent-mark.wrong { color: var(--rose-dark); background: var(--rose-soft); }
.ent-mark.missing { color: var(--muted); background: var(--surface-2); }
.ent-mark.recheck { color: var(--amber-dark); background: var(--amber-soft); font-size: 11px; padding: 0 6px; }
.warn-text { color: var(--amber-dark); font-weight: 700; }
.outdated-hint { margin-top: 6px; padding: 5px 8px; border-radius: 6px; background: var(--amber-bg); color: var(--amber-dark); font-size: 12px; font-weight: 600; }
.entity-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr); gap: 20px; padding: 6px 2px; }
.error-card { border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); padding: 12px 14px; margin-bottom: 10px; }
.flow-row { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-top: 10px; font-size: 12px; }
.flow-step { padding: 3px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); font-weight: 600; }
.flow-step.done { background: var(--teal-soft); color: var(--teal-dark); }
.flow-arrow { color: var(--muted-2); }
.edit-box { display: flex; flex-direction: column; }
.error-text { color: var(--rose-dark); font-size: 12px; margin-top: 6px; }
@media (max-width: 1150px) { .entity-detail { grid-template-columns: 1fr; } }
.scope-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px 20px; }
@media (max-width: 860px) { .scope-grid { grid-template-columns: 1fr; } }

/* ---------- 第二輪：Report ---------- */
.report-doc { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 28px 32px; box-shadow: var(--shadow-sm); }
.report-cover { border-bottom: 2px solid var(--ink); padding-bottom: 14px; margin-bottom: 18px; }
.report-cover h2 { font-size: 24px; font-weight: 800; margin: 4px 0; }
.report-agency { font-size: 12px; font-weight: 800; color: var(--teal-dark); letter-spacing: 0.04em; }
.report-section { margin: 18px 0; }
.report-section h3, .report-section-title { font-size: 16px; font-weight: 800; margin: 22px 0 10px; padding-left: 10px; border-left: 3px solid var(--teal); }
.report-summary { min-height: 96px; }
.report-summary-print { display: none; }
.report-item { margin-bottom: 16px; }
.report-item.is-internal .report-item-body { outline: 2px dashed var(--amber); outline-offset: 2px; border-radius: var(--radius-lg); }
.report-item-bar { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-bottom: 6px; }
.report-item-body .card, .report-item-body > section, .report-item-body > div { margin-bottom: 0; }
.report-item-body .gap-hero { margin-bottom: 0; }
.report-note { margin-top: 6px; }
.report-note-print { display: none; font-size: 13px; color: var(--ink-2); margin-top: 6px; }
#report-frames { position: absolute; width: 0; height: 0; overflow: hidden; }

@media print {
  .sidebar, .no-print, .topbar { display: none !important; }
  .app-shell { display: block; }
  .page-content { padding: 0; }
  .report-doc { border: 0; box-shadow: none; padding: 0; }
  .report-summary-print, .report-note-print { display: block; }
  .report-item { break-inside: avoid; }
  .report-item.is-internal .report-item-body { outline: 0; }
  body { background: #fff; }
}
.report-kpi-row .grid-4 { margin-bottom: 0; }

/* ---------- Overview：時間區段、和上一期比 ---------- */
.period-custom { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.period-custom input[type="date"] { padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; font: inherit; color: var(--ink); background: var(--surface); }
.kpi-value .kpi-diff { font-size: 12px; font-weight: 600; margin-top: 6px; letter-spacing: 0; }
.period-custom[hidden] { display: none; }

/* ---------- Entity Intelligence：問題卡（發現 → 原因 → 解法 → 下一步） ---------- */
.issue-steps { display: grid; grid-template-columns: 1.4fr 1fr 1fr 1.3fr; gap: 12px; font-size: 13px; line-height: 1.55; }
.issue-step { background: var(--surface-2); border-radius: 8px; padding: 10px 12px; min-width: 0; }
.issue-step-title { font-size: 12px; font-weight: 800; color: var(--muted); margin-bottom: 6px; letter-spacing: .02em; }
.plain-list { list-style: none; padding: 0; margin: 0 0 8px; display: grid; gap: 6px; font-size: 13px; }
@media (max-width: 1100px) { .issue-steps { grid-template-columns: 1fr 1fr; } }
.callout .link-btn { display: inline; color: inherit; font-size: inherit; font-weight: 700; }
.lang-toggle { font-weight: 700; min-width: 44px; }
.lang-toggle { white-space: nowrap; }

/* ---------- Answers & Citations：一列篩選、題目清單、平台／日期切換 ---------- */
.filter-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin: -6px 0 18px; }
.filter-row .search-input { flex: 1 1 180px; max-width: 260px; padding: 7px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 13px; background: var(--surface); color: var(--ink); }
.more-filters { position: relative; }
.more-filters summary { list-style: none; cursor: pointer; padding: 7px 12px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 13px; font-weight: 600; color: var(--ink-2); }
.more-filters summary::-webkit-details-marker { display: none; }
.more-filters summary::after { content: ' ▾'; color: var(--muted); }
.more-filters[open] summary { border-color: var(--teal); }
.more-panel { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 280px; display: grid; gap: 10px; padding: 14px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: 0 10px 30px rgba(15, 23, 42, .12); }
.more-panel label { display: grid; gap: 4px; font-size: 12px; font-weight: 700; color: var(--muted); }
.more-panel select { width: 100%; }
.topic-row td { background: var(--surface-2); padding: 8px 12px; font-size: 13px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); font-size: 12.5px; font-weight: 600; color: var(--ink-2); cursor: pointer; min-height: 0; }
.chip.active { border-color: var(--teal); background: var(--teal-bg); color: var(--teal-dark); }
.chip-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--rose); }
.chip-dot.on { background: var(--teal); }
/* 題目清單需要較寬的左欄 */
.split-view:has(.prompt-row) { grid-template-columns: minmax(0, 1.5fr) minmax(340px, 1fr); }
.prompt-row td { font-size: 12.5px; vertical-align: top; }
.prompt-row td:first-child { min-width: 220px; }
.prompt-row td:not(:first-child) { white-space: nowrap; }
.more-panel { left: auto; right: 0; }

/* ---------- Answers & Citations：右側題目指標、平台 × 日期格子 ---------- */
.mini-kpis { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.mini-kpi { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: var(--surface-2); min-width: 0; }
.mini-kpi-label { font-size: 11.5px; font-weight: 700; color: var(--muted); }
.mini-kpi-value { font-size: 18px; font-weight: 800; color: var(--ink); margin: 2px 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pg-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 8px; }
.pg-table { border-collapse: collapse; font-size: 12px; }
.pg-table th, .pg-table td { padding: 5px 6px; text-align: center; white-space: nowrap; border-bottom: 1px solid var(--border); }
.pg-table tr:last-child th, .pg-table tr:last-child td { border-bottom: 0; }
.pg-table th:first-child { position: sticky; left: 0; background: var(--surface); text-align: left; font-weight: 700; z-index: 1; }
.pg-cell { display: inline-flex; align-items: center; justify-content: center; width: 28px; height: 24px; border-radius: 6px; border: 1px solid transparent; font-size: 12px; font-weight: 800; padding: 0; min-height: 0; cursor: pointer; }
.pg-cell.hit { background: var(--teal-soft); color: var(--teal-dark); }
.pg-cell.miss { background: var(--rose-soft); color: var(--rose-dark); }
.pg-cell.empty { color: var(--muted-2); cursor: default; }
.pg-cell.on { border-color: var(--ink); box-shadow: 0 0 0 1px var(--ink); }
.top-sites { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: 12.5px; }
.top-sites li span:first-child { font-weight: 600; margin-right: 6px; }
.top-sites li .pill { margin-right: 6px; }
.answer-head { display: flex; align-items: center; gap: 6px; margin: 18px 0 10px; padding-top: 14px; border-top: 1px dashed var(--border); }
.empty-state { text-align: center; padding: 48px 24px; }
.empty-state .card-sub { margin: 8px auto 16px; max-width: 520px; }

/* ---------- Answers & Citations：全寬題目表 + 右側滑出面板 ---------- */
.prompt-table-card { margin-bottom: 20px; }
.group-by { display: flex; align-items: center; gap: 6px; font-size: 12.5px; font-weight: 700; color: var(--muted); }
.group-by select { padding: 6px 30px 6px 10px; border: 1px solid var(--border); border-radius: 8px; font: inherit; font-size: 13px; font-weight: 600; color: var(--ink); background: var(--surface); }
.prompt-table { width: 100%; table-layout: fixed; }
.prompt-table th { white-space: nowrap; }
.prompt-table th.sortable { cursor: pointer; user-select: none; }
.prompt-table th.sortable:hover { color: var(--ink); }
.prompt-table th .sort-mark { color: var(--muted-2); margin-left: 3px; font-size: 10px; }
.prompt-table th.sorted .sort-mark { color: var(--teal-dark); }
.prompt-table th:first-child, .prompt-table td:first-child { width: 42%; }
.prompt-table td { font-size: 13px; vertical-align: middle; }
.prompt-table td.num, .prompt-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
.prompt-table .group-row td { background: var(--surface-2); font-weight: 700; cursor: pointer; }
.prompt-table .group-row .caret { display: inline-block; width: 14px; color: var(--muted); }
.prompt-table .prompt-row td:first-child { padding-left: 30px; }
.prompt-table.flat .prompt-row td:first-child { padding-left: 12px; }
.prompt-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
.prompt-line .ptext { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--ink); }
.prompt-line .pill { flex-shrink: 0; font-size: 10.5px; padding: 1px 6px; }
.delta-up { color: var(--teal-dark); font-weight: 700; }
.delta-down { color: var(--rose-dark); font-weight: 700; }
.panel-backdrop { position: fixed; inset: 0; background: rgba(15, 23, 42, .25); z-index: 60; }
.slide-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface); box-shadow: -12px 0 32px rgba(15, 23, 42, .18); z-index: 61; overflow-y: auto; padding: 18px 20px 28px; }
.slide-panel .evidence-drawer { position: static; max-height: none; border: 0; padding: 0; box-shadow: none; overflow: visible; }
.panel-close { position: sticky; top: 0; float: right; z-index: 2; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--border); background: var(--surface); font-size: 14px; cursor: pointer; padding: 0; min-height: 0; margin: -4px -6px 6px 8px; }

/* ---------- Citation Gap：優先處理的題目 + 右側面板 ---------- */
.gap-table th:first-child, .gap-table td:first-child { width: 34%; }
.gap-table td { vertical-align: middle; }
.gap-verdict { border: 1px solid var(--border); border-radius: 10px; padding: 12px 14px; background: var(--surface-2); font-size: 13px; }
.panel-actions { margin-top: 20px; padding-top: 14px; border-top: 1px solid var(--border); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
a.pg-cell { text-decoration: none; }

/* Citation Gap 題目表：欄寬固定、文字可換行，不超出畫面 */
.gap-table { table-layout: fixed; width: 100%; }
.gap-table .prompt-row td, .gap-table td { white-space: normal; }
.gap-table th { white-space: normal; }
.gap-table th:nth-child(1), .gap-table td:nth-child(1) { width: 28%; }
.gap-table th:nth-child(2), .gap-table td:nth-child(2) { width: 10%; }
.gap-table th:nth-child(3), .gap-table td:nth-child(3) { width: 10%; }
.gap-table th:nth-child(4), .gap-table td:nth-child(4) { width: 11%; }
.gap-table th:nth-child(5), .gap-table td:nth-child(5) { width: 8%; }
.gap-table th:nth-child(6), .gap-table td:nth-child(6) { width: 15%; }
.gap-table th:nth-child(7), .gap-table td:nth-child(7) { width: 18%; }
.gap-table .pill { white-space: nowrap; }
.gap-table .prompt-row td:first-child { padding-left: 14px; min-width: 0; }

/* Citation Gap 面板：每一區一張卡，最後一句是建議 */
.gap-alert { border: 1px solid var(--rose-soft); background: var(--rose-bg); border-radius: 10px; padding: 12px 14px; margin-bottom: 10px; }
.gap-alert-title { font-size: 13px; font-weight: 800; color: var(--rose-dark); margin-bottom: 8px; }
.gap-alert-text { font-size: 12.5px; color: var(--rose-dark); margin-top: 4px; }
.gap-sec { border: 1px solid var(--border); border-radius: 10px; background: var(--surface); margin-bottom: 10px; }
.gap-sec > summary { cursor: pointer; list-style: none; padding: 11px 14px; font-size: 13.5px; font-weight: 700; display: flex; align-items: center; gap: 6px; }
.gap-sec > summary::-webkit-details-marker { display: none; }
.gap-sec > summary::after { content: '▾'; margin-left: auto; color: var(--muted); }
.gap-sec:not([open]) > summary::after { content: '▸'; }
.gap-sec-body { padding: 0 14px 12px; font-size: 13px; }
.gap-sub { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.gchip { display: inline-block; font-size: 12px; padding: 3px 9px; border-radius: 6px; margin: 0 6px 6px 0; background: var(--surface-2); color: var(--ink); }
.gchip.ok { background: var(--emerald-soft); color: var(--teal-dark); }
.gchip.bad { background: var(--rose-soft); color: var(--rose-dark); }
.gchip.me { background: var(--amber-soft); color: var(--amber-dark); font-weight: 700; }
.gap-tip { margin-top: 10px; padding: 8px 12px; border-radius: 8px; background: var(--teal-bg); color: var(--teal-dark); font-size: 12.5px; display: flex; gap: 8px; }
.gap-tip strong { flex: none; }
.gap-miss { margin: 0; padding-left: 18px; color: var(--rose-dark); }
.gap-miss li { margin: 2px 0; }
.gap-rec { margin: 0; padding-left: 20px; line-height: 1.9; }
.gap-no { margin-top: 6px; color: var(--rose-dark); font-weight: 700; font-size: 12.5px; }
.gbar { display: grid; grid-template-columns: 76px minmax(0, 1fr) 44px; align-items: center; gap: 8px; margin: 5px 0; font-size: 12.5px; }
.gbar-track { height: 12px; background: var(--surface-2); border-radius: 4px; overflow: hidden; }
.gbar-track > div { height: 100%; background: var(--ink-2); border-radius: 4px; }
.gbar-track > div.me { background: var(--rose); min-width: 3px; }
.more-queries { margin-top: 8px; font-size: 12.5px; }
.more-queries summary { cursor: pointer; color: var(--teal-dark); font-weight: 700; }
.check-list { list-style: none; margin: 0 0 10px; padding: 0; }
.check-list li { padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 13px; }
.check-list label { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; }
.check-list input { margin-top: 3px; }
.check-list .done { color: var(--muted); text-decoration: line-through; }
.track-row { display: flex; align-items: center; gap: 16px; }
.track-num { font-size: 22px; font-weight: 800; }
.track-arrow { color: var(--muted); font-size: 18px; }
#task-drawer .brief-block { margin-top: 18px; }
#task-drawer .brief-title { margin-bottom: 8px; }
