/* WindEar 精稿樣式
   UI Kit：shadcn/ui create preset b5ALjL03fM
   Lyra 風格 · Zinc 灰階 · 直角（radius 0）· 標題 Noto Serif · 內文 Noto Sans · Remix Icon
   token 名稱照 shadcn，之後換成 React + shadcn 元件時可以直接對上。 */

:root {
  --background: oklch(1 0 0);
  --foreground: oklch(0.141 0.005 285.823);
  --card: oklch(1 0 0);
  --card-foreground: oklch(0.141 0.005 285.823);
  --popover: oklch(1 0 0);
  --primary: oklch(0.21 0.006 285.885);
  --primary-foreground: oklch(0.985 0 0);
  --secondary: oklch(0.967 0.001 286.375);
  --secondary-foreground: oklch(0.21 0.006 285.885);
  --muted: oklch(0.967 0.001 286.375);
  --muted-foreground: oklch(0.552 0.016 285.938);
  --accent: oklch(0.967 0.001 286.375);
  --accent-foreground: oklch(0.21 0.006 285.885);
  --destructive: oklch(0.577 0.245 27.325);
  --success: oklch(0.56 0.12 155);
  --border: oklch(0.92 0.004 286.32);
  --input: oklch(0.92 0.004 286.32);
  --ring: oklch(0.705 0.015 286.067);
  --ring-card: oklch(0.141 0.005 285.823 / 10%);
  --chart-1: oklch(0.871 0.006 286.286);
  --chart-2: oklch(0.552 0.016 285.938);
  --chart-3: oklch(0.442 0.017 285.786);
  --chart-4: oklch(0.37 0.013 285.805);
  --chart-5: oklch(0.274 0.006 286.033);
  --sidebar: oklch(1 0 0);
  --canvas: oklch(0.97 0.001 286.375);
  --sidebar-foreground: oklch(0.141 0.005 285.823);
  --sidebar-accent: oklch(0.967 0.001 286.375);
  --sidebar-border: oklch(0.92 0.004 286.32);
  --radius: 0;
  --font-sans: 'Noto Sans', 'Noto Sans TC', system-ui, sans-serif;
  --font-heading: 'Noto Serif', 'Noto Serif TC', serif;
  --sidebar-w: 248px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --background: oklch(0.141 0.005 285.823);
    --foreground: oklch(0.985 0 0);
    --card: oklch(0.21 0.006 285.885);
    --card-foreground: oklch(0.985 0 0);
    --popover: oklch(0.21 0.006 285.885);
    --primary: oklch(0.92 0.004 286.32);
    --primary-foreground: oklch(0.21 0.006 285.885);
    --secondary: oklch(0.274 0.006 286.033);
    --secondary-foreground: oklch(0.985 0 0);
    --muted: oklch(0.274 0.006 286.033);
    --muted-foreground: oklch(0.705 0.015 286.067);
    --accent: oklch(0.274 0.006 286.033);
    --accent-foreground: oklch(0.985 0 0);
    --destructive: oklch(0.704 0.191 22.216);
    --success: oklch(0.72 0.14 155);
    --border: oklch(1 0 0 / 10%);
    --input: oklch(1 0 0 / 15%);
    --ring: oklch(0.552 0.016 285.938);
    --ring-card: oklch(1 0 0 / 10%);
    --sidebar: oklch(0.21 0.006 285.885);
    --canvas: oklch(0.141 0.005 285.823);
    --sidebar-foreground: oklch(0.985 0 0);
    --sidebar-accent: oklch(0.274 0.006 286.033);
    --sidebar-border: oklch(1 0 0 / 10%);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --background: oklch(0.141 0.005 285.823);
  --foreground: oklch(0.985 0 0);
  --card: oklch(0.21 0.006 285.885);
  --card-foreground: oklch(0.985 0 0);
  --popover: oklch(0.21 0.006 285.885);
  --primary: oklch(0.92 0.004 286.32);
  --primary-foreground: oklch(0.21 0.006 285.885);
  --secondary: oklch(0.274 0.006 286.033);
  --secondary-foreground: oklch(0.985 0 0);
  --muted: oklch(0.274 0.006 286.033);
  --muted-foreground: oklch(0.705 0.015 286.067);
  --accent: oklch(0.274 0.006 286.033);
  --accent-foreground: oklch(0.985 0 0);
  --destructive: oklch(0.704 0.191 22.216);
  --success: oklch(0.72 0.14 155);
  --border: oklch(1 0 0 / 10%);
  --input: oklch(1 0 0 / 15%);
  --ring: oklch(0.552 0.016 285.938);
  --ring-card: oklch(1 0 0 / 10%);
  --sidebar: oklch(0.21 0.006 285.885);
  --canvas: oklch(0.141 0.005 285.823);
  --sidebar-foreground: oklch(0.985 0 0);
  --sidebar-accent: oklch(0.274 0.006 286.033);
  --sidebar-border: oklch(1 0 0 / 10%);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--canvas);
  color: var(--foreground);
  font: 400 13px/1.6 var(--font-sans);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; text-decoration: none; }
