/* ==========================================================================
   Pasado — styles
   Mobile-first. Bottom tab bar on phones, sidebar from 900px up.
   ========================================================================== */

:root {
  --bg: #f5f7fc;
  --surface: #ffffff;
  --surface-2: #eff2f9;
  --surface-3: #e6eaf4;
  --border: #e1e6f0;
  --text: #141a2e;
  --muted: #5d667c;
  --faint: #8b93a7;

  --primary: #2547d0;
  --primary-2: #3559e6;
  --primary-ink: #ffffff;
  --primary-soft: #e8edff;
  --accent: #f5b301;
  --accent-soft: #fff4d1;

  --good: #12924a;
  --good-soft: #e2f5ea;
  --bad: #d23838;
  --bad-soft: #fde9e9;
  --warn: #c76a00;
  --warn-soft: #fff1dc;

  --c-verbal: #6d55d6;
  --c-numerical: #0d8f84;
  --c-analytical: #d4780a;
  --c-general: #d2386a;

  --radius: 20px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .04), 0 8px 24px -10px rgba(16, 24, 40, .10);
  --shadow-hover: 0 2px 4px rgba(16, 24, 40, .05), 0 16px 32px -12px rgba(37, 71, 208, .22);
  --shadow-lg: 0 10px 40px rgba(16, 24, 40, .18);
  --grad: linear-gradient(135deg, #2547d0 0%, #3b5cf0 50%, #6a45e0 100%);
  --grad-warm: linear-gradient(135deg, #f5b301, #ff8a3d);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --tabbar-h: 66px;
  --topbar-h: 60px;
  --font: "Plus Jakarta Sans", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d111d;
    --surface: #151a2b;
    --surface-2: #1b2136;
    --surface-3: #242b44;
    --border: #283050;
    --text: #e9ecf6;
    --muted: #a0a9c2;
    --faint: #7a839c;
    --primary: #7090ff;
    --primary-2: #87a2ff;
    --primary-ink: #0d111d;
    --primary-soft: #1f2a52;
    --accent-soft: #3a3014;
    --good: #3ccf7c;
    --good-soft: #143525;
    --bad: #ff6b6b;
    --bad-soft: #3d1a1d;
    --warn: #ffab40;
    --warn-soft: #3a2a12;
    --c-verbal: #9d8bff;
    --c-numerical: #2fc9b9;
    --c-analytical: #f5a43a;
    --c-general: #ff6f9c;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
    --shadow-hover: 0 2px 4px rgba(0, 0, 0, .3), 0 16px 32px -12px rgba(112, 144, 255, .25);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d111d;
  --surface: #151a2b;
  --surface-2: #1b2136;
  --surface-3: #242b44;
  --border: #283050;
  --text: #e9ecf6;
  --muted: #a0a9c2;
  --faint: #7a839c;
  --primary: #7090ff;
  --primary-2: #87a2ff;
  --primary-ink: #0d111d;
  --primary-soft: #1f2a52;
  --accent-soft: #3a3014;
  --good: #3ccf7c;
  --good-soft: #143525;
  --bad: #ff6b6b;
  --bad-soft: #3d1a1d;
  --warn: #ffab40;
  --warn-soft: #3a2a12;
  --c-verbal: #9d8bff;
  --c-numerical: #2fc9b9;
  --c-analytical: #f5a43a;
  --c-general: #ff6f9c;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 24px -10px rgba(0, 0, 0, .5);
  --shadow-hover: 0 2px 4px rgba(0, 0, 0, .3), 0 16px 32px -12px rgba(112, 144, 255, .25);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  background:
    radial-gradient(900px 480px at 0% -10%, color-mix(in srgb, var(--primary) 9%, transparent), transparent 70%),
    radial-gradient(700px 420px at 100% 0%, color-mix(in srgb, #6a45e0 7%, transparent), transparent 70%);
}
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
a { color: var(--primary); text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
/* Instant taps on phones: no double-tap-zoom delay on controls */
a, button, input, select, textarea, label, .choice, .flashcard, .cal-day { touch-action: manipulation; }
img { max-width: 100%; }
h1, h2, h3, h4 { line-height: 1.25; margin: 0 0 .5em; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 800; }
h2 { font-size: 1.25rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 700; }
p { margin: 0 0 .8em; }
.muted { color: var(--muted); }
.small { font-size: .875rem; }
.tiny { font-size: .78rem; }
.center { text-align: center; }
.hidden { display: none !important; }
.only-desktop { display: none; }
@media (min-width: 900px) { .only-desktop { display: block; } }
:focus-visible { outline: 3px solid var(--primary); outline-offset: 2px; border-radius: 6px; }

/* ---------- Layout ---------- */
.app { min-height: 100vh; min-height: 100dvh; }
.sidebar { display: none; }
.main { min-width: 0; }
.view {
  padding: 16px 16px calc(var(--tabbar-h) + 28px + env(safe-area-inset-bottom));
  max-width: 1100px;
  margin: 0 auto;
  outline: none;
}

.topbar {
  position: sticky; top: 0; z-index: 30;
  height: calc(var(--topbar-h) + env(safe-area-inset-top));
  padding: env(safe-area-inset-top) 12px 0 16px;
  display: flex; align-items: center; gap: 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid transparent;
  transition: border-color .2s;
}
.topbar.scrolled { border-bottom-color: var(--border); }
.brand { display: flex; align-items: center; gap: 10px; color: var(--text); }
.brand img { border-radius: 9px; display: block; }
.brand strong { font-weight: 800; font-size: 1.02rem; }
.brand small { display: block; font-size: .72rem; color: var(--muted); font-weight: 600; }
.brand span { line-height: 1.15; }
.topbar-title { display: none; font-weight: 800; font-size: 1.1rem; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 6px; }

.level-chip, .streak-chip {
  display: inline-flex; align-items: center; gap: 5px;
  height: 34px; padding: 0 12px; border-radius: 999px;
  font-weight: 700; font-size: .82rem; border: 1px solid var(--border);
  background: var(--surface); white-space: nowrap;
}
.level-chip { color: var(--primary); }
.streak-chip { color: var(--warn); }
.streak-chip.cold { color: var(--faint); }
.icon-btn {
  width: 38px; height: 38px; display: inline-grid; place-items: center;
  border-radius: 12px; border: 0; background: transparent; color: var(--muted);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn svg, .tabbar svg, .side-nav svg { width: 22px; height: 22px; }

/* Bottom tab bar (phones & small tablets) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-top: 1px solid var(--border);
}
.tabbar a {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); font-size: .7rem; font-weight: 700; position: relative;
}
.tabbar a.active { color: var(--primary); }
.tabbar a::before {
  content: ""; position: absolute; top: 8px; left: 50%; width: 56px; height: 30px; margin-left: -28px; border-radius: 999px;
  background: var(--primary-soft); transform: scaleX(.4); opacity: 0; transition: transform .3s var(--ease), opacity .2s;
}
.tabbar a.active::before { transform: none; opacity: 1; }
.tabbar a svg, .tabbar a span { position: relative; }
.tabbar a.active svg { animation: tabPop .35s var(--ease); }
.tabbar .badge-dot {
  position: absolute; top: 9px; right: calc(50% - 18px);
  width: 9px; height: 9px; border-radius: 50%; background: var(--bad); border: 2px solid var(--surface);
}

@media (min-width: 900px) {
  .app { display: grid; grid-template-columns: 250px minmax(0, 1fr); }
  .sidebar {
    display: flex; flex-direction: column; gap: 14px;
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    padding: 20px 12px 16px; border-right: 1px solid var(--border);
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary-soft) 35%, var(--surface)), var(--surface) 240px);
    /* Still scrolls (wheel, trackpad, keyboard) on very short screens, but without a visible bar */
    overflow-y: auto; scrollbar-width: none; overscroll-behavior: contain;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar .brand { padding: 0 8px 4px; }
  .sidebar .brand strong { white-space: nowrap; }
  .sidebar .brand small { display: flex; align-items: center; gap: 6px; }
  .sidebar .brand .beta-tag { margin-left: 0; vertical-align: 0; }
  .side-nav { display: flex; flex-direction: column; gap: 1px; }
  .side-nav .nav-head {
    padding: 12px 12px 5px; font-size: .68rem; font-weight: 800; letter-spacing: .09em;
    text-transform: uppercase; color: var(--faint);
  }
  .side-nav .nav-head:first-child { padding-top: 2px; }
  .side-nav a {
    display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 12px;
    color: var(--muted); font-weight: 600; font-size: .93rem; position: relative;
    transition: background .15s, color .15s;
  }
  .side-nav a svg { width: 20px; height: 20px; flex: none; transition: transform .2s var(--ease); }
  .side-nav a:hover { background: var(--surface-2); color: var(--text); }
  .side-nav a:hover svg { transform: translateX(2px); }
  .side-nav a.active { background: var(--primary-soft); color: var(--primary); font-weight: 700; }
  .side-nav a.active::before { content: ""; position: absolute; left: -12px; top: 8px; bottom: 8px; width: 4px; border-radius: 0 4px 4px 0; background: var(--grad); }
  .side-nav a.nav-heart svg { color: #e5486b; }
  .side-nav a.nav-heart:hover svg { animation: heartBeat 1s var(--ease); transform: none; }
  .side-nav .badge-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 3px color-mix(in srgb, var(--bad) 18%, transparent); }
  .side-foot { margin-top: auto; padding-top: 4px; }
  .side-foot .list-item { padding: 10px; border: 1px solid var(--border); }
  /* Shorter laptop screens: tighter rows so everything fits without scrolling */
  @media (max-height: 880px) {
    .sidebar { gap: 10px; padding-top: 16px; }
    .side-nav a { padding: 7px 12px; }
    .side-nav a.active::before { top: 7px; bottom: 7px; }
    .side-nav .nav-head { padding-top: 8px; padding-bottom: 3px; }
  }
  @media (max-height: 740px) {
    .side-nav a { padding: 5px 12px; font-size: .9rem; }
    .side-foot .grow > .tiny, .side-foot .grow > br:has(+ .tiny) { display: none; }
  }
  .tabbar, .brand-mobile, .only-mobile { display: none !important; }
  .topbar { padding-left: 28px; padding-right: 24px; }
  .topbar-title { display: block; }
  .view { padding: 24px 28px 60px; }
}

/* ---------- Generic components ---------- */
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.card.flat { box-shadow: none; }
@media (hover: hover) {
  a.card, a.list-item, .mini-topic { transition: transform .18s var(--ease), box-shadow .18s, background .15s; }
  a.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-hover); }
  a.list-item:hover { background: color-mix(in srgb, var(--primary-soft) 55%, var(--surface-2)); }
  .mini-topic:hover { transform: translateY(-2px); }
}
.card + .card { margin-top: 14px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-title h2, .card-title h3 { margin: 0; }
.section { margin-top: 26px; }
.section-head { display: flex; align-items: end; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.section-head h2 { margin: 0; }
.grid { display: grid; gap: 14px; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-4 { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (min-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(4, 1fr); }
}

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 46px; padding: 0 20px; border-radius: 14px; border: 1px solid transparent;
  font-weight: 700; font-size: .95rem; background: var(--surface-2); color: var(--text);
  transition: transform .08s ease, background .15s, box-shadow .15s; text-align: center;
  user-select: none; -webkit-user-select: none;
}
.btn:active { transform: scale(.97); }
.btn svg { width: 19px; height: 19px; }
.btn-primary { background: var(--primary); background-image: linear-gradient(180deg, var(--primary-2), var(--primary)); color: var(--primary-ink); box-shadow: 0 4px 0 color-mix(in srgb, var(--primary) 60%, #000); }
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { box-shadow: 0 1px 0 color-mix(in srgb, var(--primary) 60%, #000); transform: translateY(3px); }
.btn-good { background: var(--good); color: #fff; box-shadow: 0 4px 0 color-mix(in srgb, var(--good) 60%, #000); }
.btn-good:active { box-shadow: none; transform: translateY(3px); }
.btn-bad { background: var(--bad); color: #fff; }
.btn-outline { background: transparent; border-color: var(--border); }
.btn-outline:hover { background: var(--surface-2); }
.btn-ghost { background: transparent; color: var(--primary); }
.btn-ghost:hover { background: var(--primary-soft); }
.btn-sm { min-height: 36px; padding: 0 14px; font-size: .85rem; border-radius: 11px; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; pointer-events: none; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 10px; border-radius: 999px;
  font-size: .75rem; font-weight: 700; background: var(--surface-2); color: var(--muted); white-space: nowrap;
}
.pill.pro { background: var(--primary-soft); color: var(--primary); }
.pill.sub { background: var(--accent-soft); color: var(--warn); }
.pill.good { background: var(--good-soft); color: var(--good); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }

.progress { height: 8px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress > span { display: block; height: 100%; border-radius: inherit; background: var(--primary); transition: width .5s ease; }

.segmented {
  display: inline-grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  background: var(--surface-2); border-radius: 14px; padding: 4px; gap: 4px; width: 100%;
}
.segmented button {
  border: 0; background: transparent; border-radius: 10px; padding: 9px 10px; font-weight: 700;
  color: var(--muted); font-size: .9rem;
}
.segmented button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }

.field { display: flex; flex-direction: column; gap: 6px; margin-bottom: 14px; }
.field label { font-weight: 700; font-size: .88rem; }
.input, select.input, textarea.input {
  width: 100%; min-height: 46px; padding: 10px 14px; border-radius: 12px;
  border: 1.5px solid var(--border); background: var(--surface); font-size: 1rem;
}
textarea.input { min-height: 90px; resize: vertical; }
.input:focus { border-color: var(--primary); outline: none; box-shadow: 0 0 0 3px var(--primary-soft); }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.empty { text-align: center; padding: 30px 16px; color: var(--muted); }
.empty .big { font-size: 2.4rem; margin-bottom: 6px; }

.page-head { margin-bottom: 18px; }
.page-head h1 { margin-bottom: 4px; }
.back-link { display: inline-flex; align-items: center; gap: 4px; font-weight: 700; font-size: .9rem; margin-bottom: 10px; }
.back-link svg { width: 18px; height: 18px; }

/* ---------- Home ---------- */
.hero {
  position: relative; overflow: hidden;
  background: var(--grad);
  color: #fff; border-radius: 24px; padding: 24px 22px; box-shadow: 0 18px 40px -18px rgba(37, 71, 208, .6);
}
.hero::before, .hero::after { content: ""; position: absolute; border-radius: 50%; pointer-events: none; }
.hero::after {
  right: -60px; top: -70px; width: 240px; height: 240px;
  background: radial-gradient(circle, rgba(255,255,255,.22), transparent 70%);
  animation: floatA 14s ease-in-out infinite;
}
.hero::before {
  left: 35%; bottom: -110px; width: 260px; height: 260px;
  background: radial-gradient(circle, rgba(245,179,1,.28), transparent 70%);
  animation: floatB 18s ease-in-out infinite;
}
.hero h1, .hero p { position: relative; z-index: 1; }
.hero h1 { font-size: 1.45rem; margin-bottom: 4px; }
.hero p { opacity: .9; margin: 0; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 18px; position: relative; z-index: 1; max-width: 460px; }
.hero-stat { background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.16); border-radius: 14px; padding: 10px 12px; min-width: 0; }
.hero-stat b { display: block; font-size: 1.15rem; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 400px) { .brand-mobile strong { display: none; } }
.hero-stat span { font-size: .75rem; opacity: .85; font-weight: 600; }
.hero .btn { position: relative; z-index: 1; }
.hero-cta { margin-top: 18px; display: flex; gap: 10px; flex-wrap: wrap; }
.hero .btn-primary { background: #fff; color: #2547d0; box-shadow: 0 4px 0 rgba(0,0,0,.2); }
.hero .btn-outline { color: #fff; border-color: rgba(255,255,255,.4); }
.hero .btn-outline:hover { background: rgba(255,255,255,.12); }

.home-grid { display: grid; gap: 14px; margin-top: 14px; }
.home-grid > .grid { min-width: 0; }
@media (min-width: 1000px) { .home-grid { grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); align-items: start; } }

.goal-ring { position: relative; width: 74px; height: 74px; flex: none; }
.goal-ring svg { width: 74px; height: 74px; transform: rotate(-90deg); }
.goal-ring .val { position: absolute; inset: 0; display: grid; place-items: center; font-weight: 800; font-size: .9rem; }
.goal-row { display: flex; align-items: center; gap: 16px; }

.countdown { display: flex; gap: 8px; margin-top: 8px; }
.countdown div { flex: 1; text-align: center; background: var(--surface-2); border-radius: 12px; padding: 8px 4px; }
.countdown b { display: block; font-size: 1.35rem; line-height: 1.1; }
.countdown span { font-size: .72rem; color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }

.goal-row > div { min-width: 0; }
.week-strip { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; margin-top: 10px; }
.week-strip div { text-align: center; font-size: .72rem; color: var(--muted); font-weight: 700; }
.week-strip i {
  display: grid; place-items: center; margin: 4px auto 0; width: 100%; max-width: 30px; aspect-ratio: 1; border-radius: 50%;
  background: var(--surface-2); font-style: normal; font-size: .85rem;
}
.week-strip i.on { background: var(--accent); color: #3a2a00; }
.week-strip i.today { box-shadow: 0 0 0 2px var(--primary); }

.list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: 14px;
  background: var(--surface-2); color: var(--text);
}
.list-item .grow { flex: 1; min-width: 0; }
.list-item > svg { width: 22px; height: 22px; flex: none; }
.list-item .title { font-weight: 700; font-size: .95rem; }
.list-item .sub { font-size: .8rem; color: var(--muted); }
.dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }

/* Topic cards */
.topic-card {
  position: relative; display: flex; flex-direction: column; gap: 10px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 16px; box-shadow: var(--shadow); transition: transform .15s, box-shadow .15s; overflow: hidden;
}
a.topic-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }
.topic-card .t-icon {
  width: 46px; height: 46px; border-radius: 14px; display: grid; place-items: center; font-size: 1.45rem;
  background: color-mix(in srgb, var(--tc) 14%, transparent);
}
.topic-card h3 { margin: 0; }
.topic-card .progress > span { background: var(--tc); }
.topic-card .meta { display: flex; justify-content: space-between; font-size: .78rem; color: var(--muted); font-weight: 600; }
.topic-card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--tc); }
.tc-verbal { --tc: var(--c-verbal); }
.tc-numerical { --tc: var(--c-numerical); }
.tc-analytical { --tc: var(--c-analytical); }
.tc-general { --tc: var(--c-general); }

.mini-topics { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.mini-topic { padding: 12px; border-radius: 14px; background: var(--surface-2); }
.mini-topic .lbl { display: flex; align-items: center; gap: 6px; font-weight: 700; font-size: .82rem; margin-bottom: 8px; }
.mini-topic .progress > span { background: var(--tc); }
.mini-topic .pct { font-size: .75rem; color: var(--muted); margin-top: 4px; font-weight: 600; }

/* ---------- Learn ---------- */
.lesson-list { display: flex; flex-direction: column; gap: 10px; }
.lesson-row {
  display: flex; align-items: center; gap: 14px; padding: 14px 16px; border-radius: 16px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text); transition: border-color .15s, transform .15s;
}
.lesson-row:hover { border-color: var(--tc); transform: translateX(2px); }
.lesson-row .num {
  width: 38px; height: 38px; flex: none; border-radius: 50%; display: grid; place-items: center; font-weight: 800;
  background: color-mix(in srgb, var(--tc) 14%, transparent); color: var(--tc);
}
.lesson-row.done .num { background: var(--good); color: #fff; }
.lesson-row .grow { flex: 1; min-width: 0; }
.lesson-row .title { font-weight: 700; }
.lesson-row .sub { font-size: .82rem; color: var(--muted); }
.lesson-row .chev { color: var(--faint); }
.lesson-row.locked { opacity: .5; }

.topic-banner {
  border-radius: 22px; padding: 20px; color: #fff; position: relative; overflow: hidden;
  background: linear-gradient(135deg, var(--tc), color-mix(in srgb, var(--tc) 70%, #000));
}
.topic-banner h1 { margin: 6px 0 4px; }
.topic-banner p { opacity: .92; margin: 0; }
.topic-banner .t-emoji { font-size: 2rem; }
.topic-banner .btn-row { margin-top: 16px; }
.topic-banner .btn { background: rgba(255,255,255,.18); color: #fff; }
.topic-banner .btn:hover { background: rgba(255,255,255,.28); }

/* Lesson reader */
.reader { max-width: 760px; margin: 0 auto; }
.reader-progress { position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 20; height: 4px; background: var(--surface-3); margin: -16px -16px 16px; }
.reader-progress span { display: block; height: 100%; width: 0; background: var(--tc, var(--primary)); transition: width .1s; }
@media (min-width: 900px) { .reader-progress { margin: -24px -28px 20px; } }
.reader h1 { font-size: 1.55rem; }
.block { margin: 16px 0; }
.block-text p:last-child { margin-bottom: 0; }
.block h2.lesson-h { font-size: 1.2rem; margin-top: 28px; padding-top: 4px; }
.hl { background: var(--accent-soft); padding: 0 4px; border-radius: 4px; font-weight: 600; }
.callout { border-radius: 16px; padding: 14px 16px; display: flex; gap: 12px; }
.callout .ic { font-size: 1.25rem; line-height: 1.3; }
.callout p:last-child, .callout ul:last-child { margin-bottom: 0; }
.callout.tip { background: var(--good-soft); }
.callout.warn { background: var(--warn-soft); }
.callout b.lbl { display: block; font-size: .78rem; text-transform: uppercase; letter-spacing: .05em; margin-bottom: 2px; }
.callout.tip b.lbl { color: var(--good); }
.callout.warn b.lbl { color: var(--warn); }
.keypoints { border: 2px solid var(--primary-soft); background: color-mix(in srgb, var(--primary-soft) 45%, var(--surface)); border-radius: 16px; padding: 16px; }
.keypoints h3 { color: var(--primary); display: flex; gap: 8px; align-items: center; }
.keypoints ul { margin: 0; padding-left: 20px; }
.keypoints li { margin-bottom: 6px; }
.table-wrap { overflow-x: auto; border-radius: 14px; border: 1px solid var(--border); -webkit-overflow-scrolling: touch; }
table.tbl { width: 100%; border-collapse: collapse; font-size: .9rem; min-width: 420px; }
table.tbl th { background: var(--surface-2); text-align: left; padding: 10px 12px; font-weight: 700; white-space: nowrap; }
table.tbl td { padding: 10px 12px; border-top: 1px solid var(--border); vertical-align: top; }

.interactive { border-radius: 18px; border: 1.5px solid var(--border); background: var(--surface); overflow: hidden; }
.interactive-head {
  display: flex; align-items: center; gap: 8px; padding: 10px 16px; font-weight: 800; font-size: .78rem;
  text-transform: uppercase; letter-spacing: .06em; background: var(--surface-2); color: var(--muted);
}
.interactive-body { padding: 16px; }
.step { padding: 10px 0 10px 16px; border-left: 3px solid var(--primary); margin: 8px 0; animation: fadeUp .3s ease; }
.step-answer { background: var(--good-soft); border-radius: 12px; padding: 12px 14px; margin-top: 10px; animation: fadeUp .3s ease; }

/* Choices (shared by checks & quizzes) */
.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.choice {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 13px 14px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface);
  font-size: .98rem; font-weight: 500; transition: border-color .12s, background .12s, transform .08s;
  box-shadow: 0 2px 0 var(--border);
}
.choice:hover:not(:disabled) { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); background: var(--surface-2); }
.choice:active:not(:disabled) { transform: translateY(2px); box-shadow: none; }
.choice .key {
  width: 30px; height: 30px; flex: none; border-radius: 9px; display: grid; place-items: center;
  font-weight: 800; font-size: .85rem; border: 2px solid var(--border); color: var(--muted);
}
.choice.selected { border-color: var(--primary); background: var(--primary-soft); box-shadow: 0 2px 0 var(--primary); }
.choice.selected .key { border-color: var(--primary); background: var(--primary); color: var(--primary-ink); }
.choice.correct { border-color: var(--good); background: var(--good-soft); box-shadow: 0 2px 0 var(--good); animation: pop .35s var(--ease); }
.choice.correct .key { background: var(--good); border-color: var(--good); color: #fff; }
.choice.wrong { border-color: var(--bad); background: var(--bad-soft); box-shadow: 0 2px 0 var(--bad); animation: shake .35s; }
.choice.wrong .key { background: var(--bad); border-color: var(--bad); color: #fff; }
.choice:disabled { cursor: default; }
.choice.dim { opacity: .55; }

.feedback { margin-top: 14px; border-radius: 14px; padding: 14px 16px; animation: fadeUp .25s ease; }
.feedback.good { background: var(--good-soft); }
.feedback.bad { background: var(--bad-soft); }
.feedback .fb-title { font-weight: 800; margin-bottom: 4px; display: flex; align-items: center; gap: 6px; }
.feedback.good .fb-title { color: var(--good); }
.feedback.bad .fb-title { color: var(--bad); }
.feedback p:last-child { margin: 0; }

/* Flashcards */
.flash-wrap { perspective: 1200px; }
.flashcard {
  position: relative; height: 210px; transform-style: preserve-3d; transition: transform .5s cubic-bezier(.2,.8,.2,1);
  cursor: pointer; user-select: none; -webkit-user-select: none;
}
.flashcard.flipped { transform: rotateY(180deg); }
.flash-face {
  position: absolute; inset: 0; border-radius: 18px; display: grid; place-items: center; text-align: center;
  padding: 20px; backface-visibility: hidden; -webkit-backface-visibility: hidden; font-weight: 700; font-size: 1.15rem;
  background: var(--primary-soft); color: var(--text); border: 2px solid color-mix(in srgb, var(--primary) 30%, transparent);
}
.flash-face.back { transform: rotateY(180deg); background: var(--surface-2); font-weight: 500; font-size: 1rem; }
.flash-face small { position: absolute; bottom: 10px; left: 0; right: 0; font-size: .72rem; color: var(--muted); font-weight: 600; }
.flash-nav { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 12px; }
.flash-count { font-weight: 700; color: var(--muted); font-size: .85rem; }

/* Order (tap in sequence) */
.order-pool, .order-picked { display: flex; flex-direction: column; gap: 8px; }
.order-picked { min-height: 48px; padding: 10px; border-radius: 14px; border: 2px dashed var(--border); margin-bottom: 12px; }
.order-picked:empty::before { content: "Tap the items below in the correct order"; color: var(--faint); font-size: .88rem; text-align: center; padding: 4px; }
.order-item {
  text-align: left; padding: 11px 14px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface);
  font-size: .95rem; display: flex; gap: 10px; align-items: flex-start; animation: fadeUp .2s ease;
}
.order-item .n { font-weight: 800; color: var(--primary); min-width: 18px; }
.order-picked .order-item { border-color: var(--primary); background: var(--primary-soft); }
.order-item.correct { border-color: var(--good); background: var(--good-soft); }
.order-item.wrong { border-color: var(--bad); background: var(--bad-soft); }

.fill-row { display: flex; gap: 10px; margin-top: 12px; }
.fill-row .input { flex: 1; }

/* ---------- Quiz player ---------- */
.quiz-shell { max-width: 720px; margin: 0 auto; }
.quiz-top { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.quiz-top .progress { flex: 1; height: 12px; }
.quiz-top .progress > span { background: linear-gradient(90deg, var(--good), color-mix(in srgb, var(--good) 70%, #fff)); }
.combo { font-weight: 800; color: var(--warn); font-size: .9rem; white-space: nowrap; min-width: 52px; text-align: right; }
.q-meta { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.q-text { font-size: 1.08rem; font-weight: 600; }
.q-text p { margin-bottom: .6em; }
.q-text em { font-weight: 400; }
.quiz-foot {
  position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 10px);
  margin-top: 16px; z-index: 5;
}
@media (min-width: 900px) { .quiz-foot { bottom: 16px; } }

.result-hero { text-align: center; padding: 28px 18px; }
.score-ring { width: 150px; height: 150px; margin: 0 auto 10px; position: relative; }
.score-ring svg { width: 150px; height: 150px; transform: rotate(-90deg); }
.score-ring .val { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; }
.score-ring .val b { font-size: 2.1rem; line-height: 1; }
.score-ring .val span { font-size: .8rem; color: var(--muted); font-weight: 700; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 18px 0; }
.stat { background: var(--surface-2); border-radius: 14px; padding: 12px 8px; text-align: center; }
.stat b { display: block; font-size: 1.2rem; }
.stat span { font-size: .75rem; color: var(--muted); font-weight: 700; }

.review-item { padding: 14px 0; border-top: 1px solid var(--border); }
.review-item:first-child { border-top: 0; }
.review-item .ans { font-size: .9rem; margin-top: 6px; }
.review-item .ans b.good { color: var(--good); }
.review-item .ans b.bad { color: var(--bad); }
.review-item .exp { font-size: .88rem; color: var(--muted); margin-top: 6px; }

.option-card {
  display: flex; gap: 14px; align-items: flex-start; text-align: left; width: 100%;
  padding: 16px; border-radius: 16px; border: 2px solid var(--border); background: var(--surface);
  transition: border-color .15s, background .15s;
}
.option-card:hover { border-color: color-mix(in srgb, var(--primary) 50%, var(--border)); }
.option-card.active { border-color: var(--primary); background: var(--primary-soft); }
.option-card .oc-ic { font-size: 1.6rem; line-height: 1; }
.option-card b { display: block; margin-bottom: 2px; }
.option-card span { font-size: .85rem; color: var(--muted); }
.topic-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.topic-pick button {
  padding: 14px 10px; border-radius: 14px; border: 2px solid var(--border); background: var(--surface);
  font-weight: 700; font-size: .9rem; display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.topic-pick button .e { font-size: 1.5rem; }
.topic-pick button.active { border-color: var(--tc); background: color-mix(in srgb, var(--tc) 12%, var(--surface)); }

.done-banner { display: flex; align-items: center; gap: 12px; background: var(--good-soft); border-radius: 14px; padding: 12px 14px; font-weight: 700; color: var(--good); }

/* ---------- Mock exam ---------- */
.exam-bar {
  position: sticky; top: calc(var(--topbar-h) + env(safe-area-inset-top)); z-index: 20;
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; margin: -6px 0 14px;
  border-radius: 16px; background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow);
}
.timer { display: inline-flex; align-items: center; gap: 6px; font-weight: 800; font-variant-numeric: tabular-nums; font-size: 1.05rem; }
.timer svg { width: 20px; height: 20px; }
.timer.low { color: var(--bad); animation: pulse 1s infinite; }
.exam-bar .grow { flex: 1; min-width: 0; }
.exam-bar .progress { height: 6px; margin-top: 4px; }
.exam-count { font-size: .78rem; color: var(--muted); font-weight: 700; }
.nav-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(40px, 1fr)); gap: 6px; }
.nav-grid button {
  height: 40px; border-radius: 10px; border: 1.5px solid var(--border); background: var(--surface);
  font-weight: 700; font-size: .82rem; position: relative;
}
.nav-grid button.answered { background: var(--primary-soft); border-color: color-mix(in srgb, var(--primary) 40%, transparent); color: var(--primary); }
.nav-grid button.current { box-shadow: 0 0 0 2px var(--primary); }
.nav-grid button.flagged::after { content: ""; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 50%; background: var(--warn); }
.nav-grid button.r-good { background: var(--good-soft); border-color: var(--good); color: var(--good); }
.nav-grid button.r-bad { background: var(--bad-soft); border-color: var(--bad); color: var(--bad); }
.legend { display: flex; flex-wrap: wrap; gap: 12px; font-size: .78rem; color: var(--muted); margin-top: 10px; }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 4px; vertical-align: -1px; }
.exam-layout { display: grid; gap: 16px; }
@media (min-width: 1100px) {
  .exam-layout { grid-template-columns: minmax(0, 1fr) 300px; align-items: start; }
  .exam-side { position: sticky; top: calc(var(--topbar-h) + 84px); }
}
.exam-side-mobile { display: block; }
@media (min-width: 1100px) { .exam-side-mobile { display: none; } }
.exam-side { display: none; }
@media (min-width: 1100px) { .exam-side { display: block; } }
.kbd { display: inline-block; padding: 1px 6px; border-radius: 5px; border: 1px solid var(--border); background: var(--surface-2); font-size: .75rem; font-weight: 700; }
.breakdown-row { margin-bottom: 12px; }
.breakdown-row .lbl { display: flex; justify-content: space-between; font-weight: 700; font-size: .9rem; margin-bottom: 4px; }
.breakdown-row .progress > span { background: var(--tc); }

/* ---------- Planner / Calendar ---------- */
.planner { display: grid; gap: 16px; }
@media (min-width: 1000px) { .planner { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); align-items: start; } }
.cal-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.cal-head h2 { margin: 0; flex: 1; font-size: 1.15rem; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.cal-dow { text-align: center; font-size: .72rem; font-weight: 800; color: var(--faint); text-transform: uppercase; padding: 4px 0; }
.cal-day {
  position: relative; min-width: 0; overflow: hidden; aspect-ratio: 1 / 1; min-height: 44px; border-radius: 12px; border: 1.5px solid transparent;
  background: var(--surface-2); padding: 5px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font-weight: 700; font-size: .88rem; color: var(--text);
}
@media (min-width: 640px) { .cal-day { aspect-ratio: auto; min-height: 78px; align-items: flex-start; } }
.cal-day.other { opacity: .35; }
.cal-day.today { border-color: var(--primary); }
.cal-day.today .d { background: var(--primary); color: var(--primary-ink); }
.cal-day.selected { background: var(--primary-soft); border-color: var(--primary); }
.cal-day .d { width: 26px; height: 26px; display: grid; place-items: center; border-radius: 50%; font-size: .85rem; }
.cal-day .dots { display: flex; gap: 3px; flex-wrap: wrap; justify-content: center; }
.cal-day .dots i { width: 6px; height: 6px; border-radius: 50%; }
.cal-day .studied { position: absolute; top: 4px; right: 5px; font-size: .7rem; }
.cal-day .exam-flag { position: absolute; bottom: 3px; right: 4px; font-size: .8rem; }
.cal-day .evt-labels { display: none; width: 100%; }
@media (min-width: 640px) {
  .cal-day .dots { display: none; }
  .cal-day .evt-labels { display: flex; flex-direction: column; gap: 2px; }
  .cal-day .evt-labels span {
    font-size: .66rem; font-weight: 700; padding: 1px 5px; border-radius: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
    background: color-mix(in srgb, var(--ec) 18%, transparent); color: var(--ec);
  }
  .cal-day .evt-labels span.done { text-decoration: line-through; opacity: .6; }
}
.event-item { display: flex; gap: 12px; align-items: flex-start; padding: 12px; border-radius: 14px; background: var(--surface-2); border-left: 5px solid var(--ec); }
.event-item.done .e-title { text-decoration: line-through; opacity: .6; }
.event-item .grow { flex: 1; min-width: 0; }
.event-item .e-title { font-weight: 700; }
.event-item .e-meta { font-size: .8rem; color: var(--muted); }
.event-item .e-notes { font-size: .85rem; margin-top: 4px; white-space: pre-wrap; }
.check-btn {
  width: 28px; height: 28px; border-radius: 9px; border: 2px solid var(--ec, var(--border)); background: transparent;
  display: grid; place-items: center; flex: none; padding: 0; color: #fff;
}
.check-btn.on { background: var(--ec, var(--good)); }
.check-btn svg { width: 16px; height: 16px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 34px; height: 34px; border-radius: 50%; border: 3px solid transparent; padding: 0; }
.swatch.active { border-color: var(--text); }
.dow-pick { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.dow-pick button { height: 42px; border-radius: 12px; border: 2px solid var(--border); background: var(--surface); font-weight: 700; font-size: .82rem; }
.dow-pick button.active { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); }

/* ---------- Tips ---------- */
.accordion { display: flex; flex-direction: column; gap: 10px; }
.acc-item { border: 1px solid var(--border); border-radius: 16px; background: var(--surface); overflow: hidden; }
.acc-head {
  width: 100%; display: flex; align-items: center; gap: 12px; padding: 15px 16px; border: 0; background: transparent;
  text-align: left; font-weight: 700; font-size: .98rem;
}
.acc-head .ic { font-size: 1.3rem; }
.acc-head .chev { margin-left: auto; transition: transform .2s; color: var(--faint); }
.acc-item.open .acc-head .chev { transform: rotate(90deg); }
.acc-body { display: none; padding: 0 16px 16px; }
.acc-item.open .acc-body { display: block; animation: fadeUp .2s ease; }
.acc-body ul { padding-left: 20px; margin: 0; }
.acc-body li { margin-bottom: 8px; }
.checklist label { display: flex; gap: 12px; align-items: flex-start; padding: 10px 0; border-top: 1px solid var(--border); cursor: pointer; }
.checklist label:first-child { border-top: 0; }
.checklist input { width: 22px; height: 22px; accent-color: var(--good); flex: none; margin-top: 1px; }
.checklist input:checked + span { text-decoration: line-through; color: var(--muted); }
.tip-of-day { display: flex; gap: 12px; align-items: flex-start; }
.tip-of-day .ic { font-size: 1.6rem; }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; margin-bottom: 14px; }
.chip-row::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--border); background: var(--surface);
  font-weight: 700; font-size: .85rem; color: var(--muted);
}
.chip.active { background: var(--primary); border-color: var(--primary); color: var(--primary-ink); }

/* ---------- Progress ---------- */
.badges { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.badge {
  text-align: center; padding: 14px 8px; border-radius: 16px; background: var(--surface-2);
  font-size: .78rem; font-weight: 700; color: var(--muted);
}
.badge .b-ic { font-size: 2rem; display: block; margin-bottom: 4px; filter: grayscale(1); opacity: .45; }
.badge.earned { background: var(--accent-soft); color: var(--text); }
.badge.earned .b-ic { filter: none; opacity: 1; }
.chart-box svg { width: 100%; height: auto; display: block; }
.rank-card { display: flex; align-items: center; gap: 16px; }
.rank-ic { width: 64px; height: 64px; border-radius: 20px; display: grid; place-items: center; font-size: 2rem; background: var(--accent-soft); flex: none; }

/* ---------- Modal / sheet ---------- */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 100; background: rgba(8, 12, 24, .45);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  display: flex; align-items: flex-end; justify-content: center; animation: fadeIn .2s ease;
}
.modal {
  width: 100%; max-height: 92vh; max-height: 92dvh; overflow-y: auto; background: var(--surface);
  border-radius: 24px 24px 0 0; padding: 8px 18px calc(20px + env(safe-area-inset-bottom));
  box-shadow: var(--shadow-lg); animation: sheetUp .28s cubic-bezier(.2,.8,.2,1);
}
.modal::before { content: ""; display: block; width: 42px; height: 5px; border-radius: 3px; background: var(--border); margin: 4px auto 12px; }
.modal-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.modal-head h2 { margin: 0; flex: 1; }
@media (min-width: 640px) {
  .modal-backdrop { align-items: center; padding: 20px; }
  .modal { max-width: 520px; border-radius: 24px; padding: 22px 24px; animation: popIn .22s cubic-bezier(.2,.8,.2,1); }
  .modal::before { display: none; }
}

.toast-root { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top) + 12px); z-index: 200; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 16px; }
.toast {
  background: var(--text); color: var(--bg); padding: 11px 18px; border-radius: 14px; font-weight: 700; font-size: .9rem;
  box-shadow: var(--shadow-lg); animation: toastIn .3s cubic-bezier(.2,.8,.2,1); max-width: 440px; text-align: center;
}
.toast.xp { background: var(--accent); color: #2b2000; }
.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 150; width: 100%; height: 100%; }

/* ---------- Animations ---------- */
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes sheetUp { from { transform: translateY(100%); } to { transform: none; } }
@keyframes popIn { from { opacity: 0; transform: scale(.94); } to { opacity: 1; transform: none; } }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes shake { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }
@keyframes pulse { 50% { opacity: .55; } }
@keyframes pop { 0% { transform: scale(1); } 40% { transform: scale(1.06); } 100% { transform: scale(1); } }
.pop { animation: pop .35s ease; }
/* Page-change animation only (in-page updates re-render without it) */
.view.enter > * { animation: fadeUp .35s var(--ease) both; }
.view.enter > :nth-child(2) { animation-delay: .04s; }
.view.enter > :nth-child(3) { animation-delay: .08s; }
.view.enter > :nth-child(n+4) { animation-delay: .12s; }
.view.enter .grid > *, .view.enter .grid-4 > * { animation: fadeUp .4s var(--ease) both; }
.view.enter .grid > :nth-child(2), .view.enter .grid-4 > :nth-child(2) { animation-delay: .06s; }
.view.enter .grid > :nth-child(3), .view.enter .grid-4 > :nth-child(3) { animation-delay: .1s; }
.view.enter .grid > :nth-child(4), .view.enter .grid-4 > :nth-child(4) { animation-delay: .14s; }
.view.enter .grid > :nth-child(n+5), .view.enter .grid-4 > :nth-child(n+5) { animation-delay: .18s; }
.view.enter .progress > span { animation: growX .8s var(--ease) .15s both; transform-origin: left center; }
@keyframes growX { from { transform: scaleX(0); } to { transform: none; } }
@keyframes floatA { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-30px, 24px); } }
@keyframes floatB { 0%, 100% { transform: translate(0, 0) scale(1); } 50% { transform: translate(40px, -20px) scale(1.12); } }
@keyframes tabPop { 0% { transform: scale(.8); } 60% { transform: scale(1.12); } 100% { transform: none; } }
@keyframes heartBeat { 0%, 100% { transform: scale(1); } 25% { transform: scale(1.2); } 50% { transform: scale(.95); } 75% { transform: scale(1.12); } }
@keyframes flicker { 0%, 100% { transform: rotate(-4deg) scale(1); } 50% { transform: rotate(4deg) scale(1.1); } }
@keyframes shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
html[data-motion="off"] *, html[data-motion="off"] *::before, html[data-motion="off"] *::after { animation: none !important; transition: none !important; }

@media print {
  .sidebar, .tabbar, .topbar { display: none !important; }
  .view { padding: 0; }
}

/* Reading passages inside questions: plain, readable quote box instead of long italics */
.q-text p > em:only-child {
  display: block; font-style: normal; font-weight: 400; font-size: .95rem; line-height: 1.6;
  background: var(--surface-2); border-left: 4px solid var(--primary); border-radius: 12px; padding: 12px 14px;
}
.exam-count { white-space: nowrap; }
.list > .list-item { width: 100%; min-width: 0; }
.list-item .title, .list-item .sub { overflow-wrap: anywhere; }

/* ---------- Accounts: sign-up / log-in page ---------- */
body.auth-mode .sidebar, body.auth-mode .topbar, body.auth-mode .tabbar { display: none !important; }
body.auth-mode .app { display: block; }
body.auth-mode .view { max-width: none; padding: 0; }
/* Sign-up / log-in: the page still scrolls (wheel, touch, keyboard) but shows no scrollbar */
html.auth-mode { scrollbar-width: none; }
html.auth-mode::-webkit-scrollbar, html.auth-mode body::-webkit-scrollbar { display: none; }
.auth-wrap { min-height: 100vh; min-height: 100dvh; display: grid; grid-template-columns: minmax(0, 1fr); }
.auth-hero {
  position: relative; overflow: hidden; color: #fff;
  background: linear-gradient(140deg, #1c3aa8 0%, #2f55e4 50%, #5b3fd6 100%);
  padding: calc(28px + env(safe-area-inset-top)) 22px 34px;
}
.auth-hero::after {
  content: ""; position: absolute; right: -90px; bottom: -90px; width: 300px; height: 300px; border-radius: 50%;
  background: radial-gradient(circle, rgba(245, 179, 1, .35), transparent 70%);
}
.auth-hero .brand { color: #fff; position: relative; z-index: 1; }
.auth-hero .brand small { color: rgba(255,255,255,.75); }
.auth-hero h1 { font-size: 1.7rem; margin: 26px 0 8px; position: relative; z-index: 1; max-width: 520px; }
.auth-hero > p { opacity: .9; margin: 0; position: relative; z-index: 1; max-width: 480px; }
.auth-features { display: none; list-style: none; padding: 0; margin: 28px 0 0; position: relative; z-index: 1; }
.auth-features li { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 16px; font-size: .92rem; opacity: .95; }
.auth-features .af-ic { width: 40px; height: 40px; flex: none; border-radius: 12px; background: rgba(255,255,255,.15); display: grid; place-items: center; font-size: 1.2rem; }
.auth-panel { padding: 0 16px calc(30px + env(safe-area-inset-bottom)); margin-top: -18px; position: relative; z-index: 2; }
.auth-card {
  max-width: 420px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 24px;
  padding: 24px 20px; box-shadow: var(--shadow-lg);
}
.auth-card h2 { font-size: 1.35rem; margin-bottom: 6px; }
.auth-card-brand { display: none; text-align: center; margin-bottom: 14px; }
.auth-card-brand img { border-radius: 16px; }
.auth-card-brand strong { display: block; margin-top: 6px; font-size: 1.15rem; }
.auth-card .callout { margin-top: 14px; }
.auth-card .callout .btn { margin-top: 4px; }
.auth-fine { margin: 16px 0 0; line-height: 1.5; }
.google-btn {
  width: 100%; min-height: 50px; margin-top: 8px; display: flex; align-items: center; justify-content: center; gap: 12px;
  border-radius: 999px; border: 1px solid #747775; background: #fff; color: #1f1f1f;
  font-family: Roboto, var(--font); font-weight: 600; font-size: 1rem; letter-spacing: .1px;
  transition: background .15s, box-shadow .15s, transform .08s;
}
.google-btn:hover { background: #f7f8f8; box-shadow: 0 1px 3px rgba(60,64,67,.3); }
.google-btn:active { transform: scale(.98); }
.google-btn:disabled { opacity: .7; cursor: progress; }
.google-btn.loading svg { animation: pulse 1s infinite; }
@media (min-width: 900px) {
  .auth-wrap { grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); }
  /* The blue panel stays in place while the form side scrolls */
  .auth-hero { padding: 48px 56px; display: flex; flex-direction: column; justify-content: center; position: sticky; top: 0; height: 100vh; height: 100dvh; }
  .auth-hero h1 { font-size: 2.3rem; }
  .auth-features { display: block; }
  .auth-panel { margin: 0; padding: 40px; display: flex; flex-direction: column; justify-content: center; }
  .auth-card { padding: 32px 30px; width: 100%; }
  .auth-card-brand { display: block; }
}
/* Shorter laptop screens: a more compact form so it fits without scrolling */
@media (min-width: 900px) and (max-height: 900px) {
  .auth-panel { padding: 24px 40px; }
  .auth-card { padding: 24px 30px; }
  .auth-card-brand { margin-bottom: 8px; }
  .auth-card-brand img { width: 44px; height: 44px; }
  .auth-card .segmented { margin-bottom: 14px !important; }
  .auth-card h2 { font-size: 1.25rem; margin-bottom: 2px; }
  .email-form .field { margin-bottom: 9px; }
  .or-divider { margin: 12px 0 10px; }
  .auth-fine { margin-top: 12px; font-size: .72rem; }
  .auth-features li { margin-bottom: 12px; }
  .auth-hero h1 { margin-top: 18px; }
}

/* Avatars and sync status */
.avatar { border-radius: 50%; object-fit: cover; display: block; flex: none; }
.avatar-letter { display: grid; place-items: center; background: var(--primary); color: var(--primary-ink); font-weight: 800; }
.account-row { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.sync-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; margin-right: 5px; vertical-align: 1px; background: var(--faint); }
.sync-dot.synced { background: var(--good); }
.sync-dot.saving { background: var(--accent); animation: pulse 1s infinite; }
.sync-dot.error, .sync-dot.offline { background: var(--warn); }
#progressBtn .avatar { border: 2px solid var(--border); }

/* ---------- Loading screen (first paint) ---------- */
.boot-splash {
  position: fixed; inset: 0; z-index: 300; display: grid; place-items: center; padding: 24px;
  background:
    radial-gradient(600px 400px at 50% 30%, color-mix(in srgb, var(--primary) 16%, transparent), transparent 70%),
    var(--bg);
  transition: opacity .4s ease, visibility .4s;
}
.boot-splash.done { opacity: 0; visibility: hidden; pointer-events: none; }
.boot-inner { display: flex; flex-direction: column; align-items: center; text-align: center; max-width: 340px; width: 100%; }
.boot-logo { position: relative; width: 104px; height: 104px; display: grid; place-items: center; margin-bottom: 18px; }
.boot-logo img { position: relative; border-radius: 22px; box-shadow: 0 14px 34px -10px rgba(37, 71, 208, .6); animation: bootFloat 2.4s ease-in-out infinite; }
.boot-ring {
  position: absolute; inset: 0; border-radius: 50%;
  border: 3px solid color-mix(in srgb, var(--primary) 18%, transparent); border-top-color: var(--primary);
  animation: bootSpin 1.1s linear infinite;
}
.boot-title { font-weight: 800; font-size: 1.35rem; letter-spacing: -.01em; color: var(--text); }
.boot-sub { font-size: .85rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
.boot-bar { position: relative; width: 180px; height: 5px; border-radius: 999px; background: var(--surface-3); overflow: hidden; margin: 22px 0 14px; }
.boot-bar span { position: absolute; top: 0; bottom: 0; left: 0; width: 40%; border-radius: inherit; background: var(--grad); animation: bootSlide 1.3s var(--ease) infinite; }
.boot-text { min-height: 2.8em; font-size: .88rem; color: var(--muted); line-height: 1.5; animation: fadeIn .4s ease; }
@keyframes bootSpin { to { transform: rotate(360deg); } }
@keyframes bootFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }
@keyframes bootSlide { from { transform: translateX(-110%); } to { transform: translateX(260%); } }
/* Without motion the bar shows as a calm static fill */
@media (prefers-reduced-motion: reduce) { .boot-bar span { width: 60%; } }
html[data-motion="off"] .boot-bar span { width: 60%; }

.splash { min-height: 60vh; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px; }
.splash img { border-radius: 18px; animation: pulse 1.4s infinite; }
.sync-dot.pending { background: var(--primary); }

/* ---------- Study features ---------- */
.quest { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.quest .q-ic { font-size: 1.3rem; width: 28px; text-align: center; }
.quest .grow { flex: 1; min-width: 0; }
.quest .title { font-weight: 700; font-size: .9rem; margin-bottom: 5px; }
.quest .progress { height: 7px; }
.quest .progress > span { background: var(--accent); }
.quest.done .progress > span { background: var(--good); }
.quest.done .title { color: var(--muted); }
.weak-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.weak-row .grow { flex: 1; min-width: 0; }
.weak-row .title { font-weight: 700; font-size: .9rem; margin-bottom: 5px; overflow-wrap: anywhere; }
.weak-row .progress > span { background: var(--tc); }
.bm-btn {
  border: 1.5px solid var(--border); background: var(--surface); color: var(--muted); border-radius: 999px;
  padding: 4px 12px; font-size: .8rem; font-weight: 700; white-space: nowrap;
}
.bm-btn:hover { border-color: var(--accent); color: var(--text); }
.bm-btn.on { background: var(--accent-soft); border-color: var(--accent); color: var(--warn); }
#mFlag + .bm-btn { margin-left: 6px; }
.flash-rate { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.focus-ring { position: relative; width: 240px; height: 240px; margin: 0 auto; }
.focus-ring svg { width: 240px; height: 240px; transform: rotate(-90deg); }
.focus-ring .val { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; }
.focus-ring .val b { font-size: 3rem; line-height: 1; font-variant-numeric: tabular-nums; }
.focus-pill {
  position: fixed; right: 16px; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); z-index: 45;
  background: var(--text); color: var(--bg); padding: 9px 14px; border-radius: 999px; font-weight: 800; font-size: .9rem;
  box-shadow: var(--shadow-lg); font-variant-numeric: tabular-nums;
}
@media (min-width: 900px) { .focus-pill { bottom: 20px; right: 24px; } }

/* ---------- Challenge a friend ---------- */
.vs-card { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; margin: 18px 0 14px; }
.vs-side { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 14px 8px; border-radius: 18px; background: var(--surface-2); border: 2px solid transparent; }
.vs-side.win { border-color: var(--good); background: var(--good-soft); }
.vs-name { font-weight: 800; font-size: .95rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.vs-score { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.vs-score small { font-size: .9rem; color: var(--muted); font-weight: 700; }
.vs-mid { font-weight: 900; font-size: 1.1rem; color: var(--warn); }
.vs-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(34px, 1fr)); gap: 6px; }
.vs-q { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0; border-radius: 10px; background: var(--surface-2); font-weight: 800; font-size: .85rem; }
.vs-q .ok { color: var(--good); }
.vs-q .no { color: var(--bad); }
.share-panel .input { font-size: .85rem; }
.invite-banner { display: flex; gap: 12px; align-items: flex-start; padding: 14px; margin-bottom: 18px; border-radius: 16px; background: var(--accent-soft); border: 2px solid var(--accent); }
.invite-banner .ib-ic { font-size: 1.8rem; line-height: 1; }

/* ---------- Leaderboard ---------- */
.lb-you { display: flex; align-items: center; gap: 16px; margin-bottom: 14px; }
.podium { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); align-items: end; gap: 8px; margin: 6px 0 18px; }
.pod { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 2px; min-width: 0; }
.pod-medal { font-size: 2rem; line-height: 1; }
.pod-name { font-weight: 800; font-size: .9rem; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod-xp { font-size: .78rem; color: var(--muted); font-weight: 700; }
.pod-bar { width: 100%; border-radius: 12px 12px 4px 4px; margin-top: 6px; background: var(--surface-3); }
.pod-1 .pod-bar { height: 92px; background: linear-gradient(180deg, var(--accent), color-mix(in srgb, var(--accent) 55%, var(--surface-3))); }
.pod-2 .pod-bar { height: 64px; background: linear-gradient(180deg, #b8c1d1, var(--surface-3)); }
.pod-3 .pod-bar { height: 46px; background: linear-gradient(180deg, #d79b6a, var(--surface-3)); }
.pod.me .pod-name { color: var(--primary); }
.lb-list { display: flex; flex-direction: column; gap: 6px; }
.lb-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: 14px; background: var(--surface-2); }
.lb-row .grow { flex: 1; min-width: 0; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb-row.me { background: var(--primary-soft); box-shadow: inset 0 0 0 2px var(--primary); }
.lb-rank { width: 24px; text-align: center; font-weight: 800; color: var(--muted); }

/* ---------- Feedback ---------- */
.stars { display: flex; gap: 4px; }
.star { border: 0; background: none; font-size: 2rem; line-height: 1; color: var(--surface-3); padding: 2px; transition: transform .1s, color .1s; }
.star.on { color: var(--accent); }
.star:active { transform: scale(.88); }

/* Email sign-in */
.or-divider { display: flex; align-items: center; gap: 12px; margin: 18px 0 14px; color: var(--faint); font-size: .8rem; font-weight: 700; }
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.email-form .field { margin-bottom: 12px; }
.pw-wrap { position: relative; }
.pw-wrap .input { padding-right: 70px; }
.pw-toggle { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); border: 0; background: transparent; color: var(--primary); font-weight: 700; font-size: .85rem; padding: 8px 10px; border-radius: 10px; }
.pw-toggle:hover { background: var(--primary-soft); }

/* ---------- Beta, support and donation ---------- */
.beta-tag {
  display: inline-block; margin-left: 6px; padding: 2px 7px; border-radius: 999px; vertical-align: 2px;
  font-size: .6rem; font-weight: 800; letter-spacing: .08em; line-height: 1.4;
  background: var(--grad-warm); color: #2b1a00;
}
.brand-mobile .beta-tag { margin-left: 0; }
.streak-chip .flame { display: inline-block; }
.streak-chip:not(.cold) .flame { animation: flicker 2.4s ease-in-out infinite; }
.beta-card, .donate-card { display: flex; gap: 14px; align-items: flex-start; transition: opacity .2s, transform .2s var(--ease); }
.beta-card { border: 1.5px dashed color-mix(in srgb, var(--accent) 70%, var(--border)); background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface)); }
.beta-card h3, .donate-card h3 { margin-bottom: 4px; }
.beta-card .grow, .donate-card .grow { flex: 1; min-width: 0; }
.beta-ic, .donate-card-ic { font-size: 1.6rem; line-height: 1.2; }
.donate-card { background: linear-gradient(135deg, color-mix(in srgb, #e5486b 10%, var(--surface)), var(--surface) 70%); }
.donate-card-ic { animation: heartBeat 2.6s var(--ease) infinite; display: inline-block; }
.leaving { opacity: 0; transform: translateY(-6px) scale(.98); }
.support-item svg { color: #e5486b; }

.donate-hero {
  position: relative; overflow: hidden; text-align: center; color: #fff; border-radius: 24px; padding: 30px 22px 28px;
  background: linear-gradient(135deg, #d63a63 0%, #7a3fd6 55%, #2547d0 100%);
  box-shadow: 0 18px 40px -18px rgba(122, 63, 214, .6);
}
.donate-hero::after {
  content: ""; position: absolute; left: -80px; top: -80px; width: 260px; height: 260px; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, rgba(255,255,255,.2), transparent 70%); animation: floatA 16s ease-in-out infinite;
}
.donate-hero h1 { font-size: 1.6rem; margin: 6px 0; position: relative; z-index: 1; }
.donate-hero p { max-width: 560px; margin: 0 auto; opacity: .92; position: relative; z-index: 1; }
.donate-heart { font-size: 2.6rem; line-height: 1; display: inline-block; animation: heartBeat 2.2s var(--ease) infinite; position: relative; z-index: 1; }
.donate-grid { display: grid; gap: 14px; margin-top: 16px; }
@media (min-width: 820px) { .donate-grid { grid-template-columns: minmax(0, 380px) minmax(0, 1fr); align-items: start; } }
.qr-card { text-align: center; }
.qr-frame {
  padding: 14px; border-radius: 20px; background: #fff; margin: 0 auto 12px; max-width: 320px;
  box-shadow: inset 0 0 0 2px #e6eaf4, 0 10px 30px -14px rgba(37, 71, 208, .45);
}
.qr-frame img { display: block; width: 100%; height: auto; border-radius: 10px; }
.qr-label { display: flex; align-items: center; justify-content: center; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.donate-steps { margin: 0; padding-left: 0; list-style: none; counter-reset: step; }
.donate-steps li { counter-increment: step; position: relative; padding: 0 0 12px 40px; }
.donate-steps li::before {
  content: counter(step); position: absolute; left: 0; top: -1px; width: 28px; height: 28px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 800; font-size: .85rem; background: var(--primary-soft); color: var(--primary);
}
.amount-row, .app-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.amount-row span { padding: 7px 12px; border-radius: 999px; background: var(--accent-soft); font-weight: 700; font-size: .85rem; }
.app-chips span { padding: 6px 12px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--border); font-weight: 700; font-size: .82rem; }

/* Loading skeleton (leaderboard) */
.skeleton-row { display: flex; align-items: center; gap: 12px; padding: 10px 4px; }
.skeleton-row i {
  display: block; height: 14px; border-radius: 8px;
  background: linear-gradient(90deg, var(--surface-2) 25%, var(--surface-3) 50%, var(--surface-2) 75%); background-size: 200% 100%;
  animation: shimmer 1.4s linear infinite;
}
.skeleton-row i:nth-child(1) { width: 32px; height: 32px; border-radius: 50%; flex: none; }
.skeleton-row i:nth-child(2) { flex: 1; }
.skeleton-row i:nth-child(3) { width: 56px; flex: none; }
