/* ==========================================================================
   Theme: Apple-style glass header + Night theme. Loaded last.
   ========================================================================== */
:root{--gutter:clamp(12px,3vw,24px);--glass-bg:rgba(246,243,237,.62);--glass-line:rgba(20,22,31,.10)}

/* Pinned glass header - full width, content blurs beneath it */
.topbar{
  position:sticky; top:0; z-index:70;
  margin:0 calc(-1 * var(--gutter)) 24px; padding:12px var(--gutter);
  background:var(--glass-bg);
  -webkit-backdrop-filter:saturate(180%) blur(24px); backdrop-filter:saturate(180%) blur(24px);
  border-bottom:1px solid var(--glass-line);
}
@media (max-width:560px){.topbar{position:static;-webkit-backdrop-filter:none;backdrop-filter:none;background:transparent}}

/* Theme switch */
.theme-toggle{width:40px;height:40px;border-radius:50%;border:1px solid var(--glass-line);background:rgba(255,255,255,.55);-webkit-backdrop-filter:blur(10px);backdrop-filter:blur(10px);display:grid;place-items:center;cursor:pointer;color:var(--ink);flex:none;transition:transform .2s,background .2s}
.theme-toggle:hover{transform:rotate(14deg) scale(1.05)}
.theme-toggle svg{width:19px;height:19px}
.theme-toggle .moon{display:block}.theme-toggle .sun{display:none}
.topbar-right{display:flex;align-items:center;gap:12px;flex-wrap:wrap}

/* Glass for floating surfaces */
.chart-tooltip{-webkit-backdrop-filter:blur(14px) saturate(160%);backdrop-filter:blur(14px) saturate(160%)}
.ms-pop,.dim-picker-popover,.filter-builder-modal{-webkit-backdrop-filter:blur(22px) saturate(170%);backdrop-filter:blur(22px) saturate(170%)}

