/* Kairo design system.
   Dark-first: this runs in gyms, on OLED phones, and mirrored to TVs.
   Every phase owns the entire screen -- you should never have to *read*
   anything mid-set to know whether you're working or resting. */

:root {
  --bg: #08090c;
  --surface: #14161b;
  --surface-2: #1e222a;
  --border: #2a2f39;
  --text: #f4f5f7;
  --muted: #868d9a;

  /* Phase colors. Saturated enough to read as a signal across a room.
     --break is the long between-sets rest. It sits in the one hue family
     nothing else occupies, deliberately: the dangerous confusion would be
     mistaking a break for WORK, and a rose reads as neither mint nor the
     indigo of a short rest at a glance. */
  --work: #00e5a0;
  --rest: #4c6fff;
  --break: #ff5c8a;
  --prep: #ffb020;
  --done: #a78bfa;

  --radius: 18px;
  --radius-sm: 12px;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);

  color-scheme: dark;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

/* The UA's [hidden] rule is a bare attribute selector, so any component
   that sets `display` from a class silently outranks it and stays on
   screen with the attribute set. Everything here toggles visibility via
   the hidden attribute, so make it win outright. */
[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui,
    sans-serif;
  font-size: 16px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  /* The run screen is a fixed-height flood; nothing should rubber-band. */
  overflow: hidden;
}

button {
  font: inherit;
  color: inherit;
  border: none;
  background: none;
  cursor: pointer;
  /* Sweaty hands double-tap; nobody wants to select the button's label. */
  user-select: none;
  -webkit-user-select: none;
}

/* ---------- screens ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  /* dvh, not vh: mobile Safari's collapsing toolbar makes vh overshoot. */
  height: 100dvh;
}

body[data-screen="home"] #screen-home,
body[data-screen="setup"] #screen-setup,
body[data-screen="history"] #screen-history,
body[data-screen="settings"] #screen-settings,
body[data-screen="run"] #screen-run {
  display: flex;
}

/* ---------- home + setup ---------- */

#screen-home,
#screen-history,
#screen-settings,
#screen-setup {
  padding: max(24px, env(safe-area-inset-top)) 20px
    max(24px, env(safe-area-inset-bottom));
  overflow-y: auto;
  gap: 28px;
}

.setup-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.wordmark {
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.18em;
  margin: 0;
}

.wordmark span {
  color: var(--work);
}

.icon-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--surface);
  color: var(--muted);
  transition: color 0.2s var(--ease), background 0.2s var(--ease);
}

.icon-btn[aria-pressed="true"] {
  color: var(--work);
}

.icon-btn:active {
  background: var(--surface-2);
}

/* This app says things rather than drawing them -- START, END, PAUSE, the
   wordmark. A labelled pill leaves no doubt about what a control does,
   where an icon has to be guessed at. */
.text-btn {
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  transition: background 0.15s var(--ease), color 0.15s var(--ease);
}

.text-btn:active {
  background: var(--surface-2);
  color: var(--text);
}

/* Which glyph shows is derived from aria-pressed, so every sound button on
   the page follows the state without JS touching each one's paths. */
.icon-btn[aria-pressed="true"] .sound-mute,
.icon-btn[aria-pressed="false"] .sound-wave {
  display: none;
}

.head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Balances the back button so the title sits centred. */
.head-spacer {
  width: 44px;
}

.section-label {
  margin: 0 0 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.preset-section {
  display: flex;
  flex-direction: column;
}

.preset-hint {
  margin: 4px 8px 0;
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: var(--muted);
}

.preset-hint strong {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.06em;
}

/* A preset is a saved intent, not a format, so it reads as the accent
   colour rather than as another slab in the format list. */
.format-card.is-preset .format-card-name {
  color: var(--work);
  text-transform: none;
  letter-spacing: 0;
  font-size: 17px;
}

/* ---------- MIX builder ---------- */

.builder {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.block-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  overflow-y: auto;
}

.block-row {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.block-order {
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  min-width: 1.5ch;
}

.block-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.block-name {
  font-size: 15px;
  font-weight: 700;
}

.block-sub {
  font-size: 12px;
  color: var(--muted);
}

.block-row[data-kind="rest"] .block-name {
  color: var(--break);
}

.block-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--surface-2);
  color: var(--muted);
  display: grid;
  place-items: center;
  font-size: 16px;
  line-height: 1;
}

