/* Student tutor pages: one calm reading column, in the spirit of a chat window.
   Blue pen for the student's actions, red pen only where marks are shown. */
:root {
  --paper: #f7f5f0;
  --surface: #ffffff;
  --ink: #2b2a27;
  --muted: #6b675f;
  --line: #e4e0d6;
  --bubble: #ece8df;
  --pen: #2e5e8c;
  --pen-soft: #e3ebf3;
  --red: #b23a2e;
  --amber: #94640f;
  --on-pen: #ffffff;
  --scrim: rgba(43, 42, 39, .35);
  --serif: "Songti TC", "Noto Serif TC", "Source Han Serif TC", "PMingLiU", serif;
  --sans: "PingFang TC", "Microsoft JhengHei", "Noto Sans TC", "Heiti TC", system-ui, sans-serif;
  --column: 44rem;
  color-scheme: light;
}

/* Dark theme: follows the device unless the student picked one with the theme button. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #1b1a18; --surface: #252421; --ink: #ebe7df; --muted: #a39e94; --line: #3a3833;
    --bubble: #302e2a; --pen: #8db4dc; --pen-soft: #22303d; --red: #e8877a; --amber: #dcb05a; --on-pen: #13202d;
    --scrim: rgba(0, 0, 0, .6);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --paper: #1b1a18; --surface: #252421; --ink: #ebe7df; --muted: #a39e94; --line: #3a3833;
  --bubble: #302e2a; --pen: #8db4dc; --pen-soft: #22303d; --red: #e8877a; --amber: #dcb05a; --on-pen: #13202d;
  --scrim: rgba(0, 0, 0, .6);
  color-scheme: dark;
}
/* Figures are drawn black on white; keep them on a white card in either theme. */
.question img { background: #fff; border-radius: 6px; }
.theme-toggle { min-width: 2.2rem; }
.topline .actions { display: flex; gap: .8rem; align-items: baseline; }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 1rem/1.7 var(--sans);
}
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
button:disabled { cursor: default; opacity: .5; }
:focus-visible { outline: 2px solid var(--pen); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }
.sr {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.finished { border: 1px solid var(--line); border-radius: 16px; background: var(--surface); padding: .9rem 1rem; }
.finished p { margin: 0 0 .7rem; }
.thumbs figure { position: relative; margin: 0; }
.thumbs .remove {
  position: absolute; top: .2rem; right: .2rem; width: 1.6rem; height: 1.6rem; border-radius: 999px;
  border: 0; background: rgba(43, 42, 39, .7); color: #fff; line-height: 1; font-size: 1rem;
}

.column { width: 100%; max-width: var(--column); margin: 0 auto; padding: 0 1rem; }

/* Buttons: one solid (blue pen), the rest quiet. */
.solid {
  border: 0; border-radius: 999px; padding: .45rem 1.1rem;
  background: var(--pen); color: var(--on-pen); font-weight: 600;
}
.quiet {
  border: 1px solid var(--line); border-radius: 999px; padding: .35rem .9rem;
  background: var(--surface); color: var(--ink); font-size: .92rem;
}
.quiet:hover:not(:disabled) { border-color: var(--muted); }
.link { border: 0; background: none; padding: .25rem 0; color: var(--muted); }
.link:hover { color: var(--ink); }

.notice { margin: .5rem 0 0; font-size: .9rem; color: var(--muted); min-height: 1.4em; }
.notice[data-type="error"] { color: var(--red); }

/* ---------- Home: sign-in and question list ---------- */
.home { padding-top: 3rem; padding-bottom: 4rem; }
.home h1 { font: 600 1.5rem/1.3 var(--serif); margin: 0 0 .35rem; }
.home .lead { margin: 0 0 2rem; color: var(--muted); }
.signin { max-width: 22rem; }
.signin label { display: block; margin: 1rem 0 .3rem; font-size: .92rem; color: var(--muted); }
.signin input {
  width: 100%; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 10px;
  background: var(--surface);
}
.signin .solid { margin-top: 1.4rem; width: 100%; padding: .65rem; }

.topline { display: flex; align-items: baseline; justify-content: space-between; gap: 1rem; }
/* The menu button and the title stay together on the left. */
.topline .menu-button + h1 { margin-right: auto; }
.unit { margin: 2.2rem 0 0; }
.unit h2 { font: 600 1.05rem/1.4 var(--sans); margin: 0 0 .4rem; }
.unit h2 small { font-weight: 400; color: var(--muted); margin-left: .5rem; }
.questions { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.questions li { border-bottom: 1px solid var(--line); }
.questions button {
  display: flex; width: 100%; align-items: center; gap: .75rem;
  padding: .8rem .25rem; border: 0; background: none; text-align: left;
}
.questions button:hover .q-name { color: var(--pen); }
.q-name { flex: 1; }
.q-marks { color: var(--muted); font-size: .9rem; }
.status { font-size: .82rem; padding: .05rem .6rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.status[data-state="進行中"] { border-color: var(--pen); color: var(--pen); }
.status[data-state="已交卷"] { background: var(--bubble); border-color: var(--bubble); color: var(--ink); }

/* ---------- Work page ---------- */
.work { min-height: 100dvh; display: flex; flex-direction: column; }
.bar {
  position: sticky; top: 0; z-index: 5;
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid var(--line);
}
.bar .column { display: flex; align-items: center; gap: .75rem; padding-top: .55rem; padding-bottom: .55rem; }
.bar h1 { flex: 1; margin: 0; font: 600 1rem/1.4 var(--sans); text-align: center; }
.parts { display: flex; flex-wrap: wrap; gap: .4rem; padding-bottom: .55rem; }
.chip { font-size: .8rem; color: var(--muted); padding: 0 .55rem; border-radius: 999px; border: 1px solid var(--line); }
.chip[data-status="open"][data-current] { color: var(--pen); border-color: var(--pen); }
.chip[data-status="done"] { background: var(--bubble); border-color: var(--bubble); color: var(--ink); }
.chip[data-status="given"] { border-style: dashed; }

.question {
  margin: 1.2rem 0 .5rem; padding: 1rem 1.1rem; background: var(--surface);
  border: 1px solid var(--line); border-radius: 14px;
}
.question summary { cursor: pointer; color: var(--muted); font-size: .9rem; list-style: none; }
.question summary::-webkit-details-marker { display: none; }
.question[open] summary { margin-bottom: .6rem; }
.question .note { color: var(--muted); font-size: .88rem; margin: 0 0 .5rem; }
.question p { margin: .3rem 0; }
.question .part { margin-top: .6rem; }
.question .part b { font-weight: 600; margin-right: .35rem; }
.question .marks { color: var(--muted); font-size: .88rem; }
.question figure { margin: .8rem 0 0; text-align: center; }
.question img { max-width: 100%; height: auto; }

.chat { flex: 1; padding: .8rem 0 1.5rem; }
.turn { margin: 1.1rem 0; white-space: pre-line; overflow-wrap: anywhere; }
.turn.tutor { font: 400 1.05rem/1.8 var(--serif); }
.turn.student { display: flex; justify-content: flex-end; }
.turn.student > div {
  max-width: 85%; padding: .55rem .9rem; border-radius: 18px;
  background: var(--bubble); font-family: var(--sans);
}
.turn.given {
  font-family: var(--sans); padding: .6rem .9rem; border-left: 3px solid var(--pen);
  background: var(--pen-soft); border-radius: 0 10px 10px 0;
}
.turn.muted { color: var(--muted); }
.thinking { color: var(--muted); font-style: italic; }
.katex { font-size: 1.05em; }
.katex-display { overflow-x: auto; overflow-y: hidden; }

/* Composer: the one rounded box at the bottom. */
.dock {
  position: sticky; bottom: 0; z-index: 5;
  background: linear-gradient(to bottom, transparent, var(--paper) 1.2rem);
  padding: 1.4rem 0 max(.9rem, env(safe-area-inset-bottom));
}
.helpers { display: flex; gap: .5rem; margin-bottom: .55rem; }
.composer {
  border: 1px solid var(--line); border-radius: 20px; background: var(--surface);
  padding: .6rem .7rem .5rem .9rem;
  box-shadow: 0 1px 2px rgba(43, 42, 39, .04), 0 4px 18px rgba(43, 42, 39, .05);
}
.composer:focus-within { border-color: color-mix(in srgb, var(--pen) 45%, var(--line)); }
.composer textarea {
  width: 100%; min-height: 2.6rem; max-height: 9rem; resize: none; border: 0; outline: 0;
  background: none; padding: .2rem 0; line-height: 1.6;
}
.preview { min-height: 1.4rem; color: var(--muted); font-size: .92rem; padding: 0 0 .2rem; overflow-x: auto; }
.tools { display: flex; align-items: center; gap: .3rem; }
.tools .sym {
  border: 0; background: none; padding: .2rem .5rem; border-radius: 8px; color: var(--muted);
  font-size: .95rem;
}
.tools .sym:hover { background: var(--paper); color: var(--ink); }
.tools .solid { margin-left: auto; }

.stuck {
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
  padding: .9rem 1rem;
}
.stuck p { margin: 0 0 .7rem; }
.stuck .row { display: flex; flex-wrap: wrap; gap: .5rem; }

/* Hand-in sheet */
.sheet { border: 0; padding: 0; max-width: var(--column); width: 100%; margin: auto auto 0; background: none; }
.sheet::backdrop { background: var(--scrim); }
.sheet .panel {
  background: var(--surface); border-radius: 20px 20px 0 0; padding: 1.2rem 1.2rem max(1.2rem, env(safe-area-inset-bottom));
}
.sheet h2 { margin: 0 0 .3rem; font: 600 1.1rem/1.4 var(--sans); }
.sheet p { margin: 0 0 .8rem; color: var(--muted); font-size: .92rem; }
.pick { display: block; border: 1.5px dashed var(--line); border-radius: 14px; padding: 1rem; text-align: center; color: var(--pen); cursor: pointer; }
.pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.pick:focus-within { outline: 2px solid var(--pen); outline-offset: 2px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(4.5rem, 1fr)); gap: .5rem; margin: .8rem 0 0; }
.thumbs img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.sheet .row { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1rem; }

/* Marking scheme after hand-in: the red-pen column. */
.scheme { margin: 1rem 0 2.5rem; }
.scheme h2 { font: 600 1.15rem/1.4 var(--serif); margin: 0 0 .2rem; }
.scheme .label { color: var(--muted); font-size: .9rem; margin: 0 0 1rem; }
.scheme section { margin: 1.2rem 0 0; }
.scheme h3 { font: 600 1rem/1.4 var(--sans); margin: 0 0 .3rem; }
.rows { border-top: 1px solid var(--line); }
.srow { display: grid; grid-template-columns: 1fr 3.5rem; gap: .75rem; padding: .45rem 0; border-bottom: 1px solid var(--line); }
.srow .lines p { margin: .1rem 0; }
.srow .mk { color: var(--red); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.srow.alt .lines { color: var(--muted); }
.srow .remark { color: var(--muted); font-size: .88rem; }
.srow .fix { color: var(--red); font-size: .85rem; }
.explain { margin-top: .8rem; padding: .7rem .9rem; background: var(--paper); border-radius: 10px; font-family: var(--serif); }
.explain .banner { display: block; font: 400 .82rem/1.5 var(--sans); color: var(--muted); margin-bottom: .2rem; }

@media (max-width: 30rem) {
  .bar h1 { font-size: .95rem; }
  .turn.student > div { max-width: 92%; }
}
@media (prefers-reduced-motion: reduce) { * { scroll-behavior: auto !important; } }

/* ---------- Sidebar: beside the page on wide screens, behind ☰ on narrow ones ---------- */
:root { --sidebar: 16rem; }
.sidebar {
  position: fixed; inset: 0 auto 0 0; z-index: 20; width: var(--sidebar);
  display: flex; flex-direction: column; gap: .2rem;
  padding: max(.9rem, env(safe-area-inset-top)) .75rem max(.9rem, env(safe-area-inset-bottom));
  background: var(--surface); border-right: 1px solid var(--line);
  transform: translateX(-100%); visibility: hidden;
  transition: transform .2s ease, visibility 0s linear .2s;
  overflow-y: auto;
}
/* Hidden (not only moved) when closed, so it leaves the tab order. */
.nav-open .sidebar { transform: none; visibility: visible; transition: transform .2s ease; box-shadow: 0 0 40px rgba(0, 0, 0, .18); }
.nav-scrim { position: fixed; inset: 0; z-index: 15; background: var(--scrim); display: none; }
.nav-open .nav-scrim { display: block; }
.brand { font: 600 1.1rem/1.4 var(--serif); padding: .3rem .55rem .8rem; }
.nav { display: flex; flex-direction: column; gap: .1rem; }
.nav-link, .recent a {
  display: block; padding: .45rem .55rem; border-radius: 10px; color: var(--ink); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.nav-link:hover, .recent a:hover { background: var(--paper); }
.nav-link[aria-current], .recent a[aria-current] { background: var(--pen-soft); color: var(--pen); }
.nav-link.new { font-weight: 600; color: var(--pen); }
.nav-heading { margin: 1.1rem .55rem .2rem; font-size: .8rem; color: var(--muted); }
.recent { list-style: none; margin: 0; padding: 0; flex: 1; font-size: .93rem; }
.recent .empty { padding: .3rem .55rem; color: var(--muted); font-size: .88rem; }
.nav-foot { display: flex; justify-content: space-between; align-items: center; padding: .6rem .55rem 0; border-top: 1px solid var(--line); }
.menu-button { font-size: 1.25rem; line-height: 1; padding: .2rem .35rem; color: var(--ink); }
.bar-spacer { width: 1.9rem; }

@media (min-width: 48rem) {
  .with-sidebar { padding-left: var(--sidebar); }
  .with-sidebar .sidebar { transform: none; visibility: visible; box-shadow: none; transition: none; }
  .with-sidebar .menu-button { visibility: hidden; }
  .with-sidebar .topline .menu-button { display: none; }
  .nav-scrim { display: none !important; }
}
@media (prefers-reduced-motion: reduce) { .sidebar { transition: none; } }

/* ---------- Chat home ---------- */
.hello { padding: 18vh 0 1rem; text-align: center; }
.hello h2 { font: 600 1.6rem/1.3 var(--serif); margin: 0 0 .5rem; }
.hello p { color: var(--muted); margin: 0 auto 1.2rem; max-width: 30rem; }
.suggest { display: flex; flex-wrap: wrap; justify-content: center; gap: .5rem; }
.working {
  display: flex; justify-content: space-between; align-items: center; gap: .75rem;
  margin-bottom: .5rem; font-size: .88rem; color: var(--muted);
}
.working span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.working .link { color: var(--pen); white-space: nowrap; }

.problem-card {
  margin: 1.1rem 0; padding: .9rem 1rem 1rem; border: 1px solid var(--line); border-radius: 16px;
  background: color-mix(in srgb, var(--surface) 60%, var(--paper));
}
.problem-card[data-live] { border-color: color-mix(in srgb, var(--pen) 40%, var(--line)); }
.card-head { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.problem-card .question { margin: .6rem 0 .5rem; }
.problem-card .parts { padding: 0; }
.card-turns .turn:first-child { margin-top: .8rem; }
.card-turns .turn:last-child { margin-bottom: 0; }
.turn.solution {
  font-family: var(--sans); padding: .6rem .9rem; border-left: 3px solid var(--red);
  background: var(--paper); border-radius: 0 10px 10px 0;
}
.chip[data-status="shown"] { border-style: dashed; color: var(--red); }
.options { display: grid; gap: .45rem; margin-top: .7rem; }
.option {
  display: flex; gap: .7rem; align-items: baseline; text-align: left; width: 100%;
  padding: .55rem .8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface);
}
.option:hover:not(:disabled) { border-color: var(--pen); }
.option:disabled { opacity: 1; }
.option[data-chosen] { border-color: var(--red); }
.option[data-correct] { border-color: var(--pen); background: var(--pen-soft); }
.problem-card img { max-width: 100%; height: auto; background: #fff; border-radius: 6px; }
.problem-card figure { margin: .8rem 0 0; text-align: center; }
/* Keep the composer at the bottom of the screen even when the chat is short. */
.work > main { flex: 1; width: 100%; }

.table-wrap { overflow-x: auto; margin: .6rem 0; }
.qtable { border-collapse: collapse; font-size: .95rem; }
.qtable th, .qtable td { border: 1px solid var(--line); padding: .25rem .6rem; text-align: center; }
.qtable th { background: var(--paper); font-weight: 600; }
.option figure { margin: .4rem 0 0; }
.option img { max-width: min(16rem, 100%); }

/* ---------- Teacher console ---------- */
.console .column.wide { max-width: 64rem; }
.console .bar .column { flex-wrap: wrap; }
.console .bar h1 { flex: 0 0 auto; text-align: left; margin-right: .5rem; }
.tabs { display: flex; gap: .2rem; flex: 1; overflow-x: auto; }
.tab { border: 0; background: none; padding: .35rem .7rem; border-radius: 999px; color: var(--muted); white-space: nowrap; }
.tab[aria-selected="true"] { background: var(--pen-soft); color: var(--pen); font-weight: 600; }
.console main { padding-top: 1.2rem; padding-bottom: 3rem; }
.console h2 { font: 600 1.05rem/1.4 var(--sans); margin: 1.6rem 0 .6rem; }
.banner { margin: 0 0 1rem; padding: .7rem .9rem; border-radius: 12px; background: color-mix(in srgb, var(--red) 12%, var(--surface)); color: var(--red); }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(11rem, 1fr)); gap: .7rem; }
.stat { display: flex; flex-direction: column; gap: .1rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.stat strong { font: 600 1.35rem/1.3 var(--sans); font-variant-numeric: tabular-nums; }
.stat-label, .stat-sub, .muted { color: var(--muted); font-size: .85rem; }
.grid { width: 100%; border-collapse: collapse; font-size: .93rem; }
.grid th { text-align: left; font-weight: 600; color: var(--muted); font-size: .82rem; border-bottom: 1px solid var(--line); padding: .4rem .5rem; }
.grid td { border-bottom: 1px solid var(--line); padding: .5rem; white-space: nowrap; }
.grid .num { text-align: right; font-variant-numeric: tabular-nums; }
.grid .warn { color: var(--red); font-weight: 600; }
.grid tr[data-disabled] td { color: var(--muted); }
.pill { display: inline-block; font-size: .75rem; padding: 0 .5rem; margin-left: .35rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.pill.flag { border-color: var(--red); color: var(--red); }
.console .row { display: flex; flex-wrap: wrap; gap: .8rem; align-items: center; }
.console select, .console input:not([type="checkbox"]) {
  padding: .45rem .7rem; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink);
}
.create { display: flex; flex-wrap: wrap; gap: .5rem; align-items: center; }
.account { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin-top: 1rem; padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.account strong { margin-right: .4rem; }
#password-box, #create-password { flex-basis: 100%; }
.secret { margin: .3rem 0 0; }
.secret code { font-size: 1.05rem; padding: .1rem .4rem; background: var(--pen-soft); border-radius: 6px; user-select: all; }
.records { list-style: none; margin: 0; padding: 0; border-top: 1px solid var(--line); }
.record { display: flex; gap: .5rem; align-items: baseline; width: 100%; padding: .6rem .25rem; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; }
.record:hover .record-label { color: var(--pen); }
.record-label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.records .pill { margin-left: 0; }
.transcript { margin: .7rem 0; padding: .6rem .8rem; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); }
.transcript.student { background: var(--bubble); border-color: var(--bubble); }
.transcript.highlight { border-color: var(--red); box-shadow: 0 0 0 2px color-mix(in srgb, var(--red) 25%, transparent); }
.transcript .meta { font-size: .78rem; color: var(--muted); margin-bottom: .25rem; }
.transcript .body { white-space: pre-line; overflow-wrap: anywhere; }
.settings { display: grid; gap: 1rem; max-width: 26rem; }
.field { display: grid; gap: .25rem; }
.field span { font-weight: 600; font-size: .92rem; }
.grid th.num { text-align: right; }
@media (max-width: 36rem) {
  .console .bar h1 { display: none; }
  .console .tab { padding: .35rem .55rem; }
}
.grid th { white-space: nowrap; }
@media (max-width: 36rem) {
  .stats { grid-template-columns: 1fr 1fr; }
  .stat { padding: .65rem .8rem; }
  .stat strong { font-size: 1.1rem; }
}

/* ---------- Photo questions ---------- */
.photo-button { cursor: pointer; position: relative; }
.photo-button:focus-within { outline: 2px solid var(--pen); outline-offset: 2px; }
.attached { display: flex; justify-content: space-between; gap: .75rem; align-items: center; margin-bottom: .5rem; font-size: .88rem; color: var(--pen); }
.crop-sheet .panel { max-height: 92dvh; overflow-y: auto; }
.crop-stage { position: relative; width: 100%; margin: .2rem auto .8rem; touch-action: none; user-select: none; }
.crop-image { display: block; width: 100%; height: 100%; border-radius: 8px; background: #fff; }
.crop-box {
  position: absolute; border: 2px solid var(--pen); border-radius: 4px; cursor: move;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, .45);
}
.crop-stage { overflow: hidden; border-radius: 8px; }
/* Corner handles sit inside the frame, so they are never clipped at the photo's edge. */
.crop-handle { position: absolute; width: 1.6rem; height: 1.6rem; border: 0 solid var(--pen); }
.crop-handle.nw { left: -2px; top: -2px; border-width: 5px 0 0 5px; cursor: nwse-resize; }
.crop-handle.ne { right: -2px; top: -2px; border-width: 5px 5px 0 0; cursor: nesw-resize; }
.crop-handle.sw { left: -2px; bottom: -2px; border-width: 0 0 5px 5px; cursor: nesw-resize; }
.crop-handle.se { right: -2px; bottom: -2px; border-width: 0 5px 5px 0; cursor: nwse-resize; }
.crop-sheet .row { display: flex; gap: .5rem; align-items: center; }
.crop-sheet .grow { flex: 1; }
.photo-button.disabled { opacity: .5; pointer-events: none; }
.profile-text { width: 100%; padding: .6rem .8rem; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); resize: vertical; line-height: 1.6; }
.profile .row { justify-content: space-between; margin-top: .4rem; }
.gen-list { display: grid; gap: .8rem; margin: 1rem 0; }
.gen-card { padding: .8rem 1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.gen-card[data-deleted] { opacity: .55; }
.gen-head { display: flex; flex-wrap: wrap; gap: .5rem; align-items: baseline; margin-bottom: .4rem; }
.gen-body p { margin: .25rem 0; }
.gen-body h4 { margin: .6rem 0 .1rem; font-size: .85rem; color: var(--muted); }
.gen-body .step { font-size: .92rem; }
.pill.ok { border-color: var(--pen); color: var(--pen); }
.pill.check { border-color: var(--amber); color: var(--amber); }
.gen-body .unsure { color: var(--amber); font-size: .85rem; }
.job-steps { display: flex; flex-wrap: wrap; gap: .4rem; list-style: none; margin: .7rem 0 .4rem; padding: 0; }
.job-steps li { padding: .1rem .7rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); font-size: .88rem; }
.job-steps li[data-state="done"] { background: var(--pen-soft); border-color: var(--pen-soft); color: var(--pen); }
.job-steps li[data-state="now"] { border-color: var(--pen); color: var(--pen); font-weight: 600; animation: job-pulse 1.4s ease-in-out infinite; }
.job-steps li[data-state="failed"] { border-color: var(--red); color: var(--red); }
@keyframes job-pulse { 50% { opacity: .55; } }
@media (prefers-reduced-motion: reduce) { .job-steps li[data-state="now"] { animation: none; } }

/* ---------- Mistake notebook ---------- */
.notebook { list-style: none; margin: 0; padding: 0; display: grid; gap: .9rem; }
.notebook-entry { padding: .9rem 1.1rem; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); }
.notebook-head { display: flex; flex-wrap: wrap; gap: .4rem .7rem; align-items: baseline; }
.notebook-head .muted { margin-left: auto; font-size: .88rem; }
.notebook-preview { margin: .55rem 0 .8rem; line-height: 1.7; overflow-wrap: anywhere; }
.notebook-preview .katex-display { overflow-x: auto; overflow-y: hidden; }
.notebook-actions { display: flex; flex-wrap: wrap; gap: .5rem .8rem; align-items: center; }
.notebook-actions .link { margin-left: auto; color: var(--muted); }
.notebook-empty { padding: 1.4rem 1.1rem; border: 1px dashed var(--line); border-radius: 14px; color: var(--muted); }
.status[data-reason="shown"], .status[data-reason="given"] { border-color: var(--red); color: var(--red); }
.status[data-reason="hints"] { border-color: var(--pen); color: var(--pen); }
@media (max-width: 30rem) {
  .notebook-actions .link { margin-left: 0; }
}

/* My homework: worksheet list, burst camera, page check and results. */
.hw-list, .hw-pages, .hw-result { list-style: none; margin: 0; padding: 0; }
.hw-item { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between;
  padding: .9rem 0; border-bottom: 1px solid var(--line); }
.hw-item strong { margin-right: .5rem; }
.hw-item .chip[data-state="released"] { background: var(--bubble); border-color: var(--bubble); color: var(--ink); }
.hw-item-actions { display: flex; gap: .5rem; }
.camera { position: relative; margin: .5rem 0; border-radius: 16px; overflow: hidden; background: #000; }
.camera video { display: block; width: 100%; max-height: 65vh; object-fit: contain; }
.shutter { position: absolute; left: 50%; bottom: 1rem; transform: translateX(-50%); width: 68px; height: 68px;
  border-radius: 50%; border: 5px solid rgba(255,255,255,.55); background: #fff; }
.shutter:active { transform: translateX(-50%) scale(.92); }
.shutter:disabled { opacity: .6; }
.hw-actions { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; margin: .8rem 0; }
.hw-actions .pick { cursor: pointer; }
.hw-pages { display: flex; gap: .5rem; overflow-x: auto; padding-bottom: .4rem; }
.hw-pages li { flex: 0 0 auto; text-align: center; font-size: .8rem; color: var(--muted); }
.hw-pages img { display: block; height: 84px; border-radius: 8px; border: 1px solid var(--line); }
.hw-pages.large { flex-direction: column; overflow: visible; }
.hw-pages.large img { width: 100%; height: auto; max-height: 60vh; object-fit: contain; }
.hw-pdf { display: flex; flex-direction: column; justify-content: center; gap: .2rem; height: 84px; width: 64px; padding: .3rem; border-radius: 8px; border: 1px solid var(--line); background: var(--paper, transparent); overflow: hidden; }
.hw-pdf strong { color: var(--red); font-size: .9rem; }
.hw-pdf span { font-size: .65rem; word-break: break-all; line-height: 1.2; }
.hw-pages.large .hw-pdf { width: 100%; height: auto; min-height: 5rem; }
.hw-page-tools { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; margin: .4rem 0 1rem; }
.hw-page-tools span { margin-right: auto; color: var(--ink); }
#progress { width: 100%; }
.hw-result li { display: flex; justify-content: space-between; gap: 1rem; padding: .6rem 0; border-bottom: 1px solid var(--line); }
.hw-result li[data-verdict="right"] span:last-child { color: var(--green, #2e7d32); }
.hw-result li[data-verdict="wrong"] span:last-child { color: var(--red); }
.hw-total { color: var(--muted); font-size: .85rem; }
.hw-handed-in { flex-basis: 100%; }
