/* Business Clinic Attendance: the one stylesheet for every page.

   The look is borrowed from airport wayfinding signs: a calm light ground,
   black sign panels with white type for anything live (your status, who is in
   the room, the classroom code), big clear figures, and ONE yellow "go" action
   per screen. Read DESIGN.md for the reasons behind each choice.

   How this file is organised:
     1. Font and design tokens (named values used everywhere)
     2. Base elements
     3. Page frame: sidebar, top bar, menu, bottom bar
     4. Components: buttons, sign panels, panels, forms, lists, tables, notices
     5. Page-specific pieces
     6. The classroom screen
     7. Phone and tablet adjustments, reduced motion
*/

/* ---- 1. Font and design tokens ---------------------------------------- */

/* Atkinson Hyperlegible Next: designed so letters and digits that look alike
   (0 and O, 1 and l and I) never get confused. Served from our own server. */
@font-face {
  font-family: "Atkinson Next";
  src: url("fonts/atkinson-hyperlegible-next.woff2") format("woff2-variations"),
       url("fonts/atkinson-hyperlegible-next.woff2") format("woff2");
  font-weight: 200 800;
  font-display: swap;
}

:root {
  /* Surfaces */
  --ground: #f2f3f5;      /* the page */
  --surface: #ffffff;     /* panels */
  --raised: #f7f8f9;      /* inputs, hovered rows */
  --active: #e6e8eb;      /* selected nav item, empty bar track */
  --border: #e0e3e7;      /* panel edges */
  --rule: #eceef1;        /* lines between rows */
  --control: #c3c8ce;     /* button and input edges */
  --control-hover: #aab0b7;
  --input-hover: #9aa1a8;
  --flagged-row: #fffafa; /* a faint red tint behind rows that need a look */

  /* Text: every tier reaches 4.5:1 contrast on the ground and on white */
  --ink: #111416;
  --muted: #545b62;
  --faint: #656c73;

  /* Sign panels: black with white type, like an airport sign */
  --sign: #14181b;
  --sign-2: #2a3035;      /* lines and tracks on a sign */
  --sign-ink: #ffffff;
  --sign-muted: #b3bbc3;
  --sign-in: #8fe0b3;     /* "In the room" text on a sign */
  --sign-in-dot: #3ccf84;

  /* The brand yellow, kept for the one action you should take next */
  --go: #f0b429;
  --go-press: #dfa31a;
  --go-ink: #111416;

  /* Status: pale tints with dark text of the same hue */
  --in: #1d7a4b;      --in-tint: #e1f2e8;   --in-ink: #0b3a21;
  --bad: #b42318;     --bad-press: #8f1c13;  --bad-tint: #fdecea;  --bad-ink: #7a1810;  --bad-line: #f2c4bf;
  --warn-tint: #fff6dc; --warn-ink: #6b4a00; --warn-line: #f0d98a;

  --focus: #1f6feb;

  /* Shape and space (4px grid) */
  --r-panel: 10px;
  --r-control: 8px;
  --gap: 16px;
  --pad: 20px;
  --font: "Atkinson Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --sidebar: 240px;
  --topbar: 56px;
  --tabbar: 64px;
}

/* ---- 2. Base elements -------------------------------------------------- */

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 400 16px/1.5 var(--font);
  font-variant-numeric: tabular-nums;     /* digits line up in every column */
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p, dl, dd { margin: 0; }
h1 { font-size: 28px; line-height: 1.2; font-weight: 700; letter-spacing: -0.01em; text-wrap: balance; }
h2 { font-size: 18px; line-height: 1.3; font-weight: 700; }
h3 { font-size: 16px; font-weight: 700; }
a { color: inherit; text-underline-offset: 3px; text-decoration-thickness: 1px; }
::selection { background: var(--go); color: var(--go-ink); }
.icon { flex: none; }

/* Keyboard users always see where they are. */
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 4px; }

