:root {
  --bg: #050914;
  --bg2: #07132a;
  --panel: rgba(10, 22, 42, .92);
  --panel2: rgba(15, 34, 64, .86);
  --surface: rgba(7, 15, 31, .78);
  --line: #24456f;
  --line2: #3a73aa;
  --text: #f1fbff;
  --muted: #9bb8d4;
  --faint: #6988ab;
  --cyan: #6fffe9;
  --cyan2: #29cfce;
  --blue: #2e6cff;
  --gold: #ffd35a;
  --gold2: #ffea9d;
  --pink: #ff5ea8;
  --green: #7dff99;
  --red: #ff637f;
  --shadow: rgba(0, 0, 0, .46);
  --radius: 18px;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
  margin: 0;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 0%, rgba(111, 255, 233, .16), transparent 30%),
    radial-gradient(circle at 90% 8%, rgba(255, 94, 168, .13), transparent 26%),
    radial-gradient(circle at 55% 104%, rgba(255, 211, 90, .12), transparent 31%),
    linear-gradient(135deg, #020510 0%, #07142a 46%, #040711 100%);
  overflow: hidden;
}
button, input, select { font: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
.skip-link {
  position: fixed;
  left: 10px;
  top: -100px;
  z-index: 100;
  background: var(--gold);
  color: #07111e;
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 900;
}
.skip-link:focus { top: 10px; }
.app-shell {
  height: 100vh;
  padding: 12px;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  gap: 10px;
}
.app-header, .phase-ribbon, .panel, .app-footer {
  border: 1px solid rgba(111, 255, 233, .2);
  background: linear-gradient(180deg, rgba(12, 28, 55, .95), rgba(5, 12, 27, .92));
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.08);
}
.app-header {
  min-height: 104px;
  padding: 12px;
  display: grid;
  grid-template-columns: minmax(320px, 1fr) auto;
  gap: 12px;
  align-items: center;
}
.brand-lockup { display: grid; grid-template-columns: 310px minmax(240px, 1fr); gap: 14px; align-items: center; min-width: 0; }
.brand-logo {
  display: block;
  width: 100%;
  max-width: 310px;
  border-radius: 16px;
  filter: drop-shadow(0 0 16px rgba(111,255,233,.16));
}
.brand-copy { min-width: 0; }
.eyebrow {
  display: inline-flex;
  align-items: center;
  color: var(--cyan);
  font-size: 11px;
  letter-spacing: .16em;
  text-transform: uppercase;
  font-weight: 950;
}
.brand-copy h1 {
  font-size: clamp(22px, 3vw, 38px);
  line-height: .98;
  letter-spacing: -.055em;
  margin-top: 4px;
}
.brand-copy p { margin-top: 7px; color: #b6cae0; max-width: 760px; font-weight: 650; line-height: 1.35; }
.transport { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; max-width: 560px; }
.btn {
  min-height: 38px;
  border: 1px solid var(--line2);
  border-radius: 13px;
  padding: 9px 12px;
  color: var(--text);
  background: linear-gradient(180deg, #17345f, #0b1b35);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.09), 0 8px 22px rgba(0,0,0,.18);
  font-size: 12px;
  font-weight: 950;
  transition: transform .16s ease, border-color .16s ease, filter .16s ease;
}
.btn:hover { transform: translateY(-1px); border-color: var(--cyan); filter: brightness(1.05); }
.btn.primary { color: #03141b; border-color: #b9fff8; background: linear-gradient(180deg, #a9fff7, #35d0cd); }
.btn.success { color: #041508; border-color: #c8ffd1; background: linear-gradient(180deg, #b8ffc6, #4cdc72); }
.btn.gold { color: #171000; border-color: #fff2b5; background: linear-gradient(180deg, #fff2a5, #ffd35a); }
.btn.danger { border-color: #ff8ca2; background: linear-gradient(180deg, #9c2545, #3b1022); }
.btn.secondary { background: linear-gradient(180deg, #17345f, #0b1b35); }
.btn.ghost { background: rgba(255,255,255,.045); border-color: rgba(255,255,255,.16); color: #cee2ff; }
.btn.full { width: 100%; align-self: end; }
.phase-ribbon {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
}
.phase-ribbon article {
  min-height: 76px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px;
  padding: 10px;
  background:
    linear-gradient(135deg, rgba(111,255,233,.08), transparent 46%),
    rgba(255,255,255,.035);
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 9px;
  align-items: start;
}
.phase-ribbon strong { color: var(--gold); font-size: 17px; }
.phase-ribbon span { font-weight: 950; }
.phase-ribbon small { grid-column: 2; color: var(--muted); line-height: 1.3; }
.workspace {
  min-height: 0;
  display: grid;
  grid-template-columns: 330px minmax(420px, 1fr) 360px;
  gap: 10px;
}
.panel { min-height: 0; padding: 12px; overflow: hidden; }
.control-panel, .inspector-panel { overflow-y: auto; display: grid; align-content: start; gap: 11px; scrollbar-color: #3c72a9 rgba(4,8,18,.45); }
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 3px;
}
.panel-heading.compact { margin-bottom: 8px; }
.panel-heading > div { display: flex; align-items: center; gap: 9px; min-width: 0; }
.panel-heading h2 { font-size: 15px; letter-spacing: -.02em; }
.step-index {
  width: 30px; height: 30px; display: inline-grid; place-items: center;
  border-radius: 11px;
  background: rgba(111,255,233,.11);
  border: 1px solid rgba(111,255,233,.22);
  color: var(--gold);
  font-weight: 950;
  font-size: 12px;
}
.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255,211,90,.28);
  border-radius: 999px;
  color: var(--gold2);
  background: rgba(255,211,90,.08);
  padding: 5px 8px;
  font-size: 10px;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .08em;
  white-space: nowrap;
}
label { display: grid; gap: 6px; color: #c7dcf4; font-size: 12px; font-weight: 850; }
input, select {
  min-height: 38px;
  border-radius: 12px;
  border: 1px solid rgba(111,255,233,.22);
  background: #071326;
  color: var(--text);
  padding: 8px 10px;
  outline: none;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
}
input:focus, select:focus { border-color: var(--cyan); box-shadow: 0 0 0 3px rgba(111,255,233,.11); }
input[type="range"] { padding: 0; accent-color: var(--cyan); min-height: 22px; }
output { justify-self: end; color: var(--gold); font-weight: 950; }
.split-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; align-items: end; }
.range-stack { display: grid; gap: 10px; padding: 9px; border: 1px solid rgba(255,255,255,.09); background: rgba(255,255,255,.035); border-radius: 16px; }
.callout {
  border: 1px solid rgba(255,211,90,.22);
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(255,211,90,.1), rgba(111,255,233,.045));
  padding: 11px;
}
.callout strong { display: block; color: var(--gold2); margin-bottom: 5px; font-size: 12px; }
.callout p { color: var(--muted); font-size: 12px; line-height: 1.35; }
.center-stack { min-height: 0; display: grid; grid-template-rows: auto 210px minmax(0, 1fr); gap: 10px; }
.hero-panel {
  min-height: 190px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 180px;
  gap: 14px;
  align-items: stretch;
  background:
    radial-gradient(circle at 90% 0%, rgba(255,94,168,.15), transparent 36%),
    radial-gradient(circle at 0% 0%, rgba(111,255,233,.16), transparent 40%),
    linear-gradient(180deg, rgba(12, 28, 55, .95), rgba(5, 12, 27, .92));
}
.hero-copy { display: grid; align-content: center; gap: 9px; min-width: 0; }
.hero-copy h2 { font-size: clamp(24px, 3.2vw, 42px); letter-spacing: -.06em; line-height: .96; }
.hero-copy p { color: #b8cee8; line-height: 1.35; max-width: 820px; }
.hero-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.signal-card {
  border-radius: 18px;
  border: 1px solid rgba(111,255,233,.22);
  background: rgba(3,8,17,.58);
  display: grid;
  place-items: center;
  align-content: center;
  gap: 8px;
  text-align: center;
}
.orb {
  width: 78px;
  height: 78px;
  border-radius: 999px;
  background:
    radial-gradient(circle, #fff 0 8%, var(--cyan) 9% 27%, var(--blue) 28% 56%, rgba(255,94,168,.8) 57% 75%, transparent 76%),
    #061426;
  border: 1px solid rgba(255,255,255,.2);
  box-shadow: 0 0 30px rgba(111,255,233,.2);
  transition: transform .2s ease, box-shadow .2s ease;
}
.orb.active, .orb.playing { animation: pulse 1s ease-in-out infinite alternate; box-shadow: 0 0 44px rgba(111,255,233,.5), 0 0 24px rgba(255,94,168,.32); }
@keyframes pulse { from { transform: scale(.97); } to { transform: scale(1.05); } }

.audio-meter-shell {
  width: min(132px, 88%);
  height: 9px;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(111,255,233,.2);
  background: rgba(255,255,255,.07);
}
.audio-meter-shell span {
  display: block;
  width: 2%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--cyan), var(--gold), var(--pink));
  transition: width .08s linear;
}
#audioStatusText {
  width: 90%;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.25;
}

#statusText { font-size: 14px; }
#clockText { color: var(--gold); font-weight: 950; }
.timeline-panel { overflow: hidden; }
.timeline {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(130px, 1fr);
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 4px;
  scrollbar-color: #3c72a9 rgba(4,8,18,.45);
}
.section-card {
  min-height: 140px;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 16px;
  padding: 10px;
  background: linear-gradient(180deg, rgba(25,58,99,.6), rgba(6,15,30,.72));
  display: grid;
  align-content: start;
  gap: 7px;
  position: relative;
  overflow: hidden;
}
.section-card:before {
  content: "";
  position: absolute; inset: 0 0 auto 0; height: 4px;
  background: linear-gradient(90deg, var(--cyan), var(--blue), var(--gold), var(--pink));
  opacity: .75;
}
.section-card strong { font-size: 13px; margin-top: 3px; }
.section-card small { color: var(--muted); line-height: 1.25; }
.energy-meter { height: 7px; border-radius: 999px; background: rgba(255,255,255,.08); overflow: hidden; }
.energy-meter span { display: block; height: 100%; background: linear-gradient(90deg, var(--cyan), var(--gold), var(--pink)); border-radius: inherit; }
.lower-grid { min-height: 0; display: grid; grid-template-columns: .88fr 1.12fr; gap: 10px; }
.lane-map { display: grid; gap: 8px; overflow-y: auto; max-height: calc(100% - 42px); padding-right: 3px; }
.lane {
  display: grid;
  grid-template-columns: 96px 1fr auto;
  gap: 9px;
  align-items: center;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 14px;
  padding: 8px;
  background: rgba(255,255,255,.035);
}
.lane strong { font-size: 12px; }
.lane span { color: var(--muted); font-size: 11px; line-height: 1.3; }
.lane em { color: var(--gold); font-size: 11px; font-style: normal; font-weight: 950; }
.piano-panel { min-width: 0; }
#motifCanvas {
  width: 100%;
  height: calc(100% - 42px);
  min-height: 180px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.1);
  background:
    linear-gradient(90deg, rgba(255,255,255,.04) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255,255,255,.05) 1px, transparent 1px),
    rgba(2,8,18,.55);
  background-size: 40px 100%, 100% 28px;
}
.style-card, .reference-list, .mutation-log { display: grid; gap: 8px; }
.style-card article, .reference-list article, .mutation-log article {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 15px;
  background: rgba(255,255,255,.035);
  padding: 10px;
}
.style-card h3, .reference-list h3 { font-size: 14px; margin-bottom: 5px; }
.style-card p, .reference-list p, .mutation-log p { color: var(--muted); font-size: 12px; line-height: 1.35; }
.mini-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; margin-top: 9px; }
.mini-grid span { border-radius: 12px; border: 1px solid rgba(111,255,233,.13); background: rgba(111,255,233,.055); padding: 7px; color: #dceeff; font-size: 11px; font-weight: 800; }
.top-gap { margin-top: 8px; }
.mutation-log { max-height: 170px; overflow-y: auto; }
.app-footer {
  min-height: 42px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
  padding: 9px 12px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
}
.docs-dialog {
  width: min(780px, calc(100vw - 30px));
  border: 1px solid rgba(111,255,233,.28);
  border-radius: 22px;
  background: #071326;
  color: var(--text);
  box-shadow: 0 40px 120px rgba(0,0,0,.56);
  padding: 0;
}
.docs-dialog::backdrop { background: rgba(0, 0, 0, .72); backdrop-filter: blur(5px); }
.docs-head { display: flex; justify-content: space-between; gap: 12px; align-items: start; padding: 18px; border-bottom: 1px solid rgba(255,255,255,.1); }
.docs-head h2 { margin-top: 4px; }
.docs-body { padding: 18px; display: grid; gap: 12px; color: #c8dcf4; line-height: 1.45; }
.docs-body h3 { color: var(--gold2); }
.docs-body code { color: var(--cyan); background: rgba(111,255,233,.08); border-radius: 5px; padding: 1px 4px; }
.docs-body ul { margin: 0; padding-left: 20px; }
@media (max-width: 1220px) {
  body { overflow: auto; }
  .app-shell { height: auto; min-height: 100vh; }
  .app-header { grid-template-columns: 1fr; }
  .transport { justify-content: start; max-width: none; }
  .workspace { grid-template-columns: 1fr; }
  .center-stack { grid-template-rows: auto auto auto; }
  .control-panel, .inspector-panel { max-height: none; }
  .phase-ribbon { grid-template-columns: repeat(2, minmax(0,1fr)); }
}
@media (max-width: 760px) {
  .brand-lockup { grid-template-columns: 1fr; }
  .brand-logo { max-width: 100%; }
  .phase-ribbon { grid-template-columns: 1fr; }
  .hero-panel, .lower-grid, .split-row { grid-template-columns: 1fr; }
  .lane { grid-template-columns: 1fr; }
  .app-footer { justify-content: start; }
}

/* Phase 2 additions */
.soundfont-matrix {
  display: grid;
  gap: 8px;
}
.soundfont-matrix article {
  border: 1px solid rgba(111,255,233,.15);
  border-radius: 14px;
  padding: 9px;
  background: linear-gradient(135deg, rgba(111,255,233,.06), rgba(255,211,90,.04));
}
.soundfont-matrix strong { display: block; color: var(--gold2); font-size: 12px; letter-spacing: .02em; }
.soundfont-matrix small { display: block; margin-top: 3px; color: var(--cyan); font-weight: 850; text-transform: uppercase; letter-spacing: .08em; font-size: 9px; }
.soundfont-matrix p { margin-top: 5px; color: var(--muted); font-size: 11px; line-height: 1.35; }
.chip-list { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 10px; }
.chip-list span {
  border: 1px solid rgba(111,255,233,.16);
  border-radius: 999px;
  padding: 4px 7px;
  color: #dffcff;
  background: rgba(111,255,233,.06);
  font-size: 10px;
  font-weight: 850;
}
.brand-copy .eyebrow, .hero-copy .eyebrow { color: var(--gold2); }
.timeline .section-card strong { color: #f7fdff; }
.lane em { min-width: 38px; text-align: center; }


/* Phase 4 additions */
.style-dna-panel, .playback-diagnostics {
  display: grid;
  gap: 8px;
}
.style-dna-panel article, .playback-diagnostics article {
  border: 1px solid rgba(111,255,233,.15);
  border-radius: 14px;
  padding: 9px;
  background: linear-gradient(135deg, rgba(111,255,233,.055), rgba(46,108,255,.045));
}
.style-dna-panel h3, .playback-diagnostics h3 {
  font-size: 13px;
  color: var(--gold2);
  margin-bottom: 6px;
}
.style-dna-panel p, .playback-diagnostics p, .tiny-note {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin-top: 5px;
}
.warning-card {
  border-color: rgba(255,211,90,.28) !important;
  background: linear-gradient(135deg, rgba(255,211,90,.08), rgba(255,94,168,.05)) !important;
}
.transport .btn.secondary:nth-of-type(4) {
  border-color: rgba(255,211,90,.45);
}

/* Phase 8 additions */
.event-ledger-panel { border-color: rgba(255,211,90,.16); }
.event-ledger {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 8px;
  margin-top: 10px;
}
.ledger-row {
  border: 1px solid rgba(111,255,233,.16);
  border-radius: 14px;
  padding: 9px;
  background: linear-gradient(135deg, rgba(5,21,38,.82), rgba(46,108,255,.08));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}
.ledger-row strong {
  display: block;
  color: var(--gold2);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.ledger-row span,
.ledger-row em {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  margin-top: 4px;
}
.ledger-row em { color: var(--cyan); font-style: normal; }
.muted-ledger { opacity: .55; }


/* Phase 7 additions */
.mixer-panel { border-color: rgba(72, 236, 255, .18); }
.lane-mixer { display: grid; gap: 10px; }
.mixer-row {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(130px, .7fr) auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 16px;
  background: rgba(6,18,34,.72);
}
.mixer-row strong { color: var(--cyan); display: block; }
.mixer-row small { display: block; color: var(--muted); line-height: 1.35; margin-top: 2px; }
.btn.mini { padding: 8px 10px; min-height: 34px; font-size: .78rem; }
.mini-slider { display: grid; gap: 4px; font-size: .78rem; color: var(--muted); }
.mini-slider input { width: 100%; }
@media (max-width: 760px) {
  .mixer-row { grid-template-columns: 1fr; }
}


.cue-intent-matrix { display: grid; gap: 8px; }
.cue-focus-card {
  border: 1px solid rgba(111,255,233,.16);
  border-radius: 16px;
  padding: 10px;
  background: linear-gradient(135deg, rgba(111,255,233,.08), rgba(255,211,90,.045));
}
.cue-focus-card h3 { font-size: 13px; margin-bottom: 6px; }
.cue-focus-card p, .cue-focus-card small { color: var(--muted); font-size: 12px; line-height: 1.35; }
.cue-matrix-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.cue-matrix-grid span {
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 7px 8px;
  color: var(--muted);
  background: rgba(255,255,255,.035);
  font-size: 11px;
  font-weight: 900;
}
.cue-matrix-grid span.active { color: #05131c; border-color: #b9fff8; background: linear-gradient(180deg, #a9fff7, #35d0cd); }


/* Phase 8 additions */
.motif-cell-panel { grid-column: 1 / -1; border-color: rgba(255, 211, 90, .2); }
.motif-cell-matrix { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 8px; margin-top: 10px; }
.motif-cell {
  border: 1px solid rgba(111,255,233,.16);
  border-radius: 15px;
  padding: 10px;
  background: linear-gradient(135deg, rgba(111,255,233,.07), rgba(255,211,90,.045));
}
.motif-cell strong { display: block; color: var(--gold2); font-size: 12px; letter-spacing: .02em; }
.motif-cell span, .motif-cell em { display: block; color: var(--muted); font-size: 11px; line-height: 1.35; margin-top: 5px; }
.motif-cell em { color: var(--cyan); font-style: normal; }
.style-library-panel { display: grid; gap: 7px; }
.style-lib-subhead { color: var(--gold2); font-size: 10px; text-transform: uppercase; letter-spacing: .12em; font-weight: 950; margin-top: 4px; }
.style-lib-row {
  border: 1px solid rgba(111,255,233,.14);
  border-radius: 14px;
  padding: 9px;
  background: rgba(255,255,255,.035);
}
.style-lib-row.protected { border-color: rgba(255,211,90,.18); background: linear-gradient(135deg, rgba(255,211,90,.06), rgba(111,255,233,.03)); }
.style-lib-row strong { display: block; color: var(--cyan); font-size: 12px; }
.style-lib-row span, .style-lib-row em { display: block; color: var(--muted); font-size: 11px; line-height: 1.35; margin-top: 4px; }
.style-lib-row em { color: #c8dcf4; font-style: normal; }
.library-import-label textarea {
  width: 100%;
  min-height: 104px;
  resize: vertical;
  border-radius: 14px;
  border: 1px solid rgba(111,255,233,.22);
  background: #071326;
  color: var(--text);
  padding: 10px;
  font: 12px/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.library-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.library-actions .btn { min-height: 34px; }
@media (max-width: 760px) { .library-actions { grid-template-columns: 1fr; } }
