/* ============================================================
   Nightdesk — night-studio console
   deep indigo darkness · warm VU glow · felt faders
   ============================================================ */

:root {
  --bg0: #05070f;
  --bg1: #0a0f20;
  --panel: #0e1526;
  --panel2: #111a30;
  --line: rgba(158, 172, 224, 0.10);
  --line2: rgba(158, 172, 224, 0.16);
  --ink: #d8ddf1;
  --dim: #7d87ae;
  --dim2: #565f82;
  --amber: #ffb35c;
  --amber2: #ff8a3d;
  --amber-dim: rgba(255, 179, 92, 0.16);
  --glow: 0 0 18px rgba(255, 170, 90, 0.28);
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% -10%, #141c38 0%, var(--bg1) 46%, var(--bg0) 100%);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

/* faint film grain over everything — lo-fi cocoon */
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 60;
  opacity: 0.05;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='0.6'/%3E%3C/svg%3E");
}

::selection { background: rgba(255, 179, 92, 0.25); }

:focus-visible {
  outline: 2px solid rgba(255, 179, 92, 0.7);
  outline-offset: 3px;
  border-radius: 4px;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: none;
  cursor: pointer;
}

/* ---------------- gate ---------------- */

.gate {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  background:
    radial-gradient(60% 50% at 50% 62%, rgba(255, 160, 80, 0.10) 0%, rgba(10, 15, 32, 0) 70%),
    radial-gradient(120% 90% at 50% -10%, #121a36 0%, #0a0f20 55%, #05070f 100%);
  transition: opacity 1.2s ease;
}
.gate.away { opacity: 0; pointer-events: none; }
.gate-inner { text-align: center; padding: 24px; }
.gate-mark { display: flex; gap: 7px; justify-content: center; margin-bottom: 26px; }
.gate-mark span {
  width: 5px; border-radius: 3px; display: block;
  background: linear-gradient(to top, var(--amber2), var(--amber));
  box-shadow: 0 0 12px rgba(255, 170, 90, 0.5);
}
.gate-mark span:nth-child(1) { height: 26px; }
.gate-mark span:nth-child(2) { height: 38px; }
.gate-mark span:nth-child(3) { height: 20px; }
.gate-title {
  margin: 0 0 6px;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 500;
  font-size: clamp(34px, 7vw, 52px);
  letter-spacing: 0.04em;
}
.gate-sub { margin: 0 0 34px; color: var(--dim); font-size: 15px; letter-spacing: 0.06em; }
.gate-btn {
  padding: 15px 42px;
  border-radius: 999px;
  font-size: 16px;
  letter-spacing: 0.05em;
  color: #1a1206;
  background: linear-gradient(160deg, #ffc98a, var(--amber2));
  box-shadow: 0 0 34px rgba(255, 160, 80, 0.35), 0 2px 0 rgba(0,0,0,0.35);
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.gate-btn:hover { transform: translateY(-1px); box-shadow: 0 0 44px rgba(255, 160, 80, 0.5), 0 2px 0 rgba(0,0,0,0.35); }
.gate-btn:active { transform: translateY(1px); }
.gate-btn:disabled { opacity: 0.7; cursor: wait; }
.gate-note { margin-top: 22px; color: var(--dim2); font-size: 12.5px; letter-spacing: 0.04em; }

/* ---------------- top bar ---------------- */

.topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding: 16px clamp(14px, 4vw, 34px) 12px;
}

.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark { display: flex; align-items: flex-end; gap: 3px; height: 24px; }
.brand-mark i {
  width: 4px; border-radius: 2px; display: block;
  background: linear-gradient(to top, var(--amber2), var(--amber));
  box-shadow: 0 0 8px rgba(255, 170, 90, 0.55);
}
.brand-mark i:nth-child(1) { height: 12px; }
.brand-mark i:nth-child(2) { height: 22px; }
.brand-mark i:nth-child(3) { height: 15px; }
.brand-name {
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: 21px; letter-spacing: 0.05em; display: block; line-height: 1.05;
}
.brand-tag { color: var(--dim2); font-size: 11px; letter-spacing: 0.18em; text-transform: uppercase; }

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

.play {
  width: 52px; height: 52px; flex: none;
  border-radius: 50%;
  display: grid; place-items: center;
  background: radial-gradient(circle at 34% 30%, #1a2340, #0d1428 70%);
  border: 1px solid var(--line2);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), 0 4px 14px rgba(0,0,0,0.4);
  transition: box-shadow 0.4s ease, border-color 0.4s ease;
}
.play svg { width: 22px; height: 22px; fill: var(--dim); transition: fill 0.3s; }
.play .ic-pause { display: none; }
.play.on {
  border-color: rgba(255, 179, 92, 0.5);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.06), var(--glow);
}
.play.on svg { fill: var(--amber); }
.play.on .ic-play { display: none; }
.play.on .ic-pause { display: block; }

.master-slot { display: flex; flex-direction: column; gap: 5px; width: min(230px, 42vw); }
.master-row { display: flex; justify-content: space-between; align-items: baseline; padding: 0 2px; }
.master-row .val { text-align: right; }

.cluster { display: flex; gap: 8px; }

.pill {
  padding: 9px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
  background: rgba(14, 21, 38, 0.6);
  font-size: 13px;
  letter-spacing: 0.05em;
  transition: color 0.3s, border-color 0.3s, box-shadow 0.3s;
}
.pill:hover { color: var(--ink); border-color: var(--line2); }
.pill.on, .pill[aria-expanded="true"] {
  color: var(--amber);
  border-color: rgba(255, 179, 92, 0.4);
  box-shadow: 0 0 14px rgba(255, 170, 90, 0.15);
}
.pill .on #timerLeft { color: var(--amber); }

/* ---------------- popovers ---------------- */

.pop {
  position: absolute;
  top: calc(100% + 6px);
  right: clamp(14px, 4vw, 34px);
  z-index: 50;
  min-width: 240px;
  padding: 16px;
  border-radius: var(--r-md);
  background: rgba(13, 19, 36, 0.96);
  border: 1px solid var(--line2);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
  backdrop-filter: blur(10px);
}
.pop.open { opacity: 1; transform: none; pointer-events: auto; }
.pop-title {
  margin: 0 0 10px;
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--dim);
}
.pop-note { margin: 12px 0 0; font-size: 11.5px; color: var(--dim2); line-height: 1.5; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chips button, .preset-chip {
  padding: 8px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: rgba(17, 26, 48, 0.7);
  font-size: 13px;
  transition: border-color 0.25s, color 0.25s, box-shadow 0.25s;
}
.chips button:hover, .preset-chip:hover { border-color: rgba(255, 179, 92, 0.45); color: var(--amber); }
.chips button.on { border-color: var(--amber); color: var(--amber); box-shadow: 0 0 10px rgba(255,170,90,0.2); }
.preset-list { display: flex; flex-wrap: wrap; gap: 7px; max-width: 300px; }
.preset-row { display: flex; gap: 4px; align-items: stretch; }
.preset-chip.saved { border-color: rgba(127, 168, 220, 0.4); }
.preset-del {
  padding: 0 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 14px;
}
.preset-del:hover { color: #ff9d7a; border-color: rgba(255, 130, 90, 0.4); }
.preset-save { display: flex; gap: 7px; margin-top: 14px; }
.preset-save input {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  background: rgba(7, 10, 22, 0.8);
  color: var(--ink);
  font: inherit;
  font-size: 13px;
}
.preset-save input::placeholder { color: var(--dim2); }
.preset-save button {
  padding: 9px 16px;
  border-radius: var(--r-sm);
  background: rgba(255, 179, 92, 0.14);
  border: 1px solid rgba(255, 179, 92, 0.35);
  color: var(--amber);
  font-size: 13px;
}

/* ---------------- window / scene ---------------- */

main { flex: 1; display: flex; flex-direction: column; padding: 6px clamp(14px, 4vw, 34px) 18px; gap: 18px; }

.window-wrap {
  position: relative;
  height: clamp(170px, 30vh, 300px);
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--line);
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.55), 0 10px 40px rgba(0, 0, 0, 0.35);
  flex: none;
}
#scene { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.glass-sheen {
  position: absolute; inset: 0; pointer-events: none;
  background:
    linear-gradient(115deg, rgba(190, 205, 245, 0.05) 0%, rgba(190, 205, 245, 0) 28%),
    radial-gradient(120% 100% at 50% 110%, rgba(5, 7, 15, 0.5) 0%, rgba(5, 7, 15, 0) 55%);
}