/* ───────── Night theme ───────── */
:root[data-theme="dark"]{
  color-scheme:dark;
  --bg:#0d0f16; --bg2:#141824; --surface:#161a26; --surface2:#1b2030;
  --ink:#eceef5; --ink2:#c5cadb; --muted:#8e95aa; --line:rgba(255,255,255,.09);
  --brand:#ff5c8d; --brand-dark:#f03a73; --good:#34d399; --bad:#f87171; --warn:#fbbf24;
  --shadow-soft:0 1px 2px rgba(0,0,0,.4),0 8px 24px -8px rgba(0,0,0,.5);
  --shadow-card:0 1px 1px rgba(0,0,0,.4),0 6px 14px -4px rgba(0,0,0,.45),0 26px 50px -26px rgba(0,0,0,.7);
  --shadow-hover:0 2px 2px rgba(0,0,0,.4),0 12px 26px -8px rgba(0,0,0,.6),0 34px 60px -26px rgba(228,0,79,.35);
  --shadow-lift:0 2px 4px rgba(0,0,0,.5),0 18px 48px -12px rgba(0,0,0,.7);
  --ring:rgba(255,92,141,.28);
  --glass-bg:rgba(13,15,22,.62); --glass-line:rgba(255,255,255,.10);
}
:root[data-theme="dark"] .theme-toggle{background:rgba(255,255,255,.08)}
:root[data-theme="dark"] .theme-toggle .moon{display:none}
:root[data-theme="dark"] .theme-toggle .sun{display:block}
[data-theme="dark"] body{background:var(--bg);color:var(--ink)}
[data-theme="dark"] .report-section{background:linear-gradient(180deg,rgba(24,28,42,.96),rgba(19,22,33,.94));border-color:rgba(255,255,255,.06);outline-color:rgba(255,255,255,.05)}
[data-theme="dark"] .report-section::before{opacity:.7}
[data-theme="dark"] .insight-card,[data-theme="dark"] .note-card.text{background:var(--surface)}
[data-theme="dark"] .llm-card.total{background:linear-gradient(150deg,#221620,#2a1824)}
[data-theme="dark"] .gsc-3d{background:radial-gradient(120% 90% at 50% 0%,#25191f 0%,#17121a 100%);border-color:rgba(255,255,255,.08)}
[data-theme="dark"] .layout-btn.active,[data-theme="dark"] .metric-tab.active,[data-theme="dark"] .view-seg-btn.on{background:#33222c;color:var(--ink)}
[data-theme="dark"] .llm-pill{background:rgba(245,158,11,.14);color:#fbbf24;border-color:rgba(245,158,11,.3)}
[data-theme="dark"] .note-card.photo img{background:#0f121b}
[data-theme="dark"] .vis-in:focus,[data-theme="dark"] .note-cap:focus{background:var(--surface)}
[data-theme="dark"] .llm-chip.up,[data-theme="dark"] .rk-sub .up{color:#34d399}
[data-theme="dark"] .llm-chip.up{background:rgba(52,211,153,.14)}
[data-theme="dark"] .llm-chip.down,[data-theme="dark"] .rk-sub .down{color:#f87171}
[data-theme="dark"] .llm-chip.down{background:rgba(248,113,113,.14)}
[data-theme="dark"] .llm-chip.flat{background:rgba(255,255,255,.08)}
[data-theme="dark"] .ins-badge{background:rgba(255,92,141,.14);color:#ffa3bd;border-color:rgba(255,92,141,.25)}
[data-theme="dark"] .ins-ico{background:linear-gradient(135deg,rgba(255,92,141,.2),rgba(252,108,0,.14))}
[data-theme="dark"] .insight-card{background:linear-gradient(180deg,#171b28,#141824)}
[data-theme="dark"] .eyebrow,[data-theme="dark"] .llm-eyebrow{background:rgba(255,92,141,.12);border-color:rgba(255,92,141,.22)}
[data-theme="dark"] .section-title,[data-theme="dark"] .llm-head h2,[data-theme="dark"] .topbar h1{color:var(--ink)}
[data-theme="dark"] .metric-card,[data-theme="dark"] .llm-card,[data-theme="dark"] .llm-panel,[data-theme="dark"] .chart-container-card,[data-theme="dark"] .table-card,[data-theme="dark"] .history-inspector-card,[data-theme="dark"] .city-card{border-color:rgba(255,255,255,.08)}
[data-theme="dark"] .kw-badge{box-shadow:0 10px 22px -10px rgba(0,0,0,.8)}
[data-theme="dark"] .city-row.hot,[data-theme="dark"] .ins-leg.hot,[data-theme="dark"] .fun-row.hot,[data-theme="dark"] .kw-row:hover{background:rgba(255,92,141,.12)}
[data-theme="dark"] .view-seg,[data-theme="dark"] .presets{background:var(--bg2)}
[data-theme="dark"] input[type="checkbox"].cb{background:var(--surface2);border-color:#4a5068}
[data-theme="dark"] .chart-tooltip{background:rgba(8,9,15,.9);box-shadow:0 18px 40px -10px rgba(0,0,0,.8),0 0 0 1px rgba(255,255,255,.12)}
[data-theme="dark"] .c3d-labels span{color:#9aa1b6}
/* SVG charts: hard-coded ink/white inside generated SVG */
[data-theme="dark"] svg text[fill="#14161f"]{fill:#eceef5}
[data-theme="dark"] svg text[fill="#3b4150"]{fill:#c5cadb}
[data-theme="dark"] svg [stroke="#fff"]{stroke:var(--surface)}
[data-theme="dark"] svg line[stroke^="rgba(20,22,31"],[data-theme="dark"] svg circle[stroke^="rgba(20,22,31"]{stroke:rgba(255,255,255,.08)}
[data-theme="dark"] svg line[stroke="#14161f"]{stroke:#eceef5}
[data-theme="dark"] svg circle[fill="#fff"]{fill:var(--surface)}
[data-theme="dark"] .pie-pct{stroke:rgba(0,0,0,.4)}
[data-theme="dark"] .report-section::before,[data-theme="dark"] .topbar::after{filter:saturate(1.1)}
