/* HIGHER VIBRATIONS page. Colours are tokens on :root: a dark lab bench by default; a light workshop follows the system unless
   the page sets data-theme. The brass plate itself is drawn on the canvas and looks the same in both. */
:root {
  --bench: #0e0c0a;
  --bench-2: #19150f;
  --panel: #16120d;
  --line: #3a3024;
  --ink: #f0e7d6;
  --muted: #a8997f;
  --brass: #c9a24a;
  --brass-hi: #f4d47c;
  --brass-lo: #6b5021;
  --lock: #ffe48a;
  --lock-ink: #2a1d05;
  --led-off: #2a2219;
  --knob-a: #4a4237;
  --knob-b: #15120e;
  --focus: #ffd75e;
  --danger: #e0794f;
  --shadow: rgba(0, 0, 0, .55);
}
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    --bench: #eee6d8;
    --bench-2: #e2d7c4;
    --panel: #f8f3ea;
    --line: #cdbfa6;
    --ink: #221c14;
    --muted: #6e624f;
    --brass: #9d7826;
    --brass-hi: #c89b35;
    --brass-lo: #b89b63;
    --lock: #8a6510;
    --lock-ink: #fff7e0;
    --led-off: #ddd0b9;
    --knob-a: #6f665a;
    --knob-b: #2a251e;
    --focus: #8a5a00;
    --danger: #b2492a;
    --shadow: rgba(60, 40, 10, .25);
  }
}
:root[data-theme="dark"] { --bench: #0e0c0a; --bench-2: #19150f; --panel: #16120d; --line: #3a3024; --ink: #f0e7d6; --muted: #a8997f; }
:root[data-theme="light"] { --bench: #eee6d8; --bench-2: #e2d7c4; --panel: #f8f3ea; --line: #cdbfa6; --ink: #221c14; --muted: #6e624f; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; background: var(--bench); color: var(--ink); }
body.is-ended { overflow: hidden; }
body {
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(120% 60% at 50% 0%, var(--bench-2), transparent 70%),
    var(--bench);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 3px; }

.hv { max-width: 1240px; margin: 0 auto; padding: 6px 16px 28px; }
.hv-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; }
.hv-head h1 {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: .32em; text-transform: uppercase; color: var(--brass-hi);
  text-shadow: 0 0 18px rgba(244, 212, 124, .35);
}
.hv-icon {
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line); background: var(--panel); display: grid;
  place-items: center; cursor: pointer;
}
.hv-icon svg { width: 22px; height: 22px; fill: none; stroke: var(--brass-hi); stroke-width: 1.6; stroke-linecap: round; stroke-linejoin: round; }
.hv-icon .spk { fill: var(--brass-hi); stroke: none; }
.hv-icon .cross { display: none; }
.hv-icon[aria-pressed="true"] .wave { display: none; }
.hv-icon[aria-pressed="true"] .cross { display: inline; stroke: var(--danger); }

.hv-bench { display: grid; gap: 10px; }

/* ---------- the plate ---------- */
.hv-plate-wrap {
  position: relative; width: 100%; aspect-ratio: 1; border-radius: 12px; touch-action: none;
  box-shadow: 0 0 0 1px var(--brass-lo), 0 14px 40px var(--shadow), 0 0 46px rgba(201, 162, 74, .22);
  transition: box-shadow .5s ease;
}
.hv-plate-wrap.is-ringing { box-shadow: 0 0 0 1px var(--brass), 0 14px 40px var(--shadow), 0 0 60px rgba(244, 212, 124, .32); }
.hv-plate-wrap.is-locked { box-shadow: 0 0 0 2px var(--lock), 0 14px 40px var(--shadow), 0 0 90px rgba(255, 228, 138, .55); }
#plate { display: block; width: 100%; height: 100%; border-radius: 12px; cursor: crosshair; }
#shimmer {
  position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 12px; pointer-events: none; mix-blend-mode: soft-light;
  opacity: 0; transition: opacity .4s ease;
}
#shimmer.is-on { opacity: .55; animation: buzz .143s ease-in-out infinite alternate; }
@keyframes buzz { from { opacity: .4; } to { opacity: .62; } }
.hv-locked {
  position: absolute; top: 12px; left: 50%; transform: translateX(-50%) scale(.85); opacity: 0; pointer-events: none;
  padding: 4px 14px; border-radius: 999px; font: 700 13px/1.4 ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: .3em;
  color: var(--lock-ink); background: var(--lock); box-shadow: 0 0 24px rgba(255, 228, 138, .8);
  transition: opacity .25s ease, transform .25s ease;
}
.hv-plate-wrap.is-locked .hv-locked { opacity: 1; transform: translateX(-50%) scale(1); }
.hv-plate-wrap.lock-pop .hv-locked { animation: pop .6s ease; }
@keyframes pop { 0% { transform: translateX(-50%) scale(1.35); } 100% { transform: translateX(-50%) scale(1); } }
.hv-hint {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); margin: 0; width: max-content; max-width: calc(100% - 24px);
  padding: 5px 12px; border-radius: 8px; background: rgba(10, 8, 5, .62); color: #f6ecd9; font-size: 13px; text-align: center;
  pointer-events: none; transition: opacity .4s ease;
}
.hv-hint.is-off { opacity: 0; }

