/* Musica Mundana
 * Two plates: Night (default) — brass engraving on a deep ink sky;
 * Vellum — iron-gall ink and hand-tinted pigments on old paper.
 * The page commits to its own plate rather than following the OS theme;
 * the canvas reads these same tokens.
 */

:root {
  color-scheme: dark;
  --ground: #05070f;
  --ground-2: #0c1124;
  --panel: rgba(11, 15, 32, 0.68);
  --panel-solid: #0d1228;
  --line: rgba(207, 174, 108, 0.22);
  --line-strong: rgba(207, 174, 108, 0.48);
  --brass: #cfae6c;
  --brass-hi: #ecd29a;
  --ink: #2a2016;
  --text: #ece4d1;
  --text-2: #aaa4b8;
  --text-3: #767089;
  --warn: #ff7a66;
  --focus: #ecd29a;
  --on-brass: #120e06;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  --veil: rgba(5, 7, 15, 0.94);

  --v-bell: #f3c96b;
  --v-glass: #8fdcf3;
  --v-harp: #86e3b0;
  --v-wood: #f29870;
  --v-choir: #b9a3ff;
  --v-low: #ff6f8f;

  --f-display: "IM Fell English", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --f-body: "EB Garamond", "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --f-mono: "IBM Plex Mono", ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;

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

:root[data-plate="vellum"] {
  color-scheme: light;
  --ground: #e9ddc3;
  --ground-2: #dccaa6;
  --panel: rgba(241, 232, 210, 0.8);
  --panel-solid: #f1e7cf;
  --line: rgba(64, 44, 20, 0.2);
  --line-strong: rgba(64, 44, 20, 0.45);
  --brass: #7c5a1f;
  --brass-hi: #4f370f;
  --ink: #2a2016;
  --text: #2a2016;
  --text-2: #5c4b34;
  --text-3: #86745a;
  --warn: #b3321f;
  --focus: #7c5a1f;
  --on-brass: #f6eed9;
  --shadow: 0 16px 40px rgba(70, 45, 15, 0.18);
  --veil: rgba(233, 221, 195, 0.95);

  --v-bell: #c08714;
  --v-glass: #2f62ae;
  --v-harp: #2b8468;
  --v-wood: #c0482a;
  --v-choir: #6a4aa2;
  --v-low: #9c1f40;
}

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

html, body { height: 100%; }
html { overflow: hidden; }

body {
  margin: 0;
  overflow: hidden;
  background: var(--ground);
  color: var(--text);
  font: 400 17px/1.5 var(--f-body);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

[hidden] { display: none !important; }

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.sr {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.micro {
  font: 500 10px/1.2 var(--f-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
}
.micro em { font-style: normal; color: var(--text-2); }
.accent { color: var(--brass); }

/* ——— The sky ——— */

#sky {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  user-select: none;
  -webkit-user-select: none;
}
#sky[data-cursor="grab"] { cursor: grab; }
#sky[data-cursor="grabbing"] { cursor: grabbing; }
#sky[data-cursor="pointer"] { cursor: pointer; }

/* ——— Heads-up display ——— */

.hud { transition: opacity 0.9s ease, transform 0.9s cubic-bezier(0.2, 0.7, 0.2, 1), visibility 0s; }
body.intro-open .hud {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease, visibility 0s 0.4s;
}
body.intro-open .masthead { transform: translateY(-10px); }
body.intro-open .palette { transform: translate(-50%, 14px); }

.masthead {
  position: fixed;
  top: calc(18px + var(--safe-t));
  left: calc(var(--gutter) + var(--safe-l));
  max-width: 330px;
  pointer-events: none;
  z-index: 5;
}
.masthead > * { margin: 0; }
.brand {
  font: 400 31px/1 var(--f-display);
  letter-spacing: 0.005em;
  color: var(--text);
}
.tagline {
  margin-top: 4px;
  font: italic 400 16px/1.3 var(--f-display);
  color: var(--text-2);
}
.system {
  margin-top: 16px;
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: auto;
}
.caption {
  margin-top: 10px;
  max-width: 34ch;
  font: italic 400 15px/1.45 var(--f-body);
  color: var(--text-2);
  text-wrap: pretty;
}

.select { position: relative; display: inline-flex; min-width: 0; }
.select select {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px 32px 6px 11px;
  font: 400 16px/1.25 var(--f-body);
  color: var(--text);
  cursor: pointer;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: border-color 0.2s;
}
.select select:hover { border-color: var(--line-strong); }
.select::after {
  content: "";
  position: absolute;
  right: 13px;
  top: 50%;
  width: 6px;
  height: 6px;
  border-right: 1.5px solid var(--text-2);
  border-bottom: 1.5px solid var(--text-2);
  transform: translateY(-70%) rotate(45deg);
  pointer-events: none;
}
.select option { background: var(--panel-solid); color: var(--text); }

.tools {
  position: fixed;
  top: calc(16px + var(--safe-t));
  right: calc(var(--gutter) - 4px + var(--safe-r));
  display: flex;
  gap: 8px;
  z-index: 5;
}

.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text-2);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  transition: color 0.2s, border-color 0.2s, background-color 0.2s;
}
.icon-btn:hover { color: var(--brass-hi); border-color: var(--line-strong); }
.icon-btn[aria-expanded="true"] { color: var(--brass-hi); border-color: var(--brass); }
.icon-btn svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#btn-sound .ico-off { display: none; }
#btn-sound[aria-pressed="true"] .ico-on { display: none; }
#btn-sound[aria-pressed="true"] .ico-off { display: block; }
#btn-sound[aria-pressed="true"] { color: var(--warn); }

.only-narrow { display: none; }

/* ——— Palette: voices, size, time ——— */

.palette {
  position: fixed;
  left: 50%;
  bottom: calc(16px + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  align-items: stretch;
  padding: 10px 6px;
  max-width: calc(100vw - 2 * var(--gutter));
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px) saturate(1.25);
  -webkit-backdrop-filter: blur(16px) saturate(1.25);
  z-index: 6;
}
.palette .group {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 2px 16px;
}
.palette .group + .group { border-left: 1px solid var(--line); }

.orbs { display: flex; gap: 9px; }
.orb {
  position: relative;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--c);
  background: radial-gradient(circle at 34% 30%, color-mix(in srgb, var(--c) 35%, #fff) 0 10%, var(--c) 48%, color-mix(in srgb, var(--c) 60%, #000) 100%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--c) 40%, transparent);
  transition: transform 0.2s cubic-bezier(0.3, 1.5, 0.5, 1), box-shadow 0.2s;
}
.orb:hover { transform: translateY(-2px) scale(1.06); }
.orb[aria-pressed="true"] {
  transform: translateY(-2px);
  box-shadow: 0 0 0 2px var(--ground-2), 0 0 0 3.5px var(--c), 0 0 22px -2px var(--c);
}
:root[data-plate="vellum"] .orb {
  background: var(--c);
  box-shadow: inset 0 0 0 1px rgba(42, 32, 22, 0.55);
}
:root[data-plate="vellum"] .orb[aria-pressed="true"] {
  box-shadow: inset 0 0 0 1px rgba(42, 32, 22, 0.55), 0 0 0 2px var(--panel-solid), 0 0 0 3.5px var(--ink);
}

.seg { display: flex; align-items: center; gap: 2px; }
.seg button {
  width: 26px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--text-3);
  transition: color 0.2s, background-color 0.2s;
}
.seg button:hover { color: var(--text); }
.seg button[aria-pressed="true"] { color: var(--brass-hi); background: color-mix(in srgb, var(--brass) 14%, transparent); }
.seg i {
  display: block;
  width: var(--d);
  height: var(--d);
  border-radius: 50%;
  background: currentColor;
}

.transport { flex-direction: row !important; align-items: center; gap: 14px !important; }
.play {
  width: 40px;
  height: 40px;
  flex: none;
  display: grid;
  place-items: center;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--brass);
  background: color-mix(in srgb, var(--brass) 12%, transparent);
  color: var(--brass-hi);
  transition: background-color 0.2s;
}
.play:hover { background: color-mix(in srgb, var(--brass) 24%, transparent); }
.play svg { width: 18px; height: 18px; fill: currentColor; }
.play .ico-play { display: none; }
.play[aria-pressed="true"] .ico-play { display: block; }
.play[aria-pressed="true"] .ico-pause { display: none; }

