:root {
  color-scheme: light;
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  /* Brand: #2cb7b0 for fills, its darker tone for text. Teal marks what is current or selected at rest;
     orange answers the pointer: hover, press, keyboard focus and a calendar range being painted. */
  --brand: #2cb7b0;
  --brand-ink: #127a75;
  --brand-soft: #e8f7f6;
  --on-brand: #052f2c;
  --active: #ff9100;
  --active-soft: #fff3e3;
  --active-ink: #9a4f00;
  --danger: #a12d38;
  --danger-soft: #fff3f4;
  --danger-border: #f0d3d6;
  --warn-border: #ffd7a6;
  --warn-bg: #fffaf3;
  --held: #c9eeeb;
  --held-ink: #0d5f5a;
  --sel: #ffe3bf;
  --ink: #12302e;
  --muted: #5d7371;
  --border: #e2eaea;
  --line: #eef3f3;
  --paper: #fff;
  --page: #f5f8f8;
  --raised: #fff;
  --backdrop: #12302e99;
  --shadow: #0f2e2c2e;
  --radius: 16px;
  color: var(--ink);
  background: var(--page);
}
/* Dark theme: deep navy surfaces, the same teal and orange accents. */
:root[data-theme="dark"] {
  color-scheme: dark;
  --brand-ink: #5ed6cf;
  --brand-soft: #10333f;
  --active: #ff9f2e;
  --active-soft: #33271a;
  --active-ink: #ffb866;
  --danger: #ff8a94;
  --danger-soft: #3a1b27;
  --danger-border: #5c2a39;
  --warn-border: #5a4322;
  --warn-bg: #1f1d22;
  --held: #1b5560;
  --held-ink: #d4f5f2;
  --sel: #4f3617;
  --ink: #e6edf8;
  --muted: #92a2c0;
  --border: #20335a;
  --line: #172848;
  --paper: #101d36;
  --page: #0b1528;
  --raised: #142443;
  --backdrop: #020811cc;
  --shadow: #00000080;
}

* { box-sizing: border-box; }
/* No rubber-band bounce or pull-to-refresh past the page edges; the page stays put under an open dialog. */
html { overscroll-behavior: none; }
html:has(dialog[open]) { overflow: hidden; }
body { --tabbar: 0px; margin: 0; min-width: 280px; background: var(--page); -webkit-tap-highlight-color: transparent; }
button, input, select { font: inherit; }
button { color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .55; }
:focus-visible { outline: 2px solid var(--active); outline-offset: 2px; }
h1, h2, h3, p { margin: 0; }
h1, h2 { letter-spacing: -.025em; }
p { line-height: 1.5; }
:root[data-theme="dark"] .when-light, :root:not([data-theme="dark"]) .when-dark { display: none; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

.icon { display: inline-grid; place-items: center; width: 20px; height: 20px; flex: 0 0 auto; }
.icon svg { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.shell { min-height: 100dvh; display: grid; grid-template-columns: 236px minmax(0, 1fr); }
.sidebar {
  background: var(--paper);
  color: var(--ink);
  border-right: 1px solid var(--border);
  height: 100dvh;
  position: sticky;
  top: 0;
  display: flex;
  flex-direction: column;
  padding: 28px 16px 20px;
  overflow: auto;
}
.brand { display: flex; align-items: center; gap: 11px; padding: 0 8px; min-width: 0; }
/* A small whale: body and tail in white on the brand colour. */
.brand-mark {
  display: inline-grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--brand);
}
.brand-mark::before {
  content: "";
  width: 20px;
  height: 12px;
  margin: 4px 0 0 -3px;
  background: #fff;
  border-radius: 60% 60% 45% 45% / 75% 75% 35% 35%;
}
.brand-mark::after {
  content: "";
  position: absolute;
  right: 7px;
  top: 12px;
  width: 8px;
  height: 8px;
  border: 2px solid #fff;
  border-left: 0;
  border-bottom: 0;
  border-radius: 0 70% 0 0;
  transform: rotate(-15deg);
}
.brand strong, .brand small, .profile strong, .profile small { display: block; overflow-wrap: anywhere; }
.brand strong { font-size: 15px; letter-spacing: -.01em; }
.brand small, .profile small { color: var(--muted); margin-top: 2px; font-size: 12px; }
.nav { display: grid; gap: 2px; margin-top: 34px; }
.nav-group { color: var(--muted); padding: 0 12px; margin: 22px 0 6px; font-size: 11px; font-weight: 650; text-transform: uppercase; letter-spacing: .06em; }
.nav-button {
  border: 0;
  background: transparent;
  display: flex;
  align-items: center;
  text-align: left;
  gap: 10px;
  color: var(--ink);
  padding: 10px 12px;
  min-height: 42px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  position: relative;
}
.nav-button .icon { color: var(--muted); }
.nav-button[aria-current="page"] { background: var(--brand-soft); color: var(--ink); }
.nav-button[aria-current="page"] .icon { color: var(--brand-ink); }
.nav-button[aria-current="page"]::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 3px;
  background: var(--brand);
}
.profile {
  margin-top: auto;
  border: 0;
  border-top: 1px solid var(--border);
  background: transparent;
  color: var(--ink);
  padding: 16px 8px 2px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  text-align: left;
  width: 100%;
}
.profile > div { min-width: 0; flex: 1; }
.profile .swap { color: var(--muted); width: 18px; height: 18px; }
button.profile { border-radius: 0; }
.role-tag { display: none; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.avatar { position: relative; overflow: hidden; display: grid; place-items: center; flex: 0 0 auto; width: 36px; height: 36px; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); font-size: 12px; font-weight: 750; }

