/* ---------- Fonts ----------
   Preloaded in index.html. "block" holds text for a moment instead of flashing
   a fallback font and swapping. The 500 file also serves weight 400. */
@font-face { font-family: "Krona One"; src: url(../ds/fonts/KronaOne-Regular.woff2) format("woff2"); font-weight: 400; font-display: block; }
@font-face { font-family: "IBM Plex Mono"; src: url(../ds/fonts/IBMPlexMono-500.woff2) format("woff2"); font-weight: 400 500; font-display: block; }
@font-face { font-family: "IBM Plex Mono"; src: url(../ds/fonts/IBMPlexMono-600.woff2) format("woff2"); font-weight: 600; font-display: block; }
@font-face { font-family: "IBM Plex Mono"; src: url(../ds/fonts/IBMPlexMono-700.woff2) format("woff2"); font-weight: 700; font-display: block; }

/* ---------- Tokens ----------
   App variables mapped onto the Seegnalz design tokens (ds/seegnalz-tokens.css,
   loaded before this file). Seegnalz is light only. No shadows; every corner is 4px.
   --danger is reserved for destructive actions. */
:root {
  color-scheme: light;
  --canvas: var(--page);
  --panel: var(--color-bg-surface);
  --hover: var(--primitive-gray-100);
  --field: var(--color-bg-surface);
  --fg: var(--color-text-primary);
  --muted: var(--color-text-secondary);
  --faint: var(--color-text-secondary);
  --line: var(--color-border-default);
  --blue: var(--color-action-primary);
  --blue-press: #5236e0;
  --blue-soft: var(--color-selection-on-subtle);
  --on-blue: var(--color-text-inverse);
  --fill: var(--color-accent-blue);
  --danger: var(--color-action-danger);
  --stroke: var(--stroke-default);
  --focus: var(--color-text-primary); /* keyboard focus ring: black, like the rest of the UI */
  --font: var(--font-mono);
  --mono: var(--font-mono);
  --panel-w: 264px;
  --sw: 26px;      /* color swatch size: backgrounds and custom palette */
  --sw-gap: 6px;
  --r-panel: 4px;
  --r: 4px;
}

/* ---------- Base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font: 500 13px/18px var(--font);
  letter-spacing: 0.005em;
  background-color: var(--canvas);
  background-image: radial-gradient(circle at 1px 1px, rgba(77, 162, 255, 0.55) 1px, transparent 1.2px);
  background-size: 18px 18px;
  background-position: 5px 8px;
  color: var(--fg);
  accent-color: var(--blue);
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; letter-spacing: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: var(--r); }
svg { flex-shrink: 0; }
[hidden] { display: none !important; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.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;
}
.skip {
  position: absolute; left: 8px; top: -100px; z-index: 100;
  background: var(--fg); color: var(--panel); padding: 6px 10px; border-radius: var(--r);
}
.skip:focus { top: 8px; }

/* ---------- Shell: canvas fills the window, panels float on it ---------- */
body { height: 100vh; height: 100dvh; overflow: hidden; }
.app {
  height: 100%;
  display: grid;
  grid-template-columns: var(--panel-w) minmax(0, 1fr) var(--panel-w);
  gap: 8px;
  padding: 8px;
  margin: 0;
}
.panel {
  min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  background: var(--panel);
  border: var(--stroke) solid var(--line);
  border-radius: var(--r-panel);
  scrollbar-width: thin;
  scrollbar-color: var(--faint) transparent;
}
.panel-top {
  position: sticky; top: 0; z-index: 2;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 48px; padding: 8px 8px 8px 12px;
  border-bottom: var(--stroke) solid var(--line);
  border-radius: var(--r-panel) var(--r-panel) 0 0;
}
#right .panel-top { justify-content: flex-end; }

/* Frame: black border, square corners, a small solid square on each corner.
   Used on the side panels and the dock. Panels don't scroll themselves
   (an inner .frame-scroll does) so the marks can sit outside the edge. */
