:root {
  /* Cool light gray-blue palette — sterile white surfaces on a soft slate background */
  --bg: #eef2f7;          /* page background — light gray-blue */
  --bg2: #e2e8f0;         /* slightly deeper gray-blue */
  --paper: #ffffff;       /* sterile white for cards / panels */
  --card: #ffffff;
  --card-hi: #f6f8fb;     /* very light gray-blue tint on white */
  --text: #1a2230;        /* cool dark navy */
  --text-soft: #3a4252;
  --muted: #6b7280;       /* neutral cool gray */
  --border: #dde3eb;      /* soft gray-blue border */
  --border-strong: #c1cad6;
  --accent: #4a6fa5;
  --accent-soft: #e3ebf5;
  --accent2: #5d7a9c;
  --good: #5b8c6a;
  --good-soft: #ecf4ee;
  --bad: #b65555;
  --bad-soft: #faecec;
  --warn: #6b7d92;        /* muted cool gray-blue instead of warm gold */
  --radius: 14px;
  --shadow-sm: 0 1px 2px rgba(30, 34, 56, 0.04), 0 1px 3px rgba(30, 34, 56, 0.06);
  --shadow: 0 2px 8px rgba(30, 34, 56, 0.06), 0 4px 16px rgba(30, 34, 56, 0.06);
  --shadow-lg: 0 8px 24px rgba(30, 34, 56, 0.08), 0 16px 40px rgba(30, 34, 56, 0.08);
  --font: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --serif: 'Fraunces', 'Playfair Display', Georgia, serif;
}

/* DARK MODE — override palette when [data-theme="dark"] is set on <html> */
:root[data-theme="dark"] {
  --bg: #0f1620;
  --bg2: #1a2230;
  --paper: #1a2230;
  --card: #1a2230;
  --card-hi: #232d3c;
  --text: #e8ecf3;
  --text-soft: #b8c2d0;
  --muted: #8590a0;
  --border: #2c3848;
  --border-strong: #3a475a;
  --accent: #7da8e0;
  --accent-soft: #1f2c3f;
  --accent2: #9bb6d8;
  --good: #6fb185;
  --good-soft: #1e2e26;
  --bad: #d97070;
  --bad-soft: #3a1f1f;
  --warn: #8aa0ba;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.2), 0 1px 3px rgba(0, 0, 0, 0.3);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.35);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.4), 0 16px 40px rgba(0, 0, 0, 0.45);
}

/* Smooth color transitions between themes */
html, body, .nav, .book-card, .course-card, .section-card, .auth-card,
.testimonial, .faq-item, .site-footer, .pricing-card, .info-page,
.about-page, .study-page, .feature, .topic-picker, .pomo, .study-section,
.study-q-card, .recall-widget, .sr-widget, .method-card, .study-panel,
.chat-panel, .footer-social a, .grade-card {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

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

html, body {
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 15% 5%, rgba(74, 111, 165, 0.06), transparent 50%),
    radial-gradient(ellipse at 85% 85%, rgba(160, 93, 93, 0.05), transparent 50%);
  z-index: -1;
  pointer-events: none;
}

.nav {
  position: sticky; top: 0; z-index: 20;
  backdrop-filter: blur(10px);
  background: var(--nav-bg, rgba(247, 245, 240, 0.88));
  border-bottom: 1px solid var(--border);
  padding: 14px 32px;
  display: flex; align-items: center; justify-content: space-between;
  color: var(--text);
}
/* Dark mode: deeper nav background so the light text actually reads. */
:root[data-theme="dark"] .nav {
  background: rgba(10, 14, 22, 0.92);
}
:root[data-theme="dark"] .nav,
:root[data-theme="dark"] .nav .logo,
:root[data-theme="dark"] .nav .nav-link,
:root[data-theme="dark"] .nav .nav-search,
:root[data-theme="dark"] .nav .progress-pill,
:root[data-theme="dark"] .nav #navUserEmail {
  color: #f1f4fa;
}
:root[data-theme="dark"] .nav .nav-link:hover { color: #ffffff; background: rgba(255,255,255,.08); }
:root[data-theme="dark"] .theme-toggle { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.18); color: #f1f4fa; }
:root[data-theme="dark"] .nav-search { background: rgba(255,255,255,.06); border-color: rgba(255,255,255,.18); }
:root[data-theme="dark"] .nav-search::placeholder { color: #aab4c5; }
.logo { display: flex; align-items: center; gap: 12px; font-weight: 700; font-size: 17px; letter-spacing: -.2px; color: var(--text); font-family: var(--serif); }
.logo-dot {
  width: 30px; height: 30px; border-radius: 8px;
  background: var(--text); color: var(--bg);
  display: grid; place-items: center; font-size: 15px; font-weight: 600;
}

.nav-right { display: flex; gap: 14px; align-items: center; font-size: 14px; color: var(--muted); }
.progress-pill {
  padding: 7px 14px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--border);
  color: var(--text-soft); font-weight: 500; font-size: 13px;
}

/* HERO */
.hero { padding: 100px 32px 80px; text-align: center; max-width: 880px; margin: 0 auto; }
.hero h1 {
  font-family: var(--serif);
  font-size: clamp(44px, 7vw, 80px);
  font-weight: 500; line-height: 1.05; letter-spacing: -1.5px;
  color: var(--text);
  margin-bottom: 22px;
}
.hero h1 em {
  font-style: italic; color: var(--accent); font-weight: 400;
}
.hero p {
  color: var(--muted);
  font-size: 18px; line-height: 1.65;
  max-width: 600px; margin: 0 auto 32px;
}
.hero-badges { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-bottom: 32px; }
.badge {
  padding: 7px 14px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--border);
  font-size: 13px; color: var(--text-soft); font-weight: 500;
}

.cta {
  display: inline-block;
  padding: 14px 30px;
  border-radius: 999px;
  background: var(--text); color: var(--paper);
  font-weight: 600; text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform .15s ease, box-shadow .2s ease, background .2s;
  border: none; cursor: pointer; font-size: 15px;
  font-family: var(--font);
}
.cta:hover { transform: translateY(-1px); box-shadow: var(--shadow-lg); background: #2a2e46; }
.cta:active { transform: translateY(0); }

.section-heading {
  max-width: 1200px; margin: 56px auto 24px; padding: 0 32px;
  display: flex; align-items: baseline; justify-content: space-between;
}
.section-heading h2 { font-family: var(--serif); font-size: 30px; font-weight: 500; letter-spacing: -.3px; color: var(--text); }
.section-heading .sub { color: var(--muted); font-size: 14px; }

/* BOOKS GRID */
.books {
  max-width: 1200px; margin: 0 auto 100px; padding: 0 32px;
  display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 20px;
}

.book-card {
  position: relative; padding: 28px;
  border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border);
  cursor: pointer; overflow: hidden;
  transition: transform .2s ease, box-shadow .25s ease, border-color .2s;
  min-height: 220px; display: flex; flex-direction: column; justify-content: space-between;
  box-shadow: var(--shadow-sm);
}
.book-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--a1, var(--accent));
  opacity: .9;
}
.book-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.book-card > * { position: relative; z-index: 1; }

.book-card.final-card {
  background: linear-gradient(135deg, var(--paper) 0%, var(--accent-soft) 100%);
  border: 2px solid var(--warn);
}
.book-card.final-card::before {
  background: var(--warn);
  height: 5px;
}
.book-card.final-card .book-title { color: var(--text); }
.book-card.final-card .book-subtitle { color: var(--text-soft); font-style: normal; }
.book-card.final-card:hover { border-color: #a76d22; }

.book-emoji { font-size: 36px; margin: 4px 0 14px; display: inline-block; }
.book-title {
  font-family: var(--serif);
  font-size: 22px; font-weight: 500; margin-bottom: 4px;
  letter-spacing: -.3px; color: var(--text);
}
.book-subtitle { color: var(--muted); font-size: 14px; margin-bottom: 20px; font-style: italic; }
.book-meta {
  display: flex; justify-content: space-between; font-size: 13px;
  color: var(--muted); align-items: center;
}

.book-progress-bar {
  height: 5px; background: var(--bg2); border-radius: 999px;
  overflow: hidden; margin-top: 10px;
}
.book-progress-bar > div {
  height: 100%;
  background: var(--a1, var(--accent));
  width: 0%; transition: width .6s; border-radius: 999px;
}

/* Section card progress bar */
.section-progress-bar {
  height: 4px; background: #e8e8e8; border-radius: 999px;
  overflow: hidden; margin: 6px 0 2px;
}
.section-progress-bar > div {
  height: 100%;
  background: var(--a1, var(--accent));
  width: 0%; transition: width .6s; border-radius: 999px;
}

/* Book header progress (inside detail view) */
.book-header-progress {
  display: flex; align-items: center; gap: 10px; margin-top: 8px;
}
.book-header-progress .book-progress-bar {
  flex: 1; max-width: 280px; height: 6px;
}
.book-progress-label {
  font-size: 13px; color: rgba(255,255,255,.8); font-weight: 500;
}

/* COURSE PICKER */
.courses-grid {
  max-width: 1100px; margin: 0 auto 100px; padding: 0 32px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 24px;
}

.course-card {
  position: relative; padding: 36px 32px 28px;
  border-radius: var(--radius);
  background: var(--card); border: 1px solid var(--border);
  cursor: pointer; overflow: hidden;
  transition: transform .2s ease, box-shadow .25s ease, border-color .2s;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column; gap: 10px;
}
.course-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 5px;
  background: var(--a1, var(--accent));
}
.course-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow);
  border-color: var(--border-strong);
}
.course-emoji {
  font-size: 48px; line-height: 1; margin: 4px 0 8px;
}
.course-title {
  font-family: var(--serif);
  font-size: 32px; font-weight: 500; letter-spacing: -.5px;
  color: var(--text);
}
.course-subtitle {
  color: var(--muted); font-size: 15px; font-style: italic;
  margin-bottom: 8px;
}
.course-desc {
  color: var(--text-soft); font-size: 14.5px; line-height: 1.55;
  margin-bottom: 12px;
}
.course-meta {
  display: flex; justify-content: space-between;
  font-size: 13px; color: var(--muted); align-items: center;
  margin-top: auto;
}
.course-cta {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
  font-weight: 600; color: var(--a1, var(--accent));
  font-size: 14px;
}

/* Course header strip (when inside a course) */
.course-header {
  max-width: 1200px; margin: 30px auto 20px; padding: 0 32px;
}
.course-header-inner {
  display: flex; align-items: center; gap: 18px;
  padding: 20px 24px;
  background: var(--paper); border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 4px solid var(--a1, var(--accent));
}
.course-emoji-big { font-size: 36px; }
.course-header-inner h1 {
  font-family: var(--serif);
  font-size: 26px; font-weight: 500; letter-spacing: -.3px;
  color: var(--text); margin: 0;
}
.course-header-inner p { color: var(--muted); font-size: 14px; font-style: italic; }

/* DETAIL VIEW */
.detail { max-width: 960px; margin: 40px auto 80px; padding: 0 32px; }
.back-btn {
  background: transparent;
  border: 1px solid var(--border); color: var(--muted);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-size: 13px;
  margin-bottom: 28px; transition: background .15s, color .15s, border-color .15s;
  font-family: var(--font);
}
.back-btn:hover { background: var(--paper); color: var(--text); border-color: var(--border-strong); }

.detail-header {
  padding: 40px; border-radius: var(--radius);
  background: var(--paper); border: 1px solid var(--border);
  margin-bottom: 28px; position: relative; overflow: hidden;
  box-shadow: var(--shadow-sm);
}
.detail-header::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
  background: var(--a1, var(--accent));
}
.detail-header > * { position: relative; z-index: 1; }
.detail-header h1 {
  font-family: var(--serif);
  font-size: 38px; font-weight: 500; letter-spacing: -.8px;
  margin: 6px 0 8px; color: var(--text);
}
.detail-header .subtitle { color: var(--muted); font-size: 16px; font-style: italic; }

.section-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); margin-bottom: 10px; overflow: hidden;
  transition: border-color .15s, box-shadow .2s;
  box-shadow: var(--shadow-sm);
}
.section-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow); }

.section-row {
  padding: 18px 22px; display: flex; align-items: center; gap: 14px;
}
.section-row .num {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--a1, var(--accent));
  color: #fff;
  display: grid; place-items: center; font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.section-row .title { flex: 1; font-weight: 500; font-size: 15px; color: var(--text); }

.study-section-btn {
  display: block; width: calc(100% - 44px); margin: 0 22px 14px 22px;
  padding: 9px 14px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px dashed var(--accent); font-family: var(--font);
  font-weight: 500; font-size: 13px; cursor: pointer;
  text-align: left;
  transition: background .15s, color .15s, border-style .15s;
}
.study-section-btn:hover {
  background: var(--accent); color: var(--paper);
  border-style: solid;
}

.status-badge {
  padding: 3px 10px; border-radius: 999px; font-size: 11px; font-weight: 600;
  letter-spacing: .3px;
}
.status-badge.pass { background: var(--good-soft); color: var(--good); border: 1px solid rgba(91, 140, 106, .25); }
.status-badge.fail { background: var(--bad-soft); color: var(--bad); border: 1px solid rgba(182, 85, 85, .25); }
.status-badge.new { background: var(--bg2); color: var(--muted); border: 1px solid var(--border); }
.status-badge.final {
  background: linear-gradient(135deg, var(--warn), #e4b473);
  color: #fff; border: 1px solid var(--warn);
  font-weight: 700; letter-spacing: .5px;
}

.cumulative-card {
  margin-top: 18px;
  border: 2px solid var(--a1, var(--accent));
  position: relative;
  background: linear-gradient(to right, var(--paper) 0%, var(--accent-soft) 100%);
  overflow: visible;
}
.cumulative-card { margin-top: 26px; }
.cumulative-card::before {
  content: 'CUMULATIVE TEST';
  position: absolute; top: -11px; left: 16px;
  font-size: 10px; font-weight: 700; letter-spacing: .4px;
  background: var(--paper); padding: 4px 14px;
  color: var(--a1, var(--accent));
  border: 1px solid var(--a1, var(--accent));
  border-radius: 999px;
  line-height: 1;
  white-space: nowrap;
}
.cumulative-card .num.cum-star {
  background: var(--warn); color: #fff;
  font-size: 16px;
}
.cumulative-card .title { font-family: var(--serif); font-weight: 600; font-size: 16px; }
.cum-sub { font-size: 12px; color: var(--muted); font-weight: 400; font-family: var(--font); margin-top: 2px; font-style: italic; }
.cum-btn {
  background: var(--text) !important; color: var(--paper) !important;
  border-color: var(--text) !important;
}
.cum-btn:hover { background: #2a2e46 !important; border-color: #2a2e46 !important; color: var(--paper) !important; }

.start-btn {
  background: var(--paper); border: 1px solid var(--border);
  color: var(--text); padding: 8px 16px; border-radius: 999px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  font-family: var(--font);
}
.start-btn:hover { background: var(--text); color: var(--paper); border-color: var(--text); }

.q-type {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: 11px; font-weight: 600; letter-spacing: .3px;
  margin-bottom: 14px;
}
.q-type.regular { background: var(--accent-soft); color: var(--accent); }
.q-type.word { background: var(--good-soft); color: var(--good); }

/* QUIZ */
.quiz-shell { max-width: 720px; margin: 0 auto; }
/* Hide the site footer while a quiz question is active so students aren't
   tempted to scroll into the marketing/legal links mid-answer. .quiz-shell
   is only rendered by renderQuizQuestion; the results card uses a
   different wrapper so the footer reappears once the quiz finishes. */
body:has(.quiz-shell) .site-footer { display: none; }
.quiz-top { margin-bottom: 22px; }
.quiz-meta { display: flex; justify-content: space-between; margin-bottom: 10px; }
.quiz-section-name { font-weight: 600; font-size: 15px; color: var(--text); font-family: var(--serif); }
.quiz-progress-text { color: var(--muted); font-size: 13px; }
.quiz-progress-bar {
  height: 4px; border-radius: 999px;
  background: var(--bg2); overflow: hidden;
}
.quiz-progress-bar > div {
  height: 100%; background: var(--a1, var(--accent));
  transition: width .4s ease-out;
}

.quiz-card {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 40px; position: relative; overflow: hidden;
  box-shadow: var(--shadow);
}
.quiz-card::before {
  content: ''; position: absolute; inset: 0 0 auto 0; height: 3px;
  background: var(--a1, var(--accent));
}

.quiz-q {
  font-size: 19px; font-weight: 400; line-height: 1.55; margin-bottom: 24px;
  color: var(--text);
}
.quiz-label {
  display: block; font-size: 12px; letter-spacing: .3px;
  color: var(--muted); font-weight: 600; margin-bottom: 8px;
}
.quiz-input {
  width: 100%; background: var(--bg); border: 1px solid var(--border);
  color: var(--text); padding: 14px 16px; border-radius: 10px;
  font-family: var(--font); font-size: 15px; resize: vertical;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.quiz-input:focus {
  outline: none; border-color: var(--accent); background: var(--paper);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.quiz-input:disabled { opacity: .75; cursor: default; background: var(--bg2); }

.quiz-actions { margin-top: 20px; display: flex; gap: 10px; flex-wrap: wrap; }

.reveal-block {
  margin-top: 20px; padding: 20px; border-radius: 10px;
  background: var(--bg); border: 1px solid var(--border);
  transition: background .25s, border-color .25s;
}
.reveal-block.good { background: var(--good-soft); border-color: rgba(91, 140, 106, .3); }
.reveal-block.bad { background: var(--bad-soft); border-color: rgba(182, 85, 85, .3); }

.verdict {
  font-family: var(--serif);
  font-size: 22px; font-weight: 500; margin-bottom: 14px; letter-spacing: -.3px;
}
.verdict.good { color: var(--good); }
.verdict.bad { color: var(--bad); }
.verdict.small { font-size: 14px; margin-top: 10px; margin-bottom: 0; }

.reveal-row { display: flex; gap: 12px; padding: 5px 0; align-items: baseline; }
.reveal-row .lbl {
  flex: 0 0 130px; font-size: 11px; letter-spacing: .3px;
  color: var(--muted); font-weight: 600;
}
.reveal-row .val { flex: 1; font-size: 15px; color: var(--text); }
.reveal-row .val.correct { color: var(--good); font-weight: 500; }

.override-btn {
  margin-top: 12px; background: transparent;
  border: 1px dashed var(--border-strong); color: var(--muted);
  padding: 8px 14px; border-radius: 8px; font-size: 12px;
  cursor: pointer; font-family: var(--font);
  transition: background .15s, color .15s, border-color .15s;
}
.override-btn:hover { background: var(--paper); color: var(--text); border-color: var(--text); }

.q-btn {
  background: var(--paper); border: 1px solid var(--border);
  color: var(--text-soft); padding: 10px 18px; border-radius: 999px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
  font-family: var(--font);
}
.q-btn:hover { background: var(--bg2); border-color: var(--border-strong); color: var(--text); }

.self-marked { font-size: 13px; font-weight: 500; padding: 10px 0; }
.self-marked.right { color: var(--good); }
.self-marked.wrong { color: var(--bad); }

/* RESULTS */
.results-card {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 56px 48px; text-align: center;
  position: relative; overflow: hidden; box-shadow: var(--shadow);
}
.results-card::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
}
.results-card.pass::before { background: var(--good); }
.results-card.fail::before { background: var(--bad); }

.grade-big {
  font-family: var(--serif);
  font-size: 110px; font-weight: 400; line-height: 1;
  margin-bottom: 10px; letter-spacing: -3px;
  color: var(--text);
}
.results-card.pass .grade-big { color: var(--good); }
.results-card.fail .grade-big { color: var(--bad); }

.results-score { font-family: var(--serif); font-size: 26px; font-weight: 500; margin-bottom: 4px; color: var(--text); }
.results-pct { color: var(--muted); font-size: 15px; margin-bottom: 20px; }
.results-title { font-size: 16px; font-weight: 500; margin-bottom: 10px; color: var(--text-soft); }
.results-msg {
  color: var(--muted); font-size: 15px; margin-bottom: 28px;
  max-width: 440px; margin-left: auto; margin-right: auto; line-height: 1.6;
}
.results-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* MODAL */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(30, 34, 56, 0.35);
  backdrop-filter: blur(4px); z-index: 100;
  animation: fadeIn .25s ease;
}
.modal {
  position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%);
  width: min(92vw, 640px); max-height: 88vh; overflow-y: auto;
  background: var(--paper); border: 1px solid var(--border);
  border-radius: var(--radius); z-index: 101;
  box-shadow: var(--shadow-lg);
  animation: popIn .3s cubic-bezier(.2,.9,.3,1.1);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes popIn {
  from { opacity: 0; transform: translate(-50%, -46%) scale(.96); }
  to { opacity: 1; transform: translate(-50%, -50%) scale(1); }
}

.modal::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
  background: var(--accent);
  border-radius: var(--radius) var(--radius) 0 0;
}

.modal-close {
  position: absolute; top: 14px; right: 14px;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--bg); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; font-size: 13px;
  display: grid; place-items: center; transition: background .15s, color .15s;
}
.modal-close:hover { background: var(--bg2); color: var(--text); }

.modal-content { padding: 32px 34px 28px; }

.tutor-row { display: flex; align-items: center; gap: 14px; margin-bottom: 22px; }
.tutor-avatar {
  width: 52px; height: 52px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 26px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  border: 1px solid rgba(74, 111, 165, .15);
}
.tutor-avatar.big { width: 68px; height: 68px; font-size: 34px; margin: 0 auto 16px; }

.tutor-name { font-family: var(--serif); font-weight: 600; font-size: 17px; color: var(--text); }
.tutor-sub { color: var(--muted); font-size: 13px; }

.modal-content h2 {
  font-family: var(--serif);
  font-size: 24px; font-weight: 500; letter-spacing: -.3px;
  margin: 10px 0 8px; color: var(--text);
}
.tutor-text { color: var(--muted); font-size: 15px; margin-bottom: 18px; line-height: 1.6; }

