/* ~200 lines, no framework. */
:root {
  --bg: #fbfbf9;
  --fg: #1b1b1a;
  --muted: #6b6b66;
  --line: #dcdcd6;
  --card: #fff;
  --accent: #2f5d9e;
  --btn: #e7eefa;
  --btn-hover: #d8e4f7;
  --btn-fg: #234b80;
  --btn-line: #c3d4ee;
  --danger: #a33;
  --ok: #2c7a4b;
  --warn: #b25f00;
  --yellow: #9a7d00;
  --radius: 6px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #16171a; --fg: #e6e6e3; --muted: #9a9a95; --line: #2e3035;
    --card: #1d1f23; --accent: #7aa7e8; --danger: #e08b8b; --ok: #74c493; --warn: #cf8845; --yellow: #d8be4b;
    --btn: #22314a; --btn-hover: #2b3d5b; --btn-fg: #bcd3f5; --btn-line: #33445f;
  }
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif;
}
header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: .7rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--card);
}
/* brand and the admin's way in on the left, who-you-are and the switches on the right */
header .brand-row { display: flex; align-items: baseline; gap: 1rem; }
header nav { display: flex; align-items: center; gap: 1rem; }
/* the log-out button is a POST, but it belongs in the row of links */
header nav .logout { display: inline; margin: 0; }
header nav .logout button { font-size: inherit; padding: 0; }
.brand { font-weight: 700; letter-spacing: .04em; text-decoration: none; color: var(--fg); }
.who { color: var(--muted); }
main { max-width: 52rem; margin: 0 auto; padding: 1.5rem 1.2rem 4rem; }
h1 { font-size: 1.6rem; margin: .2rem 0 1rem; }
h2 { font-size: 1.25rem; margin: 2rem 0 .8rem; }
h3 { font-size: 1.05rem; margin: 0 0 .3rem; }
h4 { font-size: .85rem; text-transform: uppercase; letter-spacing: .06em;
     color: var(--muted); margin: 1rem 0 .4rem; font-weight: 600; }
a { color: var(--accent); }
a.big { font-size: 1.1rem; font-weight: 600; text-decoration: none; }
span.big { font-size: 1.05rem; font-weight: 600; }
span.big.muted { font-weight: 400; }
a.big:hover { text-decoration: underline; }
.muted { color: var(--muted); font-size: .88rem; }
.error { color: var(--danger); }
.tag {
  display: inline-block; margin-left: .5rem; padding: 0 .4rem; border-radius: 3px;
  background: var(--line); color: var(--muted); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .05em; vertical-align: 1px;
}
.card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin: 0 0 1rem;
}
ul.list { list-style: none; padding: 0; margin: 0; }
ul.list li { border-bottom: 1px solid var(--line); padding: .7rem 0; }
ul.list li:last-child { border-bottom: 0; }
.status {
  display: inline-block; margin-left: .5rem; padding: 0 .4rem; border-radius: 3px;
  background: var(--line); color: var(--muted); font-size: .72rem;
  text-transform: uppercase; letter-spacing: .05em; vertical-align: 1px;
}
.status.ok { background: var(--ok); color: var(--card); }
.status.graded { background: var(--accent); color: var(--card); }
.status.late, .status.warn { background: var(--warn); color: var(--card); }
/* a deadline that is open and waiting for this student */
.status.open { background: var(--yellow); color: var(--card); }
p.warning {
  margin: .8rem 0 0; padding: .5rem .7rem; border-radius: var(--radius);
  border: 1px solid var(--danger); color: var(--danger); font-size: .9rem;
}
.status.missed { background: var(--danger); color: var(--card); }
.due { color: var(--muted); font-size: .9rem; margin: 0 0 .6rem; }
label { display: block; margin: 0 0 .7rem; font-size: .9rem; color: var(--muted); }
label.inline { display: inline; margin: 0; }
input[type=text], input[type=password], textarea, input[type=file] {
  display: block; width: 100%; margin-top: .2rem; padding: .45rem .55rem;
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius);
}
textarea { resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .92rem; }
select {
  display: block; margin-top: .2rem; padding: .4rem .5rem;
  font: inherit; color: var(--fg); background: var(--bg);
  border: 1px solid var(--line); border-radius: var(--radius);
}
/* the deadline calendar: one column per weekday, every day a checkbox styled as a chip */
table.cal { border-collapse: collapse; width: 100%; margin: .4rem 0 1rem; table-layout: fixed; }
/* the read-only calendar stacks one table per month, so its heads repeat */
table.cal.view + table.cal.view { margin-top: 1.2rem; }
table.cal th {
  font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; padding: 0 0 .3rem;
}
table.cal td.day { padding: 1px; text-align: center; }
table.cal td.day label { display: block; margin: 0; cursor: pointer; }
/* the native box is only there for the keyboard; the span is what you see */
table.cal td.day input { position: absolute; opacity: 0; width: 0; height: 0; }
table.cal td.day .d {
  display: block; padding: .35rem .1rem; border: 1px solid var(--btn-line); border-radius: var(--radius);
  font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--fg); background: var(--bg);
}
/* dimmed: weekends, the winter break, and anything outside lecture time */
table.cal td.day.dim .d { color: var(--muted); background: var(--line); border-color: var(--line); }
table.cal td.day label:hover .d { border-color: var(--accent); }
table.cal td.day input:focus-visible + .d { outline: 2px solid var(--accent); outline-offset: 1px; }
table.cal td.day input:checked + .d {
  background: var(--accent); border-color: var(--accent); color: var(--card); font-weight: 600;
}
/* the read-only calendar has nothing to click, so it drops the boxes: a dimmed day is
   simply grey text, and only a deadline day is filled — in the colour of its status chip */
