/* =========================================================================
   Timer: Calc's look (paper, ink, one orange block, hairlines, Geist Mono),
   set up for workouts. Setup: the workout's length over a number pad.
   Running: the clock, a phase chip and a tick meter over three controls.
   ========================================================================= */

:root {
  --paper: #F2F1ED;
  --ink: #121211;
  --ink-2: #5E5D58;
  --ink-3: rgba(18, 18, 17, .26);
  --rule: rgba(18, 18, 17, .13);
  --hover: rgba(18, 18, 17, .035);
  --flood: rgba(18, 18, 17, .12);
  --accent: #FF5A00;
  --accent-text: #BF4300;
  --on-accent: #121211;
  --accent-flood: rgba(18, 18, 17, .16);

  --f-num: "Geist Mono", ui-monospace, monospace;
  --f-text: "Geist", system-ui, sans-serif;
  --w-num: 200;
  --w-key: 300;
  --w-adj: 0;
  --track-num: -0.04em;
  --cap-track: .14em;

  --s1: 4px; --s2: 8px; --s3: 12px; --s4: 16px; --s5: 24px; --s6: 32px; --s7: 48px;
  --g: clamp(16px, 2.4vw, 36px);
  --kp-x: var(--g);
  --kp-y: clamp(10px, 1.4vmin, 18px);
  --fn-size: clamp(17px, min(2.8vw, 3.6vh), 30px);
  --key-size: clamp(20px, min(3.6vw, 4.6vh), 40px);
  --foot-h: 32px;

  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);

  --fs: 120px;          /* the clock's size, set by JS (measured to fit) */
  --tick-on: var(--ink);
  color-scheme: light;
}

:root[data-theme="dark"] {
  --paper: #0E0E0D;
  --ink: #EDEBE6;
  --ink-2: #9C9A94;
  --ink-3: rgba(237, 235, 230, .24);
  --rule: rgba(237, 235, 230, .13);
  --hover: rgba(237, 235, 230, .04);
  --flood: rgba(237, 235, 230, .14);
  --accent: #F2560C;
  --accent-text: var(--accent);
  --on-accent: #0E0E0D;
  --accent-flood: rgba(14, 14, 13, .18);
  --w-adj: -20;
  color-scheme: dark;
}

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

html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }

body {
  position: relative;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  grid-template-columns: minmax(0, 1fr);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--f-text);
  font-size: 12px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

button {
  font: inherit; color: inherit; background: none; border: 0; margin: 0; padding: 0;
  cursor: pointer; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
button:focus, button:focus-visible, a:focus, a:focus-visible { outline: none; }
button[hidden] { 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;
}

.tiny {
  font-family: var(--f-text);
  font-size: 10px;
  line-height: 1;
  letter-spacing: var(--cap-track);
  text-transform: uppercase;
  color: var(--ink-2);
}

/* ------------------------------ layout ---------------------------------- */

main { min-height: 0; display: grid; }

.tm {
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 54fr) minmax(0, 46fr);
}
.tm > .display { grid-row: 1; grid-column: 1; }
.tm > .keys, .tm > .ctrls { grid-row: 2; grid-column: 1; }
/* running: the clock takes the screen, the controls one band along the bottom */
.tm:not([data-state="setup"]) { grid-template-rows: minmax(0, 1fr) clamp(76px, 17vh, 150px); }
.keys[hidden], .ctrls[hidden] { display: none; }

/* ------------------------------ display --------------------------------- */

.display {
  --pad-t: calc(var(--safe-t) + var(--g));
  --pad-r: calc(var(--safe-r) + var(--g));
  --pad-b: var(--s4);
  --pad-l: calc(var(--safe-l) + var(--g));
  position: relative;
  min-height: 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: var(--pad-t) var(--pad-r) var(--pad-b) var(--pad-l);
  overflow: hidden;
}

/* the figure: caption, clock, meter, bottom-aligned like Calc's answer */
.figure {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  position: relative;
}

