/* ═══════════════════════════════════════════
   MIDICOMPOSER - Design System
   by Lukas Bohez (Oroka Conner)
   ═══════════════════════════════════════════ */

/* ─── TOKENS: Light ─── */
:root {
  --primary-color: #2c6fb8;
  --brand-accent: #60a5fa;
  --brand-accent-2: #93c5fd;
  --success-color: #36b37e;
  --warning-color: #e65100;
  --info-color: #0d61aa;
  --danger-color: #ff6b6b;

  --bg-60: #f7f8fa;
  --bg-30: #e1e4e8;
  --bg-10: #ffffff;
  --text-60: #111418;
  --text-30: #4b5561;
  --text-10: #64748b;
  --border-color: #d3d7db;
  --shadow-light: rgba(44, 76, 124, 0.06);
  --shadow-medium: rgba(44, 76, 124, 0.15);
  --shadow-heavy: rgba(44, 76, 124, 0.25);
  --bg-overlay: rgba(0,0,0,0.15);
  --text-inverse: #ffffff;
}

/* ─── TOKENS: Dark ─── */
html[data-theme='dark'] {
  --bg-60: #0f1112;
  --bg-30: #1f2326;
  --bg-10: #0a0b0c;
  --text-60: #e6eef8;
  --text-30: #b9c5d6;
  --text-10: #94a3b8;
  --border-color: #2a3034;
  --shadow-light: rgba(0,0,0,0.5);
  --shadow-medium: rgba(0,0,0,0.6);
  --shadow-heavy: rgba(0,0,0,0.8);
  --bg-overlay: rgba(255,255,255,0.12);
  --text-inverse: #0f1112;
}

/* ─── DERIVED TOKENS ─── */
:root {
  --bg: var(--bg-60);
  --bg2: var(--bg-30);
  --surface: var(--bg-30);
  --card: var(--bg-10);
  --card2: #f0f3f6;
  --border: color-mix(in srgb, var(--border-color) 80%, transparent);
  --border2: var(--border-color);
  --txt: var(--text-60);
  --txt-m: var(--text-10);
  --txt-s: color-mix(in srgb, var(--text-10) 60%, var(--text-60) 40%);
  --hi: var(--text-60);
  --ind: var(--primary-color);
  --ind-d: color-mix(in srgb, var(--primary-color) 12%, transparent);
  --ind-glow: color-mix(in srgb, var(--primary-color) 35%, transparent);
  --rose: #FF6584; --rose-d: rgba(255,101,132,.10);
  --amber: #F5A623; --amber-d: rgba(245,166,35,.10);
  --teal: #00C9A7; --teal-d: rgba(0,201,167,.10);
  --green: #2DD4A0; --green-d: rgba(45,212,160,.10);
  --blue: #60A5FA;
  --pink: #F472B6;
  --red: #F87171;
  --mono: 'JetBrains Mono', 'Cascadia Code', Consolas, monospace;
  --sans: 'Inter', system-ui, sans-serif;
  --r: 10px;
  --rl: 14px;
}

html[data-theme='dark'] {
  --card2: #14171a;
}

/* ─── RESET ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body {
  height: 100%;
  background: var(--bg);
  color: var(--txt);
  font-family: var(--sans);
  font-size: 13px;
  overflow: hidden;
}
/* Firefox has no ::-webkit-scrollbar, so without these two properties it falls
   back to full-width system scrollbars and the panels look nothing like they do
   in Chrome. The standard properties come first so Chrome uses them too where
   supported, with the -webkit- rules left as the fallback for older versions. */
* { scrollbar-width: thin; scrollbar-color: var(--border2) transparent; }
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
::-webkit-scrollbar-track { background: transparent; }

/* ─── APP SHELL ─── */
#app { display: flex; flex-direction: column; height: 100vh; }

/* ─── HEADER ─── */
#header {
  flex-shrink: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 0;
  padding: 0 20px;
  background: var(--bg2);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}