.block-btn:active {
  background: var(--border);
  color: var(--text);
}

.block-btn:disabled {
  opacity: 0.3;
}

.builder-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.builder-btn {
  padding: 14px 8px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  transition: background 0.15s var(--ease);
}

.builder-btn:active {
  background: var(--surface-2);
}

.builder-empty {
  padding: 22px 16px;
  border-radius: var(--radius-sm);
  border: 1px dashed var(--border);
  color: var(--muted);
  text-align: center;
  font-size: 14px;
}

.picker-row {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  text-align: left;
}

.picker-row + .picker-row {
  margin-top: 8px;
}

.picker-row:active {
  background: var(--surface-2);
}

.picker-name {
  font-size: 15px;
  font-weight: 700;
}

.picker-sub {
  font-size: 12px;
  color: var(--muted);
}

/* ---------- settings ---------- */

.settings-body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
}

.palette-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.section-label-spaced {
  margin-top: 28px;
}

.palette-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 14px;
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid transparent;
  text-align: left;
  transition: background 0.15s var(--ease), border-color 0.15s var(--ease);
}

.palette-card[aria-pressed="true"] {
  border-color: var(--work);
}

.palette-card:active {
  background: var(--surface-2);
}

.palette-name {
  font-size: 17px;
  font-weight: 700;
}

.palette-note {
  grid-column: 1;
  font-size: 13px;
  color: var(--muted);
}

/* The swatches are the actual decision -- the names are just handles. */
.palette-swatches {
  grid-column: 1 / -1;
  display: flex;
  gap: 6px;
  margin-top: 12px;
}

.swatch {
  flex: 1;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.palette-check {
  grid-column: 2;
  grid-row: 1 / 3;
  color: var(--work);
  font-size: 18px;
  font-weight: 800;
  opacity: 0;
}

.palette-card[aria-pressed="true"] .palette-check {
  opacity: 1;
}

/* ---------- history ---------- */

.history-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
  overflow-y: auto;
}

.history-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 4px 14px;
  width: 100%;
  padding: 16px 18px;
  border-radius: var(--radius);
  background: var(--surface);
  text-align: left;
  transition: background 0.15s var(--ease);
}

.history-card:active {
  background: var(--surface-2);
}