.tempo { display: flex; flex-direction: column; gap: 6px; }
.tempo-row { display: flex; align-items: center; gap: 10px; }
.tempo output {
  min-width: 3.4em;
  font: 500 13px/1 var(--f-mono);
  font-variant-numeric: tabular-nums;
  color: var(--text);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 124px;
  height: 22px;
  margin: 0;
  background: transparent;
  cursor: pointer;
}
input[type="range"]::-webkit-slider-runnable-track {
  height: 2px;
  border-radius: 2px;
  background: var(--line-strong);
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  margin-top: -6px;
  border-radius: 50%;
  background: var(--brass);
  border: 2px solid var(--ground-2);
  box-shadow: 0 0 0 1px var(--brass);
}
input[type="range"]::-moz-range-track { height: 2px; background: var(--line-strong); border: 0; }
input[type="range"]::-moz-range-thumb {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--brass);
  border: 2px solid var(--ground-2);
  box-shadow: 0 0 0 1px var(--brass);
}

/* ——— Setup: tuning and physics ——— */

.setup {
  position: fixed;
  right: calc(var(--gutter) + var(--safe-r));
  top: 50%;
  transform: translateY(-50%);
  width: 236px;
  display: grid;
  gap: 18px;
  padding: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  z-index: 5;
}
body.intro-open .setup { transform: translate(10px, -50%); }
.field { display: grid; gap: 7px; }
.field .select { width: 100%; }