#header::after {
  content: '';
  position: absolute;
  bottom: -1px; left: 0; right: 0;
  height: 1px;
  background: var(--ind-glow);
  opacity: .6;
}
#themeToggleBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--txt-m);
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
  padding: 0;
  flex-shrink: 0;
}
#themeToggleBtn:hover { background: var(--card2); color: var(--hi); }

.logo-mark {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-right: 24px;
  cursor: default;
  user-select: none;
}
.logo-spectrum { display: flex; align-items: flex-end; gap: 2px; height: 22px; }
.ls-bar {
  width: 3px;
  background: var(--ind);
  border-radius: 1.5px;
  transition: height .1s ease;
  animation: spectrum-pulse var(--dur, 0.6s) ease-in-out infinite alternate;
}
@keyframes spectrum-pulse { from { opacity: .4; } to { opacity: 1; } }
.logo-text { font-size: 15px; font-weight: 800; color: var(--hi); letter-spacing: -.03em; }
.logo-text span { color: var(--ind); }
.logo-byline { font-size: 9px; color: var(--txt-m); letter-spacing: .05em; }

/* ─── NAV TABS ─── */
#nav { display: flex; gap: 2px; height: 100%; }
.nav-tab {
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 16px;
  height: 100%;
  border: none;
  background: transparent;
  color: var(--txt-m);
  font-family: var(--sans);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all .15s;
  white-space: nowrap;
  position: relative;
}
.nav-tab:hover { color: var(--txt); }
.nav-tab.active { color: var(--hi); border-bottom-color: var(--ind); }

.hsp { flex: 1; }
#header-actions { display: flex; align-items: center; gap: 6px; }

/* ─── PAGES ─── */
#pages { flex: 1; overflow: hidden; }
.page { display: none; height: 100%; overflow-y: auto; }
.page.active { display: block; }
#page-prompt.active, #page-mix.active { display: flex; flex-direction: column; }

/* ─── COMPOSE PAGE ─── */
#compose-inner { padding: 28px 32px 40px; max-width: 1100px; margin: 0 auto; }

.section-header { display: flex; align-items: baseline; gap: 10px; margin-bottom: 16px; }
.section-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--txt-m);
}
.section-title i { margin-right: 5px; }
.section-line { flex: 1; height: 1px; background: var(--border); }

/* ─── PRESET GRID ─── */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 28px;
}
@media (max-width: 900px) { .preset-grid { grid-template-columns: repeat(2, 1fr); } }

.preset-card {
  position: relative;
  padding: 16px;
  border-radius: var(--rl);
  border: 1px solid var(--border2);
  background: var(--card);
  cursor: pointer;
  transition: all .18s;
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  font-family: var(--sans);
  text-align: left;
}
.preset-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 3px;
  background: var(--ac, var(--ind));
  opacity: 0;
  transition: opacity .18s;
}
.preset-card:hover {
  border-color: var(--ac, var(--ind));
  background: var(--card2);
  transform: translateY(-2px);
  box-shadow: 0 8px 32px rgba(0,0,0,.4), 0 0 0 1px var(--ac, var(--ind)) inset;
}
.preset-card:hover::before { opacity: 1; }
.preset-card.active { border-color: var(--ac, var(--ind)); background: var(--card2); }
.preset-card.active::before { opacity: 1; }

.pc-icon {
  width: 36px; height: 36px;
  border-radius: 9px;
  background: var(--ac-d, var(--ind-d));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  color: var(--ac, var(--ind));
  flex-shrink: 0;
}
.pc-name { font-size: 13px; font-weight: 700; color: var(--hi); line-height: 1.2; }
.pc-tag { font-size: 10.5px; color: var(--txt-m); line-height: 1.4; }
.pc-check {
  position: absolute;
  top: 10px; right: 10px;
  width: 18px; height: 18px;
  border-radius: 50%;
  background: var(--ac, var(--ind));
  color: #fff;
  font-size: 9px;
  display: none;
  align-items: center;
  justify-content: center;
}
.preset-card.active .pc-check { display: flex; }

