/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --page: #f6f5f1;
  --surface-1: #fcfcfb;
  --surface-2: #f1f0ec;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --muted: #898781;
  --grid: #e7e6df;
  --axis: #c3c2b7;
  --border: rgba(11, 11, 11, 0.09);
  --shadow: 0 1px 2px rgba(11, 11, 11, .04), 0 8px 24px -12px rgba(11, 11, 11, .12);
  --accent: #2a78d6;
  --accent-wash: rgba(42, 120, 214, .10);
  --good: #006300;

  --series-1: #2a78d6; --series-2: #eb6834; --series-3: #1baf7a; --series-4: #eda100;
  --series-5: #e87ba4; --series-6: #008300; --series-7: #4a3aa7; --series-8: #e34948;
  --other: #b5b3ab;

  --seq-0: #f1f4f9; --seq-1: #cde2fb; --seq-2: #9ec5f4; --seq-3: #6da7ec; --seq-4: #3987e5; --seq-5: #256abf; --seq-6: #184f95; --seq-7: #0d366b;
  --div-neg: #2a78d6; --div-mid: #f0efec; --div-pos: #e34948;

  --radius: 16px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #232321;
    --text-primary: #ffffff; --text-secondary: #c3c2b7; --muted: #8f8d86;
    --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .09);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .6);
    --accent: #3987e5; --accent-wash: rgba(57, 135, 229, .16); --good: #0ca30c;
    --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
    --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
    --other: #5c5b56;
    --seq-0: #1f2329; --seq-1: #13294a; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #9ec5f4; --seq-7: #cde2fb;
    --div-neg: #3987e5; --div-mid: #383835; --div-pos: #e66767;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --page: #0d0d0d; --surface-1: #1a1a19; --surface-2: #232321;
  --text-primary: #ffffff; --text-secondary: #c3c2b7; --muted: #8f8d86;
  --grid: #2c2c2a; --axis: #383835; --border: rgba(255, 255, 255, .09);
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 12px 32px -16px rgba(0, 0, 0, .6);
  --accent: #3987e5; --accent-wash: rgba(57, 135, 229, .16); --good: #0ca30c;
  --series-1: #3987e5; --series-2: #d95926; --series-3: #199e70; --series-4: #c98500;
  --series-5: #d55181; --series-6: #008300; --series-7: #9085e9; --series-8: #e66767;
  --other: #5c5b56;
  --seq-0: #1f2329; --seq-1: #13294a; --seq-2: #184f95; --seq-3: #1c5cab; --seq-4: #2a78d6; --seq-5: #5598e7; --seq-6: #9ec5f4; --seq-7: #cde2fb;
  --div-neg: #3987e5; --div-mid: #383835; --div-pos: #e66767;
}