/* ---------- the panel ---------- */
.hv-panel { display: grid; gap: 9px; align-content: start; }
.hv-readout {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 12px; row-gap: 6px; align-items: end;
  padding: 8px 12px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
}
.hv-freq { font: 600 34px/1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--brass-hi); font-variant-numeric: tabular-nums; }
.hv-freq small { font-size: 14px; margin-left: 4px; color: var(--muted); }
.hv-mode { justify-self: end; text-align: right; color: var(--muted); font-size: 13px; min-height: 1.4em; }
.hv-mode b { color: var(--ink); font-weight: 600; }
.hv-mode .new { color: var(--lock); font-weight: 700; letter-spacing: .08em; }
.hv-meter { grid-column: 1 / -1; display: grid; grid-template-columns: repeat(20, 1fr); gap: 3px; height: 12px; }
.hv-meter i { border-radius: 2px; background: var(--led-off); transition: background .08s linear, box-shadow .08s linear; }
.hv-meter i.on { background: var(--brass); }
.hv-meter i.hot { background: var(--lock); box-shadow: 0 0 8px rgba(255, 228, 138, .8); }

.hv-knobs { display: grid; grid-template-columns: 1.4fr 1fr 1fr; align-items: end; justify-items: center; gap: 8px; }
.hv-knob-box { display: grid; justify-items: center; gap: 6px; }
.hv-knob { position: relative; width: 70px; height: 70px; border-radius: 50%; touch-action: none; cursor: grab; }
.hv-big .hv-knob { width: 100px; height: 100px; }
.hv-knob:active { cursor: grabbing; }
.hv-ring {
  position: absolute; inset: 0; border-radius: 50%;
  background: repeating-conic-gradient(from -2deg, var(--brass-lo) 0 1.4deg, transparent 1.4deg 15deg);
  -webkit-mask: radial-gradient(circle, transparent 60%, #000 61%, #000 70%, transparent 71%);
  mask: radial-gradient(circle, transparent 60%, #000 61%, #000 70%, transparent 71%);
}
.hv-cap {
  position: absolute; inset: 15%; border-radius: 50%; transform: rotate(var(--rot, 0deg));
  background:
    repeating-conic-gradient(rgba(255, 255, 255, .05) 0 4deg, rgba(0, 0, 0, .08) 4deg 8deg),
    radial-gradient(circle at 35% 30%, var(--knob-a), var(--knob-b) 75%);
  box-shadow: 0 6px 14px var(--shadow), inset 0 1px 1px rgba(255, 255, 255, .22), inset 0 -3px 6px rgba(0, 0, 0, .5);
}
.hv-cap i {
  position: absolute; left: 50%; top: 7%; width: 4px; height: 26%; margin-left: -2px; border-radius: 2px;
  background: var(--brass-hi); box-shadow: 0 0 8px rgba(244, 212, 124, .9);
}
.hv-knob-label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); white-space: nowrap; }
.hv-knob-label b { color: var(--ink); font: 600 11px ui-monospace, "SF Mono", Menlo, Consolas, monospace; letter-spacing: 0; margin-left: 4px; }