/* ─── INTENSITY STRIP ─── */
.intensity-strip { display: flex; gap: 8px; margin-bottom: 28px; min-height: 80px; align-items: stretch; }
.intensity-placeholder { font-size: 11px; color: var(--txt-s); padding: 20px 0; align-self: center; }

.int-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 14px 10px 12px;
  border-radius: var(--r);
  border: 1px solid var(--border2);
  background: var(--card);
  cursor: pointer;
  transition: all .15s;
  font-family: var(--sans);
}
.int-card:hover { background: var(--card2); }
.int-card.active {
  border-color: var(--ac, var(--ind));
  background: var(--card2);
  box-shadow: 0 0 0 1px var(--ac, var(--ind)) inset, 0 4px 20px rgba(0,0,0,.3);
}
.int-card i { font-size: 16px; color: var(--txt-s); transition: color .15s; }
.int-card.active i { color: var(--ac, var(--ind)); }
.int-label { font-size: 11px; font-weight: 700; color: var(--txt); }
.int-bpm { font-size: 9px; font-family: var(--mono); color: var(--txt-m); }

/* ─── TWO-COL ─── */
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 28px; }
@media (max-width: 700px) { .two-col { grid-template-columns: 1fr; } }

/* ─── FIELDS ─── */
.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--txt-m);
  margin-bottom: 5px;
}
.field-row { display: flex; align-items: center; gap: 10px; }
.field-row input[type=range] { flex: 1; accent-color: var(--ind); cursor: pointer; height: 4px; }
.field-val {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  color: var(--hi);
  min-width: 40px;
  text-align: right;
}
input.bpm-input {
  width: 56px;
  padding: 5px 7px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--hi);
  font-size: 12px;
  font-weight: 600;
  font-family: var(--mono);
  text-align: center;
  outline: none;
  transition: border-color .12s;
}
input.bpm-input:focus { border-color: var(--ind); }
.field-hints { display: flex; justify-content: space-between; font-size: 9px; color: var(--txt-s); margin-top: 3px; }
.bpm-hint { font-weight: 400; color: var(--teal); font-size: 9px; margin-left: 4px; }

/* ─── EXTRA AREA ─── */
textarea.extra-area {
  width: 100%;
  padding: 10px 12px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--hi);
  font-size: 12px;
  font-family: var(--sans);
  outline: none;
  resize: vertical;
  min-height: 72px;
  line-height: 1.6;
  transition: border-color .12s;
}
textarea.extra-area:focus { border-color: var(--ind); }
textarea.extra-area::placeholder { color: var(--txt-s); }

/* ─── INSTRUMENT CHECKBOXES ─── */
.instruments-grid { display: flex; flex-direction: column; gap: 6px; }
.inst-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--card);
  cursor: pointer;
  transition: all .12s;
}
.inst-row:hover { border-color: var(--border2); background: var(--card2); }
.inst-row.enabled { border-color: color-mix(in srgb, var(--ind) 25%, transparent); }
.inst-check {
  width: 16px; height: 16px;
  border-radius: 4px;
  border: 1.5px solid var(--border2);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all .12s;
}
.inst-row.enabled .inst-check { background: var(--ind); border-color: var(--ind); }
.inst-check i { font-size: 8px; color: #fff; display: none; }
.inst-row.enabled .inst-check i { display: block; }
.inst-row input[type=checkbox] { display: none; }
.inst-info { flex: 1; }
.inst-name { font-size: 12px; font-weight: 600; color: var(--txt); }
.inst-sub { font-size: 9.5px; color: var(--txt-m); }
.inst-icon { font-size: 13px; color: var(--txt-s); width: 20px; text-align: center; }
.inst-program {
  font-family: var(--sans);
  font-size: 11px;
  padding: 2px 6px;
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--hi);
  outline: none;
  cursor: pointer;
  transition: border-color .12s;
  max-width: 130px;
}
.inst-program:focus { border-color: var(--ind); }