.skip-link { position: absolute; left: -999px; top: 8px; background: var(--sign); color: #fff; padding: 8px 12px; border-radius: 6px; z-index: 50; }
.skip-link:focus { left: 8px; }

.muted { color: var(--muted); }
.small { font-size: 14px; }
.center { text-align: center; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
/* Anything with the hidden attribute stays hidden, even if a class sets display. */
[hidden] { display: none !important; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Simple vertical rhythm: children of .stack sit 12px apart, .stack-lg 24px. */
.stack > * + * { margin-top: 12px; }
.stack-lg > * + * { margin-top: 24px; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* ---- 3. Page frame ----------------------------------------------------- */

.page {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 32px 64px;
  display: grid;
  gap: 24px;
  align-content: start;
}
.page.narrow { max-width: 480px; }
.page.medium { max-width: 760px; }
.page.member-home { max-width: 480px; }
@media (min-width: 1024px) {
  .page.member-home { max-width: 1040px; }
  .home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
}
.home-grid { display: grid; gap: 24px; }

/* Brand: a small black sign with the initials in yellow. */
.brand { display: inline-flex; align-items: center; gap: 10px; font-weight: 700; font-size: 16px; text-decoration: none; color: var(--ink); }
.mark {
  width: 28px; height: 28px; border-radius: 6px; flex: none;
  display: grid; place-items: center;
  background: var(--sign); color: var(--go);
  font: 700 12px/1 var(--font); letter-spacing: 0.02em;
}

/* Sidebar (laptop and desktop, admin only) */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: var(--sidebar);
  display: flex; flex-direction: column; gap: 20px;
  padding: 20px 12px 16px;
  border-right: 1px solid var(--border);
  background: var(--ground);
  overflow-y: auto;
}
.sidebar .brand { padding: 4px 10px; }
.side-nav { display: grid; gap: 2px; }
.side-nav a {
  display: flex; align-items: center; gap: 12px;
  min-height: 44px; padding: 0 8px; border-radius: var(--r-control);
  color: var(--muted); text-decoration: none; font-size: 15px;
}

.side-nav a[aria-current="page"] { background: var(--sign); color: var(--sign-ink); font-weight: 700; }
/* Each icon sits on a small square sign, like the rows of the phone menu. */
.side-nav .tile { width: 30px; height: 30px; border-radius: 6px; flex: none; display: grid; place-items: center; background: var(--active); color: var(--ink); }
.side-nav a[aria-current="page"] .tile { background: var(--sign-2); color: var(--sign-ink); }
.side-group { font-size: 13px; color: var(--faint); padding: 16px 12px 4px; }
.side-foot { margin-top: auto; padding: 12px; border-top: 1px solid var(--border); display: grid; gap: 4px; }
.side-user { font-size: 14px; font-weight: 700; }
.link-button {
  display: inline-flex; align-items: center; gap: 6px; padding: 0; min-height: 32px;
  background: none; border: 0; color: var(--muted); font: inherit; font-size: 14px; cursor: pointer;
}


body.with-sidebar .page { margin-left: var(--sidebar); max-width: calc(1120px + var(--sidebar)); padding-left: 40px; padding-right: 40px; }
body.with-sidebar .page.narrow, body.with-sidebar .page.medium { margin-left: calc(var(--sidebar) + 40px); padding-left: 0; }

/* Top bar: on phones and tablets for everyone; on large screens only for members. */
.topbar {
  /* Above the bottom bar (25): the Menu sheet lives inside the top bar, and a
     parent's layer decides how high everything inside it can go. At 20 the
     bottom bar was drawn over the menu's last row (Log out). */
  position: sticky; top: 0; z-index: 30;
  height: var(--topbar);
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 0 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
body.with-sidebar .topbar { display: none; }

/* Menu: a <details> element. The summary is the button; the sheet is the list. */
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-button {
  display: inline-flex; align-items: center; gap: 8px;
  min-height: 44px; padding: 0 14px; border-radius: var(--r-control);
  border: 1px solid var(--control); background: var(--surface);
  font-weight: 700; font-size: 15px; cursor: pointer;
}
.menu[open] .menu-button { background: var(--sign); border-color: var(--sign); color: var(--sign-ink); }
.menu:not([open]) .menu-sheet { display: none; }   /* closed means not laid out at all */
.menu-sheet {
  position: fixed; left: 0; right: 0; top: var(--topbar); bottom: 0; z-index: 30;
  overflow-y: auto;
  overscroll-behavior: contain;   /* scrolling the menu never scrolls the page behind it */
  /* Room at the bottom for the iPhone home bar, so the last row (Log out) can
     always be scrolled fully into view. */
  padding: 20px 16px calc(40px + env(safe-area-inset-bottom));
  background: var(--ground);
  display: grid; gap: 16px; align-content: start;
}
.menu-user { font-size: 14px; color: var(--muted); }
.menu-list { display: grid; background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-panel); overflow: hidden; }

/* Rows that lead with a black square sign and end with a chevron. Used for
   menus and for lists of things you can open. */
.menu-list a, .nav-row {
  display: flex; align-items: center; gap: 14px;
  min-height: 60px; padding: 8px 14px 8px 12px;
  text-decoration: none; font-weight: 700;
  border-top: 1px solid var(--rule);
}
.menu-list a:first-child, .nav-row:first-child { border-top: 0; }
.menu-list a > .icon:last-child, .nav-row > .icon:last-child { margin-left: auto; color: var(--faint); }
.menu-list a[aria-current="page"] { background: var(--raised); }
.glyph {
  width: 36px; height: 36px; border-radius: 6px; flex: none;
  display: grid; place-items: center;
  background: var(--sign); color: var(--sign-ink);
}

/* Bottom bar (admin, phones and tablets): the main pages, always visible. */
.tabbar { display: none; }

/* ---- 4. Components ------------------------------------------------------ */

/* Buttons. One look, a few roles:
     .btn          neutral (white with an edge)
     .btn-go       THE next action: yellow, with a black arrow square
     .btn-dark     a strong action that isn't "go" (Punch out, Correct time)
     .btn-danger   deletes something
     .btn-quiet    a text-only action                                    */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-height: 44px; padding: 0 18px;
  border-radius: var(--r-control);
  border: 1px solid var(--control);
  background: var(--surface); color: var(--ink);
  font: 700 15px/1 var(--font);
  text-decoration: none; cursor: pointer;
  transition: background-color .15s ease-out, border-color .15s ease-out, transform .1s ease-out;
}

.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: .55; cursor: default; transform: none; }
.btn-small { min-height: 36px; padding: 0 12px; font-size: 14px; gap: 6px; }
.btn-block { width: 100%; }
.btn-large { min-height: 56px; font-size: 18px; }

.btn-go { background: var(--go); border-color: var(--go); color: var(--go-ink); padding-left: 8px; }

.btn-go .arrow {
  width: 30px; height: 30px; border-radius: 5px; flex: none;
  display: grid; place-items: center;
  background: var(--go-ink); color: var(--go);
}
.btn-large.btn-go { padding-left: 10px; }
.btn-large.btn-go .arrow { width: 38px; height: 38px; }
.btn-dark { background: var(--sign); border-color: var(--sign); color: var(--sign-ink); }

.btn-danger { background: var(--surface); border-color: var(--bad-line); color: var(--bad); }

.btn-danger.solid { background: var(--bad); border-color: var(--bad); color: #fff; }

.btn-quiet { border-color: transparent; background: transparent; color: var(--muted); padding: 0 8px; }

.inline-form { display: inline; }

/* Title row at the top of a page: the heading, a line under it, and the actions. */
.title-row { display: flex; flex-wrap: wrap; gap: 16px; align-items: flex-end; justify-content: space-between; }
.title-row .sub { color: var(--muted); margin-top: 4px; }
.title-row .actions { display: flex; flex-wrap: wrap; gap: 8px; }
.back { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); text-decoration: none; font-size: 15px; min-height: 32px; }
.back:hover { color: var(--ink); }

/* Sign panels: black, white type, for anything that is live status. */
.sign { background: var(--sign); color: var(--sign-ink); border-radius: var(--r-panel); padding: 20px 22px; }
.sign .muted, .sign .sub { color: var(--sign-muted); }
.sign h2 { color: var(--sign-muted); font-size: 15px; font-weight: 700; }

/* Panels: white surfaces with a thin edge, no shadow. */
.panel { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-panel); }
.panel-pad { padding: var(--pad); }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; padding: 16px var(--pad) 12px; }
.panel-head .muted { font-size: 14px; }
.grid-main { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: var(--gap); align-items: stretch; }
/* Side panels in that row share the main panel's height; their rows spread out
   evenly instead of leaving an empty band at the bottom. */