/* ---------- base ---------- */
* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 80px; }
body { margin: 0; background: var(--page); color: var(--text-primary); font-family: var(--font); font-size: 15px; line-height: 1.5; -webkit-font-smoothing: antialiased; }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -0.02em; }
code { font-size: .9em; background: var(--surface-2); padding: 1px 6px; border-radius: 6px; }
button, input, select { font: inherit; color: inherit; }
b { font-weight: 650; }
[hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.eyebrow { font-size: 12px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 600; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: -.01em; }
.brand-mark { color: var(--accent); font-size: 1.2em; }

/* ---------- landing ---------- */
.landing { min-height: 100vh; display: grid; place-items: center; padding: 48px 16px;
  background: radial-gradient(1200px 600px at 20% -10%, var(--accent-wash), transparent 60%), var(--page); }
.landing-inner { max-width: 620px; width: 100%; text-align: center; }
.landing h1 { font-size: clamp(34px, 6vw, 56px); line-height: 1.05; margin: 28px 0 16px; letter-spacing: -0.035em; }
.lede { color: var(--text-secondary); font-size: 17px; margin: 0 auto 32px; max-width: 520px; }
.landing .brand { justify-content: center; font-size: 18px; }
.dropzone { display: block; border: 1.5px dashed var(--axis); border-radius: 20px; padding: 44px 24px; cursor: pointer;
  background: var(--surface-1); transition: border-color .2s, background .2s, transform .2s; box-shadow: var(--shadow); }
.dropzone:hover, .dropzone:focus-visible, .dropzone.drag { border-color: var(--accent); background: var(--accent-wash); outline: none; }
.dropzone.drag { transform: scale(1.01); }
.dz-icon { font-size: 28px; color: var(--accent); }
.dz-title { font-weight: 650; font-size: 18px; margin-top: 6px; }
.dz-sub { color: var(--muted); font-size: 14px; }
.privacy { color: var(--text-secondary); font-size: 14px; margin-top: 18px; }
.howto { text-align: left; max-width: 420px; margin: 8px auto 0; color: var(--text-secondary); font-size: 14px; }
.howto summary { cursor: pointer; text-align: center; color: var(--muted); }
.load-status { margin-top: 16px; min-height: 22px; font-size: 14px; color: var(--text-secondary); }
.load-status.error { color: #d03b3b; }
/* Baked-in snapshot deployments: no upload UI, just a loading line until the data arrives. */
.snapshot .landing-inner > :not(.load-status) { display: none; }
.snapshot .landing { min-height: 60vh; }
.snapshot #load-another { display: none; }
/* An exported file can't re-read its own sources from disk, so it doesn't offer to export again. */
.exported #export-html { display: none; }
.ghost-btn:disabled { opacity: .6; cursor: progress; }

/* ---------- top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 20; backdrop-filter: saturate(1.4) blur(14px); -webkit-backdrop-filter: saturate(1.4) blur(14px);
  background: color-mix(in srgb, var(--page) 78%, transparent); border-bottom: 1px solid var(--border); }
.topbar-inner { max-width: 1320px; margin: 0 auto; padding: 10px 24px; display: flex; align-items: center; gap: 20px; }
.sectionnav { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: 1; }
.sectionnav::-webkit-scrollbar { display: none; }
.sectionnav a { color: var(--text-secondary); text-decoration: none; font-size: 14px; padding: 6px 12px; border-radius: 999px; white-space: nowrap; transition: background .15s, color .15s; }
.sectionnav a:hover { background: var(--surface-2); color: var(--text-primary); }
.sectionnav a.active { background: var(--text-primary); color: var(--surface-1); }
.topbar-actions { display: flex; gap: 8px; align-items: center; }
.icon-btn { width: 34px; height: 34px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-1); cursor: pointer; font-size: 16px; }
.icon-btn:hover { background: var(--surface-2); }
.ghost-btn { border: 1px solid var(--border); background: var(--surface-1); border-radius: 10px; padding: 6px 14px; cursor: pointer; font-size: 14px; font-weight: 550; white-space: nowrap; }
.ghost-btn:hover { background: var(--surface-2); }

/* ---------- layout ---------- */
main { max-width: 1320px; margin: 0 auto; padding: 0 24px 64px; }
.hero { padding: 48px 0 8px; }
.hero h1 { font-size: clamp(36px, 5.5vw, 64px); letter-spacing: -0.04em; line-height: 1.02; margin: 10px 0 12px; }
.hero-meta { color: var(--text-secondary); font-size: 16px; }
.people-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 20px 0 28px; }
.chip { display: inline-flex; align-items: center; gap: 8px; padding: 5px 12px 5px 6px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface-1); font-size: 14px; cursor: pointer; }
.chip:hover { background: var(--surface-2); }
.avatar { width: 24px; height: 24px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11px; font-weight: 700; flex: none; }
.dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; flex: none; }