/* ─── MELODY ZONE ─── */
.melody-zone {
  border: 2px dashed var(--border2);
  border-radius: var(--rl);
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all .15s;
  margin-bottom: 28px;
}
.melody-zone:hover { border-color: var(--ind); background: var(--ind-d); }
.melody-zone.loaded {
  border-style: solid;
  border-color: color-mix(in srgb, var(--teal) 35%, transparent);
  background: var(--teal-d);
  text-align: left;
  cursor: default;
}
.mz-icon { font-size: 20px; color: var(--txt-s); margin-bottom: 6px; }
.mz-label { font-size: 11.5px; color: var(--txt-m); }
.mz-label strong { color: var(--txt); }
.mz-loaded-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.mz-title { font-size: 12px; font-weight: 700; color: var(--teal); display: flex; align-items: center; gap: 6px; }
.mz-meta { font-size: 10px; font-family: var(--mono); color: var(--txt-m); }
.mz-bars { display: flex; gap: 2px; height: 28px; align-items: flex-end; margin-top: 6px; }
.mz-bar { flex: 1; background: var(--teal); border-radius: 2px; opacity: .6; min-height: 3px; }
.mz-tracks { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.mz-track-chip {
  padding: 3px 9px;
  border-radius: 20px;
  border: 1px solid var(--border2);
  background: var(--card);
  font-size: 10px;
  cursor: pointer;
  transition: all .1s;
  color: var(--txt-m);
}
.mz-track-chip:hover { border-color: var(--teal); color: var(--teal); }
.mz-track-chip.active { background: var(--teal-d); border-color: var(--teal); color: var(--teal); font-weight: 600; }

/* ─── PROMPT (inside "Let an AI write the notes") ─── */
#prompt-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.9;
  color: var(--txt);
  white-space: pre-wrap;
  background: var(--bg);
  outline: none;
  cursor: text;
}
#prompt-area.empty { color: var(--txt-s); font-style: italic; }

/* ─── MIX PAGE ─── */
#mix-inner { flex: 1; display: grid; grid-template-columns: 1fr; overflow: hidden; min-height: 0; }
.mix-board { display: flex; flex-direction: column; overflow: hidden; background: var(--bg2); }
#mix-inner.no-paste #mixer-scroll {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr));
  gap: 10px; align-content: start;
}
#mix-inner.no-paste .mx-card { margin: 0; }
.panel-head {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.panel-title {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--txt-m);
}
.panel-title i { margin-right: 5px; }

#json-paste {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  background: var(--bg);
  color: var(--hi);
  font-family: var(--mono);
  font-size: 10.5px;
  line-height: 1.7;
  padding: 14px 16px;
  transition: background .15s;
}
#json-paste.err { background: color-mix(in srgb, var(--red) 4%, transparent); }
#json-paste.ok { background: color-mix(in srgb, var(--green) 3%, transparent); }
#json-paste::placeholder { color: var(--txt-s); font-family: var(--sans); font-size: 12px; }


#parse-msg {
  padding: 4px 2px;
  font-size: 10px;
  font-family: var(--mono);
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 5px;
}
.msg-ok { color: var(--green); }
.msg-err { color: var(--red); }


/* ─── MIXER PANEL ─── */
#mixer-scroll { flex: 1; overflow-y: auto; padding: 10px; }
#mixer-empty { padding: 40px 20px; text-align: center; color: var(--txt-s); font-size: 11px; }

.mx-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 6px;
  overflow: hidden;
  transition: opacity .15s;
}
.mx-card.muted { opacity: .3; }
.mx-card.locked { border-color: color-mix(in srgb, var(--amber) 30%, transparent); }
.mx-top {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 9px;
  border-bottom: 1px solid var(--border);
}
.mx-color { width: 3px; height: 20px; border-radius: 2px; flex-shrink: 0; }
.mx-name { flex: 1; font-size: 10.5px; font-weight: 700; color: var(--hi); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mx-sub { font-size: 8.5px; color: var(--txt-m); white-space: nowrap; }
.mx-btn {
  width: 20px; height: 20px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--txt-m);
  font-size: 9px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .1s;
  padding: 0;
  flex-shrink: 0;
}
.mx-btn:hover { border-color: var(--border2); color: var(--hi); }
.mx-btn.on { background: var(--amber-d); border-color: color-mix(in srgb, var(--amber) 30%, transparent); color: var(--amber); }
.mx-btn.mut { background: var(--ind-d); border-color: color-mix(in srgb, var(--ind) 30%, transparent); color: var(--ind); }