.grid-main > .panel { display: flex; flex-direction: column; }
.grid-main > .panel > .bars { flex: 1; align-content: space-evenly; }

/* Status marks: a dot and a word, never colour alone. */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 26px; padding: 0 10px; border-radius: 999px;
  font-size: 13px; font-weight: 700; white-space: nowrap;
}
.pill::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill-in { background: var(--in-tint); color: var(--in-ink); }
.pill-bad { background: var(--bad-tint); color: var(--bad-ink); }
.pill-warn { background: var(--warn-tint); color: var(--warn-ink); }
.pill-quiet { background: var(--active); color: var(--muted); }
.flag { color: var(--bad); font-size: 13px; font-weight: 700; }

/* Forms */
.field { display: grid; gap: 6px; }
.label { font-size: 14px; font-weight: 700; color: var(--muted); }
.label .opt { font-weight: 400; }
.hint { font-size: 14px; color: var(--muted); }
input[type=text], input[type=password], input[type=date], input[type=time], input[type=number], select, textarea {
  width: 100%; min-height: 48px; padding: 10px 14px;
  border: 1px solid var(--control); border-radius: var(--r-control);
  background: var(--surface); color: var(--ink);
  font: 400 16px/1.4 var(--font);
}
textarea { min-height: 96px; resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
.code-input::placeholder { font-size: 17px; font-weight: 400; letter-spacing: 0; color: var(--faint); }

input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid var(--focus); outline-offset: 0; border-color: var(--focus); border-radius: var(--r-control); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px 16px; align-items: end; }
.choice { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--r-control); background: var(--surface); cursor: pointer; }
.choice:has(input:checked) { border-color: var(--sign); outline: 1px solid var(--sign); outline-offset: -2px; }
.choice input { margin-top: 3px; accent-color: var(--sign); width: 18px; height: 18px; }
.choice strong { display: block; }