table.cal.view td.day .d { border-color: transparent; background: none; }
table.cal.view td.day.dim .d { background: none; color: var(--muted); }
table.cal.view td.day.due .d { background: var(--line); color: var(--fg); }
table.cal.view td.day.due.ok .d { background: var(--ok); color: var(--card); }
table.cal.view td.day.due.open .d { background: var(--yellow); color: var(--card); }
table.cal.view td.day.due.late .d, table.cal.view td.day.due.warn .d {
  background: var(--warn); color: var(--card);
}
table.cal.view td.day.due.missed .d { background: var(--danger); color: var(--card); }
table.cal a.daylink { display: block; text-decoration: none; }
/* a public holiday keeps its weight and gets a star */
table.cal .star { font-style: normal; font-size: .7em; vertical-align: .35em; margin-left: .1em; }
/* a day an assignment with hand-ins owns: a colour of its own, and no checkbox to toggle */
table.cal td.day.taken .d {
  background: var(--warn); border-color: var(--warn); color: var(--card); cursor: default;
}
table.cal td.day.out .d, table.cal td.day.out { border: 0; background: none; }
table.cal tr.month th {
  text-align: left; padding: .7rem 0 .25rem; font-size: .8rem; color: var(--fg);
  text-transform: none; letter-spacing: 0; border-bottom: 1px solid var(--line);
}
ul.list li.undated { opacity: .75; }
/* line number to deadline, next to the mass editor's box */
p.lines {
  display: flex; flex-wrap: wrap; gap: .1rem .9rem; margin: .3rem 0 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82rem;
}
/* the two shapes of the repetition form sit behind these */
.tabs { display: flex; flex-wrap: wrap; gap: .4rem; margin: 0 0 .9rem; }
.tabs .tab {
  background: none; border: 1px solid var(--line); color: var(--muted);
  font-size: .85rem; padding: .25rem .8rem;
}
.tabs .tab.on { background: var(--btn); color: var(--btn-fg); border-color: var(--btn-line); }
/* the repetition form: a row of small labelled fields that wraps */
.fields { display: flex; flex-wrap: wrap; gap: 0 1.2rem; }
.fields label { flex: 1 1 9rem; }
p.notice {
  margin: 0 0 .8rem; padding: .5rem .7rem; border-radius: var(--radius);
  border: 1px solid var(--ok); color: var(--ok); font-size: .9rem;
}
input:focus, textarea:focus, button:focus, select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }
button, .button {
  font: inherit; padding: .4rem .9rem; border: 1px solid var(--btn-line); border-radius: var(--radius);
  background: var(--btn); color: var(--btn-fg); cursor: pointer;
  text-decoration: none; display: inline-block;
}
button:hover, .button:hover { background: var(--btn-hover); }
button.link {
  background: none; border: 0; padding: 0 .3rem; color: var(--accent);
  text-decoration: underline; font-size: .85rem;
}
button.link.danger { color: var(--danger); }
button.link.pub { color: var(--ok); }
button.link.priv { color: var(--muted); }
.pub { color: var(--ok); font-size: .85rem; }
/* how far a deadline moves, in the mass editor's preview */
.shift {
  display: inline-block; margin-left: .5rem; padding: 0 .35rem; border-radius: 3px;
  background: var(--line); color: var(--muted); font-size: .78rem; font-variant-numeric: tabular-nums;
}
p.chips { margin: .2rem 0 .6rem; }
p.chips > .status:first-child { margin-left: 0; }
table.roster { width: 100%; border-collapse: collapse; font-size: .92rem; margin-top: .4rem; }
table.roster th {
  text-align: left; font-size: .75rem; text-transform: uppercase; letter-spacing: .05em;
  color: var(--muted); font-weight: 600; padding: 0 .4rem .2rem 0;
}
table.roster td { padding: .3rem .4rem .3rem 0; border-top: 1px solid var(--line); vertical-align: middle; }
table.roster td.points { text-align: right; white-space: nowrap; width: 1%; }
table.roster td.points input { width: 4rem; margin: 0; text-align: right; }
.save-row { display: flex; flex-wrap: wrap; align-items: center; gap: .8rem; margin-top: .8rem; }
/* the little forms in the admin console sit on one line with their labels */
.inline-form { display: inline-flex; align-items: center; gap: .3rem; margin: .2rem .4rem .2rem 0; }
.inline-form input[type=password], .inline-form input[type=text] { display: inline-block; width: 9rem; margin: 0; }
.inline-form select { display: inline-block; width: auto; margin: 0; }
.staff-row { display: flex; flex-wrap: wrap; gap: .3rem; margin: .3rem 0; }
.staff-row .tag { display: inline-flex; align-items: center; gap: .2rem; margin-left: 0; text-transform: none;
  letter-spacing: 0; font-size: .8rem; }