.filters { display: flex; align-items: center; flex-wrap: wrap; gap: 12px; padding: 12px 14px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; margin-bottom: 20px; }
.filters-label { font-size: 13px; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .08em; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; gap: 2px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 12px; border-radius: 8px; cursor: pointer; font-size: 14px; color: var(--text-secondary); }
.seg button:hover { color: var(--text-primary); }
.seg button.on { background: var(--surface-1); color: var(--text-primary); box-shadow: 0 1px 2px rgba(0, 0, 0, .12); font-weight: 600; }
.seg.small button { font-size: 13px; padding: 4px 10px; }
.custom-range { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.custom-range input { border: 1px solid var(--border); background: var(--surface-1); border-radius: 8px; padding: 4px 8px; font-size: 14px; }
.range-note { color: var(--muted); font-size: 13px; margin-left: auto; }

.kpis { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); }
.kpi .k-label { font-size: 13px; color: var(--text-secondary); }
.kpi .k-value { font-size: 28px; font-weight: 650; letter-spacing: -0.03em; line-height: 1.15; margin-top: 2px; }
.kpi .k-sub { font-size: 12px; color: var(--muted); }

.section { padding-top: 56px; }
.section-head { margin-bottom: 18px; }
.section-head.row { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.section-head h2 { font-size: clamp(24px, 3vw, 34px); margin-top: 6px; letter-spacing: -0.03em; }
.section-sub { color: var(--text-secondary); margin: 6px 0 0; max-width: 760px; font-size: 14px; }

.grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px; }
.grid.inner { gap: 8px; }
.span-4 { grid-column: span 4; } .span-5 { grid-column: span 5; } .span-6 { grid-column: span 6; }
.span-7 { grid-column: span 7; } .span-8 { grid-column: span 8; } .span-12 { grid-column: span 12; }
@media (max-width: 980px) { .grid > [class*="span-"] { grid-column: span 12; } }

.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 18px 12px; box-shadow: var(--shadow); min-width: 0; }
.card-head { margin-bottom: 8px; }
.card-head.row { display: flex; justify-content: space-between; gap: 8px 12px; align-items: flex-start; flex-wrap: wrap; }
.card-head.row > div:first-child { flex: 1 1 220px; min-width: 0; }
.card-head h3 { font-size: 16px; }
.card-head p { margin: 2px 0 0; font-size: 13px; color: var(--muted); }
.card-tools { display: flex; gap: 6px; align-items: center; }
.tbl-btn { border: 1px solid var(--border); background: transparent; border-radius: 8px; font-size: 12px; padding: 3px 8px; cursor: pointer; color: var(--text-secondary); }
.tbl-btn:hover, .tbl-btn.on { background: var(--surface-2); color: var(--text-primary); }
.chart { width: 100%; }
.chart-host .chart { width: 100%; }
.data-table { max-height: 360px; overflow: auto; font-size: 13px; }
.data-table table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.data-table th { color: var(--muted); font-weight: 600; position: sticky; top: 0; background: var(--surface-1); }
.empty-chart { color: var(--muted); font-size: 14px; display: grid; place-items: center; height: 160px; }

/* headlines */
.headlines { list-style: none; padding: 0; margin: 6px 0 0; display: grid; gap: 2px; }
.headlines li { display: flex; gap: 12px; align-items: baseline; padding: 9px 4px; border-bottom: 1px solid var(--grid); font-size: 15px; color: var(--text-secondary); }
.headlines li:last-child { border-bottom: 0; }
.headlines li b { color: var(--text-primary); }
.headlines .h-icon { font-size: 18px; width: 24px; flex: none; text-align: center; }