.workspace { width: min(100%, 1120px); margin-inline: auto; padding: 30px clamp(24px, 4vw, 52px) 48px; }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 26px; }
.location { font-size: 13px; font-weight: 600; color: var(--muted); }
.toolbar-actions, .actions, .segments { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.date-chip { padding: 8px 12px; font-size: 13px; line-height: 18px; color: var(--ink); background: var(--paper); border: 1px solid var(--border); border-radius: 999px; font-weight: 600; }
.heading { display: flex; justify-content: space-between; align-items: end; gap: 14px; margin-bottom: 22px; }
.heading h1 { font-size: clamp(28px, 3.6vw, 40px); line-height: 1.1; font-weight: 750; }
.heading p { color: var(--muted); margin-top: 6px; font-size: 15px; }
.surface { background: var(--paper); border: 1px solid var(--border); border-radius: var(--radius); }
.summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 0 0 14px; }
.summary > div { padding: 14px 20px; }
.summary > div + div { border-left: 1px solid var(--line); }
.summary dt { color: var(--muted); font-size: 13px; font-weight: 600; }
.summary dd { margin: 4px 0 0; color: var(--muted); font-size: 14px; }
.summary strong { color: var(--ink); font-size: 28px; letter-spacing: -.03em; font-variant-numeric: tabular-nums; }
.row-icon { display: grid; place-items: center; width: 36px; height: 36px; flex: 0 0 auto; border-radius: 50%; background: var(--brand-soft); color: var(--brand-ink); }
.row-icon .icon { width: 18px; height: 18px; }
.row-icon.wait { color: var(--muted); background: transparent; box-shadow: inset 0 0 0 1.5px var(--border); }
.panel-top { padding: 18px 20px 14px; display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 12px; }
.panel-top h2, .settings-card h2 { font-size: 19px; }
.panel-top p, .settings-card header p { color: var(--muted); margin-top: 4px; font-size: 13px; }
.segments { gap: 2px; padding: 3px; border-radius: 999px; background: var(--line); width: fit-content; max-width: 100%; }
.segment { min-height: 34px; border-radius: 999px; border: 0; padding: 5px 13px; background: transparent; color: var(--muted); font-weight: 600; font-size: 13px; }
.segment[aria-pressed="true"] { background: var(--brand); color: var(--on-brand); }
.list { margin: 0; padding: 0; list-style: none; }
.list-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 12px; min-height: 66px; padding: 10px 20px; border-top: 1px solid var(--line); }
.identity { display: flex; align-items: center; min-width: 0; gap: 11px; }
.identity strong, .identity small { display: block; overflow-wrap: anywhere; }
.identity strong { font-size: 14px; }
.identity small { margin-top: 3px; color: var(--muted); font-size: 12px; }
/* A class or a person in a list: name, a note and what is on the right. */
.answer { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 62px; padding: 10px 20px; border: 0; border-top: 1px solid var(--line); background: transparent; text-align: left; }
.answer-name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.answer-name strong, .answer-name small { display: block; }
.answer-name strong { font-size: 14px; }
.answer-name small { margin-top: 3px; color: var(--muted); font-size: 12px; }
.answer-count { font-size: 14px; white-space: nowrap; font-variant-numeric: tabular-nums; }
.answer .chevron { width: 16px; height: 16px; color: var(--muted); }
.add-row { color: var(--brand-ink); font-size: 14px; font-weight: 650; }
.plain-list { max-width: 640px; overflow: hidden; }
.plain-list li:first-child .answer { border-top: 0; }
.list-title { margin: 22px 0 8px; font-size: 13px; font-weight: 650; letter-spacing: 0; color: var(--muted); }
.archive-toggle { margin: 10px 0; color: var(--muted); }
/* No answer yet: an open, dashed chip with an hourglass that keeps turning over. */
.waiting { display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto; padding: 4px 11px 4px 7px; border: 1px dashed var(--muted); border-radius: 999px; color: var(--muted); font-size: 12px; font-weight: 650; white-space: nowrap; }
.hourglass { display: inline-block; font-size: 14px; line-height: 1; }
.meal { display: inline-flex; align-items: center; gap: 4px; }
.meal .icon { width: 14px; height: 14px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 40px; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--border); background: var(--paper); color: var(--brand-ink); font-size: 13px; font-weight: 650; text-align: center; }
.button .icon { width: 16px; height: 16px; }
.button.primary { background: var(--brand); color: var(--on-brand); border-color: var(--brand); }
.button.danger { color: var(--danger); border-color: var(--danger-border); }
.button.icon-button { min-width: 40px; padding-inline: 8px; color: var(--muted); }
.button.icon-button .icon { width: 18px; height: 18px; }
.button.compact { min-height: 36px; }
.button.ghost { border-color: transparent; background: transparent; }
.empty { padding: 28px 20px; color: var(--muted); border-top: 1px solid var(--line); }
.empty strong { display: block; color: var(--ink); margin-bottom: 4px; }

