/* =========================================================================
   TEMPO — "The Dial"  ·  incandescent analog-instrument aesthetic
   One luminous circular instrument on an obsidian stage.
   ========================================================================= */
:root {
  --stage: #0a0807;
  --stage-2: #0f0c0a;
  --panel: rgba(28, 23, 19, 0.62);
  --panel-solid: #15110d;
  --face: #100c09;
  --face-edge: #221a13;

  --bone: #f3ece0;
  --bone-2: #b6ab9a;
  --bone-3: #756c5f;
  --line: rgba(243, 236, 224, 0.08);
  --line-2: rgba(243, 236, 224, 0.16);

  --amber: #ff9d44;
  --amber-2: #ffce8c;
  --amber-deep: #b65216;
  --amber-glow: rgba(255, 157, 68, 0.55);

  --ok: #ffe7ab;          /* in-tune / locked white-gold */
  --ok-bloom: rgba(255, 231, 171, 0.6);
  --near: #ff9d44;
  --off: #e2613a;         /* warm terracotta for far-off */

  --serif: "Instrument Serif", Georgia, serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;

  --r: 14px;
  --r-lg: 22px;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: var(--sans);
  color: var(--bone);
  background: var(--stage);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
button { font-family: inherit; color: inherit; }

/* atmospheric stage */
.stage-bg {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% -12%, #1c140d 0%, rgba(10,8,7,0) 55%),
    radial-gradient(90% 70% at 50% 120%, #130f0c 0%, rgba(10,8,7,0) 60%);
}
.stage-bg::after { /* film grain */
  content: ""; position: absolute; inset: 0; opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
/* breathing aura that pulses with the beat */
.stage-aura {
  position: fixed; left: 50%; top: 46%; width: 900px; height: 900px;
  transform: translate(-50%, -50%); z-index: 0; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, var(--amber-glow) 0%, rgba(255,157,68,0) 62%);
}

.app { position: relative; z-index: 1; min-height: 100vh; display: flex; flex-direction: column; }

/* ---------------- Header ---------------- */
.app-head {
  display: grid; grid-template-columns: 1fr auto 1fr; align-items: center;
  padding: 22px 30px; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 10px; display: grid; place-items: center;
  color: var(--stage); background: linear-gradient(150deg, var(--amber-2), var(--amber));
  box-shadow: 0 6px 20px -6px var(--amber-glow);
}
.brand-name { font-family: var(--serif); font-style: italic; font-size: 23px; letter-spacing: .01em; line-height: 1; }
.brand-sub { font-size: 10px; letter-spacing: .34em; text-transform: uppercase; color: var(--bone-3); margin-top: 3px; }

/* mode switch */
.mode-switch { justify-self: center; position: relative; display: flex; background: var(--panel-solid); border: 1px solid var(--line-2); border-radius: 99px; padding: 5px; gap: 2px; }
.mode-switch .thumb { position: absolute; top: 5px; bottom: 5px; width: calc(50% - 5px); border-radius: 99px;
  background: linear-gradient(150deg, color-mix(in srgb, var(--amber-2) 16%, transparent), color-mix(in srgb, var(--amber) 12%, transparent)); border: 1px solid color-mix(in srgb, var(--amber) 30%, transparent);
  transition: transform .34s cubic-bezier(.5,.1,.2,1); }
.mode-switch.tuner .thumb { transform: translateX(100%); }
.mode-btn { position: relative; z-index: 1; display: inline-flex; align-items: center; gap: 8px; border: 0; background: none;
  padding: 9px 22px; font-size: 13px; font-weight: 500; letter-spacing: .04em; color: var(--bone-3); cursor: pointer; border-radius: 99px; transition: color .25s; }
.mode-btn.active { color: var(--bone); }
.mode-btn.active svg { color: var(--amber); }

.head-right { justify-self: end; display: flex; align-items: center; gap: 10px; font-size: 11px; color: var(--bone-3); letter-spacing: .12em; }
.ref-pill { border: 1px solid var(--line); border-radius: 99px; padding: 6px 12px; font-family: var(--mono); }

/* ---------------- Main / stage ---------------- */
.app-main { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 4px 20px 28px; gap: 18px; }
/* .mode-pane holds the fixed .sheet-backdrop as a child, and its paneIn animation
   makes it a stacking context — so the backdrop's z-index is scoped to the pane.
   Lift the whole pane above the mode-switch (whose active tab is z-index:1) so the
   presets sheet paints OVER the Metronome/Tuner tabs. Fade via OPACITY only, never
   a transform: a transform would also make the pane the containing block for the
   fixed backdrop, shrinking it to the pane instead of covering the viewport. */
.mode-pane { display: flex; flex-direction: column; align-items: center; gap: 18px; width: 100%; position: relative; z-index: 2; animation: paneIn .45s ease both; }
@keyframes paneIn { from { opacity: 0; } to { opacity: 1; } }

/* overline above the dial */
.dial-overline { display: flex; align-items: center; gap: 14px; color: var(--bone-3); font-size: 11px; letter-spacing: .32em; text-transform: uppercase; }
.dial-overline .dot { width: 4px; height: 4px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 8px var(--amber); }
.dial-overline b { color: var(--bone-2); font-weight: 500; }

/* ---------------- The Dial ---------------- */
.dial-wrap { position: relative; width: min(74vw, 46vh, 440px); aspect-ratio: 1; }
.dial-glow { position: absolute; inset: -12%; border-radius: 50%; opacity: .0;
  background: radial-gradient(circle, var(--amber-glow) 0%, rgba(255,157,68,0) 60%); pointer-events: none; }
.dial-wrap.live .dial-glow { animation: none; }
.dial-svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }

.tick { stroke: var(--line-2); }
.tick.major { stroke: var(--bone-3); }
.dial-rim { fill: none; stroke: var(--face-edge); stroke-width: 2; }
.ring-hit { fill: none; stroke: transparent; stroke-width: 46; cursor: grab; }
.ring-hit:active { cursor: grabbing; }

.beat-dot { cursor: pointer; transition: r .12s ease; }
.beat-dot .bd-ring { fill: var(--face); stroke: var(--line-2); stroke-width: 2; transition: all .12s ease; }
.beat-dot.strong .bd-ring { stroke: color-mix(in srgb, var(--amber) 45%, transparent); }
.beat-dot.mute .bd-ring { stroke-dasharray: 3 4; opacity: .5; }
.beat-dot.live .bd-ring { fill: var(--amber); stroke: var(--amber-2); filter: drop-shadow(0 0 10px var(--amber-glow)); }
.beat-dot .bd-num { fill: var(--bone-3); font-family: var(--mono); font-size: 13px; text-anchor: middle; dominant-baseline: middle; pointer-events: none; transition: fill .12s; }
.beat-dot.live .bd-num { fill: var(--stage); font-weight: 600; }

.sweep { stroke: var(--amber); stroke-width: 2.5; stroke-linecap: round; opacity: .5; filter: drop-shadow(0 0 6px var(--amber-glow)); }

/* dial face (center, HTML overlay) */
.dial-face {
  position: absolute; inset: 19%; border-radius: 50%;
  background: radial-gradient(120% 120% at 50% 30%, var(--stage-2), var(--face) 70%);
  border: 1px solid var(--face-edge);
  box-shadow: inset 0 2px 14px rgba(0,0,0,.7), inset 0 0 0 1px rgba(255,255,255,.02), 0 24px 60px -30px #000;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  cursor: pointer; user-select: none; -webkit-user-select: none; overflow: hidden;
}
.dial-face::before { content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(120% 90% at 50% 0%, color-mix(in srgb, var(--amber-2) 7%, transparent), transparent 60%); }
.dial-face .ripple { position: absolute; inset: 0; border-radius: 50%; border: 1px solid var(--amber); opacity: 0; pointer-events: none; }

.bpm-big { font-family: var(--mono); font-size: clamp(34px, 7.5vh, 58px); font-weight: 600; line-height: .82;
  letter-spacing: -.04em; font-variant-numeric: tabular-nums; color: var(--bone);
  position: relative; z-index: 1; transition: color .2s; }
.dial-caption { font-size: 10px; letter-spacing: .2em; text-transform: uppercase; color: var(--bone-3); margin-top: -6px; }
.dial-caption b { color: var(--amber); font-weight: 500; }
.dial-wrap.playing .bpm-big { color: var(--amber-2); text-shadow: 0 0 34px var(--amber-glow); }
.bpm-unit { font-size: 11px; letter-spacing: .34em; color: var(--bone-3); margin-top: 8px; position: relative; z-index: 1; }
.tempo-name { font-family: var(--serif); font-style: italic; font-size: clamp(16px, 4.5vw, 22px); color: var(--amber); margin-top: 6px; position: relative; z-index: 1; }
.dial-hint { position: absolute; bottom: 15%; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--bone-3); opacity: .7; z-index: 1; }
.play-glyph { position: absolute; bottom: 12%; color: var(--amber); z-index: 1; opacity: .85; }