.switches { gap: 10px; }
.switch {
  display: flex;
  align-items: flex-start;
  gap: 11px;
  padding: 0;
  border: 0;
  background: none;
  text-align: left;
  font: 400 16px/1.2 var(--f-body);
  color: var(--text);
}
.switch .track {
  position: relative;
  flex: none;
  width: 30px;
  height: 17px;
  margin-top: 1px;
  border-radius: 99px;
  border: 1px solid var(--line-strong);
  transition: background-color 0.2s, border-color 0.2s;
}
.switch .track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--text-3);
  transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
}
.switch[aria-checked="true"] .track {
  background: color-mix(in srgb, var(--brass) 22%, transparent);
  border-color: var(--brass);
}
.switch[aria-checked="true"] .track::after {
  transform: translateX(13px);
  background: var(--brass-hi);
  box-shadow: 0 0 8px color-mix(in srgb, var(--brass) 80%, transparent);
}
.sw-text small {
  display: block;
  margin-top: 2px;
  font: italic 400 13.5px/1.25 var(--f-body);
  color: var(--text-3);
}

.stepper { display: flex; align-items: center; gap: 12px; }
.stepper button {
  width: 30px;
  height: 30px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--line-strong);
  background: none;
  font: 400 18px/1 var(--f-mono);
  color: var(--text);
  transition: border-color 0.2s, color 0.2s;
}
.stepper button:hover { border-color: var(--brass); color: var(--brass-hi); }
.stepper output {
  min-width: 1.2em;
  text-align: center;
  font: 500 15px/1 var(--f-mono);
  font-variant-numeric: tabular-nums;
}

.text-btn {
  justify-self: start;
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: none;
  font: 500 10.5px/1 var(--f-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-2);
  transition: border-color 0.2s, color 0.2s;
}
.text-btn:hover { border-color: var(--warn); color: var(--warn); }