button, select, input { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--font-heading); font-weight: 600; margin: 0; letter-spacing: -0.005em; }
.muted { color: var(--muted-foreground); }
.num { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.ri { font-size: 16px; line-height: 1; }

/* ---------- 版面 ---------- */
.app { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--sidebar-w); flex: 0 0 var(--sidebar-w);
  background: var(--sidebar); color: var(--sidebar-foreground);
  border-right: 1px solid var(--sidebar-border);
  position: sticky; top: 0; height: 100vh;
  display: flex; flex-direction: column;
}
.main { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.content { padding: 8px 24px 48px; display: flex; flex-direction: column; gap: 16px; max-width: 1280px; width: 100%; }

/* ---------- 側欄 ---------- */
.sb-head { padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.sb-logo { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 4px; font-family: var(--font-heading); font-weight: 600; font-size: 15px; }
.sb-logo .mark { width: 24px; height: 24px; display: grid; place-items: center; background: var(--primary); color: var(--primary-foreground); }
.sb-logo .mark .ri { font-size: 14px; }
.brand-switch { position: relative; }
.brand-switch select {
  width: 100%; height: 40px; appearance: none; cursor: pointer;
  background: var(--background); border: 1px solid var(--input); padding: 0 32px 0 40px; font-weight: 500;
}
.brand-switch .avatar { position: absolute; left: 8px; top: 8px; pointer-events: none; }
.brand-switch .chev { position: absolute; right: 10px; top: 12px; pointer-events: none; color: var(--muted-foreground); }
.avatar { width: 24px; height: 24px; display: grid; place-items: center; background: var(--muted); border: 1px solid var(--border); font-size: 11px; font-weight: 600; }
.brand-fixed { display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 8px; border: 1px solid var(--border); font-weight: 500; }

.sb-nav { flex: 1; overflow-y: auto; padding: 4px 12px 12px; display: flex; flex-direction: column; }
.sb-group { font-size: 11px; font-weight: 500; color: var(--muted-foreground); padding: 20px 8px 4px; letter-spacing: 0.04em; }
.sb-item {
  display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 8px;
  color: var(--sidebar-foreground); font-size: 13px;
}
.sb-item:hover { background: var(--sidebar-accent); }
.sb-item[aria-current="page"] { background: var(--sidebar-accent); font-weight: 600; box-shadow: inset 2px 0 0 var(--primary); }
.sb-item .ri { color: var(--muted-foreground); }
.sb-item[aria-current="page"] .ri { color: var(--foreground); }
.sb-item .lbl { flex: 1; }
.sb-item .count { font-size: 11px; min-width: 20px; height: 18px; padding: 0 5px; display: grid; place-items: center; border: 1px solid var(--border); background: var(--background); font-variant-numeric: tabular-nums; }
.sb-item .wf { font-size: 10px; color: var(--muted-foreground); border: 1px dashed var(--border); padding: 0 4px; }
.sb-sep { height: 1px; background: var(--sidebar-border); margin: 8px 0; }
.sb-agency { margin-top: auto; }
.sb-layer { font-size: 11px; color: var(--muted-foreground); padding: 8px 8px 4px; display: flex; align-items: center; gap: 6px; }
.sb-foot { padding: 12px; border-top: 1px solid var(--sidebar-border); }
.powered { font-size: 11px; color: var(--muted-foreground); padding: 4px 8px; }

/* ---------- 頁首 ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  height: 52px; padding: 0 24px; display: flex; align-items: center; gap: 12px;
  background: color-mix(in oklch, var(--canvas) 85%, transparent);
  backdrop-filter: blur(8px);
}
.crumbs { display: flex; align-items: center; gap: 6px; color: var(--muted-foreground); font-size: 12px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; }
.crumbs .ri { font-size: 14px; }
.crumbs b { color: var(--foreground); font-weight: 500; }
.top-actions { display: flex; align-items: center; gap: 8px; }

.page-head { display: flex; align-items: center; gap: 8px; padding-top: 8px; }
.page-head .info { width: 20px; height: 20px; }
.page-head .info .ri { font-size: 16px; }

.page-head h1 { font-size: 26px; line-height: 1.25; }
.ro-tag { display: inline-flex; align-items: center; gap: 4px; margin-left: 8px; font-size: 12px; color: var(--muted-foreground); }
.ro-tag .ri { font-size: 14px; }
.page-head p { margin: 4px 0 0; color: var(--muted-foreground); }

/* ---------- 元件：Button／Select／Badge／Segmented ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 32px; padding: 0 10px; font-size: 12px; font-weight: 500; white-space: nowrap; cursor: pointer;
  border: 1px solid var(--input); background: var(--background); transition: background .15s;
}
.btn:hover { background: var(--accent); }
.btn.primary { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.btn.primary:hover { background: color-mix(in oklch, var(--primary) 90%, var(--background)); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--accent); }
.btn.icon { width: 32px; padding: 0; }
.btn.sm { height: 28px; padding: 0 8px; }

.select { position: relative; display: inline-flex; align-items: center; }
.select select {
  appearance: none; height: 32px; padding: 0 28px 0 10px; cursor: pointer; font-size: 12px;
  border: 1px solid var(--input); background: var(--background);
}
.select .ri { position: absolute; right: 8px; pointer-events: none; color: var(--muted-foreground); font-size: 14px; }
.select .pre { color: var(--muted-foreground); margin-right: 4px; }
.select.active select { border-color: var(--foreground); }

.badge { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 8px; font-size: 11px; font-weight: 500; border: 1px solid var(--border); white-space: nowrap; }
.badge.solid { background: var(--primary); color: var(--primary-foreground); border-color: transparent; }
.badge.soft { background: var(--muted); border-color: transparent; }

.seg { display: inline-flex; border: 1px solid var(--input); padding: 2px; background: var(--muted); }
.seg button { height: 26px; padding: 0 10px; font-size: 12px; font-weight: 500; border: 0; background: transparent; color: var(--muted-foreground); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--background); color: var(--foreground); box-shadow: 0 0 0 1px var(--border); }

/* ---------- 篩選列 ---------- */
.filters { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.filters .hint { font-size: 11px; color: var(--muted-foreground); display: inline-flex; align-items: center; gap: 4px; margin-left: 4px; }

/* ---------- Card ---------- */
.card { background: var(--card); color: var(--card-foreground); box-shadow: 0 0 0 1px var(--ring-card); display: flex; flex-direction: column; }
.card-head { padding: 16px 16px 0; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.card-title { font-family: var(--font-heading); font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.card-desc { font-size: 12px; color: var(--muted-foreground); margin-top: 2px; }
.card-body { padding: 16px; flex: 1; }
.card-foot { padding: 10px 16px; border-top: 1px solid var(--border); font-size: 12px; color: var(--muted-foreground); display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.link { display: inline-flex; align-items: center; gap: 2px; font-weight: 500; color: var(--foreground); cursor: pointer; background: none; border: 0; padding: 0; font-size: 12px; }
.link:hover { text-decoration: underline; text-underline-offset: 3px; }

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

/* ---------- 總覽上排：2×2 指標卡＋AI 流量 ---------- */
.overview-top { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.kpi-2x2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.kpi { padding: 16px; gap: 10px; }
.kpi-label { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted-foreground); font-weight: 500; }
.kpi-label a:hover { color: var(--foreground); text-decoration: underline; text-underline-offset: 3px; }
.kpi-label .go { margin-left: auto; color: var(--muted-foreground); }
.kpi-row { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.kpi-value { font-family: var(--font-heading); font-size: 32px; font-weight: 600; line-height: 1.1; font-variant-numeric: tabular-nums; }
.delta { display: inline-flex; align-items: center; gap: 2px; font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
.delta .ri { font-size: 14px; }
.delta.up { color: var(--success); }
.delta.down { color: var(--destructive); }
.delta .vs { color: var(--muted-foreground); font-weight: 400; margin-left: 4px; }
.kpi-meta { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 12px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: auto; }
.kpi-meta .rank b { font-weight: 600; }

.info { position: relative; display: inline-grid; place-items: center; width: 16px; height: 16px; border: 0; background: none; padding: 0; color: var(--muted-foreground); cursor: help; }
.info .ri { font-size: 14px; }
.info:hover::after, .info:focus-visible::after {
  content: attr(data-tip); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%);
  width: 220px; padding: 6px 8px; background: var(--primary); color: var(--primary-foreground);
  font-size: 12px; font-weight: 400; line-height: 1.5; text-align: left; z-index: 20; white-space: normal;
}

.traffic .card-body { display: flex; flex-direction: column; padding-top: 8px; }
.t-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--border); }
.t-row:last-child { border-bottom: 0; }
.t-row .t-label { font-size: 12px; color: var(--muted-foreground); }
.t-row .t-value { font-family: var(--font-heading); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.2; }
.t-row .t-side { text-align: right; font-size: 11px; color: var(--muted-foreground); display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.t-empty { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; justify-content: center; flex: 1; }
.t-empty .icons { display: flex; gap: 6px; }
.t-empty .icons span { width: 32px; height: 32px; display: grid; place-items: center; border: 1px solid var(--border); background: var(--muted); }

/* ---------- 圖表 ---------- */
.legend { display: flex; gap: 14px; flex-wrap: wrap; font-size: 12px; color: var(--muted-foreground); }
.legend i { display: inline-block; width: 10px; height: 2px; vertical-align: middle; margin-right: 6px; background: currentColor; }
.legend i.dash { background: repeating-linear-gradient(90deg, currentColor 0 3px, transparent 3px 5px); }
.chart svg { display: block; width: 100%; height: auto; overflow: visible; }
.chart .grid line { stroke: var(--border); }
.chart .axis text { fill: var(--muted-foreground); font-size: 11px; font-family: var(--font-sans); }
.chart path.s-own { stroke: var(--own-line, var(--foreground)); }
.chart path.s-cite { stroke: var(--chart-2); }
.chart path.s-rival { stroke: var(--chart-2); stroke-dasharray: 4 3; }
.chart .dot { fill: var(--background); stroke: var(--own-line, var(--foreground)); }
.chart .hover-line { stroke: var(--ring); }
.chart-tip { position: absolute; pointer-events: none; background: var(--popover); box-shadow: 0 0 0 1px var(--ring-card), 0 4px 16px oklch(0 0 0 / 8%); padding: 8px 10px; font-size: 12px; min-width: 150px; display: none; z-index: 5; }
.chart-tip .row { display: flex; justify-content: space-between; gap: 12px; }
.chart-wrap { position: relative; }

.hbars { display: flex; flex-direction: column; gap: 10px; }
.hbar { display: grid; grid-template-columns: 112px minmax(0, 1fr) 48px; align-items: center; gap: 10px; font-size: 12px; }
.hbar .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hbar button.name { text-align: left; background: none; border: 0; padding: 0; cursor: pointer; }
.hbar button.name:hover, .hbar a.name:hover { text-decoration: underline; text-underline-offset: 3px; }
.hbar .track { height: 8px; background: var(--muted); position: relative; }
.hbar .fill { position: absolute; inset: 0 auto 0 0; background: var(--chart-2); }
.hbar.own .fill { background: var(--foreground); }
.hbar.own .name { font-weight: 600; }
.hbar .val { text-align: right; font-variant-numeric: tabular-nums; }

.stack { display: flex; height: 28px; gap: 2px; }
.stack span { display: grid; place-items: center; font-size: 11px; font-weight: 500; }
.stack .pos { background: var(--foreground); color: var(--background); }
.stack .neu { background: var(--chart-1); color: var(--foreground); }
.stack .neg { background: var(--destructive); color: #fff; }
.tone-legend { display: flex; gap: 20px; margin-top: 12px; font-size: 12px; flex-wrap: wrap; }
.tone-legend span { display: inline-flex; align-items: center; gap: 6px; }
.tone-legend i { width: 8px; height: 8px; display: inline-block; }

/* ---------- Tabs ---------- */
.tabs { display: inline-flex; align-self: flex-start; background: var(--muted); padding: 3px; gap: 2px; max-width: 100%; overflow-x: auto; }
.tabs button { height: 28px; padding: 0 12px; border: 1px solid transparent; background: transparent; color: color-mix(in oklch, var(--foreground) 60%, transparent); font-size: 12px; font-weight: 500; cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.tabs button:hover { color: var(--foreground); }
.tabs button[aria-selected="true"] { background: var(--background); color: var(--foreground); box-shadow: 0 0 0 1px var(--border); }
.tabs.sm button { height: 24px; padding: 0 10px; }
.tab-count { font-size: 11px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

/* ---------- 表格 ---------- */
.toolbar { display: flex; align-items: center; gap: 8px; padding: 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.search { position: relative; display: inline-flex; align-items: center; flex: 0 1 260px; }
.search .ri { position: absolute; left: 9px; color: var(--muted-foreground); font-size: 14px; }
.search input { width: 100%; height: 32px; border: 1px solid var(--input); background: var(--background); padding: 0 10px 0 30px; font-size: 12px; outline: none; }
.search input:focus-visible { border-color: var(--ring); }
.table-wrap { overflow-x: auto; position: relative; }
.table { width: 100%; border-collapse: collapse; font-size: 13px; }
.table th { text-align: left; font-weight: 500; font-size: 12px; color: var(--muted-foreground); height: 36px; padding: 0 12px; border-bottom: 1px solid var(--border); white-space: nowrap; }
.table td { padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap; vertical-align: middle; }
.table td.wide { white-space: normal; min-width: 240px; }
.table tbody tr:hover { background: color-mix(in oklch, var(--muted) 60%, transparent); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .num, .num { font-variant-numeric: tabular-nums; }
.cell-link { background: none; border: 0; padding: 0; text-align: left; cursor: pointer; font-weight: 500; color: var(--foreground); }
.cell-link:hover { text-decoration: underline; text-underline-offset: 3px; }
.no-match { padding: 24px 16px; margin: 0; }
.meter { display: inline-flex; align-items: center; gap: 8px; }
.meter .track { width: 64px; height: 6px; background: var(--muted); position: relative; display: inline-block; }
.meter .fill { position: absolute; inset: 0 auto 0 0; background: var(--foreground); }
.badge.warn { border-color: color-mix(in oklch, var(--destructive) 40%, transparent); color: var(--destructive); }
.badge.as-btn { cursor: pointer; background: transparent; font: inherit; font-size: 11px; font-weight: 500; }
.badge.solid.as-btn { background: var(--primary); }
.badge.as-btn:hover { box-shadow: 0 0 0 1px var(--ring); }
.warn-txt { color: var(--destructive); font-weight: 500; }
.ok { display: inline-flex; align-items: center; gap: 2px; }
.ok .ri { font-size: 14px; color: var(--success); }
.tone { display: inline-flex; align-items: center; gap: 6px; }
.tone i { width: 6px; height: 6px; display: inline-block; }
.t-pos { background: var(--foreground); } .t-neu { background: var(--chart-1); outline: 1px solid var(--chart-2); outline-offset: -1px; } .t-neg { background: var(--destructive); }
.site { display: inline-flex; align-items: center; gap: 8px; }
.site .ri { font-size: 16px; }
.fav { width: 18px; height: 18px; display: inline-grid; place-items: center; background: var(--muted); border: 1px solid var(--border); font-size: 10px; font-weight: 600; color: var(--muted-foreground); }

/* ---------- Sheet（標準面板） ---------- */
body.sheet-open { overflow: hidden; }
.scrim { position: fixed; inset: 0; background: oklch(0 0 0 / 30%); z-index: 40; }
.sheet { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); z-index: 41; background: var(--background); box-shadow: -1px 0 0 var(--border), -16px 0 48px oklch(0 0 0 / 12%); display: flex; flex-direction: column; }
.sheet.enter { animation: sheet-in .2s ease-out; }
@keyframes sheet-in { from { transform: translateX(24px); opacity: 0; } to { transform: none; opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .sheet.enter { animation: none; } }
.sheet-head { padding: 12px 20px 16px; border-bottom: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; }
.sheet-bar { display: flex; align-items: center; gap: 8px; }
.crumb-trail { flex: 1; display: flex; align-items: center; gap: 2px; font-size: 11px; color: var(--muted-foreground); min-width: 0; overflow: hidden; white-space: nowrap; }
.crumb-trail span { display: inline-flex; align-items: center; gap: 4px; }
.crumb-trail .ri { font-size: 13px; }
.crumb-trail .cur { color: var(--foreground); font-weight: 500; }
.sheet-head h2 { font-size: 18px; line-height: 1.4; outline: none; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 20px 32px; display: flex; flex-direction: column; gap: 18px; }
.sheet-body > *, .content > * { flex-shrink: 0; min-width: 0; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); box-shadow: 0 0 0 1px var(--ring-card); }
.stat { padding: 12px 14px; font-size: 12px; }
.stat + .stat { box-shadow: -1px 0 0 var(--border); }
.stat-v { font-family: var(--font-heading); font-size: 22px; font-weight: 600; font-variant-numeric: tabular-nums; line-height: 1.3; color: var(--foreground); }
.p-sec { display: flex; flex-direction: column; gap: 10px; }
.p-sec p { margin: 0; }
.p-sec-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.p-sec h3 { font-size: 13px; }
.list { display: flex; flex-direction: column; box-shadow: 0 0 0 1px var(--ring-card); }
.list-row { display: flex; align-items: center; gap: 8px; padding: 9px 12px; font-size: 12px; }
.list-row + .list-row { border-top: 1px solid var(--border); }
a.list-row:hover { background: var(--muted); }
.list-row .ri { color: var(--muted-foreground); }
.url { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; color: var(--muted-foreground); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote { margin: 0; padding: 12px 14px; background: var(--muted); border-left: 2px solid var(--foreground); line-height: 1.8; }
.quote mark { background: var(--foreground); color: var(--background); padding: 0 3px; }
.steps { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0; counter-reset: s; }
.steps li { display: flex; align-items: flex-start; gap: 10px; padding: 6px 0 6px 0; position: relative; }
.steps li .ri { width: 24px; height: 24px; display: grid; place-items: center; border: 1px solid var(--border); background: var(--background); font-size: 13px; flex: 0 0 24px; color: var(--muted-foreground); z-index: 1; }
.steps li span { padding-top: 2px; }
.steps li:not(:last-child)::before { content: ''; position: absolute; left: 12px; top: 30px; bottom: -6px; width: 1px; background: var(--border); }
.p-q { display: flex; align-items: flex-start; gap: 6px; font-size: 12px; }
.p-q .ri { color: var(--muted-foreground); margin-top: 2px; }
.matrix td, .matrix th { padding-left: 10px; padding-right: 10px; }
.sheet .hbar { grid-template-columns: 112px minmax(0, 1fr) 96px; }

/* ---------- 引用缺口 ---------- */
.gap-card { text-align: left; font: inherit; color: inherit; border: 0; cursor: pointer; padding: 16px; gap: 10px; transition: box-shadow .15s; }
.gap-card:hover { box-shadow: 0 0 0 1px var(--ring); }
.gap-card.on { box-shadow: 0 0 0 2px var(--foreground); }
.gap-card p { margin: 0; font-size: 12px; }
.gap-top { display: flex; align-items: center; gap: 8px; }
.gap-ic { width: 28px; height: 28px; display: grid; place-items: center; background: var(--muted); border: 1px solid var(--border); }
.gap-bar { height: 6px; background: var(--muted); position: relative; }
.gap-bar span { position: absolute; inset: 0 auto 0 0; background: var(--foreground); }
.dots { display: inline-flex; align-items: center; gap: 3px; }
.dots i { width: 8px; height: 8px; display: inline-block; background: var(--muted); box-shadow: inset 0 0 0 1px var(--border); }
.dots.rival i.on { background: var(--destructive); box-shadow: none; }
.dots.none i.on { background: var(--foreground); box-shadow: none; }
.dots .num { margin-left: 6px; font-size: 12px; }
.table td.act { width: 40px; padding: 4px 8px; text-align: right; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- 資料正確度 ---------- */
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.badge .ri { font-size: 12px; }
.badge.bad { background: var(--destructive); color: #fff; border-color: transparent; }
.badge.as-link:hover { box-shadow: 0 0 0 1px var(--ring); }
.gap-ic.v-bad { color: var(--destructive); }
.gap-ic.v-ok { color: var(--success); }
.table td.wide-s { white-space: normal; min-width: 160px; }
.official { font-family: var(--font-heading); }
.wrong { color: var(--destructive); font-weight: 600; text-decoration: underline wavy color-mix(in oklch, var(--destructive) 50%, transparent); text-underline-offset: 4px; }
.src { display: inline-flex; align-items: flex-start; gap: 4px; font-size: 12px; color: var(--muted-foreground); }
.src .ri { font-size: 13px; margin-top: 2px; }
.compare { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; font-size: 12px; }
.compare .quote { margin-top: 6px; font-size: 13px; }
.quote.bad { border-left-color: var(--destructive); color: var(--destructive); font-weight: 600; }
@media (max-width: 860px) { .grid-3, .compare { grid-template-columns: minmax(0, 1fr); } }

/* ---------- 待辦行動（看板） ---------- */
.board { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; align-items: start; }
.col { background: var(--card); box-shadow: 0 0 0 1px var(--ring-card); display: flex; flex-direction: column; min-height: 200px; }
.col-head { display: flex; align-items: center; gap: 6px; padding: 12px 14px; font-weight: 600; font-size: 13px; border-bottom: 1px solid var(--border); }
.col-head .ri { color: var(--muted-foreground); }
.col-head .count { margin-left: auto; font-size: 11px; font-weight: 500; min-width: 20px; height: 18px; padding: 0 5px; display: grid; place-items: center; background: var(--muted); }
.col-body { display: flex; flex-direction: column; gap: 8px; padding: 10px; }
.col-empty { font-size: 12px; padding: 12px 4px; margin: 0; }
.task-card { display: flex; flex-direction: column; align-items: stretch; text-align: left; font: inherit; color: inherit; background: var(--card); border: 1px solid var(--border); padding: 12px; gap: 6px; cursor: pointer; transition: border-color .15s, box-shadow .15s; }
.task-card:hover { border-color: var(--ring); }
.task-card:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
.task-from { display: inline-flex; align-items: center; gap: 4px; align-self: flex-start; font-size: 11px; color: var(--muted-foreground); background: var(--muted); padding: 2px 6px; }
.task-title { font-weight: 600; font-size: 14px; line-height: 1.45; }
.task-ref { font-size: 12px; color: var(--muted-foreground); line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.task-check { display: flex; gap: 8px; font-size: 12px; color: var(--muted-foreground); line-height: 1.5; border-top: 1px dashed var(--border); padding-top: 8px; margin-top: 2px; }
.task-check b { flex: 0 0 auto; font-weight: 500; color: var(--foreground); }
.task-card.done .task-title { color: var(--muted-foreground); text-decoration: line-through; text-decoration-color: var(--border); }
button.list-row { width: 100%; text-align: left; font: inherit; font-size: 12px; color: inherit; background: none; border: 0; cursor: pointer; }
button.list-row:hover { background: var(--muted); }
@media (max-width: 860px) { .board { grid-template-columns: minmax(0, 1fr); } .col { min-height: 0; } }

/* ---------- 報告 ---------- */
.report-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }
.r-settings { position: sticky; top: 64px; }
.field { display: flex; flex-direction: column; gap: 6px; border: 0; margin: 0; padding: 0; min-width: 0; }
.field-label { font-size: 12px; font-weight: 600; padding: 0; margin-bottom: 2px; }
.check { display: flex; align-items: center; gap: 8px; height: 28px; cursor: pointer; font-size: 13px; }
.check input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.check .box { width: 16px; height: 16px; border: 1px solid var(--input); display: grid; place-items: center; background: var(--background); }
.check .box .ri { font-size: 12px; visibility: hidden; }
.check input:checked + .box { background: var(--primary); border-color: var(--primary); color: var(--primary-foreground); }
.check input:checked + .box .ri { visibility: visible; }
.check input:focus-visible + .box { outline: 2px solid var(--ring); outline-offset: 2px; }
.r-paper { --r-accent: var(--foreground); background: var(--card); box-shadow: 0 0 0 1px var(--ring-card), 0 8px 32px oklch(0 0 0 / 6%); padding: 40px 48px; max-width: 820px; width: 100%; display: flex; flex-direction: column; gap: 28px; }
.r-head { display: flex; align-items: center; gap: 10px; padding-bottom: 16px; border-bottom: 2px solid var(--r-accent); }
.r-mark { width: 32px; height: 32px; display: grid; place-items: center; background: var(--r-accent); color: var(--background); font-weight: 700; }
.r-logo { height: 32px; max-width: 120px; object-fit: contain; }
.r-org { font-weight: 600; }
.r-title h1 { font-size: 28px; line-height: 1.3; }
.r-title p { margin: 8px 0 0; }
.r-sec { display: flex; flex-direction: column; gap: 12px; break-inside: avoid; }
.r-sec h2 { font-size: 16px; padding-bottom: 6px; border-bottom: 1px solid var(--border); }
.r-lead { margin: 0; font-size: 12px; color: var(--muted-foreground); }
.r-points { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; line-height: 1.8; }
.r-stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); box-shadow: 0 0 0 1px var(--ring-card); }
.r-stats > div { padding: 12px 14px; display: flex; flex-direction: column; }
.r-stats > div + div { box-shadow: -1px 0 0 var(--border); }
.r-stats b { font-family: var(--font-heading); font-size: 22px; font-variant-numeric: tabular-nums; }
.r-stats span { font-size: 12px; color: var(--muted-foreground); }
.r-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.r-table td { white-space: normal; }
.r-foot { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; font-size: 11px; color: var(--muted-foreground); border-top: 1px solid var(--border); padding-top: 12px; }
@media (max-width: 1080px) { .report-layout { grid-template-columns: minmax(0, 1fr); } .r-settings { position: static; } }
@media (max-width: 860px) { .r-paper { padding: 24px 20px; } }
@media print {
  :root { --background: #fff; --card: #fff; --foreground: #111; }
  .sidebar, .topbar, .page-head, .filters, .r-settings, .toast { display: none !important; }
  .content { padding: 0; max-width: none; }
  .report-layout { display: block; }
  .r-paper { box-shadow: none; padding: 0; max-width: none; }
}

/* ---------- 品牌設定 ---------- */
.set-layout { display: flex; flex-direction: column; gap: 16px; }
.set-nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); overflow-x: auto; }
.set-nav button { display: flex; align-items: center; gap: 6px; height: 38px; padding: 0 12px; border: 0; background: transparent; cursor: pointer; font-size: 13px; color: var(--muted-foreground); white-space: nowrap; flex: 0 0 auto; margin-bottom: -1px; }
.set-nav button:hover { color: var(--foreground); }
.set-nav button[aria-current] { color: var(--foreground); font-weight: 600; box-shadow: inset 0 -2px 0 var(--foreground); }
.set-body { display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; }
.form-grid .span-2 { grid-column: 1 / -1; }
.input { height: 32px; border: 1px solid var(--input); background: var(--background); padding: 0 10px; font-size: 13px; width: 100%; outline: none; }
.input:focus-visible { border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklch, var(--ring) 30%, transparent); }
.input:disabled { background: var(--muted); color: var(--muted-foreground); cursor: not-allowed; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chips .badge { height: 26px; padding: 0 4px 0 10px; font-size: 12px; }
.chip-x { border: 0; background: none; padding: 0; width: 18px; height: 18px; display: grid; place-items: center; cursor: pointer; color: var(--muted-foreground); }
.chip-x:hover { color: var(--foreground); }
.notice { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--muted); font-size: 12px; }
.conn { display: flex; align-items: center; gap: 12px; padding: 14px 0; border-bottom: 1px solid var(--border); }
.conn:last-child { border-bottom: 0; }
.conn-ic { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--border); background: var(--muted); }
.conn-ic .ri { font-size: 18px; }
.wl-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.wl-preview-col { display: flex; flex-direction: column; gap: 8px; }
.upload { display: flex; align-items: center; gap: 10px; }
.upload label.btn { cursor: pointer; }
.wl-mark { display: grid; place-items: center; color: #fff; font-weight: 700; flex: 0 0 auto; }
.wl-logo { max-width: 140px; object-fit: contain; }
.color-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.color-row input[type="color"] { width: 36px; height: 32px; padding: 2px; border: 1px solid var(--input); background: var(--background); cursor: pointer; }
.swatch { width: 22px; height: 22px; border: 0; cursor: pointer; box-shadow: inset 0 0 0 1px oklch(0 0 0 / 15%); }
.swatch.on { outline: 2px solid var(--foreground); outline-offset: 2px; }
.pv-app { display: grid; grid-template-columns: 140px 1fr; height: 200px; box-shadow: 0 0 0 1px var(--ring-card); background: var(--background); font-size: 11px; overflow: hidden; }
.pv-side { background: var(--sidebar); border-right: 1px solid var(--border); padding: 10px 8px; display: flex; flex-direction: column; gap: 2px; }
.pv-brand { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-size: 12px; overflow: hidden; white-space: nowrap; }
.pv-item { padding: 4px 6px; color: var(--muted-foreground); }
.pv-item.on { background: var(--muted); color: var(--foreground); font-weight: 600; box-shadow: inset 2px 0 0 var(--pv); }
.pv-powered { margin-top: auto; font-size: 10px; color: var(--muted-foreground); }
.pv-main { padding: 12px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.pv-h { font-family: var(--font-heading); font-weight: 600; font-size: 14px; }
.pv-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; width: 100%; }
.pv-cards span { height: 52px; box-shadow: 0 0 0 1px var(--ring-card); }
.pv-btn { background: var(--pv); color: #fff; padding: 4px 10px; font-weight: 500; }
.pv-report { box-shadow: 0 0 0 1px var(--ring-card); background: var(--card); padding: 14px; display: flex; flex-direction: column; gap: 10px; }
.pv-report .r-head { gap: 8px; font-size: 13px; }
.pv-lines { display: flex; flex-direction: column; gap: 6px; }
.pv-lines span { height: 6px; background: var(--muted); }
.pv-lines span:nth-child(2) { width: 80%; } .pv-lines span:nth-child(3) { width: 60%; }
.sb-logo.wl { font-family: var(--font-sans); font-size: 14px; height: auto; min-height: 32px; }
@media (max-width: 1080px) { .wl-layout { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- AI 流量與搜尋 ---------- */
.grid-4 { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; }
.grid-traffic { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 16px; }
.legend i.sq { width: 10px; height: 10px; }
@media (max-width: 1080px) { .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-traffic { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 860px) { .grid-4 { grid-template-columns: minmax(0, 1fr); } }

/* ---------- 代理商層 ---------- */
.brand-go { display: inline-flex; align-items: center; gap: 10px; background: none; border: 0; padding: 0; cursor: pointer; text-align: left; }
.brand-go:hover b { text-decoration: underline; text-underline-offset: 3px; }
.sec-title { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.sec-title h2 { font-size: 16px; }
.plan.on { box-shadow: 0 0 0 2px var(--foreground); }
.plan-price { font-family: var(--font-heading); font-size: 22px; font-weight: 600; margin-bottom: 12px; }
.plan-price .muted { font-family: var(--font-sans); font-size: 12px; font-weight: 400; margin-left: 4px; }
.plan-feats { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; font-size: 12px; }
.plan-feats li { display: flex; gap: 6px; align-items: flex-start; }
.plan-feats .ri { font-size: 14px; color: var(--success); margin-top: 1px; }
.plan-feats li.no { color: var(--muted-foreground); }
.plan-feats li.no .ri { color: var(--muted-foreground); }

/* ---------- 其他 ---------- */
.toast { position: fixed; bottom: 20px; right: 20px; z-index: 60; background: var(--primary); color: var(--primary-foreground); padding: 10px 14px; font-size: 12px; z-index: 50; max-width: 360px; }
.wf-banner { display: flex; align-items: center; gap: 10px; padding: 12px 16px; border: 1px dashed var(--border); color: var(--muted-foreground); }

/* ---------- 窄螢幕 ---------- */
@media (max-width: 1080px) {
  .overview-top { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 860px) {
  .sidebar { position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%); transition: transform .2s; }
  .app.sb-open .sidebar { transform: none; box-shadow: 0 0 0 100vmax oklch(0 0 0 / 30%); }
  .grid-2, .kpi-2x2 { grid-template-columns: minmax(0, 1fr); }
  .content, .topbar { padding-left: 16px; padding-right: 16px; }
  .viewer-label, .crumbs > :not(b) { display: none; }
}

/* 題庫：分平台頻率、啟用開關 */
.select.freq select { min-width: 92px; }
.select.freq.off select { color: var(--muted-foreground); border-style: dashed; }
.table tr.row-off td:not(:nth-last-child(-n+2)) { opacity: .5; }
.switch { position: relative; width: 34px; height: 18px; border: 1px solid var(--border); background: var(--muted); cursor: pointer; padding: 0; flex-shrink: 0; }
.switch span { position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; background: var(--muted-foreground); transition: transform .15s; }
.switch[aria-checked="true"] { background: var(--primary); border-color: var(--primary); }
.switch[aria-checked="true"] span { transform: translateX(16px); background: var(--primary-foreground); }
.switch:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* 總覽頂部卡片相連、不留間距：1px 間隙露出底色當分隔線 */
.overview-top, .overview-top .kpi-2x2 { gap: 1px; background: var(--ring-card); }
.overview-top { box-shadow: 0 0 0 1px var(--ring-card); }
.overview-top .card { box-shadow: none; }
/* 內層不要再鋪一次半透明底色，否則四張 KPI 卡之間的線會疊成兩倍深 */
.overview-top .kpi-2x2 { background: transparent; }

/* 和競品的趨勢：自家粗黑線，競品用配色 C（顏色寫在每條線的 style）；右側直接標名稱 */
.chart .line.off, .chart .end-label.off { display: none; }
.chart .end-label { font-size: 11px; font-family: var(--font-sans); fill: var(--muted-foreground); }
.chart .end-label.s-own { fill: var(--foreground); font-weight: 600; }
.legend-btn { display: inline-flex; align-items: center; border: 0; background: none; padding: 0; font: inherit; color: var(--muted-foreground); cursor: pointer; }
.legend-btn.s-own { color: var(--foreground); font-weight: 600; }
.legend-btn i { width: 14px; height: 2px; }
.legend-btn.s-own i { height: 3px; background: var(--own-line, var(--foreground)); }
.legend-btn.s-rc i { height: 2px; }
.legend-btn[aria-pressed="false"] { opacity: .4; text-decoration: line-through; }

/* 各 AI 平台表現：品牌 × 平台熱圖 */
.heat { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; min-width: 640px; }
.heat th, .heat td { text-align: left; padding: 8px 16px; vertical-align: middle; }
.heat .hv small { font-size: 11px; color: var(--muted-foreground); font-weight: 400; margin-left: 6px; }
.heat thead th { font-weight: 500; font-size: 13px; color: var(--muted-foreground); border-bottom: 1px solid var(--border); }
.heat .hn { display: block; font-size: 11px; color: var(--muted-foreground); font-weight: 400; margin-top: 2px; }
.heat .hv { display: block; font-size: 14px; white-space: nowrap; color: var(--foreground); }
.heat tbody tr + tr > * { border-top: 1px solid var(--card); }
.heat tbody tr.own > * { border-bottom: 1px solid var(--border); }
.heat-brand { white-space: nowrap; font-weight: 500; width: 180px; }
.heat tr.own .heat-brand, .heat tr.own .hv { font-weight: 700; }
.heat-all { border-left: 1px solid var(--border); }
.heat tbody .heat-all .hv { font-weight: 600; }
.heat-head, .heat-link { border: 0; background: none; padding: 0; font: inherit; color: inherit; text-align: left; cursor: pointer; width: 100%; }
.heat-head:hover { color: var(--foreground); text-decoration: underline; text-underline-offset: 3px; }
.heat-link:hover .hv { text-decoration: underline; text-underline-offset: 3px; }
.heat-head:focus-visible, .heat-link:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }

/* 題目設定面板：左標籤、右欄位 */
.form-rows { display: flex; flex-direction: column; gap: 12px; }
.form-row { display: grid; grid-template-columns: 88px minmax(0, 1fr); gap: 12px; align-items: start; }
.form-row > .field-label { padding-top: 7px; color: var(--muted-foreground); font-weight: 500; }
.form-row > span:not(.field-label) { padding-top: 7px; }
.form-row .select, .form-row .select select { width: 100%; }

/* 主題管理與題庫的主題欄 */
.topic-bar { display: flex; align-items: center; gap: 8px; padding: 10px 16px; flex-wrap: wrap; }
.topic-bar .info { width: 18px; height: 18px; }
.topic-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-left: 8px; flex: 1; }
.topic-chip { display: inline-flex; align-items: center; gap: 6px; height: 26px; padding: 0 4px 0 10px; font-size: 12px; border: 1px solid var(--border); }
.topic-chip b { font-weight: 500; }
.topic-chip .chip-x .ri { font-size: 13px; }
.topic-chip.editing { padding: 0; border: 0; gap: 4px; }
.topic-chip.editing .input { height: 26px; width: 120px; font-size: 12px; }
.topic-add .input { height: 26px; width: 160px; font-size: 12px; }
/* 題目底下展開的主題與旅程階段 */
.pedit-toggle { display: inline-flex; align-items: flex-start; gap: 4px; text-align: left; }
.pedit-toggle .ri { margin-top: 2px; color: var(--muted-foreground); }
.table tr.pedit-row > td { background: var(--muted); padding: 12px 16px 14px 34px; }
.pedit-row .chips { gap: 4px; align-items: center; }
.pedit-row .badge { height: 22px; font-size: 11px; }
.form-row .select.add-topic, .form-row .select.add-topic select { width: 32px; flex: none; }
.pedit-row .seg { align-self: flex-start; }
.select.add-topic select { height: 22px; width: 32px; padding: 0; text-align: center; text-align-last: center; font-size: 13px; cursor: pointer; }

/* 頁面標題旁的說明：往下展開（放在 .info:hover 之後才蓋得過） */
.info.below:hover::after, .info.below:focus-visible::after { bottom: auto; top: calc(100% + 6px); left: 0; transform: none; width: 300px; }

/* 期間：日期區間選擇器 */
.date-wrap { position: relative; }
.date-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 10px; border: 1px solid var(--input); background: var(--background); font: inherit; font-size: 12px; font-weight: 500; color: var(--foreground); cursor: pointer; white-space: nowrap; }
.date-btn .pre { color: var(--muted-foreground); font-weight: 400; }
.date-btn .muted { font-weight: 400; margin-left: 2px; }
.date-btn .ri { color: var(--muted-foreground); font-size: 14px; }
.date-btn.active { border-color: var(--foreground); }
.date-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; display: flex; background: var(--popover, var(--card)); box-shadow: 0 0 0 1px var(--ring-card), 0 8px 24px oklch(0 0 0 / 10%); }
.dp-presets { display: flex; flex-direction: column; gap: 2px; padding: 8px; border-right: 1px solid var(--border); min-width: 104px; }
.dp-presets button { text-align: left; border: 0; background: none; font: inherit; font-size: 12px; height: 30px; padding: 0 10px; cursor: pointer; color: var(--muted-foreground); }
.dp-presets button:hover { background: var(--muted); color: var(--foreground); }
.dp-presets button[aria-pressed="true"] { background: var(--muted); color: var(--foreground); font-weight: 600; }
.dp-main { position: relative; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.dp-nav { position: absolute; top: 8px; left: 8px; right: 8px; display: flex; justify-content: space-between; pointer-events: none; }
.dp-nav .btn { pointer-events: auto; }
.dp-months { display: flex; gap: 20px; }
.month-name { text-align: center; font-size: 12px; font-weight: 600; height: 28px; line-height: 28px; }
.dow, .days { display: grid; grid-template-columns: repeat(7, 32px); }
.dow span { text-align: center; font-size: 11px; color: var(--muted-foreground); height: 24px; line-height: 24px; }
.day { height: 32px; border: 0; background: none; font: inherit; font-size: 12px; color: var(--foreground); cursor: pointer; font-variant-numeric: tabular-nums; }
.day:hover:not(:disabled) { background: var(--muted); }
.day:disabled { color: var(--muted-foreground); opacity: .4; cursor: default; }
.day.today { text-decoration: underline; text-underline-offset: 3px; }
.day.mid { background: var(--muted); }
.day.start, .day.end { background: var(--primary); color: var(--primary-foreground); }
.day:focus-visible { outline: 2px solid var(--ring); outline-offset: -2px; }
.dp-foot { display: flex; align-items: center; gap: 8px; border-top: 1px solid var(--border); padding-top: 10px; font-size: 12px; }
.dp-foot .muted { margin-right: auto; }
@media (max-width: 720px) {
  .date-pop { flex-direction: column; left: 0; right: auto; width: calc(100vw - 32px); }
  .dp-presets { flex-direction: row; flex-wrap: wrap; border-right: 0; border-bottom: 1px solid var(--border); }
  .dp-months .month + .month { display: none; }
  .dow, .days { grid-template-columns: repeat(7, minmax(0, 1fr)); }
}

/* 題目範圍分頁：和篩選下拉同高 */
.filters .scope-tabs { height: 32px; align-items: stretch; }
.filters .scope-tabs button { height: auto; font-size: 12px; }

/* 和競品的趨勢：時間維度＋指標兩組切換 */
.trend-ctl { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* 更多篩選（回答與引用） */
.more-wrap { position: relative; }
.more-n { display: inline-grid; place-items: center; min-width: 16px; height: 16px; padding: 0 4px; background: var(--foreground); color: var(--background); font-size: 11px; font-weight: 600; }
.more-pop { position: absolute; top: calc(100% + 6px); left: 0; z-index: 30; width: min(340px, calc(100vw - 60px)); padding: 14px; display: flex; flex-direction: column; gap: 14px; background: var(--popover, var(--card)); box-shadow: 0 0 0 1px var(--ring-card), 0 8px 24px oklch(0 0 0 / 10%); }
.more-group { display: flex; flex-direction: column; gap: 6px; }
.more-label { display: flex; align-items: center; gap: 4px; font-size: 12px; color: var(--muted-foreground); }
.seg.seg-fill { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; width: 100%; }
.seg.seg-fill button { height: 30px; }
.more-foot { display: flex; justify-content: flex-end; border-top: 1px solid var(--border); padding-top: 10px; margin-top: -2px; }


/* 回答與引用：題目／回答／引用網站切換放在搜尋旁 */
.seg.view-tabs button[aria-selected="true"] { background: var(--background); color: var(--foreground); box-shadow: 0 0 0 1px var(--border); }
.seg.view-tabs .tab-count { margin-left: 6px; color: var(--muted-foreground); font-variant-numeric: tabular-nums; }

/* 側欄最下面的檢視身分切換（精稿模擬） */
.sb-viewer { display: flex; flex-direction: column; gap: 6px; padding: 10px 8px 4px; }
.sb-viewer-lbl { font-size: 11px; color: var(--muted-foreground); }
.sb-viewer .seg button { height: 26px; }

/* 回答與引用：和競品比較的四種結果 */
.outcome-cards { margin-bottom: 16px; }
.outcome-card { display: flex; flex-direction: column; }
.o-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; flex: none; }

/* 引用網站（熱門引用）：網頁標題＋網址 */
.cite-page { display: flex; flex-direction: column; min-width: 0; }
.cite-url { font-size: 11px; word-break: break-all; }
.cite-url:hover { text-decoration: underline; }

/* 回答與引用：這一頁自己的篩選（旅程階段、語氣、結果），在四張結果卡上方 */
.page-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; font-size: 12px; }
.page-filters .pf-sep { width: 1px; height: 18px; background: var(--border); margin: 0 4px; }

/* 不能和目前條件一起選的篩選：變灰 */
.outcome-card.off, .page-filters .select.off { opacity: .4; cursor: not-allowed; }
.outcome-card.off:hover { box-shadow: none; }
.page-filters .select.off select { cursor: not-allowed; }

/* 側欄收合：寬螢幕收成 56px 只剩圖示的窄欄，滑過圖示顯示頁名 */
.sidebar { transition: width .2s, flex-basis .2s; }
@media (min-width: 861px) {
  .sb-collapsed { --sidebar-w: 56px; }
  .sb-collapsed .sb-head { padding: 12px; }
  .sb-collapsed .sb-logo { width: 32px; padding: 0 4px; font-size: 0; gap: 0; }
  .sb-collapsed .sb-logo.wl img { width: 24px; height: 24px !important; object-fit: contain; object-position: left; }
  .sb-collapsed .brand-switch, .sb-collapsed .brand-fixed { width: 32px; }
  .sb-collapsed .brand-switch select { width: 32px; height: 32px; padding: 0; color: transparent; }
  .sb-collapsed .brand-switch select option { color: var(--foreground); }
  .sb-collapsed .brand-switch .avatar { left: 4px; top: 4px; }
  .sb-collapsed .brand-switch .chev { display: none; }
  .sb-collapsed .brand-fixed { height: 32px; padding: 0 3px; overflow: hidden; white-space: nowrap; }
  .sb-collapsed .sb-nav { overflow: visible; padding: 4px 12px 12px; }
  .sb-collapsed .sb-group { font-size: 0; height: 1px; padding: 0; margin: 12px 4px; background: var(--sidebar-border); }
  .sb-collapsed .sb-group:first-child { margin-top: 4px; }
  .sb-collapsed .sb-item { width: 32px; padding: 0; justify-content: center; position: relative; }
  .sb-collapsed .sb-item .lbl, .sb-collapsed .sb-item .wf { display: none; }
  .sb-collapsed .sb-item .count { position: absolute; top: 3px; right: 3px; min-width: 0; width: 7px; height: 7px; padding: 0; font-size: 0; border: 0; background: var(--primary); }
  .sb-collapsed .sb-item:hover::after, .sb-collapsed .sb-item:focus-visible::after {
    content: attr(data-label); position: absolute; left: calc(100% + 8px); top: 50%; transform: translateY(-50%); z-index: 40;
    white-space: nowrap; padding: 4px 8px; font-size: 12px; font-weight: 500;
    background: var(--primary); color: var(--primary-foreground); pointer-events: none;
  }
  .sb-collapsed .sb-layer, .sb-collapsed .sb-viewer, .sb-collapsed .powered { display: none; }
}
