/* Resonance for the web: the plate lying wide, the meter beneath it.
   Tokens match the app player: one signal colour, everything else ink on paper. */
:root { --top-h: 88px; }
@media (max-width: 760px) { :root { --top-h: 64px; } }
:root {
  --bg: #F2F1ED; --panel: #F7F6F2; --ink: #1A1A18; --text2: #62635F; --text3: #8A8B86;
  --sep: #DEDDD7; --sep2: #C4C3BD; --signal: #E0531F;
  --plate: #EBE9E3;
  --aspect: 1.6;
  --gutter: 32px;
  --chrome: 360px; /* everything above and below the plate, plus air; web.js measures it */
  --w: min(1180px, 100vw - 2 * var(--gutter), max(500px, (100dvh - var(--chrome)) * var(--aspect)));
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #000; --panel: #0B0B0A; --ink: #F2F1ED; --text2: #A6A6A0; --text3: #8A8984;
    --sep: #2C2C28; --sep2: #45453F; --signal: #F0612B; --plate: #000;
  }
}
:root[data-theme="dark"] {
  --bg: #000; --panel: #0B0B0A; --ink: #F2F1ED; --text2: #A6A6A0; --text3: #8A8984;
  --sep: #2C2C28; --sep2: #45453F; --signal: #F0612B; --plate: #000;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { min-height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: Inter, "Helvetica Neue", Helvetica, Arial, sans-serif; -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 1, "case" 1;
  min-height: 100vh; min-height: 100dvh;
  display: flex; justify-content: center; align-items: center;
}
button { font: inherit; color: inherit; }
button:focus-visible, .scale:focus-visible { outline: 1px solid var(--signal); outline-offset: 3px; }

.page { width: max(var(--w), 280px); padding: 24px 0; display: flex; flex-direction: column; }
.label { font-size: 10px; font-weight: 500; letter-spacing: 1.6px; text-transform: uppercase; color: var(--text3); }

.bar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; min-height: 32px;
  padding-bottom: 8px; border-bottom: 1px solid var(--ink); }
.bar-right { display: flex; align-items: center; gap: 14px; white-space: nowrap; justify-self: end;
  margin-right: var(--corner-w, 0px); } /* clear of the pinned App · Shop · menu */
/* The Align Instruments lockup, top centre on every page; it leads home. */
.site-logo { display: block; color: var(--ink); justify-self: center; }
.site-logo svg { display: block; width: 100%; height: auto; }
.iconbtn { width: 28px; height: 28px; display: grid; place-items: center; background: none; border: 0; cursor: pointer;
  margin-right: -6px; color: var(--ink); }
.linkbtn { background: none; border: 0; cursor: pointer; padding: 0; color: var(--text2); }
.linkbtn:hover { color: var(--ink); }
.status { display: inline-flex; align-items: center; gap: 8px; }
.lamp { width: 7px; height: 7px; border-radius: 50%; border: 0.5px solid var(--sep2); background: transparent;
  transition: background .3s, box-shadow .3s; }
.lamp.on { background: var(--signal); border-color: var(--signal); box-shadow: 0 0 0 3px color-mix(in srgb, var(--signal) 18%, transparent); }

/* The plate in a thin frame: black steel with pale sand, or (light) a pale plate with black sand. */
.plate { position: relative;
  /* Full column width, unless the screen is too short: then it shrinks and centres, like in the app. */
  width: max(200px, min(100% - 11px, (100dvh - var(--chrome)) * var(--aspect))); margin: 20px auto 0; aspect-ratio: var(--aspect);
  background: var(--plate); border-radius: 3px; cursor: pointer;
  box-shadow: 0 0 0 0.5px var(--sep2), 0 0 0 5px var(--panel), 0 0 0 5.5px var(--sep2); overflow: hidden; }
.plate canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }

.readout { display: grid; grid-template-columns: 1fr auto auto; align-items: end; gap: 40px; margin-top: 22px; }
.freq { font-size: 40px; font-weight: 300; letter-spacing: -1.5px; line-height: 1; }
.freq small { font-size: 13px; letter-spacing: 0.5px; color: var(--text2); margin-left: 6px; font-weight: 400; }
.sub { margin-top: 8px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.meta { display: grid; gap: 7px; min-width: 150px; padding-bottom: 2px; }
.meta .row { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.meta .val { font-size: 13px; }
.leds { display: flex; gap: 4px; }
.leds i { width: 6px; height: 6px; border-radius: 50%; border: 0.5px solid var(--sep2); }
.leds i.on { background: var(--ink); border-color: var(--ink); }
.leds i.on:nth-last-child(-n+2) { background: var(--signal); border-color: var(--signal); }

.transport { display: flex; align-items: center; gap: 12px; }
.key { width: 48px; height: 48px; border-radius: 50%; border: 1px solid var(--signal); background: var(--signal); color: #FFF;
  display: grid; place-items: center; cursor: pointer; }
.key.small { width: 34px; height: 34px; }
.key.ghost { background: transparent; color: var(--ink); border-color: var(--sep2); }
.key:active { opacity: .75; transform: scale(.97); }
.key .i-stop, .key.on .i-play { display: none; }
.key.on .i-stop { display: block; }

/* The frequency meter, as in the app: log scale, resonance marks above, needle in signal orange. */
.scale { display: block; width: 100%; height: 50px; margin-top: 14px; touch-action: none; cursor: ew-resize; }
.scale .res { stroke: var(--sep2); stroke-width: 1; }
.scale .tick { stroke: var(--text3); stroke-width: 1; }
.scale .tick.major { stroke: var(--ink); }
.scale .base { stroke: var(--ink); stroke-width: 1; }
.scale text { font-size: 9px; fill: var(--text3); letter-spacing: 0.5px; font-family: inherit; }
.scale .needle { stroke: var(--signal); stroke-width: 2; }
.scale .needle.minor { stroke-width: 1; opacity: .55; }
.scale.locked { cursor: default; }

/* One quiet row: which bank, which preset, which voices. */
.controls { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 32px; margin-top: 16px;
  padding-top: 12px; border-top: 0.5px solid var(--sep2); }
.banks, .presets, .voices { display: flex; align-items: center; }
.banks { gap: 18px; }
.presets { gap: 4px; justify-content: center; flex-wrap: wrap; }
.presets[hidden] { display: none; }
.voices { gap: 12px; }
.banks button, .presets button, .voices button { border: 0; background: none; cursor: pointer; height: 28px;
  display: inline-flex; align-items: center; gap: 6px; }
.banks button { font-size: 12px; letter-spacing: 0.5px; color: var(--text3); }
.banks button::before { content: ""; width: 5px; height: 5px; border-radius: 50%; background: transparent; }
.banks button[aria-pressed="true"] { color: var(--ink); }
.banks button[aria-pressed="true"]::before { background: var(--signal); }
.presets button { padding: 0 8px; border-radius: 6px; border: 0.5px solid transparent; font-size: 11px; color: var(--text2); }
.presets button:hover { color: var(--ink); }
.presets button[aria-pressed="true"] { border-color: var(--ink); color: var(--ink); }
.presets.named small { font-size: 10px; color: var(--text3); }
.voices button { font-size: 10px; font-weight: 500; letter-spacing: 1.2px; text-transform: uppercase; color: var(--text3); padding: 0; }
.voices button i { width: 6px; height: 6px; border-radius: 50%; border: .5px solid var(--sep2); }
.voices button[aria-pressed="true"] { color: var(--ink); }
.voices button[aria-pressed="true"] i { background: var(--signal); border-color: var(--signal); }
.voices button:disabled { opacity: .3; cursor: default; }
.caption { margin-top: 10px; height: 14px; text-align: center; }
.caption { font-size: 10px; font-weight: 500; letter-spacing: 1.6px; text-transform: uppercase; color: var(--text3); }

/* Safety sheet. */
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,0.42); display: grid; place-items: center; z-index: 5;
  padding: 16px; animation: fade .25s ease; }
.sheet[hidden] { display: none; }
.sheet-card { width: min(440px, 100%); background: var(--bg); border-top: 1px solid var(--ink); padding: 26px 24px 28px;
  animation: rise .3s cubic-bezier(.2,.8,.2,1); }
