/* Attendance register: ruled rows, ink-blue pen, red margin. System fonts on purpose:
   nothing to download on a weak campus connection. */
:root {
  --paper: #eef1f6;
  --sheet: #fbfcfe;
  --ink: #16233b;
  --ink-2: #4d5b75;
  --rule: #d3dae6;
  --pen: #2347b8;
  --pen-ink: #ffffff;
  --margin: #c23b3b;
  --ok: #1b7a4b;
  --late: #9a5a06;
  --bad: #b3261e;
  --wash-ok: #e3f3ea;
  --wash-late: #fbeed8;
  --wash-bad: #fbe4e2;
  --wash-pen: #e4eafb;
  --serif: "Iowan Old Style", "Charter", "Palatino Linotype", Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --paper: #0d1424; --sheet: #151e33; --ink: #e7ecf7; --ink-2: #9ba8c2; --rule: #2a3550;
    --pen: #7d9bff; --pen-ink: #0d1424; --margin: #ef7b7b; --ok: #5fcf98; --late: #f0b45f; --bad: #ff8c84;
    --wash-ok: #14301f; --wash-late: #38290f; --wash-bad: #3b1a19; --wash-pen: #1b2a57;
  }
}
:root[data-theme="dark"] {
  --paper: #0d1424; --sheet: #151e33; --ink: #e7ecf7; --ink-2: #9ba8c2; --rule: #2a3550;
  --pen: #7d9bff; --pen-ink: #0d1424; --margin: #ef7b7b; --ok: #5fcf98; --late: #f0b45f; --bad: #ff8c84;
  --wash-ok: #14301f; --wash-late: #38290f; --wash-bad: #3b1a19; --wash-pen: #1b2a57;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.5 var(--sans);
  min-height: 100dvh; -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { font-family: var(--serif); font-weight: 600; line-height: 1.2; margin: 0; letter-spacing: -0.01em; }
h1 { font-size: 1.75rem; } h2 { font-size: 1.3rem; } h3 { font-size: 1.05rem; }
p { margin: 0 0 .75rem; max-width: 62ch; }
a { color: var(--pen); }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-2); }
.small { font-size: .875rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 3px solid var(--pen); outline-offset: 2px; border-radius: 4px; }

/* ---------------------------------------------------------------- layout */
#app { max-width: 600px; margin: 0 auto; padding: 0 16px calc(84px + env(safe-area-inset-bottom)); }
#app.wide { max-width: 1040px; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 0 10px; }
.top .who { font-family: var(--serif); font-size: 1.1rem; font-weight: 600; }
.top .sub { display: block; font: .8rem var(--sans); color: var(--ink-2); }
.page-title { padding: 6px 0 12px; }
.stack > * + * { margin-top: 16px; }

.tabs {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; justify-content: center; gap: 2px;
  background: var(--sheet); border-top: 1px solid var(--rule); padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}