/* The 6-digit code box: big, spaced digits. */
.code-input {
  text-align: center; font-size: 28px !important; font-weight: 700 !important;
  letter-spacing: 0.35em; padding-left: calc(14px + 0.35em) !important;
  min-height: 60px !important; background: var(--raised) !important;
}

/* Notices: something the admin should act on. */
.notice {
  display: flex; flex-wrap: wrap; gap: 12px 16px; align-items: center; justify-content: space-between;
  padding: 14px 16px; border-radius: var(--r-panel); border: 1px solid;
  font-size: 15px;
}
.notice > .icon { margin-top: 1px; }
.notice-bad { background: var(--bad-tint); border-color: var(--bad-line); color: var(--bad-ink); }
.notice-warn { background: var(--warn-tint); border-color: var(--warn-line); color: var(--warn-ink); }
.notice-plain { background: var(--surface); border-color: var(--border); color: var(--muted); }
.notice .lead { display: flex; gap: 10px; align-items: flex-start; flex: 1 1 320px; }
.notice-list { display: grid; width: 100%; border-top: 1px solid currentColor; border-color: inherit; }
.notice-item { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; justify-content: space-between; padding: 10px 0 0; }
.error-text { color: var(--bad); font-weight: 700; font-size: 15px; }

/* Messages after an action ("Punched in at 10:12"). */
.flash { display: flex; gap: 10px; align-items: center; padding: 12px 16px; border-radius: var(--r-panel); font-weight: 700; font-size: 15px; animation: flash-in .25s ease-out; }
.flash-ok { background: var(--in-tint); color: var(--in-ink); }
.flash-error { background: var(--bad-tint); color: var(--bad-ink); }
.flash-warn { background: var(--warn-tint); color: var(--warn-ink); }
@keyframes flash-in { from { opacity: 0; transform: translateY(-4px); } }

/* Tables: rules and alignment, no stripes. */
.table-box { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 15px; }
table.data th { text-align: left; font-size: 14px; font-weight: 700; color: var(--muted); padding: 4px 12px 10px; white-space: nowrap; }
table.data td { padding: 12px; border-top: 1px solid var(--rule); vertical-align: middle; }
table.data th:first-child, table.data td:first-child { padding-left: var(--pad); }
table.data th:last-child, table.data td:last-child { padding-right: var(--pad); }
table.data tr.is-flagged td { background: var(--flagged-row); }
table.data .num { text-align: right; }
table.data a { font-weight: 700; text-decoration: none; }
table.data a:hover { text-decoration: underline; }
.cell-actions { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: nowrap; }
.sub-note { display: block; font-size: 13px; color: var(--muted); }

/* Empty states: keep the frame, say what happens next. */
.empty { padding: 28px var(--pad); color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

/* Facts: label / value pairs */
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 10px 20px; }
.facts dt { color: var(--muted); font-size: 15px; }
.facts dd { font-weight: 700; }

/* ---- 5. Page-specific pieces --------------------------------------------- */

/* Login and password pages: one centred column. */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; }
.auth-box { width: 100%; max-width: 420px; display: grid; gap: 24px; }
.auth-sign { padding: 22px; }
.auth-sign .brand { color: var(--sign-ink); }
.auth-sign h1 { margin-top: 18px; font-size: 30px; }
@media (max-width: 640px) { .auth-sign h1 { font-size: 28px; } }
.auth-sign p { margin-top: 6px; color: var(--sign-muted); }

