/* ============================================================
   LINGUATERRA — Apple-inspired glass system
   visionOS / iOS 26 / macOS Tahoe lineage
   Inter + Space Grotesk + JetBrains Mono + Noto Sans TC/SC
   ============================================================ */

:root {
  /* Surface — Deep Space canvas */
  --bg-base: #0a0e27;        /* deep navy floor */
  --bg-tint-hi: #1a1f4e;     /* indigo top-left */
  --bg-tint-lo: #050714;     /* near-black bottom-right */
  --bg-0: #0a0e27;
  --bg-1: #11163a;
  --bg-2: #181d47;
  --bg-3: #232a5c;

  /* Glass surfaces */
  --glass-1: rgba(255, 255, 255, 0.04);
  --glass-2: rgba(255, 255, 255, 0.07);
  --glass-3: rgba(255, 255, 255, 0.11);
  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.14);
  --inner-hi: rgba(255, 255, 255, 0.10);   /* top-edge highlight */

  /* Text */
  --fg-0: rgba(255, 255, 255, 0.92);
  --fg-1: rgba(255, 255, 255, 0.74);
  --fg-2: rgba(255, 255, 255, 0.55);
  --fg-3: rgba(255, 255, 255, 0.38);

  /* Brand accents — logo gold */
  --accent: #c9a84c;                              /* E.T. Cosmo gold */
  --accent-soft: rgba(201, 168, 76, 0.55);
  --accent-glow: rgba(201, 168, 76, 0.30);
  --accent-tint: rgba(201, 168, 76, 0.14);
  --accent-edge: rgba(201, 168, 76, 0.32);

  --info: #7dd3fc;
  --info-tint: rgba(125, 211, 252, 0.12);
  --info-edge: rgba(125, 211, 252, 0.30);

  --warn: #fbbf77;                                /* gold-amber */
  --warn-tint: rgba(251, 191, 119, 0.14);
  --warn-edge: rgba(251, 191, 119, 0.30);

  --attn: #c084fc;                                /* nebula violet */
  --attn-tint: rgba(192, 132, 252, 0.14);
  --attn-edge: rgba(192, 132, 252, 0.32);

  /* Legacy alias mapping — preserved for component code that still references them.
     Now routes through the cosmic palette. */
  --lime: var(--accent);
  --lime-soft: var(--accent-tint);
  --lime-glow: var(--accent-glow);
  --amber: var(--warn);
  --amber-glow: rgba(251, 191, 119, 0.30);
  --magenta: var(--attn);
  --magenta-glow: rgba(192, 132, 252, 0.30);
  --cyan: var(--accent);
  --violet: var(--attn);
  --good: var(--accent);
  --bad: var(--attn);

  /* Type */
  --font-display: "Merriweather", Georgia, "Times New Roman", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "SF Mono", monospace;
  --font-tc: "Noto Sans TC", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-sc: "Noto Sans SC", -apple-system, BlinkMacSystemFont, sans-serif;

  /* Motion — Apple spring */
  --spring: cubic-bezier(0.32, 0.72, 0, 1);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);

  /* Radius — strict scale */
  --r-input: 10px;
  --r-btn: 12px;
  --r-card: 20px;
  --r-modal: 24px;
  --r-sm: 10px;
  --r-md: 14px;
  --r-lg: 20px;
  --r-xl: 24px;

  /* Shadows */
  --shadow-card:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 16px 48px rgba(0, 0, 0, 0.12);
  --shadow-card-hover:
    0 1px 2px rgba(0, 0, 0, 0.04),
    0 4px 12px rgba(0, 0, 0, 0.08),
    0 24px 64px rgba(0, 0, 0, 0.22);
  --shadow-btn:
    0 1px 2px rgba(0, 0, 0, 0.06),
    0 2px 8px rgba(0, 0, 0, 0.10);
  --shadow-modal:
    0 1px 2px rgba(0, 0, 0, 0.05),
    0 12px 40px rgba(0, 0, 0, 0.20),
    0 40px 120px rgba(0, 0, 0, 0.40);
}