/* ——— Hint, tooltip, toast ——— */

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(var(--palette-top) + 14px);
  transform: translateX(-50%);
  width: max-content;
  max-width: min(560px, calc(100vw - 2 * var(--gutter)));
  margin: 0;
  text-align: center;
  font: italic 400 18px/1.35 var(--f-display);
  color: var(--text-2);
  text-shadow: 0 1px 14px var(--ground), 0 0 4px var(--ground);
  pointer-events: none;
  opacity: 0;
  z-index: 4;
}
.hint.show { opacity: 1; }
body.intro-open .hint.show { opacity: 0; }

.tip {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 12;
  display: grid;
  gap: 4px;
  max-width: 270px;
  padding: 10px 13px 11px;
  background: color-mix(in srgb, var(--panel-solid) 94%, transparent);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  box-shadow: var(--shadow);
  pointer-events: none;
  font: 400 15px/1.35 var(--f-body);
}
.tip-notes {
  font: 500 13px/1.4 var(--f-mono);
  color: var(--text);
}
.tip-line { color: var(--text-2); }
.tip .dim { margin-top: 3px; color: var(--text-3); letter-spacing: 0.08em; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(var(--palette-top) + 58px);
  transform: translate(-50%, 8px);
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: calc(100vw - 2 * var(--gutter));
  padding: 8px 10px 8px 18px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font: 400 16px/1.3 var(--f-body);
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 25;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
#toast-text { padding-block: 4px; }
#toast-action {
  flex: none;
  padding: 7px 13px;
  border-radius: 999px;
  border: 0;
  background: var(--brass);
  color: var(--on-brass);
  font: 500 10.5px/1 var(--f-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ——— Buttons ——— */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 0 22px;
  border-radius: 999px;
  font: 500 11.5px/1 var(--f-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  transition: background-color 0.2s, border-color 0.2s, color 0.2s, transform 0.2s;
}
.btn-primary {
  border: 1px solid var(--brass);
  background: var(--brass);
  color: var(--on-brass);
}
.btn-primary:hover { background: var(--brass-hi); border-color: var(--brass-hi); }
.btn-ghost {
  border: 1px solid var(--line-strong);
  background: transparent;
  color: var(--text);
}
.btn-ghost:hover { border-color: var(--brass); color: var(--brass-hi); }
.btn-link {
  min-height: 44px;
  padding: 0 6px;
  border: 0;
  background: none;
  color: var(--text-2);
  text-decoration: underline;
  text-underline-offset: 4px;
  text-decoration-color: var(--line-strong);
}
.btn-link:hover { color: var(--brass-hi); }

/* ——— Intro ——— */

.intro {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  padding-block: calc(40px + var(--safe-t)) calc(40px + var(--safe-b));
  padding-inline: max(var(--gutter), 6vw);
  background: linear-gradient(90deg, var(--veil) 0%, color-mix(in srgb, var(--ground) 78%, transparent) 36%, transparent 66%);
  transition: opacity 0.9s ease;
}
.intro.leaving { opacity: 0; pointer-events: none; }
.intro-inner { max-width: 560px; }
.intro-inner > * { margin: 0; animation: rise 1s cubic-bezier(0.2, 0.7, 0.2, 1) both; }
.intro-inner > :nth-child(2) { animation-delay: 0.08s; }
.intro-inner > :nth-child(3) { animation-delay: 0.16s; }
.intro-inner > :nth-child(4) { animation-delay: 0.24s; }
.intro-inner > :nth-child(5) { animation-delay: 0.32s; }
.intro-inner > :nth-child(6) { animation-delay: 0.4s; }
@keyframes rise {
  from { opacity: 0.001; transform: translateY(12px); }
  to { opacity: 1; transform: none; }
}
.intro-eyebrow em { font-style: italic; text-transform: none; letter-spacing: 0.04em; font-family: var(--f-body); font-size: 13px; }
.intro-title {
  margin-top: 18px !important;
  font: 400 clamp(56px, 8.4vw, 118px)/0.9 var(--f-display);
  letter-spacing: -0.012em;
  color: var(--text);
  text-wrap: balance;
}
.intro-lede {
  margin-top: 14px !important;
  font: italic 400 clamp(21px, 2.1vw, 27px)/1.25 var(--f-display);
  color: var(--brass-hi);
}
.intro-body {
  margin-top: 22px !important;
  max-width: 33em;
  font: 400 19px/1.55 var(--f-body);
  color: var(--text);
  text-wrap: pretty;
}
.intro-actions {
  margin-top: 30px !important;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}
.intro-fine {
  margin-top: 22px !important;
  font: italic 400 15px/1.4 var(--f-body);
  color: var(--text-3);
}

/* ——— Almanac ——— */

.almanac {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 30;
  width: min(480px, 100%);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-block: calc(30px + var(--safe-t)) calc(48px + var(--safe-b));
  padding-inline: 34px calc(34px + var(--safe-r));
  background: var(--panel-solid);
  border-left: 1px solid var(--line);
  box-shadow: -30px 0 80px rgba(0, 0, 0, 0.35);
  animation: slide-in 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
}
@keyframes slide-in {
  from { transform: translateX(40px); opacity: 0.001; }
  to { transform: none; opacity: 1; }
}
.almanac-close { position: absolute; top: calc(18px + var(--safe-t)); right: calc(18px + var(--safe-r)); }
.almanac h2 {
  margin: 12px 0 0;
  max-width: 13em;
  font: 400 36px/1.05 var(--f-display);
  text-wrap: balance;
}
.almanac h3 {
  margin: 34px 0 0;
  font: italic 400 24px/1.2 var(--f-display);
  color: var(--brass-hi);
}
.almanac p { margin: 12px 0 0; font: 400 18px/1.6 var(--f-body); text-wrap: pretty; }
.almanac .lead { margin-top: 18px; font-size: 19.5px; color: var(--text); }
.almanac strong { font-weight: 500; color: var(--brass-hi); }
.table-wrap { margin-top: 16px; overflow-x: auto; }
.kepler { width: 100%; border-collapse: collapse; font: 400 16.5px/1.3 var(--f-body); }
.kepler th {
  padding: 0 10px 8px 0;
  text-align: left;
  font: 500 9.5px/1.2 var(--f-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-3);
  border-bottom: 1px solid var(--line-strong);
}
.kepler td { padding: 8px 10px 8px 0; border-bottom: 1px solid var(--line); }
.kepler td.num { font: 500 13.5px/1.3 var(--f-mono); font-variant-numeric: tabular-nums; white-space: nowrap; }
.keys {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 8px 18px;
  margin: 16px 0 0;
  font: 400 16.5px/1.4 var(--f-body);
}
.keys dt { color: var(--brass-hi); font-style: italic; }
.keys dd { margin: 0; color: var(--text-2); }
kbd {
  display: inline-block;
  min-width: 1.6em;
  padding: 1px 6px;
  border: 1px solid var(--line-strong);
  border-bottom-width: 2px;
  border-radius: 5px;
  font: 500 11.5px/1.5 var(--f-mono);
  font-style: normal;
  text-align: center;
  color: var(--text);
}
.almanac .colophon {
  margin-top: 36px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font: italic 400 15.5px/1.5 var(--f-body);
  color: var(--text-3);
}

/* ——— Share ——— */

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding-inline: var(--gutter);
  background: rgba(3, 4, 10, 0.5);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}
.sheet {
  position: relative;
  width: min(480px, 100%);
  padding: 26px 26px 24px;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: var(--shadow);
}
.sheet h2 { margin: 10px 0 0; font: 400 30px/1.1 var(--f-display); }
.sheet > p { margin: 10px 0 20px; font: 400 17px/1.5 var(--f-body); color: var(--text-2); }
.sheet .micro { display: block; margin: 16px 0 8px; }
.sheet-close { position: absolute; top: 14px; right: 14px; }
.copy-row { display: flex; gap: 8px; margin: 0; }
.text-field {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: var(--ground);
  font: 400 12.5px/1 var(--f-mono);
  color: var(--text);
}
.text-field::placeholder { color: var(--text-3); }
.field-error { margin: 10px 0 0; font: italic 400 15px/1.4 var(--f-body); color: var(--warn); }

/* ——— Imprint and privacy ——— */

.legal-links { color: var(--text-2); }
.legal-links a {
  color: inherit;
  text-decoration: none;
  transition: color 0.2s;
}
.legal-links a:hover { color: var(--brass-hi); }
.legal {
  position: fixed;
  left: calc(var(--gutter) + var(--safe-l));
  bottom: calc(18px + var(--safe-b));
  z-index: 21; /* above the intro veil */
  display: flex;
  gap: 8px;
  transition: opacity 0.9s ease, visibility 0s;
}
.almanac .legal-links { margin-top: 14px; font: 500 10px/1.2 var(--f-mono); }

/* ——— Narrower screens ——— */

@media (max-width: 999px) {
  .only-narrow { display: grid; }
  .setup {
    top: auto;
    left: calc(var(--gutter) + var(--safe-l));
    right: calc(var(--gutter) + var(--safe-r));
    bottom: calc(var(--palette-top) + 10px);
    width: auto;
    max-width: 560px;
    margin-inline: auto;
    grid-template-columns: 1fr 1fr;
    align-items: start;
    background: var(--panel-solid);
    box-shadow: var(--shadow);
    transform: translateY(10px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s, transform 0.25s, visibility 0s 0.25s;
    z-index: 7;
  }
  .setup.open {
    transform: none;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s, transform 0.25s, visibility 0s;
  }
  body.intro-open .setup { transform: translateY(10px); }
  .setup .switches { grid-column: 1 / -1; }
  .caption { max-width: 40ch; }
  /* The palette needs the bottom edge; the almanac carries the links from here on. */
  body:not(.intro-open) .legal {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0s 0.4s;
  }
}

@media (max-width: 899px) {
  .intro {
    align-items: flex-end;
    padding-bottom: calc(64px + var(--safe-b)); /* room for the imprint/privacy links */
    background: linear-gradient(180deg, transparent 0%, color-mix(in srgb, var(--ground) 70%, transparent) 30%, var(--veil) 52%);
  }
}

@media (max-width: 640px) {
  :root { --gutter: 16px; }
  .masthead { top: calc(20px + var(--safe-t)); max-width: calc(100vw - 2 * var(--gutter)); }
  .brand { font-size: 23px; }
  .tagline { display: none; }
  .system { margin-top: 16px; }
  .caption { font-size: 14px; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
  .tools { top: calc(14px + var(--safe-t)); gap: 4px; }
  .tools .icon-btn { width: 34px; height: 34px; }
  .tools .icon-btn svg { width: 16px; height: 16px; }
  #btn-full { display: none; }

  .palette {
    display: grid;
    grid-template-columns: auto 1fr;
    row-gap: 10px;
    width: calc(100vw - 2 * var(--gutter));
    padding: 12px 4px;
  }
  .palette .group { padding: 0 12px; }
  .palette .voices { grid-column: 1 / -1; flex-direction: row; align-items: center; justify-content: space-between; }
  .palette .voices .micro { display: none; }
  .orbs { width: 100%; justify-content: space-between; }
  .orb { width: 32px; height: 32px; }
  .palette .group + .group { border-left: 0; }
  .palette .transport { border-left: 1px solid var(--line) !important; justify-content: flex-start; }
  .tempo input[type="range"] { width: 100%; min-width: 80px; }
  .tempo { flex: 1; }
  .setup { grid-template-columns: 1fr; gap: 14px; }

  .intro-body { font-size: 17.5px; }
  .almanac { padding-inline: 22px calc(22px + var(--safe-r)); }
  .almanac h2 { font-size: 30px; max-width: 11em; }
  .copy-row { flex-wrap: wrap; }
  .copy-row .btn { flex: 1; }
}

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