/* The Revolution — your voice is the interface.
   Five themes (Pink default, Purple, Gold, Dark, White). Each song shades the theme slightly by its key
   (--h is set per song); a theme never leaves its own colour family. */

:root {
  --ok: #4ade80;
  --warn: #ffb03a;
  --bad: #ff4d6d;
  --dock-w: 390px;
  --dock-h: 0px;
  --radius: 22px;
  --font: "Geist", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Instrument Serif", Georgia, "Times New Roman", serif;
  --gutter: clamp(24px, 4.5vw, 72px); /* one margin for everything, growing with the screen */
}

/* Pink (default): only shades of pink — deep rose to soft blush, on near-black */
:root, :root[data-theme="pink"] {
  --h: 336;
  --accent: hsl(var(--h) 92% 70%);
  --accent-2: hsl(var(--h) 100% 85%);
  --on-accent: #2a0616;
  --bg: #0f0609;
  --ink: #fbf1f5;
  --muted: rgba(251, 241, 245, 0.62);
  --faint: rgba(251, 241, 245, 0.12);
  --glass: rgba(28, 10, 17, 0.62);
  --glass-strong: rgba(24, 8, 14, 0.92);
  --panel-solid: #1a0a11;
  --line: rgba(255, 255, 255, 0.1);
  --surface: rgba(255, 255, 255, 0.06);
  --surface-2: rgba(255, 255, 255, 0.12);
  --field: rgba(0, 0, 0, 0.35);
  --scrim: rgba(10, 3, 6, 0.55);
  color-scheme: dark;
}

/* Purple: pink fading into violet and indigo */
:root[data-theme="purple"] {
  --h: 318;
  --accent: hsl(var(--h) 88% 68%);
  --accent-2: hsl(calc(var(--h) - 62) 80% 74%);
  --on-accent: #fff;
  --bg: #08060e;
  --ink: #f4f1fa;
  --muted: rgba(244, 241, 250, 0.62);
  --faint: rgba(244, 241, 250, 0.12);
  --glass: rgba(16, 13, 24, 0.62);
  --glass-strong: rgba(14, 11, 21, 0.92);
  --panel-solid: #0e0b15;
  --scrim: rgba(5, 4, 9, 0.55);
}

/* Gold: champagne gold on warm black */
:root[data-theme="gold"] {
  --h: 43;
  --accent: hsl(var(--h) 60% 64%);
  --accent-2: hsl(calc(var(--h) + 4) 72% 82%);
  --on-accent: #1d1505;
  --bg: #0b0906;
  --ink: #f8f3e8;
  --muted: rgba(248, 243, 232, 0.6);
  --faint: rgba(248, 243, 232, 0.12);
  --glass: rgba(22, 18, 11, 0.64);
  --glass-strong: rgba(18, 15, 9, 0.93);
  --panel-solid: #15110a;
  --scrim: rgba(8, 6, 3, 0.55);
}

/* Dark: monochrome silver on black */
:root[data-theme="dark"] {
  --accent: #f4f4f5;
  --accent-2: #a1a1aa;
  --on-accent: #0a0a0a;
  --bg: #050505;
  --ink: #f4f4f5;
  --muted: rgba(244, 244, 245, 0.58);
  --faint: rgba(244, 244, 245, 0.1);
  --glass: rgba(18, 18, 20, 0.66);
  --glass-strong: rgba(14, 14, 16, 0.94);
  --panel-solid: #111113;
  --scrim: rgba(0, 0, 0, 0.6);
}

