/* Homework Hatch: a warm paper-and-ink notebook. Hard outlines, offset shadows, one loud
   egg-yolk accent. Light + dark through tokens; every page shares these class names. */
:root {
  --paper: #f2ede3;
  --surface: #fffdf8;
  --surface-2: #f7f2e8;
  --ink: #141311;
  --text: #141311;
  --muted: #6b6559;
  --line: #141311;          /* hard outlines */
  --hair: #d9d1c1;          /* quiet dividers */
  --yolk: #ffc629;
  --yolk-soft: #fff1c2;
  --tomato: #ff5a36;
  --tomato-soft: #ffe1d8;
  --mint: #1fae68;
  --mint-soft: #d8f5e5;
  --sky: #3d6dff;
  --sky-soft: #dfe7ff;
  --lilac: #9b7bff;
  --lilac-soft: #ebe4ff;
  --rail: #141311;
  --rail-text: #efe9dc;
  --rail-muted: #8d877a;
  --shadow-color: #141311;
  --shadow: 3px 3px 0 var(--shadow-color);
  --shadow-lg: 5px 5px 0 var(--shadow-color);
  --radius: 14px;
  --radius-sm: 9px;
  --rail-w: 232px;
  --display: "Bricolage Grotesque", "Geist", ui-sans-serif, system-ui, sans-serif;
  --font: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  /* legacy token names still used in templates */
  --bg: var(--paper);
  --border: var(--hair);
  --accent: var(--yolk);
  --accent-strong: #b37c00;
  --accent-soft: var(--yolk-soft);
  --ok: var(--mint); --ok-soft: var(--mint-soft);
  --warn: #b36b00; --warn-soft: var(--yolk-soft);
  --err: #d8391a; --err-soft: var(--tomato-soft);
  --info: var(--sky); --info-soft: var(--sky-soft);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0f0e0c;
    --surface: #1a1916;
    --surface-2: #23211d;
    --ink: #f1ebdd;
    --text: #f1ebdd;
    --muted: #a29b8c;
    --line: #3b3830;
    --hair: #2e2b25;
    --yolk: #ffc629;
    --yolk-soft: #3a2f10;
    --tomato: #ff6b4a;
    --tomato-soft: #3d1a12;
    --mint: #3ddc8a;
    --mint-soft: #13301f;
    --sky: #7b9bff;
    --sky-soft: #18223f;
    --lilac: #b5a0ff;
    --lilac-soft: #261f3f;
    --rail: #080807;
    --rail-text: #efe9dc;
    --rail-muted: #7d7769;
    --shadow-color: #000;
    --accent-strong: var(--yolk);
    --warn: #ffc629; --err: #ff6b4a;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; color: var(--text); font: 15px/1.55 var(--font); -webkit-font-smoothing: antialiased;
  background: var(--paper);
}
a { color: inherit; text-decoration: none; text-underline-offset: 3px; }
a:hover { text-decoration: underline; text-decoration-thickness: 2px; text-decoration-color: var(--yolk); }
.prose a, p a, .help a, .small a, label a { text-decoration: underline; text-decoration-color: color-mix(in srgb, currentColor 35%, transparent); }
h1, h2, h3, h4 { font-family: var(--display); line-height: 1.1; margin: 0 0 .5em; letter-spacing: -.02em; font-weight: 750; }
h1 { font-size: clamp(1.9rem, 3.4vw, 2.6rem); letter-spacing: -.035em; font-weight: 800; }
h2 { font-size: 1.22rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
code, pre, kbd { font-family: var(--mono); font-size: .88em; }
code { background: var(--surface-2); padding: .1em .35em; border-radius: 5px; border: 1px solid var(--hair); }
pre { background: var(--surface-2); padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; border: 1.5px solid var(--line); }
pre code { border: 0; padding: 0; background: none; }
kbd { border: 1.5px solid var(--line); border-bottom-width: 3px; border-radius: 6px; padding: 0 .4em; background: var(--surface); }
hr { border: 0; border-top: 1.5px dashed var(--hair); margin: 22px 0; }
img { max-width: 100%; height: auto; }
::selection { background: var(--yolk); color: #141311; }
.muted { color: var(--muted); }
.small { font-size: .86rem; }
.mono, .num { font-family: var(--mono); font-variant-numeric: tabular-nums; }
.nowrap { white-space: nowrap; }
.right { text-align: right; }
.center { text-align: center; }
.mt { margin-top: 16px; }
.mb { margin-bottom: 16px; }
.hidden, [hidden] { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { flex: none; vertical-align: -4px; }
.kicker { font: 600 .74rem var(--mono); text-transform: uppercase; letter-spacing: .12em; color: var(--muted); margin: 0 0 6px; }
.hl { background: linear-gradient(transparent 58%, var(--yolk) 58%, var(--yolk) 92%, transparent 92%); padding: 0 .08em; }

/* ---------- shell: ink rail + paper page ---------- */
.shell { display: flex; min-height: 100vh; }
.rail {
  width: var(--rail-w); flex: none; background: var(--rail); color: var(--rail-text);
  padding: 20px 14px 16px; position: sticky; top: 0; height: 100vh; overflow-y: auto; display: flex; flex-direction: column;
}
@media (prefers-color-scheme: dark) { .rail { border-right: 1.5px solid #2a2721; } }
.brand { display: flex; align-items: center; gap: 10px; color: inherit; text-decoration: none; padding: 2px 8px 22px; }
.brand:hover { text-decoration: none; }
.brand img { width: 34px; height: 34px; }
.brand span { font: 800 1.08rem/1 var(--display); letter-spacing: -.02em; }
.nav { display: grid; gap: 3px; }
.nav a {
  display: flex; align-items: center; gap: 12px; padding: 9px 12px; border-radius: 11px; color: var(--rail-text);
  font-weight: 550; font-size: .95rem; text-decoration: none; border: 1.5px solid transparent;
}
.nav a:hover { background: #ffffff12; text-decoration: none; }
.nav a.active { background: var(--yolk); color: #141311; border-color: #141311; box-shadow: 2px 2px 0 #000; font-weight: 700; }
.rail-foot { margin-top: auto; display: grid; gap: 10px; padding-top: 16px; border-top: 1px dashed #ffffff26; }
.rail-stats { display: flex; gap: 8px; padding: 0 4px; }
.pill-dark { display: inline-flex; align-items: center; gap: 6px; border: 1.5px solid #ffffff30; border-radius: 999px; padding: 3px 10px;
  font: 600 .8rem var(--mono); color: var(--rail-text); text-decoration: none; }
a.pill-dark:hover { border-color: var(--yolk); color: var(--yolk); text-decoration: none; }
.me { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 12px; color: var(--rail-text); text-decoration: none; border: 1.5px solid transparent; }
.me:hover { background: #ffffff12; text-decoration: none; }
.me.active { border-color: var(--yolk); }
.me small { display: block; color: var(--rail-muted); font-size: .76rem; }
.avatar { width: 34px; height: 34px; border-radius: 10px; background: var(--yolk); color: #141311; display: grid; place-items: center;
  font: 800 1rem var(--display); border: 1.5px solid #000; flex: none; }
.signout { background: none; border: 0; color: var(--rail-muted); font: 500 .82rem var(--font); cursor: pointer; padding: 0 8px; text-align: left; display: inline-flex; gap: 6px; align-items: center; }
.signout:hover { color: var(--rail-text); }

.main { flex: 1; min-width: 0; padding: 34px 40px 72px;
  background-image: radial-gradient(color-mix(in srgb, var(--ink) 9%, transparent) 1px, transparent 1.2px); background-size: 22px 22px; }
.container { max-width: 1140px; margin: 0 auto; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 24px; }
.page-head h1 { margin: 0; }
.page-head p { margin: 6px 0 0; max-width: 68ch; }
.mobilebar { display: none; }

@media (max-width: 900px) {
  .shell { display: block; min-height: 0; }
  /* The drawer: sized to the visible screen (not 100vh, which hides its foot under Safari's toolbar),
     fully off-screen and out of the tab order when closed, with a scrim that swallows taps when open. */
  .rail { position: fixed; inset: 0 auto 0 0; height: auto; z-index: 40; transform: translateX(calc(-100% - 12px)); visibility: hidden;
    transition: transform .2s ease, visibility 0s linear .2s; padding-bottom: calc(16px + env(safe-area-inset-bottom)); overscroll-behavior: contain; }
  .rail.open { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 8px 0 0 #0003, 0 0 0 100vmax rgb(0 0 0 / .45); }
  html:has(.rail.open) { overflow: hidden; }
  body:has(.rail.open) .main, body:has(.rail.open) .mobilebar { pointer-events: none; }
  .signout { padding: 10px 8px; }
  .mobilebar {
    display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 14px;
    background: var(--rail); color: var(--rail-text); position: sticky; top: 0; z-index: 30;
  }
  .mobilebar .brand { padding: 0; }
  .mobilebar button { background: none; border: 1.5px solid #ffffff30; color: inherit; border-radius: 10px; padding: 6px 8px; cursor: pointer; }
  .main { padding: 20px 16px calc(56px + env(safe-area-inset-bottom)); min-height: calc(100vh - 54px); min-height: calc(100dvh - 54px); }
}

/* ---------- surfaces ---------- */
.card {
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius); padding: 18px 20px;
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 18px; }
.grid > .card + .card, .grid > * + .card { margin-top: 0; }
.card h2 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card h2 a { font: 600 .8rem var(--mono); text-transform: uppercase; letter-spacing: .08em; }
.card-flat { background: var(--surface-2); border: 1.5px dashed var(--hair); border-radius: var(--radius); padding: 14px 16px; }
.card.accent { background: var(--yolk); color: #141311; }
.card.accent .muted { color: #141311b3; }
.grid { display: grid; gap: 18px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.grid-main { grid-template-columns: minmax(0, 1.75fr) minmax(0, 1fr); }
@media (max-width: 980px) { .grid-3, .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .grid-main { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 640px) { .grid-2, .grid-3 { grid-template-columns: 1fr; } }
.stat .value { font: 800 1.9rem/1 var(--display); letter-spacing: -.03em; }
.stat .label { color: var(--muted); font: 500 .78rem var(--mono); text-transform: uppercase; letter-spacing: .06em; margin-top: 6px; }
.list { list-style: none; margin: 0; padding: 0; }
.list > li { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; border-bottom: 1.5px dashed var(--hair); }
.list > li:last-child { border-bottom: 0; }
.list .grow { flex: 1; min-width: 0; }
.list .title { font-weight: 600; overflow-wrap: anywhere; }
.empty { text-align: center; color: var(--muted); padding: 30px 12px; }
.empty .big { font-size: 2rem; }
.empty-mark { width: 72px; height: 72px; margin: 0 auto 12px; border-radius: 20px; background: var(--yolk); color: #141311; border: 1.5px solid var(--line); box-shadow: var(--shadow); display: grid; place-items: center; }

/* ---------- controls ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; border: 1.5px solid var(--line);
  background: var(--yolk); color: #141311; font: 650 .92rem var(--font); padding: 8px 15px; border-radius: 11px;
  cursor: pointer; text-decoration: none; line-height: 1.2; box-shadow: var(--shadow); transition: transform .06s, box-shadow .06s;
}
@media (prefers-color-scheme: dark) { .btn { border-color: #000; } }
.btn:hover { text-decoration: none; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow-color); }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow-color); }
.btn:disabled { opacity: .5; cursor: default; transform: none; box-shadow: var(--shadow); }
.btn-ghost { background: var(--surface); color: var(--text); }
@media (prefers-color-scheme: dark) { .btn-ghost { border-color: var(--line); } }
.btn-danger { background: var(--tomato); color: #141311; }
.btn-sm { padding: 5px 10px; font-size: .84rem; border-radius: 9px; box-shadow: 2px 2px 0 var(--shadow-color); }
.btn-sm:hover { box-shadow: 3px 3px 0 var(--shadow-color); }
.btn-block { width: 100%; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.linklike { background: none; border: 0; padding: 0; color: inherit; font: inherit; cursor: pointer; text-decoration: underline; text-decoration-color: var(--hair); text-underline-offset: 3px; }
.linklike:hover { text-decoration-color: var(--yolk); }
form.inline { display: inline; }

label { display: block; font-weight: 600; font-size: .88rem; margin: 14px 0 5px; }
label .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date],
input[type=search], input[type=tel], input[type=time], input:not([type]), select, textarea {
  width: 100%; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--surface); color: var(--text); font: 15px var(--font);
}
textarea { min-height: 120px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus { outline: none; box-shadow: 3px 3px 0 var(--yolk); }
.check { display: flex; align-items: center; gap: 8px; font-weight: 450; }
.check input { width: auto; margin: 0; accent-color: var(--ink); }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 0 14px; }
.help { color: var(--muted); font-size: .84rem; margin-top: 4px; }

/* ---------- badges, flashes, tabs, tables ---------- */
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font: 600 .72rem var(--mono);
  text-transform: uppercase; letter-spacing: .04em; background: var(--surface-2); color: var(--text); border: 1.5px solid var(--line); white-space: nowrap; }
.badge.ok, .badge.graded, .badge.submitted, .badge.done { background: var(--mint-soft); }
.badge.warn, .badge.past_due, .badge.submitted_late { background: var(--yolk-soft); }
.badge.err, .badge.missing { background: var(--tomato); color: #141311; }
.badge.info, .badge.upcoming { background: var(--sky-soft); }
.badge.accent { background: var(--yolk); color: #141311; }

.flashes { margin-bottom: 18px; display: grid; gap: 8px; }
.flash { padding: 10px 14px; border-radius: 11px; background: var(--sky-soft); font-size: .92rem; border: 1.5px solid var(--line); box-shadow: 2px 2px 0 var(--shadow-color); }
.flash.success { background: var(--mint-soft); }
.flash.error { background: var(--tomato-soft); }
.flash.warning { background: var(--yolk-soft); }

.tabs { display: flex; gap: 6px; margin-bottom: 22px; overflow-x: auto; padding: 2px 3px 6px; }
.tabs a { display: inline-flex; align-items: center; gap: 8px; padding: 7px 14px; color: var(--muted); white-space: nowrap; font-weight: 600;
  border: 1.5px solid transparent; border-radius: 999px; text-decoration: none; }
.tabs a:hover { color: var(--text); border-color: var(--hair); text-decoration: none; }
.tabs a.active { color: #141311; background: var(--yolk); border-color: var(--line); box-shadow: 2px 2px 0 var(--shadow-color); }
@media (prefers-color-scheme: dark) { .tabs a.active { border-color: #000; } }

table.table { width: 100%; border-collapse: collapse; font-size: .92rem; }
.table th { text-align: left; color: var(--muted); font: 600 .72rem var(--mono); text-transform: uppercase; letter-spacing: .08em; padding: 8px 10px; border-bottom: 1.5px solid var(--line); }
.table td { padding: 10px; border-bottom: 1.5px dashed var(--hair); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table-wrap { overflow-x: auto; }

.progress { height: 10px; background: var(--surface-2); border-radius: 999px; overflow: hidden; border: 1.5px solid var(--line); }
.progress > span { display: block; height: 100%; background: var(--yolk); border-right: 1.5px solid var(--line); }

/* ---------- rich content (Canvas pages, AI answers) ---------- */
.prose { overflow-wrap: anywhere; }
.prose table { border-collapse: collapse; margin: 12px 0; }
.prose td, .prose th { border: 1px solid var(--hair); padding: 6px 8px; }
.prose img { border-radius: 8px; }
.prose blockquote { margin: 10px 0; padding: 4px 14px; border-left: 4px solid var(--yolk); color: var(--muted); }
.prose h1, .prose h2, .prose h3 { margin-top: 1em; }
a.cite { display: inline-block; font: 700 .7rem var(--mono); padding: 0 6px; border-radius: 6px; background: var(--yolk); color: #141311; border: 1px solid var(--line); vertical-align: 1px; text-decoration: none; }

/* ---------- dashboard ---------- */
.today-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; flex-wrap: wrap; margin-bottom: 22px; }
.today-head h1 { margin: 0; }
.sync-pill { display: inline-flex; align-items: center; gap: 8px; font: 500 .8rem var(--mono); color: var(--muted); border: 1.5px dashed var(--hair); border-radius: 999px; padding: 5px 12px; background: var(--surface); }
.sync-pill .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--mint); box-shadow: 0 0 0 3px var(--mint-soft); }
.sync-pill.stale .dot { background: var(--tomato); box-shadow: 0 0 0 3px var(--tomato-soft); }
.week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; margin-bottom: 22px; }
.day-cell { background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 10px 10px 12px; text-decoration: none; color: inherit; min-height: 88px;
  display: flex; flex-direction: column; gap: 6px; transition: transform .06s; }
.day-cell:hover { text-decoration: none; transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow-color); }
.day-cell .dow { font: 600 .7rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.day-cell .date { font: 800 1.4rem/1 var(--display); }
.day-cell .dots { display: flex; flex-wrap: wrap; gap: 4px; margin-top: auto; }
.day-cell .dots i { width: 10px; height: 10px; border-radius: 3px; background: var(--c, var(--sky)); border: 1px solid var(--line); }
.day-cell.today { background: var(--yolk); color: #141311; box-shadow: var(--shadow); }
.day-cell.today .dow { color: #141311b3; }
.day-cell.empty-day { border-style: dashed; border-color: var(--hair); }
@media (max-width: 640px) {
  .week { grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 5px; overflow: visible; }
  .day-cell { min-height: 68px; padding: 8px 4px; align-items: center; text-align: center; }
  .day-cell .dow { font-size: .6rem; letter-spacing: .02em; }
  .day-cell .date { font-size: 1.1rem; }
  .day-cell .dots { justify-content: center; gap: 3px; }
  .day-cell .dots i { width: 8px; height: 8px; }
}
.agenda-day { margin: 0 0 6px; padding-top: 6px; }
.agenda-day + .agenda-day { border-top: 1.5px solid var(--line); margin-top: 8px; padding-top: 12px; }
.agenda-day > .kicker { color: var(--text); }
.task { display: grid; grid-template-columns: 4px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 9px 0; }
.task + .task { border-top: 1.5px dashed var(--hair); }
.task .bar { align-self: stretch; border-radius: 4px; background: var(--c, var(--sky)); }
.task .title { font-weight: 600; overflow-wrap: anywhere; }
.task .meta { font: 500 .78rem var(--mono); color: var(--muted); }
.task.done .title { text-decoration: line-through; color: var(--muted); }
.countdown { font: 700 .74rem var(--mono); padding: 3px 8px; border-radius: 8px; border: 1.5px solid var(--line); background: var(--surface-2); white-space: nowrap; }
.countdown.urgent { background: var(--tomato); color: #141311; }
.countdown.soon { background: var(--yolk); color: #141311; }
.countdown.late { background: var(--tomato-soft); }
.gradebar { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; align-items: center; padding: 8px 0; }
.gradebar + .gradebar { border-top: 1.5px dashed var(--hair); }
.gradebar .name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none; }
.gradebar .score { font: 700 .9rem var(--mono); }
.gradebar .track { grid-column: 1 / -1; height: 8px; border-radius: 999px; background: var(--surface-2); border: 1.5px solid var(--line); overflow: hidden; }
.gradebar .track span { display: block; height: 100%; background: var(--c, var(--mint)); }
.quick { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.quick a { display: flex; flex-direction: column; gap: 8px; padding: 12px; border: 1.5px solid var(--line); border-radius: 12px; background: var(--surface);
  text-decoration: none; font-weight: 650; font-size: .88rem; transition: transform .06s; }
.quick a:hover { transform: translate(-1px, -1px); box-shadow: 3px 3px 0 var(--shadow-color); text-decoration: none; }
.quick a .icon { color: var(--text); }

.class-card { border-top: 10px solid var(--c, var(--yolk)); }

/* ---------- landing & auth ---------- */
.public { min-height: 100vh; background-image: radial-gradient(color-mix(in srgb, var(--ink) 10%, transparent) 1px, transparent 1.2px); background-size: 22px 22px; }
.auth-wrap { min-height: 100vh; min-height: 100svh; display: grid; place-items: center; padding: 24px 16px; }
.auth-card { width: 100%; max-width: 430px; }
.auth-card .brand { color: var(--text); justify-content: center; padding-bottom: 16px; }
.landing-nav { max-width: 1120px; margin: 0 auto; padding: 18px 20px; display: flex; justify-content: space-between; align-items: center; }
.landing-nav .brand { color: var(--text); padding: 0; }
.hero { max-width: 1120px; margin: 0 auto; padding: 48px 20px 28px; display: grid; grid-template-columns: 1.05fr .95fr; gap: 44px; align-items: center; }
.hero h1 { font-size: clamp(2.4rem, 6vw, 4.4rem); line-height: .98; letter-spacing: -.045em; }
.hero p.lead { font-size: 1.15rem; color: var(--muted); max-width: 46ch; }
.hero-art { background: var(--surface); border: 1.5px solid var(--line); border-radius: 18px; padding: 20px; box-shadow: var(--shadow-lg); transform: rotate(1.2deg); }
.features { max-width: 1120px; margin: 0 auto; padding: 28px 20px 72px; }
.feature { transition: transform .08s; }
.feature:nth-child(3n+1) { transform: rotate(-.6deg); }
.feature:nth-child(3n+2) { transform: rotate(.5deg); }
.feature .ico { width: 42px; height: 42px; border-radius: 12px; background: var(--yolk); border: 1.5px solid var(--line); display: grid; place-items: center; margin-bottom: 10px; font-size: 1.2rem; }
.sticker { display: inline-block; font: 700 .76rem var(--mono); text-transform: uppercase; letter-spacing: .1em; background: var(--tomato); color: #141311;
  border: 1.5px solid var(--line); border-radius: 8px; padding: 4px 9px; transform: rotate(-2deg); box-shadow: 2px 2px 0 var(--shadow-color); }
@media (max-width: 820px) { .hero { grid-template-columns: 1fr; padding-top: 22px; } .hero-art { transform: none; } }

/* ---------- calendar ---------- */
.cal { width: 100%; border-collapse: separate; border-spacing: 6px; table-layout: fixed; margin: -6px; width: calc(100% + 12px); }
.cal th { font: 600 .72rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); padding: 4px 6px; text-align: left; }
.cal td { border: 1.5px solid var(--line); border-radius: 10px; height: 108px; vertical-align: top; padding: 6px; background: var(--surface); }
.cal td.other { background: transparent; border-style: dashed; border-color: var(--hair); color: var(--muted); }
.cal td.today { background: var(--yolk-soft); box-shadow: var(--shadow); }
.cal .day { font: 700 .82rem var(--mono); }
.cal td.today .day { background: var(--yolk); color: #141311; border: 1.5px solid var(--line); border-radius: 6px; padding: 0 5px; }
.cal .item { display: block; font-size: .72rem; font-weight: 600; padding: 2px 6px; margin-top: 4px; border-radius: 6px; background: color-mix(in srgb, var(--c, var(--sky)) 22%, var(--surface)); border-left: 4px solid var(--c, var(--sky));
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; color: var(--text); }
.cal .item.event { background: var(--lilac-soft); border-left-color: var(--lilac); }
.cal .item.done, .cal .item.graded, .cal .item.submitted { background: var(--mint-soft); border-left-color: var(--mint); text-decoration: line-through; color: var(--muted); }
.cal .item.missing { background: var(--tomato-soft); border-left-color: var(--tomato); }
@media (max-width: 700px) { .cal { border-spacing: 3px; } .cal td { height: 64px; padding: 3px; border-radius: 7px; } .cal .item { font-size: .6rem; padding: 1px 3px; } }
.cal .day { color: inherit; text-decoration: none; display: inline-block; min-width: 1.6em; }
.cal .day:hover { text-decoration: underline; }
.cal .item.submitted_late { background: var(--mint-soft); border-left-color: var(--mint); text-decoration: line-through; color: var(--muted); }
.cal-views { margin: -8px 0 16px; }
.cal-views a { padding: 5px 14px; }

/* week and day views: one entry per assignment or event, in time order */
.cal-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "when act" "what what"; column-gap: 6px;
  padding: 6px 6px 6px 9px; border-radius: 9px; border: 1.5px solid var(--hair); border-left: 4px solid var(--c, var(--sky));
  background: color-mix(in srgb, var(--c, var(--sky)) 14%, var(--surface)); font-size: .82rem; }
.cal-entry + .cal-entry { margin-top: 6px; }
.cal-entry .when { grid-area: when; align-self: center; font: 600 .68rem var(--mono); color: var(--muted); }
.cal-entry .what { grid-area: what; min-width: 0; overflow-wrap: break-word; }
.cal-entry .what > a, .cal-entry .what > span { font-weight: 650; color: var(--text); }
.cal-entry .meta { font-size: .72rem; color: var(--muted); margin-top: 2px; }
.cal-entry .meta .badge { font-size: .64rem; padding: 0 7px; }
.cal-entry form { grid-area: act; align-self: start; }
.cal-entry .btn-sm { padding: 3px 6px; }
.cal-entry.event { --c: var(--lilac); }
.cal-entry.study { border-style: dashed; border-left-style: solid; }
.cal-entry.study.done .what > a { text-decoration: line-through; color: var(--muted); }
.cal .item.study { border-left-style: dashed; font-style: italic; }
/* "Add to calendar" under tutor answers (js/tutor_calendar.js) */
.msg-actions { margin-top: 6px; }
.msg.assistant:has(.calcard:not([hidden])) { max-width: 100%; width: 100%; }
.msg-actions .linklike { font-size: .8rem; }
.calcard { margin-top: 10px; padding: 12px; border: 2px solid var(--line); border-radius: var(--radius-sm); background: var(--surface); }
.calcard-head { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
.calrows { list-style: none; margin: 0 0 10px; padding: 0; display: grid; gap: 8px; }
.calrow { display: grid; grid-template-columns: auto 10rem auto minmax(0, 1fr); grid-template-areas: "on title title title" ". date times class" ". notes notes notes";
  gap: 6px 8px; align-items: center; padding-bottom: 8px; border-bottom: 1.5px dashed var(--hair); }
.calrow:last-child { border-bottom: 0; padding-bottom: 0; }
.calrow input, .calrow select { margin: 0; padding: 6px 8px; min-width: 0; }
.calrow-on { grid-area: on; width: 18px; height: 18px; }
.calrow-title { grid-area: title; font-weight: 600; }
.calrow-date { grid-area: date; }
.calrow-times { grid-area: times; display: flex; align-items: center; gap: 4px; }
.calrow-times input { width: 8.6rem; }
.calrow-class { grid-area: class; }
.calrow-notes { grid-area: notes; font-size: .85rem; }
.calcard.added .calrow { opacity: .7; }
.calrow-have { grid-column: 2 / -1; }
.calcard-earlier { margin-top: 6px; }
@media (max-width: 900px) {
  .calrow { grid-template-columns: auto minmax(0, 1fr) minmax(0, 1fr); grid-template-areas: "on title title" ". date class" ". times times" ". notes notes"; }
  .calrow-times input { flex: 1; width: auto; }
}
@media (max-width: 640px) {
  .msg.assistant:has(.calcard:not([hidden])) { padding: 10px; }
  .calcard { padding: 10px; }
  .calrow { grid-template-columns: auto minmax(0, 1fr); grid-template-areas: "on title" ". date" ". times" ". class" ". notes"; }
}
.cal .item.mine.done, .cal-entry.mine.done .what > a { text-decoration: line-through; color: var(--muted); }
.cal-entry.mine.done .btn { background: var(--mint); color: #141311; border-color: var(--line); }
.cal .item.study.done { text-decoration: line-through; color: var(--muted); }
.cal-entry.done, .cal-entry.submitted, .cal-entry.submitted_late, .cal-entry.graded { background: var(--mint-soft); border-left-color: var(--mint); }
.cal-entry.done .what > a, .cal-entry.submitted .what > a, .cal-entry.submitted_late .what > a, .cal-entry.graded .what > a { text-decoration: line-through; color: var(--muted); }
.cal-entry.done .btn { background: var(--mint); color: #141311; border-color: var(--line); }
.cal-entry.missing { background: var(--tomato-soft); border-left-color: var(--tomato); }
.cal-entry.wide { grid-template-columns: 92px minmax(0, 1fr) auto; grid-template-areas: "when what act"; column-gap: 12px; padding: 12px 12px 12px 14px; font-size: .95rem; }
.cal-entry.wide .when { font-size: .8rem; padding-top: 2px; align-self: start; }
.cal-entry.wide .meta { font-size: .8rem; }
.cal-entry.wide + .cal-entry.wide { margin-top: 10px; }
.calw-wrap { container-type: inline-size; margin-bottom: 22px; }
.calw { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; align-items: start; }
.calw-day { background: var(--surface); border: 1.5px solid var(--line); border-radius: 12px; padding: 8px; min-height: 160px; }
.calw-day.today { background: var(--yolk-soft); box-shadow: var(--shadow); }
.calw-day.past { background: var(--surface-2); border-color: var(--hair); }
.calw-head { display: flex; align-items: baseline; gap: 6px; margin: 0 0 8px; color: inherit; text-decoration: none; }
.calw-head:hover { text-decoration: none; }
.calw-head .dow { font: 600 .7rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.calw-head .date { font: 800 1.3rem/1 var(--display); }
.calw-day.today .calw-head .date { background: var(--yolk); color: #141311; border: 1.5px solid var(--line); border-radius: 8px; padding: 1px 6px; }
.calw-empty { font-size: .75rem; color: var(--muted); margin: 0; }
.cald { padding: 14px; }
/* Seven columns need about 120px each; narrower than that, each day becomes a row. */
@container (max-width: 880px) {
  .calw { grid-template-columns: 1fr; gap: 10px; }
  .calw-day { min-height: 0; display: grid; grid-template-columns: 64px minmax(0, 1fr); column-gap: 10px; }
  .calw-head { grid-row: 1 / span 99; flex-direction: column; gap: 2px; margin: 0; }
  .calw-day > :not(.calw-head) { grid-column: 2; }
  .calw-day > .cal-entry + .cal-entry { margin-top: 6px; }
  .calw-empty { align-self: center; }
}
@media (max-width: 560px) { .cal-entry.wide { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "when act" "what what"; padding: 10px; } }

/* ---------- exam planner ---------- */
.quiet-note { margin: -6px 0 12px; }
.page-head > :first-child { min-width: 0; }
.page-head h1, .page-head .kicker { overflow-wrap: anywhere; }
fieldset.chip-row, fieldset.method-grid { border: 0; padding: 0; margin: 0; min-width: 0; }
.mt-xs { margin-top: 6px; }
.btn-col { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; }
.badge.kind-final { background: var(--tomato-soft); }
.badge.kind-midterm { background: var(--yolk-soft); }
.badge.kind-test { background: var(--sky-soft); }
.badge.kind-quiz { background: var(--mint-soft); }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.cdot { display: inline-block; width: .7em; height: .7em; border-radius: 50%; background: var(--c); border: 1.5px solid var(--line); margin-right: 4px; vertical-align: -.05em; }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; border: 0; padding: 0; margin: 0; min-width: 0; }
.swatches legend { font-weight: 600; margin-bottom: 8px; }
.swatch { width: 36px; height: 36px; border-radius: 50%; background: var(--c); border: 2px solid var(--line, #141311); cursor: pointer; display: inline-block; position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.swatch:has(input:checked) { outline: 3px solid var(--ink, #141311); outline-offset: 3px; }
.swatch:has(input:focus-visible) { outline: 3px solid var(--sky); outline-offset: 3px; }
.chip-radio { display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border: 1.5px solid var(--hair); border-radius: 999px; cursor: pointer; font-size: .86rem; font-weight: 600; }
.chip-radio input { margin: 0; accent-color: var(--ink, #141311); }
.chip-radio:has(input:checked) { background: var(--yolk); color: #141311; border-color: var(--line); }
.chip-radio:has(input:focus-visible) { outline: 3px solid var(--sky); outline-offset: 2px; }
.countdown.big { font-size: .95rem; padding: 6px 12px; }
.ask-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; }
.plan-week { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 8px; }
.plan-day { border: 1.5px solid var(--hair); border-radius: 10px; padding: 8px; min-height: 90px; background: var(--surface); }
.plan-day.today { border-color: var(--line); background: var(--yolk-soft); box-shadow: var(--shadow); }
.plan-day-head { margin-bottom: 6px; }
.plan-day-head .dow { font: 600 .7rem var(--mono); text-transform: uppercase; letter-spacing: .1em; color: var(--muted); }
.plan-day-head .date { font: 800 1.1rem/1 var(--display); }
.plan-chip { display: block; padding: 5px 7px; border-radius: 8px; border-left: 4px solid var(--c, var(--lilac)); background: color-mix(in srgb, var(--c, var(--lilac)) 16%, var(--surface));
  color: var(--text); text-decoration: none; font-size: .76rem; }
.plan-chip + .plan-chip { margin-top: 5px; }
.plan-test { display: flex; align-items: center; gap: 4px; font: 700 .74rem var(--mono); color: var(--text); text-decoration: none; margin-bottom: 5px; overflow-wrap: anywhere; }
.plan-test .icon { color: var(--tomato); }
.plan-chip:hover { text-decoration: none; filter: brightness(.97); }
.plan-chip .t { display: block; font-weight: 650; overflow-wrap: anywhere; }
.plan-chip .m { display: block; color: var(--muted); font: 500 .68rem var(--mono); }
.plan-chip.done { background: var(--mint-soft); border-left-color: var(--mint); }
.plan-chip.done .t { text-decoration: line-through; color: var(--muted); }
@media (max-width: 860px) { .plan-week { grid-template-columns: 1fr; } .plan-day { min-height: 0; display: grid; grid-template-columns: 64px minmax(0, 1fr); column-gap: 10px; }
  .plan-day-head { grid-row: 1 / span 99; } .plan-day > :not(.plan-day-head) { grid-column: 2; } }
.plan-sessions { list-style: none; margin: 0; padding: 0; }
.plan-sessions > li { display: grid; grid-template-columns: 96px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 10px 0; border-bottom: 1.5px dashed var(--hair); }
.plan-sessions > li:last-child { border-bottom: 0; }
.plan-sessions .when { font: 600 .78rem var(--mono); color: var(--muted); }
.plan-sessions > li.today .when { color: var(--text); }
.plan-sessions > li.done { opacity: .7; }
@media (max-width: 560px) { .plan-sessions > li { grid-template-columns: minmax(0, 1fr) auto; } .plan-sessions .when { grid-column: 1 / -1; } }
.method-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
@media (max-width: 640px) { .method-grid { grid-template-columns: 1fr; } }
.method { display: flex; flex-direction: column; gap: 6px; border: 1.5px solid var(--hair); border-radius: 12px; padding: 12px; cursor: pointer; background: var(--surface); }
.method input { position: absolute; opacity: 0; pointer-events: none; }
.method:has(input:focus-visible) { outline: 3px solid var(--sky); outline-offset: 2px; }
.method .name { font-weight: 700; }
.method { position: relative; }
.method:has(input:checked) { border-color: var(--line); background: var(--yolk-soft); box-shadow: 2px 2px 0 var(--shadow-color); }
.timer-face { display: flex; flex-direction: column; align-items: center; gap: 4px; margin: 6px 0 12px; }
.timer-face #clock { font: 800 3.2rem/1 var(--mono); letter-spacing: -.02em; }
.timer-card.ping { box-shadow: 0 0 0 4px var(--yolk); transition: box-shadow .3s; }
@media (prefers-reduced-motion: reduce) { .timer-card.ping { transition: none; } }

/* ---------- study ---------- */
.flashcard { perspective: 1400px; cursor: pointer; margin: 8px auto 16px; max-width: 660px; }
.flashcard .inner { position: relative; min-height: 300px; transition: transform .5s cubic-bezier(.2, .8, .2, 1); transform-style: preserve-3d; }
.flashcard.flipped .inner { transform: rotateY(180deg); }
.flashcard .face {
  position: absolute; inset: 0; -webkit-backface-visibility: hidden; backface-visibility: hidden; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 34px; border-radius: 18px; background: var(--surface); border: 1.5px solid var(--line);
  box-shadow: var(--shadow-lg); font: 600 1.3rem/1.4 var(--font); overflow-y: auto;
  background-image: repeating-linear-gradient(transparent 0 31px, color-mix(in srgb, var(--sky) 16%, transparent) 31px 32px);
}
.flashcard .back { transform: rotateY(180deg); background-color: var(--yolk-soft); background-image: none; font-weight: 500; font-size: 1.12rem; }
.flashcard .face.prose p { margin: 0 0 .4em; }
.flashcard .face.prose p:last-child { margin-bottom: 0; }
.flashcard .face code { font-size: .92em; }
.viewer { display: grid; grid-template-columns: auto minmax(0, 660px) auto; gap: 16px; align-items: center; justify-content: center; }
.viewer .flashcard { margin: 8px 0; width: 100%; }
.nav-arrow { width: 52px; height: 52px; border-radius: 16px; border: 1.5px solid var(--line); background: var(--surface);
  color: var(--text); font: 700 1.7rem/1 var(--display); cursor: pointer; box-shadow: var(--shadow); transition: transform .06s; }
.nav-arrow:hover { background: var(--yolk); color: #141311; transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--shadow-color); }
.nav-arrow:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--shadow-color); }
.viewer-pos { font: 700 1rem var(--mono); font-variant-numeric: tabular-nums; margin: 6px 0 14px; letter-spacing: .06em; }
@media (max-width: 640px) { .viewer { gap: 6px; } .nav-arrow { width: 38px; height: 38px; font-size: 1.3rem; border-radius: 11px; } .flashcard .face { padding: 22px; font-size: 1.1rem; } }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 11px 13px; border: 1.5px solid var(--line); border-radius: 11px; margin: 8px 0; cursor: pointer; font-weight: 450; background: var(--surface); }
.choice:hover { background: var(--yolk-soft); }
.choice input { margin-top: 4px; width: auto; accent-color: var(--ink); }
.choice.correct { background: var(--mint-soft); box-shadow: 2px 2px 0 var(--mint); }
.choice.wrong { background: var(--tomato-soft); box-shadow: 2px 2px 0 var(--tomato); }

/* ---------- live quiz ---------- */
.live-code { font: 700 2.8rem var(--mono); letter-spacing: .14em; }
.live-choices { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.live-choices button { min-height: 90px; font: 700 1.05rem var(--font); border-radius: 14px; border: 1.5px solid var(--line); color: #141311; cursor: pointer; padding: 12px; box-shadow: var(--shadow); }
.live-choices button:nth-child(1) { background: var(--tomato); }
.live-choices button:nth-child(2) { background: #7fa2ff; }
.live-choices button:nth-child(3) { background: var(--yolk); }
.live-choices button:nth-child(4) { background: #5fd99a; }
.live-choices button:nth-child(5) { background: #c3b0ff; }
.live-choices button:nth-child(6) { background: #6fe0e0; }
.live-choices button:disabled { opacity: .45; cursor: default; }
.live-choices button.picked { outline: 4px solid var(--ink); outline-offset: 2px; }
.timer { font: 700 1.6rem var(--mono); }
@media (max-width: 560px) { .live-choices { grid-template-columns: 1fr; } }

/* ---------- chat & tutor ---------- */
.chat { display: flex; flex-direction: column; height: calc(100vh - 220px); min-height: 400px; }
.chat-log { flex: 1; overflow-y: auto; padding: 12px 4px; display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 78%; padding: 10px 14px; border-radius: 14px; background: var(--surface-2); overflow-wrap: anywhere; border: 1.5px solid var(--hair); }
.msg.mine { align-self: flex-end; background: var(--yolk); color: #141311; border-color: var(--line); border-bottom-right-radius: 4px; }
.msg .meta { font: 500 .72rem var(--mono); color: var(--muted); margin-bottom: 3px; display: flex; gap: 8px; }
.msg .meta button { font-size: .72rem; }
.msg.assistant { max-width: 100%; background: var(--surface); border: 1.5px solid var(--line); box-shadow: 2px 2px 0 var(--shadow-color); border-bottom-left-radius: 4px; }
.composer { display: flex; gap: 10px; padding-top: 12px; border-top: 1.5px dashed var(--hair); align-items: flex-end; }
.composer textarea { min-height: 48px; height: 48px; }
.tutor-layout { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 22px; }
.convo-list a { display: block; padding: 8px 11px; border-radius: 10px; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-decoration: none; border: 1.5px solid transparent; }
.convo-list a:hover { border-color: var(--hair); text-decoration: none; }
.convo-list a.active { background: var(--surface); border-color: var(--line); box-shadow: 2px 2px 0 var(--shadow-color); font-weight: 600; }
@media (max-width: 900px) {
  /* Phones keep the conversations: a one-row "new chat" form and a sideways strip of past chats. */
  .tutor-layout { grid-template-columns: minmax(0, 1fr); gap: 10px; }
  .tutor-layout aside form.card { display: flex; gap: 8px; align-items: center; padding: 8px; }
  .tutor-layout aside form.card label { display: none; }
  .tutor-layout aside form.card select { flex: 1; min-width: 0; }
  .tutor-layout aside form.card .btn { width: auto; margin-top: 0; white-space: nowrap; }
  .convo-list { display: flex; gap: 6px; overflow-x: auto; margin-top: 8px; padding: 0 2px 4px; scrollbar-width: none; }
  .convo-list a { flex: none; max-width: 65vw; border-color: var(--hair); }
  .chat { height: calc(100vh - 250px); height: calc(100dvh - 250px); min-height: 340px; padding: 12px 14px; }
  .chat .ai-note { font-size: .74rem; line-height: 1.35; padding-bottom: 6px; }
}
.chat:has(> .attach-panel:not([hidden])) { height: auto; }
.chat:has(> .attach-panel:not([hidden])) .chat-log { flex: none; max-height: 30vh; max-height: 30dvh; }

/* ---------- pickers, uploads, chips ---------- */
.picker-list { max-height: 330px; overflow-y: auto; margin-top: 6px; border: 1.5px solid var(--line); border-radius: 12px; padding: 2px 12px; background: var(--surface); }
.picker-list li { gap: 10px; }
.picker-list li.picker-group { display: block; padding: 0; }
.picker-group details > summary { display: flex; align-items: center; gap: 8px; padding: 9px 0; cursor: pointer; font-weight: 600; list-style: none; }
.picker-group details > summary::-webkit-details-marker { display: none; }
.picker-group details > summary::before { content: "▸"; font-size: .8em; transition: transform .15s; }
.picker-group details[open] > summary::before { transform: rotate(90deg); }
.picker-group .list { margin: 0 0 6px 18px; }
.picker-group-tools { margin: -4px 0 2px 18px; }
.picker-tools { margin-top: 6px; }
.kind { font: 600 .66rem var(--mono); text-transform: uppercase; letter-spacing: .08em; border: 1.5px solid var(--line); border-radius: 6px; padding: 0 5px; margin-left: 4px; background: var(--sky-soft); }
.drive-panel { border: 1.5px dashed var(--hair); border-radius: 12px; padding: 10px; }
.attach-bar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 8px 0; }
.attach-panel { border-top: 1.5px dashed var(--hair); padding: 12px 0; }
.chip { display: inline-flex; gap: 5px; align-items: center; background: var(--yolk-soft); border: 1.5px solid var(--line); border-radius: 999px; padding: 2px 10px; font-size: .84rem; max-width: 100%; }
.dropzone { display: block; border: 2px dashed var(--line); border-radius: var(--radius); padding: 26px 14px; text-align: center; cursor: pointer; margin: 0 0 10px; background: var(--surface-2); font-weight: 450; }
.dropzone.over, .dropzone:hover { background: var(--yolk-soft); }
.pick-bar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; padding: 8px 0 12px; margin-bottom: 6px; border-bottom: 1.5px solid var(--line);
  position: sticky; top: 0; background: var(--surface); z-index: 1; }
.dice { font-size: 3rem; letter-spacing: .1em; }
@media (hover: none) and (pointer: coarse) { .keys-hint { display: none; } }
.ai-note { margin: 0 0 6px; padding-bottom: 8px; border-bottom: 1.5px dashed var(--hair); }

/* ---------- Learn, Test, import ---------- */
.star-btn { background: none; border: 0; padding: 2px 6px; font-size: 1.25rem; line-height: 1; cursor: pointer; color: var(--muted); border-radius: 8px; }
.star-btn[aria-pressed="true"] { color: var(--accent-strong); }
.star-btn:hover { background: var(--yolk-soft); }
.star-btn:focus-visible, .mc-option:focus-visible, .learn-q:focus-visible { outline: 3px solid var(--sky); outline-offset: 2px; }
.star-col { width: 36px; padding-right: 0 !important; }
.exam-ring { display: flex; align-items: center; gap: 10px; background: var(--surface); border: 1.5px solid var(--line); border-radius: 14px; padding: 8px 14px 8px 8px; box-shadow: var(--shadow); max-width: 100%; }
.exam-ring svg { transform: rotate(-90deg); flex: none; }
.exam-ring text { transform: rotate(90deg); transform-origin: 18px 18px; font: 700 8.5px var(--mono); fill: var(--text); }
.exam-ring .ring-track { fill: none; stroke: var(--surface-2); stroke-width: 4; }
.exam-ring .ring-fill { fill: none; stroke: var(--mint); stroke-width: 4; stroke-linecap: round; }
.learn { max-width: 760px; margin: 0 auto; }
.learn-top { display: grid; gap: 8px; margin-bottom: 14px; }
.learn-progress { display: flex; height: 14px; border: 1.5px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--surface-2); }
.learn-progress .seg { display: block; height: 100%; transition: width .3s ease; }
.seg-new, .dot-new { background: var(--surface-2); }
.seg-learning, .dot-learning { background: var(--yolk); }
.seg-mastered, .dot-mastered { background: var(--mint); }
.learn-legend { display: flex; gap: 14px; flex-wrap: wrap; margin: 0; color: var(--muted); }
.learn-legend strong { color: var(--text); font-family: var(--mono); }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; border: 1px solid var(--line); margin-right: 5px; vertical-align: -1px; }
.learn-options summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.learn-options fieldset { border: 0; padding: 0; margin: 8px 0 0; display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.learn-options legend { float: left; margin-right: 6px; font-weight: 600; }
.learn-options .check { margin: 8px 0 0; }
.learn-q { outline: none; }
.learn-q-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.learn-q-head .kicker { margin: 0; }
.learn-prompt { font: 600 1.25rem/1.45 var(--font); margin: 10px 0 16px; }
.learn-prompt p:last-child { margin-bottom: 0; }
.mc-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.mc-option { display: flex; gap: 10px; align-items: flex-start; text-align: left; padding: 12px 14px; min-height: 56px; border: 1.5px solid var(--line); border-radius: 12px;
  background: var(--surface); color: var(--text); font: 500 1rem/1.4 var(--font); cursor: pointer; box-shadow: 2px 2px 0 var(--shadow-color); }
.mc-option:hover:not(:disabled) { background: var(--yolk-soft); }
.mc-option:disabled { cursor: default; opacity: .75; }
.mc-option.correct { background: var(--mint-soft); box-shadow: 2px 2px 0 var(--mint); opacity: 1; }
.mc-option.wrong { background: var(--tomato-soft); box-shadow: 2px 2px 0 var(--tomato); opacity: 1; }
.mc-option .prose p { margin: 0; }
.mc-key { flex: none; font: 700 .75rem var(--mono); border: 1.5px solid var(--line); border-radius: 6px; padding: 0 6px; background: var(--surface-2); margin-top: 2px; }
.typed-form input { font-size: 1.05rem; padding: 12px 14px; }
.learn-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; margin-top: 12px; }
.center-row { justify-content: center; }
.learn-feedback:empty { display: none; }
.learn-feedback { margin-top: 14px; padding-top: 12px; border-top: 1.5px dashed var(--hair); }
.fb { font-weight: 700; margin: 0 0 8px; }
.fb-right { color: var(--ok); }
.fb-almost { color: var(--warn); }
.fb-wrong { color: var(--err); }
.learn-answer { background: var(--mint-soft); border: 1.5px solid var(--line); border-radius: 10px; padding: 8px 12px; margin: 8px 0; }
.learn-answer.yours { background: var(--surface-2); }
.learn-answer .kicker { margin-bottom: 2px; }
.learn-answer .prose p:last-child { margin-bottom: 0; }
.learn-answer .given { white-space: pre-wrap; overflow-wrap: anywhere; }
.learn .list .prose p { margin: 0; }
@media (max-width: 640px) {
  .mc-options { grid-template-columns: 1fr; }
  .learn-prompt { font-size: 1.1rem; }
  .learn-actions .btn { flex: 1 1 auto; min-height: 44px; }
}
.test { max-width: 760px; margin: 0 auto; }
.test-bar { position: sticky; top: 8px; z-index: 5; display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; }
@media (max-width: 900px) { .test-bar { top: 54px; } }
.test-q { border: 1.5px solid var(--line); margin: 14px 0 0; min-width: 0; }
.test-q legend { float: left; width: 100%; margin-bottom: 6px; }
.test-prompt { font-weight: 600; font-size: 1.08rem; margin-bottom: 8px; clear: both; }
.test-prompt p:last-child { margin-bottom: 0; }
.tf-shown { background: var(--surface-2); border: 1.5px dashed var(--hair); border-radius: 10px; padding: 8px 12px; margin-bottom: 6px; }
.tf-shown .prose p:last-child { margin-bottom: 0; }
.tf-choices .choice { flex: 1 1 140px; }
.choice .prose p { margin: 0; }
.timer.urgent { color: var(--err); }
.test-misses .miss-row { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 8px; margin-top: 6px; align-items: baseline; }
.test-misses .miss-row .prose p { margin: 0; }
.import-tools { margin-top: 6px; gap: 12px; }
.import-seps { margin-top: 12px; }
.import-seps summary { cursor: pointer; font-weight: 600; font-size: .9rem; }
.import-seps input[type=text] { margin-top: 6px; }
.import-preview { margin-top: 14px; }
.import-preview:empty { display: none; }
.import-summary { margin: 0 0 8px; }
.import-table td { white-space: pre-wrap; overflow-wrap: anywhere; }
.skipped-lines { margin: 6px 0 10px; padding-left: 18px; color: var(--muted); font-family: var(--mono); font-size: .8rem; overflow-wrap: anywhere; }
.file-pick { cursor: pointer; font-weight: 450; margin: 0; }
.steps { margin: 0 0 8px; padding-left: 20px; }
.steps li { margin: 4px 0; }
.export-help h3 { margin-top: 2px; }
.free-learn { max-width: 900px; margin: 0 auto; padding: 18px 20px 64px; }
.free-hero h1 { font-size: clamp(2.1rem, 5.5vw, 3.6rem); line-height: 1; letter-spacing: -.04em; }
.free-hero .lead { font-size: 1.12rem; color: var(--muted); max-width: 60ch; }
.free-points { list-style: none; padding: 0; margin: 16px 0 0; display: grid; gap: 6px; }
.free-points .icon { color: var(--ok); }
.free-section { margin-top: 34px; }
.sort-toggle { display: inline-flex; margin: 0 0 6px; }
.sort-yes { background: var(--mint-soft); }
.sort-no { background: var(--tomato-soft); }
.sort-done { max-width: 660px; margin: 8px auto; outline: none; }
.sort-done h2 { justify-content: center; }
@media (prefers-reduced-motion: reduce) {
  .flashcard .inner, .learn-progress .seg, .rail { transition: none; }
  .btn, .btn:hover, .btn:active, .nav-arrow:hover, .nav-arrow:active, .day-cell:hover, .quick a:hover { transform: none; }
}
.learn > .flash { margin-bottom: 12px; }

.nav-badge { margin-left: auto; font-size: .66rem; padding: 0 7px; }

/* ---------- Brain Grade (courses/_brain_grade.html) ---------- */
.brain-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
.brain-head h2 { margin: 0; }
.brain-nums { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-top: 14px; }
.brain-num { border: 1.5px solid var(--hair); border-radius: 12px; padding: 12px 14px; background: var(--surface-2); }
.brain-num.tests { border-color: var(--line); background: var(--yolk-soft); box-shadow: 2px 2px 0 var(--shadow-color); }
.brain-num .label { font: 600 .72rem var(--mono); text-transform: uppercase; letter-spacing: .06em; color: var(--muted); }
.brain-num .value { font: 800 1.9rem/1.1 var(--display); letter-spacing: -.03em; margin: 4px 0 2px; }
.brain-msg { font-weight: 600; margin: 14px 0 6px; }
.brain-lost { list-style: none; margin: 8px 0 0; padding: 0; }
.brain-lost li { display: flex; justify-content: space-between; gap: 12px; padding: 6px 0; border-bottom: 1.5px dashed var(--hair); }
.brain-lost li:last-child { border-bottom: 0; }
.brain-lost strong { font-family: var(--mono); white-space: nowrap; }
.label-chip { display: inline-block; position: relative; vertical-align: middle; }
.table-wrap:has(.label-chip[open]) { overflow: visible; }
.label-chip > summary { list-style: none; cursor: pointer; }
.label-chip > summary::-webkit-details-marker { display: none; }
.label-pop { position: absolute; z-index: 6; left: 0; top: calc(100% + 6px); width: min(300px, 80vw); padding: 12px; background: var(--surface);
  border: 1.5px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.share-card { border: 0; padding: 0; background: transparent; max-width: min(460px, 94vw); }
.share-card::backdrop { background: rgb(0 0 0 / .55); }
.share-card canvas { width: 100%; height: auto; border-radius: 12px; border: 1.5px solid var(--line); margin-top: 6px; }
@media (max-width: 640px) {
  .brain-nums { gap: 6px; }
  .brain-num { padding: 10px 8px; }
  .brain-num .value { font-size: 1.35rem; }
  .brain-num .label { font-size: .62rem; letter-spacing: .02em; }
  .label-pop { position: static; width: auto; margin-top: 6px; }
}

/* ---------- phones (iPhone pass) ---------- */
.prose > h1:first-child { margin-top: 0; }
.shared-set > .flash { margin-bottom: 14px; }
.cald { margin-bottom: 18px; }
#whatif .whatif-in { width: 90px; text-align: right; }
.class-card { position: relative; }
.class-card h3 a::after { content: ""; position: absolute; inset: 0; border-radius: inherit; }  /* the whole card opens the class */
.class-card form { position: relative; z-index: 1; }
.file-text { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 70vh; overflow: auto; }
.card-edit { grid-template-columns: 1fr 1.4fr auto; align-items: start; }
.chip-radio, .method, .btn-row > .check, .chip-row > .check, .list > li > label.check { margin: 0; }
.method { font-weight: 400; font-size: inherit; }
.cal-controls { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.cal-controls .cal-views { margin: 0; padding: 2px; }
.touch-only { display: none; }

@media (max-width: 980px) {
  .session-grid > div { display: contents; }  /* phone order: what to do, timer, blank page, this plan */
  .session-grid .card + .card { margin-top: 0; }
  .session-grid #timer { order: 1; }
  .session-grid [aria-labelledby="page-h"] { order: 2; }
  .session-grid #timer + .card { order: 3; }
  .files-list.is-empty { order: 1; }
}
@media (max-width: 900px) {
  .pick-bar { top: 54px; }
  .whatif-side { display: contents; }  /* the what-if result sits above the table and stays in view */
  .whatif-side > .card { margin-top: 0; }
  .whatif-grid .stat { order: -1; position: sticky; top: 62px; z-index: 5; padding: 10px 14px; }
  .whatif-grid .stat .value { font-size: 1.5rem; }
}

@media (max-width: 640px) {
  /* iOS Safari zooms into any field under 16px when it's tapped. */
  input[type=text], input[type=email], input[type=password], input[type=number], input[type=url], input[type=date],
  input[type=search], input[type=tel], input[type=time], input:not([type]), select, textarea { font-size: 16px; }
  input[type=date], input[type=time] { -webkit-appearance: none; appearance: none; min-height: 44px; text-align: left; }

  .landing-nav { padding: 14px 16px; gap: 12px; }
  .landing-nav .brand span { white-space: nowrap; }
  .landing-nav .btn-row { flex-wrap: nowrap; }
  .landing-nav .btn-row .btn:not(.btn-ghost) { display: none; }  /* every public page has a bigger sign-up button below */

  .card { padding: 16px 14px; }
  .prose ul, .prose ol { padding-left: 1.3em; }
  .form-row { grid-template-columns: minmax(0, 1fr); }
  .form-row.ymd { grid-template-columns: 1.4fr 1fr 1fr; }
  .task { gap: 10px; }
  .task > .btn-row { flex-wrap: nowrap; gap: 6px; }
  .page-head > .btn-row:has(> :nth-child(2)) { flex: 1 1 100%; }
  .page-head > .btn-row:has(> :nth-child(2)) > * { flex: 1 1 auto; }
  .page-head > .btn-row:has(> :nth-child(2)) > form > .btn { width: 100%; }

  /* Tab strips run to the screen edge and fade out, so it's clear they scroll. */
  .tabs { margin-left: -16px; margin-right: -16px; padding-left: 16px; padding-right: 16px; scroll-padding-inline: 16px; gap: 2px; scrollbar-width: none;
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 28px), transparent);
    mask-image: linear-gradient(90deg, transparent, #000 14px, #000 calc(100% - 28px), transparent); }
  .tabs::-webkit-scrollbar { display: none; }
  .tabs a { padding: 7px 11px; gap: 6px; }

  /* Calendar: controls on one row; the month grid shows colored marks and a tap opens the day. */
  .page-head .cal-tz { display: none; }
  .cal-controls { width: 100%; justify-content: space-between; gap: 6px; }
  .cal-controls .btn-row { gap: 6px; }
  .cal-controls .btn { padding: 7px 11px; }
  .cal-controls .cal-views { margin: 0; padding: 2px; -webkit-mask-image: none; mask-image: none; }
  .cal-views a { padding: 6px 10px; }
  .cal td { position: relative; height: 54px; }
  .cal .day::after { content: ""; position: absolute; inset: 0; }
  .cal .item { font-size: 0; line-height: 0; height: 5px; padding: 0; margin-top: 3px; border: 0; border-radius: 3px; background: var(--c, var(--sky)); pointer-events: none; }
  .cal .item.event { background: var(--lilac); }
  .cal .item.missing { background: var(--tomato); }
  .cal .item.done, .cal .item.graded, .cal .item.submitted, .cal .item.submitted_late, .cal .item.study.done { background: var(--mint); opacity: .45; }
  .cal .item.study { background: repeating-linear-gradient(90deg, var(--c, var(--lilac)) 0 4px, transparent 4px 6px); }

  .cal-entry .btn-sm, .task .btn-sm { min-width: 40px; min-height: 36px; padding: 6px 10px; }
  .mobilebar .pill-dark { padding: 8px 12px; }
  .card h2 a { padding: 10px 0; margin: -10px 0; }
  .public p.center.small a { display: inline-block; padding: 8px 2px; }
  .sync-pill { display: block; max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .sync-pill .dot { display: inline-block; margin-right: 8px; vertical-align: 1px; }

  /* A shared set: term over definition. */
  .shared-set .table thead { display: none; }
  .shared-set .table tr { display: block; padding: 12px 0; border-bottom: 1.5px dashed var(--hair); }
  .shared-set .table tr:last-child { border-bottom: 0; }
  .shared-set .table td { display: block; padding: 0; border: 0; }
  .shared-set .table td:first-child { font-weight: 650; margin-bottom: 4px; }

  #whatif .col-group { display: none; }
  #whatif .whatif-in { width: 72px; padding: 8px 10px; }
  #whatif th, #whatif td { padding-left: 6px; padding-right: 6px; }

  .row-actions { flex-direction: column; align-items: flex-end; gap: 6px; flex: none; }
  .row-actions .btn-sm { min-width: 44px; min-height: 36px; }
  .list a.title { display: block; }

  .pick-bar #pick-count { flex: 1 0 100%; }
  .pick-bar .btn-sm { flex: 1; min-height: 38px; }
  #pick-list input[type=checkbox] { width: 22px; height: 22px; }

  .file-text { max-height: none; overflow: visible; margin: 0 -4px; padding: 10px; font-size: .8rem; border-width: 1px; }

  /* The deck editor: each card is a row of star and delete over full-width front and back. */
  .card-table thead { display: none; }
  .card-table, .card-table tbody { display: block; }
  .card-table tr { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; grid-template-areas: "star . del" "edit edit edit";
    align-items: center; padding: 4px 0 12px; border-bottom: 1.5px dashed var(--hair); }
  .card-table tr:last-child { border-bottom: 0; }
  .card-table td { padding: 0; border: 0; }
  .card-table td.star-col { grid-area: star; width: auto; }
  .card-table td[colspan] { grid-area: edit; }
  .card-table td.right { grid-area: del; }
  .card-table .card-edit { grid-template-columns: 1fr; gap: 8px; }
  .card-table .card-edit .btn { justify-self: end; }
  .card-table .star-btn, .card-table td.right .linklike { min-width: 44px; min-height: 44px; }

  .chip-radio { min-height: 40px; }
  .viewer { grid-template-columns: 1fr 1fr; gap: 10px; }
  .viewer .flashcard { grid-column: 1 / -1; order: -1; margin: 0; }
  .viewer .nav-arrow { width: 100%; height: 48px; font-size: 2.1rem; line-height: 1; }
  .test-bar { margin: 0 -16px; padding: 8px 16px; border-radius: 0; border-width: 0 0 1.5px; box-shadow: none; }
  .test-q input { scroll-margin-top: 120px; }
  .method:not(:has(input:checked)) .why { display: none; }
  .method-save { position: sticky; bottom: 0; z-index: 2; display: flex; align-items: center; gap: 10px; margin: 12px -14px -16px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1.5px dashed var(--hair);
    border-radius: 0 0 var(--radius) var(--radius); }
  .method-save .btn { margin-top: 0; }

  .stat-row { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
  .stat-row .card { padding: 12px 10px; }
  .stat-row .value { font-size: 1.35rem; }
  .stat-row .label { letter-spacing: .02em; }
  .ach-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
  .ach-grid .card-flat { padding: 10px 12px; }
  .coin-history tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; border-bottom: 1.5px dashed var(--hair); }
  .coin-history td { border: 0; padding: 8px 4px 0; }
  .coin-history td:nth-child(2) { grid-row: 2; padding: 0 4px 8px; }
  .coin-history td:nth-child(3) { grid-column: 2; grid-row: 1 / span 2; align-self: center; }
}

/* Touch screens: no keyboard hints, no hover-only cues, finger-sized controls. */
@media (hover: none) and (pointer: coarse) {
  .ext-setup { display: none; }
  .touch-only { display: block; }
  .no-touch { display: none; }
  .learn-q:focus-visible { outline: none; }
}
@media (pointer: coarse) {
  .btn { min-height: 42px; }
  .btn-sm { min-height: 36px; padding: 7px 12px; }
  .check { align-items: flex-start; }
  .check input[type=checkbox], .check input[type=radio], .choice input { width: 20px; height: 20px; flex: none; margin-top: 1px; }
}

/* ---------- the walkthrough (js/tour.js) ---------- */
.tour-spot { position: fixed; z-index: 60; border-radius: var(--radius-sm); pointer-events: none;
  box-shadow: 0 0 0 3px var(--yolk), 0 0 0 200vmax rgb(0 0 0 / .45); }
body.tour-room { padding-bottom: var(--tour-room, 0); }
/* The open menu drawer comes first; the tour steps aside until it closes. */
body:has(#sidebar.open) :is(.tour-spot, .tour-pop, .tour-pill) { display: none; }
.tour-pop { position: fixed; z-index: 61; width: min(360px, calc(100vw - 16px)); background: var(--surface); color: var(--text);
  border: 1.5px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow-lg); padding: 16px 18px; }
.tour-pop h2 { font: 700 1.15rem var(--display); margin: 2px 0 6px; outline: none; }
.tour-pop .tour-body { margin: 0 0 10px; line-height: 1.45; }
.tour-count { font: 600 .72rem var(--mono); color: var(--muted); margin: 0; text-transform: uppercase; letter-spacing: .04em; }
.tour-check { margin: 0 0 10px; color: var(--muted); }
.tour-check.ok { color: var(--text); font-weight: 650; }
.tour-actions { justify-content: flex-end; }
.tour-foot { margin: 10px 0 0; color: var(--muted); text-align: right; }
.tour-center { top: 50%; left: 50%; transform: translate(-50%, -50%); width: min(420px, calc(100vw - 24px));
  box-shadow: 0 0 0 200vmax rgb(0 0 0 / .45), var(--shadow-lg); }
.tour-sheet { left: 8px; right: 8px; bottom: calc(8px + env(safe-area-inset-bottom)); top: auto; width: auto; }
@media (max-height: 520px) {  /* a phone held sideways: keep the explanation short so the page shows above it */
  .tour-pop { padding: 8px 12px; }
  .tour-pop h2 { font-size: 1rem; margin: 0 0 2px; }
  .tour-pop .tour-body { font-size: .86rem; line-height: 1.35; margin-bottom: 6px; }
  .tour-foot { margin-top: 4px; }
  .tour-sheet { left: auto; width: min(520px, calc(100vw - 16px)); }
}
.tour-pill { position: fixed; z-index: 59; right: 16px; bottom: calc(16px + env(safe-area-inset-bottom)); display: flex; align-items: stretch;
  background: var(--yolk); color: #141311; border: 1.5px solid var(--line); border-radius: 999px; box-shadow: var(--shadow); max-width: calc(100vw - 32px); }
.tour-pill button { background: none; border: 0; color: inherit; font: 600 .85rem var(--font); cursor: pointer; padding: 9px 14px; }
.tour-pill-go { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
.tour-pill-x { border-left: 1.5px solid rgb(0 0 0 / .25) !important; padding: 9px 12px !important; font-size: 1.05rem !important; }
.tour-toast { position: fixed; z-index: 62; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: var(--surface); border: 1.5px solid var(--line); border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 10px 14px; max-width: calc(100vw - 32px); }

/* ---------- Get set up (dashboard) ---------- */
.setup-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 8px; }
.setup-list li { display: grid; grid-template-columns: 26px minmax(0, 1fr); gap: 10px; align-items: start; }
.setup-list .tick { width: 22px; height: 22px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: .8rem; }
.setup-list .done .tick { background: var(--mint); color: #141311; }
.setup-list .done a { text-decoration: line-through; color: var(--muted); }
.setup-bar { height: 8px; border-radius: 99px; background: var(--surface-2); border: 1px solid var(--hair); overflow: hidden; margin-top: 4px; }
.setup-bar span { display: block; height: 100%; background: var(--mint); }
