:root {
  --bg: #f6f5f1;
  --surface: #ffffff;
  --ink: #1d2230;
  --muted: #667085;
  --line: #e6e3db;
  --brand: #3b5bdb;
  --brand-ink: #ffffff;
  --brand-soft: #e8edff;
  --rw: #7048e8;
  --rw-soft: #efe9ff;
  --math: #0c8599;
  --math-soft: #e0f5f7;
  --good: #2f9e44;
  --good-soft: #e6f6e9;
  --bad: #e03131;
  --bad-soft: #fdecec;
  --warn: #e8590c;
  --warn-soft: #fff1e6;
  --shadow: 0 1px 2px rgba(20, 24, 40, .05), 0 4px 16px rgba(20, 24, 40, .05);
  --radius: 16px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12141b;
    --surface: #1b1e28;
    --ink: #e9ebf2;
    --muted: #9aa1b3;
    --line: #2b2f3d;
    --brand: #6b85ff;
    --brand-ink: #0e1120;
    --brand-soft: #232a4a;
    --rw: #9d7dff;
    --rw-soft: #2a2244;
    --math: #3bc0d4;
    --math-soft: #16323a;
    --good: #51cf66;
    --good-soft: #1a3322;
    --bad: #ff6b6b;
    --bad-soft: #3a1d20;
    --warn: #ff922b;
    --warn-soft: #3a2616;
    --shadow: none;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 16px/1.55 Inter, system-ui, -apple-system, "Segoe UI", sans-serif;
}
h1, h2, h3 { font-family: Fraunces, Georgia, serif; font-weight: 700; line-height: 1.2; margin: 0; }
a { color: inherit; text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.eyebrow { display: block; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }

/* ---------- chrome ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 24px; border-bottom: 1px solid var(--line); background: var(--surface);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.logo {
  display: inline-grid; place-items: center; width: 30px; height: 30px; border-radius: 8px;
  background: var(--brand); color: var(--brand-ink); font: 700 16px Fraunces, Georgia, serif;
}
.logo.big { width: 56px; height: 56px; border-radius: 16px; font-size: 30px; }
.topbar nav { display: flex; gap: 18px; align-items: center; font-size: 14px; }
.who { font-weight: 600; }
.link { color: var(--muted); }
.link:hover { color: var(--ink); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 0; border-radius: 12px; padding: 12px 20px; font: 600 15px Inter, system-ui, sans-serif;
  cursor: pointer; transition: transform .08s, opacity .15s; white-space: nowrap;
}
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--brand); color: var(--brand-ink); }
.btn.primary:disabled { opacity: .4; cursor: default; }
.btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); padding: 8px 14px; }
.btn.wide { width: 100%; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 22px; }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.login-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; box-shadow: var(--shadow); padding: 36px 28px; }
.login-head { text-align: center; margin-bottom: 26px; }
.login-head h1 { font-size: 32px; margin: 14px 0 4px; }
.who-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 20px; }
.who-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: 8px; padding: 18px 10px; border: 2px solid var(--line); border-radius: 16px; cursor: pointer; transition: border-color .15s, background .15s; }
.who-tile input { position: absolute; opacity: 0; pointer-events: none; }
.who-tile:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.who-tile:has(input:focus-visible) { outline: 2px solid var(--brand); outline-offset: 2px; }
.avatar { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font: 700 22px Fraunces, Georgia, serif; color: #fff; }
.avatar.a1 { background: linear-gradient(135deg, #f76707, #e64980); }
.avatar.a2 { background: linear-gradient(135deg, #7048e8, #1c7ed6); }
.who-name { font-weight: 600; }
.field { display: block; margin-bottom: 16px; }
.field span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; }
.field input { width: 100%; padding: 13px 14px; font-size: 18px; letter-spacing: .15em; border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--ink); }
.field input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.error { color: var(--bad); background: var(--bad-soft); padding: 10px 12px; border-radius: 10px; font-size: 14px; margin: 0 0 16px; }

/* ---------- dashboard ---------- */
.page { max-width: 1080px; margin: 0 auto; padding: 32px 24px 64px; }
.hello h1 { font-size: 34px; margin-bottom: 6px; }
.grid-top { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 16px; margin: 28px 0 36px; }
.today { display: flex; align-items: center; gap: 20px; transition: border-color .15s; }
.today:hover, .journal:not(.empty):hover { border-color: var(--brand); }
.today-text { flex: 1; min-width: 0; }
.today-text h2 { font-size: 22px; margin: 4px 0; }
.today-text p { margin: 0; font-size: 14px; }
.ring {
  --p: 0; flex: none; width: 76px; height: 76px; border-radius: 50%; display: grid; place-items: center;
  background: conic-gradient(var(--brand) calc(var(--p) * 1%), var(--brand-soft) 0);
}
.ring span { width: 60px; height: 60px; border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-size: 13px; color: var(--muted); }
.ring b { font-size: 20px; color: var(--ink); }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat .num { font: 700 34px Fraunces, Georgia, serif; }
.stat .muted { font-size: 13px; }
.journal:not(.empty) .num { color: var(--warn); }
.journal.empty { cursor: default; }

.section-title { font-size: 22px; margin-bottom: 4px; }
.skills { margin-bottom: 36px; }
.skill-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 16px; }
.skill-card h3 { font-size: 18px; margin-bottom: 16px; display: flex; align-items: center; gap: 10px; }
.skill-card h3::before { content: ""; width: 10px; height: 10px; border-radius: 3px; }
.skill-card.rw h3::before { background: var(--rw); }
.skill-card.math h3::before { background: var(--math); }
.skill-row { margin-bottom: 14px; }
.skill-row:last-child { margin-bottom: 0; }
.skill-label { display: flex; justify-content: space-between; gap: 12px; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.bar { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; border-radius: 99px; transition: width .6s ease; }
.bar.low i { background: var(--bad); }
.bar.mid i { background: var(--warn); }
.bar.high i { background: var(--good); }
.bar.untested { background: repeating-linear-gradient(90deg, var(--line) 0 6px, transparent 6px 10px); }

.plan ol { margin: 14px 0 12px; padding-left: 22px; }
.plan li { margin-bottom: 8px; }

.hello { display: flex; align-items: center; gap: 22px; }
.countdown { flex: none; display: flex; align-items: center; gap: 10px; padding: 12px 16px; border-radius: 16px; background: var(--brand); color: var(--brand-ink); }
.countdown b { font: 700 38px/1 Fraunces, Georgia, serif; }
.countdown span { font-size: 13px; font-weight: 600; line-height: 1.3; }
.countdown small { font-weight: 500; opacity: .85; }

.roadmap { margin-bottom: 36px; }
.timeline { list-style: none; margin: 18px 0 0; padding: 0; }
.timeline li { position: relative; padding: 0 0 18px 26px; border-left: 2px solid var(--line); margin-left: 6px; }
.timeline li:last-child { padding-bottom: 0; border-left-color: transparent; }
.timeline li::before { content: ""; position: absolute; left: -7px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface); border: 2px solid var(--line); }
.timeline li.past::before { background: var(--good); border-color: var(--good); }
.timeline li.now::before { background: var(--brand); border-color: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft); }
.timeline .when { display: block; font-size: 12px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted); }
.timeline li.now .when { color: var(--brand); }
.timeline p { margin: 2px 0 0; font-size: 14px; }
.timeline .you { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em; padding: 2px 8px; border-radius: 99px; background: var(--brand-soft); color: var(--brand); margin-left: 6px; }
.timeline li.past b, .timeline li.past p { opacity: .6; }