.modal-qblock {
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin-bottom: 12px;
}
.modal-qblock .lbl {
  font-size: 10px; letter-spacing: .4px; color: var(--muted);
  text-transform: uppercase; font-weight: 600; margin-bottom: 6px;
  display: block;
}
.modal-q { font-size: 15px; line-height: 1.55; color: var(--text); }
.modal-qblock.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-qblock.two-col > div {
  padding: 12px 14px; border-radius: 8px;
  background: var(--paper); border: 1px solid var(--border);
}
.modal-you { color: var(--bad); font-weight: 500; font-size: 14px; word-break: break-word; }
.modal-correct { color: var(--good); font-weight: 500; font-size: 14px; word-break: break-word; }

.tutor-bubble {
  background: var(--accent-soft);
  border: 1px solid rgba(74, 111, 165, .2);
  border-left: 3px solid var(--accent);
  border-radius: 10px; padding: 18px 20px; margin-top: 8px;
}
.tutor-bubble p { margin-bottom: 12px; font-size: 14.5px; line-height: 1.65; color: var(--text); }
.tutor-bubble p:last-child { margin-bottom: 0; }
.walkthrough { font-size: 14.5px; line-height: 1.7; color: var(--text); margin: 6px 0; }

.fix-section { margin-top: 14px; padding: 14px 16px; background: var(--paper); border-radius: 10px; border: 1px solid var(--border); }
.fix-section + .fix-section { margin-top: 10px; }
.fix-heading { font-size: 11px; font-weight: 700; letter-spacing: .4px; text-transform: uppercase; color: var(--muted); margin-bottom: 8px; }
.fix-list { margin-left: 20px; font-size: 14px; line-height: 1.7; color: var(--text); }
.fix-list li { margin-bottom: 5px; }
.fix-list li:last-child { margin-bottom: 0; }
.final-line { font-size: 14px; margin-top: 12px; color: var(--text); }
.final-line .lbl { color: var(--muted); font-size: 11px; letter-spacing: .3px; text-transform: uppercase; font-weight: 600; margin-right: 6px; }

.why-input {
  width: 100%; margin-top: 10px;
  padding: 12px 14px; border-radius: 10px;
  background: var(--paper); border: 1px solid var(--border);
  color: var(--text); font-size: 14.5px;
  font-family: var(--font); line-height: 1.5;
  resize: vertical;
  transition: border-color .15s, box-shadow .15s;
}
.why-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.why-actions { display: flex; gap: 10px; margin-top: 12px; flex-wrap: wrap; }
.why-submit { padding: 10px 22px; font-size: 13px; }

.why-options { display: grid; gap: 8px; margin-top: 10px; }
.why-btn {
  text-align: left; padding: 12px 15px; border-radius: 10px;
  background: var(--paper); border: 1px solid var(--border);
  color: var(--text); font-size: 14px; cursor: pointer;
  font-family: var(--font); transition: background .15s, border-color .15s, transform .1s;
}
.why-btn:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
  transform: translateX(2px);
}

.modal-actions { display: flex; gap: 10px; margin-top: 20px; flex-wrap: wrap; }

/* FOOTER */
footer {
  text-align: center; padding: 40px 20px; color: var(--muted); font-size: 13px;
  border-top: 1px solid var(--border); margin-top: 60px;
  background: var(--paper);
}

/* AI bits */
.ai-tag {
  display: inline-block; margin-left: 10px;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid rgba(74, 111, 165, .2);
  font-weight: 600; letter-spacing: .3px; vertical-align: middle;
}
.ai-note {
  margin-top: 12px; padding: 10px 14px; border-radius: 8px;
  background: var(--paper); border: 1px solid var(--border);
  font-size: 13.5px; color: var(--text-soft);
}
.ai-err {
  color: var(--bad); font-size: 13px; margin-top: 10px;
  padding: 8px 12px; background: var(--bad-soft);
  border-radius: 8px; border: 1px solid rgba(182, 85, 85, .25);
}
.ai-tag-row {
  font-size: 11px; color: var(--muted); font-weight: 600;
  letter-spacing: .3px; text-transform: uppercase; margin-bottom: 10px;
}
.ai-bubble .ai-output { font-size: 14.5px; line-height: 1.7; color: var(--text); }
.ai-output h2, .ai-output h3, .ai-output h4 { margin: 12px 0 6px; font-weight: 600; font-family: var(--serif); color: var(--text); }
.ai-output h4 { font-size: 14px; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; font-family: var(--font); }
.ai-output p { margin-bottom: 10px; }
.ai-output ol, .ai-output ul { margin: 8px 0 10px 22px; }
.ai-output li { margin-bottom: 4px; }
.ai-output code {
  background: var(--bg2); padding: 2px 6px; border-radius: 4px;
  font-size: 13px; font-family: 'SF Mono', Consolas, monospace;
  color: var(--accent2);
}

.grading-spinner {
  display: flex; align-items: center; gap: 12px;
  color: var(--muted); font-size: 14px; padding: 8px 0;
}
.spinner {
  width: 16px; height: 16px; border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.typing { display: inline-flex; gap: 4px; padding: 4px 0; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); opacity: .5;
  animation: bounce 1.2s infinite ease-in-out;
}
.typing span:nth-child(2) { animation-delay: .15s; }
.typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

.hint { margin-top: 14px; font-size: 12px; color: var(--muted); }

.gen-tag {
  display: inline-block; margin-left: 8px;
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--accent);
  border: 1px solid rgba(74, 111, 165, .25);
  font-weight: 500;
}
.gen-tag.good { background: var(--good-soft); color: var(--good); border-color: rgba(91, 140, 106, .3); }

.gen-banner {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px; margin-bottom: 16px;
  background: var(--accent-soft); border: 1px solid rgba(74, 111, 165, .25);
  border-radius: 10px; color: var(--accent);
  font-size: 13.5px; font-weight: 500;
}
.ai-err-inline { color: var(--bad); font-size: 13px; }

/* FAB */
.ask-fab {
  position: fixed; bottom: 24px; right: 24px; z-index: 30;
  display: flex; align-items: center; gap: 10px;
  padding: 13px 22px; border-radius: 999px;
  background: var(--text); color: var(--paper);
  border: none; font-family: var(--font);
  font-weight: 500; font-size: 14px; cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .2s, background .2s;
}
.ask-fab:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); background: #2a2e46; }
.ask-fab .fab-icon { font-size: 18px; }

/* ===================== STUDY PAGE ===================== */
.study-page {
  max-width: 820px; margin: 0 auto; padding: 32px 24px 80px;
}
.study-page.hidden { display: none; }
.study-hero {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: 16px; padding: 32px;
  margin-bottom: 28px;
  border-left: 4px solid var(--a1, var(--accent));
}
.study-eyebrow {
  font-size: 12px; font-weight: 600; color: var(--a1, var(--accent));
  text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 10px;
}
.study-title-h1 {
  font-family: var(--serif); font-weight: 500;
  font-size: 32px; letter-spacing: -.4px;
  color: var(--text); margin: 0 0 12px;
}
.study-blurb {
  color: var(--text-soft); font-size: 15px; line-height: 1.6;
  margin: 0 0 18px;
}
.study-cta-row { display: flex; gap: 10px; flex-wrap: wrap; }
.study-section {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px;
  margin-bottom: 20px;
}
.study-h2 {
  font-family: var(--serif); font-weight: 500;
  font-size: 22px; color: var(--text);
  margin: 0 0 8px;
}
.study-section-sub {
  font-size: 13px; color: var(--muted); margin: 0 0 18px;
}
.study-lesson {
  font-size: 15px; line-height: 1.7; color: var(--text);
}
.study-lesson h1, .study-lesson h2, .study-lesson h3 {
  font-family: var(--serif); font-weight: 600;
  color: var(--text); margin: 18px 0 8px;
}
.study-lesson h3 { font-size: 17px; }
.study-lesson p { margin: 0 0 12px; }
.study-lesson ul, .study-lesson ol { margin: 0 0 12px 24px; }
.study-lesson li { margin-bottom: 4px; }
.study-lesson code {
  background: var(--card-hi); padding: 2px 5px; border-radius: 4px;
  font-family: 'Courier New', monospace; font-size: 13px;
}
.study-lesson pre {
  background: var(--card-hi); border: 1px solid var(--border);
  border-radius: 8px; padding: 14px;
  overflow-x: auto; margin: 12px 0;
  font-size: 13px; line-height: 1.5;
}
.study-lesson pre code { background: transparent; padding: 0; }
.study-lesson table {
  border-collapse: collapse; margin: 12px 0;
  font-size: 14px; width: 100%;
}
.study-lesson th, .study-lesson td {
  border: 1px solid var(--border); padding: 6px 10px; text-align: left;
}
.study-lesson th { background: var(--card-hi); font-weight: 600; }

.study-questions { display: flex; flex-direction: column; gap: 14px; }
.study-q-card {
  display: flex; gap: 14px; padding: 18px;
  border: 1px solid var(--border); border-radius: 12px;
  background: var(--card-hi);
}
.study-q-num {
  flex-shrink: 0; width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent); color: var(--paper);
  display: grid; place-items: center;
  font-weight: 600; font-size: 13px;
}
.study-q-body { flex: 1; min-width: 0; }
.study-q-text {
  font-size: 15px; line-height: 1.55; color: var(--text);
  margin-bottom: 10px;
}
.study-q-solution {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px;
  font-size: 14px; color: var(--text-soft);
  margin-bottom: 8px;
}
.study-q-solution summary {
  cursor: pointer; font-weight: 600; color: var(--accent);
  list-style: none; font-size: 13px;
  user-select: none;
}
.study-q-solution summary::-webkit-details-marker { display: none; }
.study-q-solution[open] summary { margin-bottom: 8px; }
.study-q-answer { margin-bottom: 6px; }
.study-q-explain { color: var(--muted); font-size: 13px; }
.study-q-ask {
  background: transparent; border: 1px dashed var(--accent);
  color: var(--accent); padding: 6px 12px; border-radius: 6px;
  font-family: var(--font); font-size: 12px; font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.study-q-ask:hover { background: var(--accent); color: var(--paper); }
.study-footer { text-align: center; margin-top: 28px; }

/* ===================== LANDING PAGE ===================== */
.landing { max-width: 1100px; margin: 0 auto; padding: 0 24px 80px; }
.landing.hidden { display: none; }

.landing-hero {
  padding: 80px 0 64px; text-align: center;
}
.landing-eyebrow {
  display: inline-block; padding: 6px 14px;
  border-radius: 999px; background: var(--accent-soft);
  color: var(--accent); font-weight: 600; font-size: 12px;
  letter-spacing: .3px; margin-bottom: 28px;
}
.landing-h1 {
  font-family: var(--serif); font-weight: 500;
  font-size: clamp(40px, 6vw, 64px); line-height: 1.08;
  letter-spacing: -1.5px; color: var(--text);
  margin: 0 0 24px;
}
.landing-h1 em { color: var(--accent); font-style: italic; }
.landing-lede {
  font-size: 18px; line-height: 1.6; color: var(--text-soft);
  max-width: 640px; margin: 0 auto 36px;
}
.landing-cta-row {
  display: flex; gap: 12px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 12px;
}
.landing-cta-sub {
  font-size: 13px; color: var(--muted);
}
.cta-primary {
  background: var(--text); color: var(--paper);
  border: 1px solid var(--text);
  padding: 14px 28px; border-radius: 999px;
  font-family: var(--font); font-weight: 600; font-size: 15px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(30, 34, 56, 0.15);
  transition: transform .15s, box-shadow .2s, background .2s;
}
.cta-primary:hover {
  background: #2a2e46;
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(30, 34, 56, 0.22);
}
.cta-secondary {
  background: var(--paper); color: var(--text);
  border: 1px solid var(--border-strong);
  padding: 14px 28px; border-radius: 999px;
  font-family: var(--font); font-weight: 600; font-size: 15px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.cta-secondary:hover { border-color: var(--text); background: var(--card-hi); }
.cta-full { display: block; width: 100%; margin-top: 18px; }

.landing-stats {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 24px; padding: 40px 32px;
  background: var(--card-hi); border: 1px solid var(--border);
  border-radius: 18px; margin-bottom: 80px;
}
.landing-stats .stat { text-align: center; }
.landing-stats .stat-num {
  font-family: var(--serif); font-size: 36px; font-weight: 600;
  color: var(--text); margin-bottom: 4px;
}
.landing-stats .stat-label {
  font-size: 13px; color: var(--muted); text-transform: uppercase;
  letter-spacing: .8px;
}
@media (max-width: 720px) {
  .landing-stats { grid-template-columns: repeat(2, 1fr); }
}

.landing-grade { padding: 0 0 80px; }
.landing-section-sub {
  text-align: center; color: var(--text-soft); font-size: 15px;
  margin: -32px auto 32px; max-width: 540px;
}
.grade-grid {
  display: grid; grid-template-columns: repeat(4, 1fr);
  gap: 14px; margin-bottom: 24px;
}
.grade-card {
  position: relative;
  background: var(--paper); border: 1px solid var(--border);
  border-radius: 14px; padding: 22px 18px 22px 22px;
  cursor: pointer; text-align: left;
  font-family: var(--font); color: var(--text);
  transition: border-color .15s, transform .2s, box-shadow .2s, background .15s;
}
.grade-card:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.grade-card .grade-num {
  font-family: var(--serif); font-weight: 600; font-size: 38px;
  line-height: 1; color: var(--accent);
  margin-bottom: 2px;
}
.grade-card .grade-label {
  font-size: 11px; color: var(--muted);
  text-transform: uppercase; letter-spacing: .8px;
  margin-bottom: 10px;
}
.grade-card .grade-course {
  font-weight: 600; font-size: 14px; color: var(--text);
}
.grade-card .grade-arrow {
  position: absolute; top: 18px; right: 18px;
  font-size: 18px; color: var(--muted);
  transition: transform .2s, color .15s;
}
.grade-card:hover .grade-arrow {
  color: var(--accent); transform: translateX(4px);
}
.grade-card-ap { background: linear-gradient(135deg, var(--paper) 0%, var(--accent-soft) 100%); border-color: var(--warn); }
.grade-card-ap .grade-num { color: var(--warn); }
.grade-card-ap:hover { border-color: var(--warn); }
.grade-cta { text-align: center; margin-top: 24px; }
@media (max-width: 900px) {
  .grade-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 480px) {
  .grade-grid { grid-template-columns: 1fr; }
}

.landing-features { padding: 0 0 80px; }
.landing-h2 {
  font-family: var(--serif); font-weight: 500;
  font-size: 32px; letter-spacing: -.5px;
  text-align: center; color: var(--text); margin: 0 0 48px;
}
.features-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 24px;
}
.feature {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: 14px; padding: 28px 24px;
  transition: border-color .15s, transform .2s, box-shadow .2s;
}
.feature:hover {
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: var(--shadow);
}
.feature-icon { font-size: 32px; margin-bottom: 14px; }
.feature h3 {
  font-family: var(--serif); font-weight: 600; font-size: 18px;
  margin: 0 0 8px; color: var(--text);
}
.feature p {
  font-size: 14px; line-height: 1.6; color: var(--text-soft); margin: 0;
}
@media (max-width: 900px) {
  .features-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 600px) {
  .features-grid { grid-template-columns: 1fr; }
}

.landing-how { padding: 0 0 80px; }
.how-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 28px;
}
.how-step { text-align: center; padding: 0 12px; }
.how-num {
  width: 48px; height: 48px; border-radius: 50%;
  background: var(--accent); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; font-size: 20px;
  margin: 0 auto 16px;
}
.how-step h3 {
  font-family: var(--serif); font-weight: 600; font-size: 18px;
  margin: 0 0 8px; color: var(--text);
}
.how-step p {
  font-size: 14px; line-height: 1.6; color: var(--text-soft); margin: 0;
}
@media (max-width: 720px) {
  .how-grid { grid-template-columns: 1fr; }
}

.landing-pricing { padding: 0 0 80px; }
.pricing-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 24px; max-width: 940px; margin: 0 auto;
}
@media (max-width: 800px) { .pricing-grid { grid-template-columns: 1fr; } }
.pricing-card {
  background: var(--paper);
  border: 2px solid var(--border);
  border-radius: 18px; padding: 36px 32px;
  text-align: center;
  box-shadow: var(--shadow-sm);
  display: flex; flex-direction: column;
}
.pricing-card-pro {
  background: linear-gradient(135deg, var(--paper) 0%, var(--accent-soft) 100%);
  border-color: var(--accent);
  box-shadow: var(--shadow);
  position: relative;
}
.pricing-card-free { border-color: var(--border); }

.pricing-toggle {
  display: inline-grid; grid-template-columns: 1fr 1fr;
  background: var(--bg2); padding: 4px; border-radius: 999px;
  gap: 4px; margin-bottom: 16px; align-self: center;
}
.pricing-toggle-btn {
  padding: 7px 16px; border-radius: 999px;
  background: transparent; border: none;
  font-family: var(--font); font-size: 13px; font-weight: 600;
  color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.pricing-toggle-btn.active {
  background: var(--paper); color: var(--text);
  box-shadow: var(--shadow-sm);
}
.pricing-toggle-btn .pricing-save {
  display: inline-block; margin-left: 6px;
  background: var(--good); color: var(--paper);
  padding: 1px 7px; border-radius: 999px;
  font-size: 10px; font-weight: 700;
}
.pricing-fine {
  font-size: 11.5px; color: var(--muted); margin-top: 12px; line-height: 1.4;
}
.pricing-badge-pro { background: var(--accent); }

/* UPGRADE OVERLAY (modal when a free user hits a Pro feature) */
.upgrade-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.upgrade-overlay.hidden { display: none; }
.upgrade-card {
  background: var(--paper); border: 2px solid var(--accent);
  border-radius: 18px; padding: 36px 32px 28px;
  width: 100%; max-width: 440px; position: relative;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.upgrade-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent; border: none;
  font-size: 16px; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.upgrade-close:hover { background: var(--bg2); color: var(--text); }
.upgrade-emoji { font-size: 40px; margin-bottom: 8px; }
.upgrade-title {
  font-family: var(--serif); font-weight: 500; font-size: 26px;
  margin: 0 0 8px; color: var(--text);
}
.upgrade-title em { color: var(--accent); font-style: italic; }
.upgrade-sub { color: var(--text-soft); font-size: 14px; line-height: 1.6; margin: 0 0 18px; }
.upgrade-card .pricing-toggle { margin: 0 auto 14px; display: inline-grid; }
.upgrade-amount {
  font-family: var(--serif); font-weight: 600;
  font-size: 44px; color: var(--text); line-height: 1;
  margin-bottom: 16px;
}
.upgrade-amount span { font-size: 16px; color: var(--muted); font-weight: 500; font-family: var(--font); }
.upgrade-list {
  list-style: none; padding: 0; margin: 0 0 18px;
  text-align: left; display: inline-block;
}
.upgrade-list li { font-size: 14px; line-height: 1.7; color: var(--text-soft); }
.upgrade-fine { font-size: 11.5px; color: var(--muted); margin-top: 10px; }
.pricing-badge {
  display: inline-block; padding: 4px 12px;
  border-radius: 999px; background: var(--accent);
  color: var(--paper); font-size: 11px; font-weight: 700;
  letter-spacing: .8px; text-transform: uppercase;
  margin-bottom: 18px;
}
.pricing-amount {
  font-family: var(--serif); font-weight: 600;
  font-size: 56px; color: var(--text); line-height: 1;
}
.pricing-amount span {
  font-size: 18px; color: var(--muted); font-weight: 500;
  font-family: var(--font);
}
.pricing-trial {
  font-size: 13px; color: var(--muted); margin: 8px 0 22px;
}
.pricing-list {
  list-style: none; padding: 0; margin: 0 0 8px;
  text-align: left; display: inline-block;
}
.pricing-list li {
  font-size: 14px; line-height: 1.7; color: var(--text-soft);
}

/* TESTIMONIALS */
.landing-testimonials { padding: 0 0 80px; }
.testimonial-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 22px; }
.testimonial {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: 14px; padding: 26px; position: relative; margin: 0;
  transition: border-color .15s, transform .2s, box-shadow .2s;
}
.testimonial:hover { border-color: var(--accent); transform: translateY(-3px); box-shadow: var(--shadow); }
.testimonial::before {
  content: '"'; position: absolute; top: 8px; left: 16px;
  font-family: var(--serif); font-size: 56px; color: var(--accent-soft);
  line-height: 1; pointer-events: none;
}
.testimonial blockquote {
  font-size: 14.5px; line-height: 1.65; color: var(--text);
  margin: 0 0 18px; padding-top: 18px; position: relative; z-index: 1;
}
.testimonial figcaption { display: flex; align-items: center; gap: 12px; }
.testi-avatar {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--accent); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; font-size: 15px; flex-shrink: 0;
}
.testi-name { font-weight: 600; font-size: 14px; color: var(--text); }
.testi-meta { font-size: 12px; color: var(--muted); }
@media (max-width: 900px) { .testimonial-grid { grid-template-columns: 1fr; } }

/* FAQ */
.landing-faq { padding: 0 0 80px; max-width: 720px; margin: 0 auto; }
.faq-list { display: flex; flex-direction: column; gap: 10px; }
.faq-item {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: 12px; padding: 18px 22px;
  transition: border-color .15s;
}
.faq-item[open] { border-color: var(--accent); }
.faq-item summary {
  cursor: pointer; list-style: none; font-weight: 600;
  font-size: 15px; color: var(--text);
  display: flex; justify-content: space-between; align-items: center;
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+'; font-size: 20px; color: var(--accent); font-weight: 300;
  transition: transform .2s;
}
.faq-item[open] summary::after { content: '−'; }
.faq-item p { margin: 12px 0 0; font-size: 14px; line-height: 1.65; color: var(--text-soft); }
.faq-item p a { color: var(--accent); }