[data-theme="light"] {
  /* Surface — Orbital Dawn canvas */
  --bg-base: #faf7f2;          /* warm cream/pearl floor */
  --bg-tint-hi: #e8eef5;       /* pale dawn sky-blue (top) */
  --bg-tint-mid: #faf7f2;      /* cream (middle) */
  --bg-tint-lo: #f5ebe0;       /* warm sand (bottom) */
  --bg-0: #faf7f2;
  --bg-1: #f3ede4;
  --bg-2: #ebe3d6;
  --bg-3: #ddd2c2;

  /* Glass — opalescent pearl */
  --glass-1: rgba(255, 255, 255, 0.55);
  --glass-2: rgba(255, 255, 255, 0.70);
  --glass-3: rgba(255, 255, 255, 0.86);
  --hairline: rgba(180, 160, 200, 0.15);
  --hairline-strong: rgba(120, 100, 150, 0.22);
  --inner-hi: rgba(255, 255, 255, 0.90);

  /* Text — purple-tinted near-black, never pure black */
  --fg-0: rgb(12, 8, 24);
  --fg-1: rgba(12, 8, 24, 0.88);
  --fg-2: rgba(12, 8, 24, 0.72);
  --fg-3: rgba(12, 8, 24, 0.54);

  /* Brand accents — logo gold, deepened for legibility on light backgrounds */
  --accent: #9a7d2a;                              /* E.T. Cosmo gold (light mode) */
  --accent-soft: rgba(154, 125, 42, 0.55);
  --accent-glow: rgba(154, 125, 42, 0.22);
  --accent-tint: rgba(154, 125, 42, 0.12);
  --accent-edge: rgba(154, 125, 42, 0.30);

  --info: #5eb5db;
  --info-tint: rgba(94, 181, 219, 0.12);
  --info-edge: rgba(94, 181, 219, 0.30);

  --warn: #e89968;                                /* warm coral-gold */
  --warn-tint: rgba(232, 153, 104, 0.14);
  --warn-edge: rgba(232, 153, 104, 0.32);

  --attn: #b794a8;                                /* dusty rose-mauve */
  --attn-tint: rgba(183, 148, 168, 0.14);
  --attn-edge: rgba(183, 148, 168, 0.32);

  --shadow-card:
    0 1px 2px rgba(60, 40, 80, 0.04),
    0 4px 12px rgba(60, 40, 80, 0.06),
    0 16px 48px rgba(60, 40, 80, 0.09);
  --shadow-card-hover:
    0 1px 2px rgba(60, 40, 80, 0.05),
    0 4px 12px rgba(60, 40, 80, 0.08),
    0 24px 64px rgba(60, 40, 80, 0.15);
  --shadow-btn:
    0 1px 2px rgba(60, 40, 80, 0.05),
    0 2px 8px rgba(60, 40, 80, 0.08);
}

[data-theme="light"] html,
[data-theme="light"] body {
  background:
    radial-gradient(900px 700px at 82% 14%, rgba(232, 180, 200, 0.18), transparent 70%),
    radial-gradient(800px 600px at 14% 86%, rgba(180, 200, 230, 0.20), transparent 70%),
    linear-gradient(to bottom,
      var(--bg-tint-hi) 0%,
      var(--bg-tint-mid) 45%,
      var(--bg-tint-lo) 100%);
}

[data-theme="light"] .glass {
  backdrop-filter: blur(32px) saturate(180%);
  -webkit-backdrop-filter: blur(32px) saturate(180%);
  border-top-color: rgba(255, 255, 255, 0.85);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.90),
    var(--shadow-card);
}

[data-theme="light"] .grain { opacity: 0.03; }

* {
  box-sizing: border-box;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

html, body, #app {
  margin: 0;
  padding: 0;
  height: 100%;
  color: var(--fg-0);
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.5;
  letter-spacing: -0.01em;
  font-weight: 400;
  font-feature-settings: "ss01", "cv11";
  overflow: hidden;
}

