@font-face {
  font-family: "Inter";
  src: url("../fonts/inter-latin-var.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f7f6f3;
  --surface: #ffffff;
  --surface-2: #f3f2ee;
  --border: #e7e5df;
  --text: #0e0e10;
  --text-2: #52514e;
  --text-3: #7a7974;
  --grid: #eeece7;
  --brand-a: #7b5cf0;
  --brand-b: #e3497a;
  --brand-c: #f0803c;
  --brand-grad: linear-gradient(135deg, var(--brand-a) 0%, var(--brand-b) 58%, var(--brand-c) 100%);
  --brand-ink: #ffffff;
  --series-1: #2a78d6;
  --series-2: #eb6834;
  --series-3: #1baf7a;
  --error: #b42323;
  --shadow-sm: 0 1px 2px rgba(20, 16, 40, .05);
  --shadow: 0 1px 2px rgba(20, 16, 40, .04), 0 8px 24px rgba(20, 16, 40, .06);
  --shadow-lg: 0 20px 60px rgba(40, 20, 80, .18);
  --radius: 18px;
  --hero-glow-1: rgba(123, 92, 240, .20);
  --hero-glow-2: rgba(227, 73, 122, .16);
  --hero-glow-3: rgba(240, 128, 60, .14);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #0f0f12;
    --surface: #18181c;
    --surface-2: #202026;
    --border: #2b2b32;
    --text: #f2f1ee;
    --text-2: #c3c2bb;
    --text-3: #94938c;
    --grid: #26262c;
    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;
    --error: #f08585;
    --shadow-sm: none;
    --shadow: 0 1px 0 rgba(255,255,255,.03) inset;
    --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
    --hero-glow-1: rgba(123, 92, 240, .28);
    --hero-glow-2: rgba(227, 73, 122, .20);
    --hero-glow-3: rgba(240, 128, 60, .14);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f0f12;
  --surface: #18181c;
  --surface-2: #202026;
  --border: #2b2b32;
  --text: #f2f1ee;
  --text-2: #c3c2bb;
  --text-3: #94938c;
  --grid: #26262c;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --error: #f08585;
  --shadow-sm: none;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset;
  --shadow-lg: 0 20px 60px rgba(0,0,0,.6);
  --hero-glow-1: rgba(123, 92, 240, .28);
  --hero-glow-2: rgba(227, 73, 122, .20);
  --hero-glow-3: rgba(240, 128, 60, .14);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.6 "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-feature-settings: "cv11", "ss01";
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; }
h1, h2, h3 { line-height: 1.15; margin: 0; letter-spacing: -0.02em; }
h1 { font-size: clamp(2rem, 5.4vw, 3.4rem); font-weight: 800; letter-spacing: -0.035em; }
h2 { font-size: 1.25rem; font-weight: 700; }
h3 { font-size: 1rem; font-weight: 650; letter-spacing: -0.01em; }
code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .86em; background: var(--surface-2); border: 1px solid var(--border); padding: 1px 6px; border-radius: 6px; }
a { color: var(--brand-a); }
.muted { color: var(--text-2); margin: 4px 0 0; font-size: .875rem; }
.wrap { max-width: 1140px; margin: 0 auto; padding: 0 16px; }
.grad-text { background: var(--brand-grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
svg { display: block; }

/* ---------- Header / footer ---------- */
.site-header {
  position: sticky; top: 0; z-index: 20;
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid color-mix(in srgb, var(--border) 70%, transparent);
}
.header-inner { display: flex; align-items: center; justify-content: space-between; height: 62px; gap: 12px; }
.header-actions { display: flex; gap: 8px; }
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 750; font-size: 1.05rem; letter-spacing: -0.02em; color: var(--text); text-decoration: none; }
.brand-mark { width: 30px; height: 30px; border-radius: 9px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; box-shadow: 0 4px 14px rgba(227, 73, 122, .35); }
.brand-mark svg { width: 20px; height: 20px; }
.brand.small { font-size: .9rem; }
.brand.small .brand-mark { width: 22px; height: 22px; border-radius: 7px; box-shadow: none; }
.brand.small .brand-mark svg { width: 15px; height: 15px; }
.site-footer { border-top: 1px solid var(--border); color: var(--text-3); font-size: .8rem; padding: 26px 0; margin-top: 64px; }
.footer-inner { display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.site-footer p { margin: 0; }

/* ---------- Buttons ---------- */
.btn {
  appearance: none; display: inline-flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 11px 20px; border-radius: 999px; font: inherit; font-weight: 650; cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, border-color .15s ease, background .15s ease;
  white-space: nowrap;
}
.btn svg { width: 18px; height: 18px; }
.btn:hover { border-color: var(--text-3); }
.btn:active { transform: translateY(1px); }
.btn:focus-visible, select:focus-visible, .drop-zone:focus-within, .link:focus-visible, .icon-btn:focus-visible { outline: 2px solid var(--brand-a); outline-offset: 2px; }
.btn-primary { background: var(--brand-grad); color: var(--brand-ink); border-color: transparent; box-shadow: 0 6px 20px rgba(227, 73, 122, .30); }
.btn-primary:hover { border-color: transparent; box-shadow: 0 8px 26px rgba(227, 73, 122, .42); }
.btn-primary:disabled { opacity: .6; cursor: progress; }
.btn-soft { background: color-mix(in srgb, var(--brand-a) 10%, var(--surface)); border-color: color-mix(in srgb, var(--brand-a) 25%, var(--border)); color: var(--text); }
.btn-ghost { background: transparent; }
.btn-sm { padding: 7px 14px; font-size: .86rem; }
.btn-sm svg { width: 16px; height: 16px; }
.icon-btn { appearance: none; border: 0; background: transparent; color: var(--text-2); width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center; cursor: pointer; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg { width: 20px; height: 20px; }
.link { appearance: none; border: 0; background: none; padding: 0; font: inherit; color: var(--brand-a); cursor: pointer; font-weight: 600; }

/* ---------- Upload ---------- */
.upload-view { position: relative; padding: 64px 0 0; overflow: hidden; }
.hero-bg {
  position: absolute; inset: -120px 0 auto 0; height: 720px; z-index: -1; pointer-events: none;
  background:
    radial-gradient(420px 320px at 18% 30%, var(--hero-glow-1), transparent 70%),
    radial-gradient(460px 340px at 82% 24%, var(--hero-glow-2), transparent 70%),
    radial-gradient(380px 260px at 55% 70%, var(--hero-glow-3), transparent 70%);
  filter: blur(8px);
}
.hero { text-align: center; max-width: 780px; margin: 0 auto 36px; }
.pill {
  display: inline-flex; align-items: center; gap: 7px; padding: 6px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 80%, transparent); border: 1px solid var(--border);
  font-size: .82rem; font-weight: 600; color: var(--text-2); margin-bottom: 22px; box-shadow: var(--shadow-sm);
}
.pill svg { width: 15px; height: 15px; color: var(--brand-b); }
.lede { color: var(--text-2); font-size: 1.12rem; max-width: 620px; margin: 18px auto 0; }

.drop-zone {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  max-width: 720px; margin: 0 auto; padding: 46px 20px;
  border: 2px dashed color-mix(in srgb, var(--brand-a) 35%, var(--border));
  border-radius: 24px; background: color-mix(in srgb, var(--surface) 88%, transparent);
  cursor: pointer; box-shadow: var(--shadow); transition: border-color .15s, background .15s, transform .15s;
}
.drop-zone:hover, .drop-zone.dragging { border-color: var(--brand-b); transform: translateY(-2px); }
.drop-zone.dragging { background: color-mix(in srgb, var(--brand-b) 6%, var(--surface)); }
.drop-zone input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.drop-icon { width: 58px; height: 58px; border-radius: 18px; background: var(--brand-grad); color: #fff; display: grid; place-items: center; margin-bottom: 10px; box-shadow: 0 10px 26px rgba(227, 73, 122, .35); }
.drop-icon svg { width: 28px; height: 28px; }
.drop-title { font-weight: 700; font-size: 1.1rem; }
.drop-sub { color: var(--text-3); font-size: .9rem; }
.drop-sub u { text-decoration-color: color-mix(in srgb, var(--brand-a) 60%, transparent); text-underline-offset: 3px; }
.drop-zone.loading .drop-title::after { content: " · reading…"; color: var(--text-3); font-weight: 500; }
.error { color: var(--error); text-align: center; margin: 14px 0 0; font-weight: 500; }
.upload-alt { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; margin: 22px 0 64px; }
.upload-alt .muted { margin: 0; }

.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.feature { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.feature p { color: var(--text-2); margin: 8px 0 0; font-size: .92rem; }
.f-icon { width: 40px; height: 40px; border-radius: 12px; display: grid; place-items: center; margin-bottom: 14px; }
.f-icon svg { width: 22px; height: 22px; }
.f1 { background: color-mix(in srgb, var(--brand-a) 14%, transparent); color: var(--brand-a); }
.f2 { background: color-mix(in srgb, var(--brand-b) 14%, transparent); color: var(--brand-b); }
.f3 { background: color-mix(in srgb, var(--brand-c) 16%, transparent); color: var(--brand-c); }

.info-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.info-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 24px 26px; box-shadow: var(--shadow); }
.steps { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 14px; }
.steps li { display: flex; gap: 14px; align-items: flex-start; color: var(--text-2); }
.steps li > span { flex: none; width: 28px; height: 28px; border-radius: 50%; background: var(--brand-grad); color: #fff; font-weight: 700; font-size: .85rem; display: grid; place-items: center; }
.steps li > div { padding-top: 3px; }
.checks { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 12px; }
.checks li { position: relative; padding-left: 30px; color: var(--text-2); }
.checks li::before {
  content: ""; position: absolute; left: 0; top: 2px; width: 20px; height: 20px; border-radius: 50%;
  background: color-mix(in srgb, var(--series-3) 16%, transparent);
}
.checks li::after {
  content: ""; position: absolute; left: 7px; top: 6px; width: 5px; height: 9px;
  border: solid var(--series-3); border-width: 0 2px 2px 0; transform: rotate(45deg);
}
.checks strong, .steps strong { color: var(--text); }

/* ---------- Dashboard ---------- */
.dash-view { padding-top: 28px; }
.dash-hero {
  position: relative; overflow: hidden; border-radius: 26px; padding: 34px 36px;
  background: var(--brand-grad); color: #fff; display: flex; justify-content: space-between; gap: 24px; align-items: flex-end; flex-wrap: wrap;
  box-shadow: 0 18px 50px rgba(160, 60, 140, .28);
}
.dash-hero::before, .dash-hero::after {
  content: ""; position: absolute; border-radius: 50%; background: rgba(255,255,255,.10); pointer-events: none;
}
.dash-hero::before { width: 360px; height: 360px; right: -120px; top: -160px; }
.dash-hero::after { width: 220px; height: 220px; right: 180px; bottom: -150px; }
.dash-hero-text { position: relative; min-width: 0; flex: 1 1 380px; }
.eyebrow { margin: 0 0 8px; font-size: .78rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; opacity: .85; }
.dash-hero h1 { font-size: clamp(1.8rem, 4.4vw, 2.7rem); }
#dashSub { margin: 10px 0 0; opacity: .92; }
.hero-stats { position: relative; flex: 1 1 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; margin-top: 8px; }
.hs { background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.26); border-radius: 18px; padding: 16px 18px 18px; min-width: 0; }
.hs-label { font-size: .85rem; font-weight: 650; opacity: .92; }
.hs-big { font-size: clamp(2.4rem, 5.6vw, 3.6rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1.05; margin-top: 6px; font-variant-numeric: tabular-nums; }
.hs-note { font-size: .92rem; opacity: .92; margin-top: 6px; line-height: 1.35; }
@media (max-width: 900px) { .hero-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.dash-hero-big .big-num { font-size: clamp(2.8rem, 7vw, 4.4rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1; font-variant-numeric: tabular-nums; }
.dash-hero-big .big-label { font-size: .9rem; opacity: .9; margin-top: 6px; }
.profile-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 18px; }
.profile-strip:empty { display: none; }
.chip { background: rgba(255,255,255,.18); border: 1px solid rgba(255,255,255,.28); border-radius: 999px; padding: 5px 12px; font-size: .82rem; color: rgba(255,255,255,.92); }
.chip b { color: #fff; font-weight: 650; }

.toolbar {
  position: relative; display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap;
  margin: 18px 0 0; padding: 10px 12px 10px 18px; border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 86%, transparent); border: 1px solid var(--border);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); box-shadow: var(--shadow);
}
.filters { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; min-width: 0; }
/* section links in the header: centred when there is room, scroll (not clip) when there isn't */
.top-nav { flex: 1 1 auto; min-width: 0; display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; padding: 0 8px; }
.top-nav::-webkit-scrollbar { display: none; }
.top-nav a { flex: none; padding: 7px 12px; border-radius: 999px; font-size: .88rem; font-weight: 600; color: var(--text-2); text-decoration: none; white-space: nowrap; }
.top-nav a:first-child { margin-left: auto; }
.top-nav a:last-child { margin-right: auto; }
.top-nav a:hover { background: var(--surface-2); color: var(--text); }
.top-nav a.active { background: color-mix(in srgb, var(--brand-a) 12%, transparent); color: var(--brand-a); }
.section-title { scroll-margin-top: 150px; }
.custom-range { display: flex; gap: 8px; flex-wrap: wrap; }
.date-field { display: flex; align-items: center; gap: 6px; font-size: .82rem; color: var(--text-2); font-weight: 600; }
.date-field input {
  font: inherit; font-size: .9rem; font-weight: 600; padding: 7px 10px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); color-scheme: inherit; min-width: 0;
}
.date-field input:focus-visible { outline: 2px solid var(--brand-a); outline-offset: 2px; }
@media (max-width: 1040px) {
  .header-inner { height: auto; flex-wrap: wrap; padding-top: 10px; padding-bottom: 6px; row-gap: 6px; }
  .top-nav { order: 3; flex-basis: 100%; padding: 0; margin: 0 -4px;
    -webkit-mask-image: linear-gradient(to right, #000 85%, transparent); mask-image: linear-gradient(to right, #000 85%, transparent); }
  .top-nav a:first-child { margin-left: 0; }
  .section-title { scroll-margin-top: 120px; }
}
.filter-label { font-size: .86rem; color: var(--text-2); font-weight: 600; }
select {
  font: inherit; font-weight: 600; padding: 8px 34px 8px 14px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--surface) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M7 10l5 5 5-5' fill='none' stroke='%237a7974' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") no-repeat right 10px center / 16px;
  color: var(--text); appearance: none; cursor: pointer;
}
.section-title { margin: 40px 0 14px; font-size: .78rem; text-transform: uppercase; letter-spacing: .1em; color: var(--text-3); font-weight: 700; display: flex; align-items: center; gap: 10px; }
.section-title::after { content: ""; flex: 1; height: 1px; background: var(--border); }

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

.kpi-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.kpi { padding: 18px 20px; position: relative; overflow: hidden; }
.kpi-top { display: flex; align-items: center; gap: 10px; }
.kpi-icon { width: 30px; height: 30px; border-radius: 9px; display: grid; place-items: center; flex: none; }
.kpi-icon svg { width: 17px; height: 17px; }
.kpi-icon.c1 { background: color-mix(in srgb, var(--brand-a) 14%, transparent); color: var(--brand-a); }
.kpi-icon.c2 { background: color-mix(in srgb, var(--brand-b) 14%, transparent); color: var(--brand-b); }
.kpi-icon.c3 { background: color-mix(in srgb, var(--brand-c) 16%, transparent); color: var(--brand-c); }
.kpi-label { font-size: .82rem; color: var(--text-2); font-weight: 600; }
.kpi-value { font-size: 2.3rem; font-weight: 780; letter-spacing: -0.03em; margin-top: 12px; font-variant-numeric: tabular-nums; line-height: 1.1; }
.kpi-note { font-size: .78rem; color: var(--text-3); margin-top: 4px; }

.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }
.grid-2 > .wide { grid-column: 1 / -1; }
.chart-card figcaption { margin-bottom: 12px; }
.chart-card h3 { font-size: 1.08rem; }
.takeaway {
  margin: 8px 0 4px; padding: 8px 12px; border-radius: 10px; font-size: .92rem; font-weight: 520; line-height: 1.45; color: var(--text);
  background: color-mix(in srgb, var(--brand-a) 7%, var(--surface)); border-left: 3px solid var(--brand-a);
}
.takeaway:empty { display: none; }
.takeaway + .muted { margin-top: 6px; font-size: .8rem; color: var(--text-3); }

/* ---------- Your story ---------- */
.story-head { display: flex; align-items: center; gap: 14px; }
.story-head .section-title { flex: 1; }
.story-head .btn { margin-top: 26px; }
.card-save { position: absolute; top: 12px; right: 12px; width: 32px; height: 32px; opacity: .55; }
.card-save svg { width: 17px; height: 17px; }
.story-card:hover .card-save, .card-save:focus-visible { opacity: 1; }

/* theme button */
.theme-btn svg { display: none; }
.theme-btn[data-mode="automatic"] .ic-auto, .theme-btn[data-mode="light"] .ic-light, .theme-btn[data-mode="dark"] .ic-dark { display: block; }

/* ---------- Story mode ---------- */
.story-mode {
  width: min(460px, 100vw); height: min(860px, 100dvh); max-width: 100vw; max-height: 100dvh; padding: 0; border: 0;
  border-radius: 26px; background: #0f0f12; color: #fff; overflow: hidden; box-shadow: var(--shadow-lg);
}
.story-mode[open] { display: flex; flex-direction: column; animation: dlg-in .18s ease-out; }
.story-mode::backdrop { background: rgba(8, 6, 16, .82); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.sm-progress { display: flex; gap: 4px; padding: 14px 16px 0; }
.sm-progress i { flex: 1; height: 3px; border-radius: 2px; background: rgba(255,255,255,.25); }
.sm-progress i.done { background: #fff; }
.sm-top { display: flex; align-items: center; justify-content: space-between; padding: 8px 10px 0 18px; }
.sm-brand { font-weight: 750; letter-spacing: -0.01em; opacity: .9; }
.story-mode .icon-btn { color: rgba(255,255,255,.85); }
.story-mode .icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.sm-stage { position: relative; flex: 1; padding: 12px 16px; display: flex; min-height: 0; }
.sm-card {
  flex: 1; border-radius: 22px; padding: 32px 28px; display: flex; flex-direction: column; justify-content: center;
  background: var(--brand-grad); position: relative; overflow: hidden;
}
.sm-card.c1 { background: linear-gradient(150deg, #5b3fd9, #7b5cf0 55%, #b04fd6); }
.sm-card.c3 { background: linear-gradient(150deg, #e3497a, #f0803c 55%, #f4b04c); }
.sm-card::before { content: ""; position: absolute; width: 300px; height: 300px; border-radius: 50%; right: -110px; top: -120px; background: rgba(255,255,255,.1); }
.sm-card .sm-icon { width: 58px; height: 58px; border-radius: 16px; background: rgba(255,255,255,.18); display: grid; place-items: center; margin-bottom: 22px; }
.sm-card .sm-icon svg { width: 32px; height: 32px; }
.sm-big { font-size: clamp(2.6rem, 13vw, 4.2rem); font-weight: 800; letter-spacing: -0.04em; line-height: 1.02; overflow-wrap: anywhere; }
.sm-text { font-size: 1.2rem; line-height: 1.45; margin: 16px 0 0; opacity: .95; }
.sm-card.enter { animation: sm-in .28s ease-out; }
@keyframes sm-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: none; } }
.sm-nav { position: absolute; top: 0; bottom: 0; z-index: 2; border: 0; background: transparent; cursor: pointer; }
.sm-prev { left: 0; width: 33%; }
.sm-next { right: 0; width: 67%; }
.sm-nav:focus-visible { outline: 2px solid #fff; outline-offset: -6px; border-radius: 22px; }
.sm-foot { display: flex; align-items: center; justify-content: space-between; padding: 4px 16px 18px 20px; }
.sm-count { font-size: .88rem; opacity: .75; }
.sm-save { background: rgba(255,255,255,.14); color: #fff; border-color: rgba(255,255,255,.25); }
.sm-save:hover { border-color: #fff; }
@media (max-width: 520px) { .story-mode { border-radius: 0; width: 100vw; height: 100dvh; } }
.story-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }
.story-card {
  position: relative; overflow: hidden; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px 22px 22px; box-shadow: var(--shadow);
}
.story-card::after { content: ""; position: absolute; inset: 0 0 auto 0; height: 4px; background: var(--brand-grad); opacity: .85; }
.story-card .kpi-icon { width: 34px; height: 34px; border-radius: 10px; }
.story-card .kpi-icon svg { width: 19px; height: 19px; }
.story-big { font-size: clamp(1.7rem, 3.2vw, 2.3rem); font-weight: 800; letter-spacing: -0.035em; line-height: 1.1; margin-top: 14px; overflow-wrap: anywhere; }
.story-card.c1 .story-big { color: var(--brand-a); }
.story-card.c2 .story-big { color: var(--brand-b); }
.story-card.c3 .story-big { color: color-mix(in srgb, var(--brand-c) 85%, var(--text)); }
.story-text { margin: 8px 0 0; color: var(--text-2); font-size: 1rem; line-height: 1.5; }
@media (max-width: 900px) { .story-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .story-grid { grid-template-columns: minmax(0, 1fr); } }
.chart-box { position: relative; height: 240px; }
.wide .chart-box { height: 290px; }

.legend { display: flex; gap: 16px; flex-wrap: wrap; margin: -4px 0 10px; font-size: .82rem; color: var(--text-2); font-weight: 500; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }

.word-cloud { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 16px; align-items: baseline; }
.word { padding: 4px 11px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text); font-weight: 550; }
.word small { color: var(--text-3); margin-left: 5px; font-size: .72em; font-weight: 500; }
.empty-note { color: var(--text-3); font-size: .86rem; margin-top: 14px; }
.empty-note.full { width: 100%; }

.data-table { width: 100%; border-collapse: collapse; font-size: .875rem; margin-top: 12px; font-variant-numeric: tabular-nums; }
.data-table th, .data-table td { text-align: right; padding: 8px 10px; border-bottom: 1px solid var(--grid); white-space: nowrap; }
.data-table th:first-child, .data-table td:first-child { text-align: left; }
.data-table th { color: var(--text-3); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; }
.data-table tbody tr:last-child td { border-bottom: 0; }
.table-details summary { cursor: pointer; font-weight: 650; }
.table-scroll { overflow-x: auto; max-height: 480px; }
.table-details { margin-top: 28px; }

/* ---------- About this export ---------- */
.ov-lede { margin: 0 0 14px; }
.ov-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.ov-stat { background: var(--surface-2); border-radius: 14px; padding: 12px 14px; min-width: 0; }
.ov-value { font-size: 1.45rem; font-weight: 760; letter-spacing: -0.02em; margin-top: 4px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; line-height: 1.2; }
.ov-stat.small .ov-value { font-size: 1rem; font-weight: 650; letter-spacing: -0.01em; margin-top: 6px; }
.ov-matches { margin-top: 20px; }
.ov-matches .muted { max-width: 760px; }
.ov-bar { display: flex; height: 30px; border-radius: 10px; overflow: hidden; margin: 12px 0 10px; background: var(--surface-2); }
.ov-seg { display: flex; align-items: center; justify-content: center; color: #fff; font-size: .8rem; font-weight: 700; min-width: 2px; }
.ov-seg + .ov-seg { border-left: 2px solid var(--surface); }
.ov-legend { margin: 0; }
.ov-sections { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.ov-sections .muted { margin: 0 4px 0 0; }
@media (max-width: 900px) { .ov-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }

/* ---------- Conversations & all-data sections ---------- */
.section-lede { margin: -6px 0 14px; }
.convo-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 14px; flex-wrap: wrap; margin-bottom: 14px; }
.search {
  font: inherit; padding: 9px 14px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text); min-width: 0; width: min(320px, 100%);
}
.search:focus-visible { outline: 2px solid var(--brand-a); outline-offset: 2px; }
.convo-list { display: grid; gap: 6px; max-height: 640px; overflow-y: auto; }
.convo { border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.convo summary, .data-section summary {
  cursor: pointer; list-style: none; display: flex; align-items: baseline; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.convo summary { padding: 11px 14px; }
.convo summary::-webkit-details-marker, .data-section summary::-webkit-details-marker { display: none; }
.convo summary::before, .data-section summary::before {
  content: ""; width: 7px; height: 7px; border: solid var(--text-3); border-width: 0 2px 2px 0; transform: rotate(-45deg);
  margin-right: 4px; flex: none; align-self: center; transition: transform .15s;
}
.convo[open] > summary::before, .data-section[open] > summary::before { transform: rotate(45deg); }
.convo summary b { flex: 1; font-weight: 650; }
.convo-meta { color: var(--text-3); font-size: .82rem; }
.msgs { list-style: none; margin: 0; padding: 4px 14px 14px 28px; display: grid; gap: 8px; }
.msgs li { background: var(--surface-2); border-radius: 12px; padding: 8px 12px; max-width: 640px; }
.msgs li.hit { outline: 2px solid color-mix(in srgb, var(--brand-b) 60%, transparent); }
.msgs time { display: block; font-size: .72rem; color: var(--text-3); margin-bottom: 2px; }
.msgs p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.more-btn { margin-top: 12px; }

.all-sections { display: grid; gap: 12px; }
.data-section > summary h3 { flex: 1; }
.data-section > .kv, .data-section > .kv-list, .data-section > .kv-chips { margin-top: 14px; }
.kv { display: grid; grid-template-columns: minmax(120px, 220px) minmax(0, 1fr); gap: 0; margin: 0; font-size: .9rem; }
.kv > dt { color: var(--text-2); font-weight: 600; padding: 8px 12px 8px 0; border-top: 1px solid var(--grid); }
.kv > dd { margin: 0; padding: 8px 0; border-top: 1px solid var(--grid); min-width: 0; overflow-wrap: anywhere; }
.kv .kv { font-size: .86rem; }
.kv-list { margin: 0; padding-left: 20px; display: grid; gap: 8px; }
.kv-list > li { overflow-wrap: anywhere; }
.kv-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.kv-chip { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; font-size: .84rem; overflow-wrap: anywhere; }
.kv-empty { color: var(--text-3); }
@media (max-width: 520px) {
  .kv { grid-template-columns: minmax(0, 1fr); }
  .kv > dt { padding-bottom: 0; }
  .kv > dd { border-top: 0; padding-top: 2px; }
}

/* ---------- Export dialog ---------- */
.export-dialog {
  width: min(620px, calc(100vw - 24px)); max-height: calc(100vh - 32px); padding: 0; border: 1px solid var(--border);
  border-radius: 22px; background: var(--surface); color: var(--text); box-shadow: var(--shadow-lg);
}
.export-dialog[open] { display: flex; flex-direction: column; animation: dlg-in .18s ease-out; }
.export-dialog::backdrop { background: rgba(12, 8, 24, .45); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(8px) scale(.98); } to { opacity: 1; transform: none; } }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 6px 24px; }
.dlg-body { padding: 8px 24px 12px; overflow-y: auto; }
.dlg-foot { display: flex; align-items: center; justify-content: flex-end; gap: 10px; padding: 14px 18px 18px 24px; border-top: 1px solid var(--border); }
.dlg-status { margin: 0 auto 0 0; font-size: .85rem; color: var(--text-2); }
.dlg-note { font-size: .82rem; color: var(--text-3); margin: 16px 0 0; }
.seg { border: 0; padding: 0; margin: 6px 0 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.seg legend { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; margin-bottom: 8px; padding: 0; }
.seg label { position: relative; cursor: pointer; }
.seg input { position: absolute; opacity: 0; }
.seg label > span { display: flex; flex-direction: column; gap: 2px; padding: 14px 16px; border-radius: 14px; border: 1.5px solid var(--border); transition: border-color .15s, background .15s; }
.seg small { color: var(--text-3); font-size: .8rem; }
.seg input:checked + span { border-color: var(--brand-b); background: color-mix(in srgb, var(--brand-b) 7%, var(--surface)); }
.seg input:focus-visible + span { outline: 2px solid var(--brand-a); outline-offset: 2px; }
.opt-head { display: flex; justify-content: space-between; align-items: baseline; margin: 22px 0 10px; }
.opt-head h3 { font-size: .78rem; text-transform: uppercase; letter-spacing: .08em; color: var(--text-3); font-weight: 700; }
.opt-links { font-size: .85rem; color: var(--text-3); }
.opt-groups { display: grid; gap: 14px; }
.opt-group h4 { margin: 0 0 6px; font-size: .9rem; font-weight: 650; }
.opt-list { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 12px; }
.opt { display: flex; gap: 10px; align-items: flex-start; padding: 7px 8px; border-radius: 10px; cursor: pointer; font-size: .9rem; }
.opt:hover { background: var(--surface-2); }
.opt input { width: 17px; height: 17px; margin: 2px 0 0; accent-color: var(--brand-b); flex: none; }
.opt small { display: block; color: var(--text-3); font-size: .78rem; }

.offscreen { position: fixed; left: -10000px; top: 0; width: 1200px; pointer-events: none; }

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .kpi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-2, .features, .info-grid { grid-template-columns: minmax(0, 1fr); }
  .dash-hero-big { text-align: left; }
}
@media (max-width: 520px) {
  .upload-view { padding-top: 40px; }
  .kpi-value { font-size: 1.45rem; }
  .kpi { padding: 14px; }
  .card { padding: 16px; }
  .dash-hero { padding: 26px 22px; border-radius: 22px; }
  .toolbar { padding: 10px 10px 10px 14px; }
  .toolbar .btn { padding: 9px 14px; font-size: .86rem; }
  .opt-list { grid-template-columns: 1fr; }
  #topDays th, #topDays td { padding: 7px 5px; font-size: .82rem; }
  #topDays td:first-child { white-space: normal; }
  .seg { grid-template-columns: 1fr; }
  .header-actions #exportBtnTop { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

/* ---------- Small phones ---------- */
@media (max-width: 700px) {
  /* the toolbar wraps to several rows on phones, so don't pin it over the content */
  .toolbar { position: static; }
  .section-title { scroll-margin-top: 110px; }
  .opt-head { flex-wrap: wrap; gap: 4px 12px; }
}
@media (max-width: 420px) {
  .wrap { padding: 0 12px; }
  .header-inner { min-height: 56px; }
  .brand { font-size: .98rem; gap: 8px; }
  .dash-hero { padding: 22px 16px; }
  .hero-stats { gap: 8px; }
  .hs { padding: 12px 12px 14px; border-radius: 14px; }
  .hs-label { font-size: .76rem; }
  .hs-big { font-size: 2.05rem; }
  .hs-note { font-size: .8rem; }
  .kpi-grid { gap: 10px; }
  .kpi-top { flex-direction: column; align-items: flex-start; gap: 8px; }
  .kpi-value { font-size: 1.8rem; margin-top: 8px; }
  .ov-grid { gap: 8px; }
  .ov-stat { padding: 10px 11px; }
  .ov-value { font-size: 1.2rem; }
  .ov-stat.small .ov-value { font-size: .88rem; }
  .story-card { padding: 18px; }
  .chart-box { height: 220px; }
  .wide .chart-box { height: 240px; }
}