/* Member home: the state sign at the top. */
.state-sign { display: grid; gap: 6px; padding: 22px; }
.state-sign .when { color: var(--sign-muted); font-size: 15px; }
.state-sign .big { font-size: 44px; line-height: 1.05; font-weight: 700; letter-spacing: -0.015em; text-wrap: balance; }
.state-sign .big.text { font-size: 32px; line-height: 1.15; }
.state-sign .so-far { font-size: 18px; color: var(--sign-muted); }
.state-sign .so-far b { color: var(--sign-ink); }
.state-sign .status { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.state-sign .status::before { content: ""; width: 9px; height: 9px; border-radius: 50%; background: var(--sign-muted); }
.state-sign .status.on { color: var(--sign-in); }
.state-sign .status.on::before { background: var(--sign-in-dot); }

.punch-panel { padding: 18px; display: grid; gap: 12px; }

.totals-line { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; }
.total-figure { font-size: 15px; color: var(--muted); }
.total-figure b { font-size: 24px; color: var(--ink); }

/* History rows (member) */
.history { display: grid; }
.history-row { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 16px; align-items: center; padding: 14px var(--pad); border-top: 1px solid var(--rule); }
.history-row:first-child { border-top: 0; }
.history-row .day { font-weight: 700; }
.history-row .times { font-size: 15px; color: var(--muted); }
.history-row .hours { font-weight: 700; font-size: 17px; text-align: right; min-width: 3.5em; }

/* Admin: the live "In the room" sign board. */
.room-board { padding: 18px 22px 20px; display: grid; gap: 12px; }
.room-board .board-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.room-board .count { font-size: 15px; color: var(--sign-muted); font-weight: 700; }
.room-board .count b { color: var(--sign-ink); font-size: 22px; }
.room-names { display: flex; flex-wrap: wrap; gap: 10px 28px; }
.room-name { font-size: 20px; font-weight: 700; display: inline-flex; align-items: baseline; gap: 8px; }
.room-name .t { font-size: 16px; font-weight: 400; color: var(--sign-muted); }
.room-empty { color: var(--sign-muted); font-size: 16px; }
/* When someone new appears on the board, their name flips in, like a split-flap sign. */
.arrived { animation: flip-in .6s cubic-bezier(.2, .8, .2, 1); transform-origin: 50% 0; }
@keyframes flip-in { from { transform: rotateX(-80deg); opacity: 0; } }

/* Admin: hours bars (each bar = that person's share of the highest total). */
.bars { display: grid; gap: 12px; padding: 0 var(--pad) var(--pad); }
.bar-row { display: grid; grid-template-columns: minmax(0, 11em) minmax(60px, 1fr) 44px; gap: 10px; align-items: center; font-size: 15px; }
.bar-row .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { height: 8px; border-radius: 4px; background: var(--active); overflow: hidden; }
.bar-fill { height: 100%; border-radius: 4px; background: var(--sign); }
.bar-value { text-align: right; font-weight: 700; }

.poll-status { font-size: 14px; color: var(--muted); }

/* Temporary password hand-over */
.secret {
  font-size: 30px; font-weight: 700; letter-spacing: 0.08em;
  padding: 14px 16px; border-radius: var(--r-control);
  background: var(--raised); border: 1px dashed var(--control);
  user-select: all; overflow-wrap: anywhere;
}

/* ---- 6. The classroom screen ---------------------------------------------
   Sized in vh (percent of the screen height) so it fills any projector or TV.
   Dark by default (a black sign); the "Light" switch suits bright rooms
   where a projector makes black look grey. */
body.display-page { min-height: 100vh; overflow: hidden; background: var(--sign); color: var(--sign-ink); }
body.display-page.light { background: var(--surface); color: var(--ink); }
.display { height: 100vh; display: grid; grid-template-rows: auto 1fr; gap: 3.5vh; padding: 4.5vh 4vw; }
.display-head { display: flex; justify-content: space-between; align-items: center; gap: 2vw; font-size: 2.3vh; }
.display-head .brand { color: inherit; font-size: 2.6vh; }
.display-head .mark { width: 4vh; height: 4vh; font-size: 1.6vh; border-radius: .8vh; background: var(--sign-2); }
.display .light .mark, body.light .display-head .mark { background: var(--sign); }
.display-tools { display: flex; align-items: center; gap: 1.4vw; color: var(--sign-muted); }
body.light .display-tools, body.light .display .muted { color: var(--muted); }
.display-tools button {
  font: 700 1.7vh var(--font); color: inherit; background: transparent;
  border: 1px solid currentColor; border-radius: 6px; padding: .6vh 1vw; cursor: pointer; opacity: .8;
}
.display-body { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 5vw; align-items: start; min-height: 0; }
.code-col { display: grid; gap: 2vh; justify-items: start; }
.display .say { font-size: 2.8vh; color: var(--sign-muted); display: flex; align-items: center; gap: 1vw; }
body.light .display .say { color: var(--muted); }
.display .say .arrow { width: 4vh; height: 4vh; border-radius: .6vh; background: var(--go); color: var(--go-ink); display: grid; place-items: center; }
.display .say .arrow .icon { width: 2.6vh; height: 2.6vh; }
.code-big { font-size: 17vh; line-height: .95; font-weight: 700; letter-spacing: 0.03em; white-space: nowrap; }
.countdown { width: 100%; display: flex; align-items: center; gap: 1.2vw; font-size: 2.2vh; color: var(--sign-muted); }
body.light .countdown { color: var(--muted); }
.countdown-track { flex: 1; height: .8vh; border-radius: 1vh; background: var(--sign-2); overflow: hidden; }
body.light .countdown-track { background: var(--active); }
.countdown-fill { height: 100%; background: currentColor; color: var(--sign-ink); transition: width 1s linear; }
body.light .countdown-fill { color: var(--ink); }
.qr-box { width: 40vh; padding: 2.2vh; background: #fff; /* QR codes scan best on pure white */ border-radius: 1.6vh; margin-top: 1.5vh; }
body.light .qr-box { border: 1px solid var(--border); }
.qr-box svg { display: block; width: 100%; height: auto; }
.room-col h2 { font-size: 3.4vh; font-weight: 700; display: flex; align-items: baseline; gap: 1.2vw; margin-bottom: 2vh; color: inherit; }
.room-col h2 b { font-size: 7vh; line-height: 1; }
.display-people { display: grid; }
.person { display: flex; justify-content: space-between; align-items: baseline; gap: 2vw; font-size: 4vh; padding: 1.5vh 0; border-top: 1px solid var(--sign-2); }
body.light .person { border-color: var(--border); }
.person span:last-child { color: var(--sign-muted); font-size: 3.6vh; }
body.light .person span:last-child { color: var(--muted); }
.display-closed { height: 100%; display: grid; place-content: center; text-align: center; gap: 2vh; }
.display-closed h1 { font-size: 7vh; }
.display-closed p { font-size: 3vh; color: var(--sign-muted); }
@media (max-width: 1000px), (max-aspect-ratio: 1/1) {
  body.display-page { overflow: auto; }
  .display { height: auto; min-height: 100vh; padding: 24px 16px; gap: 24px; }
  .display-head { flex-wrap: wrap; font-size: 15px; }
  .display-head .brand { font-size: 16px; }
  .display-head .mark { width: 28px; height: 28px; font-size: 12px; }
  .display-tools { flex-wrap: wrap; gap: 8px; }
  .display-tools button { font-size: 13px; padding: 6px 10px; }
  .display-body { grid-template-columns: minmax(0, 1fr); gap: 32px; }
  .code-big { font-size: min(18vw, 140px); }
  .code-col { min-width: 0; }
  .display .say { font-size: 17px; }
  .countdown { font-size: 14px; }
  .qr-box { width: min(70vw, 320px); padding: 14px; }
  .room-col h2 { font-size: 20px; } .room-col h2 b { font-size: 40px; }
  .person { font-size: 20px; padding: 12px 0; }
  .person span:last-child { font-size: 18px; }
}
.offline { position: fixed; left: 50%; bottom: 3vh; transform: translateX(-50%); background: var(--bad); color: #fff; padding: 1vh 2vw; border-radius: 1vh; font-size: 2.2vh; font-weight: 700; }

/* ---- 7. Phone and tablet ----------------------------------------------- */

/* Below 1024px wide the admin sidebar becomes the top bar + bottom bar. */
@media (max-width: 1023px) {
  .sidebar { display: none; }
  body.with-sidebar .topbar { display: flex; }
  body.with-sidebar .page,
  body.with-sidebar .page.narrow,
  body.with-sidebar .page.medium { margin-left: auto; margin-right: auto; padding-left: 24px; padding-right: 24px; }
  body.with-sidebar .page.narrow { max-width: 480px; }
  body.with-sidebar .page.medium { max-width: 760px; }
.page.member-home { max-width: 480px; }
@media (min-width: 1024px) {
  .page.member-home { max-width: 1040px; }
  .home-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: start; }
}
.home-grid { display: grid; gap: 24px; }
  body.with-sidebar { padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom)); }
  .tabbar {
    position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
    display: grid; grid-template-columns: repeat(5, 1fr);
    height: calc(var(--tabbar) + env(safe-area-inset-bottom));
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--sign);
  }
  .tabbar a {
    display: grid; place-items: center; align-content: center; gap: 3px;
    color: var(--sign-muted); text-decoration: none; font-size: 12px; font-weight: 700;
  }
  .tabbar a[aria-current="page"] { color: var(--sign-ink); background: var(--sign-2); }
  .grid-main { grid-template-columns: minmax(0, 1fr); }
}