details.sub > summary { cursor: pointer; font-size: .9rem; color: var(--accent); margin: .6rem 0 .2rem; }
table.roster td .inline-form { margin: 0; }
details.settings > summary { cursor: pointer; font-size: .85rem; color: var(--accent); margin: .4rem 0; }
form.upload {
  display: flex; flex-wrap: wrap; align-items: center; gap: .6rem;
  margin-top: .8rem; padding-top: .8rem; border-top: 1px dashed var(--line);
}
form.upload input[type=file] { flex: 1 1 14rem; width: auto; margin: 0; }
.mine-file { display: flex; flex-wrap: wrap; align-items: baseline; gap: .6rem; margin-top: .8rem; }
/* long file names are cut with an ellipsis; the full name is in the title tooltip */
.fname {
  display: inline-block; max-width: min(22rem, 60vw); overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap; vertical-align: bottom;
}
table.subs .fname, table.roster .fname { max-width: min(16rem, 45vw); }
details.replace > summary {
  cursor: pointer; display: inline-block; margin-top: .4rem;
  color: var(--accent); font-size: .85rem;
}
details.replace > form.upload { margin-top: .4rem; }
.own, .shared {
  margin-top: 1.2rem; padding: .3rem 1rem .9rem;
  background: var(--bg); border: 1px solid var(--line); border-radius: var(--radius);
}
.own > :first-child, .shared > :first-child { margin-top: .7rem; }
.own > form.upload { border-top: 0; padding-top: 0; }
.own > .mine > .mine-file { margin-top: .7rem; }
.actions { display: flex; flex-wrap: wrap; align-items: baseline; gap: .2rem 1rem; margin-top: .4rem; }
.actions > details { flex: 1 1 18rem; }
.actions > details > summary { margin-top: 0; }
.late-text { color: var(--warn); }
table.subs { width: 100%; border-collapse: collapse; font-size: .92rem; }
table.subs td { padding: .3rem .4rem .3rem 0; border-bottom: 1px solid var(--line); vertical-align: middle; }
table.subs tr:last-child td { border-bottom: 0; }
table.subs td:nth-child(3), table.subs td:nth-child(4), table.subs td:nth-child(5) {
  text-align: right; white-space: nowrap; width: 1%;
}
.post { border-bottom: 1px solid var(--line); padding: .9rem 0; }
.post:last-of-type { border-bottom: 0; }
.post-head { display: flex; align-items: baseline; gap: .7rem; margin-bottom: .2rem; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md pre, .md blockquote { margin: .6rem 0; }
.md code {
  background: var(--line); padding: .1rem .3rem; border-radius: 3px;
  font: .9em ui-monospace, SFMono-Regular, Menlo, monospace;
}
.md pre {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  padding: .7rem .8rem; overflow-x: auto;
}
.md pre code { background: none; padding: 0; }
.md blockquote {
  margin-left: 0; padding-left: .8rem; border-left: 3px solid var(--line); color: var(--muted);
}
.md img { max-width: 100%; }
.md table { border-collapse: collapse; }
.md th, .md td { border: 1px solid var(--line); padding: .3rem .5rem; }
.htmx-request { opacity: .55; }
@media (max-width: 34rem) {
  main { padding: 1rem .8rem 3rem; }
  table.subs td:nth-child(2) { display: none; }
}
.view { font-size: .88rem; }
p.boards { display: flex; flex-direction: column; align-items: flex-start; gap: .5rem; }
p.boards > span { display: inline-flex; flex-wrap: wrap; align-items: center; gap: .5rem; }
p.boards .button { min-width: 15rem; text-align: left; }
.counts { font-size: .85rem; color: var(--muted); }
details.card > summary { cursor: pointer; font-weight: 600; }
details.card[open] > summary { margin-bottom: .8rem; }
.unread {
  display: inline-block; margin-left: .5rem; padding: 0 .45rem; border-radius: 999px;
  background: var(--accent); color: var(--card); font-size: .72rem; font-weight: 600; vertical-align: 1px;
}
ul.list li.new a.big { font-weight: 700; }
.post.pending { opacity: .8; border-left: 3px solid var(--accent); padding-left: .7rem; }
.post.editing { background: var(--card); }
.post.editing textarea { font-size: .92rem; }

/* pop quiz */
.answer-fields { display: grid; grid-template-columns: 1fr 1fr; gap: 0 1rem; }
.quiz-head { display: flex; flex-wrap: wrap; align-items: center; gap: 1rem; margin-bottom: .6rem; }
.clock {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.6rem;
  color: var(--accent); line-height: 1;
}
.clock.over { color: var(--muted); font-size: 1rem; text-transform: uppercase; letter-spacing: .06em; }
.quiz-question { font-size: 1.15rem; margin-bottom: 1rem; }
.quiz-grid { display: grid; grid-template-columns: 1fr 1fr; gap: .8rem; }
.quiz-option {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer;
  padding: .8rem .9rem; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card); color: var(--fg);
}
button.quiz-option:hover { border-color: var(--accent); background: var(--btn); }
.quiz-option.picked { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); }
.quiz-option.done { cursor: default; }
.quiz-letter {
  display: inline-block; min-width: 1.4rem; font-weight: 700; color: var(--muted);
}
.quiz-option .md { display: inline-block; vertical-align: top; max-width: calc(100% - 2rem); }
.quiz-result { margin-top: .5rem; display: flex; align-items: center; gap: .5rem; font-size: .85rem; }
.quiz-result .bar {
  height: .5rem; min-width: 2px; border-radius: 999px; background: var(--accent); flex: 0 0 auto;
}
.qr { margin-top: 1.4rem; text-align: center; }
.qr-svg { width: min(22rem, 70vw); height: auto; border: 8px solid #fff; border-radius: var(--radius); }
@media (max-width: 34rem) {
  .answer-fields, .quiz-grid { grid-template-columns: 1fr; }
}