/* ---------------- Tempo line (under dial) ---------------- */
.tempo-line { display: flex; align-items: center; gap: 16px; width: min(74vw, 46vh, 440px); }
.nudge { width: 44px; height: 44px; flex: none; border-radius: 50%; border: 1px solid var(--line-2); background: var(--panel-solid);
  display: grid; place-items: center; cursor: pointer; color: var(--bone-2); transition: all .15s; }
.nudge:hover { color: var(--amber); border-color: color-mix(in srgb, var(--amber) 50%, transparent); box-shadow: 0 0 18px -6px var(--amber-glow); }
.nudge:active { transform: scale(.94); }
.tempo-rail { position: relative; flex: 1; height: 44px; display: flex; align-items: center; }
input[type="range"].rail { -webkit-appearance: none; appearance: none; accent-color: var(--amber); width: 100%; height: 2px; background: var(--line-2); cursor: pointer; outline: none; border-radius: 2px; }
input[type="range"].rail::-webkit-slider-thumb { -webkit-appearance: none; appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--amber); box-shadow: 0 0 0 5px color-mix(in srgb, var(--amber) 16%, transparent), 0 0 16px var(--amber-glow); cursor: grab; }
input[type="range"].rail::-moz-range-thumb { width: 14px; height: 14px; border: 0; border-radius: 50%; background: var(--amber); cursor: grab; }
.tap-pad { flex: none; height: 44px; padding: 0 18px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--panel-solid);
  font-size: 13px; letter-spacing: .04em; color: var(--bone); cursor: pointer; display: inline-flex; align-items: center; gap: 8px; transition: all .12s; }