select, textarea, input:not([type="checkbox"], [type="radio"]) {
  display: block;
  width: 100%;
  padding: 10px 12px;
  min-height: 43px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--paper);
  color: var(--ink);
  font-size: 16px;
}
select:focus, textarea:focus, input:not([type="checkbox"], [type="radio"]):focus { border-color: var(--active); outline: none; }
::placeholder { color: var(--muted); opacity: .8; }
input:is([type="checkbox"], [type="radio"]) { accent-color: var(--brand); width: 18px; height: 18px; margin: 0; flex: 0 0 auto; }
label, legend { font-size: 13px; font-weight: 650; }
.field { display: grid; gap: 7px; min-width: 0; }
.field small, .hint { color: var(--muted); font-size: 13px; font-weight: 400; }
fieldset { border: 0; margin: 0; padding: 0; min-width: 0; }
legend { padding: 0; margin: 0 0 10px; }
.settings-grid { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.settings-side { display: grid; gap: 16px; min-width: 0; }
.settings-card { display: grid; gap: 20px; padding: 22px; min-width: 0; }
.settings-card form, .editor-form { display: grid; gap: 17px; }
.settings-card .actions { margin-top: 4px; }
.time-fields { display: grid; grid-template-columns: repeat(auto-fit, minmax(136px, 1fr)); gap: 9px; }
.dialog-title { font-size: 23px; }
dialog { width: min(480px, calc(100% - 24px)); max-height: calc(100dvh - 30px); overflow: auto; overscroll-behavior: contain; color: var(--ink); border: 1px solid var(--border); background: var(--raised); padding: 22px; border-radius: 20px; box-shadow: 0 24px 70px var(--shadow); }
dialog::backdrop { background: var(--backdrop); }
.dialog-head { display: flex; justify-content: space-between; align-items: start; gap: 12px; margin-bottom: 16px; }
.dialog-head p { margin-top: 4px; }
.editor-form .actions { justify-content: flex-end; }
.editor-form .actions .danger { margin-right: auto; }
.confirm-copy { margin-bottom: 16px; }
.add-ways { display: grid; gap: 10px; }
.add-ways .actions + .hint { margin-top: 8px; }
.attendance-total { font-weight: 650; }
.pupil-list { display: grid; gap: 6px; max-height: min(45dvh, 360px); overflow: auto; padding: 3px; }
.pupil-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 10px; align-items: center; }
.pupil-row label { display: flex; align-items: center; gap: 5px; font-weight: 600; }
textarea { resize: vertical; font: inherit; }
.checklist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; max-height: 220px; overflow: auto; padding: 3px; }
.checklist label { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 10px; min-height: 42px; border: 1px solid var(--border); border-radius: 10px; overflow-wrap: anywhere; font-weight: 600; }
.checklist label:has(input:checked) { border-color: var(--brand); background: var(--brand-soft); }
.invite-code { user-select: all; word-break: break-word; display: block; margin-block: 14px; padding: 14px; background: var(--brand-soft); border-radius: 10px; font-size: 16px; }
.readiness { max-width: 640px; margin-bottom: 14px; }
.readiness.has-problems { border-color: var(--warn-border); background: var(--warn-bg); }
.alerts { margin: 0; padding: 14px 20px 14px 40px; display: grid; gap: 7px; color: var(--active-ink); font-size: 14px; line-height: 1.45; }
.warn-text { color: var(--active-ink); font-weight: 650; }
.checklist.single { grid-template-columns: 1fr; }
fieldset .hint { margin-bottom: 9px; }
fieldset > .button { margin-top: 10px; }
.error { color: var(--danger); font-weight: 650; font-size: 13px; }
.toast { position: fixed; right: 22px; bottom: calc(22px + var(--tabbar)); z-index: 5; background: var(--ink); color: var(--page); box-shadow: 0 8px 28px var(--shadow); border-radius: 12px; padding: 12px 16px; max-width: min(400px, calc(100% - 28px)); font-size: 14px; white-space: pre-line; }
.toast.problem { background: var(--danger); color: #fff; }
.launch { width: min(440px, calc(100% - 32px)); display: grid; gap: 12px; margin: 14vh auto 0; padding: 26px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--paper); color: var(--ink); }
.launch p { color: var(--muted); }
.launch .button { justify-self: start; }

