/* MusicGen studio — late-night console.
   One accent family, glass panels, monospace micro-labels. */

:root {
  --bg: #07080f;
  --bg-2: #0b0d18;
  --panel: rgba(19, 23, 38, 0.82);
  --panel-solid: #131726;
  --panel-2: rgba(30, 36, 58, 0.7);
  --line: rgba(120, 140, 190, 0.16);
  --line-strong: rgba(130, 150, 210, 0.34);
  --text: #eef1fa;
  --muted: #98a3c0;
  --dim: #6b7695;
  --accent: #8b9dff;
  --accent-2: #ff6f9c;
  --accent-3: #5fe3c0;
  --radius: 16px;
  --radius-sm: 10px;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f4f5fa;
    --bg-2: #eceef7;
    --panel: rgba(255, 255, 255, 0.86);
    --panel-solid: #ffffff;
    --panel-2: rgba(238, 241, 250, 0.9);
    --line: rgba(30, 45, 90, 0.12);
    --line-strong: rgba(30, 45, 90, 0.26);
    --text: #0d1220;
    --muted: #5a6480;
    --dim: #7b85a0;
    --accent: #3d5ce0;
    --accent-2: #d63d6e;
    --accent-3: #17967c;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(1100px 620px at 12% -8%, rgba(139, 157, 255, 0.16), transparent 60%),
    radial-gradient(900px 520px at 92% 4%, rgba(255, 111, 156, 0.12), transparent 62%),
    linear-gradient(180deg, var(--bg), var(--bg-2) 60%, var(--bg));
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  letter-spacing: -0.005em;
}

#app {
  max-width: 640px;
  margin: 0 auto;
  padding: 10px 12px 44px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.skip {
  position: absolute;
  left: -9999px;
  background: var(--panel-solid);
  color: var(--text);
  padding: 8px 12px;
  border-radius: 8px;
  z-index: 60;
}
.skip:focus { left: 10px; top: 10px; }

/* ---------------------------------------------------------------- header */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--panel);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 18px 40px -28px rgba(0, 0, 0, 0.9), inset 0 1px 0 rgba(255, 255, 255, 0.05);
  padding: 10px 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

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

button, select, input[type="range"] { font: inherit; color: inherit; }

button {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  min-height: 40px;
  cursor: pointer;
  color: var(--text);
  transition: background 130ms ease, border-color 130ms ease, transform 90ms ease;
}
button:hover { background: rgba(70, 84, 130, 0.42); border-color: var(--line-strong); }
button:active { transform: translateY(1px); }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

#play {
  min-width: 48px;
  font-size: 16px;
  border-color: transparent;
  background: linear-gradient(160deg, rgba(139, 157, 255, 0.95), rgba(120, 110, 255, 0.75));
  color: #080a14;
  font-weight: 700;
}
#play:hover { filter: brightness(1.08); }

#generate {
  border-color: rgba(139, 157, 255, 0.5);
  background: rgba(139, 157, 255, 0.14);
}
#random { background: rgba(255, 111, 156, 0.12); border-color: rgba(255, 111, 156, 0.32); }
#evolve, #mutate { font-size: 13px; padding-inline: 10px; }
#mute, #menu { padding-inline: 10px; font-size: 13px; }
button[aria-pressed="true"] {
  border-color: var(--accent-2);
  background: rgba(255, 111, 156, 0.18);
}

.songline {
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
  min-height: 22px;
}
#title {
  font-size: 17px;
  font-weight: 650;
  letter-spacing: -0.02em;
}
#meta {
  color: var(--muted);
  font-size: 12px;
  font-family: var(--mono);
  letter-spacing: 0;
}
.dot { color: var(--dim); }
.chip {
  margin-left: auto;
  min-height: 26px;
  padding: 2px 10px;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 11px;
  color: var(--accent);
  background: rgba(139, 157, 255, 0.1);
  border-color: rgba(139, 157, 255, 0.28);
}

/* ---------------------------------------------------------------- viz */
.vizwrap {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(139, 157, 255, 0.07), rgba(7, 8, 15, 0.2));
}
#viz { width: 100%; height: 132px; display: block; }
.vizmodes {
  position: absolute;
  right: 6px;
  top: 6px;
  display: flex;
  gap: 3px;
  background: rgba(7, 8, 15, 0.55);
  border-radius: 999px;
  padding: 3px;
  backdrop-filter: blur(8px);
}
.vizmodes button {
  min-height: 24px;
  padding: 1px 9px;
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
}
.vizmodes button[aria-pressed="true"] {
  background: rgba(139, 157, 255, 0.22);
  color: var(--text);
}

.progress {
  height: 3px;
  background: rgba(120, 140, 190, 0.16);
  border-radius: 3px;
  overflow: hidden;
}
#progressbar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 80ms linear;
}