.tap-pad:hover { border-color: color-mix(in srgb, var(--amber) 50%, transparent); }
.tap-pad:active, .tap-pad.flash { background: var(--amber); color: var(--stage); border-color: var(--amber); }

/* ---------------- Dock ---------------- */
.dock { display: flex; flex-wrap: wrap; justify-content: center; align-items: stretch; gap: 10px;
  background: var(--panel); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 99px;
  padding: 9px; box-shadow: 0 20px 60px -30px #000, inset 0 1px 0 rgba(255,255,255,.03); max-width: 100%; }
.dock-mod { position: relative; display: inline-flex; align-items: center; gap: 9px; border: 0; background: transparent; cursor: pointer;
  padding: 9px 16px; border-radius: 99px; color: var(--bone-2); transition: background .15s, color .15s; }
.dock-mod:hover { background: rgba(243,236,224,.05); color: var(--bone); }
.dock-mod.active { color: var(--amber); background: color-mix(in srgb, var(--amber) 8%, transparent); }
.dock-mod .dm-label { font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: var(--bone-3); }
.dock-mod .dm-val { font-family: var(--mono); font-size: 15px; color: var(--bone); }
.dock-mod.active .dm-val { color: var(--amber); }
.dock-mod .dm-stack { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.2; gap: 1px; }
.dock-mod svg { color: inherit; }
.dock-div { width: 1px; align-self: stretch; background: var(--line); margin: 6px 0; }

/* popover */
.popover { position: absolute; bottom: calc(100% + 12px); left: 50%; transform: translateX(-50%); z-index: 50;
  background: var(--panel-solid); border: 1px solid var(--line-2); border-radius: 18px; padding: 18px; min-width: 250px;
  box-shadow: 0 30px 70px -24px #000; animation: popIn .18s ease; }
@keyframes popIn { from { opacity: .4; transform: translateX(-50%) translateY(8px); } to { opacity: 1; transform: translateX(-50%) translateY(0); } }
.popover::after { content: ""; position: absolute; top: 100%; left: 50%; transform: translateX(-50%); border: 7px solid transparent; border-top-color: var(--line-2); }
.pop-title { font-size: 10px; letter-spacing: .16em; text-transform: uppercase; color: var(--bone-3); margin-bottom: 12px; }
.meter-row { display: flex; align-items: center; gap: 10px; }
.meter-row .ts-slash { font-family: var(--serif); font-style: italic; font-size: 28px; color: var(--amber); }
.startdots { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; }
.startdot { width: 30px; height: 30px; border-radius: 9px; border: 1px solid var(--line-2); background: var(--face); color: var(--bone-2);
  font-family: var(--mono); font-size: 13px; cursor: pointer; transition: all .12s; }
.startdot.on { background: var(--amber); color: var(--stage); border-color: var(--amber); }

/* voice readout chip */
.voice-readout { display: flex; align-items: center; gap: 8px; }

/* ---------------- Presets sheet ---------------- */
/* z-index sits ABOVE the fixed cosmic-rail (6000) and its mobile burger (6200):
   the sheet is portaled to <body> (metro-metronome.jsx) so it shares the body
   stacking level with the rail; on mobile a too-low z-index let the rail paint
   over the sheet's left edge (clipped "Rhythm patterns"/chips). See cosmic-rail.css. */
.sheet-backdrop { position: fixed; inset: 0; z-index: 6500; background: rgba(6,5,4,.62); backdrop-filter: blur(6px); display: flex; align-items: flex-end; justify-content: center; padding: 18px; }
@keyframes fade { from { opacity: .35; } to { opacity: 1; } }
/* Flex column: fixed .sheet-head + internally-scrolling .sheet-body. overflow:hidden
   on the sheet clips the body so the scrollbar stays INSIDE the rounded corners (all
   four stay rounded) and the header/close button never scroll away as presets grow. */
.sheet { width: 100%; max-width: 760px; background: linear-gradient(180deg, var(--stage-2), var(--panel-solid)), var(--stage-2); border: 1px solid var(--line-2);
  border-radius: 26px; box-shadow: 0 -10px 80px -20px #000; animation: sheetUp .3s cubic-bezier(.4,.1,.2,1);
  max-height: min(72vh, 720px); display: flex; flex-direction: column; overflow: hidden; }
@keyframes sheetUp { from { transform: translateY(30px); opacity: .4; } }
.sheet-head { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 24px 26px 16px; border-bottom: 1px solid var(--line); }
.sheet-head h3 { margin: 0; font-family: var(--serif); font-style: italic; font-size: 26px; font-weight: 400; }
/* min-height:0 lets the flex child actually scroll instead of growing the sheet */
.sheet-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 20px 26px 26px; scrollbar-width: thin; scrollbar-color: var(--line-2) transparent; }
.sheet-body::-webkit-scrollbar { width: 11px; }
.sheet-body::-webkit-scrollbar-track { background: transparent; }
.sheet-body::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 99px; border: 3px solid transparent; background-clip: content-box; }
.sheet-body::-webkit-scrollbar-thumb:hover { background: var(--bone-3); background-clip: content-box; }
.preset-group + .preset-group { margin-top: 22px; }
.pg-label { font-size: 11px; letter-spacing: .2em; text-transform: uppercase; color: var(--amber); margin-bottom: 12px; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.preset-chip { text-align: left; border: 1px solid var(--line-2); background: var(--face); border-radius: 14px; padding: 14px; cursor: pointer; transition: all .15s; }
.preset-chip:hover { border-color: var(--amber); transform: translateY(-2px); }
.preset-chip.sel { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); }
.preset-chip .pc-name { font-size: 14.5px; font-weight: 500; color: var(--bone); }
.preset-chip .pc-meter { font-family: var(--mono); font-size: 11px; color: var(--bone-3); margin-top: 4px; }