.mx-faders { padding: 7px 9px; display: flex; flex-direction: column; gap: 4px; }
.mx-fader-row { display: flex; align-items: center; gap: 6px; }
.mx-fader-label { font-size: 8px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--txt-s); width: 24px; }
.mx-fader-row input[type=range] { flex: 1; accent-color: var(--ac, var(--ind)); height: 3px; cursor: pointer; }
.mx-fader-val { font-family: var(--mono); font-size: 8px; color: var(--txt-m); min-width: 24px; text-align: right; }
.mx-info { font-size: 8.5px; color: var(--txt-s); padding: 4px 9px; border-top: 1px solid var(--border); }
.mx-roll { height: 16px; border-top: 1px solid var(--border); overflow: hidden; }
.mx-roll canvas { display: block; width: 100%; height: 100%; }

#mix-footer {
  padding: 10px 16px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}
.mix-status-text { font-size: 11px; color: var(--txt-m); }

/* ─── EXPORT PAGE ─── */
#export-inner { max-width: 720px; margin: 0 auto; padding: 40px 32px; }
.export-hero { text-align: center; padding: 40px 0 32px; }
.export-hero-icon {
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--ind-d);
  border: 2px solid color-mix(in srgb, var(--ind) 25%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  color: var(--ind);
  margin: 0 auto 16px;
}
.export-title { font-size: 22px; font-weight: 800; color: var(--hi); margin-bottom: 6px; letter-spacing: -.02em; }
.export-sub { font-size: 12.5px; color: var(--txt-m); max-width: 480px; margin: 0 auto; line-height: 1.65; }

.daw-compat {
  display: flex;
  justify-content: center;
  gap: 20px;
  padding: 16px 0 24px;
  flex-wrap: wrap;
}
.daw-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  font-size: 10px;
  color: var(--txt-m);
}
.daw-icon i { font-size: 22px; color: var(--ind); opacity: .7; }
.daw-icon:hover i { opacity: 1; }

.export-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin: 24px 0; }
.export-card {
  padding: 20px;
  border-radius: var(--rl);
  border: 1px solid var(--border2);
  background: var(--card);
}
.export-card-title {
  font-size: 11.5px;
  font-weight: 700;
  color: var(--hi);
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 7px;
}
.export-card-title i { color: var(--ind); }
.export-card-desc { font-size: 10.5px; color: var(--txt-m); line-height: 1.6; margin-bottom: 14px; }

.watermark-info {
  padding: 16px;
  border-radius: var(--r);
  border: 1px solid color-mix(in srgb, var(--amber) 20%, transparent);
  background: color-mix(in srgb, var(--amber) 5%, transparent);
  margin: 16px 0;
  display: flex;
  gap: 12px;
  align-items: flex-start;
}
.wm-icon { font-size: 16px; color: var(--amber); flex-shrink: 0; margin-top: 2px; }
.wm-text { font-size: 11px; color: var(--txt); line-height: 1.65; }
.wm-text strong { color: var(--amber); }