.history-when {
  grid-column: 1;
  font-size: 13px;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.history-name {
  grid-column: 1;
  font-size: 18px;
  font-weight: 700;
}

.history-detail {
  grid-column: 1;
  font-size: 13px;
  color: var(--muted);
}

.history-result {
  grid-column: 2;
  grid-row: 1 / 4;
  font-size: 24px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  color: var(--work);
}

.history-note {
  grid-column: 1 / -1;
  margin-top: 8px;
  font-size: 13px;
  color: var(--text);
  opacity: 0.75;
  font-style: italic;
}

.empty-note {
  color: var(--muted);
  text-align: center;
  padding: 40px 20px;
  font-size: 15px;
}

.note-field {
  width: 100%;
  min-height: 84px;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 15px;
  resize: vertical;
}

.note-field:focus {
  outline: 2px solid var(--work);
  outline-offset: 1px;
}

.btn-danger {
  background: var(--surface);
  color: var(--break);
}

/* ---------- home: the format list ---------- */

.format-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.format-card {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  padding: 22px 20px;
  background: var(--surface);
  border-radius: var(--radius);
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}

.format-card:active {
  transform: scale(0.985);
  background: var(--surface-2);
}

.format-card-name {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 0.09em;
}

.format-card-summary {
  color: var(--muted);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.format-card-chevron {
  color: var(--border);
  font-size: 22px;
  line-height: 1;
}

.format-badge {
  align-self: flex-start;
  font-size: clamp(2.5rem, 12vw, 4rem);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 1;
  margin: 0;
}

.format-sub {
  color: var(--muted);
  font-size: 15px;
  margin: 8px 0 0;
}

/* The field list is the only part of this screen that grows with the
   format -- Tabata reached six steppers with sets, and MIX will go
   further -- so it absorbs the overflow itself rather than pushing START
   off the bottom. min-height:0 is what actually permits a flex item to
   shrink below its content; overflow-y alone does nothing here. Short
   field lists are unaffected, since this only shrinks under pressure. */
.steppers {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  overflow-y: auto;
}

.stepper {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 14px 14px 20px;
}

.stepper-label {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.1em;
  color: var(--muted);
}

.stepper-value {
  font-size: 30px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  min-width: 3.2ch;
  text-align: right;
}

.stepper-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  font-size: 24px;
  font-weight: 500;
  line-height: 1;
  transition: transform 0.15s var(--ease), background 0.15s var(--ease);
}

.stepper-btn:active {
  transform: scale(0.9);
  background: var(--border);
}

.summary {
  text-align: center;
  color: var(--muted);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.summary strong {
  color: var(--text);
  font-weight: 600;
}

.start-btn {
  margin-top: auto;
  padding: 22px;
  border-radius: var(--radius);
  background: var(--work);
  color: var(--ink-work);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: 0.14em;
  transition: transform 0.15s var(--ease), filter 0.15s var(--ease);
}

.start-btn:active {
  transform: scale(0.98);
  filter: brightness(1.08);
}

/* Sits at the bottom of the home screen and opens the changelog, so it
   reads a step brighter than the hairline borders it used to match --
   enough to look like something you can press, not enough to compete
   with the format list. */
.version {
  align-self: center;
  padding: 4px 10px;
  color: #3f4757;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  transition: color 0.15s var(--ease);
}

.version:active {
  color: var(--muted);
}

/* ---------- changelog ---------- */

.release + .release {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

.release-head {
  display: flex;
  align-items: baseline;
  gap: 10px;
}

.release-version {
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.release[data-current="true"] .release-version {
  color: var(--work);
}

.release-current {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--work);
}

.release-date {
  margin-left: auto;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.release-notes {
  margin: 10px 0 0;
  padding-left: 18px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 14px;
  line-height: 1.45;
}

.release-notes li::marker {
  color: var(--border);
}

/* ---------- run ---------- */

#screen-run {
  --flood: var(--surface);
  --ink: var(--text);
  background: var(--flood);
  color: var(--ink);
  transition: background 0.45s var(--ease), color 0.45s var(--ease);
  padding: max(20px, env(safe-area-inset-top)) 20px
    max(20px, env(safe-area-inset-bottom));
}

/* Both halves come from js/theme.js: the flood is the palette's colour,
   and the ink is derived from it at runtime. Neither is written down
   here, because a foreground written down is a foreground that will be
   wrong for the first palette nobody vetted. */
#screen-run[data-phase="prep"] {
  --flood: var(--prep);
  --ink: var(--ink-prep);
}
#screen-run[data-phase="work"] {
  --flood: var(--work);
  --ink: var(--ink-work);
}
#screen-run[data-phase="rest"] {
  --flood: var(--rest);
  --ink: var(--ink-rest);
}
#screen-run[data-phase="break"] {
  --flood: var(--break);
  --ink: var(--ink-break);
}
#screen-run[data-phase="done"] {
  --flood: var(--done);
  --ink: var(--ink-done);
}

/* Whole-workout progress, hairline across the very top. */
.run-progress {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: rgb(0 0 0 / 0.16);
}

.run-progress-fill {
  height: 100%;
  width: 0;
  background: var(--ink);
  opacity: 0.55;
}

.run-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.run-top-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.round-count {
  font-variant-numeric: tabular-nums;
  opacity: 0.65;
}

/* The run screen is a flood of phase color, so this toggle borrows the
   phase ink instead of the dark-surface palette the home one uses --
   mint-on-mint would disappear. Muted reads as dimmed rather than
   recolored, because a second accent color here competes with the flood. */
.icon-btn-run {
  background: rgb(0 0 0 / 0.13);
  color: var(--ink);
}

.icon-btn-run[aria-pressed="true"] {
  color: var(--ink);
}

.icon-btn-run[aria-pressed="false"] {
  opacity: 0.5;
}

.icon-btn-run:active {
  background: rgb(0 0 0 / 0.24);
}

.run-center {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
}

.numeral {
  font-size: clamp(7rem, 42vw, 20rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.055em;
  line-height: 0.85;
}

/* Post-workout splits. Lives inside the done flood, so it borrows --ink
   rather than the dark surface palette, and scrolls on its own -- a
   30-round EMOM must not push the total off the screen. */
.splits {
  margin-top: 18px;
  width: min(340px, 82vw);
  max-height: 34vh;
  overflow-y: auto;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.split-row {
  display: grid;
  grid-template-columns: 1fr auto auto;
  align-items: baseline;
  gap: 10px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  font-size: 15px;
}

.split-row + .split-row {
  margin-top: 4px;
}

/* Tappable because every row can be corrected afterwards. */
.split-row[data-editable="true"] {
  background: rgb(0 0 0 / 0.1);
  cursor: pointer;
}

.split-row[data-editable="true"]:active {
  background: rgb(0 0 0 / 0.2);
}

.split-label {
  font-weight: 600;
  opacity: 0.75;
  font-size: 13px;
  letter-spacing: 0.06em;
}

.split-time {
  font-weight: 700;
  font-size: 17px;
}

/* A skipped round shows a dash, never a number -- it was never performed,
   and a plausible-looking time would be indistinguishable from a real one
   the next time this workout is read back. */
.split-row[data-source="skipped"] .split-time {
  opacity: 0.45;
}

.split-diff {
  font-size: 13px;
  font-weight: 600;
  min-width: 4.5ch;
  text-align: right;
  opacity: 0.7;
}

/* Restarted from JS on each whole-second boundary. */
.numeral.pulse {
  animation: tick-pulse 0.45s var(--ease);
}

@keyframes tick-pulse {
  0% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
  }
}

.done-note {
  text-align: center;
}

.done-note .numeral {
  font-size: clamp(4rem, 22vw, 11rem);
}

.done-label {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.26em;
  opacity: 0.7;
  margin-bottom: 10px;
}

.run-bottom {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.pips {
  display: flex;
  justify-content: center;
  gap: 7px;
  flex-wrap: wrap;
}

.pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--ink);
  opacity: 0.28;
  transition: opacity 0.3s var(--ease), transform 0.3s var(--ease);
}

.pip.filled {
  opacity: 0.85;
}

.pip.current {
  opacity: 1;
  transform: scale(1.45);
}

/* Flex rather than fixed columns: the middle action button is only
   present for formats that declare it, and the row has to look
   deliberate either way. */
.controls {
  display: flex;
  gap: 12px;
}

.ctrl {
  flex: 1;
}

.ctrl-primary {
  flex: 2;
}

.ctrl {
  padding: 20px;
  border-radius: var(--radius);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.14em;
  transition: transform 0.15s var(--ease);
  color: var(--ink);
}

.ctrl:active {
  transform: scale(0.97);
}

.ctrl-ghost {
  background: rgb(0 0 0 / 0.13);
}

/* Seek controls. Revealed only on pause, so they sit beside RESUME rather
   than competing with anything during a set -- and narrower than the
   controls either side, because the row still has to read as END | RESUME
   at a glance. */
.ctrl-skip {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  padding: 20px 22px;
}

.ctrl-skip:disabled {
  opacity: 0.3;
}

/* Tapped repeatedly mid-effort, so it reads heavier than END without
   competing with the primary control. */
.ctrl-action {
  background: rgb(0 0 0 / 0.24);
  font-size: 19px;
}

.ctrl-primary {
  background: var(--ink);
  color: var(--flood);
}

/* ---------- splits sheet ----------
   Deliberately the app's dark surface rather than the phase flood: it's a
   reading-and-typing surface, and inheriting a mint or rose background
   would make small text and a keypad much harder to work with. */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgb(0 0 0 / 0.55);
}

.sheet-panel {
  width: min(460px, 100%);
  max-height: 86dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--text);
  border-radius: var(--radius) var(--radius) 0 0;
  border-top: 1px solid var(--border);
  padding: 18px 18px max(18px, env(safe-area-inset-bottom));
  gap: 14px;
}