.cap {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--s3);
  min-height: 26px;
  margin: var(--s3) 0 clamp(6px, calc(var(--fs) * .04), 20px);
  font-size: clamp(13px, 1.25vw + 6px, 18px);
  font-weight: 300;
  line-height: 1.3;
  color: var(--ink-2);
  white-space: nowrap;
  overflow: hidden;
}
/* one input: its name on the left, like a field's label; the line under the
   display is the active field's orange line (the number is the field) */
.cap__label {
  flex: none;
  margin-right: auto;
  font-family: var(--f-text);
  font-size: 10px;
  letter-spacing: var(--cap-track);
  text-transform: uppercase;
  color: var(--ink);
}
.cap__label:empty, .tm:not([data-state="setup"]) .cap__label { display: none; }
.tm[data-state="setup"] .display.is-direct::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2px;
  background: var(--accent); pointer-events: none;
}
.cap__text { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; text-align: right; }
.cap__round {
  flex: none;
  font-family: var(--f-text);
  font-size: clamp(10px, .4vw + 8.5px, 13px);
  letter-spacing: var(--cap-track);
  text-transform: uppercase;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.cap__round b { font-weight: 400; color: var(--ink); }
.cap__round:empty { display: none; }
.tm:not([data-state="setup"]) .cap { justify-content: space-between; }
.tm:not([data-state="setup"]) .cap__text { display: none; }

/* the phase chip: work is the orange block, rest the ink block (an inversion),
   get ready an outline. One accent, never a full-screen flood. */
.phase {
  flex: none;
  display: inline-flex;
  align-items: center;
  height: clamp(24px, 1.2vw + 18px, 34px);
  padding: 0 calc(clamp(8px, .6vw + 6px, 14px) - var(--cap-track)) 0 clamp(8px, .6vw + 6px, 14px);
  font-family: var(--f-text);
  font-size: clamp(11px, .5vw + 9px, 15px);
  font-weight: 500;
  line-height: 1;
  letter-spacing: var(--cap-track);
  text-transform: uppercase;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px var(--ink);
  color: var(--ink);
}
.phase[hidden] { display: none; }
.phase[data-k="work"], .phase[data-k="done"] { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.phase[data-k="rest"], .phase[data-k="setrest"] { background: var(--ink); color: var(--paper); box-shadow: none; }

.figure-inner {
  position: relative;
  flex: none;
  display: flex;
  justify-content: flex-end;
  max-width: 100%;
}
.fig-scale { display: flex; align-items: flex-start; transform-origin: 100% 100%; }

.num {
  font-family: var(--f-num);
  font-weight: calc(var(--w-num) + var(--w-adj));
  font-variant-numeric: tabular-nums lining-nums;
  font-feature-settings: "tnum" 1, "lnum" 1;
  letter-spacing: var(--track-num);
  white-space: nowrap;
  font-size: var(--fs);
  line-height: 1;
  display: flex;
  align-items: flex-start;
  margin-right: -0.02em;
  transition: opacity .2s ease;
}
.slot {
  position: relative;
  display: block;
  height: 1em;
  overflow: hidden;
  flex: none;
}
.slot .g, .reel > span { display: block; height: 1em; line-height: 1; }
.reel { display: flex; flex-direction: column; }
/* the old characters leaving, lifted into an overlay where they were */
.num-out {
  position: absolute; inset: 0; pointer-events: none;
  font-family: var(--f-num);
  font-weight: calc(var(--w-num) + var(--w-adj));
  font-variant-numeric: tabular-nums lining-nums;
  letter-spacing: var(--track-num);
  line-height: 1;
  white-space: nowrap;
}
.num-out .slot { position: absolute; }
.slot.is-ghost { color: var(--ink-3); }
.slot.is-sep { margin-inline: -0.15em; }
.slot.is-cs { color: var(--ink-3); }
.num.is-blank .slot { color: var(--ink-3); }
.is-paused .num { animation: blink 1.1s steps(1, end) infinite; }
@keyframes blink { 50% { opacity: .28; } }

/* Calc's orange dot: beside the clock while it runs, a beat each second;
   ink in rest and get-ready, orange in work */
.dot {
  flex: none;
  width: clamp(8px, calc(var(--fs) * .085), 26px);
  height: clamp(8px, calc(var(--fs) * .085), 26px);
  border-radius: 50%;
  background: var(--accent);
  margin-right: clamp(6px, calc(var(--fs) * .05), 18px);
  margin-top: calc(var(--fs) * .2);
  transform: scale(0);
  opacity: 0;
  transition: background-color .2s ease;
}
.tm:not([data-state="setup"]) .dot { transform: none; opacity: 1; }
.tm[data-k="rest"] .dot, .tm[data-k="setrest"] .dot, .tm[data-k="prep"] .dot { background: var(--ink); }
.dot.is-beat { animation: beat .5s ease-out; }
@keyframes beat { 0% { opacity: 1; } 40% { opacity: .2; } 100% { opacity: 1; } }
.is-paused .dot { opacity: .3; }

/* the tick meter: hairline ticks across the width; the run so far is inked */
.meter { flex: none; margin-top: clamp(10px, calc(var(--fs) * .08), 28px); display: none; }
.tm:not([data-state="setup"]) .meter { display: block; }
.meter__ticks {
  height: clamp(18px, 3.2vh, 34px);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
}
.tick { flex: none; width: 1px; height: 55%; background: var(--rule); transition: background-color .15s ease; }
.tick:nth-child(5n + 1) { height: 100%; }
.tick.is-on { background: var(--tick-on); }
.tm[data-k="work"] { --tick-on: var(--accent); }
.meter__row {
  display: flex;
  justify-content: space-between;
  margin-top: var(--s2);
  font-size: 10px;
  line-height: 1;
  letter-spacing: var(--cap-track);
  text-transform: uppercase;
  color: var(--ink-2);
  font-variant-numeric: tabular-nums;
}
.meter__row b { font-weight: 400; color: var(--ink); }

/* ------------------------------ fields ---------------------------------- */

.fields {
  flex: none;
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  margin: var(--s3) calc(var(--pad-r) * -1) calc(var(--pad-b) * -1) calc(var(--pad-l) * -1);
}
.fields[hidden] { display: none; }
.cells { display: grid; grid-template-columns: repeat(var(--cols), minmax(0, 1fr)); --cols: 3; }
.cells[data-n="1"] { --cols: 1; }
.cells[data-n="2"] { --cols: 2; }
.cells[data-n="5"] { --cols: 5; }
.field {
  position: relative;
  display: block;
  min-width: 0;
  padding: var(--kp-y) var(--kp-x);
  border-left: 1px solid var(--rule);
  border-top: 1px solid var(--rule);
  text-align: left;
}
.cells .field:first-child { border-left: 0; padding-left: calc(var(--kp-x) + var(--safe-l)); }
.cells .field:last-child { padding-right: calc(var(--kp-x) + var(--safe-r)); }
@media (max-width: 639px) {
  /* five on a phone: three over two */
  .cells[data-n="5"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .cells[data-n="5"] .field:nth-child(-n + 3) { grid-column: span 2; }
  .cells[data-n="5"] .field:nth-child(n + 4) { grid-column: span 3; }
  .cells[data-n="5"] .field:nth-child(4) { border-left: 0; padding-left: calc(var(--kp-x) + var(--safe-l)); }
  .cells[data-n="5"] .field:nth-child(3) { padding-right: calc(var(--kp-x) + var(--safe-r)); }
}
.field__in { display: flex; flex-direction: column; gap: clamp(10px, 1.6vh, 20px); min-width: 0; }
.field::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0;
  height: 2px; background: var(--accent); pointer-events: none;
  transform: scaleX(0); transform-origin: 100% 50%;
  transition: transform .32s cubic-bezier(.6, 0, .3, 1);
}
.field.is-on::after { transform: none; transform-origin: 0 50%; transition: transform .38s .07s cubic-bezier(.2, .7, .2, 1); }
.field.is-on { background: var(--hover); }
.field.is-on .field__l { color: var(--ink); }
.field__l {
  align-self: flex-start;
  font-size: 10px; line-height: 1; letter-spacing: var(--cap-track); text-transform: uppercase;
  color: var(--ink-2); white-space: nowrap;
}
.field__row {
  align-self: stretch;
  min-width: 0;
  display: flex;
  align-items: baseline;
  justify-content: flex-end;
  font-family: var(--f-num);
  font-weight: calc(var(--w-key) + var(--w-adj));
  font-size: var(--key-size);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-right: -0.03em;
}
.field__row .gh { color: var(--ink-3); }
.field__row .ph { color: var(--ink-3); }
.field__row .cl { margin-inline: -0.12em; }
.field__u { margin-left: .35em; font-family: var(--f-text); font-size: 10px; letter-spacing: var(--cap-track); text-transform: uppercase; color: var(--ink-2); }
/* switching modes: the old strip, laid over the new one while its words roll out */
.cells { position: relative; }
.cells--old { position: absolute; left: 0; right: 0; z-index: 1; pointer-events: none; }
.cells--old .field, .cells--old .field.is-on { background: none; border-color: transparent; }
.cells--old .field::after { display: none; }
.cells--old .field, .cells.is-rolling .field { overflow: hidden; }
@media (hover: hover) and (pointer: fine) { .field:not(.is-on):hover .field__l { color: var(--ink); } }

/* ------------------------------ keys ------------------------------------ */

.keys {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(4, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
}
.ctrls {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  border-top: 1px solid var(--rule);
}
.ctrls.is-two { grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); }

.key {
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: var(--kp-y) var(--kp-x);
  border-left: 1px solid var(--rule);
  border-top: 1px solid var(--rule);
  min-width: 0;
  min-height: 0;
  isolation: isolate;
}
.keys .key:nth-child(3n + 1) { border-left: 0; padding-left: calc(var(--kp-x) + var(--safe-l)); }
.keys .key:nth-child(3n) { padding-right: calc(var(--kp-x) + var(--safe-r)); }
.keys .key:nth-child(-n + 3) { border-top: 0; }
.ctrls .key { border-top: 0; padding-bottom: var(--kp-y); }
.ctrls .key:first-child { border-left: 0; padding-left: calc(var(--kp-x) + var(--safe-l)); }
.ctrls .key:last-child { padding-right: calc(var(--kp-x) + var(--safe-r)); }

.key__l {
  position: relative;
  z-index: 1;
  font-family: var(--f-num);
  font-weight: calc(var(--w-key) + var(--w-adj));
  font-size: var(--key-size);
  line-height: 1;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
.key__l--word { font-size: var(--fn-size); letter-spacing: -0.01em; }
.key__l--icon { display: block; height: 1em; font-size: var(--fn-size); }
.key__l--icon svg { display: block; width: 1.3em; height: .87em; margin-top: .1em; overflow: visible; }
.key__c {
  position: absolute;
  z-index: 1;
  right: var(--kp-x);
  bottom: var(--kp-y);
  font-family: var(--f-text);
  font-size: 10px;
  line-height: 1;
  letter-spacing: var(--cap-track);
  text-transform: uppercase;
  color: var(--ink-2);
  margin-right: calc(var(--cap-track) * -1);
  opacity: .7;
}
.ctrls .key:last-child .key__c { right: calc(var(--kp-x) + var(--safe-r)); }
@media (hover: none) and (pointer: coarse) { .key__c { display: none; } }

.ink { position: absolute; inset: 0; z-index: 0; pointer-events: none; background: var(--flood); opacity: 0; }
.key:focus-visible { background: var(--hover); }
@media (hover: hover) and (pointer: fine) {
  .key:hover { background: var(--hover); }
  .key--go:hover { background: var(--accent); }
}

/* the single orange block: Start, Pause, Again */
.key--go { background: var(--accent); color: var(--on-accent); border-color: transparent; }
.key--go .key__c { color: var(--on-accent); opacity: .6; }
.key--go .ink { background: var(--accent-flood); }
.key--go:focus-visible { box-shadow: inset 0 0 0 100vmax rgba(0, 0, 0, .08); }
/* paused: Resume is the ink block, so a glance tells paused from running. Like
   Calc's pending operator, the ink spreads from the finger and stays printed. */
.pfill { position: absolute; inset: 0; z-index: 0; pointer-events: none; background: var(--ink); opacity: 0; transition: opacity .12s ease; }
.is-paused #goBtn .pfill { opacity: 1; transition: none; }
.is-paused #goBtn { color: var(--paper); transition: color 0s 90ms; }
.is-paused #goBtn .key__c { color: var(--paper); transition: color 0s 90ms; }
.is-paused #goBtn .ink { background: rgba(242, 241, 237, .16); }
#endBtn.is-armed .key__l { color: var(--accent-text); }

/* ------------------------------ menu ------------------------------------ */

.menu {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  grid-template-rows: auto repeat(var(--rows, 7), minmax(0, 1fr));
  background: var(--paper);
  --mi-x: calc(var(--kp-x) * 2);
}
.menu[hidden] { display: none; }
.menu__bar {
  display: flex; align-items: center; justify-content: space-between; gap: var(--s4);
  height: calc(44px + var(--safe-t));
  padding: var(--safe-t) calc(var(--kp-x) + var(--safe-r)) 0 calc(var(--kp-x) + var(--safe-l));
  border-bottom: 1px solid var(--rule);
}
.menu__title { font-size: 10.5px; line-height: 1; letter-spacing: var(--cap-track); text-transform: uppercase; color: var(--ink-2); }
.menu__x { display: grid; place-items: center; width: 44px; height: 44px; margin-right: -17.5px; color: var(--ink-2); }
.menu__x svg { fill: none; stroke: currentColor; stroke-width: 1.4; stroke-linecap: round; }
.menu__x:focus-visible { color: var(--ink); background: var(--hover); }
.mitem {
  position: relative;
  display: flex; flex-direction: column; justify-content: center; align-items: flex-start;
  gap: clamp(4px, .8vh, 9px);
  text-align: left; min-height: 0; overflow: hidden;
  padding: var(--s1) calc(var(--kp-x) + var(--safe-r)) var(--s1) calc(var(--mi-x) + var(--safe-l));
  border-top: 1px solid var(--rule);
}
.menu__bar + .mitem { border-top: 0; }
.mitem:last-child { padding-bottom: calc(var(--s1) + var(--safe-b)); }
.mitem::before {
  content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; z-index: 1;
  background: var(--ink); transform: scaleX(0); transform-origin: 0 50%;
  transition: transform .16s cubic-bezier(.2, .8, .2, 1);
}
.mitem:focus-visible::before { transform: none; }
.mitem[aria-current="true"]::before { background: var(--accent); transform: none; transition: none; }
.mitem__l {
  display: block;
  font-family: var(--f-num);
  font-weight: calc(var(--w-key) + var(--w-adj));
  font-size: clamp(18px, min(6vw, (100vh - 44px) / var(--rows, 7) * .3), 40px);
  line-height: 1; letter-spacing: -0.03em; margin-left: -0.04em;
  color: color-mix(in srgb, var(--ink) 90%, transparent);
}
.mitem[aria-current="true"] .mitem__l, .mitem:focus-visible .mitem__l { color: var(--ink); }
.mitem__c { display: block; font-size: 10px; line-height: 1; letter-spacing: var(--cap-track); text-transform: uppercase; color: var(--ink-2); }
.mitem__l, .mitem__c { transition: translate .24s cubic-bezier(.2, .8, .2, 1); }
.mitem:focus-visible .mitem__l, .mitem:focus-visible .mitem__c { translate: 6px 0; }
.mitem:focus-visible { background: var(--hover); }
.mitem__k {
  position: absolute; top: 50%; right: calc(var(--kp-x) + var(--safe-r)); transform: translateY(-50%);
  display: grid; place-items: center; min-width: 26px; height: 26px; padding: 0 6px;
  border: 1px solid var(--rule);
  font-size: 11px; line-height: 1; color: var(--ink-2);
}
@media (hover: none) and (pointer: coarse) { .mitem__k { display: none; } }
@media (hover: hover) and (pointer: fine) {
  .mitem:hover::before { transform: none; }
  .mitem:hover .mitem__l, .mitem:hover .mitem__c { translate: 6px 0; }
  .mitem:hover .mitem__l { color: var(--ink); }
  .menu__x:hover { color: var(--ink); }
}

/* ------------------------------ footer ---------------------------------- */

.foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--s4);
  min-height: calc(var(--foot-h) + var(--safe-b));
  padding: 0 calc(var(--safe-r) + var(--g)) var(--safe-b) calc(var(--safe-l) + var(--g));
  border-top: 1px solid var(--rule);
  font-size: 10.5px;
  color: var(--ink-2);
  letter-spacing: .01em;
}
.foot__credit { flex: none; display: inline-flex; align-items: center; height: var(--foot-h); gap: .3em; margin: 0; white-space: nowrap; }
.credit__link { display: inline-flex; align-items: center; height: 100%; gap: .3em; color: var(--ink-2); text-decoration: none; }
.credit__from { opacity: .45; }
.foot__ctl { display: flex; align-items: center; gap: var(--s5); flex: none; }
.ctl { display: inline-flex; align-items: center; }
.ctl[hidden] { display: none; }
.ctl--cmd { height: var(--foot-h); gap: 6px; white-space: nowrap; color: var(--ink-2); }
.cmd__key { font: inherit; opacity: .45; }
.cmd__chev, .cmd__ico { display: none; flex: none; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; }
#soundBtn[aria-pressed="false"] .cmd__name { text-decoration: line-through; text-decoration-thickness: 1px; }
@media (hover: none) and (pointer: coarse) {
  .cmd__key { display: none; }
  .foot { font-size: 12px; }
  #modeMenuBtn, #themeBtn, #soundBtn { color: var(--ink); }
  .cmd__chev { display: block; width: .62em; height: .9em; margin-left: .2em; stroke-width: 1.3; }
  #themeBtn, #soundBtn { gap: 5px; }
  :root:not([data-theme="dark"]) .cmd__ico--sun, :root[data-theme="dark"] .cmd__ico--moon,
  #soundBtn[aria-pressed="true"] .cmd__ico--on, #soundBtn[aria-pressed="false"] .cmd__ico--off { display: block; width: 1.25em; height: 1.25em; stroke-width: 1.6; }
  #soundBtn .cmd__name, #themeBtn .cmd__name { display: none; }   /* the icons say it */
  #soundBtn[aria-pressed="false"] { color: var(--ink-2); }
}
@media (hover: hover) and (pointer: fine) {
  .ctl--cmd:hover, .credit__link:hover { color: var(--ink); }
}
.ctl--cmd:focus-visible, .credit__link:focus-visible { color: var(--ink); }
.ctl--cmd:focus-visible .cmd__name, .credit__link:focus-visible { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }
/* tight footers (app.js sets data-fit): hotkeys go, then the credit stacks */
.foot[data-fit="1"] .cmd__key, .foot[data-fit="2"] .cmd__key { display: none; }
.foot[data-fit="1"] .foot__ctl, .foot[data-fit="2"] .foot__ctl { gap: var(--s4); }
.foot[data-fit="2"] .foot__credit { flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; line-height: 1.1; }
.foot[data-fit="2"] .credit__link { height: auto; }
/* running: Reset steps out */
.tm-run #clearBtn { display: none; }

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

@media (max-height: 520px) {
  .cap { min-height: 22px; margin-top: 0; }
  .meter__row { display: none; }
  .meter { margin-top: 8px; }
  .meter__ticks { height: 14px; }
  .tm:not([data-state="setup"]) { grid-template-rows: minmax(0, 1fr) 64px; }
}

@media (prefers-reduced-motion: reduce) {
  .bar-ico, .field::after, .field.is-on::after, .mitem::before, .mitem__l, .mitem__c, .dot { transition: none; }
  .dot.is-beat, .is-paused .num { animation: none; }
}

/* ------------------------------ theme transition ------------------------ */

/* D: the new theme swipes in from the right (app.js swipe); the orange line on
   its edge is a canvas above both themes, in its own view-transition group */
.fx {
  position: fixed; left: 0; top: 0; z-index: 30;
  display: none; pointer-events: none;
  image-rendering: pixelated;
  view-transition-name: fx;
}
.fx-run .fx { display: block; }
::view-transition-group(fx), ::view-transition-old(fx), ::view-transition-new(fx) { animation: none; }
::view-transition-old(fx) { display: none; }
::view-transition-old(root), ::view-transition-new(root) { animation: none; mix-blend-mode: normal; }
::view-transition-new(root) { z-index: 2; }
::view-transition-old(root) { z-index: 1; }