html, body {
  background:
    radial-gradient(900px 600px at 78% 12%, rgba(201, 168, 76, 0.07), transparent 70%),
    radial-gradient(700px 500px at 12% 88%, rgba(201, 168, 76, 0.04), transparent 70%),
    radial-gradient(140% 110% at 0% 0%,
      var(--bg-tint-hi) 0%,
      var(--bg-base) 45%,
      var(--bg-tint-lo) 100%);
}

@media (min-width: 1280px) {
  html, body, #app { font-size: 19px; }
}

p { line-height: 1.5; }

h1, .h-mega {
  font-family: var(--font-display);
  font-feature-settings: "ss01", "ss02", "cv11";
  letter-spacing: -0.02em;
  font-weight: 600;
}
h2, h3, h4, .h-display {
  font-family: var(--font-body);
  letter-spacing: -0.02em;
  font-weight: 600;
}
strong, b { font-weight: 600; }

button { font-family: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; color: inherit; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--glass-3);
  border-radius: 10px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--hairline-strong); background-clip: content-box; }

/* Aurora — repurposed as the spec radial; previous saturated blobs disabled */
.aurora { display: none; }

/* Star-field — fixed, no twinkle */
.starfield {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    radial-gradient(1px 1px at 13% 8%,  rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 27% 22%, rgba(255,255,255,0.30), transparent 60%),
    radial-gradient(2px 2px at 41% 14%, rgba(255,255,255,0.45), transparent 60%),
    radial-gradient(1px 1px at 56% 31%, rgba(255,255,255,0.20), transparent 60%),
    radial-gradient(1px 1px at 71% 6%,  rgba(255,255,255,0.50), transparent 60%),
    radial-gradient(1px 1px at 84% 19%, rgba(255,255,255,0.25), transparent 60%),
    radial-gradient(2px 2px at 92% 36%, rgba(255,255,255,0.40), transparent 60%),
    radial-gradient(1px 1px at  6% 44%, rgba(255,255,255,0.18), transparent 60%),
    radial-gradient(1px 1px at 19% 58%, rgba(255,255,255,0.32), transparent 60%),
    radial-gradient(2px 2px at 33% 71%, rgba(255,255,255,0.50), transparent 60%),
    radial-gradient(1px 1px at 47% 82%, rgba(255,255,255,0.22), transparent 60%),
    radial-gradient(1px 1px at 61% 65%, rgba(255,255,255,0.42), transparent 60%),
    radial-gradient(1px 1px at 76% 90%, rgba(255,255,255,0.28), transparent 60%),
    radial-gradient(2px 2px at 88% 74%, rgba(255,255,255,0.55), transparent 60%),
    radial-gradient(1px 1px at 96% 60%, rgba(255,255,255,0.20), transparent 60%),
    radial-gradient(1px 1px at  3% 28%, rgba(255,255,255,0.35), transparent 60%),
    radial-gradient(1px 1px at 22% 92%, rgba(255,255,255,0.40), transparent 60%),
    radial-gradient(1px 1px at 38% 38%, rgba(255,255,255,0.15), transparent 60%),
    radial-gradient(2px 2px at 52% 50%, rgba(255,255,255,0.32), transparent 60%),
    radial-gradient(1px 1px at 65% 24%, rgba(255,255,255,0.48), transparent 60%),
    radial-gradient(1px 1px at 80% 52%, rgba(255,255,255,0.22), transparent 60%);
  background-size: 100% 100%;
}
[data-theme="light"] .starfield { display: none; }

/* Material grain — 4% opacity */
.grain {
  position: fixed; inset: 0; pointer-events: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='220' height='220'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/><feColorMatrix values='0 0 0 0 1 0 0 0 0 1 0 0 0 0 1 0 0 0 0.55 0'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
  opacity: 0.04;
  mix-blend-mode: overlay;
  z-index: 1;
}