/* ---------------------------------------------------------------- controls */
.controls {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
  padding: 6px 12px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr) auto auto;
  align-items: center;
  gap: 8px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(120, 140, 190, 0.07);
}
.row:last-child { border-bottom: 0; }
.row label {
  color: var(--dim);
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.row select {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  min-height: 40px;
  width: 100%;
  appearance: none;
  background-image: linear-gradient(45deg, transparent 50%, var(--dim) 50%),
                    linear-gradient(135deg, var(--dim) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}
.row input[type="range"] { width: 100%; accent-color: var(--accent); height: 28px; }
.row output {
  min-width: 46px;
  text-align: right;
  color: var(--text);
  font-family: var(--mono);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.lock {
  min-height: 36px;
  min-width: 38px;
  padding: 4px 6px;
  background: transparent;
  border-color: transparent;
  font-size: 13px;
  opacity: 0.55;
}
.lock:hover { opacity: 1; background: var(--panel-2); }
.lock[aria-pressed="true"] {
  opacity: 1;
  border-color: rgba(255, 111, 156, 0.5);
  background: rgba(255, 111, 156, 0.14);
}

details summary {
  cursor: pointer;
  padding: 9px 0 6px;
  color: var(--dim);
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
details[open] summary { color: var(--accent); }
details > .row { padding-left: 2px; }

/* ---------------------------------------------------------------- timeline */
.timeline { overflow-x: auto; scrollbar-width: thin; }
.sections { display: flex; gap: 4px; min-height: 36px; }
.sec {
  flex: 1 0 auto;
  padding: 8px 9px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 10px;
  font-family: var(--mono);
  letter-spacing: 0.04em;
  color: var(--muted);
  text-align: center;
  cursor: pointer;
  white-space: nowrap;
}
.sec:hover { border-color: var(--line-strong); color: var(--text); }
.sec.active {
  border-color: rgba(139, 157, 255, 0.7);
  color: var(--text);
  background: rgba(139, 157, 255, 0.14);
}

/* ---------------------------------------------------------------- actions */
.actions { display: flex; gap: 6px; flex-wrap: wrap; }
.actions button { flex: 1 1 88px; font-size: 13px; }
.actions button.ghost { background: transparent; }

/* ---------------------------------------------------------------- sheet */
.sheet[hidden] { display: none; }
.sheet {
  position: fixed;
  left: 12px; right: 12px; bottom: 12px;
  max-width: 616px;
  margin: 0 auto;
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 40;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, 0.85);
}
.sheet button { text-align: left; }
.sheet .sep {
  height: 1px;
  background: var(--line);
  margin: 2px 0;
}
.sheet small {
  color: var(--dim);
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 4px 2px 0;
}

dialog {
  background: var(--panel-solid);
  color: var(--text);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius);
  max-width: 470px;
  width: 92vw;
  padding: 18px;
}
dialog::backdrop { background: rgba(4, 5, 12, 0.72); backdrop-filter: blur(3px); }
dialog h2 { margin: 0 0 12px; font-size: 16px; letter-spacing: -0.01em; }
dl { display: grid; grid-template-columns: 92px 1fr; gap: 7px 12px; font-size: 13px; }
dt { color: var(--muted); font-family: var(--mono); font-size: 11px; padding-top: 2px; }
dd { margin: 0; }

.library-list { display: flex; flex-direction: column; gap: 6px; max-height: 52vh; overflow: auto; margin-bottom: 10px; }
.lib-item {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 9px 11px;
}
.lib-item strong { font-weight: 600; font-size: 13px; }
.lib-item small { color: var(--dim); font-family: var(--mono); font-size: 10px; }
.lib-item button { min-height: 32px; padding: 4px 10px; font-size: 12px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translate(-50%, 16px);
  background: var(--panel-solid);
  border: 1px solid var(--line-strong);
  color: var(--text);
  padding: 10px 15px;
  border-radius: 12px;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 170ms ease, transform 170ms ease;
  z-index: 50;
  box-shadow: 0 20px 50px -18px rgba(0, 0, 0, 0.9);
  max-width: min(90vw, 460px);
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

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

/* desktop: two columns of dials, wider stage */
@media (min-width: 900px) {
  #app { max-width: 900px; }
  .topbar { padding: 12px 14px 10px; }
  #viz { height: 176px; }
  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0 24px;
    padding: 8px 16px 12px;
  }
  .controls details { grid-column: 1 / -1; }
  .row { border-bottom: 0; }
  .row:nth-child(odd) { border-right: 1px solid rgba(120, 140, 190, 0.08); padding-right: 20px; }
  .actions button { flex: 1 1 120px; }
}

@media (max-width: 380px) {
  .row { grid-template-columns: 58px minmax(0, 1fr) auto auto; }
  #evolve, #mutate { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
