/* ==========================================================================
   CSE Reviewer PH — 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: 18px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 6px 20px rgba(16, 24, 40, .06);
  --shadow-lg: 0 10px 40px rgba(16, 24, 40, .18);
  --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 6px 20px rgba(0, 0, 0, .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 6px 20px rgba(0, 0, 0, .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;
}
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.active::before {
  content: ""; position: absolute; top: 0; width: 34px; height: 3px; border-radius: 0 0 4px 4px;
  background: var(--primary);
}
.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: 18px;
    position: sticky; top: 0; height: 100vh; height: 100dvh;
    padding: 22px 14px; border-right: 1px solid var(--border); background: var(--surface);
    overflow-y: auto;
  }
  .sidebar .brand { padding: 0 8px; }
  .side-nav { display: flex; flex-direction: column; gap: 2px; }
  .side-nav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 12px;
    color: var(--muted); font-weight: 600; font-size: .95rem; position: relative;
  }
  .side-nav a:hover { background: var(--surface-2); color: var(--text); }
  .side-nav a.active { background: var(--primary-soft); color: var(--primary); }
  .side-nav .sep { height: 1px; background: var(--border); margin: 10px 8px; }
  .side-nav .badge-dot { margin-left: auto; width: 8px; height: 8px; border-radius: 50%; background: var(--bad); }
  .side-foot { margin-top: auto; }
  .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; }
.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); color: var(--primary-ink); box-shadow: 0 4px 0 color-mix(in srgb, var(--primary) 60%, #000); }
.btn-primary:hover { background: var(--primary-2); }
.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: linear-gradient(135deg, #2547d0 0%, #3b5cf0 55%, #5b3fd6 100%);
  color: #fff; border-radius: 22px; padding: 22px; box-shadow: var(--shadow);
}
.hero::after {
  content: ""; position: absolute; right: -60px; top: -60px; width: 220px; height: 220px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,.18), transparent 70%);
}
.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-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; }
@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; }

.week-strip { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; 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: 30px; height: 30px; 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 .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); }
.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, .5);
  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 .2s ease both; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::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; }
.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 .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); }
  .auth-hero { padding: 48px 56px; display: flex; flex-direction: column; justify-content: center; }
  .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; }
}

/* 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); }

.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); }