.copyright-box {
  margin: 20px 0;
  padding: 16px;
  border-radius: var(--r);
  border: 1px solid var(--border2);
  background: var(--card);
}
.cb-label { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .07em; color: var(--txt-m); margin-bottom: 6px; }
.cb-label i { margin-right: 4px; }
.cb-input {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--hi);
  font-family: var(--sans);
  font-size: 12px;
  outline: none;
  transition: border-color .12s;
  margin-bottom: 8px;
}
.cb-input:focus { border-color: var(--ind); }
.cb-hint { font-size: 9.5px; color: var(--txt-s); line-height: 1.5; }
.verify-row { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.verify-result-text { font-size: 11px; color: var(--txt-m); font-family: var(--mono); }

.export-footer {
  font-size: 10.5px;
  color: var(--txt-s);
  text-align: center;
  line-height: 1.7;
  padding-top: 8px;
}

/* ─── BUTTONS ─── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border2);
  background: transparent;
  color: var(--txt-m);
  font-size: 11.5px;
  font-weight: 500;
  font-family: var(--sans);
  cursor: pointer;
  white-space: nowrap;
  transition: all .13s;
}
.btn:hover { background: color-mix(in srgb, var(--txt) 5%, transparent); color: var(--hi); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .25; pointer-events: none; }
.btn.sm { height: 26px; padding: 0 10px; font-size: 10.5px; border-radius: 6px; }
.btn.lg { height: 40px; padding: 0 20px; font-size: 13px; font-weight: 700; border-radius: 10px; }
.btn.xl { height: 46px; padding: 0 28px; font-size: 14px; font-weight: 800; border-radius: 11px; }
.btn.full { width: 100%; }
.btn.primary {
  background: var(--ind);
  border-color: var(--ind);
  color: #fff;
  box-shadow: 0 4px 20px var(--ind-glow);
}
.btn.primary:hover { filter: brightness(1.12); box-shadow: 0 6px 28px var(--ind-glow); }
.btn.ghost-green { border-color: color-mix(in srgb, var(--green) 30%, transparent); color: var(--green); }
.btn.ghost-green:hover { background: var(--green-d); }
.btn.ghost-teal { border-color: color-mix(in srgb, var(--teal) 30%, transparent); color: var(--teal); }
.btn.ghost-teal:hover { background: var(--teal-d); }
.btn.ghost-amber { border-color: color-mix(in srgb, var(--amber) 30%, transparent); color: var(--amber); }
.btn.ghost-amber:hover { background: var(--amber-d); }
.btn.ghost-red { border-color: color-mix(in srgb, var(--red) 25%, transparent); color: var(--red); }
.btn.ghost-red:hover { background: color-mix(in srgb, var(--red) 7%, transparent); }
.btn.ghost-ind { border-color: color-mix(in srgb, var(--ind) 30%, transparent); color: var(--ind); }
.btn.ghost-ind:hover { background: var(--ind-d); }

/* ─── STATUS BAR ─── */
#statusbar {
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  background: var(--bg2);
  border-top: 1px solid var(--border);
  font-size: 10px;
  color: var(--txt-m);
}
.status-dot {
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--border2);
  flex-shrink: 0;
  transition: background .2s;
}
.status-dot.ok { background: var(--green); }
.status-dot.active { background: var(--ind); animation: pulse-dot 1.5s ease-in-out infinite; }
.status-dot.warn { background: var(--amber); }
@keyframes pulse-dot { 0%, 100% { opacity: 1; } 50% { opacity: .4; } }
.sb-spacer { flex: 1; }

kbd {
  padding: 1px 4px;
  border-radius: 3px;
  background: var(--card);
  border: 1px solid var(--border2);
  font-family: var(--mono);
  font-size: 8.5px;
  color: var(--txt-m);
}

/* ─── TOASTS ─── */
#toasts {
  position: fixed;
  top: 64px; right: 14px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 5px;
  pointer-events: none;
}
.toast {
  background: var(--card2);
  border: 1px solid var(--border2);
  padding: 9px 13px;
  border-radius: 9px;
  font-size: 11.5px;
  color: var(--txt);
  opacity: 0;
  transform: translateX(14px);
  transition: all .18s;
  max-width: 310px;
  pointer-events: all;
  display: flex;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(8px);
}
.toast.show { opacity: 1; transform: none; }
.toast.ok { border-left: 3px solid var(--green); }
.toast.err { border-left: 3px solid var(--red); }
.toast.warn { border-left: 3px solid var(--amber); }
.toast.info { border-left: 3px solid var(--ind); }