/* SITE FOOTER */
.site-footer {
  margin-top: 80px; padding: 56px 0 24px;
  border-top: 1px solid var(--border); color: var(--text-soft);
  background: var(--card-hi);
}
.footer-grid {
  max-width: 1100px; margin: 0 auto; padding: 0 24px;
  display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 40px;
}
.footer-col-title {
  font-weight: 700; font-size: 12px; letter-spacing: .8px;
  text-transform: uppercase; color: var(--text); margin-bottom: 14px;
}
.footer-col a {
  display: block; color: var(--text-soft); text-decoration: none;
  font-size: 14px; padding: 5px 0; transition: color .15s;
}
.footer-col a:hover { color: var(--accent); }
.footer-brand .footer-logo { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.footer-logo-dot {
  width: 36px; height: 36px; border-radius: 9px;
  background: var(--text); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--serif); font-weight: 700; font-size: 18px;
}
.footer-logo-text { font-family: var(--serif); font-weight: 600; font-size: 18px; color: var(--text); }
.footer-tagline {
  font-size: 14px; line-height: 1.6; margin: 0 0 18px;
  max-width: 320px; color: var(--text-soft);
}
.footer-social { display: flex; gap: 10px; flex-wrap: wrap; }
.footer-social a {
  display: grid; place-items: center;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--paper); border: 1px solid var(--border);
  font-size: 16px; padding: 0;
  transition: background .15s, transform .15s, border-color .15s;
}
.footer-social a:hover {
  background: var(--accent); border-color: var(--accent);
  transform: translateY(-2px);
}

/* "Email us" button — a pill with icon-left, text-right (vs the round
   social icons next to it). Lives inside .footer-social. */
.footer-email-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 36px; padding: 0 16px 0 12px;
  border-radius: 999px;
  background: var(--paper); border: 1px solid var(--border);
  color: var(--text); font-family: var(--font);
  font-size: 13px; font-weight: 500;
  cursor: pointer; line-height: 1;
  transition: background .15s, border-color .15s, transform .15s, color .15s;
}
.footer-email-btn:hover {
  background: var(--accent); border-color: var(--accent); color: var(--paper);
  transform: translateY(-2px);
}
.footer-email-icon { font-size: 15px; line-height: 1; }
.footer-email-text { font-weight: 500; }

/* ===== Email-us modal ===== */
.email-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.email-overlay.hidden { display: none; }
.email-card {
  background: var(--paper); border: 1px solid var(--border-strong);
  border-radius: 18px; padding: 36px 32px 28px;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow-lg);
  text-align: center; position: relative;
}
.email-close {
  position: absolute; top: 12px; right: 12px;
  width: 32px; height: 32px; border-radius: 50%;
  background: transparent; border: none;
  font-size: 16px; color: var(--muted); cursor: pointer;
  transition: background .15s, color .15s;
}
.email-close:hover { background: var(--bg2); color: var(--text); }
.email-emoji { font-size: 40px; margin-bottom: 8px; }
.email-title {
  font-family: var(--serif); font-weight: 500; font-size: 24px;
  color: var(--text); margin: 0 0 6px;
}
.email-sub {
  color: var(--muted); font-size: 13.5px; line-height: 1.5;
  margin: 0 0 20px;
}
.email-address {
  display: block; padding: 14px 18px;
  background: var(--card-hi); border: 1px solid var(--border);
  border-radius: 10px;
  font-family: 'Courier New', monospace; font-size: 17px; font-weight: 600;
  color: var(--text); text-decoration: none;
  margin-bottom: 16px;
  word-break: break-all;
}
.email-address:hover { background: var(--accent-soft); border-color: var(--accent); }
.email-actions { display: flex; gap: 8px; }
.email-actions > * { flex: 1; padding-left: 14px; padding-right: 14px; font-size: 13px; }
.email-copy-hint {
  margin-top: 12px; font-size: 12px; color: var(--good); font-weight: 600;
}
.email-copy-hint.hidden { display: none; }
.footer-bottom {
  max-width: 1100px; margin: 40px auto 0; padding: 24px 24px 0;
  border-top: 1px solid var(--border);
  display: flex; justify-content: space-between; align-items: center;
  font-size: 12px; color: var(--muted); flex-wrap: wrap; gap: 12px;
}
@media (max-width: 800px) {
  .footer-grid { grid-template-columns: 1fr 1fr; }
  .footer-brand { grid-column: 1 / -1; }
}
@media (max-width: 480px) {
  .footer-grid { grid-template-columns: 1fr; }
  .footer-bottom { flex-direction: column; }
}

/* INFO PAGES (Privacy, Terms, Contact) */
.info-page { max-width: 760px; margin: 0 auto; padding: 40px 24px 80px; }
.info-page.hidden { display: none; }
.info-hero {
  text-align: center; padding: 40px 0 32px;
  border-bottom: 1px solid var(--border); margin-bottom: 36px;
}
.info-hero h1 {
  font-family: var(--serif); font-weight: 500; font-size: 36px;
  letter-spacing: -.5px; margin: 14px 0 8px; color: var(--text);
}
.info-hero h1 em { color: var(--accent); font-style: italic; }
.info-page .back-btn { margin-bottom: 16px; }

/* CONTACT FORM */
.contact-form { display: flex; flex-direction: column; gap: 14px; margin-top: 20px; }
.contact-form label {
  display: flex; flex-direction: column; gap: 6px;
  font-size: 13px; font-weight: 600; color: var(--text);
}
.contact-form input, .contact-form select, .contact-form textarea {
  padding: 10px 12px; border-radius: 8px; border: 1px solid var(--border-strong);
  font-family: var(--font); font-size: 14px; color: var(--text);
  background: var(--paper); width: 100%; box-sizing: border-box;
}
.contact-form input:focus, .contact-form select:focus, .contact-form textarea:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.contact-form textarea { resize: vertical; min-height: 120px; font-family: var(--font); }

/* NAV SEARCH */
.nav-search {
  padding: 7px 12px; border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--paper); color: var(--text);
  font-family: var(--font); font-size: 13px; width: 180px;
  transition: width .25s, border-color .15s, box-shadow .15s;
}
.nav-search:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  width: 240px;
}
@media (max-width: 720px) { .nav-search { display: none; } }

/* THEME TOGGLE */
.theme-toggle {
  width: 34px; height: 34px; border-radius: 50%;
  background: var(--paper); border: 1px solid var(--border-strong);
  font-size: 15px; cursor: pointer; padding: 0;
  display: grid; place-items: center;
  transition: background .15s, border-color .15s, transform .15s;
}
.theme-toggle:hover { background: var(--card-hi); transform: rotate(15deg); }

/* BACK TO TOP */
.back-to-top {
  position: fixed; bottom: 24px; left: 24px; z-index: 25;
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--text); color: var(--paper);
  border: none; font-size: 18px; font-weight: 700; cursor: pointer;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s, background .15s;
}
.back-to-top.visible { opacity: 1; pointer-events: auto; }
.back-to-top:hover { background: #2a2e46; transform: translateY(-2px); }
.back-to-top.hidden { display: none; }

/* SKIP LINK (accessibility) */
.skip-link {
  position: absolute; top: -100px; left: 0;
  background: var(--text); color: var(--paper);
  padding: 10px 16px; border-radius: 0 0 8px 0;
  text-decoration: none; font-weight: 600; font-size: 14px;
  z-index: 1000; transition: top .15s;
}
.skip-link:focus { top: 0; outline: 2px solid var(--accent); outline-offset: 2px; }

/* Nav "Sign in" CTA */
.nav-cta {
  background: var(--text); color: var(--paper);
  border: 1px solid var(--text);
  padding: 7px 16px; border-radius: 999px;
  font-family: var(--font); font-weight: 600; font-size: 13px;
  cursor: pointer; transition: background .15s;
}
.nav-cta:hover { background: #2a2e46; }
.nav-cta.hidden { display: none; }

/* AUTH GATE */
.auth-gate {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(247, 245, 240, 0.96);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
}
.auth-gate.hidden { display: none; }
.auth-card {
  background: var(--paper); border: 1px solid var(--border);
  border-radius: 16px; padding: 40px 36px;
  width: 100%; max-width: 420px;
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.auth-mark {
  width: 56px; height: 56px; border-radius: 12px;
  background: var(--text); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 24px; font-weight: 700;
  margin: 0 auto 18px;
}
.auth-title {
  font-family: var(--serif); font-weight: 500;
  font-size: 24px; margin: 0 0 8px; color: var(--text);
}
.auth-sub {
  color: var(--muted); font-size: 14px; line-height: 1.55;
  margin: 0 0 22px;
}
.auth-form { display: flex; flex-direction: column; gap: 10px; }
.auth-form.hidden { display: none; }
.auth-form input {
  width: 100%; padding: 12px 14px; border-radius: 10px;
  border: 1px solid var(--border-strong);
  font-family: var(--font); font-size: 14px; color: var(--text);
  background: var(--paper); box-sizing: border-box;
}
.auth-form input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
#authCode {
  text-align: center; letter-spacing: 8px;
  font-family: 'Courier New', monospace; font-size: 18px;
}
.auth-btn {
  padding: 12px 16px; border-radius: 10px;
  background: var(--text); color: var(--paper);
  border: none; font-family: var(--font);
  font-weight: 600; font-size: 14px; cursor: pointer;
  transition: background .15s;
}
.auth-btn:hover { background: #2a2e46; }
.auth-btn:disabled { background: var(--muted); cursor: not-allowed; }
.auth-link {
  background: none; border: none; color: var(--accent);
  font-family: var(--font); font-size: 13px; cursor: pointer;
  padding: 4px;
}
.auth-link:hover { text-decoration: underline; }
.auth-emailshow {
  font-size: 13px; color: var(--muted); margin-bottom: 4px; text-align: center;
}
.auth-error {
  margin-top: 14px; padding: 10px 12px;
  background: var(--bad-soft); color: var(--bad);
  border: 1px solid var(--bad); border-radius: 8px;
  font-size: 13px; text-align: left;
}
.auth-error.hidden { display: none; }

/* Nav user chip */
.nav-user {
  display: flex; align-items: center; gap: 10px;
  padding-left: 12px; margin-left: 4px;
  border-left: 1px solid var(--border);
}
.nav-user.hidden { display: none; }
.nav-user #navUserEmail {
  font-size: 12px; color: var(--muted);
  max-width: 180px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* Nav link (About) */
.nav-link {
  background: transparent; border: none;
  color: var(--text-soft); font-family: var(--font);
  font-size: 14px; font-weight: 500; cursor: pointer;
  padding: 6px 10px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.nav-link:hover { color: var(--text); background: var(--card-hi); }

/* ABOUT PAGE */
.about-page {
  max-width: 760px; margin: 0 auto; padding: 40px 24px 80px;
}
.about-page.hidden { display: none; }
.about-hero {
  text-align: center; padding: 40px 0 32px;
  border-bottom: 1px solid var(--border); margin-bottom: 36px;
}
.about-mark {
  width: 64px; height: 64px; border-radius: 14px;
  background: var(--text); color: var(--paper);
  display: grid; place-items: center;
  font-family: var(--serif); font-size: 28px; font-weight: 700;
  margin: 0 auto 18px;
}
.about-hero h1 {
  font-family: var(--serif); font-weight: 500;
  font-size: 36px; letter-spacing: -.5px;
  margin: 0 0 8px; color: var(--text);
}
.about-hero h1 em { color: var(--accent); font-style: italic; }
.about-tagline {
  color: var(--muted); font-size: 16px; font-style: italic; margin: 0;
}
.about-body p {
  font-size: 15.5px; line-height: 1.75; color: var(--text-soft);
  margin: 0 0 20px;
}
.about-body p strong { color: var(--text); font-weight: 600; }
.about-body p:last-child { margin-bottom: 0; }
.about-page .back-btn { margin-bottom: 16px; }

/* STUDY METHODS BUTTON in nav */
.nav-left { display: flex; align-items: center; gap: 16px; }
.study-nav-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 999px;
  background: var(--accent); color: var(--paper);
  border: 1px solid var(--accent); font-family: var(--font);
  font-weight: 600; font-size: 14px; cursor: pointer;
  box-shadow: 0 2px 8px rgba(74, 111, 165, 0.25);
  transition: transform .15s, box-shadow .2s, background .2s;
}
.study-nav-btn:hover {
  background: #3a5d8c; border-color: #3a5d8c;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(74, 111, 165, 0.35);
}
.study-nav-btn .fab-icon { font-size: 16px; }

/* Pomodoro chip in nav */
.pomo-chip {
  display: flex; align-items: center; gap: 8px;
  padding: 7px 12px; border-radius: 999px;
  background: var(--text); color: var(--paper);
  font-family: var(--font); font-size: 12px; font-weight: 600;
  cursor: pointer; letter-spacing: .3px;
  transition: background .15s;
}
.pomo-chip:hover { background: #2a2e46; }
.pomo-chip.hidden { display: none; }
.pomo-chip.break { background: var(--good); }
.pomo-chip.long { background: var(--warn); }
.pomo-chip-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; opacity: .9;
  animation: pomo-pulse 1.4s infinite ease-in-out;
}
.pomo-chip.paused .pomo-chip-dot { animation: none; opacity: .4; }
.pomo-chip-time { font-variant-numeric: tabular-nums; }
@keyframes pomo-pulse {
  0%, 100% { opacity: .9; transform: scale(1); }
  50% { opacity: .3; transform: scale(.7); }
}

/* STUDY PANEL (slide in from left) */
.study-panel {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(440px, 100vw);
  background: var(--paper); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 50;
  transform: translateX(-100%); transition: transform .35s cubic-bezier(.2,.9,.3,1);
  box-shadow: 12px 0 40px rgba(30, 34, 56, 0.08);
}
.study-panel.open { transform: translateX(0); }
.study-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card-hi);
}
.study-title { display: flex; align-items: center; gap: 12px; }
.study-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--accent-soft); display: flex; align-items: center; justify-content: center;
  font-size: 19px;
}
.study-name { font-family: var(--serif); font-weight: 700; font-size: 18px; }
.study-sub { font-size: 12px; color: var(--muted); }
.study-body { flex: 1; overflow-y: auto; padding: 18px; }
.method-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 16px; margin-bottom: 12px; background: var(--paper);
  transition: border-color .15s, box-shadow .15s;
}
.method-card:hover { border-color: var(--border-strong); box-shadow: var(--shadow-sm); }
.method-head {
  display: flex; align-items: center; gap: 10px; cursor: pointer;
  user-select: none;
}
.method-num {
  width: 26px; height: 26px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 12px; flex-shrink: 0;
}
.method-title { font-family: var(--serif); font-weight: 600; font-size: 15px; flex: 1; }
.method-toggle { color: var(--muted); font-size: 14px; transition: transform .2s; }
.method-card.open .method-toggle { transform: rotate(90deg); }
.method-body {
  display: none; padding-top: 12px; margin-top: 10px; border-top: 1px dashed var(--border);
  font-size: 13.5px; color: var(--text-soft); line-height: 1.55;
}
.method-card.open .method-body { display: block; }
.method-body p { margin: 0 0 8px 0; }

/* widgets */
.pomo {
  margin-top: 12px; padding: 14px; border-radius: 10px;
  background: var(--card-hi); border: 1px solid var(--border);
}
.pomo-time {
  font-family: var(--serif); font-weight: 700; font-size: 40px;
  text-align: center; color: var(--text); letter-spacing: 1px;
}
.pomo-phase {
  text-align: center; font-size: 12px; font-weight: 600; letter-spacing: .5px;
  text-transform: uppercase; color: var(--accent); margin-bottom: 8px;
}
.pomo-phase.break { color: var(--good); }
.pomo-phase.long { color: var(--warn); }
.pomo-controls { display: flex; gap: 8px; margin-top: 12px; }
.pomo-btn {
  flex: 1; padding: 9px 12px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--paper);
  font-family: var(--font); font-size: 13px; font-weight: 500;
  cursor: pointer; color: var(--text);
  transition: background .15s, border-color .15s;
}
.pomo-btn:hover { background: var(--card-hi); }
.pomo-btn.primary {
  background: var(--text); color: var(--paper); border-color: var(--text);
}
.pomo-btn.primary:hover { background: #2a2e46; }
.pomo-meta {
  text-align: center; font-size: 11px; color: var(--muted); margin-top: 10px;
}

.pomo-settings {
  margin-top: 12px; padding-top: 10px; border-top: 1px dashed var(--border);
  font-size: 12px; color: var(--text-soft);
}
.pomo-settings summary {
  cursor: pointer; font-weight: 600; padding: 4px 0;
  list-style: none; color: var(--text-soft);
}
.pomo-settings summary::-webkit-details-marker { display: none; }
.pomo-settings[open] summary { color: var(--accent); margin-bottom: 8px; }
.pomo-settings-row {
  display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px;
}
.pomo-settings-row label {
  display: flex; align-items: center; gap: 6px;
  font-size: 11.5px; color: var(--muted);
  flex-wrap: wrap;
}
.pomo-settings-row input {
  width: 52px; padding: 5px 7px; border-radius: 6px;
  border: 1px solid var(--border-strong);
  font-family: var(--font); font-size: 12px;
}

.sr-widget { margin-top: 12px; padding: 14px; border-radius: 10px; background: var(--card-hi); border: 1px solid var(--border); }
.sr-input { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.sr-input label { font-size: 12px; color: var(--muted); }
.sr-input input {
  flex: 1; padding: 7px 10px; border-radius: 8px;
  border: 1px solid var(--border-strong); font-family: var(--font); font-size: 13px;
}
.sr-dates { display: grid; grid-template-columns: repeat(2, 1fr); gap: 6px; }
.sr-date {
  font-size: 12px; padding: 6px 8px; border-radius: 6px;
  background: var(--paper); border: 1px solid var(--border);
}
.sr-date b { color: var(--accent); display: block; font-size: 11px; }

.recall-widget { margin-top: 12px; padding: 14px; border-radius: 10px; background: var(--card-hi); border: 1px solid var(--border); }
.recall-time {
  font-family: var(--serif); font-weight: 700; font-size: 28px;
  text-align: center; color: var(--text);
}
.recall-btns { display: flex; gap: 8px; margin-top: 8px; }

.ask-max-btn {
  display: block; width: 100%; margin-top: 14px;
  padding: 10px 14px; border-radius: 999px;
  background: var(--text); color: var(--paper);
  border: 1px solid var(--text); font-family: var(--font);
  font-weight: 500; font-size: 13px; cursor: pointer;
  transition: background .15s, transform .15s;
}
.ask-max-btn:hover { background: #2a2e46; transform: translateY(-1px); }

.topic-picker {
  margin-top: 14px; padding: 12px; border-radius: 10px;
  background: var(--accent-soft); border: 1px solid var(--border);
  display: flex; flex-direction: column; gap: 8px;
}
.picker-label {
  font-size: 12px; font-weight: 600; color: var(--accent);
  letter-spacing: .3px;
}
.picker-select {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--border-strong); background: var(--paper);
  font-family: var(--font); font-size: 13px; color: var(--text);
  cursor: pointer;
}
.picker-select:focus { outline: none; border-color: var(--accent); }
.start-method-btn {
  margin-top: 4px; padding: 9px 14px; border-radius: 999px;
  background: var(--accent); color: var(--paper);
  border: 1px solid var(--accent); font-family: var(--font);
  font-weight: 500; font-size: 13px; cursor: pointer;
  transition: background .15s, transform .15s;
}
.start-method-btn:hover { background: #3a5d8c; transform: translateY(-1px); }

@media (max-width: 768px) {
  .study-panel { width: 100vw; }
  .study-nav-btn .fab-label { display: none; }
  .study-nav-btn { padding: 7px 10px; }
}

/* CHAT PANEL */
.chat-panel {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(440px, 100vw);
  background: var(--paper); border-left: 1px solid var(--border);
  display: flex; flex-direction: column; z-index: 50;
  transform: translateX(100%); transition: transform .35s cubic-bezier(.2,.9,.3,1);
  box-shadow: -12px 0 40px rgba(30, 34, 56, 0.08);
}
.chat-panel.open { transform: translateX(0); }
.chat-panel.fullscreen { width: 100vw; transition: transform .35s cubic-bezier(.2,.9,.3,1), width .25s ease; }
.chat-panel.fullscreen .chat-log { max-width: 900px; margin: 0 auto; width: 100%; }
.chat-panel.fullscreen .chat-form { max-width: 900px; margin: 0 auto; width: 100%; box-sizing: border-box; }
.chat-panel.fullscreen .chat-header { max-width: 100%; }
.chat-header {
  padding: 18px 22px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  background: var(--card-hi);
}
.chat-title { display: flex; align-items: center; gap: 12px; }
.chat-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 20px;
  border: 1px solid rgba(74, 111, 165, .2);
}
.chat-avatar.big { width: 40px; height: 40px; }
.chat-name { font-family: var(--serif); font-weight: 600; font-size: 16px; color: var(--text); }
.chat-sub { color: var(--muted); font-size: 12px; }
.chat-actions { display: flex; gap: 6px; }

.icon-btn {
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--paper); border: 1px solid var(--border);
  color: var(--muted); cursor: pointer; font-size: 14px;
  display: grid; place-items: center; transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--bg2); color: var(--text); }

