/* ════════════════════════════════════════════════════════════
   AURORA — shared design system for the v2 pages
   index2 · fitness2 · running2 · insights2
   ════════════════════════════════════════════════════════════ */

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

/* ── TOKENS ─────────────────────────────────────────────── */
[data-theme="dark"] {
  --bg:        #06070d;
  --panel:     rgba(255,255,255,.045);
  --panel-2:   rgba(255,255,255,.08);
  --stroke:    rgba(255,255,255,.085);
  --stroke-2:  rgba(255,255,255,.18);
  --text:      #edf0f7;
  --muted:     #8b93a7;
  --a1:        #7c6cff;
  --a2:        #2dd4ff;
  --green:     #3ddc97;
  --red:       #ff6b81;
  --amber:     #ffc24b;
  --purple:    #c58bff;
  --dim-green: rgba(61,220,151,.13);
  --dim-red:   rgba(255,107,129,.13);
  --dim-amber: rgba(255,194,75,.13);
  --dim-purple:rgba(197,139,255,.15);
  --dim-a1:    rgba(124,108,255,.15);
  --card-shadow: 0 14px 44px rgba(0,0,0,.35);
  --glow:      0 10px 40px rgba(124,108,255,.16);
  --blob-opacity: .55;
  color-scheme: dark;
}
[data-theme="light"] {
  --bg:        #f2f4fb;
  --panel:     rgba(255,255,255,.72);
  --panel-2:   rgba(255,255,255,.95);
  --stroke:    rgba(20,24,40,.09);
  --stroke-2:  rgba(20,24,40,.2);
  --text:      #171b28;
  --muted:     #5e6679;
  --a1:        #6356f0;
  --a2:        #0894c2;
  --green:     #0f9d6a;
  --red:       #e23b58;
  --amber:     #b97c0a;
  --purple:    #8b4fd6;
  --dim-green: rgba(15,157,106,.11);
  --dim-red:   rgba(226,59,88,.1);
  --dim-amber: rgba(185,124,10,.12);
  --dim-purple:rgba(139,79,214,.11);
  --dim-a1:    rgba(99,86,240,.1);
  --card-shadow: 0 14px 40px rgba(35,42,70,.08);
  --glow:      0 10px 36px rgba(99,86,240,.14);
  --blob-opacity: .4;
  color-scheme: light;
}

html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Inter', system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  min-height: 100vh;
  overflow-x: hidden;
  transition: background .25s, color .25s;
  -webkit-font-smoothing: antialiased;
}

/* ── AURORA BACKDROP ────────────────────────────────────── */
.aurora { position: fixed; inset: 0; z-index: -2; overflow: hidden; pointer-events: none; opacity: var(--blob-opacity); }
.aurora span { position: absolute; border-radius: 50%; filter: blur(90px); will-change: transform; }
.aurora .b1 { width: 52vw; height: 52vw; min-width: 420px; min-height: 420px; left: -14vw; top: -18vw;
  background: radial-gradient(circle at 35% 35%, var(--a1), transparent 65%);
  animation: drift1 26s ease-in-out infinite alternate; }
.aurora .b2 { width: 44vw; height: 44vw; min-width: 380px; min-height: 380px; right: -12vw; top: 4vh;
  background: radial-gradient(circle at 60% 40%, var(--a2), transparent 65%);
  animation: drift2 32s ease-in-out infinite alternate; }
.aurora .b3 { width: 38vw; height: 38vw; min-width: 320px; min-height: 320px; left: 28vw; bottom: -24vh;
  background: radial-gradient(circle at 50% 50%, var(--purple), transparent 62%);
  animation: drift3 38s ease-in-out infinite alternate; opacity: .65; }
@keyframes drift1 { to { transform: translate(9vw, 7vh) scale(1.12); } }
@keyframes drift2 { to { transform: translate(-7vw, 12vh) scale(.92); } }
@keyframes drift3 { to { transform: translate(-10vw, -8vh) scale(1.18); } }
@media (prefers-reduced-motion: reduce) {
  .aurora span { animation: none !important; }
}

/* ── LAYOUT ─────────────────────────────────────────────── */
.shell { max-width: 1180px; margin: 0 auto; padding: .8rem 1rem 4rem; }