/* ─── ACCENT PALETTE ─── */
.ac-ind { --ac: var(--ind); --ac-d: var(--ind-d); }
.ac-rose { --ac: var(--rose); --ac-d: var(--rose-d); }
.ac-amber { --ac: var(--amber); --ac-d: var(--amber-d); }
.ac-teal { --ac: var(--teal); --ac-d: var(--teal-d); }
.ac-blue { --ac: var(--blue); --ac-d: color-mix(in srgb, var(--blue) 10%, transparent); }
.ac-pink { --ac: var(--pink); --ac-d: color-mix(in srgb, var(--pink) 10%, transparent); }
.ac-green { --ac: var(--green); --ac-d: var(--green-d); }
.ac-red { --ac: var(--red); --ac-d: color-mix(in srgb, var(--red) 10%, transparent); }

#fi-midi, #fi-verify { display: none; }
/* ===== Transport and piano roll (studio.js) ===== */
#transport {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-bottom: 1px solid var(--border);
  background: var(--bg1); flex-shrink: 0;
}
.tp-pos {
  font-family: var(--mono); font-size: 12px; color: var(--txt-m);
  min-width: 88px; letter-spacing: .04em;
}
.tp-vol { display: flex; align-items: center; gap: 6px; color: var(--txt-m); font-size: 11px; }
.tp-vol input { width: 90px; }
.song-summary {
  font-family: var(--mono); font-size: 10px; color: var(--txt-m);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60%;
}
/* The roll spans the page above the split panel: it is the main readout now
   that the app composes on its own, so it gets the full width. */
#roll {
  display: block; width: 100%; height: 210px; flex-shrink: 0;
  border-bottom: 1px solid var(--border); cursor: crosshair;
  background: var(--bg2);
}
#page-mix { display: flex; flex-direction: column; overflow: hidden; }
@media (max-width: 860px) {
  #roll { height: 140px; }
  .song-summary { display: none; }
}

/* Key picker: root and mode share the row. */
.key-row { display: flex; gap: 8px; }
.key-row select { flex: 1; min-width: 0; }
#key-hint { font-family: var(--mono); }

/* ===== One obvious path (compose page) =====
   Style, mood, Compose & Play. The button lives in a bar pinned to the bottom
   of the page, so it is on screen however far down the options go, and the
   options a style already sets are folded into "More options". */
.nav-tab i { font-size: 11px; opacity: .8; }
.compose-intro { margin: 0 0 22px; max-width: 70ch; font-size: 13px; line-height: 1.6; color: var(--txt); }
.step-n {
  display: inline-flex; align-items: center; justify-content: center;
  width: 17px; height: 17px; margin-right: 6px; border-radius: 50%;
  background: var(--ind); color: #fff; font-size: 9.5px; letter-spacing: 0;
}
/* Compact style cards: all sixteen fit on a laptop screen with the button. */
.preset-card {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto;
  column-gap: 10px; row-gap: 1px; align-items: center; padding: 10px 12px;
}
.preset-card .pc-icon { grid-row: 1 / span 2; width: 30px; height: 30px; font-size: 13px; border-radius: 8px; }
.preset-card .pc-name { align-self: end; padding-right: 18px; }
.preset-card .pc-tag { align-self: start; }
.preset-card .pc-check { top: 50%; transform: translateY(-50%); }
.preset-grid { gap: 8px; margin-bottom: 24px; }
.intensity-strip { min-height: 0; margin-bottom: 20px; }
.int-card { padding: 10px 10px 9px; }

.more-opts { margin: 0 0 16px; border: 1px solid var(--border2); border-radius: var(--r); background: var(--card); }
.more-opts > summary {
  cursor: pointer; padding: 11px 14px; font-size: 12px; font-weight: 600; color: var(--txt);
  list-style-position: inside;
}
.more-opts > summary i { margin: 0 4px 0 2px; color: var(--txt-m); }
.more-opts-sub { font-weight: 400; color: var(--txt-m); margin-left: 6px; }
.more-opts[open] > summary { border-bottom: 1px solid var(--border); }
.more-opts .two-col { padding: 16px 14px 4px; margin: 0; }

.compose-bar {
  position: sticky; bottom: 0; z-index: 5;
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 -12px; padding: 12px;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(8px);
  border-top: 1px solid var(--border);
}
.compose-sel { font: 11px var(--mono); color: var(--txt-m); min-width: 0; }