.frame, .dock-card.frame { position: relative; border-color: #000; border-radius: 0; }
.panel.frame { overflow: visible; display: flex; flex-direction: column; }
.frame-scroll {
  flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain;
  scrollbar-width: thin; scrollbar-color: var(--faint) transparent;
}
.frame .panel-top { border-radius: 0; background: var(--panel); }
.frame::before {
  content: ""; position: absolute; inset: -4px; z-index: 3; pointer-events: none;
  --sq: linear-gradient(#000 0 0);
  background:
    var(--sq) left top / 6px 6px no-repeat,
    var(--sq) right top / 6px 6px no-repeat,
    var(--sq) left bottom / 6px 6px no-repeat,
    var(--sq) right bottom / 6px 6px no-repeat;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; min-width: 0; }
.brand img { border-radius: var(--r); }
.brand-text { display: grid; line-height: 14px; }
.brand-text strong { font: 400 14px/18px var(--font-display); }
.brand-text span { color: var(--muted); }

/* ---------- Stage ---------- */
.stage {
  position: relative; min-width: 0; min-height: 0;
  display: flex; flex-direction: column;
}
.canvas {
  flex: 1; min-height: 0; margin: 0;
  padding: 16px 24px 12px;
  display: grid; place-items: center;
  container-type: size;
  line-height: 0;
}
.canvas svg {
  display: block;
  width: min(100cqw, 100cqh * var(--ar, 0.8947));
  height: auto;
  aspect-ratio: var(--ar, 0.8947);
}

.art { display: contents; }
.canvas > .art > svg { border: var(--stroke) solid var(--line); border-radius: var(--r); }

/* Dock under the canvas: the seed toolbar. */
.dock { flex: none; align-self: center; width: min(100%, 540px); display: grid; gap: 6px; margin-bottom: 4px; }
.dock-card { background: var(--panel); border: var(--stroke) solid var(--line); border-radius: var(--r-panel); }
.toolbar { display: flex; align-items: center; justify-content: space-between; gap: 4px; padding: 4px; white-space: nowrap; }
.tb-group { display: flex; align-items: center; gap: 2px; }
.tb-group + .tb-group { padding-left: 6px; border-left: 1px solid var(--line); }
.tb-label { padding: 0 6px 0 8px; color: var(--muted); }

/* Headings: Krona One */
.sec h2, .modal-head h2 { font: 400 13px/18px var(--font-display); text-transform: uppercase; letter-spacing: 0.02em; }

/* ---------- Buttons: square, ink outline, uppercase ---------- */
.btn, .icon-btn, .tb-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: var(--stroke) solid var(--line); border-radius: var(--r); cursor: pointer;
  background: var(--color-action-secondary); color: var(--fg);
  font: 600 12px/16px var(--font); text-transform: uppercase;
}
/* Icons come from public/icons/ and carry their own line weight and fills; they draw in the text color. */
.btn svg, .icon-btn svg, .tb-btn svg, .ico { width: 18px; height: 18px; color: currentColor; }
/* The cross is drawn small inside its box, so it shows larger to match the other icons */
#how-close svg, #export-close svg { width: 26px; height: 26px; }
.icon-btn { width: 34px; height: 34px; }
.btn, .tb-btn { height: 34px; padding: 0 12px; }
/* The panel-top and modal close buttons sit on tinted bars. */
.panel-top .icon-btn, .modal-head .icon-btn { background: var(--panel); }
.btn:hover, .icon-btn:hover, .tb-btn:hover { background: var(--hover); }
.btn:active, .icon-btn:active, .tb-btn:active { background: var(--primitive-gray-300); }
.btn-primary { background: var(--blue); color: var(--on-blue); border: 0px !important}
.btn-primary:hover { background: var(--primitive-gray-700); }
.btn-primary:active { background: var(--color-action-primary-pressed); color: var(--fg); }
.btn-wide { width: 100%; margin-top: 8px; }

/* ---------- Sections ---------- */
.sec { padding: 8px 16px 18px; border-bottom: var(--stroke) solid var(--line); }
.sec:last-child { border-bottom: 0; }
.sec h2 { display: flex; align-items: center; min-height: 36px; }
.sub {
  display: block; padding: 0; margin: 14px 0 6px;
  font-size: 12px; font-weight: 600; color: var(--muted);
}
.sec > h2 + fieldset > legend.sub, .sec > h2 + .sub { margin-top: 0; }
.sub-val { font-weight: 400; color: var(--fg); margin-left: 4px; }
legend.sub { float: left; width: 100%; }
legend.sub + * { clear: both; }
.pals > legend, .bgs > legend { grid-column: 1 / -1; }

/* Rows: label and editable value on one line, slider underneath */
.row {
  display: grid; grid-template-columns: 1fr 52px; align-items: center; column-gap: 8px;
  margin-top: 10px;
}
.row.off > :not(.hint) { opacity: 0.4; }
.row.off input { cursor: not-allowed; }
.row > label { color: var(--fg); }
.row > input[type="range"], .row > .ends, .row > .hint { grid-column: 1 / -1; }
.num {
  height: 28px; width: 100%; padding: 0 6px;
  border: var(--stroke) solid var(--line); border-radius: var(--r);
  background: var(--field); font: 600 12px/16px var(--font);
  text-align: right; font-variant-numeric: tabular-nums;
}
.num:focus { outline: none; border-width: var(--stroke-thick); background: var(--panel); }
.toolbar .seed-num { width: 72px; flex: none; text-align: center; }
.ends { display: flex; justify-content: space-between; margin-top: -3px; font-size: 11px; color: var(--faint); }
.hint { margin: 4px 0 0; font-size: 11px; line-height: 15px; color: var(--muted); }

/* Sliders: bordered track, blue fill, ink-outlined thumb */
input[type="range"] {
  --track: linear-gradient(90deg, var(--fill) 0 var(--pct, 50%), var(--field) var(--pct, 50%));
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 30px; margin: 0; background: transparent; cursor: pointer;
}
input.track-hue { --track: linear-gradient(to right, #f00, #ff0 17%, #0f0 33%, #0ff 50%, #00f 67%, #f0f 83%, #f00); }
input.track-sat { --track: linear-gradient(to right, var(--from, #888), var(--to, #e33)); }
input[type="range"]::-webkit-slider-runnable-track {
  height: 12px; border: var(--stroke) solid var(--line); border-radius: var(--r); background: var(--track);
}
input[type="range"]::-moz-range-track {
  height: 12px; border: var(--stroke) solid var(--line); border-radius: var(--r); background: var(--track);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none; width: 22px; height: 22px; margin-top: -7px;
  border: var(--stroke) solid var(--line); border-radius: var(--r); background: var(--panel);
}
input[type="range"]::-moz-range-thumb {
  width: 18px; height: 18px; border: var(--stroke) solid var(--line); border-radius: var(--r); background: var(--panel);
}
input[type="range"]:active::-webkit-slider-thumb { background: var(--fill); border-width: var(--stroke-thick); }
input[type="range"]:active::-moz-range-thumb { background: var(--fill); border-width: var(--stroke-thick); }
input[type="range"]:focus-visible { outline: none; }
input[type="range"]:focus-visible::-webkit-slider-thumb { border: var(--stroke-thick) solid var(--focus); }
input[type="range"]:focus-visible::-moz-range-thumb { border: var(--stroke-thick) solid var(--focus); }
input[type="range"]:disabled { cursor: not-allowed; }

/* Switch (every checkbox is drawn as an on/off switch) */
.check { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 32px; margin-top: 4px; cursor: pointer; }
.check input {
  -webkit-appearance: none; appearance: none; flex: none;
  position: relative; width: 36px; height: 20px; margin: 0; cursor: pointer;
  border: var(--stroke) solid var(--color-border-muted); border-radius: var(--r);
  background: var(--primitive-gray-100);
  transition: background-color 150ms ease-out, border-color 150ms ease-out;
}
.check input::after {
  content: ""; position: absolute; top: 2px; left: 2px;
  width: 14px; height: calc(100% - 4px); border-radius: 2px;
  background: var(--color-border-muted);
  transition: transform 150ms ease-out, background-color 150ms ease-out;
}
.check input:checked { background: var(--color-bg-inverse); border-color: var(--color-bg-inverse); }
.check input:checked::after { transform: translateX(15px); background: var(--color-text-inverse); }

/* Shared: radio hidden inside a visual control */
.tile, .pal, .swatch, .seg label, .size { position: relative; cursor: pointer; }
.tile input, .pal input, .swatch input, .seg input, .size input {
  position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer;
}

/* Pickers: outlined, purple on hover, thick purple border when selected */
.tiles { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.tile { display: grid; gap: 4px; }
.thumb {
  display: block; aspect-ratio: 680 / 760; overflow: hidden;
  border: var(--stroke) solid var(--line); border-radius: var(--r); background: var(--field);
}
.thumb img { display: block; width: 100%; height: 100%; }
.tile-name { text-align: center; color: var(--muted); font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile:hover .thumb { border-color: var(--blue); }
.tile input:checked ~ .thumb { border: var(--stroke-thick) solid var(--color-border-selected); }
.tile input:checked ~ .tile-name { color: var(--fg); font-weight: 700; }
.tile input:focus-visible ~ .thumb { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Palettes: a grid of color strips, ending with a plus for a custom palette. */
.pals { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.pal { display: block; height: 28px; border-radius: var(--r); }
.chips { display: flex; height: 100%; overflow: hidden; border: var(--stroke) solid var(--line); border-radius: var(--r); }
.chips i { flex: 1; }
.pal:hover .chips { border-color: var(--blue); }
.pal:has(input:checked) .chips { border: var(--stroke-thick) solid var(--color-border-selected); }
.pal:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 3px; }

/* Plus buttons: same size and outline as the item they sit after */
.add-mark { display: grid; place-items: center; color: var(--fg); }
.add-mark .ico, .cchip-add .ico { width: 18px; height: 18px; }
.pal-add { padding: 0; border: var(--stroke) solid var(--line); background: var(--field); }
.pal-add .add-mark { height: 100%; }
.pal-add:hover { background: var(--hover); border-color: var(--blue); }
.swatch-add .dot { display: grid; place-items: center; background: var(--field); }
.swatch-add:hover .dot { background: var(--hover); }
.swatch-add input:focus-visible + .dot { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Custom palette editor: one square per color, × to remove, + to add */
.cpal { display: flex; flex-wrap: wrap; gap: var(--sw-gap); margin-top: 8px; }
.cchip { position: relative; width: var(--sw); height: var(--sw); }
.cchip input, .cchip-add {
  width: var(--sw); height: var(--sw); padding: 0; margin: 0; cursor: pointer;
  border: var(--stroke) solid var(--line); border-radius: var(--r); background: var(--field);
}
.cchip input::-webkit-color-swatch-wrapper { padding: 0; }
.cchip input::-webkit-color-swatch { border: 0; border-radius: 2px; }
.cchip input::-moz-color-swatch { border: 0; border-radius: 2px; }
.cchip-add { display: grid; place-items: center; color: var(--fg); }
.cchip-add:hover { background: var(--hover); }
.cchip-x {
  position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; padding: 0;
  display: none; place-items: center; cursor: pointer;
  color: var(--on-blue); background: var(--fg);
  border: 0; border-radius: 2px;
}
.cchip:hover .cchip-x, .cchip-x:focus-visible { display: grid; }
@media (hover: none) { .cchip-x { display: grid; } }
.cchip-x .ico { width: 16px; height: 16px; }

/* Background swatches: same size and gap as the custom palette squares, ending with a plus */
.bgs { display: flex; flex-wrap: wrap; gap: var(--sw-gap); margin-top: 4px; }
.bgs > legend { margin-top: 12px; }
.swatch { display: block; width: var(--sw); height: var(--sw); }
.dot { display: block; width: 100%; height: 100%; border: var(--stroke) solid var(--line); border-radius: var(--r); }
.swatch:hover .dot { border-color: var(--blue); }
.swatch input:checked + .dot { border: var(--stroke-thick) solid var(--color-border-selected); }
.swatch input:focus-visible + .dot { outline: 3px solid var(--focus); outline-offset: 2px; }

/* Segmented control: outlined, selected = inverse */
.seg {
  display: grid; grid-auto-flow: column; grid-auto-columns: 1fr;
  border: var(--stroke) solid var(--line); border-radius: var(--r); background: var(--panel); overflow: hidden;
}
.seg span {
  display: flex; align-items: center; justify-content: center;
  height: 30px; padding: 0 4px;
  font: 600 11px/14px var(--font); text-transform: uppercase; color: var(--fg); white-space: nowrap;
}
.seg label + label span { border-left: var(--stroke) solid var(--line); }
.seg label:hover span { background: var(--hover); }
.seg input:checked + span, .seg input:checked + span:hover { background: var(--color-bg-inverse); color: var(--color-text-inverse); }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -3px; }
#tamt-row { margin-top: 8px; }
/* Six options on two rows (3 + 3): texture */
.seg-3x2 { grid-auto-flow: row; grid-template-columns: repeat(3, 1fr); }
.seg-3x2 label:nth-of-type(n+4) span { border-top: var(--stroke) solid var(--line); }
.seg-3x2 label:nth-of-type(4) span { border-left: 0; }
/* A texture's own variant switch, right under the texture picker */
.seg-sub { margin-top: 8px; }
/* Four options on two rows (2 + 2): path shape */
.seg-2x2 { grid-auto-flow: row; grid-template-columns: repeat(2, 1fr); }
.seg-2x2 label:nth-of-type(odd) span { border-left: 0; }
.seg-2x2 label:nth-of-type(n+3) span { border-top: var(--stroke) solid var(--line); }

/* Export sizes */
.sizes { display: grid; margin: 8px -8px 0; }
.size-group { margin: 8px 8px 2px; font-weight: 600; color: var(--muted); }
.size-group:first-child, .size-group[hidden] + .size-group { margin-top: 0; }
.size {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  height: 28px; padding: 0 8px; border: var(--stroke) solid transparent; border-radius: var(--r);
}
.size:hover { background: var(--hover); }
.size:has(input:checked) { background: var(--hover); border-color: var(--fg); }
.size:has(input:checked) .size-name { font-weight: 600; }
.size:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: -3px; }
.size-dim { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
#orient-row { margin-top: 8px; }
#stats { margin-top: 8px; }
#code {
  width: 100%; height: 120px; margin-top: 8px;
  font-family: var(--mono); font-size: 11px;
  background: var(--field); border: 1px solid var(--line); border-radius: var(--r); padding: 6px;
}

/* ---------- "How it works" modal ---------- */
.modal {
  width: min(560px, calc(100vw - 32px)); max-height: calc(100dvh - 32px);
  padding: 0 16px 16px; border: var(--stroke) solid var(--line); border-radius: var(--r-panel);
  background: var(--panel); color: var(--fg);
  font-size: 11px;
}
.modal::backdrop { background: rgb(0 0 0 / 0.35); }
.modal-head {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  min-height: 48px; margin: 0 -16px 12px; padding: 0 8px 0 16px;
  background: var(--panel); border-bottom: var(--stroke) solid var(--line);
}
.modal-note { margin: 12px 0 0; color: var(--muted); }
.modal-note.modal-first { margin-top: 0; }
kbd {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 24px; height: 24px; padding: 0 6px;
  font: 500 11px/1 var(--mono); color: var(--fg);
  border: var(--stroke) solid var(--line); border-radius: var(--r); background: var(--panel);
}
/* Shortcuts: keys on the left, what they do on the right */
.keys-title { margin: 16px 0 8px; font: 600 11px/14px var(--font); color: var(--fg); }
.keys { display: grid; grid-template-columns: max-content 1fr; gap: 8px 24px; align-items: center; margin: 0; }
.keys dt { display: flex; gap: 4px; }
.keys dd { margin: 0; color: var(--muted); }
.key-text { font: 500 11px/24px var(--mono); color: var(--fg); }

/* ---------- Export modal: one fixed size, whatever is chosen inside ---------- */
.export-modal { width: min(800px, calc(100vw - 32px)); height: min(540px, calc(100dvh - 32px)); }
.export-modal[open] { display: flex; flex-direction: column; }
.export-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 16px; }
.export-preview {
  margin: 0; min-height: 0; padding: 24px;
  display: grid; place-items: center; overflow: hidden;
  background: var(--color-bg-muted); border: var(--stroke) solid var(--line); border-radius: var(--r);
  container-type: size;
}
.export-preview img {
  display: block;
  width: min(100cqw, 100cqh * var(--ar, 0.8)); height: auto; aspect-ratio: var(--ar, 0.8);
  border: var(--stroke) solid var(--line);
}
.export-controls { min-height: 0; display: flex; flex-direction: column; }
.export-controls .sizes { flex: 1; min-height: 0; overflow-y: auto; margin-top: 8px; align-content: start; }
.export-controls #orient-row { margin-top: 8px; }
.export-controls #file-row { margin-top: 8px; }
.export-controls #stats { min-height: 30px; }
.export-actions { display: flex; gap: 8px; margin-top: 8px; }
.export-actions .btn { flex: 1; }
#code { flex: none; }
@media (max-width: 680px) {
  .export-modal { height: calc(100dvh - 32px); }
  .export-body { grid-template-columns: 1fr; grid-template-rows: 38% minmax(0, 1fr); }
}

/* ---------- Toast: dashed outline, info tint ---------- */
.toast {
  position: fixed; left: 50%; top: 16px; z-index: 50;
  transform: translate(-50%, -8px);
  max-width: min(92vw, 480px); padding: 8px 12px;
  background: var(--color-feedback-info-subtle); color: var(--fg);
  border: var(--stroke) dashed var(--line); border-radius: var(--r);
  font: 500 13px/18px var(--font); text-align: center;
  opacity: 0; pointer-events: none;
  transition: opacity 160ms ease-out, transform 160ms ease-out;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- Narrow screens: one scrolling column, canvas first ---------- */
@media (max-width: 1000px) {
  :root { --panel-w: 240px; }
}
@media (max-width: 820px) {
  body { height: auto; overflow: visible; }
  .app { height: auto; grid-template-columns: 1fr; }
  .stage { order: -1; }
  .panel, .frame-scroll { overflow: visible; }
  .panel-top { position: static; }
  #right { order: 1; }
  .tb-group + .tb-group { border-left: 0; padding-left: 0; }
  .canvas { container-type: normal; display: grid; padding: 0; }
  .canvas svg { width: 100%; }
  .dock { align-self: stretch; margin-top: 8px; }
  .toolbar { flex-wrap: wrap; justify-content: center; }
  .tb-label { display: none; }
  .tb-btn { padding: 0 8px; }
  .icon-btn, .tb-btn, .btn { height: 40px; }
  .icon-btn { width: 40px; }
  .num { height: 32px; }
  .pal, .size { height: 40px; }
  .seg span { height: 32px; }
  /* Download stays in thumb reach as a bottom bar. */
  #right .panel-top {
    position: fixed; top: auto; left: 0; right: 0; bottom: 0; z-index: 40;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom));
    border-top: var(--stroke) solid var(--line); border-bottom: 0;
  }
  #right .panel-top .btn { flex: 1; }
  body { padding-bottom: calc(64px + env(safe-area-inset-bottom)); }
  .toast { top: auto; bottom: calc(72px + env(safe-area-inset-bottom)); }
}

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