/* Glass card — Apple translucent material */
.glass {
  background: var(--glass-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-card);
  backdrop-filter: blur(40px) saturate(140%);
  -webkit-backdrop-filter: blur(40px) saturate(140%);
  position: relative;
  box-shadow: var(--shadow-card);
}
/* Inner top-edge highlight — light catching glass */
.glass::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  background: linear-gradient(90deg,
    transparent 0%,
    var(--inner-hi) 25%,
    var(--inner-hi) 75%,
    transparent 100%);
  pointer-events: none;
}

.glass-hover {
  transition: transform 280ms var(--spring),
              border-color 220ms var(--ease),
              background 220ms var(--ease),
              box-shadow 280ms var(--ease);
}
.glass-hover:hover {
  transform: translateY(-2px);
  border-color: var(--hairline-strong);
  background: var(--glass-2);
  box-shadow: var(--shadow-card-hover);
}
.btn:hover, .track-tile:hover { transform: translateY(-2px); }

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r-btn);
  border: 1px solid var(--hairline);
  background: var(--glass-2);
  color: var(--fg-0);
  font-weight: 500;
  font-size: 14px;
  letter-spacing: -0.01em;
  transition: all 220ms var(--spring);
  white-space: nowrap;
  box-shadow: var(--shadow-btn);
}
.btn:hover {
  border-color: var(--hairline-strong);
  background: var(--glass-3);
  transform: translateY(-1px);
}
.btn:active { transform: translateY(0); }
.btn-primary {
  background: var(--accent);
  color: #0b1a10;
  border-color: transparent;
  font-weight: 600;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.18) inset,
    0 1px 2px rgba(0, 0, 0, 0.10),
    0 2px 8px rgba(0, 0, 0, 0.14);
}
[data-theme="light"] .btn-primary { color: #ffffff; }
.btn-primary:hover {
  background: var(--accent);
  filter: brightness(1.05);
  transform: translateY(-1px);
}
.btn-ghost { background: transparent; box-shadow: none; }
.btn-icon {
  width: 36px; height: 36px; padding: 0; justify-content: center;
}
.btn-sm {
  padding: 6px 10px;
  font-size: 12px;
  border-radius: 9px;
  box-shadow: none;
}

/* Inputs */
.input {
  background: var(--glass-1);
  border: 1px solid var(--hairline);
  border-radius: var(--r-input);
  padding: 10px 14px;
  font-size: 14px;
  color: var(--fg-0);
  outline: none;
  transition: border-color 180ms var(--ease), box-shadow 180ms var(--ease);
  width: 100%;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-tint); }

/* Chip — pill, 12px+ radius via 100px */
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 100px;
  font-size: 11px; font-family: var(--font-mono); letter-spacing: 0.02em;
  background: var(--glass-2); border: 1px solid var(--hairline);
  color: var(--fg-1); text-transform: uppercase;
}
.chip-lime { background: var(--accent-tint); border-color: var(--accent-edge); color: var(--accent); }
.chip-amber { background: var(--warn-tint); border-color: var(--warn-edge); color: var(--warn); }
.chip-magenta { background: var(--attn-tint); border-color: var(--attn-edge); color: var(--attn); }
.chip-frost { background: var(--info-tint); border-color: var(--info-edge); color: var(--info); }
.chip-premium {
  background: var(--accent-tint);
  border-color: var(--accent-edge);
  color: var(--accent);
}
.chip-premium-hero {
  background: var(--accent-tint);
  border-color: var(--accent-edge);
  color: var(--fg-0);
}

/* Type utilities */
.mono { font-family: var(--font-mono); font-feature-settings: "tnum","ss01"; letter-spacing: 0; }
.tnum { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.tc { font-family: var(--font-tc); }
.sc { font-family: var(--font-sc); }

.h-display {
  font-weight: 600;
  font-size: 28px;
  letter-spacing: -0.025em;
  line-height: 1.1;
}
.h-mega { font-weight: 500; font-size: 56px; letter-spacing: -0.04em; line-height: 1; }
.eyebrow { font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--fg-2); }
.dim { color: var(--fg-2); }
.dim2 { color: var(--fg-3); }