/* ── TOP BAR ────────────────────────────────────────────── */
.topbar {
  position: sticky; top: 10px; z-index: 100;
  display: flex; align-items: center; gap: .65rem;
  max-width: 1180px; margin: 10px auto 0;
  padding: .5rem .65rem;
  background: color-mix(in srgb, var(--bg) 62%, transparent);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border: 1px solid var(--stroke);
  border-radius: 18px;
  box-shadow: var(--card-shadow);
}
.brand { display: flex; align-items: center; gap: .5rem; text-decoration: none; color: var(--text); flex-shrink: 0; }
.logo {
  width: 28px; height: 28px; border-radius: 9px; flex-shrink: 0;
  background: linear-gradient(135deg, var(--a1), var(--a2));
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--a1) 45%, transparent);
}
.logo svg { width: 16px; height: 16px; stroke: #fff; fill: none; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.brand-name { font-weight: 800; font-size: .88rem; letter-spacing: -.02em; }
@media (max-width: 760px) { .brand-name { display: none; } }

.nav { display: flex; gap: 3px; overflow-x: auto; scrollbar-width: none; flex: 1 1 auto; min-width: 0; }
.nav::-webkit-scrollbar { display: none; }
.nav a {
  flex-shrink: 0; text-decoration: none; color: var(--muted);
  font-weight: 600; font-size: .76rem;
  padding: .42rem .8rem; border-radius: 11px;
  transition: color .15s, background .15s;
}
.nav a:hover { color: var(--text); background: var(--panel-2); }
.nav a.active {
  color: #fff;
  background: linear-gradient(135deg, var(--a1), var(--a2));
  box-shadow: 0 4px 16px color-mix(in srgb, var(--a1) 40%, transparent);
}
[data-theme="light"] .nav a.active { color: #fff; }

.controls { display: flex; align-items: center; gap: .45rem; flex-shrink: 0; margin-left: auto; }

/* segmented control (range / tabs) */
.seg {
  display: flex; gap: 2px;
  background: var(--panel); border: 1px solid var(--stroke);
  border-radius: 12px; padding: 3px;
}
.seg button {
  background: none; border: none; color: var(--muted);
  border-radius: 9px; padding: .38rem .62rem;
  font: 600 .72rem/1 'Inter', sans-serif;
  cursor: pointer; transition: color .15s, background .15s, box-shadow .15s;
  white-space: nowrap;
}
.seg button:hover:not(.active) { color: var(--text); }
.seg button.active {
  color: #fff;
  background: linear-gradient(135deg, var(--a1), var(--a2));
  box-shadow: 0 3px 12px color-mix(in srgb, var(--a1) 40%, transparent);
}

.icon-btn {
  width: 34px; height: 34px; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--panel); border: 1px solid var(--stroke);
  border-radius: 11px; cursor: pointer; color: var(--muted);
  font-size: .95rem; text-decoration: none;
  transition: color .15s, border-color .15s, transform .15s;
}
.icon-btn:hover { color: var(--text); border-color: var(--stroke-2); transform: translateY(-1px); }

.classic-link {
  display: inline-flex; align-items: center; gap: .3rem;
  background: var(--panel); border: 1px solid var(--stroke);
  border-radius: 11px; padding: .42rem .7rem;
  font: 600 .7rem/1 'Inter', sans-serif;
  color: var(--muted); text-decoration: none; white-space: nowrap;
  transition: color .15s, border-color .15s;
}
.classic-link:hover { color: var(--text); border-color: var(--stroke-2); }

/* ── HERO ───────────────────────────────────────────────── */
.hero { padding: 1.8rem .2rem 1.1rem; }
.hero h1 {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: clamp(1.7rem, 4.5vw, 2.5rem);
  font-weight: 700; letter-spacing: -.03em; line-height: 1.1;
}
.hero h1 .grad {
  background: linear-gradient(100deg, var(--a1), var(--a2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}
.hero .sub { color: var(--muted); font-size: .8rem; margin-top: .35rem; }

/* ── GRID + CARDS ───────────────────────────────────────── */
.grid { display: grid; gap: 14px; grid-template-columns: 1fr; }
.section { margin-top: 22px; }
.section-hdr {
  display: flex; align-items: center; gap: .6rem;
  font-size: .68rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .14em; color: var(--muted);
  margin: 0 .2rem 12px;
}
.section-hdr::after { content: ''; flex: 1; height: 1px; background: var(--stroke); }

.card {
  background: var(--panel);
  border: 1px solid var(--stroke);
  border-radius: 20px;
  padding: 1.05rem 1.15rem;
  position: relative; overflow: hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  transition: transform .22s ease, border-color .22s ease, box-shadow .22s ease;
}
.card:hover { transform: translateY(-3px); border-color: var(--stroke-2); box-shadow: var(--glow); }
.card.flat:hover { transform: none; box-shadow: none; }
.card.spot::before {
  content: ''; position: absolute; top: -1px; left: 12%; right: 12%; height: 1px;
  background: linear-gradient(90deg, transparent, var(--a2), transparent);
}

.kpi-label {
  font-size: .62rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted); margin-bottom: .45rem;
}
.kpi-val {
  font-family: 'Space Grotesk', 'Inter', sans-serif;
  font-size: 1.7rem; font-weight: 700; letter-spacing: -.03em; line-height: 1;
  font-variant-numeric: tabular-nums;
}
.kpi-val.lg { font-size: 2.9rem; }
.kpi-unit { font-size: .85rem; font-weight: 500; color: var(--muted); margin-left: 3px; }
.kpi-sub { font-size: .68rem; color: var(--muted); margin-top: .4rem; }

.grad-text {
  background: linear-gradient(100deg, var(--a1), var(--a2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; color: transparent;
}

/* delta chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px;
  font-size: .68rem; font-weight: 700;
  padding: 3px 9px; border-radius: 20px;
  background: var(--panel-2); color: var(--muted);
}
.chip.good { background: var(--dim-green); color: var(--green); }
.chip.bad  { background: var(--dim-red);   color: var(--red); }
.chip.warn { background: var(--dim-amber); color: var(--amber); }
.chip.info { background: var(--dim-a1);    color: var(--a1); }
[data-theme="dark"] .chip.info { color: #a99cff; }

.up   { color: var(--red); }
.down { color: var(--green); }
.flat-c { color: var(--muted); }

/* ── CHART CARDS ────────────────────────────────────────── */
.chart-card h3 {
  font-size: .64rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: .12em; color: var(--muted); margin-bottom: .8rem;
  display: flex; align-items: center; gap: .45rem;
}
.chart-card h3 .dot { width: 7px; height: 7px; border-radius: 50%; background: linear-gradient(135deg, var(--a1), var(--a2)); flex-shrink: 0; }
.chart-note { font-size: .71rem; color: var(--muted); margin-top: .6rem; line-height: 1.45; }
.chart-note strong { color: var(--text); }
.chart-note .hl {
  background: linear-gradient(100deg, var(--a1), var(--a2));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent; font-weight: 700;
}

/* ── SPLIT / STACK BARS ─────────────────────────────────── */
.split-bar { height: 12px; border-radius: 6px; background: var(--panel-2); overflow: hidden; display: flex; }
.split-bar > div { transition: width .7s cubic-bezier(.22,1,.36,1); }
.bar-red    { background: linear-gradient(90deg, var(--red), color-mix(in srgb, var(--red) 60%, var(--amber))); }
.bar-green  { background: linear-gradient(90deg, color-mix(in srgb, var(--green) 70%, var(--a2)), var(--green)); }
.bar-purple { background: linear-gradient(90deg, var(--purple), var(--a1)); }
.bar-accent { background: linear-gradient(90deg, var(--a1), var(--a2)); }
.bar-amber  { background: linear-gradient(90deg, var(--amber), color-mix(in srgb, var(--amber) 55%, var(--red))); }
.split-legend { display: flex; flex-wrap: wrap; gap: .85rem; margin-top: 7px; }
.split-legend span { font-size: .66rem; color: var(--muted); display: flex; align-items: center; gap: 5px; }
.split-legend span::before { content: ''; display: inline-block; width: 8px; height: 8px; border-radius: 3px; background: var(--swatch-c, var(--muted)); }

/* progress bars */
.prog-wrap { margin-top: .2rem; }
.prog-row { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: .35rem; }
.prog-label { font-size: .72rem; font-weight: 600; }
.prog-count { font-size: .66rem; color: var(--muted); }
.prog-bar { height: 9px; border-radius: 5px; background: var(--panel-2); overflow: hidden; }
.prog-fill { height: 100%; border-radius: 5px; background: linear-gradient(90deg, var(--a1), var(--a2)); transition: width .8s cubic-bezier(.22,1,.36,1); }
.prog-fill.green { background: linear-gradient(90deg, color-mix(in srgb, var(--green) 70%, var(--a2)), var(--green)); }
.prog-fill.amber { background: linear-gradient(90deg, var(--amber), color-mix(in srgb, var(--amber) 55%, var(--red))); }
.prog-fill.purple{ background: linear-gradient(90deg, var(--purple), var(--a1)); }

/* ── HEATMAP ────────────────────────────────────────────── */
.heatmap-wrap { overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.heatmap-wrap::-webkit-scrollbar { display: none; }
.heatmap { display: grid; grid-auto-flow: column; grid-template-rows: repeat(7, 11px); gap: 3px; width: max-content; }
.hm-cell { width: 11px; height: 11px; border-radius: 3px; background: var(--panel-2); transition: transform .12s; }
.hm-cell:hover { transform: scale(1.35); }
.hm-cell[data-level="1"] { background: color-mix(in srgb, var(--a2) 30%, var(--panel-2)); }
.hm-cell[data-level="2"] { background: color-mix(in srgb, var(--a2) 65%, var(--a1)); }
.hm-cell[data-level="3"] { background: linear-gradient(135deg, var(--a1), var(--a2)); box-shadow: 0 0 8px color-mix(in srgb, var(--a2) 50%, transparent); }

/* ── BADGES ─────────────────────────────────────────────── */
.badge-row { display: flex; flex-wrap: wrap; gap: .4rem; }
.state-badge {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: .7rem; font-weight: 600; padding: 4px 11px;
  border-radius: 20px; width: fit-content;
  background: var(--panel-2); color: var(--muted);
  border: 1px solid transparent;
}
.state-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex-shrink: 0; }
.badge-green  { background: var(--dim-green);  color: var(--green); }
.badge-red    { background: var(--dim-red);    color: var(--red); }
.badge-amber  { background: var(--dim-amber);  color: var(--amber); }
.badge-purple { background: var(--dim-purple); color: var(--purple); }
.badge-accent { background: var(--dim-a1);     color: var(--a1); }
[data-theme="dark"] .badge-accent { color: #a99cff; }
.badge-muted  { background: var(--panel-2);    color: var(--muted); }

/* ── TABLES ─────────────────────────────────────────────── */
.tbl-wrap { overflow-x: auto; scrollbar-width: thin; }
.tbl { width: 100%; border-collapse: collapse; font-size: .75rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.tbl th {
  text-align: left; padding: .45rem .55rem; color: var(--muted);
  font-weight: 700; font-size: .6rem; text-transform: uppercase; letter-spacing: .1em;
  border-bottom: 1px solid var(--stroke);
}
.tbl td { padding: .5rem .55rem; border-bottom: 1px solid color-mix(in srgb, var(--stroke) 55%, transparent); }
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr { transition: background .12s; }
.tbl tbody tr:hover { background: var(--panel-2); }

/* ── RING (SVG progress ring) ───────────────────────────── */
.ring-wrap { position: relative; width: 118px; height: 118px; flex-shrink: 0; }
.ring-wrap svg { transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: var(--panel-2); stroke-width: 9; }
.ring-fg { fill: none; stroke-width: 9; stroke-linecap: round; transition: stroke-dashoffset 1s cubic-bezier(.22,1,.36,1); }
.ring-center { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; }
.ring-val { font-family: 'Space Grotesk', sans-serif; font-size: 1.75rem; font-weight: 700; letter-spacing: -.03em; line-height: 1; }
.ring-cap { font-size: .56rem; font-weight: 700; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin-top: 3px; }

/* ── MISC ───────────────────────────────────────────────── */
.empty {
  border: 1px dashed var(--stroke-2); border-radius: 20px;
  padding: 2.2rem 1rem; text-align: center; color: var(--muted); font-size: .8rem;
  background: var(--panel);
}
.error-banner {
  background: var(--dim-red); border: 1px solid color-mix(in srgb, var(--red) 40%, transparent);
  border-radius: 14px; padding: .7rem 1rem; color: var(--red); font-size: .78rem;
}
.skeleton {
  background: linear-gradient(90deg, var(--panel) 25%, var(--panel-2) 50%, var(--panel) 75%);
  background-size: 200% 100%; animation: shimmer 1.4s infinite;
  border-radius: 20px; border: 1px solid var(--stroke);
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

footer.foot { text-align: center; color: var(--muted); font-size: .68rem; padding: 2.5rem 0 0; }
footer.foot a { color: var(--muted); }

/* ── REVEAL ANIMATION ───────────────────────────────────── */
.reveal { opacity: 0; transform: translateY(16px); transition: opacity .6s ease, transform .6s cubic-bezier(.22,1,.36,1); transition-delay: var(--d, 0s); }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
  .reveal { opacity: 1; transform: none; transition: none; }
}
/* hard-off switch set by aurora.js (?noanim / reduced motion) */
html.noanim .reveal { opacity: 1 !important; transform: none !important; transition: none !important; }
html.noanim .aurora span { animation: none !important; }
html.noanim .ring-fg, html.noanim .prog-fill, html.noanim .split-bar > div, html.noanim .stage-bar > div { transition: none !important; }

/* ── RESPONSIVE GRIDS ───────────────────────────────────── */
@media (min-width: 560px) {
  .grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-3 { grid-template-columns: repeat(2, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 880px) {
  .grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
  .grid.cols-4 { grid-template-columns: repeat(4, 1fr); }
  .grid.hero-grid { grid-template-columns: 300px 1fr; align-items: stretch; }
}
@media (max-width: 700px) {
  .topbar { flex-wrap: wrap; }
  .controls { margin-left: 0; width: 100%; justify-content: space-between; }
}