/* Profile switcher. */
.role-list { display: grid; gap: 8px; }
.role-option { display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--paper); color: var(--ink); text-align: left; }
.role-option[aria-pressed="true"] { border-color: var(--brand); background: var(--brand-soft); }
.role-option > span:nth-child(2) { flex: 1; min-width: 0; }
.role-option strong, .role-option small { display: block; }
.role-option small { color: var(--muted); font-size: 13px; margin-top: 2px; }
.role-option .check { color: var(--brand-ink); visibility: hidden; }
.role-option[aria-pressed="true"] .check { visibility: visible; }
.role-option[aria-pressed="true"] .row-icon { background: var(--paper); }

/* Attendance: plain rows. Tap a pupil, drag down the circles or swipe a row. */
.roster-tools { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 8px; }
.roster-tools .hint { margin: 0; }
.roster { max-height: min(52dvh, 440px); overflow: auto; overscroll-behavior: contain; }
.pupil {
  display: flex;
  align-items: center;
  min-height: 48px;
  padding-right: 16px;
  border-bottom: 1px solid var(--line);
  font-size: 16px;
  font-weight: 400;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: pan-y;
  cursor: pointer;
}
/* The circle column is the drag handle: a finger moving down it marks instead of scrolling. */
.pupil-grip { display: grid; place-items: center; align-self: stretch; width: 56px; flex: 0 0 auto; touch-action: none; }
.pupil-mark { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--brand); background: var(--brand); color: var(--on-brand); }
.pupil-mark .icon { width: 14px; height: 14px; }
.pupil-mark .icon svg { stroke-width: 3.5; }
.pupil-name { flex: 1; min-width: 0; padding-block: 8px; overflow-wrap: anywhere; }
.pupil .meal { color: var(--muted); margin-left: 8px; }
.pupil-state { visibility: hidden; margin-left: 10px; font-size: 14px; color: var(--active-ink); }
.pupil:has(input:not(:checked)) .pupil-mark { background: transparent; border-color: var(--border); }
.pupil:has(input:not(:checked)) .pupil-mark .icon { visibility: hidden; }
.pupil:has(input:not(:checked)) .pupil-name { color: var(--muted); }
.pupil:has(input:not(:checked)) .pupil-state { visibility: visible; }
.pupil:has(input:focus-visible) { outline: 2px solid var(--active); outline-offset: -2px; }
.pupil.swiping { background: var(--line); }

