/* St Rita's College Exam Timer
   Palette sampled from the College crest: chocolate brown, gold, cream. */

:root {
  --bg: #f6efe6;
  --surface: #fffdf9;
  --surface-2: #f1e6d7;
  --ink: #2b1306;
  --ink-2: #6e4e36;
  --line: #e2d1bb;
  --brand: #4a2208;
  --brand-2: #6b3410;
  --brand-ink: #fff6e6;
  --gold: #c58d2c;
  --gold-2: #f0c060;
  --gold-ink: #2b1306;
  --primary: #4a2208;
  --primary-ink: #fff6e6;
  --warn: #b45309;
  --warn-bg: #fdecc8;
  --danger: #a3261b;
  --break: #3f5f73;
  --finish-bg: #4a2208;
  --finish-ring: transparent;
  --sec-perusal: #c58d2c;
  --sec-planning: #a0612a;
  --sec-working: #4a2208;
  --sec-other: #7a6a5c;
  --shadow: 0 1px 2px rgba(43, 19, 6, .08), 0 6px 24px rgba(43, 19, 6, .08);
  --radius: 1.1rem;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #140904;
    --surface: #211108;
    --surface-2: #2d190c;
    --ink: #f8eedf;
    --ink-2: #cfb497;
    --line: #432817;
    --brand: #2a1305;
    --brand-2: #3a1c09;
    --brand-ink: #fff3de;
    --primary: #e9b552;
    --primary-ink: #231004;
    --warn: #f5a524;
    --warn-bg: #3d2606;
    --danger: #f07167;
    --break: #8fb4c9;
    --finish-bg: #4b2b12;
    --finish-ring: #c58d2c;
    --sec-perusal: #e9b552;
    --sec-planning: #d08a45;
    --sec-working: #f3dcb6;
    --sec-other: #b8a796;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .35);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #140904;
  --surface: #211108;
  --surface-2: #2d190c;
  --ink: #f8eedf;
  --ink-2: #cfb497;
  --line: #432817;
  --brand: #2a1305;
  --brand-2: #3a1c09;
  --brand-ink: #fff3de;
  --primary: #e9b552;
  --primary-ink: #231004;
  --warn: #f5a524;
  --warn-bg: #3d2606;
  --danger: #f07167;
  --break: #8fb4c9;
  --finish-bg: #4b2b12;
  --finish-ring: #c58d2c;
  --sec-perusal: #e9b552;
  --sec-planning: #d08a45;
  --sec-working: #f3dcb6;
  --sec-other: #b8a796;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 8px 28px rgba(0, 0, 0, .35);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  /* Scales with the screen: comfortable on a phone, readable from the back of a classroom on a panel. */
  font-size: clamp(14px, calc(0.55vw + 0.85vh), 40px);
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, system-ui, sans-serif;
  line-height: 1.35;
  overflow: hidden;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
svg { width: 1.3em; height: 1.3em; flex: none; }

.app {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ---------- Header ---------- */
.topbar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .7rem 1.4rem;
  padding-left: max(1.4rem, env(safe-area-inset-left));
  padding-right: max(1.4rem, env(safe-area-inset-right));
  background: var(--brand);
  color: var(--brand-ink);
  border-bottom: .3rem solid var(--gold);
  flex: none;
}
.crest { height: 4.4rem; width: auto; filter: drop-shadow(0 2px 4px rgba(0, 0, 0, .35)); }
.brand { min-width: 0; flex: 1; }
.school { font-size: 1.9rem; font-weight: 700; letter-spacing: .01em; line-height: 1.1; }
.subtitle { font-size: 1.15rem; color: var(--gold-2); font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now { text-align: right; flex: none; }
.now-label { font-size: .8rem; text-transform: uppercase; letter-spacing: .12em; color: var(--gold-2); font-weight: 700; }
.now-time { font-size: 2.6rem; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.05; }
.now-time .ampm { font-size: .5em; margin-left: .2em; font-weight: 600; }
.now-date { font-size: .9rem; opacity: .85; }

/* ---------- Stage ---------- */
.stage {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 1.1rem;
  padding: 1.1rem 1.4rem;
  padding-left: max(1.4rem, env(safe-area-inset-left));
  padding-right: max(1.4rem, env(safe-area-inset-right));
}
.exams {
  flex: 1 1 0;
  min-width: 0;
  display: grid;
  gap: 1.1rem;
  grid-template-columns: 1fr;
  grid-auto-rows: 1fr;
}
.exams[data-count="2"] { grid-template-columns: repeat(2, 1fr); }
.exams[data-count="3"] { grid-template-columns: repeat(3, 1fr); }
.exams[data-count="4"] { grid-template-columns: repeat(2, 1fr); }
.exams[data-count="5"], .exams[data-count="6"] { grid-template-columns: repeat(3, 1fr); }

.instructions {
  flex: 0 0 30%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.stage.many .instructions { flex-basis: 24%; }
.instr-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .55rem .6rem .55rem 1.1rem;
  border-bottom: 1px solid var(--line);
  background: var(--surface-2);
}
.instr-head h2 { margin: 0; font-size: 1.15rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); }
.instr-tools { display: flex; gap: .25rem; }
.instr-body {
  flex: 1;
  overflow: auto;
  padding: 1rem 1.2rem;
  font-size: calc(1.35rem * var(--instr-scale, 1));
  white-space: pre-line;
  line-height: 1.45;
}
.instr-body ul { margin: 0; padding-left: 1.2em; white-space: normal; }
.instr-body li { margin: 0 0 .5em; }
.instr-body p { margin: 0 0 .6em; white-space: normal; }
.instr-edit { flex: 1; display: flex; flex-direction: column; gap: .6rem; padding: .8rem; min-height: 0; }
.instr-edit textarea {
  flex: 1;
  min-height: 8rem;
  resize: none;
  padding: .8rem;
  border-radius: .7rem;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 1.1rem;
  line-height: 1.4;
}
.instr-edit-actions { display: flex; justify-content: flex-end; gap: .5rem; }

/* ---------- Exam card ---------- */
.card {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  padding: 1rem 1.3rem 1.1rem;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: .35rem solid var(--gold);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.card-head { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.card-title {
  margin: 0;
  flex: 1;
  min-width: 0;
  font-size: 1.55rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tag {
  flex: none;
  font-size: .8rem;
  font-weight: 700;
  letter-spacing: .06em;
  padding: .2em .6em;
  border-radius: 99px;
  border: 1.5px solid var(--gold);
  color: var(--ink-2);
}
.pill {
  flex: none;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  padding: .35em .85em;
  border-radius: 99px;
  background: var(--surface-2);
  color: var(--ink-2);
  white-space: nowrap;
}
.pill.k-perusal { background: var(--sec-perusal); color: #2b1306; }
.pill.k-planning { background: var(--sec-planning); color: #fff6e6; }
.pill.k-working { background: var(--sec-working); color: var(--bg); }
.pill.k-other { background: var(--sec-other); color: #fff; }
.pill.s-paused { background: var(--warn-bg); color: var(--warn); }
.pill.s-break { background: var(--break); color: #fff; }
.pill.s-finished { background: var(--danger); color: #fff; }
.pill.s-scheduled { background: var(--surface-2); color: var(--ink); }

.card-sub { font-size: 1.15rem; color: var(--ink-2); min-height: 1.4em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-sub strong { color: var(--ink); }

.timer-box {
  flex: 1;
  min-height: 3rem;
  /* The box's size must never depend on the digits inside it — the digits are
     sized to fit the box, so anything else is a ResizeObserver feedback loop. */
  contain: size;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.timer {
  display: inline-block;
  white-space: nowrap;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -.02em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  color: var(--ink);
  transition: color .3s;
}
.timer .u { font-size: .42em; font-weight: 600; margin-left: .04em; color: var(--ink-2); letter-spacing: 0; }
.timer.words { letter-spacing: 0; }

.progress {
  position: relative;
  height: .8rem;
  border-radius: 99px;
  background: var(--surface-2);
  overflow: hidden;
  display: flex;
  flex: none;
}
.progress .seg { height: 100%; border-right: 2px solid var(--surface); opacity: .28; }
.progress .seg:last-of-type { border-right: 0; }
.progress .seg.k-perusal { background: var(--sec-perusal); }
.progress .seg.k-planning { background: var(--sec-planning); }
.progress .seg.k-working { background: var(--sec-working); }
.progress .seg.k-other { background: var(--sec-other); }
.progress .fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0;
  background: var(--gold);
  border-radius: 99px;
  transition: width .9s linear;
}

.banner {
  flex: none;
  font-size: 1.35rem;
  font-weight: 700;
  text-align: center;
  padding: .45rem .8rem;
  border-radius: .7rem;
  background: var(--surface-2);
  color: var(--ink);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.banner.k-warning { background: var(--warn-bg); color: var(--warn); }
.banner.k-transition { background: var(--sec-perusal); color: #2b1306; }
.banner.k-info { background: var(--surface-2); color: var(--ink-2); font-weight: 600; }

.times { display: flex; gap: .8rem; flex: none; }
.times > div {
  flex: 1;
  min-width: 0;
  padding: .45rem .8rem;
  border-radius: .7rem;
  background: var(--surface-2);
}
.times .lbl { display: block; font-size: .8rem; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); font-weight: 700; }
.times .v { display: block; font-size: 1.6rem; font-weight: 700; font-variant-numeric: tabular-nums; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.times .v .ampm { font-size: .6em; margin-left: .15em; }
.times .finish-tile { background: var(--finish-bg); color: var(--brand-ink); box-shadow: inset 0 0 0 1.5px var(--finish-ring); }
.times .finish-tile .lbl { color: var(--gold-2); }

.card-actions { display: flex; align-items: center; gap: .7rem; flex: none; flex-wrap: wrap; }
.card-actions .note { font-size: 1rem; color: var(--ink-2); }
.card-actions .note.over { color: var(--danger); font-weight: 700; }

/* States */
.card.final .timer { color: var(--warn); }
.card.final { border-top-color: var(--warn); }
.card.paused .timer, .card.break .timer { opacity: .55; }
.card.finished { border-top-color: var(--danger); }
.card.finished .timer { color: var(--danger); }
.card.flash { animation: flash 1.2s ease-in-out 4; }
@keyframes flash {
  0%, 100% { box-shadow: var(--shadow); }
  50% { box-shadow: 0 0 0 .45rem var(--gold-2), 0 0 2.5rem .4rem var(--gold); }
}

/* Compact cards when several exams share the screen */
.exams[data-count="2"] .card-title, .exams[data-count="3"] .card-title { font-size: 1.35rem; }
.exams.compact .card { padding: .7rem .9rem .8rem; gap: .35rem; }
.exams.compact .card-title { font-size: 1.15rem; }
.exams.compact .pill { font-size: .8rem; }
.exams.compact .card-sub { font-size: .95rem; }
.exams.compact .banner { font-size: 1.05rem; padding: .3rem .6rem; }
.exams.compact .times .v { font-size: 1.2rem; }
.exams.compact .times > div { padding: .3rem .6rem; }

/* ---------- Quick presets ---------- */
.quick {
  display: flex;
  align-items: center;
  gap: .8rem;
  padding: 0 1.4rem .7rem;
  flex: none;
  min-width: 0;
}
.quick-label { font-size: .85rem; font-weight: 700; text-transform: uppercase; letter-spacing: .1em; color: var(--ink-2); flex: none; }
.quick-chips { display: flex; gap: .5rem; overflow-x: auto; scrollbar-width: none; padding: .2rem; min-width: 0; }
.quick-chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none;
  min-height: 2.8rem;
  padding: .45rem 1rem;
  border-radius: 99px;
  border: 1.5px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  font-size: 1rem;
  white-space: nowrap;
}
.chip:hover { border-color: var(--gold); }
.chip.active { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }

/* ---------- Bottom controls (bottom = within reach on a wall-mounted panel) ---------- */
.controls {
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .7rem 1.4rem;
  padding-bottom: max(.7rem, env(safe-area-inset-bottom));
  padding-left: max(1.4rem, env(safe-area-inset-left));
  padding-right: max(1.4rem, env(safe-area-inset-right));
  background: var(--surface);
  border-top: 1px solid var(--line);
  flex: none;
}
.ctl-spacer { flex: 1; }
.ctl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .55rem;
  min-height: 3.4rem;
  min-width: 3.4rem;
  padding: .5rem 1.25rem;
  border-radius: .9rem;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  font-weight: 700;
  font-size: 1.1rem;
  transition: transform .08s, background .2s;
}
.ctl:active { transform: scale(.97); }
.ctl.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); min-width: 11rem; font-size: 1.3rem; }
.ctl.primary.resume { background: var(--warn); border-color: var(--warn); color: #fff; }
.ctl:disabled { opacity: .45; cursor: default; }
.ctl.sound { background: var(--warn-bg); color: var(--warn); border-color: var(--warn); }

/* ---------- Footer ---------- */
.site-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: .2rem .6rem;
  padding: .25rem 1.4rem .4rem;
  padding-bottom: max(.4rem, env(safe-area-inset-bottom));
  background: var(--surface);
  color: var(--ink-2);
  font-size: .8rem;
  flex: none;
}
.site-footer strong { color: var(--ink); font-weight: 700; }
.site-footer .dot { opacity: .6; }
.site-footer .ver { opacity: .75; }
.link-btn {
  padding: .35rem .2rem;
  border: 0;
  background: none;
  color: var(--ink-2);
  text-decoration: underline;
  text-underline-offset: .2em;
  font-size: inherit;
}
.link-btn:hover { color: var(--ink); }

.feedback-modal { text-align: center; width: min(26rem, 100%); }
.feedback-modal .modal-actions { justify-content: center; flex-wrap: wrap; }
.qr {
  width: min(15rem, 70vw);
  aspect-ratio: 1;
  margin: 0 auto .6rem;
  padding: .7rem;
  background: #fff;
  border-radius: .8rem;
  border: 1px solid var(--line);
}
.qr svg { width: 100%; height: 100%; display: block; }
.qr-url { font-size: .8rem; word-break: break-all; margin-bottom: 1rem !important; }

/* ---------- Buttons & form controls ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 2.8rem;
  padding: .45rem 1rem;
  border-radius: .7rem;
  border: 1.5px solid var(--line);
  background: var(--surface-2);
  font-weight: 600;
  font-size: 1rem;
}
.btn.primary { background: var(--primary); color: var(--primary-ink); border-color: var(--primary); }
a.btn { text-decoration: none; color: var(--ink); }
.btn.danger { color: var(--danger); }
.btn.small { min-height: 2.3rem; padding: .3rem .7rem; font-size: .9rem; }
.btn:disabled { opacity: .45; cursor: default; }
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.7rem;
  height: 2.7rem;
  border-radius: .65rem;
  border: 1.5px solid transparent;
  background: transparent;
  color: var(--ink-2);
}
.icon-btn:hover { border-color: var(--line); background: var(--surface); }
.icon-btn:disabled { opacity: .35; }
.icon-btn svg { width: 1.4em; height: 1.4em; }

input[type="text"], input[type="number"], input[type="time"], select {
  min-height: 2.8rem;
  padding: .4rem .7rem;
  border-radius: .65rem;
  border: 1.5px solid var(--line);
  background: var(--bg);
  font-size: 1.05rem;
  min-width: 0;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* Toggle switch */
.switch { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: .5rem 0; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .track {
  flex: none;
  position: relative;
  width: 3.4rem;
  height: 1.9rem;
  border-radius: 99px;
  background: var(--line);
  transition: background .2s;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: .2rem;
  left: .2rem;
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .3);
  transition: transform .2s;
}
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(1.5rem); }
.switch input:focus-visible + .track { outline: 3px solid var(--gold); outline-offset: 2px; }
.switch .txt { display: flex; flex-direction: column; }
.switch .txt small { color: var(--ink-2); font-size: .85rem; }

/* ---------- Setup sheet ---------- */
.sheet-backdrop, .modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(20, 9, 4, .55);
}
.sheet {
  width: min(64rem, 100%);
  height: min(94vh, 100%);
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-radius: 1.2rem 1.2rem 0 0;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, .35);
  overflow: hidden;
}
.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .8rem 1.2rem;
  background: var(--brand);
  color: var(--brand-ink);
  border-bottom: .25rem solid var(--gold);
  flex: none;
}
.sheet-head h2 { margin: 0; font-size: 1.4rem; }
.sheet-head-actions { display: flex; gap: .5rem; }
.sheet-head .btn { background: transparent; color: var(--brand-ink); border-color: rgba(255, 246, 230, .35); }
.sheet-head .btn.primary { background: var(--gold); border-color: var(--gold); color: #2b1306; }
.sheet-body { flex: 1; overflow: auto; padding: 1rem 1.2rem 3rem; -webkit-overflow-scrolling: touch; }

.group { margin: 0 0 1.4rem; }
.group > h3 {
  margin: 0 0 .6rem;
  font-size: .9rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--ink-2);
}
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 1rem;
  padding: .9rem 1rem;
}
.panel + .panel { margin-top: .8rem; }
.panel .row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.panel .row + .row { margin-top: .6rem; }
.help { color: var(--ink-2); font-size: .9rem; margin: .4rem 0 0; }
.notice {
  padding: .8rem 1rem;
  border-radius: .8rem;
  background: var(--warn-bg);
  color: var(--warn);
  font-weight: 600;
  margin-bottom: .8rem;
}
.locked .exam-editor { opacity: .55; pointer-events: none; }

.exam-editor { border-top: .3rem solid var(--gold); }
.exam-editor .title-row { display: flex; gap: .6rem; align-items: center; flex-wrap: wrap; }
.exam-editor .title-row input { flex: 1 1 14rem; font-weight: 600; }
.exam-editor .title-row select { flex: 0 1 15rem; }
.sec-list { margin: .8rem 0 .4rem; display: flex; flex-direction: column; gap: .5rem; }
.sec-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  flex-wrap: wrap;
  padding: .45rem .5rem;
  border-radius: .8rem;
  background: var(--surface-2);
  border-left: .35rem solid var(--sec-other);
}
.sec-row.k-perusal { border-left-color: var(--sec-perusal); }
.sec-row.k-planning { border-left-color: var(--sec-planning); }
.sec-row.k-working { border-left-color: var(--sec-working); }
.sec-row .sec-name { flex: 1 1 10rem; }
.stepper { display: inline-flex; align-items: center; gap: .25rem; }
.stepper input { width: 4.8rem; text-align: center; font-weight: 700; font-variant-numeric: tabular-nums; }
.stepper .btn { min-width: 2.9rem; padding: .3rem .4rem; }
.stepper .unit { font-size: .9rem; color: var(--ink-2); margin-left: .15rem; }
.sec-tools { display: inline-flex; gap: .1rem; }
.exam-total { font-weight: 700; }
.exam-total span { color: var(--ink-2); font-weight: 500; }
.editor-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; padding-top: .8rem; border-top: 1px dashed var(--line); }
.editor-actions .spacer { flex: 1; }

details.aara { margin-top: .8rem; border-radius: .8rem; background: var(--surface-2); }
details.aara summary {
  cursor: pointer;
  list-style: none;
  padding: .7rem .9rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: .5rem;
}
details.aara summary::-webkit-details-marker { display: none; }
details.aara summary::after { content: "▾"; margin-left: auto; color: var(--ink-2); }
details.aara[open] summary::after { content: "▴"; }
details.aara .aara-body { padding: 0 .9rem .9rem; }
details.aara .aara-line { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
details.aara .aara-line + .aara-line { margin-top: .7rem; }
details.aara .aara-line > label { flex: 1 1 12rem; font-weight: 600; }

.warn-chips { display: flex; gap: .5rem; flex-wrap: wrap; align-items: center; }
.warn-chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .25rem .3rem .25rem .8rem;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1.5px solid var(--line);
  font-weight: 700;
}
.warn-chip .icon-btn { width: 2.1rem; height: 2.1rem; }
.add-warning { display: inline-flex; gap: .4rem; align-items: center; }
.add-warning input { width: 5.5rem; }

.preset-list { display: flex; flex-direction: column; gap: .4rem; }
.preset-item { display: flex; align-items: center; gap: .6rem; padding: .4rem .3rem .4rem .8rem; border-radius: .7rem; background: var(--surface-2); }
.preset-item .name { flex: 1; font-weight: 600; min-width: 0; }
.preset-item .meta { color: var(--ink-2); font-size: .9rem; }
.range { flex: 1 1 10rem; accent-color: var(--gold); }

.about { color: var(--ink-2); font-size: .85rem; }

/* ---------- Modal & toast ---------- */
.modal-backdrop { align-items: center; z-index: 30; padding: 1rem; }
.modal {
  width: min(30rem, 100%);
  padding: 1.4rem;
  background: var(--surface);
  border-radius: 1.1rem;
  border-top: .3rem solid var(--gold);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .4);
}
.modal h2 { margin: 0 0 .5rem; font-size: 1.4rem; }
.modal p { margin: 0 0 1.2rem; color: var(--ink-2); }
.modal input { width: 100%; margin: -.4rem 0 1.2rem; }
.modal-actions { display: flex; justify-content: flex-end; gap: .6rem; }
.modal .btn.primary.danger { background: var(--danger); border-color: var(--danger); color: #fff; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 6.5rem;
  z-index: 40;
  transform: translate(-50%, 1rem);
  max-width: calc(100% - 2rem);
  padding: .7rem 1.2rem;
  border-radius: .8rem;
  background: var(--ink);
  color: var(--bg);
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.noscript { padding: 2rem; font-size: 1.4rem; }

/* ---------- Narrow screens (phones / portrait) ---------- */
@media (max-width: 760px), (orientation: portrait) and (max-width: 1100px) {
  html { font-size: clamp(14px, 3.6vw, 22px); }
  body { overflow: auto; }
  .app { height: auto; min-height: 100vh; min-height: 100dvh; }
  .topbar { padding: .6rem .9rem; gap: .7rem; }
  .crest { height: 3rem; }
  .school { font-size: 1.25rem; }
  .subtitle { font-size: .95rem; }
  .now-time { font-size: 1.6rem; }
  .now-label, .now-date { display: none; }
  .stage { flex-direction: column; padding: .8rem; flex: none; }
  .exams, .exams[data-count] { grid-template-columns: 1fr; grid-auto-rows: auto; }
  .card { min-height: min(52vh, 30rem); }
  .exams[data-count]:not([data-count="1"]) .card { min-height: min(38vh, 22rem); }
  .instructions, .stage.many .instructions { flex-basis: auto; }
  .instr-body { max-height: none; }
  .quick { padding: 0 .8rem .6rem; }
  .controls { position: sticky; bottom: 0; padding: .55rem .6rem; gap: .4rem; flex-wrap: wrap; }
  .ctl { padding: .4rem .7rem; min-height: 3rem; font-size: 1rem; }
  .ctl.primary { min-width: 0; flex: 1 1 8rem; }
  .ctl:not(.primary) span { display: none; }
  .ctl-spacer { display: none; }
  .sheet { height: 100%; border-radius: 0; }
  .sheet-body { padding: .8rem; }
  .times .v { font-size: 1.3rem; }
  .banner, .card-sub { white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  .card.flash { animation: none; outline: .4rem solid var(--gold-2); }
  .progress .fill, .toast, .ctl { transition: none; }
}
