/* bfhs.fyi shell. Mobile first. Modes add their own sheet in modes/<mode>/<mode>.css */
:root {
  --bg: #f6f4ee; --surface: #ffffff; --surface-2: #edeae2; --text: #1d1c19; --muted: #6b675d; --border: #dcd8cc;
  --accent: #2f5bea; --accent-ink: #ffffff; --ok: #1f8a4c; --ok-bg: #e2f5e9; --bad: #c92a2a; --bad-bg: #fde8e8;
  --chem: #2f5bea; --psych: #c2410c; --hist: #6d28d9;
  --radius: 14px; --shadow: 0 1px 2px rgba(0,0,0,.06), 0 6px 20px rgba(0,0,0,.05);
  --font: "Avenir Next", "Segoe UI", system-ui, -apple-system, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #15171c; --surface: #1f2229; --surface-2: #2a2e37; --text: #ecebe6; --muted: #a09d94; --border: #353944;
    --accent: #6d8cff; --accent-ink: #0d1020; --ok: #4ade80; --ok-bg: #163524; --bad: #f87171; --bad-bg: #3b1c1c;
    --shadow: 0 1px 2px rgba(0,0,0,.4);
  }
}
:root[data-theme="dark"] {
  --bg: #15171c; --surface: #1f2229; --surface-2: #2a2e37; --text: #ecebe6; --muted: #a09d94; --border: #353944;
  --accent: #6d8cff; --accent-ink: #0d1020; --ok: #4ade80; --ok-bg: #163524; --bad: #f87171; --bad-bg: #3b1c1c;
  --shadow: 0 1px 2px rgba(0,0,0,.4);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.45; font-size: 17px; }
