/* Maths: the personal-stack look (Dash, Habits). Light only, Helvetica Neue, one blue. */
:root {
  color-scheme: only light;
  --canvas: #fafbfd; --surface: #fff; --ink: #1d2939; --muted: #667085; --line: #e6ebf2; --strong: #a1aebf;
  --blue: #2856c5; --blue-hover: #2148a8; --selection: #f0f5ff; --well: #f7f9fc;
  --good: #067647; --good-bg: #ecfdf3; --bad: #b42318; --bad-bg: #fef3f2; --due: #b54708; --due-bg: #fffaeb;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; color: var(--ink); background: var(--canvas); font-synthesis: none;
}
* { box-sizing: border-box; }
body { margin: 0; font-size: 14px; line-height: 1.5; background: var(--canvas); }
button, input, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .55; }
a { color: var(--blue); }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, summary:focus-visible { outline: 3px solid #7296ec; outline-offset: 3px; }
h1, h2, h3, p { margin: 0; }
h1 { font-size: 26px; line-height: 1.2; letter-spacing: -.7px; font-weight: 600; margin: 0 0 5px; }
h2 { font-size: 16px; font-weight: 600; letter-spacing: -.3px; }
h3 { font-size: 14px; font-weight: 600; }
p { color: var(--muted); }
[hidden] { display: none !important; }
.num { font-variant-numeric: tabular-nums; }

/* top bar, as in Dash */
.topbar { display: flex; align-items: center; gap: 32px; min-height: 65px; border-bottom: 1px solid var(--line); padding: 12px max(28px, calc((100% - 1160px) / 2)); background: #fff; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; font-size: 20px; font-weight: 700; letter-spacing: -.7px; color: var(--ink); }
.brand img { border-radius: 5px; }
.tabs { display: flex; gap: 4px; }
.tab { border: 0; background: none; padding: 8px 12px; border-radius: 5px; font-size: 13px; font-weight: 500; color: var(--muted); }
.tab:hover { background: var(--well); color: var(--ink); }
.tab[aria-current="page"] { background: var(--selection); color: var(--blue); }
.account { margin-left: auto; display: flex; align-items: center; gap: 16px; color: var(--muted); font-size: 12px; }
.account strong { color: var(--ink); font-weight: 600; }
.meter { display: inline-flex; align-items: center; gap: 8px; }
.meter .bar { width: 64px; height: 6px; border-radius: 3px; background: var(--line); overflow: hidden; }
.meter .bar span { display: block; height: 100%; background: var(--blue); }

.page { max-width: 1216px; margin: auto; padding: 24px 28px 20px; }
.heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 22px; flex-wrap: wrap; }
.eyebrow { font-size: 11px; font-weight: 600; letter-spacing: 1.2px; text-transform: uppercase; color: var(--muted); }
.subtitle { font-size: 14px; max-width: 640px; }
.page-date { font-size: 13px; color: var(--muted); }

.primary, .secondary { border-radius: 5px; padding: 9px 15px; min-height: 40px; font-weight: 600; font-size: 13px; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 10px; white-space: nowrap; }
.primary { background: var(--blue); border: 1px solid var(--blue); color: #fff; }
.primary:hover:not(:disabled) { background: var(--blue-hover); }
.secondary { background: #fff; border: 1px solid var(--strong); color: var(--ink); }
.secondary:hover { background: var(--well); }
.large { min-height: 46px; padding: 11px 20px; font-size: 14px; }
.text-button { background: none; border: 0; color: var(--blue); padding: 4px 0; font-weight: 500; font-size: 13px; text-decoration: none; }
.text-button:hover { text-decoration: underline; text-underline-offset: 3px; }
.quiet { color: var(--muted); }

.workspace { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 22px; align-items: start; }
.column { display: grid; gap: 20px; min-width: 0; }
.panel { border: 1px solid var(--line); border-radius: 7px; background: #fff; padding: 22px; min-width: 0; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 15px; }
.panel-heading p { font-size: 12px; margin-top: 3px; }
.notice { padding: 16px 18px; border: 1px solid #dce6f7; background: var(--selection); border-radius: 7px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap; }
.notice h2 { margin-bottom: 3px; }
.notice p { font-size: 13px; max-width: 620px; }
.notice .actions { display: flex; gap: 10px; flex-wrap: wrap; }
#message { padding: 12px 16px; border: 1px solid #f3b7b1; background: var(--bad-bg); color: var(--bad); border-radius: 6px; margin-bottom: 20px; display: flex; align-items: center; justify-content: space-between; gap: 10px; font-size: 13px; }

.row { display: flex; gap: 14px; align-items: center; padding: 15px 0; border-top: 1px solid var(--line); }
.row:first-child { border-top: 0; padding-top: 0; }
.row .grow { flex: 1; min-width: 0; }
.row h3 { overflow-wrap: anywhere; }
.row .meta { font-size: 12px; color: var(--muted); margin-top: 2px; }
.pill { font-size: 11px; padding: 3px 7px; border-radius: 4px; background: var(--well); color: var(--muted); white-space: nowrap; font-weight: 500; }
.pill.new { background: var(--selection); color: var(--blue); }
.pill.due { background: var(--due-bg); color: var(--due); }
.pill.done { background: var(--blue); color: #fff; }
.pill.ready { background: #fff; color: var(--blue); box-shadow: inset 0 0 0 1px #c9d6f3; }
.empty { padding: 8px 0; color: var(--muted); font-size: 14px; }

.stats { display: flex; gap: 30px; margin: 4px 0 18px; flex-wrap: wrap; }
.stats strong { display: block; font-size: 26px; font-weight: 500; line-height: 1.3; letter-spacing: -.5px; }
.stats span { font-size: 12px; color: var(--muted); }
.unit-bar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; font-size: 13px; padding: 7px 0; }
.unit-bar .track { grid-column: 1 / -1; height: 6px; border-radius: 3px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); overflow: hidden; }
.unit-bar .fill { height: 100%; background: var(--blue); }
.days { display: grid; grid-template-columns: repeat(14, minmax(0, 1fr)); gap: 4px; margin-top: 8px; }
.days span { aspect-ratio: 1; border-radius: 3px; background: var(--well); box-shadow: inset 0 0 0 1px var(--line); }
.days span.on { background: var(--blue); box-shadow: none; }
.days span.today { outline: 2px solid #7296ec; outline-offset: 1px; }
.field-row { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-top: 16px; }
select { border: 1px solid var(--strong); background: #fff; border-radius: 5px; padding: 6px 8px; font-size: 13px; }

/* course map */
.unit { margin-bottom: 28px; }
.unit-head { display: flex; align-items: baseline; gap: 12px; margin-bottom: 12px; flex-wrap: wrap; }
.unit-head h2 { font-size: 18px; }
.unit-head span { font-size: 12px; color: var(--muted); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 10px; }
.tile { text-align: left; border: 1px solid var(--line); background: #fff; border-radius: 7px; padding: 14px; display: flex; flex-direction: column; gap: 8px; min-height: 92px; }
.tile:hover { border-color: #c9d6f3; background: var(--selection); }
.tile .t { font-weight: 500; font-size: 14px; line-height: 1.35; }
.tile .s { font-size: 12px; color: var(--muted); }
.tile.locked { background: var(--well); }
.tile.locked .t { color: var(--muted); }
.pill { align-self: flex-start; }
.legend { display: flex; gap: 12px; flex-wrap: wrap; margin-bottom: 22px; align-items: center; }

/* topic dialog */
dialog { width: min(560px, calc(100% - 32px)); max-height: 88dvh; border: 1px solid var(--line); border-radius: 10px; padding: 24px; color: var(--ink); box-shadow: 0 20px 70px #1d293925; }
dialog::backdrop { background: #1d293950; }
.dialog-head { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; margin-bottom: 14px; }
.close { border: 0; background: var(--well); border-radius: 5px; width: 32px; height: 32px; font-size: 20px; line-height: 1; flex: none; }
.section { margin-top: 18px; }
.section .eyebrow { margin-bottom: 8px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { font-size: 12px; border: 1px solid var(--line); border-radius: 4px; padding: 4px 8px; background: #fff; }
.chip:hover { border-color: #c9d6f3; background: var(--selection); }
.chip.ok { color: var(--blue); border-color: #c9d6f3; }
.links { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.links a { display: flex; justify-content: space-between; gap: 10px; text-decoration: none; color: var(--ink); border: 1px solid var(--line); border-radius: 5px; padding: 10px 12px; font-size: 13px; }
.links a:hover { background: var(--selection); border-color: #c9d6f3; }
.links a span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.dialog-actions { display: grid; gap: 8px; margin-top: 22px; }

/* study session: full page */
.study { position: fixed; inset: 0; z-index: 20; background: var(--canvas); overflow-y: auto; }
.study-bar { position: sticky; top: 0; background: #fff; border-bottom: 1px solid var(--line); z-index: 2; }
.study-bar .inner { max-width: 760px; margin: auto; display: flex; align-items: center; gap: 14px; min-height: 61px; padding: 10px 20px; }
.study-bar .title { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.study-bar .title small { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 13px; }
.pips { display: flex; gap: 5px; align-items: center; margin-left: auto; flex: none; font-size: 12px; color: var(--muted); }
.pip { width: 10px; height: 10px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--strong); }
.pip.ok { background: var(--good); box-shadow: none; }
.pip.no { background: var(--bad); box-shadow: none; }
.stage { max-width: 760px; margin: 0 auto; padding: 28px 20px 60px; display: grid; gap: 16px; }
.card { background: #fff; border: 1px solid var(--line); border-radius: 7px; padding: 24px; }
.question { font-size: 18px; line-height: 1.65; color: var(--ink); }
.question math { font-size: 1.12em; }
.answer { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.answer input { flex: 1 1 200px; min-width: 0; border: 1px solid var(--strong); border-radius: 5px; padding: 11px 13px; font-size: 17px; font-variant-numeric: tabular-nums; background: #fff; }
.answer input:focus { border-color: var(--blue); outline: 3px solid #d7e2fb; outline-offset: 0; }
.hint { font-size: 12px; color: var(--muted); margin-top: 8px; }
.choices { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-top: 20px; }
.choice { border: 1px solid var(--strong); border-radius: 5px; padding: 13px; background: #fff; font-size: 17px; }
.choice:hover { background: var(--well); }
.choice[aria-pressed="true"] { border-color: var(--blue); background: var(--selection); box-shadow: inset 0 0 0 1px var(--blue); }
.verdict { border-radius: 7px; padding: 14px 18px; font-weight: 600; display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; }
.verdict.ok { background: var(--good-bg); color: var(--good); border: 1px solid #abefc6; }
.verdict.no { background: var(--bad-bg); color: var(--bad); border: 1px solid #fecdca; }
.verdict .plain { font-weight: 400; color: var(--ink); }
.steps { margin: 10px 0 0; padding-left: 20px; display: grid; gap: 8px; }
details summary { cursor: pointer; color: var(--muted); font-size: 13px; }
.blurb { font-size: 16px; line-height: 1.65; color: var(--ink); max-width: 64ch; }
.worked { background: var(--well); border: 1px solid var(--line); border-radius: 5px; padding: 16px; margin-top: 14px; }
.end-actions { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.big { font-size: 48px; font-weight: 500; letter-spacing: -1.5px; line-height: 1; }
.xp { display: inline-block; background: var(--selection); color: var(--blue); font-weight: 600; font-size: 13px; padding: 3px 8px; border-radius: 4px; }

footer { display: flex; justify-content: space-between; gap: 15px; color: var(--muted); font-size: 11px; padding: 26px 0 10px; flex-wrap: wrap; align-items: center; }
.loading { padding: 40px 0; color: var(--muted); }
.toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: 24px; background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 6px; font-size: 13px; z-index: 40; }

/* sign-in, as in Dash */
.login { max-width: 370px; margin: 100px auto; padding: 0 20px; }
.login h1 { margin: 14px 0 24px; }
.login form { display: grid; gap: 12px; }
.login label { font-size: 13px; font-weight: 600; display: grid; gap: 6px; }
.login input { border: 1px solid var(--strong); background: #fff; border-radius: 5px; padding: 10px 12px; width: 100%; min-width: 0; font-weight: 400; }
.login .primary { margin-top: 5px; }
#login-error { color: var(--bad); font-size: 13px; }

@media (max-width: 860px) { .workspace { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  .topbar { padding: 12px 18px; gap: 14px; }
  .account { width: 100%; margin-left: 0; justify-content: space-between; order: 3; }
  .page { padding: 22px 18px; }
  .panel { padding: 19px; }
  .card { padding: 19px; }
  .answer input { font-size: 16px; }
  .heading > .primary { width: 100%; white-space: normal; text-align: center; }
  .row .pill { display: none; }
  .choices { grid-template-columns: minmax(0, 1fr); }
}
@media (pointer: coarse) { button, .text-button { min-height: 44px; } }
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; transition: none !important; } }