/* White: light ivory with pink accents */
:root[data-theme="white"] {
  --h: 336;
  --accent: hsl(var(--h) 76% 54%);
  --accent-2: hsl(var(--h) 88% 70%);
  --on-accent: #fff;
  --bg: #f7f2f0;
  --ink: #1b1218;
  --muted: rgba(27, 18, 24, 0.6);
  --faint: rgba(27, 18, 24, 0.08);
  --glass: rgba(255, 255, 255, 0.66);
  --glass-strong: rgba(255, 252, 250, 0.96);
  --panel-solid: #fffaf8;
  --line: rgba(27, 18, 24, 0.1);
  --surface: rgba(27, 18, 24, 0.05);
  --surface-2: rgba(27, 18, 24, 0.1);
  --field: rgba(255, 255, 255, 0.85);
  --scrim: rgba(60, 30, 45, 0.22);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  transition: background 0.4s;
  font: 15px/1.5 var(--font);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

#stage { position: fixed; inset: 0; display: block; }

/* ---------- top bar ---------- */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between;
  padding: max(22px, env(safe-area-inset-top)) var(--gutter) 16px;
  pointer-events: none;
}
.topbar > * { pointer-events: auto; }
.top-left { display: flex; align-items: center; gap: 10px; }
.wordmark { display: flex; align-items: center; gap: 10px; font-weight: 600; font-size: 15px; letter-spacing: -0.01em; background: none; border: 0; padding: 4px 0; }
.back-btn {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; padding: 0;
  border: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(12px);
}
.back-btn[hidden] { display: none; }
.back-btn:hover { background: var(--surface-2); }
.back-btn svg { width: 18px; height: 18px; fill: none; stroke: var(--ink); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.spark { width: 12px; height: 12px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 16px var(--accent); transition: background 1s, box-shadow 1s; }

.pill {
  border: 1px solid var(--line); background: var(--surface); backdrop-filter: blur(12px);
  border-radius: 999px; padding: 8px 16px; font-weight: 600; font-size: 13px;
}
.pill:hover { background: var(--surface-2); }
.pill.on { border-color: var(--accent); color: var(--accent); }

.top-actions { display: flex; align-items: center; gap: 14px; }
.themes { display: flex; align-items: center; gap: 8px; padding: 6px 10px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); backdrop-filter: blur(12px); }
.theme-dot {
  width: 20px; height: 20px; border-radius: 50%; padding: 0; border: 1px solid rgba(128, 128, 128, 0.35);
  box-shadow: 0 0 0 2px transparent; transition: box-shadow 0.2s, transform 0.15s;
}
.theme-dot:hover { transform: scale(1.12); }
.theme-dot[aria-checked="true"] { box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--ink); }

/* ---------- hero (idle) ---------- */
.hero {
  position: fixed; left: var(--gutter); top: 50%; transform: translateY(-50%); z-index: 3;
  width: min(30vw, 440px);
  transition: opacity 0.5s, transform 0.5s;
}
.hero h1 { font-family: var(--display); font-weight: 400; font-size: clamp(40px, 5.2vw, 76px); line-height: 0.98; margin: 0 0 20px; letter-spacing: -0.015em; }
.hero h1 em { font-style: italic; background: linear-gradient(95deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; color: transparent; padding-right: 0.08em; }
.hero p { color: var(--muted); margin: 0; max-width: 30ch; font-size: 16px; line-height: 1.55; }
body:not([data-mode="idle"]) .hero { opacity: 0; transform: translateY(calc(-50% - 12px)); pointer-events: none; }

/* ---------- orb button (sits on the drawn orb) ---------- */
.orb-btn {
  position: fixed; left: 0; top: 0; z-index: 4; border-radius: 50%;
  border: 0; background: transparent; -webkit-tap-highlight-color: transparent;
  width: 120px; height: 120px; transform: translate(-50%, -50%);
}
.orb-label {
  position: absolute; left: 50%; top: calc(100% + 26px); transform: translateX(-50%); white-space: nowrap;
  font-weight: 600; font-size: 12px; letter-spacing: 0.22em; text-transform: uppercase;
}
body[data-mode="song"] .orb-btn, body[data-mode="think"] .orb-btn { display: none; }
body[data-mode="record"] .orb-label { top: calc(100% + 14px); font-size: 12px; color: var(--muted); }

.count {
  position: fixed; z-index: 4; transform: translate(-50%, -50%); pointer-events: none;
  font-family: var(--display); font-size: 88px; line-height: 1; color: #fff; text-shadow: 0 0 30px var(--accent);
}

.bring {
  position: fixed; z-index: 4; transform: translateX(-50%); cursor: pointer;
  color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 4px;
}
.bring:hover { color: var(--ink); }
body:not([data-mode="idle"]) .bring { display: none; }

/* ---------- transport ---------- */
.transport {
  position: fixed; z-index: 4; left: var(--gutter); right: calc(var(--dock-w) + var(--gutter) * 2); bottom: var(--gutter);
  display: flex; align-items: center; gap: 12px;
  background: var(--glass); backdrop-filter: blur(16px); border: 1px solid var(--line); border-radius: 999px; padding: 8px 18px 8px 8px;
}
.transport[hidden] { display: none; }
.play { width: 46px; height: 46px; border-radius: 50%; border: 0; background: linear-gradient(135deg, var(--accent), var(--accent-2)); display: grid; place-items: center; flex: none; box-shadow: 0 0 24px color-mix(in srgb, var(--accent) 45%, transparent); }
.play svg { width: 22px; height: 22px; fill: var(--on-accent); }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); }
/* Save / Share live right in the player, so they're always one tap away */
.tbtn {
  display: inline-flex; align-items: center; gap: 6px; flex: none; height: 38px; padding: 0 14px;
  border-radius: 999px; border: 1px solid var(--line); background: var(--surface); font-weight: 600; font-size: 13px;
}
.tbtn:hover { background: var(--surface-2); }
.tbtn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--on-accent); }
.tbtn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
@media (max-width: 560px) {
  /* phones: the pink dot is the logo; keep every top-bar button on screen */
  .wordmark .wm-text { display: none; }
  .top-left { gap: 8px; }
  .top-actions { gap: 6px; }
  .themes { gap: 5px; padding: 5px 7px; }
  .theme-dot { width: 15px; height: 15px; }
  .topbar .pill { padding: 7px 11px; font-size: 12px; white-space: nowrap; }
  .back-btn { width: 32px; height: 32px; }
  .transport { gap: 8px; padding-right: 8px; }
  .transport .time { display: none; }
  .tbtn { padding: 0 11px; }
  .tbtn#shareBtn span { display: none; }
}
#scrub { flex: 1; accent-color: var(--accent); }

