/* Vemarka — hand-written stylesheet, no build step. Mobile first.
   Look: an exam register. Navy ink on cool paper, ledger green for actions,
   marker yellow only where your eye should go (focus, the active column).
   Type: IBM Plex Sans (OFL, self-hosted) with tabular figures for marks. */

@font-face { font-family: "Plex"; src: url("/public/fonts/ibm-plex-sans-latin-400-normal.woff2") format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Plex"; src: url("/public/fonts/ibm-plex-sans-latin-600-normal.woff2") format("woff2"); font-weight: 600; font-display: swap; }
@font-face { font-family: "Plex"; src: url("/public/fonts/ibm-plex-sans-latin-700-normal.woff2") format("woff2"); font-weight: 700 800; font-display: swap; }

:root {
  --ink: #0b1120;        /* near-black ink: body and table text */
  --ink-2: #1c2740;      /* labels, chart words: still dark */
  --muted: #4a5468;      /* only for truly secondary hints */
  --heading: #14213d;    /* brand navy, extra bold */
  --paper: #f3f5f8;      /* page */
  --surface: #ffffff;    /* cards, inputs */
  --rule: #dde2ea;
  --rule-strong: #c7cfdb;
  --green: #0e6b57;      /* ledger green: primary actions, links */
  --green-dark: #0a5444;
  --green-tint: #e4f2ee;
  --marker: #f2c14e;     /* marker yellow: focus, active column */
  --marker-tint: #fdf3d6;
  --red: #b3261e;
  --red-tint: #fbe9e7;
  --amber: #8a5a00;
  --amber-tint: #fff4dc;
  --mis-tint: #eef2f9;
  --tint-ink: #e3e9f3;
  --row-hover: #f8fafc;
  --placeholder: #9aa3b2;
  --red-text: #7a1a14;
  --green-text: #0b4537;
  --red-border: #efb8b2;
  --saved: #bfe6d9;
  --bar: #14213d;
  --bar-2: #2b3a5c;
  --strong: #14213d;
  --on-strong: #ffffff;
  --on-green: #ffffff;
  --navy: #14213d;
  color-scheme: light;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --lift: 0 1px 2px rgba(20, 33, 61, .06), 0 4px 14px rgba(20, 33, 61, .08);
  --lift-hover: 0 2px 4px rgba(20, 33, 61, .08), 0 10px 24px rgba(20, 33, 61, .12);
  --ease: cubic-bezier(.2, .7, .2, 1);
  --font: "Plex", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* Dark theme: follows the device, unless the header switch says otherwise. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
  --ink: #f3f6fb;
  --ink-2: #d6deeb;
  --muted: #a9b5ca;
  --heading: #ffffff;
  --paper: #0e1422;
  --surface: #161e30;
  --rule: #263049;
  --rule-strong: #38446a;
  --green: #45c29f;
  --green-dark: #6fd6b8;
  --green-tint: #12352e;
  --marker-tint: #3a3014;
  --red: #f07a6e;
  --red-tint: #3b1c1b;
  --amber: #f0b850;
  --amber-tint: #30280f;
  --mis-tint: #1b2640;
  --tint-ink: #222c45;
  --row-hover: #1a2337;
  --placeholder: #67748d;
  --red-text: #ffb4ab;
  --green-text: #a6e8d2;
  --red-border: #6b2a26;
  --saved: #1f5a4a;
  --bar: #0a0f1b;
  --bar-2: #141c2e;
  --strong: #dfe6f2;
  --on-strong: #14213d;
  --on-green: #06241d;
  --lift: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .35);
  --lift-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 10px 24px rgba(0, 0, 0, .45);
  color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --ink: #f3f6fb;
  --ink-2: #d6deeb;
  --muted: #a9b5ca;
  --heading: #ffffff;
  --paper: #0e1422;
  --surface: #161e30;
  --rule: #263049;
  --rule-strong: #38446a;
  --green: #45c29f;
  --green-dark: #6fd6b8;
  --green-tint: #12352e;
  --marker-tint: #3a3014;
  --red: #f07a6e;
  --red-tint: #3b1c1b;
  --amber: #f0b850;
  --amber-tint: #30280f;
  --mis-tint: #1b2640;
  --tint-ink: #222c45;
  --row-hover: #1a2337;
  --placeholder: #67748d;
  --red-text: #ffb4ab;
  --green-text: #a6e8d2;
  --red-border: #6b2a26;
  --saved: #1f5a4a;
  --bar: #0a0f1b;
  --bar-2: #141c2e;
  --strong: #dfe6f2;
  --on-strong: #14213d;
  --on-green: #06241d;
  --lift: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 14px rgba(0, 0, 0, .35);
  --lift-hover: 0 2px 4px rgba(0, 0, 0, .35), 0 10px 24px rgba(0, 0, 0, .45);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  color: var(--ink);
  background: var(--paper);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { line-height: 1.2; font-weight: 700; letter-spacing: -0.015em; color: var(--heading); }
h1 { font-weight: 800; }
h1 { font-size: 1.6rem; margin: 0.25rem 0 0.75rem; }
h2 { font-size: 1.2rem; margin: 1.75rem 0 0.6rem; }
h3 { font-size: 1.05rem; margin: 0; }
p { margin: 0 0 0.8rem; }
a { color: var(--green); text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { color: var(--green-dark); text-decoration-thickness: 2px; }
code { font-size: 0.92em; }
:focus-visible { outline: 3px solid var(--marker); outline-offset: 2px; border-radius: 4px; }

.skip { position: absolute; left: -999px; top: 0.5rem; background: var(--marker); color: var(--navy); padding: 0.5rem 0.8rem; border-radius: var(--r-sm); z-index: 50; }
.skip:focus { left: 0.5rem; }

/* ---- App shell ------------------------------------------------------- */
.topbar { background: var(--bar); color: #fff; position: sticky; top: 0; z-index: 20; }
.topbar-inner { max-width: 72rem; margin: 0 auto; padding: 0.65rem 1rem; display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.brand { display: inline-flex; align-items: center; gap: 0.55rem; color: #fff; text-decoration: none; font-weight: 700; font-size: 1.12rem; letter-spacing: -0.01em; }
.brand:hover { color: #fff; }
.brand-mark { width: 1.75rem; height: 1.75rem; flex: none; }
.brand-mark rect { fill: var(--marker); }
.brand-mark path { fill: none; stroke: var(--navy); stroke-width: 3.2; stroke-linecap: round; stroke-linejoin: round; }
.topnav { display: flex; align-items: center; gap: 0.25rem; }
.topnav-link { color: #d9e0ee; text-decoration: none; padding: 0.4rem 0.6rem; border-radius: var(--r-sm); font: inherit; font-size: 0.95rem; transition: background .15s, color .15s; }
.topnav-link:hover { color: #fff; background: rgba(255, 255, 255, .1); }
.as-button { background: none; border: 0; cursor: pointer; }
.who { display: none; color: #9fb0cc; font-size: 0.9rem; padding: 0 0.4rem; max-width: 12rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Course navigation: a tab strip under the header on wide screens,
   a bottom bar with icons on phones. */
.coursenav { background: var(--bar-2); }
.coursenav-inner { max-width: 72rem; margin: 0 auto; padding: 0 1rem; display: flex; align-items: stretch; gap: 0.25rem; }
.coursenav-code { color: var(--marker); font-weight: 600; text-decoration: none; display: flex; align-items: center; padding-right: 0.9rem; margin-right: 0.4rem; border-right: 1px solid rgba(255, 255, 255, .15); white-space: nowrap; }
.coursenav-code:hover { color: var(--marker); }
.tab { display: flex; align-items: center; gap: 0.45rem; padding: 0.6rem 0.8rem; color: #c9d3e6; text-decoration: none; font-size: 0.95rem; border-bottom: 3px solid transparent; transition: color .15s, border-color .15s, background .15s; }
.tab:hover { color: #fff; background: rgba(255, 255, 255, .06); }
.tab svg { width: 1.15rem; height: 1.15rem; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.coursenav[data-section="overview"] [data-tab="overview"],
.coursenav[data-section="students"] [data-tab="students"],
.coursenav[data-section="gradebook"] [data-tab="gradebook"],
.coursenav[data-section="mis"] [data-tab="mis"],
.coursenav[data-section="analysis"] [data-tab="analysis"] { color: #fff; border-bottom-color: var(--marker); }

@media (max-width: 719px) {
  .coursenav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; background: var(--bar); border-top: 1px solid rgba(255, 255, 255, .12); padding-bottom: env(safe-area-inset-bottom); }
  .coursenav-inner { padding: 0; gap: 0; }
  .coursenav-code { display: none; }
  .tab { flex: 1; flex-direction: column; gap: 0.15rem; padding: 0.5rem 0.2rem 0.45rem; font-size: 0.72rem; border-bottom: 0; border-top: 3px solid transparent; }
  .tab svg { width: 1.4rem; height: 1.4rem; }
  .coursenav[data-section="overview"] [data-tab="overview"],
  .coursenav[data-section="students"] [data-tab="students"],
  .coursenav[data-section="gradebook"] [data-tab="gradebook"],
  .coursenav[data-section="mis"] [data-tab="mis"],
  .coursenav[data-section="analysis"] [data-tab="analysis"] { border-top-color: var(--marker); background: rgba(255, 255, 255, .06); }
  body:has(.coursenav) { padding-bottom: 4.5rem; }
}
@media (min-width: 720px) {
  .who { display: inline; }
  h1 { font-size: 1.85rem; }
}

.container { max-width: 46rem; margin: 0 auto; padding: 1.5rem 1rem 2.5rem; }
.container:has(.wide) { max-width: 72rem; }
.footer { text-align: center; color: var(--muted); font-size: 0.85rem; padding: 1.5rem 1rem 2rem; }
.footer p { margin: 0; }

/* ---- Messages -------------------------------------------------------- */
.flash { max-width: 44rem; margin: 1rem auto 0; padding: 0.7rem 1rem 0.7rem 2.6rem; border-radius: var(--r); background: var(--mis-tint); position: relative; box-shadow: var(--lift); animation: flash-in .35s var(--ease); }
.flash::before { content: ""; position: absolute; left: 1rem; top: 50%; width: 0.7rem; height: 0.7rem; margin-top: -0.35rem; border-radius: 50%; background: var(--ink-2); }
.flash-success { background: var(--green-tint); color: var(--green-text); }
.flash-success::before { background: var(--green); }
.flash-error { background: var(--red-tint); color: var(--red-text); }
.flash-error::before { background: var(--red); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-6px); } }
@media (max-width: 46rem) { .flash { margin: 0.75rem 1rem 0; } }
.error { background: var(--red-tint); color: var(--red-text); padding: 0.65rem 0.9rem; border-radius: var(--r-sm); border-left: 4px solid var(--red); }
.error ul { margin: 0.3rem 0 0; padding-left: 1.2rem; }
.error p { margin: 0; }
.warn { color: var(--amber); font-weight: 600; cursor: pointer; margin: 0.4rem 0; }
.ok { color: var(--green); font-weight: 600; }

/* ---- Buttons and links ---------------------------------------------- */
.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 2.6rem; padding: 0.55rem 1.1rem;
  border: 1px solid var(--green); border-radius: var(--r);
  background: var(--green); color: var(--on-green);
  font: inherit; font-weight: 600; line-height: 1.2; text-decoration: none; cursor: pointer;
  box-shadow: 0 1px 2px rgba(14, 107, 87, .25);
  transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s, border-color .15s, color .15s;
}
.button:hover { color: var(--on-green); background: var(--green-dark); border-color: var(--green-dark); transform: translateY(-1px); box-shadow: 0 6px 16px rgba(14, 107, 87, .28); text-decoration: none; }
.button:active { transform: translateY(0) scale(.98); box-shadow: 0 1px 2px rgba(14, 107, 87, .25); }
.button.small { min-height: 2.1rem; padding: 0.35rem 0.75rem; font-size: 0.9rem; border-radius: var(--r-sm); }
.button.secondary { background: var(--surface); color: var(--ink); border-color: var(--rule-strong); box-shadow: 0 1px 2px rgba(20, 33, 61, .06); }
.button.secondary:hover { color: var(--ink); border-color: var(--ink-2); background: var(--surface); box-shadow: var(--lift); }
.button.danger { background: #b3261e; border-color: #b3261e; color: #fff; box-shadow: 0 1px 2px rgba(179, 38, 30, .3); }
.button.danger:hover { background: #8e1d17; border-color: #8e1d17; box-shadow: 0 6px 16px rgba(179, 38, 30, .3); }
.button.on-dark { background: var(--marker); border-color: var(--marker); color: var(--navy); box-shadow: none; }
.button.on-dark:hover { background: #f6cf72; border-color: #f6cf72; color: var(--navy); }
.link { background: none; border: 0; padding: 0; color: var(--green); font: inherit; cursor: pointer; text-decoration: underline; text-underline-offset: 0.18em; }
.link:hover { color: var(--green-dark); }
.link.danger { color: var(--red); }
.link-small { font-size: 0.95rem; text-decoration: none; font-weight: 600; }

/* ---- Cards, forms ---------------------------------------------------- */
.card { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 1.25rem; box-shadow: 0 1px 2px rgba(20, 33, 61, .04); }
.card + .card { margin-top: 1rem; }
.narrow { max-width: 27rem; margin: 1.5rem auto; }
section.card.narrow { padding: 1.75rem 1.5rem; box-shadow: var(--lift); }
.stack { display: flex; flex-direction: column; gap: 1rem; }
.stack label { display: flex; flex-direction: column; gap: 0.35rem; font-weight: 600; font-size: 0.95rem; }
input, select, textarea { font: inherit; color: var(--ink); }
.stack input, .stack select, select, #command, input.short {
  padding: 0.6rem 0.75rem; border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
}
.stack input:hover, select:hover, #command:hover { border-color: var(--ink-2); }
.stack input:focus, select:focus, #command:focus, input.short:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px rgba(14, 107, 87, .18); }
input[type="file"] { padding: 0.6rem; border: 1px dashed var(--rule-strong); border-radius: var(--r); background: var(--paper); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--green); width: 1.05rem; height: 1.05rem; }
.stack select { width: 100%; }
.hint, .muted { color: var(--muted); font-weight: 400; }
.small { font-size: 0.9rem; }
.flush { margin: 0; }
.inline { display: inline; margin: 0; }
.inline-label { display: inline-flex !important; flex-direction: row !important; align-items: center; gap: 0.45rem; font-weight: 400 !important; }
input.short { width: 4.5rem; padding: 0.4rem 0.5rem; }
.choice { border: 0; padding: 0; margin: 0; display: flex; gap: 1.25rem; flex-wrap: wrap; }
.choice legend { font-weight: 600; margin-bottom: 0.3rem; }
.choice label { flex-direction: row; align-items: center; gap: 0.45rem; font-weight: 400; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; flex-wrap: wrap; }
.row-between h1, .row-between h2 { margin-bottom: 0.5rem; }
.row-start { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.actions { display: flex; gap: 0.9rem; font-size: 0.95rem; align-items: center; }
.empty { text-align: center; padding: 2rem 1.25rem; }
.break { word-break: break-all; font-size: 1.3rem; }
details summary { cursor: pointer; }
.table { width: 100%; border-collapse: collapse; margin: 0.75rem 0 1rem; font-size: 0.95rem; }
.table th { text-align: left; font-weight: 700; color: var(--ink-2); font-size: 0.85rem; border-bottom: 2px solid var(--rule); padding: 0.45rem 0.5rem; }
.table td { border-bottom: 1px solid var(--rule); padding: 0.45rem 0.5rem; }

/* ---- Home ------------------------------------------------------------ */
.hero { padding: 1.5rem 0 0.5rem; }
.hero h1 { font-size: clamp(2rem, 6vw, 3rem); line-height: 1.08; letter-spacing: -0.025em; margin: 0 0 1rem; max-width: 16ch; }
.lede { color: var(--ink-2); font-size: 1.12rem; max-width: 36rem; }
.steps ol { padding-left: 1.25rem; }
.steps li { margin: 0.6rem 0; }

/* ---- Courses --------------------------------------------------------- */
.course-list { list-style: none; padding: 0; margin: 1rem 0; display: grid; gap: 0.85rem; grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr)); }
.course-card { display: flex; flex-direction: column; gap: 0.2rem; height: 100%; text-decoration: none; color: var(--ink); border-left: 4px solid var(--green); transition: transform .18s var(--ease), box-shadow .18s var(--ease), border-color .18s; }
.course-card:hover { color: var(--ink); transform: translateY(-2px) scale(1.01); box-shadow: var(--lift-hover); text-decoration: none; }
.course-code { font-weight: 600; color: var(--green); letter-spacing: 0.02em; margin: 0; }
.course-title { font-size: 1.1rem; font-weight: 700; line-height: 1.3; }
.buckets { display: grid; gap: 0.85rem; }
.buckets > .card, .course-list .card { margin-top: 0; }
@media (min-width: 720px) { .buckets { grid-template-columns: 1fr 1fr; } }
.bucket { padding: 1rem 1.1rem; }
.assessment-list, .student-list { list-style: none; padding: 0; margin: 0.6rem 0 0; }
.assessment-list li, .student-list li { display: flex; justify-content: space-between; align-items: center; gap: 0.75rem; padding: 0.6rem 0; border-top: 1px solid var(--rule); }
.student-list.card { padding: 0.25rem 1.1rem; }
.student-list li:first-child { border-top: 0; }
.add-student { margin: 0.75rem 0 1rem; }
.add-student form { margin-top: 1rem; }

/* ---- Join link and QR ------------------------------------------------ */
.join-card { display: flex; gap: 1.25rem; align-items: center; flex-wrap: wrap; }
.qr { width: 9rem; height: 9rem; flex: 0 0 auto; background: #fff; padding: 0.4rem; border-radius: var(--r-sm); border: 1px solid var(--rule); }
.qr svg { width: 100%; height: 100%; display: block; }
.join-text { flex: 1 1 14rem; }
.join-text p { margin: 0 0 0.5rem; }
.join-url code { word-break: break-all; background: var(--paper); padding: 0.2rem 0.4rem; border-radius: var(--r-sm); }
.join-actions { display: flex; gap: 0.6rem; align-items: center; flex-wrap: wrap; }
.qr-screen { text-align: center; }
.qr-screen h1 { margin-top: 0; }
.qr-big { width: min(80vw, 26rem); height: min(80vw, 26rem); margin: 1rem auto; padding: 0.8rem; }
.join-url.big code { font-size: 1.15rem; }

/* ---- Gradebook ------------------------------------------------------- */
.grid-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); box-shadow: 0 1px 2px rgba(20, 33, 61, .04); }
.grid { border-collapse: separate; border-spacing: 0; width: 100%; font-size: 0.95rem; }
.grid th, .grid td { border-bottom: 1px solid var(--rule); padding: 0.45rem 0.55rem; text-align: center; white-space: nowrap; }
.grid thead th { background: var(--paper); font-weight: 600; font-size: 0.88rem; vertical-align: bottom; position: sticky; top: 0; z-index: 2; }
.grid tbody tr:hover td { background: var(--row-hover); }
.grid .sticky { position: sticky; left: 0; background: var(--surface); text-align: left; z-index: 1; box-shadow: 1px 0 0 var(--rule); }
.grid thead .sticky { background: var(--paper); z-index: 3; }
.grid tbody tr:hover .sticky { background: var(--row-hover); }
.grid input { width: 4.3rem; padding: 0.38rem; border: 1px solid var(--rule-strong); border-radius: var(--r-sm); text-align: center; font: inherit; background: var(--surface); transition: border-color .12s, box-shadow .12s; }
.grid input:focus { outline: none; border-color: var(--ink); box-shadow: 0 0 0 3px var(--marker); }
.grid input.bad { border-color: var(--red); background: var(--red-tint); }
.grid .mis { background: var(--mis-tint); color: var(--ink); }
.grid .total { position: sticky; right: 0; z-index: 1; background: var(--surface); box-shadow: -1px 0 0 var(--rule); font-weight: 600; }
.grid thead .total { background: var(--paper); z-index: 3; }
.grid td.live { font-style: italic; }
.grid .grade { font-weight: 700; color: var(--green); }
.grid th.pick { cursor: pointer; }
.grid th.pick:hover { background: var(--marker-tint); }
.grid th.voice-col { background: var(--marker); color: var(--navy); }
.grid th.voice-col .muted { color: var(--navy); }
.grid input.voice-col { border-color: var(--ink); background: var(--marker-tint); }
.grid input.flash { animation: cell-saved 1.2s; }
@keyframes cell-saved { 0% { background: var(--saved); } 100% { background: var(--surface); } }

/* ---- Voice entry ----------------------------------------------------- */
.mark-card { text-align: center; }
.mark-progress { font-size: 1.05rem; margin-top: 0; }
.mic { display: inline-flex; align-items: center; gap: 0.6rem; padding: 0.95rem 1.7rem; border-radius: 999px; border: 0; background: var(--strong); color: var(--on-strong); font: inherit; font-weight: 600; font-size: 1.1rem; cursor: pointer; box-shadow: var(--lift); transition: transform .15s var(--ease), box-shadow .15s var(--ease), background .15s; }
.mic:hover { transform: translateY(-1px) scale(1.02); box-shadow: var(--lift-hover); }
.mic:active { transform: scale(.97); }
.mic-dot { width: 0.8rem; height: 0.8rem; border-radius: 50%; background: var(--marker); }
.mic.on { background: var(--red); }
.mic.on .mic-dot { background: #fff; animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: 0.3; } }
.small-mic { padding: 0.55rem 1.1rem; font-size: 1rem; }
#typed { justify-content: center; margin: 0.9rem 0 0.3rem; }
#command { min-width: 14rem; }
.readback { font-size: 1.5rem; font-weight: 700; min-height: 2.2rem; margin: 0.8rem 0; }
.readback.ok { color: var(--green); }
.readback.bad { color: var(--red); font-size: 1.05rem; }
.confirm { text-align: left; background: var(--amber-tint); border-radius: var(--r); padding: 0.85rem 1rem; border-left: 4px solid var(--marker); }
.confirm ul { max-height: 12rem; overflow: auto; }
.mark-value { font-weight: 700; min-width: 2.5rem; text-align: right; }
.voicebar { margin-bottom: 1rem; }
.voicebar .readback { font-size: 1.15rem; margin: 0.5rem 0 0; min-height: 1.5rem; }

/* ---- MIS matching ---------------------------------------------------- */
.map-row { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; }
.map-head { min-width: 7rem; }

/* ---- Dialog ---------------------------------------------------------- */
.dialog { border: 0; border-radius: var(--r-lg); padding: 1.4rem 1.5rem; max-width: 27rem; box-shadow: 0 20px 50px rgba(20, 33, 61, .3); color: var(--ink); }
.dialog[open] { animation: flash-in .2s var(--ease); }
.dialog::backdrop { background: rgba(20, 33, 61, .5); }
.dialog h2 { margin: 0 0 0.4rem; }
.dialog-actions { display: flex; gap: 0.6rem; justify-content: flex-end; flex-wrap: wrap; margin-top: 1.1rem; }

/* ---- Destructive actions -------------------------------------------- */
.danger-zone { margin-top: 3rem; padding-top: 1rem; border-top: 1px dashed var(--rule-strong); text-align: right; }
.danger-card { border: 1px solid var(--red-border); border-top: 4px solid var(--red); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
  .button:hover, .course-card:hover, .mic:hover { transform: none; }
}

/* Small fixes from the screenshot review */
.row-between > span { display: inline-flex; gap: 0.5rem; flex-wrap: wrap; }
.voicebar .readback:empty { display: none; }
.voicebar > *:last-child { margin-bottom: 0; }
@media (max-width: 719px) {
  .grid { font-size: 0.9rem; }
  .grid .sticky { white-space: normal; min-width: 7.5rem; max-width: 9rem; font-size: 0.85rem; line-height: 1.3; }
  .grid input { width: 3.6rem; }
  .grid th, .grid td { padding: 0.4rem 0.4rem; }
}

/* Back links: a soft navy pill that fills on hover */
.back-row { margin: 0 0 1rem; }
.back {
  display: inline-flex; align-items: center; gap: 0.45rem;
  max-width: 100%; padding: 0.4rem 0.9rem 0.4rem 0.75rem;
  border-radius: 999px; background: var(--tint-ink); color: var(--ink);
  font-size: 0.92rem; font-weight: 600; text-decoration: none;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  transition: background .15s, color .15s, box-shadow .15s var(--ease), transform .15s var(--ease);
}
.back:hover { background: var(--strong); color: var(--on-strong); text-decoration: none; box-shadow: 0 4px 12px rgba(20, 33, 61, .2); }
.back:active { transform: scale(.97); }
.back-arrow { display: inline-block; transition: transform .15s var(--ease); }
.back:hover .back-arrow { transform: translateX(-3px); }

/* ---- Step 2: cards, row actions, forms -------------------------------- */
/* Assessment sections: a tinted heading band so the section stands apart
   from the assessments listed under it. */
.bucket { padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.bucket-head { display: flex; align-items: center; gap: 0.6rem; padding: 0.8rem 1rem 0.8rem 1.1rem; background: var(--tint-ink); border-bottom: 1px solid var(--rule-strong); }
.bucket-head h3 { font-size: 1.08rem; color: var(--heading); margin: 0; }
.weight { background: var(--strong); color: var(--on-strong); font-size: 0.78rem; font-weight: 600; padding: 0.15rem 0.55rem; border-radius: 999px; white-space: nowrap; }
.bucket-head .add { margin-left: auto; }
.bucket .assessment-list { margin: 0; padding: 0 1.1rem; flex: 1; }
.bucket .assessment-list li:first-child { border-top: 0; }
.bucket-empty { padding: 0.9rem 1.1rem; margin: 0; flex: 1; }
.bucket-foot { margin: 0; padding: 0.6rem 1.1rem; font-size: 0.88rem; color: var(--ink-2); background: var(--paper); border-top: 1px solid var(--rule); }

/* Row actions (Edit, Remove, Approve ...): quiet text buttons that tint on hover. */
.actions { gap: 0.3rem; }
.actions > a, .actions .link {
  display: inline-flex; align-items: center; padding: 0.25rem 0.6rem; border-radius: var(--r-sm);
  font-size: 0.9rem; font-weight: 600; text-decoration: none; color: var(--green);
  transition: background .15s, color .15s;
}
.actions > a:hover, .actions .link:hover { background: var(--green-tint); color: var(--green-dark); text-decoration: none; }
.actions .link.danger { color: var(--red); }
.actions .link.danger:hover { background: var(--red-tint); color: var(--red-text); }

/* Section headings inside pages get a little more weight. */
main h2 { color: var(--heading); }

/* File pickers: a real button instead of the browser's grey default. */
input[type="file"] { width: 100%; cursor: pointer; color: var(--muted); font-size: 0.95rem; }
input[type="file"]::file-selector-button {
  margin-right: 0.8rem; padding: 0.45rem 0.9rem; border: 1px solid var(--rule-strong); border-radius: var(--r-sm);
  background: var(--surface); color: var(--ink); font: inherit; font-weight: 600; cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
}
input[type="file"]:hover::file-selector-button { border-color: var(--ink-2); box-shadow: var(--lift); }

/* Placeholders lighter than typed text, so an empty box never looks filled. */
::placeholder { color: var(--placeholder); opacity: 1; }
.stack input::placeholder { color: var(--placeholder); }

/* Narrow form cards: heading closer to the back link. */
section.card.narrow h1 { margin-top: 0.25rem; }

/* ---- Step 3: gradebook on phones ----------------------------------- */
.help { margin: 0 0 1rem; }
.help summary { color: var(--green); font-weight: 600; font-size: 0.95rem; width: fit-content; }
.help p { margin: 0.5rem 0 0; }
.grid-tools { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin: 0 0 0.5rem; }
.switch { display: inline-flex; align-items: center; gap: 0.5rem; font-size: 0.92rem; font-weight: 600; cursor: pointer; }
.switch input { appearance: none; -webkit-appearance: none; width: 2.3rem; height: 1.3rem; border-radius: 999px; background: var(--rule-strong); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ""; position: absolute; top: 0.15rem; left: 0.15rem; width: 1rem; height: 1rem; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgba(0, 0, 0, .25); transition: transform .18s var(--ease); }
.switch input:checked { background: var(--green); }
.switch input:checked::after { transform: translateX(1rem); }
.hide-mis .grid .mis:not(.total) { display: none; }

/* The grid scrolls inside its own box, so the headings stay put on long lists. */
.grid-wrap { max-height: calc(100vh - 10rem); overflow: auto; overscroll-behavior: contain; }
.grid .sticky .sno { display: block; font-weight: 600; }
.grid .sticky .sname { display: block; color: var(--ink-2); font-size: 0.85rem; font-weight: 400; max-width: 14rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

@media (max-width: 719px) {
  .container:has(.wide) { padding-left: 0.6rem; padding-right: 0.6rem; }
  .grid-wrap { max-height: calc(100vh - 11.5rem); border-radius: var(--r); }
  .grid .sticky { min-width: 0; max-width: 7.2rem; width: 7.2rem; white-space: nowrap; padding-left: 0.55rem; }
  .grid .sticky .sno { font-size: 0.82rem; }
  .grid .sticky .sname { max-width: 6.6rem; font-size: 0.76rem; }
  .grid input { width: 3.4rem; min-height: 2.5rem; font-size: 1rem; }
  .grid thead th { font-size: 0.78rem; white-space: normal; min-width: 4.2rem; line-height: 1.25; }
  .grid thead th.sticky { min-width: 0; }
  .voicebar { padding: 0.85rem; }
  .voicebar .row-start { gap: 0.6rem; }
  #typed { flex: 1 1 100%; margin: 0; flex-wrap: nowrap; }
  #command { flex: 1; min-width: 0; }
  .voicebar .inline-label { font-size: 0.9rem; }
  .voicebar select { max-width: 11rem; }
}

/* Theme switch in the header */
.theme-toggle { display: inline-flex; align-items: center; justify-content: center; width: 2.25rem; height: 2.25rem; padding: 0; border: 0; border-radius: var(--r-sm); background: none; color: #d9e0ee; cursor: pointer; transition: background .15s, color .15s; }
.theme-toggle:hover { background: rgba(255, 255, 255, .1); color: #fff; }
.theme-toggle svg { width: 1.2rem; height: 1.2rem; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: none; }
.theme-toggle[data-mode="auto"] .i-auto, .theme-toggle[data-mode="light"] .i-light, .theme-toggle[data-mode="dark"] .i-dark { display: block; }

/* Destructive buttons: outlined in red, filled red on hover, with a bin icon. */
.button.danger-outline { background: var(--surface); color: var(--red); border: 1.5px solid var(--red); box-shadow: none; }
.button.danger-outline:hover { background: #b3261e; border-color: #b3261e; color: #fff; box-shadow: 0 6px 16px rgba(179, 38, 30, .28); }
.button .ico { width: 1.1rem; height: 1.1rem; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.button.warn-text { color: var(--red); }
.button.warn-text:hover { color: var(--red); border-color: var(--red); }
.danger-zone { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.75rem 1rem; text-align: left; padding: 1rem 1.1rem; margin-top: 3rem; border: 1px dashed var(--red-border); border-radius: var(--r-lg); background: color-mix(in srgb, var(--red-tint) 45%, transparent); }
.danger-zone p { margin: 0; flex: 1 1 16rem; }

/* Honeypot box for bots: off-screen, never shown to people. */
.hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* ---- Analysis (12.1) --------------------------------------------------- */
.analysis .card { margin-top: 1rem; }
.analysis .card h2 { margin-top: 0; font-size: 1.1rem; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(8.6rem, 1fr)); gap: 0.65rem; margin: 1rem 0 0; }
.tile { background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); padding: 0.85rem 1rem; display: flex; flex-direction: column; gap: 0.15rem; }
.tile-num { font-size: 1.6rem; font-weight: 700; color: var(--heading); line-height: 1.1; letter-spacing: -0.01em; }
.tile-of { font-size: 0.95rem; color: var(--ink-2); font-weight: 400; }
.tile-label { color: var(--ink-2); font-size: 0.86rem; }
.chart-grid { display: grid; gap: 1rem; margin-top: 1rem; }
.chart-grid .card { margin-top: 0; }
@media (min-width: 900px) { .chart-grid { grid-template-columns: 1fr 1fr; } }
.chart { width: 100%; height: auto; display: block; }
.chart .axis { stroke: var(--rule-strong); stroke-width: 1; }
.chart .bar { fill: var(--green); }
.chart .bar-fail { fill: var(--red); opacity: .85; }
.chart .val { fill: var(--ink); font-size: 13px; font-weight: 600; }
.chart .lbl { fill: var(--ink-2); font-size: 12px; }
.chart .note { fill: var(--ink-2); font-size: 12px; }
.chart .passline { stroke: var(--ink-2); stroke-width: 1.5; stroke-dasharray: 4 3; }
.chart .meanline { stroke: var(--ink); stroke-width: 2; }
.chart .medianline { stroke: var(--ink); stroke-width: 2; stroke-dasharray: 5 4; }
.chart-key { margin: 0.5rem 0 0; display: flex; align-items: center; gap: 0.35rem; flex-wrap: wrap; }
.key { display: inline-block; width: 1.2rem; height: 0; border-top: 2px solid var(--ink); vertical-align: middle; }
.key-median { border-top-style: dashed; }
.key-fail { height: 0.7rem; border: 0; background: var(--red); width: 0.7rem; border-radius: 2px; }
.grade-list { list-style: none; padding: 0; margin: 0; }
.grade-list > li { border-top: 1px solid var(--rule); }
.grade-list > li:first-child { border-top: 0; }
.grade-row { display: flex; align-items: center; gap: 0.9rem; padding: 0.5rem 0; cursor: pointer; }
.grade-tag { display: inline-block; min-width: 2.4rem; text-align: center; padding: 0.1rem 0.4rem; border-radius: var(--r-sm); background: var(--tint-ink); }
.name-list { list-style: none; padding: 0; margin: 0.25rem 0 0.5rem; }
.name-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.35rem 0; border-top: 1px dashed var(--rule); font-size: 0.95rem; }
.threshold { margin: 0.75rem 0 0.25rem; font-size: 1.05rem; }
@media (max-width: 719px) {
  .tab { font-size: 0.66rem; padding-left: 0.1rem; padding-right: 0.1rem; }
  .tile-num { font-size: 1.35rem; }
}
@media (max-width: 719px) {
  /* Charts shrink on phones; keep their words readable. */
  .chart .lbl, .chart .note { font-size: 19px; }
  .chart .val { font-size: 20px; }
}
.chart .halo { paint-order: stroke; stroke: var(--surface); stroke-width: 4px; stroke-linejoin: round; }
/* Jumps to a card (like #threshold) land below the sticky header. */
.analysis .card { scroll-margin-top: 7rem; }

/* ---- Student insight (12.2) ------------------------------------------- */
.seg { display: inline-flex; background: var(--tint-ink); border-radius: 999px; padding: 0.2rem; gap: 0.2rem; margin: 0 0 0.6rem; }
.seg-item { padding: 0.35rem 1rem; border-radius: 999px; color: var(--ink); text-decoration: none; font-weight: 600; font-size: 0.92rem; }
.seg-item:hover { background: var(--surface); color: var(--ink); text-decoration: none; }
.seg-item.is-on { background: var(--strong); color: var(--on-strong); }
.watch-list { list-style: none; padding: 0; margin: 0; }
.watch-list > li { padding: 0.65rem 0 0.65rem 0.8rem; border-left: 4px solid var(--marker); border-top: 1px solid var(--rule); }
.watch-list > li:first-child { border-top: 0; }
.watch-list > li.serious { border-left-color: var(--red); }
.watch-list a { text-decoration: none; color: var(--ink); }
.watch-list a:hover { text-decoration: underline; }
.reasons { margin: 0.2rem 0 0; padding-left: 1.1rem; color: var(--ink-2); font-size: 0.92rem; }
.table-wrap { overflow-x: auto; }
.h-sub { font-size: 1rem; font-weight: 400; }
.need-list { list-style: none; padding: 0; margin: 0; }
.need-list li { display: flex; justify-content: space-between; gap: 1rem; padding: 0.55rem 0; border-top: 1px solid var(--rule); font-size: 1.05rem; }
.need-list li:first-child { border-top: 0; }
.chart .studentline { fill: none; stroke: var(--green); stroke-width: 3; stroke-linejoin: round; }
.chart .avgline { fill: none; stroke: var(--muted); stroke-width: 2; stroke-dasharray: 2 4; opacity: .8; }
.chart .dot { fill: var(--green); stroke: var(--surface); stroke-width: 2; }
.chart .dot-fail { fill: var(--red); }
.key-student { border-top: 3px solid var(--green); }
.key-avg { border-top: 2px dotted var(--muted); }

/* ---- Assessment analysis (12.3) --------------------------------------- */
.chart .zone { fill: var(--red-tint); opacity: .7; }
.chart .zone-easy { fill: var(--marker-tint); opacity: .8; }
.chart .ring { fill: none; stroke: var(--red); stroke-width: 2; }
.band { display: inline-block; font-size: 0.75rem; font-weight: 600; padding: 0.05rem 0.45rem; border-radius: 999px; margin-left: 0.3rem; }
.band-hard { background: var(--red-tint); color: var(--red-text); }
.band-medium { background: var(--green-tint); color: var(--green-text); }
.band-easy { background: var(--marker-tint); color: var(--amber); }
.items .flag-row td { border-top: 0; padding-top: 0; }
.flag { display: block; font-size: 0.88rem; color: var(--amber); padding-left: 0.6rem; border-left: 3px solid var(--marker); margin: 0.1rem 0 0.3rem; }
.balance { list-style: none; padding: 0; margin: 0.3rem 0 0.6rem; }
.balance li { display: grid; grid-template-columns: 7rem 1fr 3.5rem; align-items: center; gap: 0.6rem; padding: 0.45rem 0; }
.balance-track { height: 0.8rem; background: var(--tint-ink); border-radius: 999px; overflow: hidden; }
.balance-fill { display: block; height: 100%; background: var(--green); border-radius: 999px; }
.balance-fill.low { background: var(--red); }
.balance-val { text-align: right; font-weight: 600; }
.big-num { font-size: 2.2rem; font-weight: 700; color: var(--heading); margin: 0 0 0.3rem; line-height: 1.1; }
.chart .numdot { stroke: var(--surface); stroke-width: 2; }
.chart .dotnum { fill: #fff; font-size: 11px; font-weight: 700; pointer-events: none; }
.num-chip { display: inline-flex; align-items: center; justify-content: center; width: 1.35rem; height: 1.35rem; border-radius: 50%; background: var(--green); color: #fff; font-size: 0.75rem; font-weight: 700; vertical-align: 1px; }

/* ---- Compare and report (12.4) ---------------------------------------- */
.chart .passrateline { fill: none; stroke: var(--ink-2); stroke-width: 2.5; stroke-dasharray: 6 4; }
.chart .dot-pass { fill: var(--ink-2); }
.key-pass { border-top: 2px dashed var(--ink-2); }
.this-row td { background: var(--green-tint); }
.seg { flex-wrap: wrap; }
.report { max-width: 50rem; margin: 0 auto; }
.report-bar { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex-wrap: wrap; margin-bottom: 1.25rem; padding: 0.75rem 1rem; background: var(--surface); border: 1px solid var(--rule); border-radius: var(--r-lg); }
/* Report in colour (2.5b): navy header band with a yellow rule, navy headings
   with a green underline, tinted table headings, grades coloured by band.
   The band is navy in light and dark themes, so its text is always white. */
.report-head { background: linear-gradient(135deg, #14213d 0%, #1f3463 100%); color: #fff; border-radius: var(--r-lg); border-bottom: 5px solid var(--marker); padding: 1.1rem 1.3rem 1rem; margin-bottom: 1.25rem; }
.report-head h1 { margin: 0 0 0.3rem; color: #fff; }
.report-head p { margin: 0; color: #d9e0ee; }
.report-head .report-kicker { color: var(--marker); font-size: 0.8rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; margin-bottom: 0.2rem; }
.report-code { color: var(--marker); }
.report h2 { font-size: 1.15rem; margin: 1.6rem 0 0.5rem; padding-bottom: 0.25rem; border-bottom: 3px solid var(--green); color: var(--heading); }
.report h3 { font-size: 0.98rem; margin: 0 0 0.3rem; color: var(--heading); }
.report-table thead th, .report-table tbody th { background: var(--tint-ink); color: var(--heading); }
.report-table tbody tr:nth-child(even) td { background: color-mix(in srgb, var(--tint-ink) 40%, transparent); }
.report-chart { background: var(--surface); border: 1px solid var(--rule); border-top: 4px solid var(--green); border-radius: var(--r); padding: 0.7rem 0.8rem; }
.report .pos { color: var(--green); font-weight: 700; }
.report .neg { color: var(--red); font-weight: 700; }
.report .flag-note { color: var(--amber); }
.report-table th.g-top { background: var(--green); color: var(--on-green); }
.report-table th.g-good { background: var(--green-tint); color: var(--green-text); }
.report-table th.g-mid { background: var(--tint-ink); color: var(--heading); }
.report-table th.g-low { background: var(--amber-tint); color: var(--amber); }
.report-table th.g-fail { background: var(--red); color: #fff; }
.report-table td.g-fail { color: var(--red); font-weight: 700; }
.report-table td.g-top { color: var(--green); font-weight: 700; }
.grade-chip { display: inline-block; min-width: 2.1rem; text-align: center; padding: 0 0.35rem; border-radius: var(--r-sm); font-weight: 700; }
.grade-chip.g-top { background: var(--green-tint); color: var(--green-text); }
.grade-chip.g-good { background: var(--green-tint); color: var(--green-text); }
.grade-chip.g-mid { background: var(--tint-ink); color: var(--heading); }
.grade-chip.g-low { background: var(--amber-tint); color: var(--amber); }
.grade-chip.g-fail { background: var(--red-tint); color: var(--red-text); }
.report-foot { border-top: 2px solid var(--marker); padding-top: 0.5rem; }
.report-table th { width: auto; }
.report-table.compact td, .report-table.compact th { padding: 0.3rem 0.35rem; font-size: 0.88rem; }
.report-charts { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-top: 1rem; }
.report-foot { margin-top: 1.5rem; }
@media (max-width: 719px) { .report-charts { grid-template-columns: 1fr; } }
@media print {
  /* Always print light, whatever the screen theme. */
  html:root, html:root:not([data-theme="light"]), html:root[data-theme="dark"] {
    --ink: #0b1120; --ink-2: #1c2740; --muted: #4a5468; --heading: #14213d; --paper: #fff; --surface: #fff;
    --rule: #ccd3de; --rule-strong: #aab4c3; --green: #0e6b57; --green-dark: #0a5444;
    --green-tint: #e4f2ee; --green-text: #0b4537; --red: #b3261e; --red-tint: #fbe9e7;
    --red-text: #7a1a14; --marker-tint: #fdf3d6; --amber: #8a5a00; --tint-ink: #e8edf5;
    --strong: #14213d; --on-strong: #fff; --mis-tint: #eef2f9; --amber-tint: #fff4dc; --on-green: #fff;
    --marker: #f2c14e; color-scheme: light;
  }
  html, body { background: #fff !important; color: #0b1120; font-size: 11pt; }
  /* Print the colours (header band, tinted rows, grade chips), not just the text. */
  .report, .report * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  .topbar, .footer, .flash, .no-print, .skip { display: none !important; }
  body:has(.coursenav) { padding-bottom: 0; }
  .container { max-width: none; padding: 0; }
  .report { max-width: none; }
  .report-charts { grid-template-columns: 1fr 1fr; }
  .page-break { break-before: page; }
  .report h2, .report h3 { break-after: avoid; }
  /* Keep each heading with its table on one page (Chrome ignores break-after on
     headings). The long student list starts its own page instead. */
  .report-block { break-inside: avoid; page-break-inside: avoid; }
  .report-table thead { display: table-header-group; }
  table, tr, .report-charts { break-inside: avoid; }
  a { color: inherit; text-decoration: none; }
  @page { margin: 14mm; }
}