/* Layout */
.app-shell {
  position: relative;
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: 60px 1fr;
  height: 100vh;
  z-index: 2;
}
.app-shell.collapsed { grid-template-columns: 64px 1fr; }

.topbar {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  border-bottom: 1px solid var(--hairline);
  background: rgba(10, 14, 39, 0.65);
  backdrop-filter: blur(40px) saturate(140%);
  -webkit-backdrop-filter: blur(40px) saturate(140%);
  z-index: 10;
}
[data-theme="light"] .topbar { background: rgba(250, 247, 242, 0.72); }

.sidebar {
  border-right: 1px solid var(--hairline);
  padding: 16px 10px;
  overflow-y: auto;
  background: rgba(10, 14, 39, 0.55);
  backdrop-filter: blur(40px) saturate(140%);
  -webkit-backdrop-filter: blur(40px) saturate(140%);
}
[data-theme="light"] .sidebar { background: rgba(250, 247, 242, 0.6); }

.main { overflow-y: auto; position: relative; scroll-behavior: smooth; }
.main-inner { max-width: 1280px; margin: 0 auto; padding: 32px 40px 80px; }

/* Sidebar nav */
.nav-item {
  display: flex; align-items: center; gap: 12px;
  padding: 9px 12px;
  border-radius: var(--r-btn);
  font-size: 13.5px;
  color: var(--fg-1);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 180ms var(--ease), color 180ms var(--ease), border-color 180ms var(--ease);
  position: relative;
  user-select: none;
}
.nav-item:hover { background: var(--glass-2); color: var(--fg-0); }
.nav-item.active {
  background: var(--glass-2);
  color: var(--fg-0);
  border-color: var(--hairline);
  box-shadow: inset 2px 0 0 0 var(--accent);
  padding-left: 14px;
}
.nav-item .ico { width: 16px; height: 16px; opacity: 0.85; flex-shrink: 0; }
.nav-section { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--fg-3); padding: 14px 12px 6px; }

