/* chop chop — "ops console" look: mint frames with cut corners on a dotted green-black grid. */
:root {
  --bg: #06110b;
  --bg-2: #0b1c13;          /* panel fill */
  --bg-3: #10281b;          /* raised fill */
  --edge: #5df28f;          /* mint frame */
  --edge-dim: #2b7a4c;
  --ink: #d9ffe5;
  --muted: #7cb892;
  --line: #1d4a31;
  --wave: #5df28f;
  --accent: #ff3d7f;        /* pink */
  --accent-dim: #7a1d41;
  --sel: rgba(255, 61, 127, 0.28);
  --region: rgba(93, 242, 143, 0.09);
  --region-edge: #2fae63;
  --rec: #ff4f4f;           /* record + destructive: one red */
  --danger: var(--rec);
  --star: #5df28f;
  --pixel: "Silkscreen", ui-monospace, monospace;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --cut: 12px;
  --h: 36px;                /* control height: buttons, inputs, segmented, clock */
  color-scheme: dark;
}
* { box-sizing: border-box; }
html { scrollbar-color: var(--edge-dim) var(--bg); }
[hidden] { display: none !important; }
::selection { background: var(--accent); color: #000; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex; flex-direction: column;
  color: var(--ink);
  font: 13px/1.5 var(--mono);
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='520' height='360' fill='none' stroke='%23ff3d7f' stroke-width='2' opacity='.22'%3E%3Cpath d='M0 300h120l40-40h140l30 30h190M60 360v-40l20-20h80M420 0v80l-30 30v90l40 40v120'/%3E%3Ccircle cx='300' cy='260' r='4'/%3E%3Ccircle cx='160' cy='300' r='4'/%3E%3Ccircle cx='430' cy='240' r='4'/%3E%3C/svg%3E") right bottom / 520px 360px no-repeat fixed,
    radial-gradient(rgba(93, 242, 143, 0.09) 1px, transparent 1.2px) 0 0 / 6px 6px,
    linear-gradient(rgba(93, 242, 143, 0.05) 1px, transparent 1px) 0 0 / 48px 48px,
    linear-gradient(90deg, rgba(93, 242, 143, 0.05) 1px, transparent 1px) 0 0 / 48px 48px,
    var(--bg);
}
a { color: var(--edge); text-underline-offset: 3px; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
kbd { font: 11px var(--mono); color: var(--edge); border: 1px solid var(--edge-dim); padding: 0 4px; }

/* Cut-corner frames: the element paints the border colour, ::before paints the fill inset by --bw. */
.panel, .tab, .btn, .seg, .menu, .howto, .recbar, .toast, .clock, .slot {
  --bw: 2px;
  --fc: var(--edge-dim);
  --fill: var(--bg-2);
  position: relative; isolation: isolate;
  background: var(--fc);
  clip-path: polygon(var(--cut) 0, 100% 0, 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%, 0 var(--cut));
  border: 0;
}
.panel::before, .tab::before, .btn::before, .seg::before, .menu::before, .howto::before,
.recbar::before, .toast::before, .clock::before, .slot::before {
  content: ""; position: absolute; inset: var(--bw); z-index: -1;
  background: var(--fill);
  --c: calc(var(--cut) - var(--bw) * 0.6);
  clip-path: polygon(var(--c) 0, 100% 0, 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%, 0 var(--c));
}

/* icons (SVG sprite in index.html) */
.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }
.ic {
  width: 16px; height: 16px; flex: none;
  fill: none; stroke: currentColor; stroke-width: 1.5; stroke-linecap: square; stroke-linejoin: miter;
}
.ic.big { width: 30px; height: 30px; stroke-width: 1.25; color: var(--edge); }
.ic.caret { width: 12px; height: 12px; margin-left: -2px; opacity: 0.7; }
.iconbtn {
  display: inline-grid; place-items: center; width: 24px; height: 24px; padding: 0;
  color: var(--muted); background: none; border: 0; cursor: pointer;
}
.iconbtn:hover { color: var(--ink); }
.iconbtn:focus-visible { outline: 2px solid var(--edge); outline-offset: -2px; }
.iconbtn.star.on { color: var(--star); }
.iconbtn.play:hover { color: var(--edge); }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 10px 16px;
  padding: 12px 20px; position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 2px solid var(--edge-dim);
}
.brand { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.logo {
  font: 20px/1 var(--pixel); letter-spacing: 1px; color: var(--edge);
  text-shadow: 0 0 12px rgba(93, 242, 143, 0.35);
}
.tag { font: 11px var(--pixel); color: var(--muted); text-transform: uppercase; letter-spacing: 1px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.langs { display: inline-flex; height: var(--h); align-items: center; }
.actsep { width: 1px; height: 22px; margin: 0 4px; background: var(--line); }
.langs button {
  height: 26px; font: 11px/1 var(--pixel); color: var(--muted); background: none; cursor: pointer;
  border: 0; padding: 0 7px;
}
.langs button:hover { color: var(--ink); }
.langs button[aria-pressed="true"] { color: var(--bg); background: var(--edge); }
.langs button:focus-visible { outline: 2px solid var(--edge); outline-offset: 1px; }

main { flex: 1; display: flex; flex-direction: column; width: 100%; max-width: 1240px; margin: 0 auto; padding: 20px; }
#editor { display: flex; flex-direction: column; gap: 18px; }

/* ---------- modules: a title tab sitting on top of a panel ---------- */
.module { display: flex; flex-direction: column; min-width: 0; }
.tabrow { display: flex; align-items: center; gap: 12px; }
.tab {
  --cut: 8px; --fc: var(--edge); --fill: var(--bg-2);
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% 100%, 0 100%);
  display: inline-flex; align-items: center; gap: 8px; margin-bottom: -2px; padding: 7px 18px 7px 12px; max-width: 70%;
  font: 12px/1 var(--pixel); text-transform: uppercase; letter-spacing: 1px; color: var(--edge);
}
.tab::before { inset: 2px 2px 0 2px; clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% 100%, 0 100%); }
.tab-dl { --fc: var(--accent); color: var(--accent); }
.tabmeta { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tabrow .link, .tabrow .iconbtn { margin-left: auto; white-space: nowrap; }
.tabrow .link { padding: 8px 0; } /* 24px+ touch target */
.panel { --fc: var(--edge); padding: 14px 16px; }
/* Panels hang from a tab: square top-left so the tab's edge runs straight into the panel's,
   cut corners top-right and bottom-right instead. */
.panel {
  clip-path: polygon(0 0, calc(100% - var(--cut)) 0, 100% var(--cut), 100% calc(100% - var(--cut)), calc(100% - var(--cut)) 100%, 0 100%);
}
.panel::before {
  clip-path: polygon(0 0, calc(100% - var(--c)) 0, 100% var(--c), 100% calc(100% - var(--c)), calc(100% - var(--c)) 100%, 0 100%);
}

/* ---------- controls ---------- */
.btn {
  --cut: 7px; --fc: var(--edge-dim); --fill: var(--bg-3);
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: var(--h);
  font: 11px/1 var(--pixel); text-transform: uppercase; letter-spacing: 0.5px; color: var(--ink);
  padding: 0 14px; cursor: pointer; user-select: none; white-space: nowrap;
}
.btn:hover:not(:disabled) { --fc: var(--edge); color: var(--edge); }
.btn:focus-visible { --fc: var(--ink); outline: none; }
.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn.primary { --fc: var(--edge); --fill: var(--edge); color: var(--bg); }
.btn.primary:hover:not(:disabled) { --fill: #8bffb2; --fc: #8bffb2; color: var(--bg); }
.btn.icon { width: var(--h); padding: 0; }
.btn.danger { color: var(--danger); }
.btn.danger:hover:not(:disabled) { --fc: var(--danger); color: var(--danger); }
.btn.rec { color: var(--rec); }
.btn.rec:hover { --fc: var(--rec); color: var(--rec); }
.btn.on { --fc: var(--accent); --fill: var(--accent); color: #000; }
.btn.on:hover:not(:disabled) { --fc: var(--accent); color: #000; }
.link {
  font: 11px var(--pixel); text-transform: uppercase; color: var(--muted);
  background: none; border: 0; padding: 0; cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.link:hover { color: var(--ink); }
.link:disabled { opacity: 0.35; cursor: not-allowed; text-decoration: none; }

select, input[type=number], input:not([type]) {
  font: 13px/1.2 var(--mono); color: var(--ink); background: var(--bg);
  border: 0; border-radius: 0; padding: 0 8px; height: 30px; box-shadow: inset 0 0 0 2px var(--edge-dim);
}
.sentence input, .packname input { height: var(--h); }
select:focus, input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--edge); }
input[type=number] { width: 72px; }
input:disabled, select:disabled { opacity: 0.35; cursor: not-allowed; }
input[type=radio] { accent-color: var(--edge); }
input[type=number] { -moz-appearance: textfield; appearance: textfield; }
input[type=number]::-webkit-inner-spin-button, input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
select {
  appearance: none; -webkit-appearance: none; padding-right: 26px; cursor: pointer;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0h2v2h2v2h2V2h2V0h2v2H8v2H6v2H4V4H2V2H0z' fill='%235df28f'/%3E%3C/svg%3E") right 10px center / 10px 6px no-repeat;
}
select option { background: var(--bg-2); color: var(--ink); }
input[type=checkbox] {
  appearance: none; -webkit-appearance: none; width: 18px; height: 18px; margin: 0; cursor: pointer;
  display: inline-grid; place-content: center; background: var(--bg); box-shadow: inset 0 0 0 2px var(--edge-dim);
}
input[type=checkbox]::before { content: ""; width: 8px; height: 8px; background: var(--edge); transform: scale(0); }
input[type=checkbox]:checked { box-shadow: inset 0 0 0 2px var(--edge); }
input[type=checkbox]:checked::before { transform: scale(1); }
input[type=checkbox]:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }
input[type=range] { appearance: none; -webkit-appearance: none; background: transparent; height: 28px; cursor: pointer; }
input[type=range]::-webkit-slider-runnable-track { height: 8px; background: repeating-linear-gradient(90deg, var(--edge-dim) 0 6px, transparent 6px 9px); }
input[type=range]::-moz-range-track { height: 8px; background: repeating-linear-gradient(90deg, var(--edge-dim) 0 6px, transparent 6px 9px); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 22px; margin-top: -7px; background: var(--edge); border: 0; }
input[type=range]::-moz-range-thumb { width: 12px; height: 22px; background: var(--edge); border: 0; border-radius: 0; }
input[type=range]:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* "Screens" (waveform, slice preview, sigil) get HUD corner brackets */
.screen { position: relative; }
.screen::after {
  --c: var(--edge); --l: 10px;
  content: ""; position: absolute; inset: 4px; z-index: 2; pointer-events: none; opacity: 0.75;
  background:
    linear-gradient(var(--c), var(--c)) left top / var(--l) 2px, linear-gradient(var(--c), var(--c)) left top / 2px var(--l),
    linear-gradient(var(--c), var(--c)) right top / var(--l) 2px, linear-gradient(var(--c), var(--c)) right top / 2px var(--l),
    linear-gradient(var(--c), var(--c)) left bottom / var(--l) 2px, linear-gradient(var(--c), var(--c)) left bottom / 2px var(--l),
    linear-gradient(var(--c), var(--c)) right bottom / var(--l) 2px, linear-gradient(var(--c), var(--c)) right bottom / 2px var(--l);
  background-repeat: no-repeat;
}
.preview.screen::after { --c: var(--accent); }

/* record menu */
.recmenu { position: relative; }
.recmenu summary { list-style: none; }
.recmenu summary::-webkit-details-marker { display: none; }
.recmenu[open] summary { --fc: var(--rec); }
.menu {
  --fc: var(--edge); --cut: 10px;
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 10; width: 300px; padding: 4px;
}
.menu button {
  display: flex; gap: 10px; align-items: flex-start; width: 100%; text-align: left; cursor: pointer;
  background: none; border: 0; border-bottom: 1px dashed var(--line); padding: 11px 12px;
  color: var(--ink); font: 13px/1.4 var(--mono);
}
.menu button:last-child { border-bottom: 0; }
.menu button:hover { background: var(--bg-3); }
.menu button > .ic { margin-top: 1px; color: var(--rec); }
.menu button > span { display: grid; gap: 2px; }
.menu b { font: 11px var(--pixel); text-transform: uppercase; color: var(--edge); }
.menu button > span > span { color: var(--muted); font-size: 12px; }

/* ---------- waveform ---------- */
.wavewrap {
  position: relative; overflow: hidden; background-color: #030a06;
  box-shadow: inset 0 0 0 2px var(--line);
  background-image:
    linear-gradient(rgba(93, 242, 143, 0.06) 1px, transparent 1px),
    linear-gradient(90deg, rgba(93, 242, 143, 0.06) 1px, transparent 1px);
  background-size: 100% 24px, 32px 100%;
}
.wavewrap.over { box-shadow: inset 0 0 0 2px var(--edge); }
.waveempty {
  position: absolute; inset: 0; z-index: 1; display: none; place-content: center; justify-items: center; gap: 6px;
  text-align: center; padding: 16px; cursor: pointer; color: var(--ink);
}
.waveempty b { font: 14px var(--pixel); text-transform: uppercase; color: var(--edge); margin-top: 6px; }
.waveempty:hover b { color: var(--ink); }
.noaudio .waveempty { display: grid; }
.wavewrap.over .waveempty { background: rgba(93, 242, 143, 0.06); }
#wave { display: block; width: 100%; height: 220px; cursor: crosshair; touch-action: none; }
#overview { display: block; width: 100%; height: 34px; border-top: 2px solid var(--line); cursor: pointer; }
.hud {
  position: absolute; top: 22px; right: 14px; z-index: 2; pointer-events: none; /* below the slice tags */
  font: 8px/1 var(--pixel); letter-spacing: 0.5px; color: var(--muted); text-transform: uppercase;
  padding: 3px 5px; background: rgba(3, 10, 6, 0.75);
}
.noaudio .hud { display: none; }
.tab #fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-transform: none; }

.transport { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 12px; }
.clock {
  --cut: 7px; --fc: var(--edge-dim); --fill: #030a06;
  display: inline-flex; align-items: center; height: var(--h);
  font: 18px/1 var(--pixel); color: var(--edge); letter-spacing: 1px; padding: 0 12px;
  text-shadow: 0 0 10px rgba(93, 242, 143, 0.4); white-space: nowrap;
}
.clock span { display: inline-block; width: 0.9em; text-align: center; }
.clock span.sep { width: 0.45em; }
#zoomall { margin-left: auto; } /* view controls sit apart from playback */
.meter { font: 11px var(--pixel); text-transform: uppercase; color: var(--muted); margin-left: 4px; }

/* ---------- dig ---------- */
.dig { display: flex; flex-wrap: wrap; gap: 12px 14px; align-items: center; }
.sentence { display: inline-flex; flex-wrap: wrap; align-items: center; gap: 8px; font-size: 14px; }
.sentence input { width: 60px; font-size: 14px; text-align: center; }
.dighint { flex-basis: 100%; font-size: 12px; }
.dig #dig { margin-left: auto; padding: 0 22px; }
.qdialog { width: min(560px, calc(100vw - 32px)); }
.qdialog h2 .ic { width: 18px; height: 18px; }
.sigilpane { display: grid; gap: 8px; margin-bottom: 12px; }
#sigil {
  display: block; width: 100%; height: 190px; cursor: crosshair; touch-action: none;
  background-color: #030a06; box-shadow: inset 0 0 0 2px var(--edge-dim);
  background-image: radial-gradient(rgba(93, 242, 143, 0.12) 1px, transparent 1.2px);
  background-size: 12px 12px;
}
.sigilfoot { display: flex; align-items: center; gap: 12px; }
.sigilfoot .muted { flex: 1; }
.sigilbar { width: 120px; height: 12px; padding: 2px; box-shadow: inset 0 0 0 2px var(--edge-dim); }
#sigilFill { height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--edge) 0 6px, transparent 6px 9px); }
.sigilpane p { margin: 0; }
.seg { --cut: 7px; --fc: var(--edge-dim); --fill: var(--bg); display: inline-flex; align-items: stretch; height: var(--h); padding: 4px; }
.seg label { cursor: pointer; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg label { display: flex; }
.seg span { display: flex; align-items: center; white-space: nowrap; padding: 0 11px; font: 11px/1 var(--pixel); text-transform: uppercase; color: var(--muted); }
.seg input:checked + span {
  background: var(--edge); color: var(--bg);
  clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px); /* same cut as the frame */
}
.seg span .ic { width: 14px; height: 14px; margin-right: 5px; }
.seg span span { display: inline; padding: 0; }
.seg label:hover input:not(:checked):not(:disabled) + span { color: var(--ink); }
.seg input:focus-visible + span { outline: 2px solid var(--ink); outline-offset: -2px; }
.seg input:disabled + span { opacity: 0.35; cursor: not-allowed; }

/* ---------- chop: slot grid ("hold") ---------- */
.panels { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 18px; align-items: start; }
.col { display: flex; flex-direction: column; gap: 18px; min-width: 0; }
@media (max-width: 900px) { .panels { grid-template-columns: 1fr; } }
.holdbar { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px 12px; margin: -2px 0 12px; }
.banksize { display: inline-flex; align-items: center; gap: 10px; }
.hold { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); gap: 6px; }
.hold[data-bank="12"] { grid-template-columns: repeat(6, minmax(0, 1fr)); }
@media (max-width: 700px) { .hold, .hold[data-bank="12"] { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
.hold .empty { grid-column: 1 / -1; padding: 0 2px 6px; }
.slot {
  --cut: 8px; --fc: var(--line); --fill: var(--bg);
  display: block; aspect-ratio: 1 / 1.1; padding: 6px; cursor: pointer; min-width: 0;
  touch-action: manipulation; user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
.slot .thumb { position: absolute; left: 6px; right: 6px; top: 22px; bottom: 34px; width: calc(100% - 12px); height: calc(100% - 56px); }
.slot .idx { position: absolute; left: 8px; top: 6px; font: 9px/1 var(--pixel); color: var(--muted); }
.slot .star { position: absolute; top: 1px; right: 1px; }
.slot .key { position: absolute; right: 7px; bottom: 6px; font: 10px/1 var(--pixel); color: var(--edge); opacity: 0.8; }
.slot .key:empty { display: none; }
.slot .nm { position: absolute; left: 8px; right: 22px; bottom: 18px; font: 10px/1 var(--pixel); color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot .meta { position: absolute; left: 8px; right: 22px; bottom: 5px; font-size: 10px; line-height: 1; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slot:hover { --fc: var(--edge-dim); }
.slot:focus-visible { --fc: var(--ink); outline: none; }
.slot.kept .idx { padding-left: 10px; }
.slot.kept .idx::before { content: ""; position: absolute; left: 0; top: 1px; width: 6px; height: 6px; background: var(--star); box-shadow: 0 0 6px var(--star); }
.slot.sel { --fc: var(--accent); --fill: #1a0a12; }
.slot.sel .nm { color: var(--accent); }
.slot.free { --fill: #040b07; cursor: default; }
.slot.hit::after { content: ""; position: absolute; inset: 0; background: var(--edge); animation: hit 0.18s ease-out forwards; pointer-events: none; }
@keyframes hit { from { opacity: 0.55; } to { opacity: 0; } }
.seg.mini { --cut: 5px; height: 30px; padding: 3px; }
.seg.mini span { padding: 0 7px; font-size: 10px; }
.seg.mini input:checked + span { clip-path: polygon(3px 0, 100% 0, 100% calc(100% - 3px), calc(100% - 3px) 100%, 0 100%, 0 3px); }
.slot.free::after {
  content: ""; position: absolute; inset: 10px; opacity: 0.6;
  background:
    linear-gradient(45deg, transparent calc(50% - 1px), var(--line) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px)),
    linear-gradient(-45deg, transparent calc(50% - 1px), var(--line) calc(50% - 1px) calc(50% + 1px), transparent calc(50% + 1px));
}
.slot.free:hover { --fc: var(--line); }

/* ---------- download ---------- */
.exportbox { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px 16px; }
.packname { display: grid; gap: 6px; flex: 1 1 200px; max-width: 320px; }
.packname input { width: 100%; font-size: 14px; }
.exportgo { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.lab { font: 10px var(--pixel); text-transform: uppercase; letter-spacing: 0.5px; color: var(--muted); }

/* ---------- inspector: item card ---------- */
.inspector { display: grid; gap: 12px; }
.tab .selname { color: var(--accent); }
.preview { height: 96px; padding: 6px; background: #030a06; box-shadow: inset 0 0 0 2px var(--line); }
.preview.on { box-shadow: inset 0 0 0 2px var(--accent-dim); }
.preview:not(.on)::after { --c: var(--edge-dim); }
.previewmsg { position: absolute; inset: 0; display: grid; place-items: center; padding: 0 18px; text-align: center; color: var(--muted); font-size: 12px; }
.previewmsg[hidden] { display: none; }
#selWave { display: block; width: 100%; height: 100%; }
#props { display: grid; gap: 7px; }
.field { display: grid; grid-template-columns: 1fr 150px; align-items: center; gap: 10px; padding-bottom: 7px; border-bottom: 1px dashed var(--line); }
.field input:not([type=checkbox]), .field select { width: 100%; }
.field.check { cursor: pointer; }
.field.check input { justify-self: end; }
#pInfo { margin: 2px 0 0; }
.actionsrow { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 4px; }
.actionsrow #pDel { margin-left: auto; }

/* ---------- dialogs ---------- */
.howto {
  --fc: var(--edge); --cut: 16px; position: fixed;
  width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 48px); overflow: hidden;
  padding: 0; color: var(--ink);
}
/* The frame (dialog + ::before fill) stays put; only the body scrolls, so the fill always covers it. */
.dlgbody { max-height: calc(100dvh - 48px); overflow: auto; padding: 24px 26px; overscroll-behavior: contain; }
.howto::backdrop { background: rgba(2, 8, 5, 0.75); }
.howto h2 { display: flex; align-items: baseline; gap: 10px; margin: 0 0 14px; font: 12px var(--pixel); text-transform: uppercase; color: var(--edge); }
.howto h2 .logo { font-size: 18px; }
.howto h2 .muted { color: var(--muted); }
.howto p { margin: 0 0 12px; }
.parts { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 4px 0 14px; }
@media (max-width: 640px) { .parts { grid-template-columns: 1fr; } }
.parts section { padding: 12px; box-shadow: inset 0 0 0 2px var(--line); background: var(--bg); }
.parts p { margin: 8px 0 0; }
.step { display: inline-block; font: 10px/1 var(--pixel); text-transform: uppercase; letter-spacing: 1px; padding: 5px 7px 4px; background: var(--ink); color: #000; }
.step.dig-step { background: var(--edge); }
.step.dl-step { background: var(--accent); }
.howfoot { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 16px; padding-top: 14px; border-top: 1px dashed var(--line); }
.howfoot .check { display: inline-flex; align-items: center; gap: 8px; color: var(--muted); cursor: pointer; }
.privlist { margin: 0 0 14px; padding-left: 18px; display: grid; gap: 6px; }
.privlist li::marker { color: var(--edge); }

.foot { width: 100%; max-width: 1240px; margin: 12px auto 0; padding: 14px 20px 32px; font-size: 12px; border-top: 1px dashed var(--line); }
.foot p { margin: 0 0 4px; }
.footmeta .link, .footmeta a { font: 12px var(--mono); text-transform: none; color: var(--muted); }
.footmeta .link:hover, .footmeta a:hover { color: var(--ink); }

/* recording bar */
.recbar {
  --fc: var(--rec); --cut: 12px;
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 40;
  display: flex; flex-wrap: wrap; align-items: center; gap: 10px 12px;
  width: min(660px, calc(100vw - 32px)); padding: 14px 16px;
}
.recdot { width: 10px; height: 10px; background: var(--rec); animation: blink 1s infinite steps(1); }
@keyframes blink { 50% { opacity: 0.2; } }
#recLabel { font: 11px var(--pixel); text-transform: uppercase; color: var(--rec); }
.rectime { font: 14px var(--pixel); color: var(--edge); min-width: 6.5em; }
.reclevel { flex: 1; min-width: 80px; height: 12px; padding: 2px; box-shadow: inset 0 0 0 2px var(--edge-dim); }
#recLevel { height: 100%; width: 0; background: repeating-linear-gradient(90deg, var(--edge) 0 6px, transparent 6px 9px); transition: width 80ms linear; }
#recLevel.hot { background: repeating-linear-gradient(90deg, var(--danger) 0 6px, transparent 6px 9px); }
.recgain { flex-basis: 100%; display: flex; align-items: center; gap: 10px; cursor: pointer; }
.recgain[hidden] { display: none; }
.recgain input { flex: 1; min-width: 120px; height: 28px; accent-color: var(--edge); }
.recgainval { font: 12px var(--pixel); color: var(--edge); min-width: 5.5em; text-align: right; }
.rechint { flex-basis: 100%; margin: 0; font-size: 12px; color: var(--muted); }
.rechint:empty { display: none; }

.toastbtn {
  margin-left: 12px; padding: 0; border: 0; background: none; cursor: pointer;
  font: inherit; color: var(--bg); text-decoration: underline; text-underline-offset: 3px;
}
.toast {
  --fc: var(--edge); --fill: var(--edge); --cut: 8px; display: flex; align-items: center;
  position: fixed; top: 66px; left: 50%; transform: translateX(-50%); z-index: 60;
  color: var(--bg); font: 11px/1.4 var(--pixel); text-transform: uppercase; padding: 10px 16px;
  max-width: calc(100vw - 32px);
}

@media (max-width: 560px) {
  .top { padding: 10px 12px; gap: 8px; }
  .tag { display: none; }
  .logo { font-size: 17px; }
  .langs { margin-right: 0; }
  .top .lbl { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
  .top .btn { padding-inline: 10px; }
  main { padding: 12px; }
  .panel { padding: 12px; }
  #wave { height: 170px; }
  .menu { width: min(300px, calc(100vw - 24px)); }
  .toast { top: 58px; }
  .clock { font-size: 15px; }
  .field { grid-template-columns: 1fr 140px; }
  .dig .seg { display: grid; grid-template-columns: 1fr 1fr; height: auto; width: 100%; } /* 2×2 so labels never wrap */
  .dig .seg > label > span { width: 100%; height: 32px; justify-content: center; }
}

/* Touch screens: no keyboard shortcuts in the help or on the slots */
@media (hover: none) and (pointer: coarse), (max-width: 560px) {
  .kbdhelp, .slot .key { display: none; }
}

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