/* ---------- producer dock ---------- */
.dock {
  position: fixed; z-index: 6; top: 84px; right: var(--gutter); bottom: var(--gutter); width: var(--dock-w);
  display: flex; flex-direction: column;
  background: var(--glass); backdrop-filter: blur(20px) saturate(1.2); border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden;
}
.dock-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.dock-head strong { display: block; font-size: 14px; }
.dock-head small { color: var(--muted); font-size: 12px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; flex: none; background: conic-gradient(from 90deg, var(--accent), var(--accent-2), var(--accent)); box-shadow: 0 0 18px color-mix(in srgb, var(--accent) 50%, transparent); }
.dock-toggle { margin-left: auto; width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: transparent; display: none; place-items: center; }
.dock-toggle svg { width: 18px; height: 18px; stroke: var(--ink); fill: none; stroke-width: 2; transition: transform 0.3s; }

.chat { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; scrollbar-width: thin; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 18px; font-size: 14px; line-height: 1.45; animation: pop 0.35s ease-out; }
.msg.producer { align-self: flex-start; background: var(--surface-2); border-bottom-left-radius: 6px; }
.msg.you { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: var(--on-accent); font-weight: 500; border-bottom-right-radius: 6px; }
.msg b { color: var(--accent); font-weight: 600; }
.msg.typing { display: flex; gap: 4px; padding: 14px; }
.msg.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: blink 1s infinite; }
.msg.typing span:nth-child(2) { animation-delay: 0.15s; }
.msg.typing span:nth-child(3) { animation-delay: 0.3s; }
.card-msg { padding: 0; background: transparent !important; max-width: 100%; width: 100%; }
@keyframes pop { from { opacity: 0; transform: translateY(6px) scale(0.98); } }
@keyframes blink { 50% { opacity: 0.25; } }

.chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 12px 16px 16px; border-top: 1px solid var(--line); }
.chips:empty { display: none; }
.chip-btn {
  border: 1px solid var(--line); background: var(--surface); border-radius: 999px;
  padding: 8px 14px; font-size: 13px; font-weight: 600; transition: background 0.2s, transform 0.1s;
}
.chip-btn:hover { background: var(--surface-2); }
.chip-btn:active { transform: scale(0.97); }
.chip-btn.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--on-accent); }
.chip-btn:disabled { opacity: 0.45; cursor: progress; }