.hv-sands { margin: 0; padding: 8px 10px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); min-width: 0; }
.hv-sands legend { padding: 0 6px; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.hv-jars { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.hv-jar {
  position: relative; display: grid; justify-items: center; gap: 3px; padding: 6px 2px 5px; min-height: 58px; border-radius: 10px;
  border: 1px solid var(--line); background: transparent; cursor: pointer; font-size: 10px; line-height: 1.15; color: var(--muted);
}
.hv-jar .pile {
  width: 30px; height: 22px; border-radius: 50% 50% 6px 6px / 70% 70% 6px 6px; background: var(--sand);
  box-shadow: inset 0 -4px 6px rgba(0, 0, 0, .3), 0 0 0 1px rgba(0, 0, 0, .25);
  background-image: radial-gradient(rgba(255, 255, 255, .28) 1px, transparent 1.4px), radial-gradient(rgba(0, 0, 0, .25) 1px, transparent 1.4px);
  background-size: 5px 5px, 7px 7px; background-position: 0 0, 2px 3px;
}
.hv-jar[aria-checked="true"] { border-color: var(--brass-hi); color: var(--ink); background: rgba(201, 162, 74, .1); box-shadow: 0 0 0 1px var(--brass-hi) inset; }
.hv-jar:disabled { opacity: .38; cursor: not-allowed; }
.hv-jar .w { font-size: 9px; letter-spacing: .06em; text-transform: uppercase; opacity: .8; }
.hv-gauge { margin-top: 8px; }
.hv-gauge-bar { height: 8px; border-radius: 4px; background: var(--led-off); overflow: hidden; }
.hv-gauge-bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--brass), var(--brass-hi)); transition: width .2s linear; }
.hv-gauge-bar.is-full i { background: var(--danger); }
.hv-gauge-text { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- sacred stops: ten pills, two rows of five ---------- */
.hv-stops-box { padding: 8px 10px 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--panel); }
.hv-stops-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.hv-stops-head span { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.hv-stops-head small { font-size: 11px; color: var(--muted); text-align: right; opacity: .85; }
.hv-stops { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 6px; }
.hv-stop {
  display: grid; justify-items: center; align-content: center; gap: 1px; min-height: 46px; padding: 4px 2px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bench); cursor: pointer; line-height: 1.1; min-width: 0;
  transition: border-color .2s ease, background .2s ease, box-shadow .2s ease;
}
.hv-stop b { font: 600 14px/1.1 ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--brass-hi); font-variant-numeric: tabular-nums; }
.hv-stop b small { font-size: 9px; color: var(--muted); font-weight: 500; }
.hv-stop span { font-size: 10px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
@media (hover: hover) { .hv-stop:hover { border-color: var(--brass); } }   /* a tapped pill on a phone must not stay lit */
.hv-stop.is-going { border-color: var(--brass-hi); box-shadow: 0 0 0 1px var(--brass-hi) inset; }
.hv-stop.is-on, .hv-stop[aria-checked="true"] {
  border-color: var(--lock); background: rgba(255, 228, 138, .14); box-shadow: 0 0 0 1px var(--lock) inset, 0 0 16px rgba(255, 228, 138, .35);
}
.hv-stop.is-on span, .hv-stop[aria-checked="true"] span { color: var(--ink); }
.hv-stop:disabled { opacity: .45; cursor: not-allowed; }

/* ---------- PREV / NEXT LOCK ---------- */
.hv-jump { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hv-jump button, .hv-quick-btn, .hv-sheet-actions button:not(.hv-print) {
  min-height: 44px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); cursor: pointer;
  font-size: 12px; letter-spacing: .16em; text-transform: uppercase; color: var(--ink);
}
.hv-jump button:disabled { opacity: .4; cursor: not-allowed; }

.hv-actions { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 8px; }
.hv-quick-btn { padding: 0 14px; min-height: 50px; letter-spacing: .1em; color: var(--brass-hi); border-color: var(--brass-lo); }
.hv-quick-btn:disabled { opacity: .45; cursor: not-allowed; }
.hv-actions.is-confirming .hv-quick-btn { display: none; }
.hv-print {
  min-height: 50px; border-radius: 12px; border: 1px solid var(--brass-hi); cursor: pointer; font-weight: 700; letter-spacing: .28em;
  text-transform: uppercase; color: #241805; background: linear-gradient(180deg, var(--brass-hi), var(--brass));
  box-shadow: 0 6px 18px rgba(201, 162, 74, .3);
}
.hv-print:disabled { opacity: .45; cursor: not-allowed; }
.hv-print.is-ready { letter-spacing: .12em; animation: ready 1.6s ease-in-out infinite; }
@keyframes ready {
  0%, 100% { box-shadow: 0 6px 18px rgba(201, 162, 74, .3), 0 0 0 0 rgba(255, 228, 138, 0); }
  50% { box-shadow: 0 6px 26px rgba(255, 228, 138, .55), 0 0 0 5px rgba(255, 228, 138, .28); }
}
.hv-confirm { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; align-items: center; }
.hv-confirm span { grid-column: 1 / -1; text-align: center; color: var(--ink); }
.hv-confirm button:not(.hv-print), .hv-end-actions button:not(.hv-print) {
  min-height: 50px; border-radius: 12px; border: 1px solid var(--line); background: var(--panel); cursor: pointer;
}
.hv-journal { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 0; font-size: 12px; color: var(--muted); }
.hv-dots { display: grid; grid-template-columns: repeat(15, 6px); gap: 3px; }
.hv-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--led-off); }
.hv-dots i.on { background: var(--brass-hi); box-shadow: 0 0 5px rgba(244, 212, 124, .8); }