@media (min-width: 1024px) {
  /* Members on a laptop: the top bar stays, the menu becomes a small dropdown. */
  .menu { position: relative; }
  .menu-sheet { position: absolute; top: calc(100% + 8px); left: auto; right: 0; bottom: auto; width: 320px; padding: 12px; border: 1px solid var(--border); border-radius: var(--r-panel); background: var(--surface); box-shadow: 0 12px 32px rgba(17, 20, 22, .14); } /* taste-skill-ignore: a real dropdown floats above the page */
}

@media (max-width: 640px) {
  .page { padding: 20px 16px 40px; gap: 20px; }
  body.with-sidebar .page, body.with-sidebar .page.narrow, body.with-sidebar .page.medium { padding-left: 16px; padding-right: 16px; }
  h1 { font-size: 24px; }
  .brand-name { font-size: 15px; }
  .title-row .actions { width: 100%; flex-direction: column-reverse; }
  .title-row .actions > *, .title-row .actions .btn { width: 100%; }

  /* Tables turn into two-line lists: the main cell and the end cell on line 1,
     the rest (each with its label) on line 2. Nothing is dropped. */
  table.data thead { display: none; }
  table.data, table.data tbody, table.data tr, table.data td { display: block; }
  table.data tr { display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 12px; padding: 12px 16px; border-top: 1px solid var(--rule); }
  table.data tr:first-child { border-top: 0; }
  table.data td { padding: 0 !important; border: 0; font-size: 14px; color: var(--muted); }
  table.data td.cell-main { flex: 1 1 auto; font-size: 16px; color: var(--ink); font-weight: 700; order: 0; }
  /* An invisible full-width item after the end cell forces the rest onto line 2. */
  table.data tr::after { content: ""; order: 1; flex-basis: 100%; height: 0; }
  table.data td.cell-end { order: 1; font-size: 16px; color: var(--ink); font-weight: 700; }
  table.data td.cell-actions-td { order: 3; width: 100%; padding-top: 8px !important; }
  table.data td:not(.cell-main):not(.cell-end):not(.cell-actions-td) { order: 2; }
  table.data td[data-label]:not(.cell-main):not(.cell-end)::before { content: attr(data-label) " "; color: var(--faint); }
  .cell-actions { justify-content: flex-start; }
  /* On a phone a list of records would become a stack of buttons. Each row keeps
     one small text action (Edit); deleting is done from the Edit page. */
  .cell-actions .btn-danger { display: none; }
  .cell-actions .btn { min-height: 32px; padding: 0; border: 0; background: none; color: var(--ink); text-decoration: underline; text-underline-offset: 3px; font-size: 14px; }
  table.data td.cell-actions-td { order: 2; width: auto; padding-top: 0 !important; margin-left: auto; }
  /* Filters: two selects side by side, one row of controls. */
  .filters { grid-template-columns: 1fr 1fr; }
  .filters .row { grid-column: 1 / -1; }
  .bar-row { grid-template-columns: minmax(0, 1fr) 30% 44px; }
  .state-sign .big { font-size: 40px; }
  .facts { grid-template-columns: 1fr; gap: 2px; }
  .facts dd { margin-bottom: 10px; }
}