/* The AI page says what it is for and owns the inputs only the prompt reads. */
.prompt-extras-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.prompt-extras-grid .melody-zone { min-height: 0; padding: 14px; margin: 0; }
.prompt-extras-grid .field { margin-bottom: 6px; }
.prompt-extras-grid textarea.extra-area { min-height: 76px; }

#mixer-empty { font-size: 12px; line-height: 2.2; color: var(--txt-m); }
.linkish {
  border: 0; background: none; padding: 0; font: inherit; color: var(--ind);
  text-decoration: underline; cursor: pointer;
}
.sb-keys kbd:nth-of-type(2) { margin-left: 8px; }

@media (max-width: 700px) {
  #compose-inner { padding: 18px 14px 0; }
  .compose-bar .btn.lg { flex: 1; justify-content: center; }
  .compose-sel { flex-basis: 100%; }
  .compose-bar .hsp { display: none; }
  .prompt-extras-grid { grid-template-columns: 1fr; }
  .more-opts-sub { display: block; margin: 4px 0 0; }
  .logo-byline, .sb-keys { display: none; }
  .nav-tab { padding: 0 10px; }
}

/* Toasts only inform: let clicks through to whatever they happen to cover. */
.toast { pointer-events: none; }
#mix-inner.no-paste #mixer-scroll { grid-auto-rows: max-content; }
@media (max-width: 700px) {
  /* Tabs get their own row on a phone instead of running off the edge. */
  #header { flex-wrap: wrap; height: auto; padding: 8px 12px 0; row-gap: 6px; }
  #nav { order: 3; flex-basis: 100%; height: 40px; }
  .nav-tab { flex: 1; justify-content: center; }
  #transport { flex-wrap: wrap; }
  .tp-vol { display: none; }
}

/* ===== One place to write music (compose page) =====
   The built-in composer and the outside-AI route share the style, mood and
   options above; the AI route sits under an "or", and its reply lands on
   Listen & Mix like a composed piece. */
.len-mode { margin-left: 6px; font-weight: 400; color: var(--teal); font-size: 10px; }
.len-reset { margin-left: 8px; font-size: 10px; }
.or-divider {
  display: flex; align-items: center; gap: 12px; margin: 22px 0 14px;
  color: var(--txt-m); font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
}
.or-divider::before, .or-divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.ai-route { margin-bottom: 28px; }
.ai-steps { padding: 14px; display: grid; gap: 18px; }
.ai-step-head { font-size: 12px; font-weight: 700; color: var(--hi); margin-bottom: 10px; display: flex; align-items: center; flex-wrap: wrap; gap: 4px; }
.ai-opt { font-weight: 400; color: var(--txt-m); }
.ai-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 10px; }
.ai-note { font-size: 11px; color: var(--txt-m); }
.prompt-peek { margin-top: 10px; }
.prompt-peek > summary { cursor: pointer; font-size: 11px; color: var(--txt-m); }
.prompt-peek #prompt-area {
  margin-top: 8px; max-height: 320px; border: 1px solid var(--border); border-radius: var(--r);
  padding: 14px 16px; font-size: 11px; line-height: 1.7;
}
.ai-step #json-paste {
  display: block; width: 100%; min-height: 140px; resize: vertical;
  border: 1px solid var(--border2); border-radius: var(--r); padding: 12px 14px;
}
.ai-step #parse-msg { padding: 0; min-height: 0; }

/* Listen & Mix says plainly that the page plays a preview. */
.preview-note {
  display: flex; gap: 8px; align-items: flex-start; margin: 0; padding: 8px 12px;
  border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--ind) 7%, var(--bg1));
  font-size: 11.5px; line-height: 1.5; color: var(--txt); flex-shrink: 0;
}
.preview-note i { color: var(--ind); margin-top: 3px; }
.preview-note strong { color: var(--hi); }
#tp-again[hidden] { display: none; }
@media (max-width: 700px) {
  .preview-note { font-size: 11px; }
  .ai-steps { padding: 12px 10px; }
}