/* ---------------- console ---------------- */

.console {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.strip {
  --acc: #ffb35c;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  padding: 16px 14px 14px;
  border-radius: var(--r-lg);
  background:
    linear-gradient(175deg, var(--panel2) 0%, var(--panel) 55%, #0b1120 100%);
  border: 1px solid var(--line);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04), 0 8px 26px rgba(0, 0, 0, 0.35);
  transition: opacity 0.5s ease;
}
.strip.shadowed { opacity: 0.55; }

.strip header { display: flex; align-items: center; gap: 9px; }
.strip h2 {
  margin: 0;
  font-family: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-weight: 500;
  font-size: 15.5px;
  letter-spacing: 0.05em;
  color: var(--ink);
}
.led {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--acc);
  box-shadow: 0 0 9px var(--acc);
  transition: opacity 0.4s, box-shadow 0.4s;
}
.strip.muted .led { opacity: 0.16; box-shadow: none; }
.strip.soloed .led { box-shadow: 0 0 14px var(--acc), 0 0 4px #fff; }
.strip.shadowed .led { opacity: 0.3; }

/* faders */

.faders { display: flex; justify-content: space-evenly; gap: 8px; flex: 1; }
.fader-slot {
  display: flex; flex-direction: column; align-items: center; gap: 7px;
  min-width: 58px; flex: 1;
}
.f-label {
  font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--dim);
}
.val {
  font-family: ui-monospace, "SF Mono", SFMono-Regular, Menlo, monospace;
  font-size: 10.5px;
  color: var(--acc, var(--amber));
  opacity: 0.85;
  min-height: 13px;
  text-align: center;
}
.master-row .f-label { color: var(--dim); }