.sheet-card h2 { font-size: 26px; font-weight: 400; letter-spacing: -0.8px; margin: 10px 0 18px; }
.sheet-card ul { list-style: none; border-top: 0.5px solid var(--sep2); margin-bottom: 24px; }
.sheet-card li { display: grid; grid-template-columns: 34px 1fr; padding: 13px 0; border-bottom: 0.5px solid var(--sep2);
  font-size: 14px; line-height: 1.4; }
.sheet-card li span { font-size: 10px; letter-spacing: 1px; color: var(--signal); padding-top: 3px; }
.confirm { width: 100%; height: 52px; border-radius: 26px; border: 1px solid var(--ink); background: var(--ink); color: var(--bg);
  font-size: 14px; letter-spacing: 0.3px; cursor: pointer; }
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { transform: translateY(24px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .sheet, .sheet-card { animation: none; } }

/* Narrower columns: the controls stack, the plate keeps its full width.
   Container queries, because the column narrows on short screens too. */
.page { container-type: inline-size; }
@container (max-width: 880px) {
  .controls { grid-template-columns: 1fr auto; gap: 10px 16px; }
  .presets { grid-column: 1 / -1; grid-row: 2; display: grid; grid-template-columns: repeat(5, 1fr);
    min-height: 60px; align-content: center; } /* two rows of numbers or one of names: same height, nothing jumps */
  .presets[hidden] { display: none; }
  .presets button { justify-content: center; }
}
/* Too narrow for three across with the corner menu: the lockup takes its own row, centred, above status and buttons. */
@container (max-width: 1100px) {
  .bar { grid-template-columns: auto 1fr; row-gap: 10px; }
  .site-logo { grid-column: 1 / -1; grid-row: 1; }
}
@container (max-width: 480px) {
  .bar-right { gap: 10px; }
  .status-name { display: none; }
  .readout { grid-template-columns: 1fr auto; gap: 16px 12px; margin-top: 18px; }
  .meta { grid-column: 1 / -1; grid-row: 2; grid-template-columns: 1fr 1fr; gap: 20px; }
  .freq { font-size: 34px; }
  .controls { grid-template-columns: 1fr; }
  .banks { justify-content: space-between; }
  .presets { grid-row: auto; }
  .voices { justify-content: space-between; }
  .presets.named button { padding: 0 4px; flex-direction: column; justify-content: center; gap: 0; height: 36px; }
}
@media (max-width: 560px) {
  /* Phones: full width, the page may scroll a little rather than shrink the plate. */
  :root { --gutter: 16px; --w: calc(100vw - 2 * var(--gutter)); }
  body { align-items: flex-start; }
  .page { padding: 16px 0 24px; }
  .plate { margin-top: 16px; width: calc(100% - 11px); }
}

/* View switch: three small outlines, the active one in ink with a signal underline. */
.views { display: flex; gap: 2px; }
.views button { width: 30px; height: 28px; display: grid; place-items: center; border: 0; background: none; cursor: pointer;
  color: var(--text3); position: relative; }
.views button:hover { color: var(--ink); }
.views button[aria-pressed="true"] { color: var(--ink); }
.views button[aria-pressed="true"]::after { content: ""; position: absolute; bottom: 1px; left: 50%; width: 4px; height: 4px;
  margin-left: -2px; border-radius: 50%; background: var(--signal); }
.linkbtn.get { color: var(--ink); }

/* Full screen: the sand is the page. Meter and readout float at the bottom and fade when you stop moving. */
.full body { overflow: hidden; background: var(--plate); }
/* The bottom block (readout, meter, banks, presets, sounds) stacks against the lower edge as one column. */
.full .page { position: fixed; inset: 0; width: auto; padding: 0 var(--gutter) 18px;
  justify-content: flex-end; pointer-events: none; }
.full .page > * { pointer-events: auto; }
.full .plate { position: fixed; inset: 0; width: 100%; height: 100%; margin: 0; aspect-ratio: auto; border-radius: 0; box-shadow: none; }
.full .bar { position: fixed; top: 0; left: var(--gutter); right: var(--gutter); height: auto; padding: 0; border: 0;
  grid-template-rows: var(--top-h); grid-auto-rows: auto; } /* first row as tall as the site head: the lockup sits where it sits on every page */
.full .bar, .full .readout, .full .scale, .full .controls, .full .caption { z-index: 2; transition: opacity .6s ease; }
.full .readout, .full .scale, .full .controls, .full .caption { position: relative; }
.full .readout { margin-top: 0; }
.full .controls { margin-top: 10px; }
.full .caption { margin-top: 6px; }
/* Veils behind the bar and the bottom block; --hud is the block's measured height (web.js). */
.full .page::after { content: ""; position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--hud, 300px) + 90px);
  pointer-events: none; z-index: 1;
  background: linear-gradient(to top, color-mix(in srgb, var(--plate) 94%, transparent) 0,
    color-mix(in srgb, var(--plate) 88%, transparent) calc(100% - 90px), transparent); transition: opacity .6s ease; }