/* ---------------- Tuner specifics ---------------- */
.note-name-big { font-family: var(--mono); font-size: clamp(60px, 17vw, 112px); font-weight: 600; line-height: .82; letter-spacing: -.04em; color: var(--bone); position: relative; z-index: 1; transition: color .2s; }
.note-name-big sup { font-family: var(--serif); font-style: italic; font-size: .34em; color: var(--bone-3); font-weight: 400; }
.note-name-big.muted { color: var(--bone-3); }
.dial-wrap.ok .note-name-big { color: var(--ok); text-shadow: 0 0 40px var(--ok-bloom); }
.dial-wrap.off .note-name-big { color: var(--off); }
.tuner-hz { font-family: var(--mono); font-size: 14px; color: var(--bone-2); margin-top: 12px; position: relative; z-index: 1; }
.tuner-cents { font-family: var(--mono); font-size: 13px; margin-top: 4px; position: relative; z-index: 1; color: var(--bone-3); }
.cents-marker { transition: all .12s ease-out; }
.tuner-status-name { font-family: var(--serif); font-style: italic; font-size: clamp(18px, 5vw, 26px); }
.tuner-status-name.idle { color: var(--bone-3); }
.tuner-status-name.ok { color: var(--ok); }
.tuner-status-name.near { color: var(--amber); }
.tuner-status-name.off { color: var(--off); }