.chat-log {
  flex: 1; overflow-y: auto; padding: 20px 22px;
  display: flex; flex-direction: column; gap: 14px;
  background: var(--bg);
}
.chat-msg { display: flex; gap: 10px; max-width: 100%; align-items: flex-start; }
.chat-msg.user { justify-content: flex-end; }
.chat-msg .chat-avatar {
  width: 30px; height: 30px; font-size: 15px; flex-shrink: 0;
}
.chat-bubble {
  max-width: 85%; padding: 12px 16px; border-radius: 14px;
  font-size: 14.5px; line-height: 1.6; word-wrap: break-word;
}
.chat-msg.assistant .chat-bubble {
  background: var(--paper);
  border: 1px solid var(--border);
  border-top-left-radius: 4px;
  color: var(--text);
  box-shadow: var(--shadow-sm);
}
.chat-msg.user .chat-bubble {
  background: var(--text); color: var(--paper);
  border-top-right-radius: 4px;
  white-space: pre-wrap;
}
.chat-bubble p { margin-bottom: 8px; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble ol, .chat-bubble ul { margin: 6px 0 8px 20px; }
.chat-bubble code { background: var(--bg2); padding: 2px 6px; border-radius: 4px; font-size: 13px; color: var(--accent2); }
.chat-msg.user .chat-bubble code { background: rgba(255,255,255,.15); color: var(--paper); }

.chat-form {
  padding: 14px 16px; border-top: 1px solid var(--border);
  display: flex; gap: 10px; align-items: flex-end;
  background: var(--paper);
}
.chat-form textarea {
  flex: 1; resize: none; min-height: 42px; max-height: 140px;
  padding: 11px 14px; border-radius: 10px;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border);
  font-family: var(--font); font-size: 14px; line-height: 1.4;
  transition: border-color .15s, box-shadow .15s;
}
.chat-form textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.chat-send {
  width: 42px; height: 42px; border-radius: 10px;
  background: var(--text); color: var(--paper);
  border: none; font-size: 15px; cursor: pointer;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
}
.chat-send:hover { background: #2a2e46; }
.chat-send:active { transform: scale(.96); }

.ask-inline { display: inline-flex; align-items: center; gap: 4px; }

/* ONBOARDING */
.onboard {
  position: fixed; inset: 0; z-index: 60;
  background: var(--bg);
  overflow-y: auto;
  animation: fadeIn .3s ease;
}
.onboard-shell {
  max-width: 640px; margin: 0 auto; padding: 32px;
  min-height: 100vh;
  display: flex; flex-direction: column;
}
.onboard-top {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 32px;
}
.logo-small { display: flex; align-items: center; gap: 10px; font-family: var(--serif); font-weight: 600; font-size: 15px; color: var(--text-soft); }
.logo-small .logo-dot { width: 26px; height: 26px; border-radius: 7px; background: var(--text); color: var(--bg); display: grid; place-items: center; font-size: 13px; }
.skip-btn {
  background: transparent; border: none; color: var(--muted);
  font-size: 13px; cursor: pointer; font-family: var(--font);
  padding: 6px 10px; border-radius: 6px;
  transition: color .15s, background .15s;
}
.skip-btn:hover { color: var(--text); background: var(--bg2); }

.onboard-progress { margin-bottom: 40px; }
.onboard-progress-bar {
  height: 4px; background: var(--bg2); border-radius: 999px;
  overflow: hidden; margin-bottom: 10px;
}
.onboard-progress-bar > div {
  height: 100%; background: var(--accent);
  transition: width .4s ease-out; border-radius: 999px;
}
.onboard-step-text { color: var(--muted); font-size: 12px; letter-spacing: .3px; }

.onboard-card {
  flex: 1;
  padding: 0 8px;
  animation: slideIn .35s cubic-bezier(.2,.9,.3,1);
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.onboard-q-label {
  font-size: 11px; letter-spacing: .5px; color: var(--muted);
  text-transform: uppercase; font-weight: 600; margin-bottom: 12px;
}
.onboard-title {
  font-family: var(--serif);
  font-size: clamp(28px, 4vw, 38px);
  font-weight: 500; line-height: 1.25; letter-spacing: -.5px;
  color: var(--text); margin-bottom: 10px;
}
.onboard-hint { color: var(--muted); font-size: 15px; margin-bottom: 28px; line-height: 1.5; }

.onboard-input {
  width: 100%; padding: 16px 18px; font-size: 20px;
  background: var(--paper); border: 1px solid var(--border);
  border-radius: 10px; color: var(--text); font-family: var(--font);
  transition: border-color .15s, box-shadow .15s;
}
.onboard-input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.onboard-input.error { border-color: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }

.onboard-options { display: grid; gap: 10px; }
.onboard-option {
  text-align: left; padding: 16px 20px; border-radius: 10px;
  background: var(--paper); border: 1px solid var(--border);
  color: var(--text); font-size: 15px; cursor: pointer;
  font-family: var(--font); font-weight: 500;
  transition: all .15s;
  display: flex; align-items: center; justify-content: space-between;
}
.onboard-option:hover {
  background: var(--accent-soft); border-color: var(--accent);
}
.onboard-option.selected {
  background: var(--text); color: var(--paper); border-color: var(--text);
}
.onboard-option.selected::after { content: '✓'; font-size: 14px; }

.onboard-scale {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
}
.scale-pt {
  padding: 20px 0; border-radius: 10px;
  background: var(--paper); border: 1px solid var(--border);
  color: var(--text); font-size: 22px; cursor: pointer;
  font-family: var(--serif); font-weight: 500;
  transition: all .15s;
}
.scale-pt:hover { background: var(--accent-soft); border-color: var(--accent); }
.scale-pt.selected {
  background: var(--text); color: var(--paper); border-color: var(--text);
  transform: scale(1.05);
}

.onboard-actions {
  display: flex; justify-content: space-between; align-items: center;
  margin-top: 40px; padding: 20px 0;
  gap: 12px;
}

/* GREETING */
.greeting {
  padding: 7px 14px; border-radius: 999px;
  background: var(--accent-soft); border: 1px solid rgba(74, 111, 165, .25);
  color: var(--accent); font-weight: 500; font-size: 13px;
  cursor: pointer; font-family: var(--font);
  transition: background .15s, border-color .15s;
}
.greeting:hover { background: var(--paper); border-color: var(--accent); }
.greeting strong { font-weight: 600; }

/* WELCOME TOAST */
.welcome-toast {
  position: fixed; top: 80px; left: 50%; transform: translate(-50%, -20px);
  background: var(--text); color: var(--paper);
  padding: 14px 22px; border-radius: 999px;
  font-size: 15px; font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0; transition: opacity .35s, transform .35s;
  z-index: 200;
}
.welcome-toast.show { opacity: 1; transform: translate(-50%, 0); }
.welcome-wave { display: inline-block; margin-right: 8px; animation: wave 1.2s ease infinite; }
@keyframes wave {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-12deg); }
  75% { transform: rotate(12deg); }
}

/* Subject toggle */
.subject-toggle {
  max-width: 1200px; margin: 0 auto 20px; padding: 0 32px;
  display: flex; gap: 8px; flex-wrap: wrap;
}
.subj-btn {
  padding: 8px 16px; border-radius: 999px;
  background: var(--paper); border: 1px solid var(--border);
  color: var(--text-soft); font-weight: 500; font-size: 13px;
  cursor: pointer; font-family: var(--font);
  transition: all .15s;
}
.subj-btn:hover { background: var(--bg2); border-color: var(--border-strong); color: var(--text); }
.subj-btn.active {
  background: var(--text); color: var(--paper); border-color: var(--text);
}

/* Recommendation card */
#recBox { max-width: 1200px; margin: 0 auto; padding: 0 32px; }
.rec-card {
  display: flex; gap: 16px; align-items: flex-start;
  padding: 20px 24px; margin-bottom: 24px;
  background: var(--paper); border: 1px solid var(--border);
  border-left: 4px solid var(--accent);
  border-radius: var(--radius); box-shadow: var(--shadow-sm);
}
.rec-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center; font-size: 22px;
  border: 1px solid rgba(74, 111, 165, .2); flex-shrink: 0;
}
.rec-body { flex: 1; min-width: 0; }
.rec-name { font-family: var(--serif); font-weight: 600; font-size: 15px; color: var(--text); margin-bottom: 6px; }
.rec-text { font-size: 14.5px; line-height: 1.6; color: var(--text-soft); }
.rec-text p { margin-bottom: 6px; }

/* Learn button + lesson panel */
.learn-btn {
  background: var(--accent-soft); border: 1px solid rgba(74, 111, 165, .25);
  color: var(--accent); padding: 8px 14px; border-radius: 999px;
  font-size: 13px; font-weight: 500; cursor: pointer;
  transition: all .15s; font-family: var(--font);
}
.learn-btn:hover { background: var(--paper); border-color: var(--accent); }

.lesson-panel {
  border-top: 1px solid var(--border);
  padding: 20px 24px;
  background: var(--bg);
  animation: fadeIn .2s ease;
}
.lesson-written {
  padding: 14px 16px; border-radius: 10px;
  background: var(--paper); border: 1px solid var(--border);
  margin-bottom: 14px; font-size: 14.5px; line-height: 1.65;
}
.lesson-written strong { color: var(--text); }
.lesson-ai {
  padding: 14px 16px; border-radius: 10px;
  background: var(--accent-soft); border: 1px solid rgba(74, 111, 165, .2);
  border-left: 3px solid var(--accent);
}
.lesson-ai-head { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: .3px; margin-bottom: 10px; }
.lesson-ai-head em { color: var(--text); font-style: normal; }
.lesson-ai-body { font-size: 14.5px; line-height: 1.7; color: var(--text); }
.lesson-ai-body h3, .lesson-ai-body h4 { font-family: var(--serif); font-weight: 600; margin: 10px 0 6px; color: var(--text); }
.lesson-ai-body h4 { font-size: 14px; color: var(--muted); letter-spacing: .3px; text-transform: uppercase; font-family: var(--font); }
.lesson-ai-body p { margin-bottom: 8px; }
.lesson-ai-body ol, .lesson-ai-body ul { margin: 6px 0 10px 22px; }
.lesson-ai-body li { margin-bottom: 4px; }

.hidden { display: none !important; }

@media (max-width: 640px) {
  .hero { padding: 70px 20px 50px; }
  .nav { padding: 12px 20px; }
  .books, .section-heading { padding: 0 20px; }
  .detail { padding: 0 20px; }
  .detail-header, .quiz-card, .results-card { padding: 28px 24px; }
  .detail-header h1 { font-size: 30px; }
  .grade-big { font-size: 80px; }
  .modal-qblock.two-col { grid-template-columns: 1fr; }
  .modal-content { padding: 26px 22px; }
  .section-row { flex-wrap: wrap; }
  .chat-panel { width: 100vw; }
  .ask-fab { padding: 11px 18px; bottom: 16px; right: 16px; }
  .ask-fab .fab-label { display: none; }
  .nav-right .progress-pill { display: none; }
}