/* ---------- Quick Plate sheet ---------- */
.hv-sheet {
  width: min(460px, calc(100% - 24px)); max-height: calc(100% - 24px); overflow-y: auto; padding: 16px; border-radius: 16px;
  border: 1px solid var(--line); background: var(--panel); color: var(--ink); box-shadow: 0 20px 60px rgba(0, 0, 0, .6);
}
.hv-sheet::backdrop { background: rgba(6, 5, 4, .72); backdrop-filter: blur(4px); }
.hv-sheet h2 { margin: 0 0 4px; font-size: 15px; letter-spacing: .32em; text-transform: uppercase; color: var(--brass-hi); text-align: center; }
.hv-sheet-sub { margin: 0 0 12px; font-size: 13px; color: var(--muted); text-align: center; }
.hv-sheet-label { margin: 12px 0 6px; font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.hv-sheet-label small { letter-spacing: 0; text-transform: none; margin-left: 6px; }
.hv-sheet .hv-jars { grid-template-columns: repeat(3, 1fr); }
.hv-jar[aria-pressed="true"] { border-color: var(--brass-hi); color: var(--ink); background: rgba(201, 162, 74, .1); box-shadow: 0 0 0 1px var(--brass-hi) inset; }
.hv-sheet-actions { display: grid; grid-template-columns: 1fr 1.6fr; gap: 8px; margin-top: 14px; }

/* ---------- phone: the actions ride along at the bottom of the screen ---------- */
@media (max-width: 899px) {
  .hv-actions {
    position: sticky; bottom: 0; z-index: 5; margin: 0 -16px; padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, transparent, var(--bench) 26%);
  }
}

/* ---------- the end screen ---------- */
.hv-end {
  position: fixed; inset: 0; z-index: 10; display: grid; place-items: start center; overflow-y: auto; padding: 16px;
  background: rgba(6, 5, 4, .82); backdrop-filter: blur(6px);
}
.hv-end[hidden] { display: none; }
.hv-end-card {
  width: min(560px, 100%); margin: auto 0; padding: 16px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel);
  box-shadow: 0 20px 60px rgba(0, 0, 0, .6); display: grid; gap: 10px;
}
.hv-end h2 { margin: 0; font-size: 15px; letter-spacing: .32em; text-transform: uppercase; color: var(--brass-hi); text-align: center; }
.hv-end-sub { margin: 0; text-align: center; color: var(--muted); }
#slab { width: min(100%, calc(100vh - 470px)); min-width: 240px; height: auto; aspect-ratio: 1; border-radius: 8px; justify-self: center; }
.hv-end-line { margin: 0; text-align: center; font: 12px ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--muted); }
.hv-mantra { margin: 0; text-align: center; font-weight: 800; letter-spacing: .14em; color: var(--lock); text-shadow: 0 0 16px rgba(255, 228, 138, .7); }
.hv-end-stats { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; font-size: 13px; }
.hv-end-stats dt { color: var(--muted); }
.hv-end-stats dd { margin: 0; font-variant-numeric: tabular-nums; }
.hv-code-label { font-size: 11px; letter-spacing: .18em; text-transform: uppercase; color: var(--muted); }
.hv-code {
  display: block; max-height: 88px; overflow: auto; padding: 8px; border-radius: 8px; border: 1px solid var(--line); background: var(--bench);
  font: 11px/1.35 ui-monospace, "SF Mono", Menlo, Consolas, monospace; word-break: break-all; user-select: all;
}
.hv-end-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.hv-note { margin: 0; min-height: 1.2em; font-size: 12px; color: var(--muted); text-align: center; }
/* the site adds its shared burn-code panel (#burnCode) after this box; while the panel shows, it carries the code (with its own
   Copy button), so this box steps aside (hidden, not removed: it keeps its text) and New plate takes the row. No panel, or a panel
   that never showed: this box shows the code */
.hv-end:has(#burnCode:not([hidden])) :is(.hv-code-label, .hv-code, #copy, #copy-note) { display: none; }
.hv-end:has(#burnCode:not([hidden])) .hv-end-actions { grid-template-columns: 1fr; }

/* ---------- desktop: plate left, instruments right ---------- */
@media (min-width: 900px) {
  .hv { padding: 14px 28px 32px; }
  .hv-head h1 { font-size: 17px; }
  .hv-bench { grid-template-columns: minmax(0, 1fr) 380px; gap: 28px; align-items: start; }
  .hv-plate-wrap { width: min(100%, calc(100vh - 92px)); justify-self: center; }
  .hv-freq { font-size: 40px; }
  .hv-big .hv-knob { width: 128px; height: 128px; }
  .hv-knob { width: 88px; height: 88px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