/* cover card inside the chat */
.cover-card { border-radius: 18px; overflow: hidden; border: 1px solid var(--line); background: var(--surface); }
.cover-card img { display: block; width: 100%; aspect-ratio: 1; }
.cover-card .cc-body { padding: 12px; display: grid; gap: 10px; }
.cover-card input { width: 100%; background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-family: var(--display); font-style: italic; font-size: 20px; }
.cover-card .cc-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.cover-card.stale { opacity: 0.45; }

/* ---------- your songs ---------- */
.count-badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; margin-left: 4px; border-radius: 99px; background: var(--accent); color: var(--on-accent); font-size: 11px; }
.count-badge[hidden] { display: none; }
.songs { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 10px; }
.song-row { display: grid; grid-template-columns: 64px 1fr auto; gap: 14px; align-items: center; padding: 10px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); }
.song-row.current { border-color: var(--accent); }
.song-row img { width: 64px; height: 64px; border-radius: 10px; object-fit: cover; display: block; }
.song-row .title { font-family: var(--display); font-style: italic; font-size: 20px; line-height: 1.15; }
.song-row .meta { color: var(--muted); font-size: 12px; }
.song-row .actions { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.song-row .actions .pill { padding: 6px 12px; font-size: 12px; }
.song-row .pill.danger.armed { border-color: var(--bad); color: var(--bad); }
.songs .empty { color: var(--muted); padding: 30px 0; text-align: center; }
.about a { color: var(--accent); }

/* ---------- cloud ---------- */
.lib-tabs { display: flex; gap: 4px; padding: 4px; margin: 6px 0 4px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); width: fit-content; }
.lib-tabs[hidden] { display: none; }
.lib-tabs button { border: 0; background: transparent; padding: 7px 16px; border-radius: 999px; font-weight: 600; font-size: 13px; color: var(--muted); }
.lib-tabs button[aria-selected="true"] { background: var(--accent); color: var(--on-accent); }
.cloud-card { margin-top: 14px; padding: 18px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); display: grid; gap: 12px; }
.cloud-card h4 { margin: 0; font-family: var(--display); font-weight: 400; font-style: italic; font-size: 26px; line-height: 1.1; }
.cloud-card p { margin: 0; color: var(--muted); font-size: 14px; }
.cloud-card input { background: var(--field); border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px; color: var(--ink); font-size: 15px; }
.cloud-card .row .pill.primary, .pill.primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--on-accent); }
.cloud-msg { font-size: 13px; color: var(--muted); min-height: 1.2em; }
.cloud-msg.err { color: var(--bad); }
.cloud-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; margin-top: 14px; font-size: 13px; color: var(--muted); }
.cloud-head strong { color: var(--ink); }
.cloud-head .pill { margin-left: auto; }
.meter-bar { height: 6px; border-radius: 99px; background: var(--surface-2); overflow: hidden; width: 140px; }
.meter-bar i { display: block; height: 100%; background: var(--accent); }
.in-cloud { font-size: 11px; font-weight: 600; color: var(--accent); }
.share-link { grid-column: 1 / -1; font-size: 12px; color: var(--muted); word-break: break-all; }
.share-link a { color: var(--accent); }
@media (max-width: 520px) {
  .song-row { grid-template-columns: 52px 1fr; }
  .song-row img { width: 52px; height: 52px; }
  .song-row .actions { grid-column: 1 / -1; justify-content: flex-start; }
}
.stale-note { margin: 0; font-size: 12px; color: var(--muted); }