.tuner-controls { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; justify-content: center; }
.listen-pad { height: 48px; padding: 0 26px; border-radius: 99px; border: 1px solid var(--line-2); background: linear-gradient(150deg, var(--amber-2), var(--amber));
  color: var(--stage); font-size: 14px; font-weight: 600; letter-spacing: .03em; cursor: pointer; display: inline-flex; align-items: center; gap: 9px; transition: all .15s; box-shadow: 0 10px 28px -12px var(--amber-glow); }
.listen-pad:hover { transform: translateY(-1px); }
.listen-pad.on { background: var(--panel-solid); color: var(--off); border-color: rgba(226,97,58,.4); box-shadow: none; }
.tuner-err { font-size: 13px; color: var(--off); text-align: center; max-width: 360px; }

.ref-rail { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: stretch; background: var(--panel); backdrop-filter: blur(14px); border: 1px solid var(--line); border-radius: 22px; padding: 14px; }
.string-key { min-width: 76px; padding: 12px 10px; border-radius: 14px; border: 1px solid var(--line-2); background: var(--face); cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 4px; transition: all .14s; }
.string-key:hover { border-color: var(--amber); transform: translateY(-2px); }
.string-key .sk-note { font-family: var(--mono); font-size: 19px; font-weight: 600; }
.string-key .sk-hz { font-size: 10px; color: var(--bone-3); }
.string-key .sk-flag { font-size: 9px; letter-spacing: .08em; text-transform: uppercase; padding: 2px 6px; border-radius: 5px; margin-top: 2px; }
.string-key.near { border-color: var(--amber); }
.string-key.near .sk-flag { color: var(--amber); background: color-mix(in srgb, var(--amber) 14%, transparent); }
.string-key.locked { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok), 0 0 22px -6px var(--ok-bloom); }
.string-key.locked .sk-note { color: var(--ok); }
.string-key.locked .sk-flag { color: var(--ok); background: rgba(255,231,171,.16); }
.chroma-rail { display: flex; flex-wrap: wrap; gap: 7px; justify-content: center; }
.chroma-pill { min-width: 48px; height: 50px; border-radius: 12px; border: 1px solid var(--line-2); background: var(--face); font-family: var(--mono); font-size: 14px; font-weight: 600; color: var(--bone); cursor: pointer; transition: all .12s; }
.chroma-pill.sharp { background: var(--stage-2); color: var(--bone-2); }
.chroma-pill:hover { border-color: var(--amber); }
.chroma-pill.lit { background: var(--amber); color: var(--stage); border-color: var(--amber); box-shadow: 0 0 18px -4px var(--amber-glow); }