/* personas */
.persona-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 14px; margin-bottom: 16px; }
.persona { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; cursor: pointer; transition: transform .15s; }
.persona:hover { transform: translateY(-2px); }
.persona-top { display: flex; align-items: center; gap: 12px; }
.persona .avatar { width: 40px; height: 40px; font-size: 15px; }
.persona h3 { margin: 0; font-size: 16px; letter-spacing: -.01em; }
.persona .p-sub { color: var(--muted); font-size: 13px; }
.persona .p-archetype { margin: 12px 0 10px; font-size: 14px; color: var(--text-secondary); }
.badges { display: flex; flex-direction: column; gap: 6px; }
.badge { display: flex; gap: 10px; align-items: center; background: var(--surface-2); border-radius: 10px; padding: 7px 10px; }
.badge .b-icon { font-size: 18px; }
.badge .b-name { font-size: 13px; font-weight: 650; }
.badge .b-rank { font-size: 11px; font-weight: 600; color: var(--muted); border: 1px solid var(--border); border-radius: 6px; padding: 0 5px; margin-left: 4px; }
.badge .b-val { font-size: 12px; color: var(--muted); }
.persona .p-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 12px; padding-top: 12px; border-top: 1px solid var(--grid); }
.p-stat .v { font-weight: 650; font-size: 16px; }
.p-stat .l { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

/* leaderboard */
.table-wrap { overflow-x: auto; }
table.lb { border-collapse: collapse; width: 100%; font-size: 14px; font-variant-numeric: tabular-nums; }
table.lb th { text-align: right; font-weight: 600; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .05em; padding: 8px 10px; border-bottom: 1px solid var(--axis); cursor: pointer; white-space: nowrap; user-select: none; }
table.lb th:first-child, table.lb td:first-child { text-align: left; }
table.lb th.sorted { color: var(--text-primary); }
table.lb td { text-align: right; padding: 9px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
table.lb tr:hover td { background: var(--surface-2); }
.namecell { display: inline-flex; align-items: center; gap: 8px; font-weight: 600; }
.bar-cell { display: inline-flex; align-items: center; gap: 8px; justify-content: flex-end; }
.mini-bar { height: 6px; border-radius: 3px; background: var(--accent); opacity: .85; }
.spark { vertical-align: middle; }

/* fingerprints */
.fingerprints { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); gap: 12px; }
.fp { border: 1px solid var(--grid); border-radius: 12px; padding: 12px 14px; }
.fp-head { display: flex; align-items: center; gap: 8px; font-weight: 650; margin-bottom: 8px; }
.fp-head .fp-emoji { margin-left: auto; font-size: 18px; letter-spacing: 2px; }
.words { display: flex; flex-wrap: wrap; gap: 6px; }
.word { background: var(--surface-2); border-radius: 999px; padding: 2px 10px; color: var(--text-secondary); }
.word small { color: var(--muted); margin-left: 4px; font-size: 11px; }

.typo { text-decoration: underline wavy #d03b3b; text-decoration-thickness: 1px; text-underline-offset: 3px; }
.typo-kinds { display: flex; flex-wrap: wrap; gap: 6px; margin: 4px 0 12px; }
.typo-table td:nth-child(2) { color: var(--text-secondary); }
.typo-table th:nth-child(2), .typo-table td:nth-child(2), .typo-table th:nth-child(4), .typo-table td:nth-child(4) { text-align: left; }
.word s { color: var(--muted); }
.trend-form { display: flex; gap: 8px; }
.trend-form input { border: 1px solid var(--border); background: var(--surface-1); border-radius: 10px; padding: 6px 12px; width: 260px; max-width: 60vw; }

/* polls */
.polls { display: grid; gap: 12px; max-height: 520px; overflow-y: auto; padding-right: 4px; }
.poll { border: 1px solid var(--grid); border-radius: 12px; padding: 12px; }
.poll-q { font-weight: 600; font-size: 14px; }
.poll-meta { font-size: 12px; color: var(--muted); margin-bottom: 8px; }
.poll-opt { display: grid; grid-template-columns: 1fr auto; gap: 2px 8px; font-size: 13px; margin-top: 6px; color: var(--text-secondary); }
.poll-bar { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--surface-2); overflow: hidden; }
.poll-bar span { display: block; height: 100%; background: var(--accent); border-radius: 3px; }

/* moments */
.moments { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 12px; margin-bottom: 16px; }
.moment { background: var(--surface-1); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; cursor: pointer; box-shadow: var(--shadow); transition: transform .15s; }
.moment:hover { transform: translateY(-2px); }
.moment .m-rank { font-size: 12px; color: var(--muted); font-weight: 600; }
.moment .m-date { font-weight: 650; font-size: 16px; }
.moment .m-n { font-size: 30px; font-weight: 650; letter-spacing: -.03em; }
.moment .m-n small { font-size: 13px; color: var(--muted); font-weight: 500; letter-spacing: 0; }
.moment .m-who { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12px; color: var(--text-secondary); margin: 6px 0; }
.moment .m-who span { display: inline-flex; gap: 5px; align-items: center; }
.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.record { background: var(--surface-2); border-radius: 12px; padding: 10px 14px; }
.record .r-l { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
.record .r-v { font-size: 18px; font-weight: 650; }
.record .r-s { font-size: 13px; color: var(--text-secondary); }
.record .r-q { font-size: 13px; color: var(--text-secondary); font-style: italic; margin-top: 4px; max-height: 60px; overflow: hidden; }

/* spotlight */
.select { border: 1px solid var(--border); background: var(--surface-1); border-radius: 10px; padding: 8px 12px; font-size: 15px; min-width: 220px; }
.spot { background: var(--surface-1); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px; box-shadow: var(--shadow); margin-bottom: 16px; }
.spot-top { display: flex; gap: 18px; align-items: center; flex-wrap: wrap; }
.spot .avatar { width: 64px; height: 64px; font-size: 24px; }
.spot h3 { font-size: 28px; letter-spacing: -.03em; }
.spot-sub { color: var(--text-secondary); }
.spot-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; margin-top: 20px; }
.spot-stat .v { font-size: 22px; font-weight: 650; letter-spacing: -.02em; }
.spot-stat .l { font-size: 12px; color: var(--muted); }
.spot-stat .c { font-size: 12px; color: var(--text-secondary); }
.spot-cols { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 20px; margin-top: 22px; padding-top: 18px; border-top: 1px solid var(--grid); }
.spot-cols h4 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.spot-badges { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.spot-badges .badge { padding: 6px 10px; }

/* drawer */
.scrim { position: fixed; inset: 0; background: rgba(0, 0, 0, .35); z-index: 40; }
.drawer { position: fixed; top: 0; right: 0; bottom: 0; width: min(560px, 100vw); background: var(--surface-1); z-index: 50; display: flex; flex-direction: column; box-shadow: -20px 0 60px rgba(0, 0, 0, .25); border-left: 1px solid var(--border); }
.drawer-head { display: flex; justify-content: space-between; align-items: flex-start; padding: 18px 20px; border-bottom: 1px solid var(--grid); }
.drawer-head h2 { font-size: 20px; margin-top: 4px; }
.drawer-body { overflow-y: auto; padding: 12px 16px 40px; background: var(--page); flex: 1; }
.bubble { max-width: 86%; margin: 4px 0; padding: 7px 11px 6px; border-radius: 12px; background: var(--surface-1); border: 1px solid var(--border); font-size: 14px; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; }
.bubble.me { margin-left: auto; background: var(--accent-wash); }
.bubble .who { font-size: 12px; font-weight: 650; display: flex; align-items: center; gap: 6px; margin-bottom: 1px; }
.bubble .t { font-size: 11px; color: var(--muted); float: right; margin: 6px 0 0 10px; }
.bubble .media-tag { color: var(--muted); font-style: italic; }
.day-sep { text-align: center; font-size: 12px; color: var(--muted); margin: 14px 0 6px; }

.foot { color: var(--muted); font-size: 13px; text-align: center; padding-top: 48px; }
.empty-note { color: var(--muted); }

@media (max-width: 720px) {
  .topbar-inner { padding: 8px 16px; gap: 10px; }
  .brand.small { display: none; }
  main { padding: 0 16px 48px; }
  .card { padding: 14px 12px 8px; }
  .range-note { margin-left: 0; }
  .kpi .k-value { font-size: 22px; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }
