/* Tock — timer & stopwatch */

@font-face {
  font-family: "Big Shoulders Display";
  src: url("../fonts/big-shoulders-display.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Hanken Grotesk";
  src: url("../fonts/hanken-grotesk.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

/* ---------- tokens ---------- */
:root {
  --font-display: "Big Shoulders Display", "Arial Narrow", "Roboto Condensed", Impact, sans-serif;
  --font-ui: "Hanken Grotesk", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --radius: 14px;
  --ease: cubic-bezier(.2, .7, .2, 1);

  /* dark (default) */
  --c-bg: #0b0d0a;
  --c-surface: #13160f;
  --c-raise: #1b1f16;
  --c-ink: #f1f4e8;
  --c-muted: #9aa18d;
  --c-line: #2a2f22;
  --c-line-strong: #3b4230;
  --shadow: 0 24px 80px rgba(0, 0, 0, .6);
  color-scheme: dark;
}
:root[data-theme="light"] {
  --c-bg: #f3f1ea;
  --c-surface: #fbfaf5;
  --c-raise: #ffffff;
  --c-ink: #15170f;
  --c-muted: #5d6253;
  --c-line: #dcd9cc;
  --c-line-strong: #bdb9a8;
  --shadow: 0 24px 80px rgba(40, 40, 20, .22);
  color-scheme: light;
}

/* accent: fill (--c-a), text on that fill (--c-ao), accent used as text/lines on the page (--c-at) */
:root, :root[data-accent="lime"] { --c-a: #c8f542; --c-ao: #10140a; --c-at: #c8f542; }
:root[data-accent="amber"] { --c-a: #ffb224; --c-ao: #1a1002; --c-at: #ffb224; }
:root[data-accent="cyan"] { --c-a: #5fe0f0; --c-ao: #04161a; --c-at: #5fe0f0; }
:root[data-accent="rose"] { --c-a: #ff8097; --c-ao: #1f060b; --c-at: #ff8097; }
:root[data-accent="mono"] { --c-a: #f1f4e8; --c-ao: #0b0d0a; --c-at: #f1f4e8; }
:root[data-theme="light"], :root[data-theme="light"][data-accent="lime"] { --c-a: #bfe838; --c-ao: #10140a; --c-at: #456300; }
:root[data-theme="light"][data-accent="amber"] { --c-a: #ffb224; --c-ao: #1a1002; --c-at: #8a4f00; }
:root[data-theme="light"][data-accent="cyan"] { --c-a: #56d4e6; --c-ao: #04161a; --c-at: #006274; }
:root[data-theme="light"][data-accent="rose"] { --c-a: #ff8097; --c-ao: #1f060b; --c-at: #ab1f3a; }
:root[data-theme="light"][data-accent="mono"] { --c-a: #15170f; --c-ao: #f3f1ea; --c-at: #15170f; }

/* semantic layer — the alarm state swaps these */
:root {
  --bg: var(--c-bg);
  --surface: var(--c-surface);
  --ink: var(--c-ink);
  --muted: var(--c-muted);
  --line: var(--c-line);
  --line-strong: var(--c-line-strong);
  --accent: var(--c-a);
  --on-accent: var(--c-ao);
  --accent-text: var(--c-at);
}
:root[data-alert="ring"] {
  --bg: var(--c-a);
  --surface: var(--c-a);
  --ink: var(--c-ao);
  --muted: color-mix(in srgb, var(--c-ao) 74%, var(--c-a));
  --line: color-mix(in srgb, var(--c-ao) 26%, var(--c-a));
  --line-strong: color-mix(in srgb, var(--c-ao) 72%, var(--c-a));
  --accent: var(--c-ao);
  --on-accent: var(--c-a);
  --accent-text: var(--c-ao);
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  background: var(--bg);
  color: var(--ink);
  font: 500 15px/1.4 var(--font-ui);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  transition: background-color .25s var(--ease), color .25s var(--ease);
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; background: none; border: 0; padding: 0; touch-action: manipulation; }
button:disabled { cursor: default; }
h2 { margin: 0; font: 700 22px/1 var(--font-display); letter-spacing: .06em; text-transform: uppercase; }
p { margin: 0; }
:focus { outline: none; }
:focus-visible { outline: 2px solid var(--accent-text); outline-offset: 3px; border-radius: 8px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; font-style: normal;
}
.skip {
  position: absolute; left: 12px; top: -60px; z-index: 20;
  background: var(--accent); color: var(--on-accent); padding: 10px 14px; border-radius: 10px;
  font-weight: 700; text-decoration: none;
}
.skip:focus { top: 12px; }

kbd {
  display: inline-block; min-width: 1.7em; padding: 1px 6px 2px;
  border: 1px solid var(--line-strong); border-bottom-width: 2px; border-radius: 6px;
  font: 600 12px/1.4 var(--font-ui); text-align: center; color: var(--muted); background: transparent;
}

/* ---------- top bar ---------- */
.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 12px;
  padding: 14px clamp(14px, 2.4vw, 28px);
  transition: opacity .4s var(--ease);
}
.brand {
  display: inline-flex; align-items: center; gap: 10px; justify-self: start;
  font: 800 24px/1 var(--font-display); letter-spacing: .1em; text-transform: uppercase;
}
.brand svg { color: var(--accent-text); flex: none; }

.modes {
  display: inline-flex; padding: 4px; gap: 2px;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface);
}
.modes button {
  position: relative;
  height: 40px; padding: 0 20px; border-radius: 999px;
  font-weight: 650; font-size: 15px; color: var(--muted);
  display: inline-flex; align-items: center; gap: 8px;
  transition: color .15s, background-color .15s;
}
.modes button:hover { color: var(--ink); }
.modes button[aria-selected="true"] { background: var(--ink); color: var(--bg); }
.run-dot { display: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent-text); flex: none; }
.modes button[data-live="1"] .run-dot { display: block; }
.modes button[data-live="1"][aria-selected="true"] .run-dot { background: var(--bg); }
.modes button[data-live="run"] .run-dot { display: block; animation: blink 1.2s steps(2, jump-none) infinite; }
.modes button[data-live="run"][aria-selected="true"] .run-dot { background: var(--bg); }

.tools { display: inline-flex; gap: 4px; justify-self: end; }
.icon {
  width: 44px; height: 44px; border-radius: 12px; flex: none;
  display: inline-grid; place-items: center; color: var(--muted);
  transition: color .15s, background-color .15s;
}
.icon:hover { color: var(--ink); background: color-mix(in srgb, var(--ink) 8%, transparent); }
.icon svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
#btn-mute .i-off { display: none; }
#btn-mute[aria-pressed="true"] .i-on { display: none; }
#btn-mute[aria-pressed="true"] .i-off { display: block; }
#btn-mute[aria-pressed="true"] { color: var(--accent-text); }

/* ---------- stage ---------- */
main {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  align-items: center;
  justify-items: center;
  gap: clamp(16px, 3vw, 48px);
  padding: 0 clamp(14px, 4vw, 64px);
  min-width: 0;
}
main.with-laps { grid-template-columns: minmax(0, 1fr) minmax(300px, 380px); }

.readout {
  container-type: inline-size;
  width: 100%;
  max-width: 1500px;
  display: flex; flex-direction: column; align-items: center;
  min-width: 0;
}

.status {
  display: inline-flex; align-items: center; gap: 10px;
  font: 700 clamp(15px, 1.5vw, 20px)/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase;
  color: var(--muted);
  min-height: 20px;
}
.status .dot { width: 9px; height: 9px; border-radius: 50%; background: var(--line-strong); flex: none; }
.status[data-state="running"] { color: var(--accent-text); }
.status[data-state="running"] .dot { background: var(--accent-text); animation: blink 1.2s steps(2, jump-none) infinite; }
.status[data-state="paused"] .dot { background: var(--muted); }
.status[data-state="done"] { color: var(--ink); font-size: clamp(24px, 3.2vw, 44px); font-weight: 800; letter-spacing: .12em; min-height: 44px; }
.status[data-state="done"] .dot { background: var(--ink); }
@keyframes blink { 50% { opacity: .25; } }

.face {
  display: flex; flex-direction: column; align-items: stretch;
  max-width: 100%;
  margin-top: clamp(8px, 2.2vh, 26px);
}
.display-wrap {
  position: relative;
  display: flex; justify-content: center;
  margin: 0 0 clamp(8px, 1.8vh, 20px);
  border-radius: 18px;
}
.display {
  --w: 2.5;
  display: flex; align-items: baseline; justify-content: center;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: min(calc(96cqw / var(--w)), var(--fs-max, 40vh), 30rem);
  line-height: .84;
  white-space: nowrap;
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  user-select: none;
  -webkit-user-select: none;
  padding-top: .04em;
}
:root { --fs-max: 40vh; }
.display span { display: inline-block; text-align: center; flex: none; }
.display .d { width: .53em; }
.display .c { width: .25em; position: relative; top: -.175em; }
.display .f { font-size: .5em; width: .54em; color: var(--muted); }
.display .p { font-size: .5em; width: .3em; color: var(--muted); }
.display .dim { color: var(--line-strong); }
.display .caret {
  width: .05em; height: .62em; align-self: center; margin-left: .02em;
  background: var(--accent-text); border-radius: 2px;
  animation: blink 1s steps(2, jump-none) infinite;
}
:root[data-alert="ring"] .display { animation: pulse 1s steps(2, jump-none) infinite; }
:root[data-alert="over"] .display { color: var(--accent-text); }
@keyframes pulse { 50% { opacity: .38; } }

.entry {
  position: absolute; inset: 0; width: 100%; height: 100%;
  opacity: 0; border: 0; padding: 0; margin: 0; background: transparent;
  font-size: 16px; cursor: text; caret-color: transparent;
}
.display-wrap.editable:hover .display { color: color-mix(in srgb, var(--ink) 86%, var(--accent-text)); }
.display-wrap.editing { box-shadow: inset 0 -3px 0 var(--accent-text); border-radius: 0; }
.display-wrap:has(.entry:focus-visible):not(.editing) { outline: 2px solid var(--accent-text); outline-offset: 4px; }

/* ruler */
.ruler {
  position: relative;
  width: 100%;
  height: 30px;
  margin-bottom: 12px;
}
.ticks { position: absolute; inset: 0 0 8px; display: flex; justify-content: space-between; align-items: flex-end; }
.ticks i { display: block; width: 2px; height: 45%; border-radius: 1px; background: var(--line-strong); transition: background-color .12s; }
.ticks i.major { height: 100%; }
.ticks i.on { background: var(--accent-text); }
.needle {
  position: absolute; bottom: 0; left: calc(var(--p, 0) * 100%); width: 0; height: 6px;
  pointer-events: none;
}
.needle::before {
  content: ""; position: absolute; left: -6px; bottom: 0;
  border-left: 6px solid transparent; border-right: 6px solid transparent; border-bottom: 6px solid var(--accent-text);
}

.sub {
  min-height: 22px;
  color: var(--muted);
  font-size: clamp(14px, 1.2vw, 17px);
  font-variant-numeric: tabular-nums;
  text-align: center;
}
.sub b { color: var(--ink); font-weight: 650; }

/* controls */
.controls {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  margin-top: clamp(12px, 2.4vh, 26px);
  width: min(100%, 620px);
}
.controls #btn-left { justify-self: end; }
.controls #btn-right { justify-self: start; }
.btn {
  height: 58px; min-width: 124px; padding: 0 22px;
  border: 1.5px solid var(--line-strong); border-radius: var(--radius);
  font: 750 21px/1 var(--font-display); letter-spacing: .1em; text-transform: uppercase;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  white-space: nowrap;
  transition: transform .08s var(--ease), background-color .15s, border-color .15s, color .15s, opacity .15s;
}
.btn:hover:not(:disabled) { border-color: var(--ink); background: color-mix(in srgb, var(--ink) 7%, transparent); }
.btn:active:not(:disabled) { transform: scale(.97); }
.btn:disabled { opacity: .35; }
.btn.primary {
  min-width: 232px; height: 68px;
  background: var(--accent); color: var(--on-accent); border-color: var(--accent);
  font-size: 27px; font-weight: 800;
}
.btn.primary:hover:not(:disabled) { background: color-mix(in srgb, var(--accent) 88%, var(--on-accent)); border-color: transparent; }
.btn.primary kbd { color: inherit; border-color: color-mix(in srgb, var(--on-accent) 45%, transparent); opacity: .75; letter-spacing: 0; text-transform: none; }
.btn.small { height: 40px; min-width: 0; padding: 0 16px; font-size: 16px; border-radius: 10px; }
.btn.solid { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.btn.solid:hover:not(:disabled) { background: color-mix(in srgb, var(--ink) 86%, var(--bg)); }

.chips {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 8px;
  margin-top: clamp(12px, 2.2vh, 22px);
  min-height: 38px;
  max-width: 900px;
}
.chip {
  height: 38px; padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 600; font-size: 14px; color: var(--ink);
  font-variant-numeric: tabular-nums;
  display: inline-flex; align-items: center; gap: 6px;
  transition: border-color .15s, background-color .15s, color .15s;
}
.chip:hover { border-color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.chip.ghost { background: transparent; border-style: dashed; color: var(--muted); }
.chip.ghost:hover { color: var(--ink); }
.chip-sep { width: 1px; align-self: stretch; margin: 6px 4px; background: var(--line); }

/* laps */
.laps {
  width: 100%;
  align-self: center;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  display: flex; flex-direction: column;
  max-height: min(64vh, 620px);
  min-height: 0;
  overflow: hidden;
}
.laps-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 16px 18px 12px; }
.laps-head .count { color: var(--muted); margin-left: 4px; }
.laps-actions { display: flex; gap: 14px; }
.link {
  color: var(--muted); font-weight: 600; font-size: 14px; text-decoration: underline; text-underline-offset: 3px;
  text-decoration-color: var(--line-strong); min-height: 32px;
}
.link:hover { color: var(--ink); text-decoration-color: currentColor; }
.laps-scroll { overflow: auto; min-height: 0; border-top: 1px solid var(--line); scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.laps table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.laps th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  text-align: right; padding: 9px 18px; font-size: 12px; font-weight: 650; letter-spacing: .08em; text-transform: uppercase; color: var(--muted);
  box-shadow: 0 1px 0 var(--line);
}
.laps th:first-child, .laps td:first-child { text-align: left; }
.laps td { padding: 9px 18px; text-align: right; border-bottom: 1px solid var(--line); font-size: 16px; }
.laps tr:last-child td { border-bottom: 0; }
.laps td:first-child { color: var(--muted); white-space: nowrap; }
.laps td:nth-child(2) { font-weight: 650; }
.laps td:nth-child(3) { color: var(--muted); }
.laps tr.live td { color: var(--accent-text); }
.tag { display: inline-block; margin-left: 8px; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; vertical-align: 1px; }
.tag.best { background: var(--accent); color: var(--on-accent); }
.tag.worst { border: 1px solid var(--muted); color: var(--ink); }
.tag.now { border: 1px solid currentColor; }
.laps-foot { padding: 10px 18px 12px; border-top: 1px solid var(--line); color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.laps-foot:empty { display: none; }

/* footer hints */
.hints {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 22px;
  padding: 14px 16px 18px;
  color: var(--muted); font-size: 13px;
  transition: opacity .4s var(--ease);
}
.hints span { white-space: nowrap; }
.hints kbd + kbd { margin-left: 3px; }

/* quiet full-screen: chrome fades until the mouse moves */
body.quiet .top, body.quiet .hints, body.quiet .chips, body.quiet .sub { opacity: 0; }
body.quiet { cursor: none; }
.chips, .sub { transition: opacity .4s var(--ease); }

/* toast + sound hint */
.toast {
  position: fixed; left: 50%; bottom: 26px; z-index: 30;
  transform: translate(-50%, 16px);
  background: var(--c-ink); color: var(--c-bg);
  padding: 11px 18px; border-radius: 12px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow);
  opacity: 0; pointer-events: none; max-width: calc(100vw - 32px); text-align: center;
  transition: opacity .2s var(--ease), transform .2s var(--ease);
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.has-act { pointer-events: auto; display: inline-flex; align-items: center; gap: 14px; padding-right: 8px; }
.toast-act {
  height: 32px; padding: 0 12px; border-radius: 8px; font-weight: 700; font-size: 14px;
  background: var(--c-bg); color: var(--c-ink);
}
.toast-act:hover { background: color-mix(in srgb, var(--c-bg) 85%, var(--c-ink)); }
.toast:not(.show) .toast-act { visibility: hidden; }
.soundhint {
  position: fixed; left: 50%; top: 76px; transform: translateX(-50%); z-index: 25;
  background: var(--c-raise); color: var(--c-ink); border: 1px solid var(--c-line-strong);
  padding: 10px 16px; border-radius: 999px; font-weight: 600; font-size: 14px;
  box-shadow: var(--shadow); max-width: calc(100vw - 32px);
}

/* ---------- dialogs ---------- */
dialog {
  width: min(560px, calc(100vw - 24px));
  max-height: min(760px, calc(100dvh - 24px));
  padding: 0; border: 1px solid var(--c-line-strong); border-radius: 20px;
  background: var(--c-surface); color: var(--c-ink);
  box-shadow: var(--shadow);
  overflow: hidden;
}
dialog[open] { display: flex; flex-direction: column; }
dialog::backdrop { background: rgba(5, 6, 4, .62); }
.dlg-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 14px 12px 22px; border-bottom: 1px solid var(--c-line); flex: none; }
.dlg-head .icon { color: var(--c-muted); }
.dlg-head .icon:hover { color: var(--c-ink); }
.dlg-body { padding: 6px 22px 18px; overflow: auto; min-height: 0; scrollbar-width: thin; scrollbar-color: var(--c-line-strong) transparent; }
.dlg-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 22px 16px; border-top: 1px solid var(--c-line); flex: none; }
dialog .link { color: var(--c-muted); }
dialog .link:hover { color: var(--c-ink); }
dialog .btn { border-color: var(--c-line-strong); }
dialog .btn.solid { background: var(--c-ink); color: var(--c-bg); border-color: var(--c-ink); }
dialog :focus-visible { outline-color: var(--c-at); }

fieldset { border: 0; margin: 0; padding: 14px 0 6px; min-width: 0; }
fieldset + fieldset { border-top: 1px solid var(--c-line); }
legend { padding: 0; font: 700 14px/1 var(--font-display); letter-spacing: .16em; text-transform: uppercase; color: var(--c-muted); float: left; width: 100%; margin-bottom: 6px; }
legend + * { clear: both; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 52px; padding: 4px 0; }
.row-label { font-weight: 600; flex: 1 1 auto; min-width: 0; }
.row-label small { display: block; font-weight: 500; font-size: 13px; color: var(--c-muted); }
.row-label small:empty { display: none; }
.inline { display: inline-flex; align-items: center; gap: 10px; }
.inline.grow { flex: 0 1 260px; }
.inline.grow input { flex: 1; min-width: 0; }
output { min-width: 3.2em; text-align: right; font-variant-numeric: tabular-nums; color: var(--c-muted); font-weight: 600; }

select, input[type="number"] {
  height: 40px; border-radius: 10px; border: 1px solid var(--c-line-strong); background: var(--c-raise); color: var(--c-ink);
  padding: 0 12px; font-weight: 600;
}
input[type="number"] { width: 92px; text-align: right; font-variant-numeric: tabular-nums; }
select { padding-right: 8px; max-width: 200px; }
input[type="range"] { accent-color: var(--c-at); height: 28px; }

.seg { display: inline-flex; padding: 3px; border: 1px solid var(--c-line-strong); border-radius: 12px; background: var(--c-raise); }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.seg span { display: block; padding: 7px 14px; border-radius: 9px; font-weight: 600; font-size: 14px; color: var(--c-muted); }
.seg input:checked + span { background: var(--c-ink); color: var(--c-bg); }
.seg input:focus-visible + span { outline: 2px solid var(--c-at); outline-offset: 2px; }

.swatches { display: inline-flex; gap: 10px; }
.swatches label { position: relative; width: 32px; height: 32px; }
.swatches input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.swatches span { display: block; width: 32px; height: 32px; border-radius: 50%; border: 2px solid var(--c-surface); box-shadow: 0 0 0 1px var(--c-line-strong); }
.swatches input:checked + span { box-shadow: 0 0 0 2px var(--c-ink); }
.swatches input:focus-visible + span { outline: 2px solid var(--c-at); outline-offset: 4px; }
[data-sw="lime"] { background: #c8f542; }
[data-sw="amber"] { background: #ffb224; }
[data-sw="cyan"] { background: #5fe0f0; }
[data-sw="rose"] { background: #ff8097; }
[data-sw="mono"] { background: linear-gradient(135deg, #f1f4e8 0 50%, #15170f 50% 100%); }

.switch {
  appearance: none; -webkit-appearance: none; flex: none; margin: 0; cursor: pointer;
  width: 50px; height: 30px; border-radius: 999px; background: var(--c-line-strong); position: relative;
  transition: background-color .15s;
}
.switch::before {
  content: ""; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%;
  background: var(--c-surface); transition: transform .15s var(--ease);
}
.switch:checked { background: var(--c-at); }
.switch:checked::before { transform: translateX(20px); }
.switch:disabled { opacity: .45; cursor: default; }

.keys { margin: 8px 0 0; }
.keys > div { display: grid; grid-template-columns: 132px 1fr; gap: 12px; align-items: baseline; padding: 9px 0; border-bottom: 1px solid var(--c-line); }
.keys > div:last-child { border-bottom: 0; }
.keys dt { white-space: nowrap; }
.keys dd { margin: 0; color: var(--c-ink); }
.keys kbd, .tip code { color: var(--c-ink); border-color: var(--c-line-strong); }
.tip { margin-top: 12px; color: var(--c-muted); font-size: 14px; }
.tip code { font: 600 13px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; padding: 1px 5px; border: 1px solid var(--c-line-strong); border-radius: 5px; }

.noscript { position: fixed; inset: auto 0 0 0; padding: 16px; text-align: center; background: var(--c-a); color: var(--c-ao); font-weight: 700; }

/* ---------- responsive ---------- */
@media (max-width: 1020px) {
  main.with-laps { grid-template-columns: minmax(0, 1fr); align-content: start; padding-top: 8px; padding-bottom: 12px; }
  main.with-laps .laps { max-width: 620px; max-height: none; }
  main.with-laps .laps-scroll { max-height: 46vh; }
  main.with-laps { --fs-max: 26vh; }
  main.with-laps .chips:empty { display: none; }
}
@media (max-width: 760px) {
  .top { grid-template-columns: auto 1fr; row-gap: 10px; padding-top: 10px; }
  .modes { grid-column: 1 / -1; grid-row: 2; justify-self: center; width: 100%; max-width: 420px; }
  .modes button { flex: 1; justify-content: center; padding: 0 8px; height: 44px; }
  .hints { display: none; }
  .btn { min-width: 0; padding: 0 14px; font-size: 18px; height: 56px; }
  .btn.primary { min-width: 0; padding: 0 26px; font-size: 24px; height: 64px; }
  .btn.primary kbd { display: none; }
  .controls { gap: 8px; grid-template-columns: minmax(0, 1fr) minmax(0, 1.5fr) minmax(0, 1fr); }
  .controls #btn-left, .controls #btn-right, .controls #btn-main { justify-self: stretch; }
  .laps-actions .link { min-height: 44px; padding: 0 4px; }
  .chip { height: 44px; padding: 0 16px; }
  main { padding-bottom: 20px; }
  :root { --fs-max: 30vh; }
  .soundhint { top: 126px; }
}
@media (max-width: 400px) {
  .brand span { display: none; }
  .icon { width: 40px; }
  .laps td, .laps th { padding-left: 12px; padding-right: 12px; }
}
/* short windows (small laptop split view, landscape phone) */
@media (max-height: 620px) {
  :root { --fs-max: 34vh; }
  .hints { display: none; }
  .top { padding-top: 8px; padding-bottom: 6px; }
  .btn { height: 48px; font-size: 18px; }
  .btn.primary { height: 54px; font-size: 22px; }
  .chip { height: 34px; }
  .ruler { height: 22px; margin-bottom: 6px; }
  main { padding-bottom: 10px; }
}
@media (max-height: 440px) {
  :root { --fs-max: 22vh; }
  .status { font-size: 13px; min-height: 14px; }
  .status[data-state="done"] { font-size: 18px; min-height: 18px; }
  .face { margin-top: 4px; }
  .display-wrap { margin-bottom: 5px; }
  .ruler { height: 16px; margin-bottom: 4px; }
  .btn { height: 42px; font-size: 17px; }
  .btn.primary { height: 46px; font-size: 20px; }
  .top { padding-top: 5px; padding-bottom: 3px; }
  .controls { margin-top: 6px; }
  .chips { margin-top: 8px; flex-wrap: nowrap; overflow-x: auto; justify-content: safe center; max-width: 100%; scrollbar-width: none; padding: 1px; }
  .chips::-webkit-scrollbar { display: none; }
  .chip { flex: none; }
  .sub { min-height: 18px; font-size: 13px; }
}
@media (max-height: 440px) and (max-width: 760px) {
  .top { grid-template-columns: auto 1fr auto; }
  .modes { grid-column: auto; grid-row: auto; width: auto; }
  .modes button { height: 36px; padding: 0 12px; font-size: 14px; }
  .brand span { display: none; }
  .tools #btn-help { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
@media (forced-colors: active) {
  .ticks i.on { background: Highlight; }
  .btn.primary { border: 2px solid ButtonText; }
}