/* People who ask for less motion get none. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* The brand mark sitting on a black sign needs its own tone to show. */
.sign .mark { background: var(--sign-2); }

/* Fingers, not mouse pointers: every tappable thing at least 44px tall on touch screens. */
@media (pointer: coarse) {
  .btn-small { min-height: 44px; }
  .topbar .brand { min-height: 44px; }
  table.data td.cell-main a { display: inline-block; padding: 11px 0; margin: -11px 0; }
  .cell-actions .btn { min-height: 44px; }
}

/* Hover feedback only on devices with a real pointer. On touch screens a
   tapped button would otherwise stay in its hover colour. */
@media (hover: hover) {
  .side-nav a:not([aria-current]):hover { background: var(--active); color: var(--ink); }
  .link-button:hover { color: var(--ink); text-decoration: underline; }
  .btn:hover { background: var(--raised); border-color: var(--control-hover); }
  .btn-go:hover { background: var(--go-press); border-color: var(--go-press); }
  .btn-dark:hover { background: var(--sign-2); border-color: var(--sign-2); }
  .btn-danger:hover { background: var(--bad-tint); border-color: var(--bad); }
  .btn-danger.solid:hover { background: var(--bad-press); }
  .btn-quiet:hover { background: var(--active); color: var(--ink); }
  input:hover, select:hover, textarea:hover { border-color: var(--input-hover); }
  .menu-list a:hover { background: var(--raised); }
}