/* Lazy-load placeholder for course expansion files. */
.books-loading {
  padding: 48px 24px;
  text-align: center;
  color: var(--muted, #6b7280);
  font-size: 15px;
}
.books-loading-err {
  color: #b00020;
}

/* Auth role toggle (Student / Parent) on the sign-in card. */
.auth-role-toggle {
  margin: 6px 0 18px;
  text-align: center;
}
.auth-role-label {
  font-size: 13px;
  color: var(--muted, #6b7280);
  margin-bottom: 8px;
}
.auth-role-buttons {
  display: inline-flex;
  gap: 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 999px;
  padding: 4px;
}
.auth-role-btn {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text, #1e2238);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 18px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.auth-role-btn:hover {
  background: rgba(0, 0, 0, 0.05);
}
.auth-role-btn.active {
  background: var(--text, #1e2238);
  color: var(--paper, #fff);
}
.auth-role-btn.active:hover {
  background: var(--text, #1e2238);
}
.auth-role-hint {
  font-size: 12px;
  color: var(--muted, #6b7280);
  margin-top: 8px;
  line-height: 1.4;
}

/* Auth code-form help row: "Didn't receive a code?" + actions + status. */
.auth-help-row {
  margin-top: 14px;
  text-align: center;
}
.auth-help-prompt {
  font-size: 13px;
  color: var(--muted, #6b7280);
  margin-bottom: 6px;
}
.auth-help-actions {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
}
.auth-help-actions .auth-link {
  background: none;
  border: none;
  color: var(--text, #1e2238);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 0;
  text-decoration: underline;
}
.auth-help-actions .auth-link:disabled {
  color: var(--muted, #6b7280);
  cursor: not-allowed;
  text-decoration: none;
}
.auth-help-sep {
  color: var(--muted, #6b7280);
  font-size: 13px;
}
.auth-resend-status {
  margin-top: 10px;
  font-size: 13px;
  line-height: 1.4;
}
.auth-resend-status.ok {
  color: #1b6b3a;
}
.auth-resend-status.err {
  color: #b00020;
}

/* Auth signup extras: age + grade + country row + collapsible link code field. */
.auth-field-row {
  display: flex;
  gap: 12px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.auth-field {
  flex: 1 1 0;
  min-width: 100px;
  display: flex;
  flex-direction: column;
  text-align: left;
  font-size: 12px;
  color: var(--muted, #6b7280);
}
.auth-field:first-child { min-width: 110px; }    /* age */
.auth-field-grade { min-width: 130px; flex: 1.2 1 0; }
.auth-field:last-child { flex: 2.5 1 0; min-width: 180px; } /* country -- widest */
@media (max-width: 520px) {
  .auth-field { flex: 1 1 100%; }
}
.auth-field span {
  margin-bottom: 4px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  height: 18px;
  line-height: 18px;
  display: block;
}
.auth-field input,
.auth-field select {
  box-sizing: border-box;
  font-family: var(--font);
  font-size: 16px;
  padding: 12px 14px;
  border: 1px solid var(--border-strong, #d4cfc0);
  border-radius: 10px;
  background: var(--paper, #fff) !important;
  color: var(--text, #1e2238) !important;
  height: 50px;
  min-height: 50px;
  line-height: 1.2;
  -webkit-text-fill-color: var(--text, #1e2238);  /* override browser autofill text color */
  caret-color: var(--text, #1e2238);
}
/* The age number input gets extra love: it's the field most people fill in,
   and the default number-input styling is tiny. Make it big, bold, readable. */
#authAge {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .5px;
  padding: 18px 20px;
  text-align: left;
  min-height: 60px;
  color: var(--text, #1e2238) !important;
  -webkit-text-fill-color: var(--text, #1e2238);
  background: var(--paper, #fff) !important;
}
#authAge::placeholder { color: var(--muted, #6b7280); opacity: 1; font-size: 18px; font-weight: 400; }
#authAge::-webkit-outer-spin-button,
#authAge::-webkit-inner-spin-button { margin-left: 6px; }

/* Dark-mode: number inputs sometimes render their text invisibly because
   the OS-level form styling wins. Force dark-mode text + bg explicitly. */
:root[data-theme="dark"] .auth-field input,
:root[data-theme="dark"] .auth-field select,
:root[data-theme="dark"] #authAge {
  background: var(--paper) !important;
  color: var(--text) !important;
  -webkit-text-fill-color: var(--text);
  border-color: var(--border-strong);
}
/* Autofill (Chrome / Safari) yellow-flash override so the text stays visible */
.auth-field input:-webkit-autofill,
#authAge:-webkit-autofill {
  -webkit-box-shadow: 0 0 0 1000px var(--paper, #fff) inset !important;
  -webkit-text-fill-color: var(--text, #1e2238) !important;
  caret-color: var(--text, #1e2238);
}
.auth-linkcode-wrap {
  margin-top: 12px;
  text-align: left;
}
.auth-linkcode-wrap summary {
  cursor: pointer;
  color: var(--text, #1e2238);
  font-size: 13px;
  font-weight: 500;
  padding: 6px 0;
}
.auth-linkcode-wrap input {
  width: 100%;
  font: inherit;
  font-size: 15px;
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 10px 12px;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  background: var(--paper, #fff);
  margin-top: 6px;
}
.auth-linkcode-hint {
  font-size: 12px;
  color: var(--muted, #6b7280);
  margin-top: 4px;
}

/* Consent gate (under-13 waiting for parent). */
.consent-gate {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(247, 245, 240, 0.96);
  backdrop-filter: blur(10px);
  display: flex; align-items: center; justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.consent-gate.hidden { display: none; }
.consent-card {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 16px;
  padding: 36px 32px;
  max-width: 520px;
  width: 100%;
  text-align: center;
}
.consent-mark {
  display: inline-block;
  width: 48px;
  height: 48px;
  border-radius: 10px;
  background: var(--text, #1e2238);
  color: var(--paper, #fff);
  text-align: center;
  line-height: 48px;
  font-family: Georgia, serif;
  font-size: 20px;
  font-weight: 700;
  margin-bottom: 16px;
}
.consent-card h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 24px;
  margin: 0 0 8px;
}
.consent-lede {
  color: var(--muted, #6b7280);
  margin: 0 0 24px;
}
.consent-codebox {
  background: #f7f5f0;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 24px;
}
.consent-codebox-label {
  font-size: 13px;
  color: var(--muted, #6b7280);
  margin-bottom: 8px;
}
.consent-codebox-code {
  font-family: 'Courier New', monospace;
  font-size: 32px;
  font-weight: 700;
  letter-spacing: 4px;
  color: var(--text, #1e2238);
  margin-bottom: 10px;
}
.consent-copy {
  background: none;
  border: 1px solid var(--border, #e6e2d7);
  color: var(--text, #1e2238);
  padding: 6px 14px;
  font: inherit;
  font-size: 13px;
  border-radius: 999px;
  cursor: pointer;
}
.consent-steps {
  text-align: left;
  margin-bottom: 24px;
}
.consent-steps h3 {
  font-size: 15px;
  margin: 0 0 8px;
}
.consent-steps ol {
  padding-left: 20px;
  color: var(--text, #1e2238);
  font-size: 14px;
  line-height: 1.5;
}
.consent-refresh {
  background: var(--text, #1e2238);
  color: var(--paper, #fff);
  border: none;
  font: inherit;
  padding: 12px 24px;
  border-radius: 10px;
  cursor: pointer;
  width: 100%;
}
.consent-foot {
  margin-top: 16px;
}
.consent-foot .auth-link {
  background: none;
  border: none;
  color: var(--muted, #6b7280);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-decoration: underline;
}

/* Parent home. */
.parent-home {
  max-width: 880px;
  margin: 24px auto;
  padding: 0 24px;
}
.parent-home.hidden { display: none; }
.parent-hero h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 32px;
  margin: 16px 0 4px;
}
.parent-sub {
  color: var(--muted, #6b7280);
  margin: 0 0 24px;
}
.parent-section {
  margin-top: 32px;
}
.parent-student-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.parent-empty {
  color: var(--muted, #6b7280);
  font-size: 14px;
  padding: 12px;
  border: 1px dashed var(--border, #e6e2d7);
  border-radius: 10px;
}
.parent-empty.err { color: #b00020; border-color: #f3c2c8; }
.parent-student-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  padding: 14px 18px;
  background: var(--paper, #fff);
}
.parent-student-email {
  font-weight: 500;
  margin-bottom: 4px;
}
.parent-student-meta {
  font-size: 13px;
  color: var(--muted, #6b7280);
}
.parent-link-form {
  display: flex;
  gap: 10px;
}
.parent-link-form input {
  flex: 1;
  font: inherit;
  font-size: 16px;
  font-family: 'Courier New', monospace;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 12px 14px;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
}
.parent-codebox {
  background: #f7f5f0;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.parent-codebox-code {
  font-family: 'Courier New', monospace;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: 4px;
}

/* Parent → student detail. */
.parent-detail {
  max-width: 880px;
  margin: 24px auto;
  padding: 0 24px;
}
.parent-detail.hidden { display: none; }
.parent-detail-hero h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 28px;
  margin: 16px 0 4px;
}
.parent-detail-meta {
  color: var(--muted, #6b7280);
  font-size: 14px;
  margin-bottom: 16px;
}
.parent-detail-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.parent-detail-row {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
  padding: 10px 14px;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  background: var(--paper, #fff);
  font-size: 14px;
}
.parent-detail-row .muted { color: var(--muted, #6b7280); font-size: 13px; }
.parent-detail-row .ok { color: #1b6b3a; }
.parent-detail-row .warn { color: #b00020; }
.parent-student-row .badge.ok { color: #1b6b3a; }
.parent-student-row .badge.warn { color: #b00020; }

/* Profile page (student or parent). */
.profile-page {
  max-width: 720px;
  margin: 24px auto;
  padding: 0 24px;
}
.profile-page.hidden { display: none; }
.profile-hero h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 28px;
  margin: 16px 0 4px;
}
.profile-sub { color: var(--muted, #6b7280); margin: 0 0 24px; }
.profile-form fieldset {
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  padding: 16px 20px;
  margin-bottom: 16px;
  background: var(--paper, #fff);
}
.profile-form legend {
  font-weight: 600;
  font-size: 14px;
  padding: 0 6px;
}
.profile-form label {
  display: block;
  margin: 10px 0;
  font-size: 13px;
  color: var(--muted, #6b7280);
}
.profile-form input[type="text"],
.profile-form input[type="time"],
.profile-form select,
.profile-form textarea {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  background: var(--paper, #fff);
  color: var(--text, #1e2238);
  margin-top: 4px;
}
.profile-label { font-weight: 500; font-size: 13px; color: var(--text, #1e2238); margin: 10px 0 6px; }
.profile-checks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 6px;
}
.profile-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
}
.profile-check input { margin: 0; }
.profile-toggle {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-size: 14px !important;
  color: var(--text, #1e2238) !important;
}
.profile-notice {
  background: #fff7e6;
  border: 1px solid #f5d99a;
  color: #6b4d00;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 12px;
}
.profile-student-row {
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  padding: 10px 14px;
  margin-bottom: 8px;
}
.profile-student-email { font-weight: 500; margin-bottom: 4px; }
.profile-actions {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.profile-save-status { font-size: 13px; color: var(--muted, #6b7280); }
.profile-save-status.ok { color: #1b6b3a; }
.profile-save-status.err { color: #b00020; }
.profile-loading {
  padding: 32px;
  text-align: center;
  color: var(--muted, #6b7280);
}
.profile-loading.err { color: #b00020; }

/* Make the .logo button behave visually like the original div. */
button.logo {
  appearance: none;
  background: transparent;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: inherit;
}
button.logo:hover { opacity: 0.85; }
button.logo:focus-visible {
  outline: 2px solid var(--text, #1e2238);
  outline-offset: 4px;
  border-radius: 6px;
}

/* Student-facing activity page (re-uses parent-detail row styles). */
.activity-page {
  max-width: 880px;
  margin: 24px auto;
  padding: 0 24px;
}
.activity-page.hidden { display: none; }
.activity-hero h1 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 28px;
  margin: 16px 0 4px;
}
.activity-sub { color: var(--muted, #6b7280); margin: 0 0 24px; }

/* Rich activity event rows (used by Activity page + parent dashboard). */
.activity-event {
  display: grid;
  grid-template-columns: 36px 1fr auto;
  gap: 12px;
  align-items: start;
  padding: 12px 14px;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  background: var(--paper, #fff);
  margin-bottom: 8px;
}
.activity-icon {
  font-size: 22px;
  line-height: 1.1;
  text-align: center;
  padding-top: 2px;
}
.activity-body { min-width: 0; }
.activity-title {
  font-size: 14px;
  font-weight: 500;
  color: var(--text, #1e2238);
  line-height: 1.35;
  word-wrap: break-word;
}
.activity-detail {
  font-size: 13px;
  color: var(--muted, #6b7280);
  margin-top: 2px;
  line-height: 1.4;
  word-wrap: break-word;
}
.activity-when {
  font-size: 12px;
  color: var(--muted, #6b7280);
  white-space: nowrap;
  padding-top: 4px;
}
@media (max-width: 480px) {
  .activity-event { grid-template-columns: 28px 1fr; }
  .activity-when { grid-column: 2; padding-top: 4px; }
  .activity-icon { font-size: 18px; }
}

/* AI-generated "where you stand" summary at the top of Activity. */
.activity-summary-card {
  background: linear-gradient(135deg, #f7f5f0 0%, #ffffff 100%);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 24px;
}
.activity-summary-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 10px;
}
.activity-summary-avatar {
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: var(--text, #1e2238);
  color: var(--paper, #fff);
  display: grid;
  place-items: center;
  font-size: 18px;
}
.activity-summary-name {
  font-weight: 600;
  font-size: 15px;
  line-height: 1.2;
}
.activity-summary-sub {
  font-size: 12px;
  color: var(--muted, #6b7280);
}
.activity-summary-refresh {
  margin-left: auto;
  background: transparent;
  border: 1px solid var(--border, #e6e2d7);
  color: var(--text, #1e2238);
  width: 34px;
  height: 34px;
  border-radius: 999px;
  font: inherit;
  font-size: 16px;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.activity-summary-refresh:hover { background: rgba(0, 0, 0, 0.03); }
.activity-summary-refresh:disabled { opacity: 0.5; cursor: not-allowed; }
.activity-summary-body {
  font-size: 15px;
  line-height: 1.55;
  color: var(--text, #1e2238);
}
.activity-summary-body p { margin: 0 0 8px; }
.activity-summary-body p:last-child { margin-bottom: 0; }
.activity-summary-body strong { font-weight: 600; }
.activity-summary-body.err { color: #b00020; font-size: 13px; }

/* My Details dropdown menu in nav. */
.nav-menu { position: relative; display: inline-block; }
.nav-menu-items {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.08);
  padding: 6px;
  min-width: 160px;
  z-index: 50;
}
.nav-menu-items.hidden { display: none; }
.nav-menu-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text, #1e2238);
}
.nav-menu-item:hover { background: rgba(0, 0, 0, 0.05); }

/* Dropdown footer: "Logged in as" + email. */
.nav-menu-divider {
  height: 1px;
  background: var(--border, #e6e2d7);
  margin: 6px 4px;
}
.nav-menu-footer {
  padding: 6px 12px 4px;
}
.nav-menu-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #6b7280);
  margin-bottom: 2px;
}
.nav-menu-email {
  font-size: 13px;
  color: var(--text, #1e2238);
  word-break: break-all;
  line-height: 1.3;
}

/* Long-form info pages (Privacy, Terms). */
.info-long {
  max-width: 760px;
  margin: 0 auto;
  line-height: 1.6;
}
.info-tldr {
  background: #f7f5f0;
  border-left: 3px solid var(--text, #1e2238);
  padding: 14px 18px;
  border-radius: 6px;
  margin-bottom: 24px;
}
.info-long h2 {
  font-family: Georgia, serif;
  font-weight: 500;
  font-size: 22px;
  margin: 32px 0 10px;
  scroll-margin-top: 80px;
}
.info-long h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 18px 0 6px;
}
.info-long ul {
  padding-left: 22px;
  margin: 8px 0 14px;
}
.info-long li { margin-bottom: 6px; }
.info-long p { margin: 8px 0 12px; }

/* Sign in / Create account tabs at the top of the auth card. */
.auth-mode-toggle { margin: 0 0 16px; }
.auth-mode-buttons {
  display: flex;
  gap: 2px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 999px;
  padding: 4px;
}
.auth-mode-btn {
  flex: 1;
  appearance: none;
  background: transparent;
  border: none;
  color: var(--text, #1e2238);
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 10px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.auth-mode-btn.active {
  background: var(--paper, #fff);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* Profile-form hint text under a disabled / read-only field. */
.profile-hint {
  display: block;
  font-size: 12px;
  color: var(--muted, #6b7280);
  margin-top: 4px;
}
.profile-form input:disabled {
  background: rgba(0, 0, 0, 0.03);
  color: var(--muted, #6b7280);
  cursor: not-allowed;
}

/* Study Methods picker — second action button + hint. */
.picker-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.picker-actions .start-method-btn,
.picker-actions .open-topic-btn {
  flex: 1;
  min-width: 160px;
  background: var(--accent, #4a6fa5);
  color: var(--paper, #fff);
  border: 1px solid var(--accent, #4a6fa5);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background .15s;
}
.picker-actions .open-topic-btn {
  background: var(--paper, #fff);
  color: var(--accent, #4a6fa5);
}
.picker-actions .start-method-btn:hover { filter: brightness(0.92); }
.picker-actions .open-topic-btn:hover {
  background: var(--accent-soft, rgba(74, 111, 165, 0.1));
}
.picker-hint {
  font-size: 12px;
  color: var(--muted, #6b7280);
  margin-top: 8px;
  line-height: 1.4;
}

/* Token Cost page: summary cards + tables. */
.token-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 24px;
}
@media (max-width: 600px) { .token-cards { grid-template-columns: 1fr; } }
.token-card {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  padding: 16px 18px;
}
.token-card-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #6b7280);
  margin-bottom: 6px;
}
.token-card-value {
  font-family: Georgia, serif;
  font-size: 26px;
  font-weight: 500;
  color: var(--text, #1e2238);
  line-height: 1.2;
}
.token-card-sub {
  font-size: 12px;
  color: var(--muted, #6b7280);
  margin-top: 4px;
}

.token-table-wrap { overflow-x: auto; }
.token-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}
.token-table th,
.token-table td {
  text-align: left;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border, #e6e2d7);
}
.token-table th {
  font-weight: 600;
  color: var(--muted, #6b7280);
  text-transform: uppercase;
  font-size: 11px;
  letter-spacing: 0.04em;
}
.token-table th.num, .token-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.token-table td.empty {
  text-align: center;
  color: var(--muted, #6b7280);
  padding: 20px;
}
.token-table td.empty.err { color: #b00020; }
.token-model { font-family: 'Courier New', monospace; font-size: 12px; color: var(--muted, #6b7280); }
.token-row { cursor: pointer; }
.token-row:hover { background: rgba(0, 0, 0, 0.02); }
.token-detail.hidden { display: none; }
.token-detail td { background: rgba(0, 0, 0, 0.02); }
.token-detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 6px 16px;
  font-size: 13px;
  padding: 4px 0;
}

/* Lesson panel: regenerate button + mermaid container. */
.lesson-ai-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.lesson-regen-btn {
  background: transparent;
  border: 1px solid var(--border, #e6e2d7);
  color: var(--muted, #6b7280);
  font: inherit;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  cursor: pointer;
}
.lesson-regen-btn:hover { color: var(--text, #1e2238); border-color: var(--text, #1e2238); }
.lesson-regen-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.mermaid-rendered {
  margin: 12px 0;
  overflow-x: auto;
  text-align: center;
}
.mermaid-rendered svg {
  max-width: 100%;
  height: auto;
}
.lesson-ai-body svg {
  display: block;
  margin: 12px auto;
  max-width: 100%;
  height: auto;
  color: var(--text, #1e2238);
}

/* Lesson walker — step-by-step guided lesson. */
.lesson-walker {
  background: var(--paper, #fff);
  border-radius: 12px;
  padding: 18px 20px;
  outline: none;
}
.lesson-step-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.lesson-step-counter {
  font-size: 12px;
  font-weight: 600;
  color: var(--muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.lesson-step-dots {
  display: inline-flex;
  gap: 6px;
}
.lesson-step-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--border, #e6e2d7);
  transition: background 0.15s;
}
.lesson-step-dot.done { background: var(--accent, #4a6fa5); opacity: 0.5; }
.lesson-step-dot.active { background: var(--accent, #4a6fa5); transform: scale(1.4); }
.lesson-step-body {
  font-size: 15px;
  line-height: 1.6;
  color: var(--text, #1e2238);
}
.lesson-step-body h3 { display: none; }
.lesson-step-body p { margin: 8px 0; }
.lesson-step-body ul, .lesson-step-body ol { margin: 8px 0 12px; padding-left: 22px; }
.lesson-step-body li { margin: 4px 0; }
/* Photomath-style *Why?* annotation lines — tagged by mdToHtml with .why-annotation */
.why-annotation {
  color: #6b4d00;
  background: linear-gradient(90deg, #fff8e1 0%, #fffdf5 100%);
  border-left: 3px solid #f5c97a;
  padding: 4px 10px;
  border-radius: 0 6px 6px 0;
  margin: 2px 0 10px;
  font-size: 13px;
}

/* Colorful numbered step badges in worked examples.
   The AI outputs each step separated by a *Why?* paragraph, so the markdown
   parser creates a NEW <ol> per step. We scope counter-reset to the parent
   container so numbering continues across multiple <ol> elements. */
.lesson-step-body, .hint-body, .ai-output { counter-reset: step-counter; }
.lesson-step-body ol,
.hint-body ol,
.ai-output ol { list-style: none; padding-left: 0; }
.lesson-step-body ol > li,
.hint-body ol > li,
.ai-output ol > li {
  counter-increment: step-counter;
  position: relative;
  padding-left: 36px;
  margin: 10px 0;
}
.lesson-step-body ol > li::before,
.hint-body ol > li::before,
.ai-output ol > li::before {
  content: counter(step-counter);
  position: absolute;
  left: 0;
  top: 1px;
  width: 24px;
  height: 24px;
  background: linear-gradient(135deg, #4a90d9, #357abd);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(74, 144, 217, 0.3);
}
/* Alternate badge colors for variety */
.lesson-step-body ol > li:nth-child(3n+2)::before,
.hint-body ol > li:nth-child(3n+2)::before,
.ai-output ol > li:nth-child(3n+2)::before {
  background: linear-gradient(135deg, #2ecc71, #27ae60);
  box-shadow: 0 2px 4px rgba(46, 204, 113, 0.3);
}
.lesson-step-body ol > li:nth-child(3n)::before,
.hint-body ol > li:nth-child(3n)::before,
.ai-output ol > li:nth-child(3n)::before {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  box-shadow: 0 2px 4px rgba(155, 89, 182, 0.3);
}

/* SVG diagrams inside lesson steps — aspect-ratio-safe scaling + colorful container */
.lesson-step-body svg,
.hint-body svg,
.ai-output svg {
  display: block;
  margin: 14px auto;
  max-width: min(360px, 100%);
  height: auto;
  border-radius: 8px;
  background: #fafcff;
  padding: 10px;
  box-shadow: 0 2px 8px rgba(74, 144, 217, 0.12);
}
.lesson-step-body svg[viewBox] {
  width: auto;
  max-width: min(360px, 100%);
}
.lesson-step-body svg text { font-size: 12px; }
.lesson-step-body blockquote {
  margin: 10px 0;
  padding: 8px 14px;
  border-left: 3px solid var(--accent, #4a6fa5);
  background: rgba(74, 111, 165, 0.06);
  font-style: italic;
  color: var(--text-muted, #4a4d63);
}
.md-table {
  border-collapse: collapse;
  margin: 12px 0;
  font-size: 14px;
  width: auto;
  max-width: 100%;
}
.md-table th, .md-table td {
  border: 1px solid var(--border, #e6e2d7);
  padding: 6px 12px;
  text-align: left;
  vertical-align: top;
}
.md-table thead th {
  background: rgba(74, 111, 165, 0.08);
  font-weight: 600;
}
.md-table tbody tr:nth-child(even) td {
  background: rgba(0, 0, 0, 0.015);
}

.lesson-ask {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin: 16px 0 12px;
  padding-top: 12px;
  border-top: 1px dashed var(--border, #e6e2d7);
}
.lesson-ask-input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 8px;
  resize: vertical;
}
.lesson-ask-btn {
  background: var(--text, #1e2238);
  color: var(--paper, #fff);
  border: none;
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.lesson-ask-btn:hover { filter: brightness(1.1); }

.lesson-step-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}
.lesson-step-prev,
.lesson-step-next,
.lesson-step-quiz {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  color: var(--text, #1e2238);
  font: inherit;
  font-size: 14px;
  padding: 9px 16px;
  border-radius: 999px;
  cursor: pointer;
}
.lesson-step-prev:disabled { opacity: 0.4; cursor: not-allowed; }
.lesson-step-next,
.lesson-step-quiz {
  background: var(--accent, #4a6fa5);
  color: var(--paper, #fff);
  border-color: var(--accent, #4a6fa5);
}
.lesson-step-quiz {
  background: #1b6b3a;
  border-color: #1b6b3a;
}
.lesson-step-next:hover,
.lesson-step-quiz:hover { filter: brightness(1.08); }

.lesson-feynman { padding-top: 6px; }
.lesson-feynman p { margin-bottom: 8px; }
.lesson-feynman-input {
  width: 100%;
  font: inherit;
  font-size: 14px;
  padding: 10px 12px;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 8px;
  resize: vertical;
}
.lesson-feynman-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.lesson-feynman-check {
  background: var(--text, #1e2238);
  color: var(--paper, #fff);
  border: none;
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.lesson-feynman-skip {
  background: transparent;
  border: 1px solid var(--border, #e6e2d7);
  color: var(--muted, #6b7280);
  font: inherit;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.lesson-feynman-feedback {
  margin-top: 12px;
  padding: 10px 14px;
  background: #f7f5f0;
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.5;
}
.lesson-feynman-feedback.err { background: #fdecec; color: #b00020; }
.lesson-feynman-feedback.hidden { display: none; }

/* Hint ladder inside quiz cards. */
.quiz-hint-box {
  margin: 12px 0;
  padding: 14px 18px;
  background: #fff9e6;
  border: 1px solid #f5d99a;
  border-radius: 10px;
  color: #5a4500;
}
.quiz-hint-box.hidden { display: none; }
.hint-head {
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
  color: #6b4d00;
}
.hint-body {
  font-size: 14px;
  line-height: 1.5;
  color: var(--text, #1e2238);
}
.hint-body p { margin: 4px 0; }
.hint-btn {
  background: #fff;
  border: 1px solid #f5d99a;
  color: #6b4d00;
}
.hint-btn:hover { background: #fff9e6; }

/* Stuck callout after a 2nd consecutive fail. */
.stuck-callout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 20px;
  margin: 16px 0;
  border: 1px solid #f5c97a;
  background: #fff9e6;
  border-radius: 14px;
}
.stuck-icon {
  font-size: 32px;
  line-height: 1;
}
.stuck-body { flex: 1; }
.stuck-title {
  font-weight: 600;
  font-size: 15px;
  color: var(--text, #1e2238);
  margin-bottom: 4px;
}
.stuck-sub {
  font-size: 13px;
  color: #6b4d00;
  line-height: 1.45;
  margin-bottom: 12px;
}
.stuck-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.stuck-open-lesson {
  background: #1e2238;
  color: #fff;
  border: none;
  padding: 9px 18px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.stuck-dismiss {
  background: transparent;
  border: 1px solid var(--border, #e6e2d7);
  color: var(--text, #1e2238);
  padding: 9px 16px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

/* Spaced-repetition widget on the courses home page. */
.review-queue {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 14px;
  padding: 18px 20px;
  /* Same centered-container pattern as .study-plan-card and .courses-grid. */
  max-width: 1036px;
  width: calc(100% - 64px);
  box-sizing: border-box;
  margin: 0 auto 18px;
}
.review-queue-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}
.review-queue-icon {
  font-size: 22px;
}
.review-queue-title {
  font-weight: 600;
  font-size: 15px;
}
.review-queue-sub {
  font-size: 13px;
  color: var(--muted, #6b7280);
}
.review-queue-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.review-queue-row {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.review-queue-row:hover { background: rgba(0, 0, 0, 0.04); }
.review-queue-row-title { font-weight: 500; font-size: 14px; margin-bottom: 2px; }
.review-queue-row-sub { font-size: 12px; color: var(--muted, #6b7280); }
.review-queue-row-cta { font-size: 13px; color: var(--accent, #4a6fa5); white-space: nowrap; }

/* Study plan card on the courses home page. */
.study-plan-card {
  background: linear-gradient(135deg, #f3ede1 0%, #ffffff 100%);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 14px;
  padding: 18px 22px;
  /* Match the centered max-width pattern used by .courses-grid /
     .section-heading so the card aligns with everything else on the
     home page instead of stretching edge-to-edge. */
  max-width: 1036px;
  width: calc(100% - 64px);
  box-sizing: border-box;
  margin: 0 auto 18px;
}
.plan-head {
  display: flex;
  align-items: center;
  gap: 14px;
}
.plan-icon { font-size: 28px; line-height: 1; }
.plan-headline { flex: 1; min-width: 0; }
.plan-title { font-weight: 600; font-size: 16px; color: var(--text, #1e2238); margin-bottom: 4px; }
.plan-sub { font-size: 13px; color: var(--muted, #6b7280); }
.plan-cta {
  background: var(--text, #1e2238);
  color: var(--paper, #fff);
  border: none;
  padding: 9px 18px;
  border-radius: 999px;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
.plan-cta:hover { filter: brightness(1.1); }
.plan-cta-sub {
  background: transparent;
  border: 1px solid var(--border, #e6e2d7);
  color: var(--text, #1e2238);
  padding: 6px 12px;
  border-radius: 999px;
  font: inherit;
  font-size: 12px;
  cursor: pointer;
}
.plan-summary {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.5;
}
.plan-week-range {
  margin-top: 14px;
  font-size: 12px;
  color: var(--muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.plan-section-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.plan-section-row {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
  font: inherit;
  cursor: pointer;
}
.plan-section-row:hover { background: rgba(0, 0, 0, 0.02); }
.plan-section-row.done { opacity: 0.65; }
.plan-section-row.done .plan-section-title { text-decoration: line-through; }
.plan-section-check {
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 1px solid var(--border, #e6e2d7);
  display: grid;
  place-items: center;
  font-size: 13px;
}
.plan-section-row.done .plan-section-check {
  background: #1b6b3a;
  border-color: #1b6b3a;
  color: #fff;
}
.plan-section-title { flex: 1; font-size: 14px; }
.plan-section-cta { font-size: 12px; color: var(--accent, #4a6fa5); white-space: nowrap; }
.plan-empty { color: var(--muted, #6b7280); font-size: 13px; padding: 8px 0; }
.plan-setup label { display: block; font-size: 13px; color: var(--muted, #6b7280); margin: 12px 0 4px; }
.plan-setup input,
.plan-setup textarea,
.plan-setup select {
  width: 100%;
  font: inherit;
  font-size: 15px;
  padding: 10px 12px;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  background: var(--paper, #fff);
  color: var(--text, #1e2238);
}
.plan-setup-actions { display: flex; gap: 8px; margin-top: 16px; }
.plan-setup-status { margin-top: 10px; font-size: 13px; color: var(--muted, #6b7280); }
.plan-setup-status.err { color: #b00020; }

/* Make sure the site footer renders cleanly under every signed-in view
   (courses home, profile, activity, lessons, parent dashboard, etc.).
   The earlier styles only kicked in inside the landing layout. */
.site-footer {
  margin-top: 48px;
  border-top: 1px solid var(--border, #e6e2d7);
}
body > .site-footer {
  padding-left: 24px;
  padding-right: 24px;
}

/* Admin page: stat cards + tables. Re-uses .token-card / .token-table. */
.admin-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-bottom: 24px;
}
.admin-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 999px;
  margin-right: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.admin-badge.admin { background: #fff4e0; color: #8c5a00; border: 1px solid #f5d99a; }
.admin-badge.ok { background: #e6f4ea; color: #1b6b3a; border: 1px solid #b8dec6; }
.admin-badge.unverif { background: #fdecec; color: #b00020; border: 1px solid #f3c2c8; }
.admin-badge.gated { background: #fff9e6; color: #6b4d00; border: 1px solid #f5d99a; }

/* Parent dashboard "at a glance" 360 summary. */
.parent-360-summary { margin-top: 16px; }
.parent-summary-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin: 12px 0;
}
.parent-summary-card {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  padding: 14px 16px;
}
.parent-summary-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted, #6b7280);
  margin-bottom: 4px;
}
.parent-summary-value {
  font-family: Georgia, serif;
  font-size: 24px;
  font-weight: 500;
  color: var(--text, #1e2238);
}
.parent-summary-sub {
  font-size: 12px;
  color: var(--muted, #6b7280);
  margin-top: 4px;
}
.parent-summary-profile {
  background: rgba(0, 0, 0, 0.02);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.6;
  margin-top: 8px;
}
.parent-summary-plan {
  margin-top: 10px;
  padding: 10px 14px;
  background: #fff9e6;
  border: 1px solid #f5d99a;
  border-radius: 8px;
  font-size: 13px;
}

/* Admin: tabs, toolbar, cost chart, user-detail modal. */
.admin-tabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 18px;
}
.admin-tab {
  background: transparent;
  border: none;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted, #6b7280);
  padding: 8px 14px;
  border-radius: 8px;
  cursor: pointer;
}
.admin-tab.active {
  background: var(--text, #1e2238);
  color: var(--paper, #fff);
}
.admin-tab:hover:not(.active) { background: rgba(0, 0, 0, 0.04); }

.admin-toolbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.admin-search,
.admin-select {
  font: inherit;
  font-size: 14px;
  padding: 8px 12px;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 8px;
  background: var(--paper, #fff);
  color: var(--text, #1e2238);
}
.admin-search { min-width: 240px; }
.admin-toolbar-count { font-size: 12px; color: var(--muted, #6b7280); margin-left: auto; }

.admin-user-row { cursor: pointer; }
.admin-user-row:hover { background: rgba(0, 0, 0, 0.03); }
.admin-user-link { color: var(--accent, #4a6fa5); text-decoration: none; font-weight: 500; }

.admin-user-modal h2 { margin: 0 0 4px; }
.admin-user-meta { font-size: 13px; color: var(--muted, #6b7280); margin-bottom: 4px; }
.admin-user-meta-sub { font-size: 12px; color: var(--muted, #6b7280); margin-bottom: 16px; }
.admin-user-meta-sub code { font-size: 11px; }
.admin-user-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px 16px;
  padding: 12px 16px;
  background: rgba(0, 0, 0, 0.03);
  border-radius: 10px;
  font-size: 13px;
  margin-bottom: 14px;
}
.admin-user-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.admin-delete {
  border-color: #e8b6b6;
  color: #b00020;
}
.admin-delete:hover { background: #fdecec; }
.admin-user-section {
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  padding: 8px 14px;
  margin-top: 8px;
}
.admin-user-section summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 13px;
}
.admin-user-list {
  margin: 8px 0 0;
  padding-left: 20px;
  font-size: 13px;
  max-height: 240px;
  overflow-y: auto;
}
.admin-user-list li { margin-bottom: 4px; line-height: 1.4; }

/* Cost chart (sparkline-ish bars). */
.admin-cost-chart {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  padding: 16px;
}
.cost-bars {
  display: flex;
  gap: 4px;
  align-items: flex-end;
  height: 160px;
}
.cost-bar {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  height: 100%;
  min-width: 0;
}
.cost-bar-fill {
  background: var(--accent, #4a6fa5);
  border-radius: 4px 4px 0 0;
  width: 100%;
}
.cost-bar-label {
  font-size: 9px;
  color: var(--muted, #6b7280);
  text-align: center;
  margin-top: 4px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Admin prebuild controls */
.prebuild-controls {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.prebuild-force {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted, #6b7280);
}
.prebuild-progress {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  padding: 16px;
}
.prebuild-bar {
  height: 10px;
  background: rgba(0, 0, 0, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 10px;
}
.prebuild-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent, #4a6fa5), #1b6b3a);
  transition: width 0.3s ease;
}
.prebuild-status-line {
  font-size: 13px;
  color: var(--text, #1e2238);
  font-family: 'Courier New', monospace;
}
.prebuild-errors {
  margin-top: 12px;
  font-size: 12px;
  color: #b00020;
  max-height: 200px;
  overflow-y: auto;
}
.prebuild-errors ul { padding-left: 20px; margin: 6px 0; }
.prebuild-errors li { margin-bottom: 4px; line-height: 1.4; }

/* =============== Curriculum browser =============== */
.curr-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px 32px 64px;
}
.curr-hero h1 { margin: 0 0 6px; font-size: 28px; }
.curr-sub { color: var(--text-muted, #4a4d63); margin: 0 0 20px; }
.curr-controls {
  display: flex; gap: 16px; flex-wrap: wrap;
  margin: 8px 0 24px; padding: 16px;
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
}
.curr-control { display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--text-muted, #4a4d63); min-width: 180px; }
.curr-control select {
  font: inherit; font-size: 14px; padding: 8px 10px;
  border: 1px solid var(--border, #e6e2d7); border-radius: 8px;
  background: var(--card-bg, #fff); color: var(--text, #1e2238);
}
.curr-course-list {
  display: grid; gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}
.curr-course-card {
  padding: 18px; border: 1px solid var(--border, #e6e2d7); border-radius: 10px;
  background: var(--card-bg, #fff); cursor: pointer;
  transition: border-color 0.15s, transform 0.1s;
}
.curr-course-card:hover { border-color: var(--accent, #4a6fa5); transform: translateY(-1px); }
.curr-course-card-head { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.curr-course-card h3 { margin: 0; font-size: 17px; }
.curr-course-grades { font-size: 12px; color: var(--text-muted, #4a4d63); white-space: nowrap; }
.curr-course-card-meta { font-size: 13px; color: var(--text-muted, #4a4d63); }
.curr-course-detail .back-btn { margin-bottom: 14px; }
.curr-course-hero h2 { margin: 0 0 4px; font-size: 24px; }
.curr-course-meta { font-size: 14px; color: var(--text-muted, #4a4d63); margin-bottom: 18px; }
.curr-unit {
  border: 1px solid var(--border, #e6e2d7); border-radius: 10px;
  background: var(--card-bg, #fff); margin-bottom: 10px;
}
.curr-unit summary {
  display: flex; gap: 12px; align-items: center; padding: 14px 18px;
  cursor: pointer; list-style: none; font-size: 15px;
}
.curr-unit summary::-webkit-details-marker { display: none; }
.curr-unit-num { font-weight: 600; color: var(--accent, #4a6fa5); }
.curr-unit-title { flex: 1; font-weight: 500; }
.curr-unit-weeks, .curr-unit-count { font-size: 12px; color: var(--text-muted, #4a4d63); }
.curr-unit-body { padding: 4px 18px 18px; }
.curr-lesson {
  border-top: 1px solid var(--border, #e6e2d7);
  padding: 14px 0;
}
.curr-lesson:first-child { border-top: none; }
.curr-lesson-head { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; margin-bottom: 8px; }
.curr-lesson-num { font-weight: 700; color: var(--accent, #4a6fa5); min-width: 36px; }
.curr-lesson-title { font-weight: 600; }
.curr-lesson-ccss {
  font-size: 11px; padding: 2px 8px; border-radius: 99px;
  background: rgba(74, 111, 165, 0.1); color: var(--accent, #4a6fa5);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.curr-lesson-fields { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; margin: 0; font-size: 14px; }
.curr-lesson-fields dt { color: var(--text-muted, #4a4d63); font-size: 13px; }
.curr-lesson-fields dd { margin: 0; }
@media (max-width: 600px) {
  .curr-lesson-fields { grid-template-columns: 1fr; gap: 2px 0; }
  .curr-lesson-fields dt { margin-top: 6px; font-weight: 600; }
}

/* Existing-content / needs-new-content badge on curriculum cards. */
.curr-legacy-badge {
  display: inline-block;
  margin-top: 10px;
  font-size: 12px;
  padding: 3px 9px;
  border-radius: 99px;
  font-weight: 500;
  white-space: nowrap;
}
.curr-legacy-existing {
  background: rgba(40, 140, 80, 0.12);
  color: #1f7a4a;
  border: 1px solid rgba(40, 140, 80, 0.3);
}
.curr-legacy-new {
  background: rgba(220, 140, 30, 0.12);
  color: #a36a18;
  border: 1px solid rgba(220, 140, 30, 0.35);
}
.curr-course-meta .curr-legacy-badge { margin-top: 0; margin-left: 8px; }

/* Grade selector + subject toggle row on courses-home. Sits in the
   same centered 1200px column as .section-heading and .courses-grid
   below it, with subject toggle on the left and grade on the right. */
.courses-controls {
  max-width: 1200px;
  margin: 0 auto 18px;
  padding: 0 32px;
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.courses-controls .subject-toggle {
  max-width: none;
  margin: 0;
  padding: 0;
  display: inline-flex;
  gap: 8px;
  flex-wrap: wrap;
}
.courses-grade {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-muted, #4a4d63);
}
.courses-grade select {
  font: inherit; font-size: 14px; padding: 6px 10px;
  border: 1px solid var(--border, #e6e2d7); border-radius: 8px;
  background: var(--card-bg, #fff); color: var(--text, #1e2238);
  min-width: 130px;
}
@media (max-width: 640px) {
  .courses-controls { justify-content: flex-start; }
}
/* Curriculum-card actions (Start learning + View units & lessons). */
.curr-course-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.curr-learn-btn {
  font: inherit; font-size: 13px; padding: 6px 12px; cursor: pointer;
  background: var(--accent, #4a6fa5); color: white; border: none; border-radius: 6px;
  font-weight: 500;
}
.curr-learn-btn:hover:not(:disabled) { background: var(--accent-hover, #3a5b8a); }
.curr-learn-btn:disabled { background: var(--border, #e6e2d7); color: var(--text-muted, #4a4d63); cursor: not-allowed; }
.curr-card-detail-btn {
  font: inherit; font-size: 13px; padding: 6px 12px; cursor: pointer;
  background: transparent; color: var(--accent, #4a6fa5);
  border: 1px solid var(--border, #e6e2d7); border-radius: 6px;
}
.curr-card-detail-btn:hover { border-color: var(--accent, #4a6fa5); }
.course-cta.disabled { opacity: 0.6; }

/* Topic cards on the curriculum-driven home grid. Slightly tighter
   than course cards because there are more of them on screen. */
.course-card.topic-card { padding: 18px; }
.course-card.topic-card .course-title { font-size: 18px; }
.course-card.topic-card .course-subtitle {
  font-size: 12px;
  color: var(--text-muted, #4a4d63);
  margin-bottom: 4px;
  font-style: normal;
}

/* =============== Favorites (heart) =============== */
.course-card.topic-card { position: relative; }
.fav-heart-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  background: transparent;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  color: var(--text-muted, #4a4d63);
  border-radius: 50%;
  transition: transform 0.1s, color 0.15s, background 0.15s;
  z-index: 2;
}
.fav-heart-btn:hover { background: rgba(0, 0, 0, 0.04); color: #c43c5b; transform: scale(1.1); }
.fav-heart-btn.favorited { color: #e0245e; }
.fav-heart-btn:focus-visible { outline: 2px solid var(--accent, #4a6fa5); outline-offset: 2px; }
.fav-heart { color: #e0245e; font-size: 16px; }

/* =============== In-house math fallback (renders when MathJax misses) =============== */
.m-display {
  display: block;
  text-align: center;
  margin: 18px 0;
  font-family: 'Cambria Math', Cambria, 'Times New Roman', serif;
  font-size: 19px;
  line-height: 1.5;
}
.m-inline {
  font-family: 'Cambria Math', Cambria, 'Times New Roman', serif;
  font-size: 1.02em;
}
.m-frac {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  vertical-align: middle;
  padding: 0 4px;
  font-size: 0.95em;
}
.m-frac .m-num {
  border-bottom: 1.5px solid currentColor;
  padding: 0 6px 2px;
  line-height: 1.2;
}
.m-frac .m-den {
  padding: 2px 6px 0;
  line-height: 1.2;
}
.m-sqrt {
  white-space: nowrap;
  display: inline-flex; align-items: center;
}
.m-sqrt .m-rad {
  border-top: 1.5px solid currentColor;
  padding: 0 2px 0 4px;
}
/* The small superscripted index on \sqrt[n]{x} — e.g. the "3" in cube root */
.m-sqrt .m-rootidx {
  font-size: 0.7em; line-height: 1;
  position: relative; top: -0.5em; left: 1px;
  margin-right: -3px; /* tuck close to the radical sign */
  vertical-align: super;
}

/* Trig / log function names rendered upright (sin, cos, log, lim, …) so
   they don't look like a product of italic single letters. Mirrors
   MathJax's default treatment. */
.m-fn {
  font-style: normal;
  font-family: var(--font, system-ui), sans-serif;
  margin-right: 1px;
}

/* Accents — small mark above the wrapped letter. We achieve the bar /
   hat / tilde / arrow with a CSS overline-ish trick so the mark
   stretches naturally over multi-character content. */
.m-bar, .m-overline {
  border-top: 1.2px solid currentColor;
  padding-top: 1px;
  display: inline-block;
  line-height: 1.1;
}
.m-underline {
  border-bottom: 1.2px solid currentColor;
  padding-bottom: 1px;
  display: inline-block;
  line-height: 1.1;
}
.m-hat::before, .m-tilde::before, .m-vec::before, .m-dot::before, .m-ddot::before {
  position: absolute;
  left: 50%;
  top: -0.55em;
  transform: translateX(-50%);
  font-size: 0.85em;
  line-height: 1;
  pointer-events: none;
}
.m-hat, .m-tilde, .m-vec, .m-dot, .m-ddot {
  position: relative;
  display: inline-block;
  padding-top: 0.4em;       /* room above for the mark */
  margin-top: -0.4em;       /* keep the baseline aligned with surrounding text */
}
.m-hat::before   { content: '^'; }
.m-tilde::before { content: '~'; }
.m-vec::before   { content: '→'; font-size: 0.7em; top: -0.4em; }
.m-dot::before   { content: '·'; }
.m-ddot::before  { content: '··'; letter-spacing: -0.1em; }

/* Binomial coefficient \binom{n}{k} — vertical pair inside big parentheses */
.m-binom {
  display: inline-flex; align-items: center;
  font-size: 1em; line-height: 1;
  margin: 0 1px;
}
.m-binom-stack {
  display: inline-flex; flex-direction: column;
  align-items: center; line-height: 1.1;
  margin: 0 2px;
  font-size: 0.85em;
}

/* Matrices: \begin{pmatrix|bmatrix|vmatrix|matrix}…\end{…} rendered as an
   HTML table flanked by big stretchy brackets. Light styling — looks like
   a textbook matrix even when MathJax never runs. */
.m-matrix {
  display: inline-flex; align-items: center;
  vertical-align: middle;
  margin: 0 2px;
  line-height: 1.2;
}
.m-mtable {
  border-collapse: collapse;
  margin: 0 4px;
}
.m-mtable td {
  padding: 2px 8px;
  text-align: center;
  border: none;
  font-variant-numeric: tabular-nums;
}
.m-mb {
  font-size: 1.6em;
  font-weight: 200;
  line-height: 1;
  align-self: stretch;
  display: inline-flex; align-items: center;
}
.m-mb-l { padding-right: 1px; }
.m-mb-r { padding-left: 1px; }

/* =============== Big-popup Learn modal =============== */
.lesson-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.lesson-modal.hidden { display: none; }
.lesson-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 30, 0.55);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
}
.lesson-modal-dialog {
  position: relative;
  background: var(--paper, #fff);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  width: min(1100px, 96vw);
  height: min(820px, 92vh);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.lesson-modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  padding: 0;
  border: none;
  background: rgba(0, 0, 0, 0.06);
  color: var(--text, #1e2238);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  border-radius: 50%;
  z-index: 2;
  font-family: inherit;
}
.lesson-modal-close:hover { background: rgba(0, 0, 0, 0.14); }
.lesson-modal-head {
  padding: 22px 56px 12px 28px;
  border-bottom: 1px solid var(--border, #e6e2d7);
  flex: 0 0 auto;
}
.lesson-modal-eyebrow {
  font-size: 13px;
  color: var(--text-muted, #4a4d63);
  margin-bottom: 4px;
}
.lesson-modal-title {
  font-family: var(--serif, Georgia, serif);
  font-size: 24px;
  font-weight: 500;
  color: var(--text, #1e2238);
}
.lesson-modal-body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 22px 28px 28px;
}
.lesson-modal-body .lesson-panel {
  /* Inherit existing .lesson-walker / step styling. */
  width: 100%;
}
@media (max-width: 640px) {
  .lesson-modal-dialog { width: 100vw; height: 100vh; border-radius: 0; }
  .lesson-modal-head { padding: 18px 48px 10px 18px; }
  .lesson-modal-body { padding: 16px 18px 28px; }
}

/* Inline Ask Max chat thread inside the lesson walker / modal. */
.lesson-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin: 14px 0 4px;
}
.lesson-chat-thread:empty { display: none; }
.lesson-chat-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.lesson-chat-author {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  font-weight: 600;
  color: var(--text-muted, #4a4d63);
}
.lesson-chat-bubble {
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(74, 111, 165, 0.08);
  font-size: 15px;
  line-height: 1.5;
  color: var(--text, #1e2238);
  max-width: 100%;
}
.lesson-chat-user .lesson-chat-bubble {
  background: var(--accent, #4a6fa5);
  color: #fff;
  align-self: flex-end;
}
.lesson-chat-user {
  align-items: flex-end;
}
.lesson-chat-bubble p { margin: 0 0 8px; }
.lesson-chat-bubble p:last-child { margin-bottom: 0; }
.lesson-chat-bubble .typing span {
  background: var(--text-muted, #4a4d63);
}

/* =============== Student Insights =============== */
.insights-section {
  margin: 20px 0 28px;
  padding: 0 2px;
}
.insights-title {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 14px;
  color: var(--text, #1e2238);
}
.insights-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}
.insight-stat {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  padding: 14px 12px;
  text-align: center;
}
.insight-stat-value {
  font-size: 22px;
  font-weight: 700;
  color: var(--accent, #4a6fa5);
  line-height: 1.2;
}
.insight-stat-label {
  font-size: 11px;
  color: var(--muted, #6b7280);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin-top: 4px;
}
.insights-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 12px;
}
.insights-panel {
  background: var(--paper, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.insights-grid .insights-panel { margin-bottom: 0; }
.insights-panel h3 {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 10px;
  color: var(--text, #1e2238);
}
.insights-strengths { border-left: 3px solid #2ecc71; }
.insights-weaknesses { border-left: 3px solid #e74c3c; }
.insights-suggestions { border-left: 3px solid #4a90d9; }
.insights-list { display: flex; flex-direction: column; gap: 6px; }
.insights-empty {
  font-size: 13px;
  color: var(--muted, #6b7280);
  font-style: italic;
  padding: 4px 0;
}
.insight-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.015);
}
.insight-item-name {
  flex: 1;
  font-size: 13px;
  font-weight: 500;
  color: var(--text, #1e2238);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.insight-item-score {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.insight-bar {
  width: 60px;
  height: 6px;
  background: var(--border, #e6e2d7);
  border-radius: 3px;
  overflow: hidden;
  flex-shrink: 0;
}
.insight-bar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.3s;
}
.mastery-mastered .insight-bar-fill { background: #2ecc71; }
.mastery-proficient .insight-bar-fill { background: #27ae60; }
.mastery-developing .insight-bar-fill { background: #f39c12; }
.mastery-struggling .insight-bar-fill { background: #e74c3c; }
.mastery-not_started .insight-bar-fill { background: var(--border, #e6e2d7); }
.insight-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  white-space: nowrap;
}
.badge-mastered { background: #eafaf1; color: #1b6b3a; }
.badge-proficient { background: #e8f8ef; color: #1e7e34; }
.badge-developing { background: #fef9e7; color: #7d6608; }
.badge-struggling { background: #fdecea; color: #922b21; }
.trend-improving { color: #2ecc71; }
.trend-steady { color: var(--muted, #6b7280); }
.trend-declining { color: #e74c3c; }

@media (max-width: 600px) {
  .insights-stats { grid-template-columns: repeat(2, 1fr); }
  .insights-grid { grid-template-columns: 1fr; }
  .insight-stat-value { font-size: 18px; }
}

/* =============== Adaptive difficulty chip =============== */
.adaptive-chip {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 6px;
  margin-left: 8px;
  vertical-align: middle;
}
.adaptive-easier {
  background: #eafaf1;
  color: #1b6b3a;
}
.adaptive-harder {
  background: #fdecea;
  color: #922b21;
}

/* =============== Activity rollup table (student + parent) =============== */
.summary-head {
  display: flex; align-items: center; justify-content: space-between;
  flex-wrap: wrap; gap: 12px; margin-bottom: 6px;
}
.summary-range-tabs {
  display: inline-flex; gap: 4px; padding: 4px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 999px;
}
.summary-tab {
  font: inherit; font-size: 13px; padding: 6px 14px;
  border: none; background: transparent; cursor: pointer;
  border-radius: 999px; color: var(--text-muted, #4a4d63);
  font-weight: 500;
}
.summary-tab.active {
  background: var(--text, #1e2238); color: var(--paper, #fff);
}
.summary-range-note {
  font-size: 13px; color: var(--text-muted, #4a4d63);
  margin: 0 0 10px;
}
.summary-table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 10px;
}
.summary-table {
  width: 100%; border-collapse: collapse; font-size: 14px;
}
.summary-table th, .summary-table td {
  padding: 10px 14px; border-bottom: 1px solid var(--border, #e6e2d7);
  text-align: left;
}
.summary-table th {
  background: rgba(0, 0, 0, 0.02);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-muted, #4a4d63);
}
.summary-table td.num, .summary-table th.num { text-align: right; }
.summary-table td.ok { color: #1f7a4a; }
.summary-table td.warn { color: #a36a18; }
.summary-table tr.summary-total td {
  background: rgba(0, 0, 0, 0.025);
  border-top: 2px solid var(--border, #e6e2d7);
  border-bottom: none;
}
.summary-table tbody tr:last-child td { border-bottom: none; }
.summary-table .empty { text-align: center; padding: 18px; color: var(--text-muted, #4a4d63); }
.summary-table .empty.err { color: #c43c5b; }

.rollup-student { font-weight: 500; }
.rollup-student-role { font-size: 11px; color: var(--text-muted, #4a4d63); text-transform: capitalize; }

/* =============== Streak chip =============== */
.streak-chip {
  font: inherit; font-size: 13px; padding: 5px 12px;
  border: 1px solid var(--border, #e6e2d7);
  background: linear-gradient(135deg, #fff4e6, #ffe2c2);
  color: #b65a14;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.streak-chip:hover { border-color: #f0a060; transform: translateY(-1px); }
.streak-chip.hidden { display: none; }

.points-chip {
  font: inherit; font-size: 13px; padding: 5px 12px;
  border: 1px solid var(--border, #e6e2d7);
  background: linear-gradient(135deg, #fff8d6, #ffe89a);
  color: #8a6500;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex; align-items: center; gap: 4px;
}
.points-chip:hover { border-color: #e0bc3a; transform: translateY(-1px); }
.points-chip.hidden { display: none; }

/* =============== Problem of the Day =============== */
#podBox { max-width: 1200px; margin: 0 auto 18px; padding: 0 32px; }
.pod-card {
  background: linear-gradient(135deg, #fff7e6 0%, #ffeacc 100%);
  border: 1px solid #f0c98a;
  border-radius: 12px;
  padding: 20px 24px;
  display: flex; flex-direction: column; gap: 12px;
}
.pod-card.solved { background: linear-gradient(135deg, #e6f4ec 0%, #c9eed5 100%); border-color: #76c894; }
.pod-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; flex-wrap: wrap; }
.pod-eyebrow { font-weight: 700; font-size: 13px; color: #a16110; letter-spacing: 0.2px; }
.pod-card.solved .pod-eyebrow { color: #1f7a4a; }
.pod-subject { font-size: 12px; color: var(--text-muted, #4a4d63); margin-top: 2px; }
.pod-stats { font-size: 12px; color: var(--text-muted, #4a4d63); }
.pod-question {
  font-size: 17px; line-height: 1.55; color: var(--text, #1e2238);
  background: rgba(255, 255, 255, 0.55);
  border-radius: 8px; padding: 12px 14px;
}
.pod-input-row { display: flex; gap: 8px; flex-wrap: wrap; }
.pod-input {
  flex: 1; min-width: 0; font: inherit; font-size: 14px;
  padding: 10px 14px; border: 1px solid var(--border, #e6e2d7);
  border-radius: 8px; background: #fff;
}
.pod-result { font-size: 14px; font-weight: 600; padding: 8px 12px; border-radius: 8px; }
.pod-result.ok { background: rgba(40, 140, 80, 0.15); color: #1f7a4a; }
.pod-result.err { background: rgba(220, 80, 80, 0.12); color: #c43c5b; }
.pod-correct { font-size: 14px; color: var(--text-muted, #4a4d63); }
.pod-hint.muted { font-size: 12px; color: var(--text-muted, #4a4d63); }

/* =============== Achievements grid =============== */
.badges-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px;
}
.badge {
  border: 1px solid var(--border, #e6e2d7); border-radius: 12px;
  padding: 16px; text-align: center;
  background: var(--card-bg, #fff);
  transition: transform 0.15s, box-shadow 0.15s;
}
.badge.earned { background: linear-gradient(135deg, #f7f4ec, #fdf8e8); border-color: #d4b878; }
.badge.earned:hover { transform: translateY(-2px); box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08); }
.badge.locked { opacity: 0.45; }
.badge-icon { font-size: 36px; margin-bottom: 8px; }
.badge-title { font-weight: 600; font-size: 15px; margin-bottom: 4px; color: var(--text, #1e2238); }
.badge-desc { font-size: 12px; color: var(--text-muted, #4a4d63); margin-bottom: 8px; min-height: 32px; }
.badge-points { font-size: 11px; color: var(--accent, #4a6fa5); font-weight: 600; }
.badge-status { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-muted, #4a4d63); margin-top: 4px; }
.badge.earned .badge-status { color: #1f7a4a; }

/* =============== Leaderboard =============== */
.leaderboard-my-rank {
  padding: 12px 16px; background: rgba(74, 111, 165, 0.06);
  border: 1px solid var(--border, #e6e2d7); border-radius: 10px;
  margin-bottom: 14px; font-size: 14px;
}

/* =============== Practice-by-question-type buttons =============== */
.practice-row {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 16px 0; font-size: 13px;
}
.practice-label {
  font-size: 12px; color: var(--text-muted, #4a4d63);
  text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600;
  margin-right: 4px;
}
.practice-btn, .study-section-link {
  font-family: var(--font); font-size: 14px;
  line-height: 20px; /* match emoji height so the pill is a clean oval */
  padding: 10px 18px;
  min-height: 40px;
  border: 1px solid var(--border, #e6e2d7);
  background: var(--paper, #ffffff);
  color: var(--text, #1e2238); cursor: pointer;
  border-radius: 999px;
  transition: background 0.15s, border-color 0.15s, transform 0.15s, box-shadow 0.15s;
  white-space: nowrap;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
  box-sizing: border-box;
  vertical-align: middle;
  box-shadow: 0 1px 0 rgba(30, 34, 56, 0.02);
}
.practice-btn:hover, .study-section-link:hover {
  background: rgba(74, 111, 165, 0.08);
  border-color: var(--accent, #4a6fa5);
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(30, 34, 56, 0.06);
}
/* Give the row itself a tiny bit more room so the pills don't feel cramped
   under the section title row, and break to a new line on narrow screens. */
.practice-row {
  padding: 12px 18px 14px;
  gap: 10px;
}

/* =============== Multi-child parent grid =============== */
.multi-child-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.multi-child-card {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border, #e6e2d7);
  border-radius: 12px;
  padding: 18px;
  display: flex; flex-direction: column; gap: 14px;
}
.multi-child-head { display: flex; gap: 12px; align-items: center; }
.multi-child-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: linear-gradient(135deg, #4a6fa5, #9fb8d6);
  color: #fff; display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 18px;
}
.multi-child-email { font-weight: 600; font-size: 14px; word-break: break-all; }
.multi-child-meta { font-size: 12px; color: var(--text-muted, #4a4d63); margin-top: 2px; }
.multi-child-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.mc-stat { text-align: center; padding: 8px; background: rgba(0, 0, 0, 0.02); border-radius: 8px; }
.mc-stat-num { font-weight: 700; font-size: 18px; color: var(--text, #1e2238); }
.mc-stat-label { font-size: 11px; color: var(--text-muted, #4a4d63); margin-top: 2px; }
.mc-view-btn { margin-top: auto; }

.auth-field-optional {
  font-size: 11px; color: var(--text-muted, #4a4d63); font-weight: 400;
  margin-left: 4px;
}

/* Achievements page "How to earn more" panel. */
.ach-howto {
  background: linear-gradient(135deg, #fff7e6 0%, #fef0d9 100%);
  border: 1px solid #f0c98a;
  border-radius: 12px;
  padding: 20px 24px;
  margin-bottom: 22px;
}
.ach-howto-title {
  font-family: var(--serif, Georgia, serif);
  font-size: 20px;
  margin: 0 0 4px;
  color: var(--text, #1e2238);
}
.ach-howto-lede {
  margin: 0 0 14px;
  color: var(--text-muted, #4a4d63);
  font-size: 14px;
}
.ach-howto-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 14px;
}
.ach-howto-item {
  display: flex; gap: 10px;
  background: rgba(255, 255, 255, 0.55);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
}
.ach-howto-item strong {
  font-size: 14px;
  color: var(--text, #1e2238);
}
.ach-howto-icon { font-size: 22px; line-height: 1; flex: 0 0 auto; }
.ach-howto-detail {
  color: var(--text-muted, #4a4d63);
  margin-top: 4px;
  line-height: 1.5;
}
.ach-howto-detail em {
  font-style: normal;
  font-weight: 600;
  color: var(--text, #1e2238);
}
.ach-grid-title {
  font-family: var(--serif, Georgia, serif);
  font-size: 22px;
  margin: 0 0 12px;
}

/* Spam-folder hint inside the verification step. */
.auth-help-spam {
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-muted, #4a4d63);
  background: rgba(255, 200, 80, 0.10);
  border: 1px solid rgba(220, 160, 30, 0.30);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 8px 0 10px;
}
.auth-help-spam code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  padding: 1px 6px;
  background: rgba(0, 0, 0, 0.05);
  border-radius: 4px;
}
.auth-help-spam strong { color: var(--text, #1e2238); }

/* ---------- Gamification: point toasts, chips, achievements header ---------- */

/* Bottom-right stack of small, non-distracting reward toasts. */
#pointToastContainer {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.point-toast {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: rgba(30, 34, 56, 0.92);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  line-height: 1.2;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.22);
  transform: translateY(8px);
  opacity: 0;
  transition: transform 280ms ease, opacity 280ms ease;
  pointer-events: auto;
  max-width: 280px;
}
.point-toast.show { transform: translateY(0); opacity: 1; }
.point-toast.fading { transform: translateY(-4px); opacity: 0; }
.point-toast .pt-icon { font-size: 15px; }
.point-toast .pt-amount {
  font-weight: 700;
  color: #ffd86b;
  font-variant-numeric: tabular-nums;
}
.point-toast .pt-reason { color: rgba(255, 255, 255, 0.85); }
.point-toast.is-milestone {
  background: linear-gradient(135deg, #b8842b 0%, #f3c969 100%);
  color: #1e2238;
}
.point-toast.is-milestone .pt-amount { color: #1e2238; }
.point-toast.is-milestone .pt-reason { color: rgba(30, 34, 56, 0.85); }

/* Small "+5" / "+50" chips that sit inside action buttons. */
.pts-chip {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  background: rgba(255, 216, 107, 0.20);
  color: #8a6300;
  vertical-align: middle;
  border: 1px solid rgba(220, 160, 30, 0.35);
}
.start-btn .pts-chip {
  background: rgba(255, 255, 255, 0.22);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.35);
}

/* Points summary cards above the achievements grid. */
.ach-points-header {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 0 0 16px;
}
.ach-points-card {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(30, 34, 56, 0.08);
  border-radius: 12px;
  padding: 10px 12px;
  text-align: center;
}
.ach-points-card.ach-points-total {
  background: linear-gradient(135deg, rgba(184, 132, 43, 0.10), rgba(243, 201, 105, 0.20));
  border-color: rgba(220, 160, 30, 0.35);
}
.ach-points-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted, #4a4d63);
}
.ach-points-num {
  font-family: var(--serif, Georgia, serif);
  font-size: 24px;
  font-weight: 700;
  color: var(--text, #1e2238);
  font-variant-numeric: tabular-nums;
}
@media (max-width: 640px) {
  .ach-points-header { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Progress bar that shows how close a locked badge is. */
.badge-progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 4px;
}
.badge-progress-bar {
  flex: 1;
  height: 6px;
  background: rgba(30, 34, 56, 0.10);
  border-radius: 999px;
  overflow: hidden;
}
.badge-progress-bar > div {
  height: 100%;
  background: linear-gradient(90deg, #b8842b, #f3c969);
  border-radius: 999px;
  transition: width 400ms ease;
}
.badge-progress-text {
  font-size: 11px;
  color: var(--text-muted, #4a4d63);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* ---------- Signup: school + district fields ---------- */

.auth-school-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 6px;
  position: relative;
}
.auth-field-full {
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: relative;
}
.auth-field-full > span {
  font-size: 13px;
  color: var(--text-muted, #4a4d63);
  font-weight: 600;
}
.auth-field-full > input {
  height: 44px;
  border: 1px solid rgba(30, 34, 56, 0.18);
  border-radius: 8px;
  padding: 0 12px;
  font-size: 15px;
  background: #fff;
  box-sizing: border-box;
}
.auth-field-full > input:focus {
  outline: none;
  border-color: rgba(184, 132, 43, 0.55);
  box-shadow: 0 0 0 3px rgba(184, 132, 43, 0.15);
}
.auth-private-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text, #1e2238);
  cursor: pointer;
}
.auth-private-check input { width: 16px; height: 16px; }

/* Floating autocomplete panel for school district search. */
.auth-suggest {
  position: absolute;
  z-index: 30;
  left: 0;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: #fff;
  border: 1px solid rgba(30, 34, 56, 0.15);
  border-radius: 8px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.12);
  max-height: 260px;
  overflow-y: auto;
}
.auth-suggest-item {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 8px 12px;
  font-size: 14px;
  color: var(--text, #1e2238);
  cursor: pointer;
  border-bottom: 1px solid rgba(30, 34, 56, 0.06);
}
.auth-suggest-item:last-child { border-bottom: 0; }
.auth-suggest-item:hover { background: rgba(184, 132, 43, 0.08); }
.auth-suggest-empty {
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-muted, #4a4d63);
  font-style: italic;
}

/* Profile page school fields share the autocomplete styles above. The
   .hidden class hides the optional US-only rows. */
.profile-us-only.hidden,
.profile-private-check.hidden,
.auth-field-state.hidden,
.auth-field-district.hidden {
  display: none !important;
}

/* ---------- Pending parent-student link invitations ---------- */

.student-pending-invites:empty,
.parent-pending-invites:empty {
  display: none;
}
.student-pending-card,
.pending-invites {
  margin: 20px 0;
  padding: 16px 18px;
  background: rgba(255, 216, 107, 0.12);
  border: 1px solid rgba(220, 160, 30, 0.40);
  border-radius: 12px;
}
.student-pending-title,
.pending-invites h3 {
  margin: 0 0 4px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text, #1e2238);
  font-family: var(--serif, Georgia, serif);
}
.student-pending-help,
.pending-invites-help {
  margin: 0 0 10px;
  font-size: 13px;
  color: var(--text-muted, #4a4d63);
}
.student-pending-row,
.pending-invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(220, 160, 30, 0.18);
}
.student-pending-row:first-of-type,
.pending-invite-row:first-of-type {
  border-top: 0;
}
.student-pending-from,
.pending-invite-email {
  font-size: 14px;
  color: var(--text, #1e2238);
}
.student-pending-actions,
.pending-invite-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.student-pending-actions .btn-primary,
.pending-invite-actions .btn-primary {
  background: #1e2238;
  color: #fff;
  border: 0;
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
}
.student-pending-actions .btn-secondary,
.pending-invite-actions .btn-secondary {
  background: transparent;
  color: var(--text, #1e2238);
  border: 1px solid rgba(30, 34, 56, 0.20);
  padding: 6px 14px;
  font-size: 13px;
  border-radius: 8px;
  cursor: pointer;
}
.student-pending-actions .btn-secondary:hover,
.pending-invite-actions .btn-secondary:hover {
  background: rgba(30, 34, 56, 0.05);
}

/* Tint the link error box green when the message represents a success
   (e.g. "Invitation sent. The link goes live once they approve."). */
#parentLinkError.ok {
  background: rgba(46, 160, 67, 0.12);
  border-color: rgba(46, 160, 67, 0.30);
  color: #195823;
}

/* ---------- Post-signup survey overlay ---------- */
.survey-overlay {
  position: fixed;
  inset: 0;
  z-index: 8500;
  background: rgba(20, 22, 36, 0.55);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}
body.survey-open {
  overflow: hidden;
}
.survey-card {
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 640px;
  padding: 32px 32px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.30);
}
.survey-head {
  text-align: center;
  margin-bottom: 20px;
}
.survey-head h1 {
  font-family: var(--serif, Georgia, serif);
  font-size: 24px;
  font-weight: 500;
  margin: 0 0 6px;
  color: var(--text, #1e2238);
}
.survey-sub {
  margin: 0;
  font-size: 14px;
  color: var(--text-muted, #4a4d63);
}
.survey-form fieldset {
  border: 0;
  padding: 0;
  margin: 0 0 18px;
}
.survey-form legend {
  display: block;
  margin-bottom: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text, #1e2238);
}
.survey-radio-row,
.survey-check-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.survey-radio-row label,
.survey-check-row label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border: 1px solid rgba(30, 34, 56, 0.18);
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  background: #fff;
}
.survey-radio-row label:hover,
.survey-check-row label:hover {
  background: rgba(184, 132, 43, 0.06);
}
.survey-radio-row input,
.survey-check-row input {
  margin: 0;
}
.survey-form input[type="text"],
.survey-form textarea {
  width: 100%;
  border: 1px solid rgba(30, 34, 56, 0.18);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  box-sizing: border-box;
  font-family: inherit;
  background: #fff;
}
.survey-form input[type="text"]:focus,
.survey-form textarea:focus {
  outline: none;
  border-color: rgba(184, 132, 43, 0.55);
  box-shadow: 0 0 0 3px rgba(184, 132, 43, 0.15);
}
.survey-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 8px;
}
.survey-actions .auth-link {
  background: transparent;
  border: 0;
  color: var(--text-muted, #4a4d63);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
}
.survey-actions .auth-btn {
  padding: 10px 22px;
}
@media (max-width: 600px) {
  .survey-card { padding: 24px 18px 18px; }
}

/* ---------- Why Atrium page ---------- */
.why-page {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.why-hero {
  text-align: center;
  padding: 24px 16px 36px;
}
.why-eyebrow {
  display: inline-block;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(184, 132, 43, 0.10);
  border: 1px solid rgba(220, 160, 30, 0.30);
  color: #8a6300;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 14px;
}
.why-hero h1 {
  font-family: var(--serif, Georgia, serif);
  font-size: 42px;
  line-height: 1.15;
  font-weight: 500;
  margin: 0 0 14px;
  color: var(--text, #1e2238);
}
.why-hero h1 em {
  color: #8a6300;
  font-style: italic;
}
.why-lede {
  font-size: 17px;
  line-height: 1.55;
  color: var(--text-muted, #4a4d63);
  max-width: 720px;
  margin: 0 auto 24px;
}
.why-cta-row {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
}
.cta-link {
  background: transparent;
  border: 0;
  color: var(--text-muted, #4a4d63);
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
}
.cta-link:hover { color: var(--text, #1e2238); }

.why-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  margin-top: 24px;
}
.why-card {
  background: #fff;
  border: 1px solid rgba(30, 34, 56, 0.08);
  border-radius: 16px;
  padding: 24px 22px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.04);
  transition: transform 200ms ease, box-shadow 200ms ease;
}
.why-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.08);
}
.why-card-icon {
  font-size: 28px;
  margin-bottom: 12px;
}
.why-card h3 {
  font-family: var(--serif, Georgia, serif);
  font-size: 18px;
  font-weight: 500;
  margin: 0 0 8px;
  color: var(--text, #1e2238);
}
.why-card p {
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted, #4a4d63);
  margin: 0;
}

.why-cta-card {
  margin-top: 40px;
  text-align: center;
  background: linear-gradient(135deg, rgba(184, 132, 43, 0.08), rgba(243, 201, 105, 0.15));
  border: 1px solid rgba(220, 160, 30, 0.35);
  border-radius: 20px;
  padding: 36px 24px;
}
.why-cta-card h2 {
  font-family: var(--serif, Georgia, serif);
  font-weight: 500;
  font-size: 26px;
  margin: 0 0 10px;
  color: var(--text, #1e2238);
}
.why-cta-card p {
  color: var(--text-muted, #4a4d63);
  margin: 0 0 18px;
  font-size: 15px;
}

@media (max-width: 600px) {
  .why-hero h1 { font-size: 32px; }
  .why-lede { font-size: 15px; }
}

/* ---------- FAQ page ---------- */
.faq-page {
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}
.faq-hero {
  text-align: center;
  margin-bottom: 28px;
}
.faq-hero h1 {
  font-family: var(--serif, Georgia, serif);
  font-size: 32px;
  font-weight: 500;
  margin: 0 0 10px;
  color: var(--text, #1e2238);
}
.faq-sub {
  font-size: 14px;
  color: var(--text-muted, #4a4d63);
  margin: 0 0 18px;
}
.faq-sub a { color: #8a6300; }
.faq-search input {
  width: 100%;
  max-width: 480px;
  height: 44px;
  border: 1px solid rgba(30, 34, 56, 0.18);
  border-radius: 10px;
  padding: 0 14px;
  font-size: 14px;
}
.faq-search input:focus {
  outline: none;
  border-color: rgba(184, 132, 43, 0.55);
  box-shadow: 0 0 0 3px rgba(184, 132, 43, 0.15);
}
.faq-group {
  margin: 28px 0;
}
.faq-group h2 {
  font-family: var(--serif, Georgia, serif);
  font-size: 20px;
  font-weight: 500;
  color: var(--text, #1e2238);
  margin: 0 0 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(30, 34, 56, 0.10);
}
.faq-group details {
  background: #fff;
  border: 1px solid rgba(30, 34, 56, 0.08);
  border-radius: 12px;
  padding: 12px 16px;
  margin-bottom: 10px;
}
.faq-group details[open] {
  background: rgba(184, 132, 43, 0.04);
  border-color: rgba(220, 160, 30, 0.25);
}
.faq-group summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 15px;
  color: var(--text, #1e2238);
  list-style: none;
  position: relative;
  padding-right: 22px;
}
.faq-group summary::-webkit-details-marker { display: none; }
.faq-group summary::after {
  content: '+';
  position: absolute;
  right: 0;
  top: 0;
  font-size: 18px;
  color: var(--text-muted, #4a4d63);
}
.faq-group details[open] summary::after { content: '−'; }
.faq-group details p {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text, #1e2238);
}
.faq-group details.hidden,
.faq-group.hidden {
  display: none;
}
.faq-cta-card {
  margin-top: 32px;
  text-align: center;
  background: rgba(30, 34, 56, 0.04);
  border-radius: 14px;
  padding: 24px;
}
.faq-cta-card h2 {
  font-family: var(--serif, Georgia, serif);
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 6px;
}
.faq-cta-card p {
  margin: 0;
  color: var(--text-muted, #4a4d63);
  font-size: 14px;
}
.faq-cta-card a { color: #8a6300; }

/* ---------- Profile: Danger Zone + multi-step account-delete modal ---------- */

.profile-danger-zone {
  margin-top: 32px;
  border: 1px solid rgba(180, 40, 40, 0.30);
  background: rgba(180, 40, 40, 0.04);
  border-radius: 12px;
  padding: 18px 20px;
}
.profile-danger-zone legend {
  color: #a3271f;
  font-weight: 700;
  padding: 0 8px;
}
.profile-danger-row {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
}
.profile-danger-text {
  flex: 1;
  min-width: 220px;
}
.profile-danger-text strong {
  display: block;
  color: #a3271f;
  font-size: 15px;
  margin-bottom: 4px;
}
.profile-danger-text p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted, #4a4d63);
  line-height: 1.5;
}
.profile-danger-btn {
  background: #fff;
  color: #a3271f;
  border: 1px solid rgba(180, 40, 40, 0.45);
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.profile-danger-btn:hover {
  background: #a3271f;
  color: #fff;
}
.profile-danger-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.delete-overlay {
  position: fixed;
  inset: 0;
  z-index: 8800;
  background: rgba(20, 22, 36, 0.65);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 32px 16px;
  overflow-y: auto;
}
.delete-card {
  position: relative;
  background: #fff;
  border-radius: 16px;
  width: 100%;
  max-width: 540px;
  padding: 36px 32px 28px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.30);
}
.delete-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: transparent;
  border: 0;
  font-size: 26px;
  line-height: 1;
  color: var(--text-muted, #4a4d63);
  cursor: pointer;
}
.delete-close:hover { color: var(--text, #1e2238); }

.delete-steps {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-bottom: 18px;
}
.delete-step-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(30, 34, 56, 0.08);
  color: var(--text-muted, #4a4d63);
  font-size: 13px;
  font-weight: 700;
  transition: background 200ms ease, color 200ms ease;
}
.delete-step-dot.is-active {
  background: #a3271f;
  color: #fff;
}
.delete-step-line {
  flex: 0 0 30px;
  height: 2px;
  background: rgba(30, 34, 56, 0.10);
}

.delete-pane {
  display: none;
}
.delete-pane.is-active {
  display: block;
}
.delete-pane h1 {
  font-family: var(--serif, Georgia, serif);
  font-size: 22px;
  font-weight: 500;
  margin: 0 0 8px;
  color: #a3271f;
}
.delete-lede {
  font-size: 14px;
  color: var(--text-muted, #4a4d63);
  line-height: 1.55;
  margin: 0 0 16px;
}
.delete-impact-list {
  list-style: none;
  padding: 0;
  margin: 0 0 16px;
}
.delete-impact-list li {
  padding: 6px 0;
  font-size: 14px;
  color: var(--text, #1e2238);
  border-bottom: 1px dashed rgba(30, 34, 56, 0.08);
}
.delete-impact-list li:last-child { border-bottom: 0; }

.delete-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(180, 40, 40, 0.03);
  margin-bottom: 8px;
  cursor: pointer;
  font-size: 14px;
  line-height: 1.45;
  color: var(--text, #1e2238);
}
.delete-check input {
  margin-top: 3px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
}
.delete-check span strong { color: #a3271f; }

.delete-expected-email {
  font-size: 12px;
  color: var(--text-muted, #4a4d63);
  background: rgba(30, 34, 56, 0.04);
  padding: 6px 10px;
  border-radius: 6px;
  margin-bottom: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}
.delete-input {
  width: 100%;
  box-sizing: border-box;
  height: 44px;
  padding: 0 12px;
  border: 1px solid rgba(30, 34, 56, 0.18);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
}
.delete-input:focus {
  outline: none;
  border-color: rgba(180, 40, 40, 0.55);
  box-shadow: 0 0 0 3px rgba(180, 40, 40, 0.15);
}

.delete-actions {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 18px;
}
.delete-secondary,
.delete-primary,
.delete-final {
  border: 0;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 600;
  border-radius: 10px;
  cursor: pointer;
}
.delete-secondary {
  background: transparent;
  color: var(--text-muted, #4a4d63);
  border: 1px solid rgba(30, 34, 56, 0.18);
}
.delete-secondary:hover {
  background: rgba(30, 34, 56, 0.05);
}
.delete-primary {
  background: #1e2238;
  color: #fff;
}
.delete-primary:hover { background: #2a2f50; }
.delete-primary:disabled,
.delete-final:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.delete-final {
  background: #a3271f;
  color: #fff;
}
.delete-final:hover:not(:disabled) {
  background: #872019;
}
.delete-pane code {
  background: rgba(30, 34, 56, 0.06);
  padding: 1px 6px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.account-deleted-banner {
  position: fixed;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 9100;
  display: flex;
  align-items: center;
  gap: 12px;
  background: #1e2238;
  color: #fff;
  padding: 12px 16px;
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.25);
  font-size: 14px;
  max-width: 540px;
}
.account-deleted-banner button {
  background: transparent;
  border: 0;
  color: rgba(255, 255, 255, 0.75);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.account-deleted-banner button:hover { color: #fff; }

/* ---------- Mobile hamburger nav ---------- */

/* The hamburger sits on the right edge of the nav bar and is only
   visible at phone widths. Three bars stack into a tidy "X" when
   the menu is open. */
.nav-hamburger {
  display: none;
  width: 40px;
  height: 40px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border-strong, rgba(30, 34, 56, 0.18));
  border-radius: 8px;
  cursor: pointer;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
}
.nav-hamburger-bar {
  display: block;
  width: 20px;
  height: 2px;
  background: var(--text, #1e2238);
  border-radius: 2px;
  transition: transform 200ms ease, opacity 200ms ease;
}
body.nav-open .nav-hamburger-bar:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
body.nav-open .nav-hamburger-bar:nth-child(2) { opacity: 0; }
body.nav-open .nav-hamburger-bar:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

@media (max-width: 720px) {
  .nav { padding: 12px 18px; position: relative; }
  .nav-hamburger { display: flex; }

  /* Hide the right-side cluster by default on phones. When the
     hamburger toggles body.nav-open, slide it down as a full-width
     panel under the nav. */
  .nav-right {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    padding: 12px 16px 20px;
    background: var(--nav-bg, rgba(247, 245, 240, 0.98));
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--border);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.12);
    transform: translateY(-8px);
    opacity: 0;
    pointer-events: none;
    transition: transform 200ms ease, opacity 200ms ease;
    max-height: calc(100vh - 64px);
    overflow-y: auto;
  }
  :root[data-theme="dark"] .nav-right {
    background: rgba(10, 14, 22, 0.97);
  }
  body.nav-open .nav-right {
    transform: translateY(0);
    opacity: 1;
    pointer-events: auto;
  }

  /* In the drawer, every child becomes a full-width row. */
  .nav-right > * {
    width: 100%;
    box-sizing: border-box;
  }
  .nav-right .nav-search {
    display: block;
    width: 100%;
    height: 40px;
  }
  .nav-right .nav-link,
  .nav-right .nav-cta {
    text-align: left;
    padding: 10px 12px;
    border-radius: 8px;
    width: 100%;
  }
  .nav-right .theme-toggle {
    width: 100%;
    height: 40px;
    border-radius: 8px;
    text-align: center;
  }
  /* The two existing dropdown menus (About Atrium, My Details) become
     inline expanding sections in the drawer instead of floating
     popovers. */
  .nav-right .nav-menu {
    display: block;
    width: 100%;
  }
  .nav-right .nav-menu-items {
    position: static;
    box-shadow: none;
    border: 0;
    background: rgba(30, 34, 56, 0.04);
    border-radius: 8px;
    margin: 4px 0 6px;
    padding: 4px;
    width: 100%;
    min-width: 0;
  }
  :root[data-theme="dark"] .nav-right .nav-menu-items {
    background: rgba(255, 255, 255, 0.04);
  }
  .nav-right .nav-menu-item {
    width: 100%;
    text-align: left;
    padding: 10px 12px;
  }
  .nav-right .progress-pill,
  .nav-right .greeting,
  .nav-right .streak-chip,
  .nav-right .points-chip {
    text-align: left;
  }
  .nav-right #navUser {
    display: block;
    width: 100%;
  }
}

/* Prevent the body from scrolling behind the drawer on phones; users
   tend to "pull" the drawer area and end up scrolling the page
   underneath. */
@media (max-width: 720px) {
  body.nav-open { overflow: hidden; }
}

/* ---------- PhotoAtrium ---------- */

/* Warning banner + Homework Mode toggle. Shown at the top of the
   scanner result page and the history list. Same look on both. */
.pa-warning-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  background: rgba(184, 132, 43, 0.08);
  border: 1px solid rgba(220, 160, 30, 0.30);
  border-radius: 12px;
  padding: 12px 16px;
  margin: 0 auto 18px;
  max-width: 960px;
}
.pa-warning-text {
  flex: 1;
  min-width: 220px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--text, #1e2238);
}
.pa-warning-text strong {
  display: block;
  margin-bottom: 2px;
  color: #8a6300;
  font-size: 14px;
}
.pa-warning-text span { color: var(--text-muted, #4a4d63); }

.pa-hw-toggle {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--text, #1e2238);
  flex-shrink: 0;
}
.pa-hw-toggle input { display: none; }
.pa-hw-slider {
  position: relative;
  width: 38px;
  height: 22px;
  background: rgba(30, 34, 56, 0.20);
  border-radius: 999px;
  transition: background 200ms ease;
}
.pa-hw-slider::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.20);
  transition: transform 200ms ease;
}
.pa-hw-toggle input:checked + .pa-hw-slider {
  background: #b8842b;
}
.pa-hw-toggle input:checked + .pa-hw-slider::after {
  transform: translateX(16px);
}
.pa-hw-label { white-space: nowrap; }

/* Homework Mode reveal placeholder buttons. Replace the hidden eq
   element when the toggle is on; click swaps to the actual answer. */
.pa-reveal-btn {
  display: block;
  width: 100%;
  padding: 14px 16px;
  background: rgba(184, 132, 43, 0.08);
  border: 2px dashed rgba(220, 160, 30, 0.45);
  color: #8a6300;
  font-weight: 600;
  font-size: 14px;
  border-radius: 10px;
  cursor: pointer;
  font-family: inherit;
  text-align: center;
  transition: background 200ms ease, transform 100ms ease;
}
.pa-reveal-btn:hover:not([disabled]) {
  background: rgba(184, 132, 43, 0.14);
}
.pa-reveal-btn:active:not([disabled]) { transform: scale(0.98); }
.pa-reveal-btn[disabled] {
  cursor: not-allowed;
  opacity: 0.5;
  background: rgba(30, 34, 56, 0.04);
  border-color: rgba(30, 34, 56, 0.18);
  color: var(--text-muted, #4a4d63);
}
.pa-reveal-btn.pa-hidden,
.pa-step-eq.pa-hidden,
.pa-answer-eq.pa-hidden,
.pa-step-content.pa-hidden {
  display: none !important;
}
.pa-reveal-answer {
  padding: 18px 16px;
  font-size: 15px;
}

/* The step number circle for a locked step shows a 🔒 instead of the
   numeral so the counter doesn't go ahead of what's been revealed. */
.pa-step-locked::before {
  content: '🔒' !important;
  background: rgba(30, 34, 56, 0.12) !important;
  color: var(--text-muted, #4a4d63) !important;
}

/* Hint card — the opening nudge in Homework Mode. */
.pa-hint-block {
  background: linear-gradient(135deg, rgba(74, 111, 165, 0.10), rgba(74, 111, 165, 0.04));
  border: 1px solid rgba(74, 111, 165, 0.30);
  border-radius: 14px;
  padding: 16px 20px;
  margin-bottom: 16px;
}
.pa-hint-block .pa-block-label {
  color: #2c5384;
}
.pa-hint-body {
  font-size: 15px;
  font-weight: 500;
  color: var(--text, #1e2238);
  line-height: 1.5;
  margin-bottom: 8px;
}
.pa-hint-foot {
  font-size: 12px;
  color: var(--text-muted, #4a4d63);
  font-style: italic;
}

/* "Best on mobile" confirmation modal — desktop-only. */
.pa-confirm-overlay {
  position: fixed;
  inset: 0;
  z-index: 8200;
  background: rgba(20, 22, 36, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.pa-confirm-card {
  background: #fff;
  border-radius: 16px;
  max-width: 460px;
  width: 100%;
  padding: 32px 30px 24px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.30);
}
.pa-confirm-icon {
  font-size: 44px;
  margin-bottom: 8px;
}
.pa-confirm-card h2 {
  font-family: var(--serif, Georgia, serif);
  font-weight: 500;
  font-size: 22px;
  margin: 0 0 12px;
  color: var(--text, #1e2238);
}
.pa-confirm-card p {
  margin: 0 0 12px;
  font-size: 14px;
  line-height: 1.55;
  color: var(--text-muted, #4a4d63);
}
.pa-confirm-sub {
  font-weight: 600;
  color: var(--text, #1e2238) !important;
  margin-top: 6px !important;
}
.pa-confirm-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.pa-confirm-actions .cta-primary,
.pa-confirm-actions .cta-secondary {
  min-width: 140px;
}

/* Floating action button: scan a math problem from any signed-in page. */
.pa-fab {
  position: fixed;
  right: 20px;
  bottom: 96px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 6px;
  background: linear-gradient(135deg, #b8842b 0%, #f3c969 100%);
  color: #1e2238;
  border: 0;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: 0 8px 24px rgba(184, 132, 43, 0.40);
  cursor: pointer;
  font-weight: 700;
  font-size: 14px;
  transition: transform 200ms ease, box-shadow 200ms ease;
}
.pa-fab:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 30px rgba(184, 132, 43, 0.50);
}
.pa-fab-icon { font-size: 18px; }
.pa-fab-label { letter-spacing: 0.2px; }
@media (max-width: 720px) {
  .pa-fab { bottom: 20px; right: 16px; padding: 10px 14px; }
  .pa-fab-label { display: none; }
}

/* Scanner page: full-screen camera viewfinder. */
.pa-scanner-page {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: #000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}
.pa-scanner-close {
  position: absolute;
  top: 16px;
  right: 16px;
  z-index: 5;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.3);
  font-size: 18px;
  cursor: pointer;
}
.pa-scanner-frame {
  flex: 1;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
#paCameraVideo {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.pa-scanner-overlay {
  position: absolute;
  inset: 12% 8%;
  pointer-events: none;
  border: 0;
}
.pa-reticle {
  position: absolute;
  width: 32px;
  height: 32px;
  border-color: rgba(255, 216, 107, 0.85);
  border-style: solid;
  border-width: 0;
}
.pa-reticle-tl { top: 0; left: 0; border-top-width: 3px; border-left-width: 3px; border-top-left-radius: 8px; }
.pa-reticle-tr { top: 0; right: 0; border-top-width: 3px; border-right-width: 3px; border-top-right-radius: 8px; }
.pa-reticle-bl { bottom: 0; left: 0; border-bottom-width: 3px; border-left-width: 3px; border-bottom-left-radius: 8px; }
.pa-reticle-br { bottom: 0; right: 0; border-bottom-width: 3px; border-right-width: 3px; border-bottom-right-radius: 8px; }
.pa-scanner-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  background: rgba(0, 0, 0, 0.55);
  padding: 6px 12px;
  border-radius: 999px;
  text-align: center;
  white-space: nowrap;
}
.pa-camera-error {
  background: rgba(180, 40, 40, 0.92);
  color: #fff;
  padding: 10px 16px;
  font-size: 13px;
  text-align: center;
}
.pa-scanner-controls {
  width: 100%;
  padding: 18px 16px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: linear-gradient(180deg, rgba(0,0,0,0) 0%, rgba(0,0,0,0.6) 100%);
}
.pa-shutter {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #fff;
  border: 4px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 100ms ease;
}
.pa-shutter:active { transform: scale(0.92); }
.pa-shutter-inner {
  width: 56px;
  height: 56px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.05) inset;
}
.pa-file-fallback {
  color: rgba(255, 255, 255, 0.85);
  font-size: 13px;
  text-decoration: underline;
  cursor: pointer;
  padding: 6px 10px;
}

/* Result page */
.pa-result-page {
  max-width: 760px;
  margin: 0 auto;
  padding: 24px 18px 80px;
}
.pa-result-hero { text-align: center; margin-bottom: 16px; }
.pa-result-hero h1 {
  font-family: var(--serif, Georgia, serif);
  font-size: 26px;
  margin: 0 0 4px;
}
.pa-result-sub { color: var(--text-muted, #4a4d63); margin: 0; font-size: 14px; }
.pa-result-content { margin-top: 16px; }

.pa-solving {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 40px 16px;
  text-align: center;
}
.pa-solving-thumb img {
  max-width: 240px;
  max-height: 200px;
  border-radius: 12px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.12);
  object-fit: cover;
}
.pa-solving-text h2 {
  font-family: var(--serif, Georgia, serif);
  font-size: 18px;
  font-weight: 500;
  margin: 12px 0 6px;
}
.pa-solving-text p { color: var(--text-muted, #4a4d63); margin: 0; font-size: 14px; }
.pa-spinner {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 3px solid rgba(184, 132, 43, 0.20);
  border-top-color: #b8842b;
  animation: pa-spin 0.8s linear infinite;
  margin: 0 auto;
}
@keyframes pa-spin { to { transform: rotate(360deg); } }

.pa-result-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 18px;
}
.pa-result-thumb {
  width: 80px;
  height: 80px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.10);
}
.pa-result-meta { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pa-result-date { font-size: 12px; color: var(--text-muted, #4a4d63); }

.pa-block-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted, #4a4d63);
  font-weight: 700;
  margin-bottom: 8px;
}
.pa-problem-block,
.pa-answer-block,
.pa-steps-block {
  background: #fff;
  border: 1px solid rgba(30, 34, 56, 0.08);
  border-radius: 14px;
  padding: 18px 20px;
  margin-bottom: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}
.pa-problem-eq { font-size: 17px; color: var(--text, #1e2238); }
.pa-answer-block {
  background: linear-gradient(135deg, rgba(184, 132, 43, 0.10), rgba(243, 201, 105, 0.18));
  border-color: rgba(220, 160, 30, 0.35);
}
.pa-answer-eq { font-size: 22px; font-weight: 600; color: #1e2238; }
.pa-edit-wrap { margin-top: 12px; font-size: 13px; color: var(--text-muted, #4a4d63); }
.pa-edit-wrap summary { cursor: pointer; }
.pa-edit-input {
  width: 100%;
  margin-top: 8px;
  padding: 8px 10px;
  border: 1px solid rgba(30, 34, 56, 0.18);
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 13px;
  box-sizing: border-box;
}
.pa-edit-btn { margin-top: 8px; }

.pa-illustration {
  text-align: center;
  margin: 0 0 16px;
  padding: 12px;
  background: #fff;
  border-radius: 14px;
  border: 1px solid rgba(30, 34, 56, 0.08);
}
.pa-illustration svg { max-width: 100%; height: auto; }

.pa-method {
  border: 1px solid rgba(30, 34, 56, 0.10);
  border-radius: 10px;
  margin-bottom: 10px;
  padding: 10px 14px;
}
.pa-method[open] { background: rgba(184, 132, 43, 0.03); }
.pa-method > summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--text, #1e2238);
  list-style: none;
  font-size: 15px;
}
.pa-method > summary::-webkit-details-marker { display: none; }
.pa-method > summary::before {
  content: '▸ ';
  display: inline-block;
  transition: transform 200ms ease;
  margin-right: 4px;
}
.pa-method[open] > summary::before { transform: rotate(90deg); }

.pa-steps {
  list-style: none;
  counter-reset: pastep;
  padding: 8px 0 0;
  margin: 0;
}
.pa-step {
  counter-increment: pastep;
  position: relative;
  padding: 10px 12px 10px 44px;
  margin-bottom: 8px;
  background: #fff;
  border: 1px solid rgba(30, 34, 56, 0.08);
  border-radius: 10px;
}
.pa-step::before {
  content: counter(pastep);
  position: absolute;
  left: 10px;
  top: 12px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #b8842b;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
}
.pa-step-eq { font-size: 16px; margin-bottom: 6px; }
.pa-step-why { font-size: 13px; color: var(--text-muted, #4a4d63); }
.pa-step-why summary {
  cursor: pointer;
  list-style: none;
  display: inline-block;
  color: #8a6300;
  font-weight: 600;
}
.pa-step-why summary::-webkit-details-marker { display: none; }
.pa-step-why summary::after { content: ' ▾'; font-size: 10px; }
.pa-step-why[open] summary::after { content: ' ▴'; }
.pa-step-why-body {
  margin-top: 6px;
  color: var(--text, #1e2238);
  line-height: 1.5;
}

.pa-note {
  background: rgba(30, 34, 56, 0.04);
  border-radius: 10px;
  padding: 12px 14px;
  font-size: 13px;
  color: var(--text, #1e2238);
  margin-bottom: 16px;
}

.pa-result-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 18px;
}
.pa-delete-btn {
  background: transparent;
  border: 1px solid rgba(180, 40, 40, 0.30);
  color: #a3271f;
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
}
.pa-delete-btn:hover { background: rgba(180, 40, 40, 0.08); }

.pa-error { text-align: center; padding: 40px 16px; }
.pa-error-icon { font-size: 36px; margin-bottom: 8px; }
.pa-error h3 {
  font-family: var(--serif, Georgia, serif);
  font-weight: 500;
  font-size: 20px;
  margin: 0 0 8px;
}
.pa-error p { color: var(--text-muted, #4a4d63); margin: 0 0 18px; }

/* List page */
.pa-list-page {
  max-width: 1000px;
  margin: 0 auto;
  padding: 28px 20px 80px;
}
.pa-list-hero { text-align: center; margin-bottom: 24px; }
.pa-list-hero h1 {
  font-family: var(--serif, Georgia, serif);
  font-size: 28px;
  margin: 0 0 6px;
}
.pa-list-sub { color: var(--text-muted, #4a4d63); margin: 0 0 16px; font-size: 14px; }
.pa-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 14px;
}
.pa-card {
  text-align: left;
  background: #fff;
  border: 1px solid rgba(30, 34, 56, 0.08);
  border-radius: 14px;
  padding: 0;
  cursor: pointer;
  overflow: hidden;
  transition: transform 200ms ease, box-shadow 200ms ease;
  display: flex;
  flex-direction: column;
}
.pa-card:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(0, 0, 0, 0.08); }
.pa-card-thumb {
  height: 130px;
  background: rgba(30, 34, 56, 0.04);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pa-card-thumb img { width: 100%; height: 100%; object-fit: cover; }
.pa-card-thumb-fallback { font-size: 32px; opacity: 0.5; }
.pa-card-body {
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.pa-card-problem {
  font-size: 13px;
  color: var(--text, #1e2238);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.pa-card-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted, #4a4d63);
  margin-top: auto;
}

.pa-tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  background: rgba(30, 34, 56, 0.08);
  color: var(--text, #1e2238);
}
.pa-tag-algebra { background: rgba(74, 111, 165, 0.16); color: #2c5384; }
.pa-tag-geometry { background: rgba(106, 168, 79, 0.16); color: #3d6929; }
.pa-tag-arithmetic { background: rgba(184, 132, 43, 0.16); color: #8a6300; }
.pa-tag-calculus { background: rgba(160, 65, 145, 0.16); color: #6b1d61; }
.pa-tag-trigonometry { background: rgba(220, 120, 60, 0.16); color: #8a3a14; }
.pa-tag-statistics { background: rgba(60, 140, 160, 0.16); color: #1a4d60; }
.pa-tag-precalculus { background: rgba(80, 110, 200, 0.16); color: #1f3b8a; }
.pa-tag-prealgebra { background: rgba(120, 110, 200, 0.16); color: #3c2c8a; }

.pa-list-empty {
  text-align: center;
  padding: 60px 20px;
  background: #fff;
  border-radius: 16px;
  border: 1px dashed rgba(30, 34, 56, 0.18);
  grid-column: 1 / -1;
}
.pa-list-empty-icon { font-size: 48px; opacity: 0.4; margin-bottom: 8px; }
.pa-list-empty h3 {
  font-family: var(--serif, Georgia, serif);
  font-weight: 500;
  font-size: 20px;
  margin: 0 0 8px;
}
.pa-list-empty p { color: var(--text-muted, #4a4d63); margin: 0 0 18px; }

@media (max-width: 600px) {
  .pa-result-head { flex-direction: column; align-items: flex-start; }
  .pa-result-thumb { width: 100%; height: 160px; }
  .pa-result-actions { flex-direction: column; }
  .pa-result-actions > * { width: 100%; }
}