.fader {
  position: relative;
  width: 100%;
  height: 168px;
  display: flex;
  justify-content: center;
  cursor: grab;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
}
.fader:active { cursor: grabbing; }

.f-track {
  position: relative;
  width: 9px;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(#04060d, #0b1124);
  box-shadow:
    inset 0 2px 6px rgba(0, 0, 0, 0.8),
    inset 0 0 0 1px rgba(158, 172, 224, 0.08);
  overflow: visible;
}
.f-fill {
  position: absolute;
  left: 0; bottom: 0;
  width: 100%;
  border-radius: 6px;
  background: linear-gradient(to top, rgba(255, 138, 61, 0.85), rgba(255, 200, 138, 0.5));
  box-shadow: 0 0 12px rgba(255, 160, 80, 0.4);
  transition: height 0.09s ease-out;
}
.f-thumb {
  position: absolute;
  left: 50%;
  transform: translate(-50%, 50%);
  width: 46px; height: 26px;
  border-radius: 7px;
  background:
    linear-gradient(180deg, #2a3352 0%, #1b2440 45%, #131a30 55%, #232c4a 100%);
  border: 1px solid rgba(158, 172, 224, 0.22);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.10),
    0 0 0 1px rgba(0, 0, 0, 0.4);
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 0 8px;
  transition: bottom 0.09s ease-out, box-shadow 0.3s ease;
}
.f-thumb i {
  display: block; height: 2px; border-radius: 1px;
  background: rgba(158, 172, 224, 0.28);
}
.f-thumb i:nth-child(2) { background: var(--acc, var(--amber)); opacity: 0.8; box-shadow: 0 0 6px var(--acc, var(--amber)); }
.fader:hover .f-thumb { box-shadow: 0 4px 12px rgba(0,0,0,0.6), inset 0 1px 0 rgba(255,255,255,0.12), 0 0 14px rgba(255,170,90,0.22); }
.fader.dragging .f-thumb,
.fader.dragging .f-fill { transition: none; }
.fader.dragging .f-thumb { box-shadow: 0 6px 16px rgba(0,0,0,0.65), inset 0 1px 0 rgba(255,255,255,0.14), 0 0 20px rgba(255,170,90,0.3); }
.strip.muted .f-thumb i:nth-child(2) { opacity: 0.25; box-shadow: none; }
.strip.muted .f-fill { opacity: 0.3; box-shadow: none; }
.strip.shadowed .f-fill { opacity: 0.5; }

/* horizontal master fader */
.fader.horizontal {
  height: 34px;
  width: 100%;
  align-items: center;
  justify-content: flex-start;
}
.fader.horizontal .f-track {
  width: 100%;
  height: 9px;
}
.fader.horizontal .f-fill {
  left: 0; top: 0; bottom: auto;
  height: 100% !important;
  background: linear-gradient(to right, rgba(255, 138, 61, 0.85), rgba(255, 200, 138, 0.5));
  transition: width 0.09s ease-out;
}
.fader.horizontal .f-thumb {
  top: 50%;
  left: 0;
  bottom: auto !important;
  transform: translate(-50%, -50%);
  width: 30px; height: 40px;
  flex-direction: row;
  gap: 3px;
  padding: 8px 0;
  justify-content: center;
  transition: left 0.09s ease-out, box-shadow 0.3s ease;
}
.fader.horizontal .f-thumb i { width: 2px; height: auto; }
.fader.horizontal.dragging .f-thumb { transition: none; }

/* level fader slot accent: keep amber (level = loudness) */
.fader-slot.level .val { color: var(--amber); }

/* ---------------- vu meter ---------------- */

.vu {
  position: relative;
  height: 7px;
  border-radius: 4px;
  background: #05080f;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.8), inset 0 0 0 1px rgba(158, 172, 224, 0.07);
  overflow: hidden;
}
.vu i {
  position: absolute; inset: 0;
  transform-origin: left center;
  transform: scaleX(0);
  border-radius: 4px;
  background: linear-gradient(to right, var(--acc, var(--amber)) 0%, var(--amber) 65%, #ffe2b8 100%);
  box-shadow: 0 0 10px var(--acc, var(--amber));
  opacity: 0.35;
  transition: opacity 0.4s;
}
.vu.live i { opacity: 1; }
.vu b {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 2px;
  background: #ffe9c9;
  box-shadow: 0 0 6px rgba(255, 220, 170, 0.9);
  opacity: 0.8;
}

/* ---------------- strip buttons ---------------- */

.strip-btns { display: flex; gap: 8px; }
.toggle {
  flex: 1;
  padding: 8px 0;
  border-radius: var(--r-sm);
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 12px;
  letter-spacing: 0.08em;
  background: rgba(7, 10, 22, 0.5);
  transition: color 0.3s, border-color 0.3s, background 0.3s, box-shadow 0.3s;
}
.toggle:hover { color: var(--ink); border-color: var(--line2); }
.toggle.mute[aria-pressed="true"] {
  color: #ff9d7a;
  border-color: rgba(255, 130, 90, 0.45);
  background: rgba(255, 110, 60, 0.08);
}
.toggle.solo[aria-pressed="true"] {
  color: var(--amber);
  border-color: rgba(255, 179, 92, 0.5);
  background: rgba(255, 179, 92, 0.10);
  box-shadow: 0 0 12px rgba(255, 170, 90, 0.18);
}

/* binaural extras */
.band-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: -4px; }
.band-chip {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 11px;
  letter-spacing: 0.12em;
  color: #c9b8ff;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid rgba(160, 140, 255, 0.35);
  background: rgba(160, 140, 255, 0.08);
  text-transform: lowercase;
}
.carrier-seg { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; }
.carrier-seg button {
  padding: 5px 10px;
  font-size: 11px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  color: var(--dim);
  border-left: 1px solid var(--line);
  transition: color 0.3s, background 0.3s;
}
.carrier-seg button:first-child { border-left: none; }
.carrier-seg button.on { color: #d3c8ff; background: rgba(160, 140, 255, 0.14); }

/* ---------------- footer ---------------- */

.foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px clamp(14px, 4vw, 34px) calc(14px + env(safe-area-inset-bottom));
  color: var(--dim2);
  font-size: 11.5px;
  letter-spacing: 0.04em;
}
.status { color: var(--dim); min-height: 14px; }

/* ---------------- responsive ---------------- */

@media (max-width: 900px) {
  .console { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 620px) {
  .topbar { gap: 12px; }
  .console { grid-template-columns: minmax(0, 1fr); }
  .window-wrap { height: clamp(150px, 24vh, 220px); }
  .fader { height: 138px; }
  .strip { padding: 14px 14px 12px; }
  .master-slot { width: 100%; order: 3; }
  .transport { width: 100%; }
  .cluster { margin-left: auto; }
  .foot { justify-content: center; text-align: center; }
}

@media (max-width: 380px) {
  .faders.three { flex-wrap: wrap; }
  .fader-slot { min-width: 72px; }
}

/* ---------------- reduced motion ---------------- */

@media (prefers-reduced-motion: reduce) {
  .gate, .pop, .f-thumb, .f-fill, .fader.horizontal .f-thumb,
  .fader.horizontal .f-fill, .strip, .toggle, .pill, .play, .play svg { transition: none; }
}
