:root {
  --bg: #F3F5F8; --surface: #fff; --sunk: #E9EDF2; --ink: #17212F; --muted: #5C6878; --line: #D9DFE7;
  --accent: #0D7A63; --accent-ink: #fff; --good: #1D8A4C; --warn: #A86A12; --bad: #BE3B33; --marker: #FFE27A;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #0F1520; --surface: #172030; --sunk: #1D2839; --ink: #E6ECF4; --muted: #9AA8BA; --line: #2B3A50;
    --accent: #3BC4A0; --accent-ink: #062019; --good: #4CC27F; --warn: #E0A43E; --bad: #F07067; --marker: #6B5A12; color-scheme: dark; }
}
* { box-sizing: border-box }
body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 "Segoe UI", system-ui, sans-serif }
a { color: var(--accent) }
h1, h2, h3 { margin: 0; line-height: 1.2 }
h1 { font-size: 1.6rem } h2 { font-size: 1.15rem } h3 { font-size: 1rem }
header.top { background: var(--surface); border-bottom: 1px solid var(--line); padding: 12px max(16px, 3vw); display: flex; gap: 16px; align-items: center; flex-wrap: wrap }
header.top .brand { font-weight: 800; font-size: 1.1rem; margin-right: auto; text-decoration: none; color: var(--ink) }
header.top nav { display: flex; gap: 4px }
header.top nav a { text-decoration: none; color: var(--muted); padding: 6px 10px; border-radius: 6px }
header.top nav a:hover { background: var(--sunk); color: var(--ink) }
main { max-width: 1280px; margin: 0 auto; padding: 22px max(16px, 3vw) 60px; display: flex; flex-direction: column; gap: 18px }
.crumbs { color: var(--muted); font-size: .9rem }
.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--line); overflow-x: auto }
.subnav a { padding: 8px 14px; text-decoration: none; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap }
.subnav a.on { color: var(--ink); border-bottom-color: var(--accent) }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; margin-right: 8px; vertical-align: middle }
.dot-green { background: #22C55E } .dot-red { background: #EF4444 }
/* Attendance grid, laid out like the LMS (wisdom.lc-up.com) */
.att-panel { background: var(--sunk); border-radius: 16px; padding: 16px; min-width: 0 }
.att-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 14px }
.att-pill { background: #0B7BE3; color: #fff; font-weight: 700; padding: 7px 16px; border-radius: 10px; font-size: .9rem }
.att-month { display: flex; align-items: center; gap: 6px }
.att-month select { border-radius: 10px; padding: 7px 10px; background: var(--surface) }
.att-arrow { text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 10px; width: 34px; height: 34px;
  display: inline-flex; align-items: center; justify-content: center; font-size: 1.2rem }
.att-scroll { overflow-x: auto }
table.att { border-collapse: separate; border-spacing: 0 6px; width: max-content; min-width: 100% }
table.att th { color: #9CA3AF; font-weight: 700; font-size: 1rem; padding: 0 4px 6px; text-align: center; border: 0; text-transform: none; letter-spacing: 0 }
table.att th.att-today { color: #0B7BE3 }
table.att td { border: 0; padding: 0 4px; vertical-align: middle }
.att-name-h { position: sticky; left: 0; z-index: 3; background: var(--sunk); text-align: left !important; padding-left: 8px !important; min-width: 250px }
td.att-name { position: sticky; left: 0; z-index: 2; background: var(--sunk); padding-left: 0 !important }
.att-who { display: flex; align-items: center; gap: 12px; padding: 8px 10px; border-left: 4px solid; background: color-mix(in srgb, var(--surface) 55%, var(--sunk)); min-width: 250px }
.att-who.flag-green { border-left-color: #22C55E } .att-who.flag-red { border-left-color: #EF4444 }
.att-who a { color: var(--ink); font-weight: 700; text-decoration: none; white-space: nowrap }
.att-who a:hover { text-decoration: underline }
.att-avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--line); display: inline-flex; align-items: center; justify-content: center; border: 2px solid var(--surface); flex: none }
.att-avatar svg { width: 18px; height: 18px; fill: #9CA3AF }
.att-tg { color: #2AABEE; font-size: .85rem }
.att-addst, .row-menu { position: relative }
.att-addst > summary { list-style: none; cursor: pointer; font-weight: 700; padding: 7px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line) }
.row-menu { margin-left: auto }
.row-menu > summary { list-style: none; cursor: pointer; width: 28px; height: 28px; border-radius: 8px; display: flex; align-items: center; justify-content: center;
  color: var(--muted); font-weight: 800 }
.row-menu > summary:hover, .row-menu[open] > summary { background: var(--line); color: var(--ink) }
.att-addst > summary::-webkit-details-marker, .row-menu > summary::-webkit-details-marker { display: none }
.att-pop { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: 290px; background: var(--surface); border: 1px solid var(--line);
  border-radius: 12px; padding: 14px; box-shadow: 0 10px 30px rgb(0 0 0 / .18); font-weight: 400 }
.row-menu .att-pop, .new-group .att-pop { left: auto; right: 0 }
.new-group > summary { font-size: .9rem; padding: 6px 12px; color: var(--muted) }
.new-group > summary:hover, .new-group[open] > summary { color: var(--ink); border-color: var(--accent) }
.day-menu { display: inline-block; margin: 0 }
.day-menu > summary { width: auto; height: auto; min-width: 34px; padding: 2px 6px; color: inherit; font-weight: 700; font-size: 1rem }
.att-pop .inline { color: var(--ink) }
.att-pop button { width: 100% }
table.att tr:has(.row-menu[open]) td.att-name { z-index: 25 }
.cell { width: 46px; height: 46px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); padding: 0; display: flex; align-items: center; justify-content: center; cursor: pointer }
.cell:hover { border-color: #0B7BE3; filter: none }
.cell svg { width: 24px; height: 24px; fill: none; stroke-width: 3; stroke-linecap: round; stroke-linejoin: round }
.cell.yes svg { stroke: #22C55E } .cell.no svg { stroke: #EF4444 }
.cell.locked { opacity: .5 }
.att-add button { width: 34px; height: 34px; padding: 0; border-radius: 10px; color: #9CA3AF }
/* Homework grid: one cell per day, number = flashcards studied */
.hwcell { width: 40px; height: 40px; border-radius: 12px; background: var(--surface); border: 1px solid var(--line); display: flex;
  align-items: center; justify-content: center; font-weight: 800; font-size: .85rem; font-variant-numeric: tabular-nums; color: var(--muted) }
.hwcell.done { background: color-mix(in srgb, #22C55E 18%, var(--surface)); border-color: #22C55E; color: #15803D }
.hwcell.warn { background: color-mix(in srgb, #F59E0B 20%, var(--surface)); border-color: #F59E0B; color: #B45309 }
.hwcell.missed svg { width: 20px; height: 20px; fill: none; stroke: #EF4444; stroke-width: 3; stroke-linecap: round }
.hwcell.future, .hwcell.none { opacity: .45 }
.hw-sum { text-align: center; padding: 0 8px !important; white-space: nowrap; font-variant-numeric: tabular-nums }
.hw-nobot td:not(.att-name) { opacity: .55 }
.hw-tag { font-size: .7rem; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 0 6px; white-space: nowrap }
.hw-key { display: inline-flex; min-width: 26px; height: 22px; padding: 0 5px; border-radius: 7px; align-items: center; justify-content: center;
  font-weight: 800; font-size: .75rem; border: 1px solid var(--line) }
.hw-key.done { background: color-mix(in srgb, #22C55E 18%, var(--surface)); border-color: #22C55E; color: #15803D }
.hw-key.warn { background: color-mix(in srgb, #F59E0B 20%, var(--surface)); border-color: #F59E0B; color: #B45309 }
.hw-key.missed { color: #EF4444 }
td.att-pct, th.att-pct-h { text-align: right; padding-left: 10px !important; font-variant-numeric: tabular-nums }
.n-new { color: #2F7BE5; font-weight: 700 } .n-learn { color: var(--bad); font-weight: 700 } .n-rev { color: var(--good); font-weight: 700 }
.crumbs a { color: var(--muted) }
.head { display: flex; gap: 12px; align-items: flex-end; flex-wrap: wrap }
.head > div:first-child { margin-right: auto }
.sub { color: var(--muted); margin: 4px 0 0 }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 18px; min-width: 0 }
.panel > h2 { margin-bottom: 12px }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 18px }
.flash { background: color-mix(in srgb, var(--marker) 55%, var(--surface)); border: 1px solid var(--line); padding: 10px 14px; border-radius: 8px }
.idbox { display: inline-flex; flex-direction: column; align-items: center; background: var(--sunk); border-radius: 10px; padding: 8px 16px }
.idbox span { font-size: .75rem; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700 }
.idbox b { font-size: 1.7rem; font-variant-numeric: tabular-nums; letter-spacing: .06em }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums }
.tablewrap { overflow-x: auto }
th { text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--line); white-space: nowrap }
td { padding: 9px 10px; border-bottom: 1px solid var(--line) }
tr:last-child td { border-bottom: 0 }
.num { text-align: right }
.muted { color: var(--muted) }
.good { color: var(--good); font-weight: 700 } .warn { color: var(--warn); font-weight: 700 } .bad { color: var(--bad); font-weight: 700 }
.pill { display: inline-block; padding: 1px 9px; border-radius: 999px; font-size: .8rem; font-weight: 700; border: 1px solid var(--line); color: var(--muted) }
.pill.open { color: var(--good); border-color: var(--good) } .pill.closed { color: var(--muted) }
form.stack { display: flex; flex-direction: column; gap: 12px }
form.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end }
label { display: flex; flex-direction: column; gap: 4px; font-size: .85rem; font-weight: 600; color: var(--muted) }
label.inline { flex-direction: row; align-items: center; gap: 8px; color: var(--ink) }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  font: inherit; color: inherit; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; padding: 8px 10px; min-width: 0 }
textarea { min-height: 220px; font-family: Consolas, ui-monospace, monospace; font-size: .9rem; resize: vertical }
button, .btn { font: inherit; font-weight: 700; border: 1px solid var(--line); background: var(--surface); color: var(--ink); border-radius: 7px; padding: 8px 14px; cursor: pointer; text-decoration: none; display: inline-block }
button.primary, .btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent) }
button.danger { color: var(--bad) }
button:hover, .btn:hover { filter: brightness(.96) }
details summary { cursor: pointer; font-weight: 700 }
details[open] summary { margin-bottom: 12px }
.empty { color: var(--muted); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 8px }
.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 16px; text-decoration: none; color: inherit; display: flex; flex-direction: column; gap: 6px }
.card:hover { border-color: var(--accent) }
.card .code { font-variant-numeric: tabular-nums; color: var(--muted) }
.hint { font-size: .85rem; color: var(--muted); margin: 0 }
.login { max-width: 360px; margin: 10vh auto; }
:focus-visible { outline: 3px solid var(--marker); outline-offset: 2px }
.tg-user { font-size: .78em; color: var(--muted); font-weight: 400 }
.study-time { display: block; font-size: .78rem; color: var(--muted); font-weight: 400 }
.study-tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px }
.study-tile { display: flex; flex-direction: column; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px }
.study-tile b { font-size: 1.25rem; font-variant-numeric: tabular-nums }
.bulkbar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 10px }
.bulkbar .picked-count { margin-right: auto; font-size: .9rem }
.bulkbar select { width: auto; max-width: 100% }
.bulkbar button:disabled { opacity: .45; cursor: default }
.cards-table th.pick, .cards-table td.pick { width: 28px; padding-right: 0 }
.cards-table td.pick input, .cards-table th.pick input { width: 16px; height: 16px; margin: 0; vertical-align: middle }
.flash-row td { background: color-mix(in srgb, var(--accent) 12%, transparent) }
.card-edit { padding: 2px 9px; font-size: .95rem; line-height: 1.4; background: transparent; border: 1px solid transparent; color: var(--muted) }
.card-edit:hover, .card-edit:focus-visible { border-color: var(--line); color: var(--ink) }
.card-editor { width: min(460px, calc(100vw - 32px)); border: 1px solid var(--line); border-radius: 12px; padding: 20px; background: var(--surface); color: var(--ink) }
.card-editor::backdrop { background: rgb(0 0 0 / .35) }
.honesty { font-weight: 700; white-space: nowrap }
.honesty.honest { color: var(--good, #1D8A4C) } .honesty.doubtful { color: var(--warn, #A86A12) } .honesty.rushing { color: var(--bad, #D0453C) }
.honesty-reasons { margin: 4px 0 0; padding-left: 18px; font-size: .85rem; color: var(--muted) }

/* Wide pages (the homework calendar) use the whole screen */
main.wide { max-width: none }
/* Homework calendar: a slim student column, and day squares that shrink so the whole month fits the screen */
table.att.hw { border-spacing: 0 4px }
table.hw th { font-size: .78rem; padding: 0 2px 4px }
table.hw td { padding: 0 2px }
table.hw .hwcell { --cell: clamp(20px, calc((100vw - 640px) / 31 - 4px), 34px); width: var(--cell); height: var(--cell); border-radius: 7px; font-size: .72rem }
table.hw .hwcell.missed svg { width: 60%; height: 60% }
table.hw .att-name-h, table.hw .att-who { min-width: 0; width: 170px; max-width: 170px; box-sizing: border-box }
table.hw .att-who { padding: 4px 8px; gap: 5px }
table.hw .att-avatar { display: none }
table.hw .att-who a { min-width: 0; overflow: hidden; text-overflow: ellipsis; font-size: .86rem; font-weight: 600 }
table.hw .att-who .hw-tag, table.hw .att-who .att-tg { flex: none; font-size: .65rem }
table.hw .hw-sum { padding: 0 5px !important; font-size: .85rem }
table.hw th.hw-sum { font-size: .72rem }
@media (max-width: 700px) {
  table.hw .att-name-h, table.hw .att-who { width: 116px; max-width: 116px }
  table.hw .att-who a { font-size: .8rem }
  table.hw .hwcell { --cell: 26px }
}

/* Homework: three colours */
.hwcell.green, .hw-key.green { background: color-mix(in srgb, #22C55E 20%, var(--surface)); border-color: #22C55E; color: #15803D }
.hwcell.yellow, .hw-key.yellow { background: color-mix(in srgb, #F59E0B 22%, var(--surface)); border-color: #F59E0B; color: #B45309 }
.hwcell.red, .hw-key.red { background: color-mix(in srgb, #EF4444 14%, var(--surface)); border-color: #EF4444; color: #DC2626 }
.hwcell.red svg { width: 60%; height: 60%; fill: none; stroke: #EF4444; stroke-width: 3; stroke-linecap: round }
.hwcell.none { opacity: .45 }
.idbox.joincode small { font-size: .72rem; font-variant-numeric: tabular-nums }
.hwcell.frozen, .hw-key.frozen { background: color-mix(in srgb, #38BDF8 16%, var(--surface)); border-color: #38BDF8; color: #0284C7 }
.frozen-badge { color: #0284C7 }
