:root {
  --bg: #ffffff; --fg: #1a1a1a; --muted: #5a5a5a; --line: #d4d4d4; --accent: #1d4e89;
  --accent-fg: #ffffff; --soft: #eef3f9; --danger: #a4161a; --ok: #1b6e3a;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root { --bg: #16181c; --fg: #ececec; --muted: #a8a8a8; --line: #3a3d44; --accent: #7fb0ec;
          --accent-fg: #0d1520; --soft: #222a35; --danger: #ff8a8a; --ok: #7fd49a; }
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--fg); font: 17px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif; }
main { padding: 16px; max-width: 1200px; margin: 0 auto; }
main.narrow { max-width: 420px; padding-top: 48px; }
h1 { font-size: 1.4rem; margin: 0; }
h2 { font-size: 1.15rem; margin: 1.2em 0 .4em; }
h3 { font-size: 1rem; margin: 1em 0 .3em; }
a { color: var(--accent); }
.top { display: flex; flex-wrap: wrap; gap: 8px 24px; align-items: center; justify-content: space-between;
       padding: 12px 16px; border-bottom: 1px solid var(--line); }
.top nav { display: flex; gap: 16px; flex-wrap: wrap; color: var(--muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.bar { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: end; }
label { display: block; }
label.check { display: flex; gap: 8px; align-items: center; }
.bar label:not(.check) { display: flex; flex-direction: column; font-weight: 600; }
.stack > * + * { margin-top: 12px; }
.stack label { font-weight: 600; }
.stack .check { font-weight: 400; }
.help { display: block; font-weight: 400; color: var(--muted); font-size: .9rem; }
input, select, textarea, button { font: inherit; color: inherit; }
input:not([type=checkbox]), select, textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--bg); }
.bar select { min-width: 260px; width: auto; }
input[type=checkbox] { width: 20px; height: 20px; accent-color: var(--accent); }
button { padding: 8px 14px; border-radius: 6px; border: 1px solid var(--accent); background: var(--accent);
         color: var(--accent-fg); cursor: pointer; }
button:hover { filter: brightness(1.08); }
button[value=cancel], #stuClose, .actions button[data-act^=un], .actions button[data-act=clear] {
  background: transparent; color: var(--accent); }
button.danger { background: transparent; color: var(--danger); border-color: var(--danger); }
button.link { background: none; border: 0; padding: 0; color: var(--accent); text-decoration: underline; font-weight: 600; text-align: left; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.actions { background: var(--soft); border-radius: 10px; padding: 4px 16px 16px; margin-top: 16px; }
.summary { font-weight: 600; }
.note { padding: 10px 14px; border-left: 4px solid var(--accent); background: var(--soft); }
.error { color: var(--danger); font-weight: 600; }
table { border-collapse: collapse; width: 100%; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th { font-size: .9rem; color: var(--muted); }
tr.offline td, tr.offline th { color: var(--muted); }
.thumbcol { display: none; }
.show-thumbs .thumbcol { display: table-cell; }
.thumbcol img { width: 200px; border: 1px solid var(--line); border-radius: 4px; }
#stuThumb { max-width: 100%; border: 1px solid var(--line); border-radius: 6px; }
#stuTabs li { margin: 6px 0; }
#stuTabs button { padding: 2px 10px; font-size: .9rem; }
dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--bg); color: var(--fg);
         width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 20px; }
dialog::backdrop { background: rgb(0 0 0 / .45); }
dialog h2 { margin-top: 0; }
.picker { max-height: 45vh; overflow: auto; border: 1px solid var(--line); border-radius: 8px; padding: 8px 12px; }
fieldset { border: 0; padding: 0; margin: 0 0 12px; }
legend { font-weight: 700; padding: 0; margin-bottom: 4px; }
.gradeall { font-style: italic; }
.toast { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); background: var(--fg); color: var(--bg);
         padding: 10px 18px; border-radius: 8px; max-width: calc(100vw - 32px); }
.toast:empty { display: none; }
@media (max-width: 700px) {
  td.current, th:nth-child(4) { display: none; }
}