.full .page::before { content: ""; position: fixed; left: 0; right: 0; top: 0; height: 90px; pointer-events: none; z-index: 1;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--plate) 88%, transparent), transparent); transition: opacity .6s ease; }
.full .page.idle .bar, .full .page.idle .readout, .full .page.idle .scale, .full .page.idle .controls, .full .page.idle .caption,
.full .page.idle::after, .full .page.idle::before { opacity: 0; }
.full .page.idle { cursor: none; }

@media (max-width: 560px) {
  .bar-right { gap: 10px; }
  .views button { width: 26px; }
}

/* Colours: the button shows the current plate with its sand; the panel holds all twenty. */
.bar { position: relative; }
.colour-btn .chip { width: 16px; height: 16px; border-radius: 50%; background: var(--sw-plate, var(--plate));
  box-shadow: 0 0 0 1px var(--sep2); display: grid; place-items: center; }
.colour-btn .chip i { width: 6px; height: 6px; border-radius: 50%; background: var(--sw-sand, var(--ink)); }
.palettes { position: absolute; top: calc(100% + 10px); right: 0; z-index: 6; width: 300px; max-width: calc(100vw - 2 * var(--gutter));
  padding: 14px 14px 12px; background: var(--bg); border: 0.5px solid var(--sep2); border-top: 1px solid var(--ink);
  box-shadow: 0 18px 40px rgba(0,0,0,.18); animation: rise .2s cubic-bezier(.2,.8,.2,1); }
.palettes[hidden] { display: none; }
.swatches { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
/* A swatch is a little plate: its colour, a ring of its sand. */
.swatch { height: 34px; border-radius: 3px; border: 0; cursor: pointer; background: var(--sw-plate);
  box-shadow: inset 0 0 0 0.5px rgba(128,128,128,.35); display: grid; place-items: center; position: relative; }
.swatch i { width: 18px; height: 18px; border-radius: 50%;
  /* a ring of speckled sand: dots masked to a band */
  background: radial-gradient(var(--sw-sand) 0.9px, transparent 1.3px) 0 0 / 2.6px 2.6px;
  -webkit-mask: radial-gradient(circle, transparent 4.5px, #000 5px, #000 9px, transparent 9.5px);
          mask: radial-gradient(circle, transparent 4.5px, #000 5px, #000 9px, transparent 9.5px); }
.swatch[aria-pressed="true"] { box-shadow: 0 0 0 1px var(--bg), 0 0 0 2px var(--ink); }
.swatch:hover i { transform: scale(1.15); }
.palette-name { margin-top: 12px; padding-top: 10px; border-top: 0.5px solid var(--sep2); color: var(--ink); }
.full .palettes { position: fixed; top: 52px; right: var(--gutter); }
/* Full screen: the greys are mixed from ink and plate, so labels read on every palette, mid-tones too. */
:root.full {
  --text2: color-mix(in srgb, var(--ink) 82%, var(--plate));
  --text3: color-mix(in srgb, var(--ink) 66%, var(--plate));
  --sep2: color-mix(in srgb, var(--ink) 38%, var(--plate));
}