/* ---------- studio drawer ---------- */
.studio { position: fixed; inset: 0; z-index: 20; background: var(--scrim); backdrop-filter: blur(4px); display: flex; justify-content: flex-end; }
.studio[hidden] { display: none; }
.studio-panel {
  width: min(600px, 100vw); height: 100%; overflow-y: auto; padding: 22px 24px 40px;
  background: var(--glass-strong); border-left: 1px solid var(--line); animation: slide 0.3s ease-out;
}
@keyframes slide { from { transform: translateX(40px); opacity: 0; } }
.studio-head {
  display: flex; align-items: center; gap: 10px; position: sticky; top: -22px; z-index: 1;
  margin: -22px -24px 0; padding: 18px 24px 12px; background: var(--panel-solid); border-bottom: 1px solid var(--line);
}
.studio-head h2 { font-family: var(--display); font-weight: 400; margin: 0; font-size: 30px; }
.studio-head .pill { margin-left: auto; }
.optional { font-size: 11px; color: var(--muted); background: var(--faint); padding: 3px 9px; border-radius: 99px; }
.studio h3 { font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin: 26px 0 10px; }
.row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.field { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; }
.field input, .field select { background: var(--field); border: 1px solid var(--line); border-radius: 10px; padding: 8px 10px; color: var(--ink); }
.field input { width: 82px; }
.unit { color: var(--muted); }
.toggle { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 13px; cursor: pointer; }
input[type="range"] { accent-color: var(--accent); }
.hint { color: var(--muted); font-size: 12px; }

.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.style-btn { text-align: left; padding: 12px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface); }
.style-btn strong { display: block; font-size: 14px; }
.style-btn span { color: var(--muted); font-size: 12px; }
.style-btn[aria-checked="true"] { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); }

.facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; margin-top: 10px; }
.facts > div, .facts .chip { background: var(--surface); border: 1px solid var(--line); border-radius: 12px; padding: 8px 12px; }
.facts span { display: block; color: var(--muted); font-size: 11px; }
.facts strong { font-size: 14px; }
.bars { display: grid; grid-template-columns: repeat(auto-fill, minmax(58px, 1fr)); gap: 5px; margin-top: 10px; }
.bar { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 7px; font-size: 12px; }
.bar small { display: block; color: var(--muted); font-size: 10px; }
.bar.voiced { border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.bar.edge { opacity: 0.5; }

.legend { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; color: var(--muted); font-size: 12px; margin-bottom: 10px; }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { width: 14px; height: 8px; border-radius: 2px; display: inline-block; }
.sw.band { background: color-mix(in srgb, var(--accent) 35%, transparent); }
.sw.raw { background: var(--muted); height: 4px; }
.sw.ok { background: var(--ok); }
.sw.warn { background: var(--warn); }
.sw.bad { background: var(--bad); }
.legend .zoom { margin-left: auto; gap: 4px; }
.zoom-btn { padding: 4px 10px; font-size: 12px; }
.view-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
#viewCanvas { display: block; }

.sliders { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px 18px; }
.sliders label { display: grid; gap: 6px; color: var(--muted); font-size: 13px; }
.sliders .val { float: right; color: var(--ink); }

/* ---------- phones & narrow screens: the producer becomes a bottom sheet ---------- */
@media (max-width: 900px) {
  :root { --dock-w: 0px; }
  .dock {
    top: auto; left: 10px; right: 10px; bottom: max(10px, env(safe-area-inset-bottom)); width: auto;
    max-height: 46vh; border-radius: 22px;
  }
  .dock-toggle { display: grid; }
  .dock.collapsed .chat { display: none; }
  .dock.collapsed .dock-toggle svg { transform: rotate(180deg); }
  .transport { left: var(--gutter); right: var(--gutter); bottom: calc(var(--dock-h) + 20px); }
  .hero { left: var(--gutter); right: var(--gutter); top: 76px; width: auto; transform: none; }
  body:not([data-mode="idle"]) .hero { transform: translateY(-12px); }
  .hero h1 { font-size: clamp(40px, 11vw, 54px); }
  .count { font-size: 52px; }
  .top-actions { gap: 8px; }
  .themes { gap: 6px; padding: 5px 8px; }
  .theme-dot { width: 16px; height: 16px; }
  .wordmark { font-size: 14px; }
}
@media (max-width: 360px) {
  .wordmark .wm-text { display: none; } /* tiny phones: the dot alone is the logo */
}

/* short phones: keep the headline compact so the orb has room */
@media (max-width: 900px) and (max-height: 720px) {
  .hero { top: 66px; }
  .hero h1 { font-size: clamp(34px, 9vw, 40px); margin-bottom: 6px; }
  .hero p { display: none; }
  .dock { max-height: 40vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