/* Teacher screen: the class, its pupils and one button. */
body.teaching { background: var(--paper); }
.teacher { max-width: 560px; margin-inline: auto; min-height: 100dvh; display: flex; flex-direction: column; }
.teacher fieldset { flex: 1; }
.teacher .roster { max-height: none; overflow: visible; }
.teacher > .empty { border: 0; flex: 1; }
.teacher-top { position: sticky; top: 0; z-index: 2; background: var(--paper); border-bottom: 1px solid var(--border); }
.teacher-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 10px; }
.teacher-head h1:focus { outline: none; }
.teacher-head h1 { font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.teacher-head p { color: var(--muted); font-size: 14px; }
.class-tabs { display: flex; gap: 20px; overflow-x: auto; padding: 0 16px; scrollbar-width: none; }
.class-tabs button { display: flex; align-items: center; gap: 4px; flex: 0 0 auto; min-height: 40px; padding: 0; border: 0; border-bottom: 2px solid transparent; background: none; color: var(--muted); font-size: 15px; }
.class-tabs button[aria-current] { color: var(--ink); border-bottom-color: var(--brand); font-weight: 600; }
.class-tabs .icon { width: 14px; height: 14px; color: var(--brand-ink); }
.teacher-bar { position: sticky; bottom: 0; display: grid; gap: 10px; padding: 8px 16px calc(12px + env(safe-area-inset-bottom)); background: var(--paper); border-top: 1px solid var(--border); }
.stepper { display: flex; align-items: center; gap: 4px; font-size: 15px; }
.stepper > span { flex: 1; }
.stepper button { width: 44px; height: 44px; border: 1px solid var(--border); border-radius: 10px; background: none; font-size: 22px; touch-action: manipulation; }
.stepper output { min-width: 36px; text-align: center; font-size: 18px; font-variant-numeric: tabular-nums; }
.teacher-bar .button { min-height: 50px; border-radius: 12px; font-size: 16px; }
body.teaching .toast { bottom: calc(130px + env(safe-area-inset-bottom)); }

/* Days-off calendar. */
.calendar { padding: 18px 18px 16px; }
.cal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.cal-head h2 { font-size: 19px; flex: 1; text-align: center; }
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.cal-week { margin-bottom: 4px; }
.cal-week span { text-align: center; font-size: 12px; font-weight: 650; color: var(--muted); padding: 4px 0; }
.cal-week span.off { opacity: .6; }
.cal-grid { row-gap: 4px; touch-action: none; user-select: none; -webkit-user-select: none; }
.day {
  position: relative;
  border: 0;
  background: transparent;
  height: 44px;
  padding: 0;
  font-size: 15px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  display: grid;
  place-items: center;
}
.day > span { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; position: relative; z-index: 1; }
.day.off { color: var(--muted); font-weight: 500; }
.day:disabled { opacity: .35; }
.day.today > span { box-shadow: inset 0 0 0 2px var(--ink); }
/* Painted periods are a continuous band across the week row. */
.day.held::before, .day.sel::before { content: ""; position: absolute; inset: 3px 0; background: var(--held); }
.day.held.first::before, .day.sel.first::before { left: 3px; border-radius: 19px 0 0 19px; }
.day.held.last::before, .day.sel.last::before { right: 3px; border-radius: 0 19px 19px 0; }
.day.held.first.last::before, .day.sel.first.last::before { border-radius: 19px; }
.day.held { color: var(--held-ink); }
.day.held.focus::before { background: var(--brand); }
.day.held.focus { color: var(--on-brand); }
.day.sel::before { background: var(--sel); }
.day.sel { color: var(--active-ink); }
.day.sel.edge > span { background: var(--active); color: #1f1300; }
.cal-legend { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 14px; font-size: 12px; color: var(--muted); }
.cal-legend span { display: inline-flex; align-items: center; gap: 6px; }
.cal-legend i { width: 14px; height: 14px; border-radius: 50%; background: var(--held); }
.cal-legend i.sel { background: var(--active); }
.cal-legend i.today { background: transparent; box-shadow: inset 0 0 0 2px var(--ink); }
.cal-panel { padding: 20px; display: grid; gap: 14px; scroll-margin-bottom: calc(var(--tabbar) + 12px); }
.cal-panel h2 { font-size: 19px; }
.cal-panel p { color: var(--muted); font-size: 14px; }
.cal-panel form { display: grid; gap: 14px; }
.cal-steps { margin: 0; padding-left: 20px; display: grid; gap: 6px; color: var(--muted); font-size: 14px; line-height: 1.45; }
.break-row { cursor: pointer; }
.break-row.focus { background: var(--brand-soft); }

@media (max-width: 980px) {
  .shell { grid-template-columns: 200px minmax(0, 1fr); }
  .sidebar { padding-inline: 12px; }
  .workspace { padding-inline: 24px; }
  .settings-grid { grid-template-columns: 1fr; }
}
/* Phones: compact header with the profile, and a tab bar at the bottom within thumb reach. */
@media (max-width: 720px) {
  .shell { display: block; }
  body.has-tabs { --tabbar: calc(62px + env(safe-area-inset-bottom)); }
  .sidebar { height: auto; flex-direction: row; align-items: center; gap: 10px; padding: 10px 14px; top: 0; z-index: 3; border-right: 0; border-bottom: 1px solid var(--border); overflow: visible; }
  .brand { padding: 0; flex: 1; }
  .brand-mark { width: 32px; height: 32px; }
  .brand-mark::before { width: 17px; height: 10px; }
  .brand-mark::after { right: 5px; top: 10px; width: 7px; height: 7px; }
  .brand strong { font-size: 14px; }
  .brand small { font-size: 11px; }
  .nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 4;
    display: flex;
    margin: 0;
    gap: 0;
    padding: 4px 6px env(safe-area-inset-bottom);
    background: var(--paper);
    border-top: 1px solid var(--border);
  }
  .nav-group { display: none; }
  .nav-button { flex: 1 1 0; flex-direction: column; justify-content: center; text-align: center; min-height: 56px; padding: 4px 2px; gap: 3px; font-size: 11px; border-radius: 12px; }
  .nav-button[aria-current="page"] { background: transparent; color: var(--brand-ink); }
  .nav-button[aria-current="page"]::before { left: 30%; right: 30%; top: 0; bottom: auto; width: auto; height: 3px; }
  .nav-button .icon { width: 22px; height: 22px; }
  .profile { margin: 0; width: auto; flex: 0 0 auto; border: 1px solid var(--border); border-radius: 999px; padding: 3px 10px 3px 3px; gap: 7px; }
  button.profile { border-radius: 999px; }
  .profile .avatar { width: 30px; height: 30px; font-size: 11px; }
  .profile > div { flex: 0 1 auto; }
  .profile strong, .profile small { display: none; }
  .profile .role-tag { display: block; font-size: 12px; font-weight: 650; white-space: nowrap; }
  .profile .swap { width: 15px; height: 15px; }
  div.profile { padding-right: 3px; }
  div.profile .role-tag { display: none; }
  .workspace { padding: 15px 14px calc(32px + var(--tabbar)); }
  .location { display: none; }
  .toolbar { margin-bottom: 14px; justify-content: flex-end; }
  .heading { margin-bottom: 16px; align-items: start; }
  .heading p { font-size: 13px; }
  .panel-top, .list-row, .answer, .summary > div { padding-inline: 13px; }
  .list-row { gap: 8px; min-height: 62px; }
  .time-fields { grid-template-columns: 1fr; }
  .time-fields .field { grid-template-columns: minmax(0, 1fr) minmax(136px, 1fr); align-items: center; }
  .toast { left: 14px; right: 14px; bottom: calc(14px + max(var(--tabbar), env(safe-area-inset-bottom))); max-width: none; }
  /* Dialogs become bottom sheets. */
  dialog { width: 100%; max-width: 100%; margin: auto 0 0; border-radius: 22px 22px 0 0; max-height: 92dvh; padding: 18px 16px calc(18px + env(safe-area-inset-bottom)); border-bottom: 0; }
  .calendar { padding: 14px 10px 14px; }
  .day { height: 46px; }
  .day > span { width: 40px; height: 40px; }
}
@media (max-width: 380px) {
  .settings-card { padding: 15px; }
  .brand small { display: none; }
  .day > span { width: 34px; height: 34px; }
}
/* Interaction: orange while the pointer is over a control or a finger presses it. Hover is limited to real
   pointers, so on a phone a tapped tab or filter does not stay orange: it settles into its teal "current" state. */
@media (hover: hover) {
  .nav-button:hover, button.answer:hover, .break-row:hover { background: var(--active-soft); }
  .nav-button:hover { color: var(--active-ink); }
  .nav-button:hover .icon, button.answer:hover .chevron { color: var(--active); }
  .nav-button[aria-current="page"]:hover::before { background: var(--active); }
  .segment:hover, .class-tabs button:hover, .add-row:hover, button.profile:hover strong { color: var(--active-ink); }
  .segment[aria-pressed="true"]:hover, .button.primary:not(:disabled):hover { background: var(--active); border-color: var(--active); color: #1f1300; }
  .button:not(.primary, .danger, :disabled):hover { background: var(--active-soft); border-color: var(--warn-border); color: var(--active-ink); }
  .button.ghost:not(:disabled):hover { border-color: transparent; }
  .button.danger:not(:disabled):hover { background: var(--danger-soft); }
  .role-option:hover, .checklist label:hover, .stepper button:hover { border-color: var(--active); }
  .day:not(:disabled):hover > span { background: var(--active-soft); color: var(--active-ink); }
  .day.held:not(:disabled):hover > span, .day.sel:not(:disabled):hover > span { background: transparent; color: inherit; }
  .day.sel.edge:not(:disabled):hover > span { background: var(--active); color: #1f1300; }
}
.nav-button:active, button.answer:active, .break-row:active { background: var(--active-soft); }
.nav-button:active .icon { color: var(--active); }
.segment:active, .class-tabs button:active, .add-row:active { color: var(--active-ink); }
.segment[aria-pressed="true"]:active, .button.primary:not(:disabled):active { background: var(--active); border-color: var(--active); color: #1f1300; }
.button:not(.primary, .danger, :disabled):active { background: var(--active-soft); border-color: var(--warn-border); color: var(--active-ink); }
.button.ghost:not(:disabled):active { border-color: transparent; }
.button.danger:not(:disabled):active { background: var(--danger-soft); }
.role-option:active, .checklist label:active, .stepper button:active { border-color: var(--active); }

@media (prefers-reduced-motion: no-preference) {
  .button, .nav-button, .nav-button .icon, .segment, .answer, .break-row, .class-tabs button, .checklist label, .role-option, .stepper button,
  .pupil, .pupil-mark, .day > span { transition: background-color .15s ease, color .15s ease, border-color .15s ease; }
  .nav-button::before { transition: background-color .15s ease; }

  /* Dialogs rise and fade in over a fading backdrop and leave the same way (app.js adds .closing). */
  dialog[open] { animation: dialog-in .24s cubic-bezier(.2, .8, .2, 1); }
  dialog[open]::backdrop { animation: fade-in .24s ease; }
  dialog.closing { animation: dialog-out .16s ease-in forwards; pointer-events: none; }
  dialog.closing::backdrop { animation: fade-out .16s ease-in forwards; }
  /* One dialog replacing another keeps its frame; only the content changes. */
  dialog.swap > * { animation: fade-in .2s ease; }

  /* The hourglass turns over, then waits while the sand runs. */
  .hourglass { animation: hourglass 2.4s cubic-bezier(.6, 0, .3, 1) infinite; }
}
@keyframes dialog-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }
@keyframes dialog-out { to { opacity: 0; transform: translateY(10px) scale(.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@keyframes sheet-out { to { transform: translateY(100%); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; } }
@keyframes hourglass {
  0%, 70% { transform: rotate(0); }
  100% { transform: rotate(180deg); }
}
/* On a phone the dialog is a bottom sheet: it slides up from the edge and back down. */
@media (prefers-reduced-motion: no-preference) and (max-width: 720px) {
  dialog[open] { animation: sheet-in .3s cubic-bezier(.2, .8, .2, 1); }
  dialog.closing { animation: sheet-out .2s ease-in forwards; }
}