/* Mode switcher */
.mode-switch {
  display: inline-flex;
  background: var(--glass-2);
  border: 1px solid var(--hairline);
  border-radius: 100px;
  padding: 3px;
  position: relative;
  font-size: 12px;
  font-weight: 500;
}
.mode-switch button {
  padding: 6px 14px;
  border-radius: 100px;
  border: 0;
  background: transparent;
  color: var(--fg-2);
  z-index: 1;
  transition: color 180ms var(--ease);
  font-weight: 500;
}
.mode-switch button.active { color: #0b1a10; }
[data-theme="light"] .mode-switch button.active { color: #ffffff; }
.mode-switch .pill {
  position: absolute;
  top: 3px; bottom: 3px;
  background: var(--accent);
  border-radius: 100px;
  transition: left 320ms var(--spring), width 320ms var(--spring);
  z-index: 0;
  box-shadow: 0 1px 2px rgba(0,0,0,0.10), 0 2px 8px rgba(0,0,0,0.14);
}

/* Goal ring */
.ring-track { stroke: rgba(255,255,255,0.08); }
[data-theme="light"] .ring-track { stroke: rgba(0,0,0,0.06); }
.ring-fill { stroke: var(--accent); transition: stroke-dashoffset 800ms var(--spring); }

/* Streak flame — semantic warn */
.flame {
  display: inline-block;
  filter: drop-shadow(0 0 8px rgba(255, 159, 10, 0.35));
  animation: flicker 2.4s ease-in-out infinite;
  transform-origin: center bottom;
}
@keyframes flicker {
  0%,100% { transform: scale(1) rotate(-1deg); }
  25% { transform: scale(1.05,0.97) rotate(1.5deg); }
  50% { transform: scale(0.97,1.05) rotate(-0.5deg); }
  75% { transform: scale(1.04,1) rotate(1deg); }
}

/* Confetti */
.confetti-piece {
  position: absolute;
  width: 8px; height: 12px;
  pointer-events: none;
  border-radius: 1.5px;
  animation: confetti-fall 2.4s linear forwards;
}
@keyframes confetti-fall {
  0% { transform: translate3d(0,-20px,0) rotate(0); opacity: 1; }
  100% { transform: translate3d(var(--cx,0), 600px, 0) rotate(720deg); opacity: 0; }
}

/* Reveal */
@keyframes rise {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.reveal { animation: rise 520ms var(--spring) both; }
.reveal-1 { animation-delay: 60ms; }
.reveal-2 { animation-delay: 120ms; }
.reveal-3 { animation-delay: 180ms; }
.reveal-4 { animation-delay: 240ms; }
.reveal-5 { animation-delay: 300ms; }
.reveal-6 { animation-delay: 360ms; }
.reveal-7 { animation-delay: 420ms; }
.reveal-8 { animation-delay: 480ms; }

.mode-fade { animation: modefade 180ms var(--spring) both; }
@keyframes modefade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Progress bar — solid green, no glow */
.bar { height: 6px; background: var(--glass-3); border-radius: 100px; overflow: hidden; position: relative; }
.bar > span { display: block; height: 100%; background: var(--accent); border-radius: 100px; transition: width 700ms var(--spring); }
.bar.amber > span { background: var(--warn); }
.bar.magenta > span { background: var(--attn); }

/* Card grid */
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(2,1fr); }
.g3 { grid-template-columns: repeat(3,1fr); }
.g4 { grid-template-columns: repeat(4,1fr); }
.g-dash { grid-template-columns: repeat(12,1fr); }

/* Track tile — desaturated tinted glass with faint top inner glow only */
.track-tile {
  position: relative;
  padding: 24px;
  border-radius: var(--r-card);
  background: var(--glass-1);
  border: 1px solid var(--hairline);
  overflow: hidden;
  cursor: pointer;
  transition: transform 280ms var(--spring), border-color 180ms var(--ease), box-shadow 280ms var(--ease);
  min-height: 200px;
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  box-shadow: var(--shadow-card);
}
/* faint inner glow at top only, no full background fill */
.track-tile::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 60% at 50% -10%, var(--track-glow, transparent), transparent 65%);
  opacity: 0.6;
  pointer-events: none;
}
/* top-edge highlight */
.track-tile::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--inner-hi), transparent);
  pointer-events: none;
}
.track-tile:hover {
  transform: translateY(-2px);
  border-color: var(--hairline-strong);
  box-shadow: var(--shadow-card-hover);
}
/* desaturated track tints (~60% less saturation than the original neon set) */
.track-eng   { --track-glow: rgba(120, 180, 130, 0.22); }
.track-toeic { --track-glow: rgba(180, 130, 150, 0.22); }
.track-ielts { --track-glow: rgba(120, 165, 190, 0.22); }
.track-zh    { --track-glow: rgba(190, 165, 120, 0.22); }

/* Skill tree node */
.node {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--glass-2);
  border: 1px solid var(--hairline);
  position: relative;
  cursor: pointer;
  transition: transform 240ms var(--spring), border-color 180ms var(--ease);
}
.node:hover { transform: scale(1.06); }
.node.done {
  background: var(--accent-tint);
  border-color: var(--accent-edge);
  color: var(--accent);
}
.node.current {
  border-color: var(--accent);
  animation: pulse 1.8s ease-in-out infinite;
}
.node.locked { opacity: 0.45; cursor: not-allowed; }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 0 0 var(--accent-glow); }
  50% { box-shadow: 0 0 0 10px transparent; }
}

/* Flashcard */
.flip { perspective: 1200px; width: 100%; height: 360px; }
.flip-inner {
  width: 100%; height: 100%;
  transition: transform 700ms var(--spring);
  transform-style: preserve-3d;
  position: relative;
}
.flip.flipped .flip-inner { transform: rotateY(180deg); }
.flip-face {
  position: absolute; inset: 0;
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
  display: flex; align-items: center; justify-content: center; flex-direction: column;
  padding: 32px;
  border-radius: var(--r-card);
  border: 1px solid var(--hairline-strong);
  background: var(--glass-2);
  text-align: center;
  box-shadow: var(--shadow-card);
}
.flip-back { transform: rotateY(180deg); background: var(--glass-3); }