.inst-seg { display: inline-flex; gap: 3px; background: var(--panel-solid); border: 1px solid var(--line); border-radius: 99px; padding: 4px; flex-wrap: wrap; justify-content: center; }
.inst-seg button { border: 0; background: none; color: var(--bone-3); font-size: 13px; padding: 8px 16px; border-radius: 99px; cursor: pointer; transition: all .15s; }
.inst-seg button:hover { color: var(--bone); }
.inst-seg button.active { background: color-mix(in srgb, var(--amber) 12%, transparent); color: var(--amber); }

.tuner-foot { display: flex; gap: 9px; align-items: flex-start; color: var(--bone-3); font-size: 12px; line-height: 1.5; max-width: 420px; text-align: left; }
.tuner-foot svg { flex: none; margin-top: 2px; }

/* ---------------- Shared buttons / modal / dialog reuse ---------------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid var(--line-2); background: var(--face); color: var(--bone); border-radius: 12px; padding: 0 16px; height: 44px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all .12s; }
.btn:hover { border-color: var(--amber); }
.btn:active { transform: translateY(1px); }
.btn.block { width: 100%; }
.btn.lg { height: 50px; }
.btn-primary { background: linear-gradient(150deg, var(--amber-2), var(--amber)); color: var(--stage); border-color: transparent; font-weight: 600; box-shadow: 0 10px 26px -12px var(--amber-glow); }
.btn-primary:hover { transform: translateY(-1px); }
.btn-danger { background: rgba(226,97,58,.12); border-color: rgba(226,97,58,.4); color: var(--off); }
.btn.dashed { background: transparent; border-style: dashed; color: var(--amber); }
.btn.grad { background: linear-gradient(100deg, var(--amber-2), var(--amber)); color: var(--stage); border-color: transparent; font-weight: 600; }
.icon-btn { background: none; border: 0; color: var(--bone-3); cursor: pointer; padding: 6px; border-radius: 8px; display: grid; place-items: center; transition: all .15s; }
.icon-btn:hover { color: var(--bone); background: var(--face); }
.icon-btn.danger:hover { color: var(--off); }
.icon-btn:disabled { opacity: .3; cursor: not-allowed; }

.toggle { width: 46px; height: 27px; border-radius: 99px; border: 1px solid var(--line-2); background: var(--face); position: relative; cursor: pointer; flex: none; transition: all .18s; padding: 0; }
.toggle .knob { position: absolute; top: 2px; left: 2px; width: 21px; height: 21px; border-radius: 50%; background: var(--bone-3); transition: all .18s; }
.toggle.on { background: linear-gradient(150deg, var(--amber-2), var(--amber)); border-color: transparent; }
.toggle.on .knob { transform: translateX(19px); background: var(--stage); }

.dd { position: relative; }
.dd-trigger { width: 100%; display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--face); border: 1px solid var(--line-2); color: var(--bone); border-radius: 11px; padding: 11px 13px; font-size: 14.5px; cursor: pointer; transition: border-color .15s; text-align: left; }
.dd-trigger:hover, .dd-trigger.open { border-color: var(--amber); }
.dd-trigger > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dd-trigger svg { color: var(--bone-3); flex: none; }
.dd-menu { position: absolute; top: calc(100% + 6px); left: 0; right: 0; z-index: 60; overflow-y: auto; background: var(--panel-solid); border: 1px solid var(--line-2); border-radius: 13px; padding: 6px; box-shadow: 0 24px 50px -16px #000; }
.dd-group { font-size: 10px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--amber); padding: 10px 10px 5px; }
.dd-opt { display: block; width: 100%; text-align: left; border: 0; background: none; color: var(--bone); font-size: 14px; padding: 9px 10px; border-radius: 8px; cursor: pointer; }
.dd-opt:hover { background: var(--face); }
.dd-opt.sel { background: color-mix(in srgb, var(--amber) 14%, transparent); color: var(--amber); }

/* Above the cosmic-rail (6000) + burger (6200); portaled to <body> via the shared
   Modal (metro-ui.jsx) so it clears the rail on mobile instead of being clipped. */