a { color: var(--accent); }
h1, h2, h3 { margin: 0; line-height: 1.2; letter-spacing: -0.01em; }
h1 { font-size: 1.25rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1rem; margin-bottom: 8px; }
p { margin: 6px 0; }
.muted { color: var(--muted); }
.fine { color: var(--muted); font-size: .85rem; }
.wrap { max-width: 640px; margin: 0 auto; padding: 16px 16px 48px; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 12px 16px; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.top-text { flex: 1; min-width: 0; }
.top-text p { margin: 0; color: var(--muted); font-size: .85rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 50%; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 1.2rem; }
.back-space { width: 0; }
.brand { font-size: .8rem; color: var(--muted); letter-spacing: .04em; }

.card { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; margin: 12px 0; box-shadow: var(--shadow); color: inherit; text-decoration: none; }
a.card:active { transform: scale(.99); }
.course { border-left: 6px solid var(--accent); }
.course.c-chem { border-left-color: var(--chem); }
.course.c-psych { border-left-color: var(--psych); }
.course.c-hist { border-left-color: var(--hist); }
.course p { color: var(--muted); margin: 4px 0 0; }
.unit { display: flex; justify-content: space-between; gap: 12px; align-items: center; }
.unit p { color: var(--muted); margin: 4px 0 0; font-size: .9rem; }
.unit-no { display: block; font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; margin-bottom: 2px; }
.unit-side { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; flex-shrink: 0; }
.cumulative { background: linear-gradient(135deg, var(--surface), var(--surface-2)); }

.badge { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .8rem; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.r1 { background: #e3ecff; color: #1d3fa8; }
.badge.r2 { background: #fff1c2; color: #8a5a00; }
:root[data-theme="dark"] .badge.r1 { background: #1d2a52; color: #9db3ff; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .badge.r1 { background: #1d2a52; color: #9db3ff; } }
.ticks { display: inline-flex; gap: 4px; }
.ticks i { width: 14px; height: 6px; border-radius: 3px; background: var(--border); }
.ticks i.on { background: var(--ok); }
.status-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }

.btn { display: inline-block; padding: 12px 20px; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; border: 0; font: inherit; font-weight: 700; cursor: pointer; text-align: center; }
.btn.big { display: block; width: 100%; font-size: 1.1rem; padding: 16px; margin-top: 12px; }
.btn.ghost { background: transparent; color: var(--accent); border: 1px solid var(--border); display: block; margin-top: 8px; }
.btn:active { filter: brightness(.95); }

.graph { width: 100%; height: auto; display: block; }
.g-tick { font-size: 10px; fill: var(--muted); }
.g-grid { stroke: var(--border); stroke-width: 1; }
.g-goal { stroke: var(--ok); stroke-dasharray: 4 4; stroke-width: 1.5; }
.g-line { fill: none; stroke: var(--accent); stroke-width: 2; stroke-linejoin: round; }
.g-dot { fill: var(--surface); stroke: var(--accent); stroke-width: 2; }
.g-dot.hit { fill: var(--ok); stroke: var(--ok); }

.topics { margin: 0; padding-left: 20px; }
.topics li { margin: 2px 0; }

.play .progress { display: flex; align-items: center; gap: 10px; margin: 4px 0 12px; }
.bar { flex: 1; height: 6px; background: var(--surface-2); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .25s; }
#count { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.section-title { font-size: .8rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }

.score { text-align: center; }
.big-score { font-size: 3.2rem; font-weight: 800; letter-spacing: -0.03em; line-height: 1; margin: 6px 0; }
.score.hit .big-score { color: var(--ok); }
.score .status-row { justify-content: center; margin-top: 8px; }
.promo { margin: 10px 0; padding: 10px; border-radius: 10px; background: #fff1c2; color: #8a5a00; font-size: 1.05rem; }
.by-topic { list-style: none; padding: 0; margin: 0; }
.by-topic li { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.by-topic li:last-child { border-bottom: 0; }
.by-topic b.ok { color: var(--ok); }
.by-topic b.bad { color: var(--bad); }
.missed { list-style: none; padding: 0; margin: 0; }
.missed li { padding: 10px 0; border-bottom: 1px solid var(--border); }
.missed li:last-child { border-bottom: 0; }
.m-q { font-weight: 600; }
.m-a { font-size: .9rem; margin-top: 4px; }
.m-a s { color: var(--bad); }
.m-a b { color: var(--ok); }
.m-why { font-size: .9rem; color: var(--muted); margin-top: 4px; }

.form label { display: block; margin: 10px 0; font-weight: 600; }
.form input, .form select { display: block; width: 100%; margin-top: 4px; padding: 12px; font: inherit; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); color: var(--text); }
.form input:focus, .form select:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
.form input:disabled, .form button:disabled { opacity: .6; }
.err { color: var(--bad); background: var(--bad-bg); padding: 8px 12px; border-radius: 10px; font-size: .95rem; margin: 10px 0 0; }

/* Account: tabs, code step */
.brand.me-link { text-decoration: none; color: var(--accent); font-weight: 700; padding: 6px 12px; border-radius: 999px; background: var(--surface-2); letter-spacing: 0; font-size: .85rem; }
.account-strip { margin: 16px 4px 0; color: var(--muted); font-size: .95rem; }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 4px; margin: 12px 0 0; background: var(--surface-2); border-radius: 12px; }
.seg button { padding: 10px 8px; border: 0; border-radius: 9px; background: transparent; color: var(--muted); font: inherit; font-size: .92rem; font-weight: 600; cursor: pointer; }
.seg button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.code-step h3 { margin-bottom: 2px; }
.code-input { text-align: center; font-size: 2rem; letter-spacing: .35em; font-variant-numeric: tabular-nums; padding: 14px 8px; }
.code-input::placeholder { color: var(--border); letter-spacing: .35em; }
.dev-note { display: inline-block; margin: 6px 0 0; padding: 4px 10px; border-radius: 999px; font-size: .8rem; background: #fff1c2; color: #8a5a00; }
.code-links { text-align: center; margin-top: 12px; }
.code-links .dot { margin: 0 6px; }
.code-links a.wait { color: var(--muted); text-decoration: none; pointer-events: none; }
.nudge { margin: 4px 4px 0; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .95rem; }
.nudge a.muted { margin-left: 6px; font-size: .9rem; }

/* Me: account card, per course blocks */
.account-card h2 { font-size: 1.3rem; }
.account-card .btn.ghost { margin-top: 10px; }
.account-card .btn.big { margin-top: 10px; }
.account-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.account-row p { margin: 2px 0; font-size: .95rem; overflow-wrap: anywhere; }
.avatar { flex-shrink: 0; display: grid; place-items: center; width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-weight: 800; font-size: 1.2rem; }
.course-title { margin: 24px 4px 4px; font-size: 1.05rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.course-title a { color: inherit; text-decoration: none; }
.c-chem .course-title { color: var(--chem); }
.c-psych .course-title { color: var(--psych); }
.c-hist .course-title { color: var(--hist); }
:root[data-theme="dark"] .c-chem .course-title { color: #8aa4ff; }
:root[data-theme="dark"] .c-psych .course-title { color: #fb923c; }
:root[data-theme="dark"] .c-hist .course-title { color: #a78bfa; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .c-chem .course-title { color: #8aa4ff; }
  :root:not([data-theme="light"]) .c-psych .course-title { color: #fb923c; }
  :root:not([data-theme="light"]) .c-hist .course-title { color: #a78bfa; }
}
.me-units { list-style: none; padding: 0 16px; margin: 8px 0 12px; }
.me-unit { padding: 12px 0; border-bottom: 1px solid var(--border); }
.me-unit:last-child { border-bottom: 0; }
.me-unit-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.me-unit-head a { color: inherit; text-decoration: none; min-width: 0; }
.me-unit-head a b { display: block; font-size: 1rem; }
.me-unit-head .unit-no { margin-bottom: 0; }
.me-unit-stats { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 14px; margin-top: 8px; font-size: .9rem; color: var(--muted); }
.me-unit-stats b { color: var(--text); }
.me-unit .fine { margin: 6px 0 0; }
.totals { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 12px; text-align: center; }
.totals div { background: var(--surface-2); border-radius: 10px; padding: 8px 4px; }
.totals b { display: block; font-size: 1.1rem; letter-spacing: -0.01em; }
.totals span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
@media (max-width: 380px) { .totals { grid-template-columns: repeat(2, 1fr); } }
.topic-acc { list-style: none; padding: 0; margin: 8px 0 0; }
.topic-acc li { padding: 8px 0; border-bottom: 1px solid var(--border); }
.topic-acc li:last-child { border-bottom: 0; }
.ta-row { display: flex; justify-content: space-between; gap: 10px; font-size: .95rem; }
.ta-row small { color: var(--muted); font-size: .75rem; }
.ta-row b.ok { color: var(--ok); }
.ta-row b.bad { color: var(--bad); }
.ta-bar { height: 5px; border-radius: 3px; background: var(--surface-2); margin-top: 6px; overflow: hidden; }
.ta-bar i { display: block; height: 100%; background: var(--ok); border-radius: 3px; }
.ta-bar i.bad { background: var(--bad); }
.empty .btn.ghost { margin-top: 8px; }

.fireworks { position: fixed; inset: 0; pointer-events: none; z-index: 50; }

/* Shared pieces every mode can use */
.q-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px 16px; box-shadow: var(--shadow); }
.q-label { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 8px; }
.q-prompt { font-size: 1.2rem; font-weight: 600; line-height: 1.35; }
.q-tip { background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: .9rem; margin-bottom: 12px; color: var(--muted); }
.opts { display: grid; gap: 10px; margin-top: 14px; }
.opts.two { grid-template-columns: 1fr 1fr; }
.opt { padding: 14px 12px; border-radius: 12px; border: 1.5px solid var(--border); background: var(--surface); color: var(--text); font: inherit; font-size: 1.05rem; cursor: pointer; text-align: center; }
.opt:hover { border-color: var(--accent); }
.opt.right { border-color: var(--ok); background: var(--ok-bg); }
.opt.wrong { border-color: var(--bad); background: var(--bad-bg); }
.opt:disabled { cursor: default; opacity: .9; }
.feedback { margin-top: 14px; padding: 12px 14px; border-radius: 12px; border-left: 4px solid var(--ok); background: var(--ok-bg); }
.feedback.wrong { border-left-color: var(--bad); background: var(--bad-bg); }
.feedback b { display: block; margin-bottom: 2px; }
.next { margin-top: 12px; }