/* Shake / flash */
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
.shake { animation: shake 320ms ease-in-out; }
.flash-good { animation: flashG 600ms ease-out; }
.flash-bad { animation: flashB 600ms ease-out; }
@keyframes flashG { 0% { background: rgba(48, 209, 88, 0.22); } 100% { background: transparent; } }
@keyframes flashB { 0% { background: rgba(255, 55, 95, 0.22); } 100% { background: transparent; } }

/* Quest celebration sparks */
.quests-celebrate { position: relative; }
.spark-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.spark-layer .spark {
  position: absolute; top: -8px; left: var(--sx);
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--sc); box-shadow: 0 0 8px var(--sc);
  animation: sparkfall var(--sd) linear var(--ss) infinite;
  opacity: 0;
}
@keyframes sparkfall {
  0% { transform: translateY(-10px) scale(0.8); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translateY(180px) scale(1); opacity: 0; }
}

/* Streak pulse — warn color */
.streak-today { animation: streakpulse 2s ease-in-out infinite; }
@keyframes streakpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(255, 159, 10, 0.45); }
  50% { box-shadow: 0 0 0 6px rgba(255, 159, 10, 0); }
}

/* Modal */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  animation: fadein 200ms var(--ease);
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
.modal {
  width: 100%; max-width: 520px;
  background: var(--glass-1);
  border: 1px solid var(--hairline-strong);
  border-radius: var(--r-modal);
  padding: 32px;
  position: relative;
  animation: pop 320ms var(--spring) both;
  box-shadow: var(--shadow-modal);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}
@keyframes pop { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
.modal { animation-duration: 200ms; }
.modal::before {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 1px;
  border-top-left-radius: inherit;
  border-top-right-radius: inherit;
  background: linear-gradient(90deg, transparent, var(--inner-hi), transparent);
  pointer-events: none;
}

/* Avatar */
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--info), var(--accent));
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 12px; color: #fff;
  flex-shrink: 0;
  border: 1.5px solid var(--bg-1);
}
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; border-width: 1.5px; }