.tabs button {
  flex: 1; max-width: 140px; background: none; border: 0; color: var(--ink-2); font: 600 .78rem var(--sans);
  padding: 8px 4px; border-radius: 10px; display: grid; justify-items: center; gap: 2px; cursor: pointer; position: relative;
}
.tabs button svg { width: 22px; height: 22px; stroke: currentColor; fill: none; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.tabs button[aria-current="page"] { color: var(--pen); background: var(--wash-pen); }
.tabs .dot { position: absolute; top: 4px; right: calc(50% - 22px); background: var(--margin); color: #fff; font: 700 .65rem var(--sans); min-width: 17px; height: 17px; border-radius: 9px; display: grid; place-items: center; padding: 0 4px; }
@media (min-width: 900px) { .tabs { position: static; border: 0; background: none; justify-content: flex-start; padding: 0 0 12px; border-bottom: 1px solid var(--rule); margin-bottom: 16px; }
  .tabs button { flex: 0 0 auto; max-width: none; grid-auto-flow: column; gap: 8px; padding: 8px 14px; font-size: .9rem; }
  #app { padding-bottom: 40px; } .tabs .dot { position: static; } }

/* ----------------------------------------------------------- register rows */
.register { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; position: relative; overflow: hidden; }
.register.ruled::before { content: ""; position: absolute; top: 0; bottom: 0; left: 58px; width: 2px; background: var(--margin); opacity: .55; pointer-events: none; }
.row.now { background: var(--wash-pen); border-radius: 8px; }
.row { display: grid; grid-template-columns: 58px 1fr auto; align-items: center; gap: 0 12px; padding: 12px 14px 12px 0; border-top: 1px solid var(--rule); min-height: 64px; }
.row:first-child { border-top: 0; }
.row .when { text-align: right; padding-right: 8px; font-size: .8rem; line-height: 1.25; color: var(--ink-2); }
.row .when b { display: block; font-size: .95rem; color: var(--ink); font-weight: 600; }
.row .what { min-width: 0; padding-left: 4px; }
.row .what .t { font-weight: 600; overflow-wrap: anywhere; }
.row .what .s { font-size: .85rem; color: var(--ink-2); }
.row.plain { grid-template-columns: 1fr auto; padding: 12px 14px; }
.row.plain .what { padding-left: 0; }
.empty { padding: 28px 18px; color: var(--ink-2); }
.empty b { color: var(--ink); display: block; font-family: var(--serif); font-size: 1.1rem; margin-bottom: 4px; }

/* statuses are marks, like a register: a tick, an L, a dash */
.mark { display: inline-flex; align-items: center; gap: 6px; font: 700 .8rem var(--sans); padding: 4px 9px 4px 7px; border-radius: 99px; white-space: nowrap; background: var(--wash-pen); color: var(--pen); }
.mark i { font-style: normal; font-family: var(--serif); font-size: 1rem; line-height: 1; }
.mark.present { background: var(--wash-ok); color: var(--ok); }
.mark.late, .mark.in_progress, .mark.excused { background: var(--wash-late); color: var(--late); }
.mark.incomplete, .mark.rejected, .mark.absent, .mark.bad { background: var(--wash-bad); color: var(--bad); }
.mark.quiet { background: transparent; color: var(--ink-2); border: 1px solid var(--rule); }

/* --------------------------------------------------------------- controls */
button, .btn { font: 600 1rem var(--sans); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 46px; padding: 0 18px; border-radius: 10px; border: 1px solid var(--pen); background: var(--pen); color: var(--pen-ink); cursor: pointer; text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn.secondary { background: transparent; color: var(--pen); }
.btn.danger { background: transparent; color: var(--bad); border-color: var(--bad); }
.btn.block { width: 100%; }
.btn.small { min-height: 36px; padding: 0 12px; font-size: .875rem; border-radius: 8px; }
.btn[disabled] { opacity: .5; cursor: not-allowed; }
label { display: block; font-weight: 600; font-size: .9rem; margin-bottom: 4px; }
input, select, textarea { width: 100%; font: 1rem var(--sans); color: var(--ink); background: var(--sheet); border: 1px solid var(--rule); border-radius: 8px; padding: 11px 12px; min-height: 46px; }
input[type="file"] { padding: 9px; }
input[type="checkbox"] { width: 20px; min-height: 20px; height: 20px; accent-color: var(--pen); }
textarea { min-height: 84px; resize: vertical; }
.field + .field { margin-top: 14px; }
.hint { font-size: .82rem; color: var(--ink-2); margin-top: 4px; }
.err { color: var(--bad); font-weight: 600; font-size: .92rem; min-height: 1.3em; margin: 10px 0 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chips button { background: var(--sheet); color: var(--ink-2); border: 1px solid var(--rule); padding: 6px 12px; border-radius: 99px; font-size: .85rem; cursor: pointer; }
.chips button[aria-pressed="true"] { background: var(--pen); color: var(--pen-ink); border-color: var(--pen); }
.bar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.spacer { flex: 1; }

.panel { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 16px; }
.banner { border-radius: 10px; padding: 14px 16px; background: var(--wash-late); color: var(--ink); border: 1px solid var(--late); }
.banner.act { background: var(--wash-pen); border-color: var(--pen); }
.banner.good { background: var(--wash-ok); border-color: var(--ok); }
.banner b { font-family: var(--serif); font-size: 1.1rem; display: block; }

/* ------------------------------------------------------------------ login */
.login { padding-top: 12vh; }
.login h1 { margin-bottom: 4px; }
.login .lede { color: var(--ink-2); margin-bottom: 24px; }
.login .panel { padding: 20px; }

/* -------------------------------------------------------------------- scan */
.viewfinder { position: relative; border-radius: 14px; overflow: hidden; background: #0a0f1d; aspect-ratio: 1 / 1; width: 100%; }
.viewfinder video { width: 100%; height: 100%; object-fit: cover; display: block; }
.viewfinder .guide { position: absolute; inset: 14%; border: 3px solid rgba(255,255,255,.85); border-radius: 18px; box-shadow: 0 0 0 100vmax rgba(0,0,0,.35); pointer-events: none; }
.viewfinder .say { position: absolute; left: 0; right: 0; bottom: 0; padding: 12px 14px; background: linear-gradient(transparent, rgba(0,0,0,.7)); color: #fff; font-weight: 600; text-align: center; }
.viewfinder .idle { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; color: #cfd8ee; }

.line-result { background: var(--sheet); border: 1px solid var(--rule); border-radius: 12px; padding: 22px 18px 20px; position: relative; overflow: hidden; }
.line-result .ruled-line { display: flex; align-items: flex-end; gap: 14px; border-bottom: 2px solid var(--rule); padding-bottom: 6px; margin: 16px 0 14px; }
.line-result .nm { font-family: var(--serif); font-size: 1.35rem; font-weight: 600; flex: 1; }
.line-result .tk { width: 58px; height: 46px; flex: none; color: var(--pen); }
.line-result .tk path { stroke: currentColor; stroke-width: 6; fill: none; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 90; stroke-dashoffset: 90; animation: ink .55s .15s ease-out forwards; }
.line-result.fail .tk { color: var(--bad); }
@keyframes ink { to { stroke-dashoffset: 0; } }
@media (prefers-reduced-motion: reduce) { .line-result .tk path { animation: none; stroke-dashoffset: 0; } }

/* --------------------------------------------------------------- lecturer */
.qrbox { background: #fff; border-radius: 14px; padding: 10px; width: min(100%, 360px); margin: 0 auto; }
.qrbox svg { display: block; width: 100%; height: auto; }
.qrwrap { text-align: center; }
.qrwrap:fullscreen { background: #fff; display: grid; place-content: center; padding: 3vmin; }
.qrwrap:fullscreen .qrbox { width: min(86vh, 86vw); }
.qrwrap:fullscreen .no-full { display: none; }
.drain { height: 4px; background: var(--rule); border-radius: 2px; margin: 10px auto 0; width: min(100%, 360px); overflow: hidden; }
.drain i { display: block; height: 100%; background: var(--pen); transform-origin: left; }
.counts { display: flex; gap: 0; border: 1px solid var(--rule); border-radius: 10px; overflow: hidden; background: var(--sheet); }
.counts div { flex: 1; text-align: center; padding: 10px 4px; border-left: 1px solid var(--rule); }
.counts div:first-child { border-left: 0; }
.counts b { display: block; font: 600 1.4rem var(--serif); font-variant-numeric: tabular-nums; }
.counts span { font-size: .75rem; color: var(--ink-2); }
.table-wrap { overflow-x: auto; border: 1px solid var(--rule); border-radius: 10px; background: var(--sheet); }
table { border-collapse: collapse; width: 100%; font-size: .92rem; }
th, td { text-align: left; padding: 10px 12px; border-top: 1px solid var(--rule); vertical-align: top; }
thead th { border-top: 0; font-size: .8rem; color: var(--ink-2); font-weight: 600; background: var(--paper); white-space: nowrap; }
td .s { display: block; font-size: .8rem; color: var(--ink-2); }
tr.attn td:first-child { box-shadow: inset 3px 0 0 var(--margin); }
.flagtxt { color: var(--bad); font-size: .8rem; font-weight: 600; display: block; margin-top: 2px; }
dialog { border: 1px solid var(--rule); border-radius: 14px; background: var(--sheet); color: var(--ink); padding: 0; width: min(560px, calc(100vw - 24px)); max-height: 90dvh; }
dialog::backdrop { background: rgba(10, 15, 29, .55); }
dialog form, dialog .inner { padding: 20px; }
dialog h2 { margin-bottom: 10px; }
.evidence { font-size: .85rem; border: 1px solid var(--rule); border-radius: 8px; max-height: 190px; overflow: auto; margin: 10px 0 14px; }
.evidence div { padding: 7px 10px; border-top: 1px solid var(--rule); } .evidence div:first-child { border-top: 0; }
.choices { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin: 12px 0; }
.choices.two { grid-template-columns: 1fr 1fr; }

.grid2 { display: grid; gap: 14px; grid-template-columns: 1fr; } @media (min-width: 700px) { .grid2 { grid-template-columns: 1fr 1fr; } }
.kv { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.kv > div { background: var(--sheet); border: 1px solid var(--rule); border-radius: 10px; padding: 12px; }
.kv b { display: block; font: 600 1.5rem var(--serif); } .kv span { font-size: .8rem; color: var(--ink-2); }
.todo { list-style: none; padding: 0; margin: 0; }
.todo li { display: flex; gap: 10px; padding: 11px 0; border-top: 1px solid var(--rule); align-items: baseline; }
.todo li:first-child { border-top: 0; }
.todo .box { flex: none; width: 20px; height: 20px; border: 2px solid var(--rule); border-radius: 5px; display: grid; place-items: center; font-size: .8rem; color: var(--ok); }
.todo li.done .box { border-color: var(--ok); } .todo li.done { color: var(--ink-2); }
.pct { height: 8px; border-radius: 4px; background: var(--rule); overflow: hidden; margin-top: 6px; }
.pct i { display: block; height: 100%; background: var(--ok); }
.pct.low i { background: var(--late); }
.toast { position: fixed; left: 50%; bottom: calc(90px + env(safe-area-inset-bottom)); transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; font-weight: 600; z-index: 50; max-width: calc(100vw - 32px); }
.nowrap { white-space: nowrap; }
.copybox { font: 600 1.2rem ui-monospace, Menlo, Consolas, monospace; letter-spacing: .06em; background: var(--paper); border: 1px dashed var(--ink-2); border-radius: 8px; padding: 12px; text-align: center; user-select: all; }

td select { min-width: 220px; }
details.panel summary { list-style-position: inside; }
