/* SynthFM demo styles - fully standalone: no framework, no imports, no build step. */

:root {
  --bg: #04040f;
  --shell-hi: #101028;
  --shell-lo: #07071a;
  --panel: #0b0b20;
  --screen: #02020c;
  --text: #dcdcff;
  --dim: rgba(220, 220, 255, 0.55);
  --cyan: #00f5ff;
  --pink: #ff0090;
  --amber: #ffdd55;
  --line: rgba(0, 245, 255, 0.28);
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", "JetBrains Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 28px 16px;
  background: var(--bg);
  color: var(--text);
  font-family: var(--mono);
}

/* faint laser grid backdrop */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(0, 245, 255, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 245, 255, 0.055) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 60% at 50% 42%, black 20%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 60% at 50% 42%, black 20%, transparent 78%);
}

/* retrowave horizon glow under the deck */
body::after {
  content: "";
  position: fixed;
  left: 0;
  right: 0;
  bottom: -140px;
  height: 220px;
  pointer-events: none;
  background: radial-gradient(ellipse 70% 60% at 50% 100%, rgba(255, 0, 144, 0.22), transparent 70%);
}

.stage {
  width: min(580px, 100%);
  position: relative;
  z-index: 1;
}

/* ── cassette shell ─────────────────────────────────────────── */

.deck {
  position: relative;
  padding: 22px 24px 20px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 18px;
  background:
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.022) 0 2px, transparent 2px 5px),
    radial-gradient(ellipse 120% 90% at 50% 0%, var(--shell-hi), var(--shell-lo));
  box-shadow:
    0 0 30px rgba(0, 245, 255, 0.1),
    0 20px 60px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 60px rgba(0, 245, 255, 0.03);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.deck[data-state="on"] {
  box-shadow:
    0 0 42px rgba(0, 245, 255, 0.16),
    0 20px 60px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(255, 255, 255, 0.06),
    inset 0 0 60px rgba(0, 245, 255, 0.05);
}

/* corner screws: one per corner */
.screw {
  position: absolute;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #a0a0c8, #17172b 65%);
  box-shadow:
    inset 0 0 2px rgba(0, 0, 0, 0.9),
    0 1px 1px rgba(0, 0, 0, 0.5);
}
.screw:nth-of-type(1) { top: 10px; left: 10px; }
.screw:nth-of-type(2) { top: 10px; right: 10px; }
.screw:nth-of-type(3) { bottom: 10px; left: 10px; }
.screw:nth-of-type(4) { bottom: 10px; right: 10px; }

.deck-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.brand {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.32em;
  color: var(--cyan);
  text-shadow: 0 0 8px rgba(0, 245, 255, 0.75), 0 0 26px rgba(0, 245, 255, 0.35);
}

.brand-pink {
  color: var(--pink);
  text-shadow: 0 0 8px rgba(255, 0, 144, 0.75), 0 0 26px rgba(255, 0, 144, 0.35);
}

.status {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 10.5px;
  letter-spacing: 0.22em;
  color: var(--dim);
}

.led {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #34344f;
  box-shadow: inset 0 0 3px rgba(0, 0, 0, 0.8);
  transition: background 0.2s ease, box-shadow 0.2s ease;
}

.deck[data-state="on"] .led {
  background: var(--cyan);
  box-shadow: 0 0 12px rgba(0, 245, 255, 0.9), 0 0 4px rgba(0, 245, 255, 1);
}
.deck[data-state="tuning"] .led {
  background: var(--pink);
  box-shadow: 0 0 12px rgba(255, 0, 144, 0.9);
  animation: led-blink 0.45s steps(2, jump-none) infinite;
}
.deck[data-state="paused"] .led {
  background: var(--amber);
  box-shadow: 0 0 10px rgba(255, 221, 85, 0.8);
}
.deck[data-state="dead"] .led {
  background: var(--pink);
  box-shadow: 0 0 12px rgba(255, 0, 144, 0.9);
}

@keyframes led-blink {
  50% { opacity: 0.25; }
}

/* icons shared by buttons, dialog and widgets */
.ic {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex: none;
}

/* ── console: LCD + cassette ────────────────────────────────── */

.console {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: stretch;
}

.lcd {
  background: var(--screen);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: inset 0 0 22px rgba(0, 245, 255, 0.12), inset 0 0 3px rgba(0, 0, 0, 0.9);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  min-width: 0;
  text-shadow: 0 0 6px rgba(0, 245, 255, 0.45);
}

.lcd-name {
  font-size: 15px;
  letter-spacing: 0.16em;
  color: var(--cyan);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.lcd-sub {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--dim);
  white-space: nowrap;
  overflow: hidden;
}