/* A folded section (Members > Hand over the admin role) shows that it opens. */
.fold > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; cursor: pointer; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary .icon { transition: transform .15s ease-out; color: var(--muted); }
.fold[open] > summary .icon { transform: rotate(90deg); }
.fold > summary .hint { display: block; font-weight: 400; }

/* Classroom screen: a plain sign arrow pointing up at the QR code. */
.display .say .pointer { width: 4vh; height: 4vh; border-radius: .6vh; display: grid; place-items: center; background: var(--sign-2); color: var(--sign-ink); }
body.light .display .say .pointer { background: var(--sign); }
.display .say .pointer .icon { width: 2.6vh; height: 2.6vh; transform: rotate(-90deg); }

/* Phones draw their own grey flash over anything tapped. We turn it off and
   give every tappable thing our own press feedback instead. */
a, button, summary, label { -webkit-tap-highlight-color: transparent; }
.menu-list a:active, .nav-row:active { background: var(--raised); }
.tabbar a:active { background: var(--sign-2); }
.side-nav a:active { background: var(--active); }

/* ---- v2.1 additions -------------------------------------------------------- */

/* Time boxes typed by hand ("9:15", "2:30 pm"): narrow, since a time is short. */
.time-input { max-width: 180px; }
.times-table .time-input { width: 100%; min-width: 96px; }
.time-pair { display: block; }
.time-pair + .time-pair { margin-top: 4px; }
.time-pair a { margin-left: 8px; }

/* A quiet text button in the bad colour, for "Delete" next to everyday actions. */
.btn-quiet.danger-text { color: var(--bad); }

/* Records: tick boxes, "Select all" and "Delete selected". */
.bulk-tools { display: flex; align-items: center; gap: 16px; }
.pick-all { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 700; color: var(--muted); cursor: pointer; }
.pick-all input, .cell-pick input { width: 20px; height: 20px; margin: 0; accent-color: var(--sign); cursor: pointer; }
table.data .cell-pick { width: 1%; padding-right: 0; }

/* Classroom screen: the start button when no session is open, and short messages. */
.display-closed form { justify-self: center; margin-top: 2vh; }
.display-closed .btn { font-size: 2.4vh; min-height: 7vh; padding: 0 3vh; }
.offline a { color: inherit; text-decoration: underline; }
.display-flash {
  position: fixed; left: 50%; bottom: 3vh; transform: translateX(-50%);   /* bottom: never covers the code or the date */
  background: var(--sign-2); color: var(--sign-ink); padding: 1vh 2vw; border-radius: 1vh;
  font-size: 2.2vh; font-weight: 700;
  animation: flash-away 6s forwards;   /* the message fades after a few seconds */
}
@keyframes flash-away { 0%, 80% { opacity: 1; } 100% { opacity: 0; visibility: hidden; } }

@media (max-width: 640px) {
  /* Phone lists: the tick box leads the row, before the name. (The :not()s
     match the general "line 2" rule above, so this one wins over it.) */
  table.data td.cell-pick:not(.cell-main):not(.cell-end):not(.cell-actions-td) { order: -1; flex: none; width: auto; align-self: center; margin-right: 2px; }
  /* A flagged row is tinted as a whole, not cell by cell (cells are inline here). */
  table.data tr.is-flagged { background: var(--flagged-row); }
  table.data tr.is-flagged td { background: none; }
  .cell-actions .btn.danger-text { color: var(--bad); }
  .panel-head { flex-wrap: wrap; }
  .times-table .time-input { width: 120px; min-height: 44px; }
}
@media (pointer: coarse) {
  .pick-all input, .cell-pick input { width: 24px; height: 24px; }
}

/* ---- v2.2: anti-cheating checks ---- */
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: .95em; }
.flag-list { display: inline-flex; flex-wrap: wrap; gap: 4px 8px; }
.flag-warn { color: var(--warn-ink); }