.modal-backdrop { position: fixed; inset: 0; z-index: 6600; background: rgba(6,5,4,.66); backdrop-filter: blur(5px); display: grid; place-items: center; padding: 20px; }
.modal { width: 100%; background: linear-gradient(180deg, var(--stage-2), var(--panel-solid)), var(--stage-2); border: 1px solid var(--line-2); border-radius: var(--r-lg); box-shadow: 0 30px 70px -20px #000; animation: sheetUp .2s ease; overflow: hidden; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 18px 18px 14px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-family: var(--serif); font-style: italic; font-size: 22px; font-weight: 400; color: var(--bone); }
.modal-body { padding: 18px; max-height: 70vh; overflow-y: auto; }
.modal-foot { padding: 14px 18px 18px; border-top: 1px solid var(--line); }
.field { margin-bottom: 16px; }
.field-label { font-size: 11px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--bone-3); margin-bottom: 8px; }
.segmented { display: inline-flex; gap: 3px; background: var(--stage-2); border: 1px solid var(--line); border-radius: 11px; padding: 3px; }
.seg { border: 0; background: transparent; color: var(--bone-3); font-size: 13px; font-weight: 500; padding: 8px 13px; border-radius: 8px; cursor: pointer; transition: all .15s; }
.seg.active { background: var(--face); color: var(--amber); }
.slider-row { display: flex; align-items: center; gap: 14px; }
.slider-val { font-family: var(--mono); font-size: 12px; color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); border: 1px solid color-mix(in srgb, var(--amber) 25%, transparent); padding: 4px 8px; border-radius: 7px; min-width: 62px; text-align: center; }
.slider-row input[type="range"] { flex: 1; height: 6px; border-radius: 99px; -webkit-appearance: none; appearance: none; background: linear-gradient(90deg, var(--amber) var(--pct,50%), var(--face) var(--pct,50%)); cursor: pointer; }
.slider-row input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--amber-2); border: 3px solid var(--amber); }
.info-banner { display: flex; gap: 10px; padding: 12px 14px; border-radius: 12px; background: color-mix(in srgb, var(--amber) 7%, transparent); border: 1px solid color-mix(in srgb, var(--amber) 20%, transparent); color: var(--bone-2); font-size: 13px; line-height: 1.45; margin-bottom: 16px; }
.info-banner svg { color: var(--amber); flex: none; margin-top: 1px; }
.seq-list { display: flex; flex-direction: column; gap: 10px; margin-bottom: 12px; }
.seq-row { display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: 14px; background: var(--face); border: 1px solid var(--line); }
.seq-num { width: 26px; height: 26px; flex: none; border-radius: 50%; display: grid; place-items: center; background: linear-gradient(150deg, var(--amber-2), var(--amber)); color: var(--stage); font-weight: 600; font-size: 13px; }
.seq-inputs { flex: 1; display: flex; align-items: flex-end; gap: 12px; }
.mini-field { flex: 1; display: flex; flex-direction: column; gap: 6px; }
.mini-field span { font-size: 10px; font-weight: 600; letter-spacing: .1em; color: var(--bone-3); }
.mini-field input { width: 100%; background: var(--stage-2); border: 1px solid var(--line-2); color: var(--bone); border-radius: 10px; padding: 10px 12px; font-family: var(--mono); font-size: 15px; }
.mini-field input:focus { outline: none; border-color: var(--amber); }
.seq-colon { color: var(--bone-3); font-size: 20px; padding-bottom: 8px; }
.seq-summary { text-align: center; font-size: 12px; color: var(--bone-3); }
.foot-actions { display: flex; gap: 12px; }
.foot-actions .btn { flex: 1; }
.train-strip { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.train-pill { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 99px; background: var(--panel); border: 1px solid var(--line); font-size: 12px; }
.train-pill.current { border-color: var(--amber); background: color-mix(in srgb, var(--amber) 10%, transparent); }
.train-pill b { font-family: var(--mono); }
.train-pill .tp-bar { width: 40px; height: 4px; border-radius: 99px; background: var(--face); overflow: hidden; }
.train-pill .tp-fill { height: 100%; background: var(--amber); }

.toast { position: fixed; bottom: 26px; left: 50%; transform: translateX(-50%); z-index: 200; background: var(--panel-solid); border: 1px solid var(--line-2); color: var(--bone); padding: 12px 20px; border-radius: 12px; font-size: 14px; box-shadow: 0 16px 36px -12px #000; animation: popIn .2s ease; }

/* ---------------- Responsive ---------------- */
@media (max-width: 620px) {
  .app-head { grid-template-columns: 1fr; justify-items: center; gap: 12px; padding: 14px 14px 4px; }
  .head-right { display: none; }
  .brand { gap: 10px; }
  .dial-wrap, .tempo-line { width: min(86vw, 380px); }
  .tempo-line { gap: 10px; }
  .tap-pad { padding: 0 14px; }
  .app-main { gap: 16px; padding: 4px 12px 24px; }
  .mode-pane { gap: 16px; }
  /* sheet + modal: tighter inner padding on phones → more content width, and the
     symmetric backdrop padding (18/20px) gives even breathing room on both edges */
  .sheet-head { padding: 20px 18px 14px; }
  .sheet-body { padding: 16px 18px 22px; }
  .modal-head { padding: 16px 18px 12px; }
  .modal-body { padding: 16px 18px; }
  .modal-foot { padding: 12px 18px 16px; }
  /* dock wraps into a tidy chip cluster (dividers off, chips get their own surface) */
  .dock { flex-wrap: wrap; justify-content: center; gap: 8px; border-radius: 22px; padding: 10px; background: var(--panel-solid); backdrop-filter: none; }
  .dock-div { display: none; }
  .dock-mod { flex: 0 0 auto; background: var(--face); border: 1px solid var(--line); padding: 9px 14px; }
  .dock-mod.active { border-color: rgba(255,157,68,.4); }
  .dock-mod .dm-stack { gap: 0; }
  .inst-seg { width: 100%; }
  /* meter editor: centered fixed panel so it never clips at the screen edge */
  .popover { position: fixed; left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%);
    width: min(86vw, 300px); min-width: 0; z-index: 120; box-shadow: 0 30px 80px -20px #000, 0 0 0 100vmax rgba(6,5,4,.55); }
  .popover::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; }
}