.lcd-sub > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
}

.lcd-tag {
  flex: none;
  font-size: 10px;
  padding: 0 6px;
  line-height: 1.5;
  color: var(--pink);
  border: 1px solid rgba(255, 0, 144, 0.5);
  text-shadow: 0 0 6px rgba(255, 0, 144, 0.5);
}

/* mini cassette riding beside the LCD */
.cassette {
  background: linear-gradient(180deg, #191936, #0c0c20);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 8px 12px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 2px 8px rgba(0, 0, 0, 0.4);
}

.cassette-side {
  font-size: 9px;
  letter-spacing: 0.3em;
  color: rgba(220, 220, 255, 0.35);
}

.cassette-window {
  position: relative;
  width: 138px;
  height: 52px;
  border-radius: 30px / 22px;
  background: var(--screen);
  border: 1px solid rgba(0, 245, 255, 0.25);
  box-shadow: inset 0 0 14px rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  overflow: hidden;
}

/* tape ribbon between the reels */
.ribbon {
  position: absolute;
  left: 18px;
  right: 18px;
  top: 50%;
  height: 9px;
  transform: translateY(-50%);
  border-radius: 2px;
  background: linear-gradient(180deg, rgba(255, 0, 144, 0.35), rgba(90, 20, 60, 0.55) 30%, rgba(30, 10, 40, 0.8) 55%, rgba(90, 20, 60, 0.55) 75%, rgba(255, 0, 144, 0.25));
  opacity: 0.8;
}

.reel {
  position: relative;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(0, 245, 255, 0.35);
  background:
    repeating-conic-gradient(rgba(0, 245, 255, 0.55) 0deg 20deg, rgba(0, 245, 255, 0.07) 20deg 60deg);
  box-shadow: inset 0 0 8px rgba(0, 245, 255, 0.18), 0 0 6px rgba(0, 245, 255, 0.12);
  animation: reel-spin 3.8s linear infinite;
  animation-play-state: paused;
}

.reel::before {
  /* wound tape ring */
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 3px solid rgba(255, 0, 144, 0.35);
  opacity: 0.55;
}

.reel::after {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  background: var(--screen);
  box-shadow: 0 0 6px rgba(0, 245, 255, 0.3);
}

.deck[data-state="on"] .reel {
  animation-play-state: running;
}

@keyframes reel-spin {
  to { transform: rotate(360deg); }
}

/* ── visualizer screen ─────────────────────────────────────── */

.screen {
  position: relative;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background:
    radial-gradient(ellipse 100% 80% at 50% 25%, #0a0a26, var(--screen) 85%);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.85), 0 0 16px rgba(0, 245, 255, 0.08);
}

.viz {
  display: block;
  width: 100%;
  height: 160px;
  filter: drop-shadow(0 0 5px rgba(0, 245, 255, 0.32));
}

/* CRT scanlines over the screen */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.28) 0 1px, transparent 1px 3px);
}

/* glass vignette */
.screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  box-shadow: inset 0 0 24px rgba(2, 2, 12, 0.9), inset 0 0 4px rgba(2, 2, 12, 0.9);
}

/* ── chunky VU meters ──────────────────────────────────────── */

.meters {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.meter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.meter-label {
  flex: none;
  width: 14px;
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.1em;
  color: var(--dim);
  text-shadow: 0 0 6px rgba(0, 245, 255, 0.4);
}

.vu {
  position: relative;
  flex: 1;
  height: 13px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: var(--screen);
  overflow: hidden;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.8);
}

.vu-fill {
  position: absolute;
  inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  background: linear-gradient(90deg, var(--cyan), #7dff9e 35%, var(--amber) 68%, var(--pink));
  will-change: transform;
}

/* chunky LED segment separators over the fill */
.vu::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 9px, var(--bg) 9px 12px);
  pointer-events: none;
}

/* ── transport ─────────────────────────────────────────────── */

.transport {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  color: var(--cyan);
  background: linear-gradient(180deg, #10102a, #08081a);
  border: 1px solid rgba(0, 245, 255, 0.3);
  border-radius: 8px;
  padding: 10px 14px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 3px 0 rgba(0, 0, 0, 0.55),
    0 4px 10px rgba(0, 0, 0, 0.35);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.06s ease;
}

.btn:hover {
  border-color: var(--cyan);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 3px 0 rgba(0, 0, 0, 0.55),
    0 0 16px rgba(0, 245, 255, 0.28);
}

.btn:active {
  transform: translateY(2px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05), 0 1px 0 rgba(0, 0, 0, 0.55);
}

.btn:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 2px;
}