.sheet-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.sheet-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.02em;
  margin: 0;
}

.sheet-body {
  min-height: 0;
  overflow-y: auto;
}

/* Inside the sheet the rows sit on the dark surface, so they need their
   own fill rather than the translucent black used over a flood. */
.sheet-body .split-row[data-editable="true"] {
  background: var(--surface);
}

.sheet-body .split-row[data-editable="true"]:active {
  background: var(--surface-2);
}

.editor-value {
  text-align: center;
  font-size: 52px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
  padding: 8px 0 4px;
}

.editor-hint {
  text-align: center;
  color: var(--muted);
  font-size: 13px;
  margin: 0 0 4px;
}

.editor-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.key {
  padding: 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  font-size: 22px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  transition: background 0.15s var(--ease), transform 0.15s var(--ease);
}

.key:active {
  background: var(--surface-2);
  transform: scale(0.96);
}

.editor-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.editor-actions button {
  flex: 1;
  padding: 16px;
  border-radius: var(--radius);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.btn-save {
  background: var(--work);
  color: var(--ink-work);
}

.btn-clear {
  background: var(--surface);
  color: var(--muted);
}

/* ---------- landscape / TV ----------
   Landscape is the AirPlay case: the phone mirrors to a TV and the timer
   is read from across a room. Height becomes the binding constraint, so
   the numeral is sized off vh and the bottom chrome collapses from a
   stack into a single row to give it back. */

@media (orientation: landscape) {
  /* Two columns: identity and the START action on the left, the settings
     on the right. Stacking these vertically pushes START off a phone's
     landscape height, and the width is going spare anyway.
     Selector must match the specificity of the base
     `body[data-screen=...]` display rule, or display stays flex and every
     grid-area below is silently ignored. */
  body[data-screen="setup"] #screen-setup {
    display: grid;
    grid-template-columns: 1fr 1.15fr;
    align-content: center;
    column-gap: 32px;
    row-gap: 12px;
    padding-top: max(16px, env(safe-area-inset-top));
    padding-bottom: max(16px, env(safe-area-inset-bottom));
  }

  .setup-head {
    grid-area: 1 / 1;
  }
  .setup-format {
    grid-area: 2 / 1;
  }
  .steppers {
    grid-area: 1 / 2 / 5 / 3;
    align-self: center;
    gap: 10px;
    /* Stays centred while the list is short, but a centred grid item
       overflows in *both* directions once it isn't -- six steppers at
       phone-landscape height clipped WORK off the top and PREP off the
       bottom. Capping it to the area lets the scroll above take over. */
    max-height: 100%;
  }

  /* Home has room to spare across, none to spare down. */
  #screen-home {
    justify-content: center;
  }

  .format-list {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .format-card {
    padding: 16px 18px;
  }
  .summary {
    grid-area: 3 / 1;
    text-align: left;
  }
  .start-btn {
    grid-area: 4 / 1;
    margin-top: 0;
  }
  .version {
    grid-area: 5 / 1;
    text-align: left;
  }

  .format-badge {
    font-size: clamp(2rem, 7vh, 3.25rem);
  }

  .stepper {
    padding: 10px 10px 10px 18px;
  }

  .stepper-value {
    font-size: 26px;
  }

  .start-btn {
    padding: 18px;
  }

  #screen-run {
    padding: max(14px, env(safe-area-inset-top)) 28px
      max(14px, env(safe-area-inset-bottom));
  }

  .numeral {
    font-size: min(52vh, 32vw);
  }

  .done-note .numeral {
    font-size: min(28vh, 20vw);
  }

  .run-bottom {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
  }

  .pips {
    flex: 1;
    justify-content: flex-start;
  }

  .controls {
    grid-template-columns: auto auto;
    gap: 10px;
  }

  .ctrl {
    padding: 14px 30px;
  }

  /* Must follow .ctrl above -- same specificity, so order decides, and the
     seek buttons would otherwise inherit the wide landscape padding. */
  .ctrl-skip {
    padding: 14px 18px;
  }
}

/* Don't let the setup form stretch across a TV or desktop monitor. */
@media (min-width: 760px) {
  #screen-setup {
    max-width: 760px;
    margin-inline: auto;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