/* League — desaturated metallic glass */
.league-bronze   { background: linear-gradient(135deg, #b08763, #6f4d2e); color: #fff; }
.league-silver   { background: linear-gradient(135deg, #c8cdd5, #8a8f97); color: #1c1c1e; }
.league-gold     { background: linear-gradient(135deg, #f4d27a, #c08a2a); color: #1c1c1e; }
.league-diamond  { background: linear-gradient(135deg, #6ab8d8, #b794a8); color: #1c1c1e; }
.league-obsidian { background: linear-gradient(135deg, #2a2a2d, #1c1c1e); color: var(--attn); border: 1px solid var(--attn-edge); }

/* Sparkline */
.spark { display: block; width: 100%; height: 36px; }

/* Mic */
.mic-btn {
  width: 140px; height: 140px;
  border-radius: 50%;
  background: var(--accent);
  color: #0b1a10;
  border: none;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: transform 220ms var(--spring);
  position: relative;
  box-shadow: var(--shadow-card);
}
[data-theme="light"] .mic-btn { color: #fff; }
.mic-btn::before, .mic-btn::after {
  content: ""; position: absolute; inset: 0;
  border-radius: 50%;
  border: 1px solid var(--accent);
  pointer-events: none;
}
.mic-btn.listening::before { animation: ripple 1.6s ease-out infinite; }
.mic-btn.listening::after { animation: ripple 1.6s ease-out 0.8s infinite; }
@keyframes ripple {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Toast */
.toast-stack { position: fixed; bottom: 24px; right: 24px; display: flex; flex-direction: column; gap: 8px; z-index: 200; }
.toast {
  background: var(--glass-1);
  border: 1px solid var(--hairline-strong);
  padding: 12px 16px;
  border-radius: var(--r-btn);
  min-width: 220px;
  font-size: 13px; display: flex; gap: 10px; align-items: center;
  animation: pop 320ms var(--spring) both;
  box-shadow: var(--shadow-card);
  backdrop-filter: blur(40px) saturate(180%);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
}

/* Mobile */
@media (max-width: 768px) {
  .app-shell { grid-template-columns: 1fr; grid-template-rows: 56px 1fr 60px; }
  .sidebar {
    position: fixed; bottom: 0; left: 0; right: 0;
    width: 100%; height: 60px;
    border-right: none; border-top: 1px solid var(--hairline);
    padding: 8px;
    display: flex; flex-direction: row; gap: 4px;
    overflow-x: auto;
    z-index: 5;
    background: rgba(28, 28, 30, 0.92);
  }
  [data-theme="light"] .sidebar { background: rgba(250, 247, 242, 0.94); }
  .sidebar .nav-section { display: none; }
  /* Sidebar premium card not visible on mobile bottom nav */
  .sidebar .glass { display: none; }
  .nav-item {
    padding: 8px; flex-direction: column; gap: 2px;
    font-size: 10px; min-width: 52px; flex: 1;
    text-align: center; border-radius: 10px;
  }
  .nav-item .nav-label { font-size: 9px; }
  /* Active indicator: top border for horizontal bottom nav */
  .nav-item.active {
    box-shadow: inset 0 3px 0 0 var(--accent);
    padding-left: 8px;
  }
  .main-inner { padding: 16px 16px 80px; }
  .g-dash { grid-template-columns: 1fr; }
  .g-dash > * { grid-column: 1 / -1 !important; }
  .g2, .g3, .g4 { grid-template-columns: 1fr; }
  .h-mega { font-size: 40px; }
  .topbar { padding: 0 12px; gap: 8px; }
  /* Topbar: remove ghost flex space from hidden search */
  .topbar .search-wrap { display: none; }
  .topbar .search-input { display: none; }
  /* Hide hamburger (useless on mobile — sidebar is the bottom tab bar) */
  .topbar .sidebar-toggle { display: none; }
  /* Hide mode switch to prevent topbar overflow — use profile/settings instead */
  .topbar .mode-switch { display: none; }
  /* Fix quests grid: 1 column on mobile */
  .quests-grid { grid-template-columns: 1fr !important; }
  /* Lesson iframe: subtract topbar + bottom nav + back-button row */
  .lesson-frame { height: calc(100svh - 176px) !important; border-radius: 12px !important; }
  /* Skill tree: disable zigzag offset so nodes don't overflow */
  .tree-zigzag-offset { display: none !important; }
  /* Skill tree label: allow wrapping on small screens */
  .tree-node-label { min-width: 0 !important; }
  /* Toast stack: full-width on mobile */
  .toast-stack { right: 12px; left: 12px; bottom: 76px; }
  .toast { min-width: 0; }
  /* Flip card: shorter height on mobile */
  .flip { height: 280px; }
}

/* Help misc */
.divider { height: 1px; background: var(--hairline); margin: 16px 0; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.spread { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gap-sm { gap: 8px; }
.gap-md { gap: 14px; }
.gap-lg { gap: 24px; }

.placeholder-img {
  background: repeating-linear-gradient(45deg, var(--glass-2) 0 8px, var(--glass-1) 8px 16px);
  border-radius: var(--r-md);
  border: 1px solid var(--hairline);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: 10px; color: var(--fg-3); text-transform: uppercase; letter-spacing: 0.1em;
}

.scroll-x { display: flex; gap: 12px; overflow-x: auto; padding-bottom: 6px; }
.scroll-x::-webkit-scrollbar { height: 6px; }

/* Skill tree connectors */
.tree-row { display: flex; align-items: center; justify-content: center; gap: 18px; position: relative; }
.tree-conn {
  width: 2px; height: 28px; background: var(--hairline);
  margin: 0 auto;
}
.tree-conn.done { background: var(--accent); }