/* ---------- practice ---------- */
.practice { max-width: 1180px; margin: 0 auto; padding: 20px 24px 64px; }
.practice-bar { display: flex; align-items: center; gap: 14px; margin-bottom: 18px; font-size: 14px; }
.practice-bar .link { margin-right: auto; }
.chip { padding: 5px 12px; border-radius: 99px; font-size: 13px; font-weight: 600; background: var(--brand-soft); color: var(--brand); }
.chip.rw { background: var(--rw-soft); color: var(--rw); }
.chip.math { background: var(--math-soft); color: var(--math); }
.timer { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 40px; text-align: right; }

.practice-body { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; align-items: start; }
.practice-body:has(.desmos-panel:not([hidden])) { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
.qcard { padding: 30px; max-width: 760px; width: 100%; margin: 0 auto; transition: border-color .2s; }
.practice-body:has(.desmos-panel:not([hidden])) .qcard { max-width: none; }
.qcard.right { border-color: var(--good); }
.qcard.wrong { border-color: var(--bad); }
.passage { font-family: Georgia, "Times New Roman", serif; font-size: 17px; line-height: 1.7; padding: 18px 20px; background: var(--bg); border-radius: 12px; margin: 14px 0 18px; white-space: pre-line; }
.prompt { font-weight: 600; font-size: 17px; white-space: pre-line; margin: 14px 0 18px; }
.choices { display: grid; gap: 10px; }
.choice {
  display: flex; align-items: center; gap: 14px; width: 100%; text-align: left;
  padding: 14px 16px; border: 2px solid var(--line); border-radius: 12px; background: var(--surface);
  color: var(--ink); font: 16px Inter, system-ui, sans-serif; cursor: pointer; transition: border-color .12s, background .12s;
}
.choice:hover:not(:disabled) { border-color: var(--brand); }
.choice .letter { flex: none; width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; border: 1.5px solid var(--line); font-weight: 600; font-size: 14px; }
.choice.picked { border-color: var(--brand); background: var(--brand-soft); }
.choice.picked .letter { background: var(--brand); border-color: var(--brand); color: var(--brand-ink); }
.choice.correct { border-color: var(--good); background: var(--good-soft); }
.choice.correct .letter { background: var(--good); border-color: var(--good); color: #fff; }
.choice.incorrect { border-color: var(--bad); background: var(--bad-soft); }
.choice.incorrect .letter { background: var(--bad); border-color: var(--bad); color: #fff; }
.choice:disabled { cursor: default; }

.feedback { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.feedback h3 { font-size: 20px; margin-bottom: 14px; }
.right .feedback h3 { color: var(--good); }
.wrong .feedback h3 { color: var(--bad); }
.fb-block { padding: 12px 16px; border-radius: 12px; background: var(--bg); margin-bottom: 10px; }
.fb-block p { margin: 2px 0 0; }
.fb-label { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.fb-block.trap { background: var(--warn-soft); }
.fb-block.trap .fb-label { color: var(--warn); }
.fb-block.strat { background: var(--brand-soft); }
.fb-block.strat .fb-label { color: var(--brand); }

.actions { display: flex; align-items: center; justify-content: flex-end; gap: 14px; margin-top: 22px; }
.actions .muted { margin-right: auto; }

.desmos-panel { padding: 0; overflow: hidden; position: sticky; top: 76px; }
.desmos-head { display: flex; justify-content: space-between; align-items: baseline; padding: 12px 16px; border-bottom: 1px solid var(--line); }
#calculator { height: min(620px, 70vh); }

.done { max-width: 520px; margin: 40px auto; text-align: center; }
.done h2 { margin-bottom: 8px; }
.done .btn { margin-top: 16px; }

.chip.review-chip { background: var(--warn-soft); color: var(--warn); }

.tutor { margin-top: 16px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; }
.tutor-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--bg); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tutor-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--good); }
.tutor-log { display: flex; flex-direction: column; gap: 8px; padding: 12px 14px; max-height: 360px; overflow-y: auto; }
.tutor-log:empty { display: none; }
.msg { max-width: 85%; padding: 9px 13px; border-radius: 14px; white-space: pre-line; font-size: 15px; }
.msg.me { align-self: flex-end; background: var(--brand); color: var(--brand-ink); border-bottom-right-radius: 4px; }
.msg.tutor { align-self: flex-start; background: var(--bg); border-bottom-left-radius: 4px; }
.msg.thinking { color: var(--muted); font-style: italic; }
.tutor-quick { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 14px 0; }
.tutor-quick:empty { display: none; }
.quick { border: 1px solid var(--brand); color: var(--brand); background: transparent; border-radius: 99px; padding: 6px 12px; font: 500 14px Inter, system-ui, sans-serif; cursor: pointer; }
.quick:hover { background: var(--brand-soft); }
.tutor-form { display: flex; gap: 8px; padding: 12px 14px; }
.tutor-form input { flex: 1; min-width: 0; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--bg); color: var(--ink); font: 15px Inter, system-ui, sans-serif; }
.tutor-form input:focus { outline: 2px solid var(--brand); border-color: transparent; }
.tutor-form .btn { padding: 10px 16px; }

/* step-by-step walkthrough */
.walk { margin-top: 16px; }
.walk-open {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px; border: 2px dashed var(--brand); border-radius: 14px; background: var(--brand-soft);
  color: var(--brand); font: 600 16px Inter, system-ui, sans-serif; cursor: pointer;
}
.walk-open:hover { border-style: solid; }
.walk-icon { font-size: 13px; }
.walk-body { border: 2px solid var(--brand); border-radius: 14px; padding: 16px; }
.walk-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.walk-dots { display: flex; gap: 6px; }
.walk-dots i { width: 9px; height: 9px; border-radius: 50%; background: var(--line); }
.walk-dots i.on { background: var(--brand); }
.walk-steps { list-style: none; counter-reset: s; margin: 0; padding: 0; display: grid; gap: 10px; }
.walk-steps li { counter-increment: s; position: relative; padding: 12px 14px 12px 50px; border-radius: 12px; background: var(--bg); transition: opacity .2s; }
.walk-steps li::before {
  content: counter(s); position: absolute; left: 12px; top: 12px; width: 26px; height: 26px; border-radius: 50%;
  display: grid; place-items: center; font-weight: 700; font-size: 14px; background: var(--line); color: var(--ink);
}
.walk-steps li.current { background: var(--brand-soft); animation: walkIn .25s ease; }
.walk-steps li.current::before { background: var(--brand); color: var(--brand-ink); }
.walk-steps li.done { opacity: .65; }
.walk-steps p { margin: 0; }
.walk-quote { margin-top: 6px !important; font-family: Georgia, serif; font-style: italic; }
.walk-math {
  margin-top: 8px; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
  font: 500 19px/1.6 "SF Mono", ui-monospace, Menlo, Consolas, monospace; white-space: pre-wrap; overflow-x: auto;
}
@keyframes walkIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.walk-graph { height: 320px; margin-top: 12px; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.walk-bars { margin-top: 12px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); display: grid; gap: 8px; }
.bars-title { margin: 0 0 4px; font-weight: 600; font-size: 14px; }
.bar-row { display: grid; grid-template-columns: minmax(70px, 30%) 1fr auto; align-items: center; gap: 10px; font-size: 14px; }
.bar-track { height: 16px; border-radius: 6px; background: var(--bg); overflow: hidden; }
.bar-track i { display: block; height: 100%; background: var(--math); opacity: .55; border-radius: 6px; }
.bar-row.hot .bar-track i { opacity: 1; background: var(--warn); }
.bar-row.hot { font-weight: 600; }
.bar-val { font-variant-numeric: tabular-nums; }
.walk-nav { display: flex; justify-content: space-between; margin-top: 14px; }
.walk-nav .btn:disabled { opacity: .35; cursor: default; }
.passage mark { background: #fff3bf; color: inherit; border-radius: 3px; padding: 0 2px; opacity: .7; }
.passage mark.hot { background: #ffd43b; opacity: 1; box-shadow: 0 0 0 2px #ffd43b; }
@media (prefers-color-scheme: dark) {
  .passage mark { background: #5c4a00; }
  .passage mark.hot { background: #8a6d00; box-shadow: 0 0 0 2px #8a6d00; }
}

/* ---------- small screens ---------- */
@media (max-width: 900px) {
  .grid-top { grid-template-columns: repeat(3, 1fr); }
  .today { grid-column: 1 / -1; }
  .practice-body:has(.desmos-panel:not([hidden])) { grid-template-columns: minmax(0, 1fr); }
  .desmos-panel { position: static; }
}
@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .page, .practice { padding-left: 16px; padding-right: 16px; }
  .hello h1 { font-size: 27px; }
  .hello { flex-direction: column; align-items: flex-start; gap: 14px; }
  .skill-cols { grid-template-columns: 1fr; }
  .grid-top { gap: 10px; }
  .stat { padding: 14px; }
  .stat .num { font-size: 26px; }
  .stat .muted { font-size: 12px; }
  .today { flex-wrap: wrap; }
  .today .btn { width: 100%; }
  .qcard { padding: 20px 16px; }
  .practice-bar { flex-wrap: wrap; }
}

/* public site: sign-up, privacy, account */
.login-alt { text-align: center; margin: 16px 0 0; font-size: 14px; }
.login-alt a, .prose a { color: var(--brand); }
.field small { display: block; margin-top: 4px; }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 4px 0 12px; font-size: 14px; }
.check input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.page.narrow { max-width: 720px; }
.prose h1 { font-size: 28px; margin-bottom: 12px; }
.prose h3 { font-size: 18px; margin: 22px 0 6px; }
.prose ul { padding-left: 20px; margin: 6px 0; }
.prose li { margin-bottom: 6px; }
.btn.danger { background: var(--bad); color: #fff; }
.danger-form { max-width: 380px; }

/* installable app */
.install { display: flex; align-items: center; gap: 14px; margin-top: 22px; position: relative; padding-right: 44px; }
.install img { border-radius: 11px; flex: none; }
.install-text { flex: 1; min-width: 0; }
.install-text p { margin: 2px 0 0; }
.install-x { position: absolute; top: 8px; right: 10px; border: 0; background: none; font-size: 22px; color: var(--muted); cursor: pointer; }
@media (display-mode: standalone) {
  .topbar { padding-top: max(14px, env(safe-area-inset-top)); }
  body { padding-bottom: env(safe-area-inset-bottom); }
}
