:root {
  --bg: #0b0912; --bg2: #12101c; --panel: #17142a; --line: #2c2742; --fg: #efeaf8; --muted: #a39cb8;
  --lav: #b9a7ff; --lav2: #8f7cf0; --ice: #8fd3ff; --amber: #f2a65a; --ok: #6fd6a0; --warn: #f2c35a; --bad: #ff7a8a;
  --r: 12px; --font: "Segoe UI Variable", "Segoe UI", system-ui, -apple-system, sans-serif; --mono: "Cascadia Code", Consolas, monospace;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); font: 15px/1.5 var(--font); }
body { min-height: 100vh; background: radial-gradient(1200px 600px at 80% -10%, #2a1f55 0%, transparent 60%), radial-gradient(900px 500px at -10% 110%, #0f2a3d 0%, transparent 60%), var(--bg); }
h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: .01em; }
h1 { font-size: 1.15rem; } h2 { font-size: 1.25rem; margin-bottom: .6rem; } h3 { font-size: 1rem; margin: 1.4rem 0 .5rem; color: var(--lav); }
p { margin: .3rem 0; }
.muted { color: var(--muted); } .small { font-size: .85rem; } .note { color: var(--muted); font-size: .88rem; margin: .5rem 0; }
button, select, input, textarea { font: inherit; color: var(--fg); }
button { background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: .45rem .9rem; cursor: pointer; }
button:hover { border-color: var(--lav2); } button:disabled { opacity: .5; cursor: wait; }
button.primary { background: linear-gradient(135deg, var(--lav2), #5b4bd1); border-color: transparent; font-weight: 600; }
select, input[type=text], input:not([type]), textarea { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .7rem; }
textarea { width: 100%; resize: vertical; }
input[type=range] { width: 100%; accent-color: var(--lav); }
.row { display: flex; gap: .6rem; align-items: center; margin: .5rem 0; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1; min-width: 0; }
.opts label { display: flex; flex-direction: column; gap: .2rem; font-size: .85rem; color: var(--muted); }
.hint { color: var(--lav); }

.top { position: sticky; top: 0; z-index: 5; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding: .7rem max(16px, env(safe-area-inset-left)); padding-top: max(.7rem, env(safe-area-inset-top)); background: rgba(11, 9, 18, .82); backdrop-filter: blur(12px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; gap: .7rem; align-items: center; } .brand p { margin: 0; font-size: .8rem; color: var(--muted); }
.sigil { width: 26px; height: 26px; border-radius: 50%; background: radial-gradient(circle at 50% 40%, #fff 0 8%, var(--ice) 14%, var(--lav2) 45%, transparent 70%); box-shadow: 0 0 18px #8f7cf088; flex: none; }
.sigil.big { width: 40px; height: 40px; }
.tabs { display: flex; gap: .3rem; } .tabs button { border-radius: 999px; } .tabs button[aria-selected=true] { background: var(--panel); border-color: var(--lav2); color: #fff; }

.layout { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 1rem; padding: 1rem max(16px, env(safe-area-inset-left)); max-width: 1400px; margin: 0 auto; }
.panel { background: rgba(23, 20, 42, .72); border: 1px solid var(--line); border-radius: var(--r); padding: 1.1rem; }
.lila { position: sticky; top: 76px; height: calc(100vh - 92px); display: flex; flex-direction: column; background: rgba(23, 20, 42, .8); border: 1px solid var(--line); border-radius: var(--r); padding: .9rem; }
.lila-tab { display: none; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin: .7rem 0; } .chips button { padding: .3rem .7rem; font-size: .88rem; }
.chips.small button { font-size: .8rem; padding: .25rem .6rem; } .chips button.on { background: var(--panel); border-color: var(--lav); color: #fff; }
.chips button .star { color: var(--amber); }
.list { list-style: none; padding: 0; margin: 0; display: grid; gap: .4rem; }
.list li { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .55rem .75rem; cursor: pointer; display: flex; justify-content: space-between; gap: .6rem; }
.list li:hover { border-color: var(--lav2); } .list li .muted { font-size: .82rem; }
.empty { color: var(--muted); padding: 2rem; text-align: center; }

.song-head { display: flex; justify-content: space-between; gap: 1rem; align-items: start; }
.proof { font-size: .78rem; padding: .25rem .6rem; border-radius: 999px; border: 1px solid var(--line); white-space: nowrap; }
.proof.midi { color: var(--warn); border-color: #5b4a20; } .proof.flp { color: var(--ice); border-color: #24506b; } .proof.render { color: var(--ok); border-color: #22533d; }
.pills { display: flex; flex-wrap: wrap; gap: .35rem; margin: .5rem 0; } .pills span { font-size: .8rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: .15rem .6rem; }

.timeline { display: flex; height: 46px; border-radius: 8px; overflow: hidden; margin: 1rem 0 .5rem; border: 1px solid var(--line); }
.timeline div { display: flex; align-items: end; padding: 3px 5px; font-size: .7rem; color: #fff; overflow: hidden; white-space: nowrap; border-right: 1px solid #0b091288; position: relative; }
.timeline div small { position: absolute; top: 3px; left: 5px; opacity: .75; }
.player { display: flex; gap: .8rem; align-items: center; flex-wrap: wrap; margin: .5rem 0; }
canvas#lanes { width: 100%; height: 260px; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; display: block; }
.fl-box { margin-top: 1rem; padding: .8rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); }
.fl-box audio { width: 100%; margin-top: .5rem; }
.downloads { display: flex; flex-wrap: wrap; gap: .4rem; } .downloads a { color: var(--fg); text-decoration: none; font-size: .85rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 999px; padding: .3rem .75rem; }
.downloads a:hover { border-color: var(--lav2); }
.versions li { display: block; } .versions li.current { border-color: var(--lav2); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 10px; }
table { border-collapse: collapse; width: 100%; font-size: .84rem; } th, td { text-align: left; padding: .45rem .55rem; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; background: var(--bg2); } td select { max-width: 220px; font-size: .8rem; padding: .25rem; }
td .sub { color: var(--muted); font-size: .76rem; } .tag { font-size: .7rem; padding: .05rem .45rem; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.tag.proven { color: var(--ok); border-color: #22533d; }
.mix-details { margin-top: .7rem; } .mix-details summary { cursor: pointer; color: var(--lav); }
#bp-mix ul, #t-result ul { margin: .3rem 0; padding-left: 1.1rem; } #bp-mix li, #t-result li { margin: .15rem 0; font-size: .86rem; }

.lila-head { display: flex; gap: .7rem; align-items: center; } .lila-head > div { flex: 1; } .lila-head p { margin: 0; }
.voice-toggle { display: flex; gap: .3rem; align-items: center; color: var(--muted); }
.chat { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: .55rem; padding: .7rem 0; }
.msg { max-width: 92%; padding: .55rem .75rem; border-radius: 14px; white-space: pre-wrap; word-wrap: break-word; }
.msg.you { align-self: end; background: #2a2450; border-bottom-right-radius: 4px; }
.msg.her { align-self: start; background: var(--bg2); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg .report { display: block; margin-top: .35rem; color: var(--ice); font-size: .82rem; }
.msg.thinking { color: var(--muted); font-style: italic; }
.chat-form { border-top: 1px solid var(--line); padding-top: .6rem; } .chat-form select { font-size: .8rem; max-width: 60%; }

.lila-portrait { width: 64px; height: 64px; border-radius: 50%; object-fit: cover; object-position: center; flex: none;
  box-shadow: 0 0 0 2px #8f7cf066, 0 0 22px #8fd3ff55; }
.msg-row { display: flex; gap: .45rem; align-items: flex-end; align-self: start; max-width: 96%; }
.msg-row img { width: 28px; height: 28px; border-radius: 50%; object-fit: cover; flex: none; box-shadow: 0 0 10px #8f7cf055; }
.msg-row .msg { max-width: 100%; }
.stars { display: flex; gap: .15rem; } .stars button { border: none; background: none; font-size: 1.5rem; color: #4a4466; padding: 0 .1rem; }
.stars button.on { color: var(--amber); }
.msg .kept { display: block; margin-top: .3rem; color: var(--lav); font-size: .78rem; }
.mem-kind { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--lav); margin-right: .4rem; }
.taste-card { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .8rem; margin: .4rem 0; font-size: .88rem; }
@media (max-width: 960px) {
  .layout { grid-template-columns: minmax(0, 1fr); } /* plain 1fr let the wide instrument table stretch the page on phones */
  .lila { position: static; height: auto; min-height: 70vh; display: none; }
  .lila.show { display: flex; }
  .lila-tab { display: inline-block; }
  .work.hide { display: none; }
}
@media (max-width: 520px) {
  .tabs { width: 100%; } .tabs button { flex: 1; padding: .4rem .3rem; font-size: .85rem; }
  .row.opts { flex-direction: column; align-items: stretch; }
  .song-head { flex-direction: column; }
}

/* Parts strip: solo / mute for listening, edit notes and remove for the song */
button.ghost { background: transparent; }
button.sm { padding: .2rem .6rem; font-size: .8rem; }
.parts { display: grid; gap: .35rem; }
.part { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto auto auto; gap: .4rem; align-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .35rem .55rem; }
.part-name { font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.part button.solo.on { background: #3a3110; border-color: var(--warn); color: var(--warn); }
.part button.mute.on { background: #3a1820; border-color: var(--bad); color: var(--bad); }
.part.removed { opacity: .7; grid-template-columns: minmax(0, 1fr) auto auto; }
@media (max-width: 560px) {
  .part { display: flex; flex-wrap: wrap; }
  .part .part-name { flex: 1 1 100%; }
  .part .muted.small { flex: 1 1 auto; align-self: center; }
  .part button.sm { padding: .35rem .75rem; }
}

/* Structure editor */
.structure { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .7rem; margin: .4rem 0 .8rem; }
.structure-list { list-style: none; padding: 0; margin: .4rem 0; display: grid; gap: .3rem; counter-reset: sec; }
.structure-list li { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; counter-increment: sec; }
.structure-list li::before { content: counter(sec); width: 1.4rem; color: var(--muted); font-size: .8rem; text-align: right; }
.structure-list select { padding: .3rem .5rem; }

/* Piano-roll editor */
.pr-overlay { position: fixed; inset: 0; z-index: 50; background: rgba(5, 4, 10, .82); display: flex; padding: max(10px, env(safe-area-inset-top)) 10px 10px; }
.pr-box { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; }
.pr-bar { display: flex; flex-wrap: wrap; gap: .4rem; align-items: center; padding: .5rem .7rem; border-bottom: 1px solid var(--line); }
.pr-bar label { display: flex; gap: .3rem; align-items: center; color: var(--muted); }
.pr-bar select { padding: .25rem .4rem; }
.pr-bar button { padding: .3rem .7rem; font-size: .85rem; }
.pr-vel-wrap input { width: 110px; }
.pr-help { padding: .3rem .7rem; }
.pr-main { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.pr-keys { flex: none; width: 74px; display: block; }
.pr-main { position: relative; }
.pr-main > .pr-keys { position: relative; z-index: 1; }
.pr-scroll { flex: 1; min-width: 0; overflow: auto; touch-action: none; }
.pr-grid { display: block; touch-action: none; }