.btn-eject {
  color: var(--pink);
  border-color: rgba(255, 0, 144, 0.45);
  text-shadow: 0 0 6px rgba(255, 0, 144, 0.5);
}

.btn-eject:hover {
  border-color: var(--pink);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    0 3px 0 rgba(0, 0, 0, 0.55),
    0 0 18px rgba(255, 0, 144, 0.32);
}

.btn-play {
  min-width: 108px;
}

.deck[data-state="on"] .btn-play {
  color: var(--pink);
  border-color: rgba(255, 0, 144, 0.5);
}

.btn-ghost {
  color: var(--dim);
  border-color: rgba(220, 220, 255, 0.25);
}

.btn-ghost:hover {
  color: var(--text);
  border-color: rgba(220, 220, 255, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.btn-x {
  padding: 8px;
  color: var(--dim);
  font-size: 0;
}

.btn-x:hover {
  color: var(--pink);
  border-color: rgba(255, 0, 144, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.vol {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.ic-vol {
  width: 15px;
  height: 15px;
  color: var(--dim);
}

.vol input[type="range"] {
  width: 120px;
  accent-color: var(--cyan);
}

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

/* ── presets ───────────────────────────────────────────────── */

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.preset-item {
  display: inline-flex;
  border-radius: 7px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
}

.chip {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--text);
  background: rgba(16, 16, 40, 0.85);
  border: 1px solid rgba(0, 245, 255, 0.3);
  border-radius: 7px 0 0 7px;
  padding: 7px 11px;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.chip:hover {
  border-color: rgba(0, 245, 255, 0.7);
}

.chip:focus-visible {
  outline: 1px solid var(--cyan);
  outline-offset: 1px;
}

.chip[data-active="true"] {
  color: var(--pink);
  border-color: var(--pink);
  text-shadow: 0 0 8px rgba(255, 0, 144, 0.6);
  background: rgba(255, 0, 144, 0.06);
}

.chip-kind {
  margin-right: 7px;
  font-size: 10px;
  letter-spacing: 0.14em;
  color: var(--cyan);
  opacity: 0.85;
}

.chip-del {
  font-size: 0;
  color: var(--pink);
  background: rgba(16, 16, 40, 0.85);
  border: 1px solid rgba(255, 0, 144, 0.35);
  border-left: none;
  border-radius: 0 7px 7px 0;
  padding: 7px 7px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.15s ease, border-color 0.15s ease;
}

.chip-del .ic {
  width: 11px;
  height: 11px;
}

.chip-del:hover,
.chip-del:focus-visible {
  opacity: 1;
  border-color: var(--pink);
}

.hint {
  margin: 0;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 11px;
  letter-spacing: 0.1em;
  color: rgba(220, 220, 255, 0.4);
}

/* ── eject dialog ──────────────────────────────────────────── */

dialog {
  width: min(440px, 92vw);
  padding: 0;
  background: var(--shell-lo);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 0 40px rgba(0, 245, 255, 0.18), 0 24px 60px rgba(0, 0, 0, 0.6);
  font-family: var(--mono);
}

dialog::backdrop {
  background: rgba(2, 2, 12, 0.75);
  backdrop-filter: blur(3px);
}

.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.dialog-head h2 {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 13px;
  letter-spacing: 0.22em;
  color: var(--pink);
  text-shadow: 0 0 8px rgba(255, 0, 144, 0.55);
}

.dialog-body {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--dim);
}

.field input,
.field select {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--cyan);
  background: var(--screen);
  border: 1px solid rgba(0, 245, 255, 0.3);
  border-radius: 7px;
  padding: 8px 10px;
}

.field input:focus,
.field select:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 10px rgba(0, 245, 255, 0.25);
}

.form-error {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--pink);
  text-shadow: 0 0 6px rgba(255, 0, 144, 0.5);
}

.form-hint {
  margin: 0;
  font-size: 10.5px;
  line-height: 1.6;
  letter-spacing: 0.06em;
  color: rgba(220, 220, 255, 0.4);
}

.dialog-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* hidden YouTube player mount - near-invisible so the iframe keeps
   its "visible" status for playback policy, but does not show */
.yt-host {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 320px;
  height: 180px;
  overflow: hidden;
  opacity: 0.02;
  pointer-events: none;
}

@media (max-width: 520px) {
  .console {
    grid-template-columns: 1fr;
    grid-auto-flow: row dense;
  }
  .cassette {
    order: -1;
    align-self: center;
  }
  .vol {
    width: 100%;
    margin-left: 0;
  }
  .vol input[type="range"] {
    width: 100%;
    flex: 1;
  }
  .btn-play {
    min-width: 0;
  }
}
