/* KF Music Studio — UI v2 (original design: "studio console" — slate + teal/amber, rounded panels)
 * © Kyle Fegan. All rights reserved. */
:root {
  --bg: #0c1014; --bg1: #121820; --bg2: #18202a; --bg3: #212b37; --line: #2a3644; --line2: #364456;
  --text: #e8eef5; --muted: #8ea0b4; --dim: #5d6f83;
  --accent: #14b8a6; --accent2: #f59e0b; --danger: #ef4444; --ok: #4ade80; --warn: #fbbf24;
  --grad: linear-gradient(135deg, var(--accent), var(--accent2));
  --radius: 14px; --side: 232px; --player: 76px; --tabs: 0px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); } .dim { opacity: .55; } .small-text { font-size: .82rem; } .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }
.error { color: #fca5a5; margin: .4rem 0; } .error:empty { display: none; }
.hint { color: var(--dim); font-size: .8rem; margin: .3rem 0; } .center { text-align: center; }
.note { background: var(--bg2); border-left: 3px solid var(--accent2); padding: .55rem .75rem; border-radius: 8px; color: var(--muted); }
h1 { font-size: 1.45rem; margin: 0 0 .9rem; letter-spacing: -.01em; } h2 { font-size: 1.1rem; margin: 0 0 .7rem; } h3 { font-size: .95rem; margin: 0 0 .5rem; }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: var(--side) 1fr; height: 100vh; height: 100dvh; padding-bottom: var(--player); }
.side { background: var(--bg1); border-right: 1px solid var(--line); display: flex; flex-direction: column; padding: 1rem .75rem; gap: .25rem; overflow-y: auto; }
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.05rem; padding: .3rem .5rem 1rem; }
.logo { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--grad); color: #0b1110; font-weight: 900; }
.nav-btn { display: flex; align-items: center; gap: .7rem; width: 100%; padding: .6rem .7rem; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.nav-btn svg { width: 20px; height: 20px; flex: none; }
.nav-btn:hover { background: var(--bg2); color: var(--text); }
.nav-btn.active { background: var(--bg3); color: var(--text); box-shadow: inset 3px 0 0 var(--accent); }
.side-foot { margin-top: auto; padding: .6rem .5rem 0; font-size: .75rem; color: var(--dim); }
.badge { display: inline-block; font-size: .72rem; padding: .12rem .5rem; border-radius: 99px; background: #3b2a08; color: var(--warn); border: 1px solid #5c4210; }
.main { overflow-y: auto; padding: 1.4rem 1.6rem 2rem; }
.view { max-width: 1180px; margin: 0 auto; }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; margin-bottom: 1rem; flex-wrap: wrap; }
.view-head h1 { margin: 0; }
.panel { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius); padding: 1.1rem 1.2rem; margin-bottom: 1rem; }
.cols { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; gap: 1rem; align-items: start; }

/* ---------- controls ---------- */
.field { margin-bottom: .85rem; } .field > label, .label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .3rem; color: #c9d5e2; }
input[type=text], input[type=password], input[type=number], input[type=file], textarea, select {
  width: 100%; background: var(--bg2); color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: .6rem .7rem; font: inherit; }
textarea { resize: vertical; min-height: 4.5rem; }
input:focus, textarea:focus, select:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.invalid { border-color: var(--danger) !important; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: .7rem; }
.btn-primary, .btn-ghost, .btn-danger { display: inline-flex; align-items: center; justify-content: center; gap: .4rem; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; padding: .6rem 1rem; text-decoration: none; border: 1px solid transparent; }
.btn-primary { background: var(--grad); color: #071312; }
.btn-primary:disabled, .btn-ghost:disabled { opacity: .5; cursor: default; }
.btn-ghost { background: var(--bg2); color: var(--text); border-color: var(--line); }
.btn-ghost:hover { border-color: var(--line2); background: var(--bg3); }
.btn-danger { background: transparent; color: #fca5a5; border-color: #5b2424; }
.btn-primary.big { width: 100%; padding: .85rem; font-size: 1.02rem; }
.small, .small-btn { padding: .35rem .65rem; font-size: .82rem; border-radius: 8px; }
.seg { display: inline-flex; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 600; padding: .35rem .8rem; border-radius: 8px; cursor: pointer; }
.seg button.active { background: var(--bg3); color: var(--text); box-shadow: 0 0 0 1px var(--line2); }
.switch { display: flex; align-items: center; gap: .55rem; cursor: pointer; margin: .4rem 0; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch .slider { width: 38px; height: 22px; border-radius: 99px; background: var(--bg3); border: 1px solid var(--line2); position: relative; flex: none; transition: background .15s; }
.switch .slider::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.switch input:checked + .slider { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .slider::after { transform: translateX(16px); background: #fff; }
.switch input:focus-visible + .slider { outline: 2px solid var(--accent); }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .6rem; }
.chip { font-size: .8rem; padding: .22rem .65rem; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); color: var(--text); font-family: inherit; }
button.chip { cursor: pointer; } button.chip.on { background: color-mix(in srgb, var(--accent) 22%, var(--bg2)); border-color: var(--accent); }
.chip .x { margin-left: .3rem; color: var(--muted); cursor: pointer; border: 0; background: none; font: inherit; padding: 0; }
.tag-input { display: flex; flex-wrap: wrap; gap: .35rem; align-items: center; background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .35rem .45rem; }
.tag-input input { flex: 1; min-width: 8rem; border: 0; background: transparent; padding: .25rem; }
.tag-input input:focus { outline: none; }
.pill { font-size: .72rem; font-weight: 700; padding: .12rem .5rem; border-radius: 99px; background: var(--bg3); color: var(--muted); text-transform: capitalize; white-space: nowrap; }
.pill.complete { color: var(--ok); } .pill.failed { color: #fca5a5; } .pill.processing, .pill.running, .pill.queued, .pill.claimed { color: var(--warn); }
.progress { height: 6px; border-radius: 99px; background: var(--bg3); overflow: hidden; margin-top: .45rem; }
.progress .bar { height: 100%; width: 0; background: var(--grad); transition: width .4s; }

/* ---------- library ---------- */
.lib-tools { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.lib-tools input { width: 14rem; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(188px, 1fr)); gap: 1rem; }
.grid.list { grid-template-columns: 1fr; gap: .45rem; }
.card { background: var(--bg1); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; cursor: pointer; position: relative; transition: transform .12s, border-color .12s; }
.card:hover { border-color: var(--line2); transform: translateY(-2px); }
.card .art { aspect-ratio: 1; position: relative; }
.card .art canvas, .art-img { width: 100%; height: 100%; display: block; }
.card .play-over { position: absolute; right: .6rem; bottom: .6rem; width: 42px; height: 42px; border-radius: 50%; border: 0; background: rgba(8, 12, 16, .78); color: #fff; cursor: pointer; display: grid; place-items: center; opacity: 0; transition: opacity .12s; }
.card:hover .play-over, .card .play-over:focus-visible, .card.playing .play-over { opacity: 1; }
.card .info { padding: .6rem .75rem .75rem; }
.card .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .m { font-size: .78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: .4rem; margin-top: .3rem; }
.card .ver { position: absolute; left: .55rem; top: .55rem; font-size: .7rem; font-weight: 800; background: rgba(8, 12, 16, .8); padding: .1rem .45rem; border-radius: 6px; }
.card .busy { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(8, 12, 16, .55); font-weight: 700; }
.grid.list .card { display: grid; grid-template-columns: 56px 1fr; align-items: center; }
.grid.list .card .art { width: 56px; height: 56px; } .grid.list .card .play-over { display: none; } .grid.list .card .ver { display: none; }
.grid.list .card .info { padding: .4rem .8rem; }
.empty { text-align: center; padding: 3rem 1rem; color: var(--muted); border: 1px dashed var(--line2); border-radius: var(--radius); }

/* ---------- song detail ---------- */
.song-hero { display: grid; grid-template-columns: 240px 1fr; gap: 1.3rem; align-items: end; margin-bottom: 1rem; }
.song-hero .art { width: 240px; height: 240px; border-radius: var(--radius); overflow: hidden; box-shadow: 0 18px 40px rgba(0,0,0,.45); }
.song-hero h1 { font-size: 2rem; margin: .2rem 0 .4rem; word-break: break-word; }
.hero-actions { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .8rem; }
.round-play { width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--grad); color: #071312; cursor: pointer; display: grid; place-items: center; }
.detail-cols { display: grid; grid-template-columns: 1fr 360px; gap: 1rem; align-items: start; }
.lyrics { white-space: pre-wrap; font-size: .95rem; line-height: 1.7; color: #d5dfea; margin: 0; max-height: 60vh; overflow: auto; }
.lyrics .sec { color: var(--accent2); font-weight: 700; }
.act-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: .45rem; }
.act-grid .btn-ghost { justify-content: flex-start; }
.dl-list { display: grid; gap: .35rem; }
.dl-list a, .dl-list .row { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem .6rem; background: var(--bg2); border: 1px solid var(--line); border-radius: 9px; color: var(--text); text-decoration: none; font-size: .88rem; }
.dl-list a:hover { border-color: var(--line2); }
.job-line { display: flex; align-items: center; justify-content: space-between; gap: .5rem; padding: .45rem 0; border-top: 1px solid var(--line); font-size: .86rem; }
.job-line:first-child { border-top: 0; }
.rights { font-size: .78rem; color: var(--dim); margin-top: .6rem; }

/* ---------- key & pitch ---------- */
.kp-row { display: flex; align-items: center; gap: .6rem; flex-wrap: wrap; }
.kp-key { font-size: 1.6rem; font-weight: 800; min-width: 7.5rem; }
.kp-step { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font-size: 1.2rem; cursor: pointer; }
.kp-semi { font-variant-numeric: tabular-nums; min-width: 3.5rem; text-align: center; font-weight: 700; }
.kp-warn { background: #2a2110; border: 1px solid #5c4210; color: #fde68a; padding: .55rem .7rem; border-radius: 10px; font-size: .85rem; margin: .6rem 0; }
.voice-pick { display: grid; gap: .4rem; margin: .5rem 0; }
.voice-opt { display: grid; grid-template-columns: auto 1fr auto; gap: .6rem; align-items: center; padding: .5rem .6rem; border: 1px solid var(--line); border-radius: 10px; background: var(--bg2); cursor: pointer; }
.voice-opt.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.voice-opt .fit { font-size: .75rem; font-weight: 700; }
.fit.good { color: var(--ok); } .fit.ok { color: var(--warn); } .fit.poor { color: #fca5a5; }

/* ---------- create ---------- */
.mode-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: .9rem; }
.count { float: right; font-weight: 400; color: var(--dim); font-size: .78rem; }
.lyrics-tools { display: flex; gap: .5rem; align-items: center; margin-top: .35rem; flex-wrap: wrap; }
.status-card { display: flex; gap: .8rem; align-items: center; }
.spinner { width: 22px; height: 22px; border-radius: 50%; border: 3px solid var(--bg3); border-top-color: var(--accent); animation: spin 1s linear infinite; flex: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- player bar ---------- */
.player { position: fixed; left: 0; right: 0; bottom: var(--tabs); height: var(--player); background: rgba(14, 19, 25, .97); border-top: 1px solid var(--line); display: grid; grid-template-columns: minmax(180px, 290px) 1fr minmax(140px, 260px); gap: 1rem; align-items: center; padding: 0 1rem; z-index: 20; backdrop-filter: blur(8px); }
.player .now { display: flex; align-items: center; gap: .65rem; min-width: 0; cursor: pointer; }
.player .now .art { width: 48px; height: 48px; border-radius: 8px; overflow: hidden; flex: none; background: var(--bg3); }
.player .now .t { font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .now .m { font-size: .76rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.player .mid { display: grid; grid-template-columns: auto 1fr; gap: .8rem; align-items: center; min-width: 0; }
.player .ctl { display: flex; align-items: center; gap: .35rem; }
.icon-btn { width: 36px; height: 36px; border-radius: 50%; border: 0; background: transparent; color: var(--text); cursor: pointer; display: grid; place-items: center; }
.icon-btn:hover { background: var(--bg3); } .icon-btn svg { width: 20px; height: 20px; }
.icon-btn.main-play { width: 42px; height: 42px; background: var(--text); color: #0b1014; }
.wave-wrap { position: relative; display: grid; grid-template-columns: auto 1fr auto; gap: .55rem; align-items: center; min-width: 0; }
.wave { width: 100%; height: 40px; cursor: pointer; display: block; }
.player .right { display: flex; align-items: center; gap: .4rem; justify-content: flex-end; }
.player .right input[type=range] { width: 100px; }
.queue-pop { position: fixed; right: 1rem; bottom: calc(var(--player) + var(--tabs) + .5rem); width: min(360px, calc(100vw - 2rem)); max-height: 50vh; overflow: auto; background: var(--bg1); border: 1px solid var(--line2); border-radius: var(--radius); padding: .6rem; z-index: 30; box-shadow: 0 16px 40px rgba(0,0,0,.5); }
.queue-pop .q { display: flex; justify-content: space-between; gap: .5rem; padding: .45rem .5rem; border-radius: 8px; cursor: pointer; font-size: .88rem; }
.queue-pop .q.cur { background: var(--bg3); } .queue-pop .q:hover { background: var(--bg2); }

/* ---------- voices ---------- */
.steps { display: grid; gap: .35rem; }
.step { display: grid; grid-template-columns: 24px 1fr auto; gap: .6rem; align-items: center; padding: .45rem .6rem; border-radius: 9px; background: var(--bg2); border: 1px solid var(--line); font-size: .88rem; cursor: pointer; }
.step.cur { border-color: var(--accent); } .step.done .dot { background: var(--ok); } .step.bad .dot { background: var(--warn); }
.step .dot { width: 12px; height: 12px; border-radius: 50%; background: var(--bg3); border: 1px solid var(--line2); }
.rec-box { text-align: center; padding: 1rem; }
.rec-prompt { font-size: 1.15rem; font-weight: 700; margin: .3rem 0 .8rem; }
.rec-lyric { font-size: 1rem; color: #d5dfea; background: var(--bg2); border-radius: 10px; padding: .6rem; margin: 0 auto .8rem; max-width: 34rem; white-space: pre-wrap; }
.rec-btn { width: 84px; height: 84px; border-radius: 50%; border: 4px solid var(--bg3); background: var(--danger); color: #fff; font-weight: 800; cursor: pointer; }
.rec-btn.on { animation: pulse 1.2s infinite; background: #b91c1c; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, .18); } }
.meter { height: 14px; border-radius: 99px; background: var(--bg3); overflow: hidden; margin: .8rem auto; max-width: 30rem; position: relative; }
.meter .lvl { height: 100%; width: 0; background: linear-gradient(90deg, var(--ok), var(--warn) 75%, var(--danger)); transition: width .05s; }
.meter .peak { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; left: 0; }
.checks { display: flex; flex-wrap: wrap; gap: .4rem; justify-content: center; margin: .6rem 0; }
.check { font-size: .78rem; padding: .2rem .55rem; border-radius: 99px; border: 1px solid var(--line); }
.check.pass { color: var(--ok); border-color: #1f4d33; } .check.fail { color: #fca5a5; border-color: #5b2424; } .check.warn { color: var(--warn); border-color: #5c4210; }
.voice-card { display: grid; grid-template-columns: 52px 1fr auto; gap: .8rem; align-items: center; }
.voice-card .av { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; font-weight: 800; background: var(--bg3); }
.consent-text { background: var(--bg2); border: 1px solid var(--line); border-radius: 10px; padding: .7rem .8rem; font-size: .92rem; line-height: 1.55; }

/* ---------- studio (kept from v1, restyled) ---------- */
.result-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .5rem; }
.track { background: var(--bg2); border: 1px solid var(--line); border-radius: 12px; padding: .7rem .8rem; }
.track.open { border-color: var(--accent); }
.track-head { display: flex; align-items: center; gap: .7rem; }
.track-head .cover { width: 38px; height: 38px; border-radius: 9px; display: grid; place-items: center; background: var(--bg3); flex: none; }
.track-info { flex: 1; min-width: 0; } .track-title { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } .track-meta { font-size: .8rem; }
.track-body { margin-top: .5rem; } .track-body:empty { display: none; }
.stems-row { display: flex; flex-wrap: wrap; gap: .4rem; margin-top: .4rem; } .stems-title { font-weight: 700; font-size: .85rem; }
.action-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: .45rem; margin: .7rem 0; }
.source-box { margin-top: 1rem; padding-top: 1rem; border-top: 1px solid var(--line); }
.section-head { display: flex; justify-content: space-between; align-items: flex-start; gap: .5rem; margin-bottom: .6rem; }
.studio-results h2 { margin: 0; }
.worker-status { margin: 1rem 0 0; padding: .5rem .7rem; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); }
.worker-status:empty { display: none; }
.worker-status.ok { color: #86efac; }
.worker-status.warn { color: #fcd34d; }
.queue-note { color: #fcd34d; font-size: .85rem; margin: 0; }
.studio-job.open { border-color: var(--accent); }
.studio-job .track-body p { margin: 0; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: .4rem; margin-bottom: .8rem; }
.chip { font-size: .8rem; padding: .2rem .6rem; border-radius: 99px; background: var(--bg2); border: 1px solid var(--line); }
.transport { display: flex; align-items: center; gap: .7rem; }
.transport input[type=range] { margin: 0; flex: 1; min-width: 0; }
.play-btn { width: 48px; height: 48px; border-radius: 50%; border: 0; background: var(--grad); color: #fff; font-size: 1.1rem; cursor: pointer; flex: none; }
.play-btn:disabled { opacity: .5; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; white-space: nowrap; }
.now-chord { display: flex; align-items: baseline; gap: .8rem; margin: .8rem 0 .3rem; }
#chordNow { font-size: 2rem; font-weight: 800; line-height: 1; background: var(--grad); -webkit-background-clip: text; background-clip: text; color: transparent; }
.chord-strip { display: flex; gap: 3px; overflow-x: auto; padding: .3rem 0 .6rem; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.chord { flex: none; padding: .45rem .3rem; border-radius: 8px; border: 1px solid var(--line); background: var(--bg2); color: var(--text); font: inherit; font-weight: 700; font-size: .85rem; cursor: pointer; }
.chord.nc { color: var(--muted); font-weight: 400; }
.chord.current { background: var(--accent); border-color: var(--accent); color: #fff; transform: scale(1.05); }
.section-list { display: flex; flex-wrap: wrap; gap: .35rem; margin: .4rem 0 .8rem; }
.section-btn { padding: .3rem .65rem; border-radius: 99px; border: 1px solid var(--line); background: transparent; color: var(--muted); font: inherit; font-size: .8rem; cursor: pointer; }
.section-btn.current { border-color: var(--accent2); color: #fff; background: rgba(245, 158, 11, .15); }
.mixer { display: grid; gap: .35rem; margin: .6rem 0 1rem; }
.mixer-head { display: flex; justify-content: space-between; align-items: center; }
.mix-row { display: grid; grid-template-columns: minmax(64px, 7rem) auto auto 1fr auto; align-items: center; gap: .4rem; padding: .35rem .5rem; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); }
.mix-row.silent .mix-label, .mix-row.silent .mix-vol { opacity: .4; }
.mix-label { font-weight: 600; font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mix-btn { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg3); color: var(--muted); font: inherit; font-weight: 700; cursor: pointer; }
.mix-btn.on { background: var(--accent); color: #fff; border-color: var(--accent); }
.mix-row .mix-btn:nth-child(3).on { background: #b91c1c; border-color: #b91c1c; }
.mix-vol { margin: 0 !important; min-width: 0; }
.mix-dl { justify-content: center; min-width: 34px; height: 34px; }
.downloads { margin-bottom: 1rem; }
.tab-box { margin-top: .5rem; }
.tab-text { margin: .4rem 0 0; padding: .8rem; background: #0a0e12; border: 1px solid var(--line); border-radius: 10px; overflow: auto; max-height: 60vh; font: 12px/1.35 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #d5dfea; white-space: pre; tab-size: 4; }
.center { text-align: center; }
.send-studio { justify-self: start; }
.midi-box { margin: .8rem 0; }
.midi-list { display: grid; gap: .35rem; margin: .4rem 0 .7rem; }
.midi-row { display: grid; grid-template-columns: minmax(64px, 7rem) 1fr auto; align-items: center; gap: .5rem; padding: .35rem .5rem; border-radius: 10px; background: var(--bg2); border: 1px solid var(--line); }
.midi-row.skipped { opacity: .55; }
.roll-head { display: flex; align-items: center; gap: .6rem; margin-bottom: .35rem; }
.roll-head select { max-width: 12rem; }
.roll-wrap { width: 100%; overflow: hidden; border-radius: 10px; border: 1px solid var(--line); background: #0a0e12; }
.roll-wrap canvas { display: block; }
.footer a { color: var(--muted); }
@media (max-width: 480px) {
  .mix-row { grid-template-columns: 1fr auto auto auto; }
  .mix-row .mix-vol { grid-column: 1 / -1; grid-row: 2; }
  .mix-label { grid-column: 1; }
  .tab-text { font-size: 10.5px; }
  .midi-row { grid-template-columns: 1fr auto; }
  .midi-row .muted { grid-column: 1 / -1; grid-row: 2; }
}
@media (min-width: 960px) {
  .studio-input { grid-column: 1; grid-row: 1; }
  .studio-jobs { grid-column: 2; grid-row: 1; }
  .studio-results { grid-column: 1 / -1; }
  .action-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 1rem; }
.login { width: min(380px, 100%); }
.footer-note { font-size: .75rem; color: var(--dim); text-align: center; padding: 1rem 0 0; }

/* ---------- mobile: sidebar -> bottom tabs ---------- */
@media (max-width: 860px) {
  :root { --tabs: 60px; --player: 64px; }
  .shell { grid-template-columns: 1fr; padding-bottom: calc(var(--player) + var(--tabs) + env(safe-area-inset-bottom)); }
  .side { position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabs) + env(safe-area-inset-bottom)); flex-direction: row; padding: 0 .3rem env(safe-area-inset-bottom); border-right: 0; border-top: 1px solid var(--line); z-index: 25; gap: 0; overflow: visible; }
  .side .brand, .side .side-foot { display: none; }
  .nav-btn { flex-direction: column; gap: .1rem; font-size: .66rem; padding: .45rem .1rem; justify-content: center; align-items: center; text-align: center; border-radius: 0; }
  .nav-btn.active { box-shadow: inset 0 2px 0 var(--accent); background: transparent; color: var(--accent); }
  .main { padding: 1rem .85rem 1.5rem; }
  .mobile-head { display: flex !important; }
  .cols, .detail-cols { grid-template-columns: 1fr; }
  .grid { grid-template-columns: repeat(2, 1fr); gap: .65rem; }
  .song-hero { grid-template-columns: 1fr; text-align: left; }
  .song-hero .art { width: 100%; height: auto; aspect-ratio: 1; max-width: 300px; margin: 0 auto; }
  .song-hero h1 { font-size: 1.5rem; }
  .player { grid-template-columns: 1fr auto; padding: 0 .6rem; gap: .5rem; bottom: calc(var(--tabs) + env(safe-area-inset-bottom)); }
  .player .mid { grid-template-columns: auto; } .player .wave-wrap, .player .right { display: none; }
  .player .ctl .opt { display: none; }
  .player .mini-progress { display: block !important; }
  .grid2 { grid-template-columns: 1fr; }
  .lib-tools input { width: 100%; }
  .mix-row { grid-template-columns: minmax(54px, 5rem) auto auto 1fr auto; }
}
.mobile-head { display: none; align-items: center; justify-content: space-between; margin-bottom: .8rem; }
.mini-progress { display: none; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--bg3); }
.mini-progress div { height: 100%; width: 0; background: var(--accent); }
.check-line { display: flex; gap: .5rem; align-items: flex-start; margin: .8rem 0; font-size: .9rem; line-height: 1.45; }
.check-line input { margin-top: .2rem; accent-color: var(--accent); }
.btn-ghost.danger { color: #fca5a5; border-color: #5b2424; }
.session { grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); align-items: start; }
.voice-opt .fit.good { color: var(--ok); } .voice-opt .fit.ok { color: var(--warn); } .voice-opt .fit.poor { color: #fca5a5; }
.kp details { margin: .6rem 0; } .kp summary { cursor: pointer; }
@media (max-width: 860px) { .session { grid-template-columns: 1fr; } }

/* Song controls (style / vocal gender / weirdness) */
.song-controls { margin-top: .9rem; }
.chips.style-row { flex-wrap: nowrap; overflow-x: auto; padding-bottom: .35rem; margin-bottom: .5rem; scrollbar-width: thin; -webkit-overflow-scrolling: touch; }
.chips.style-row .chip { flex: 0 0 auto; }
.chips.style-row { -webkit-mask-image: linear-gradient(90deg, #000 88%, transparent); mask-image: linear-gradient(90deg, #000 88%, transparent); }
.chips.style-row .chip.auto { border-style: dashed; }
.seg.seg-full { display: flex; width: 100%; }
.seg.seg-full button { flex: 1 1 auto; min-width: 0; padding: .4rem .5rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seg.seg-full button.active { color: var(--accent); }
.seg.disabled { opacity: .45; pointer-events: none; }
.range-scale { display: flex; justify-content: space-between; font-size: .72rem; color: var(--dim); margin-top: .1rem; }
#weirdOut { color: var(--accent2, #f59e0b); font-weight: 700; }
/* Stacked: the Create panel is narrow on desktop too. min-width:0 stops the scrolling chip row widening its column. */
.grid2.ctl-row { grid-template-columns: 1fr; gap: 0; }
.cols > *, .panel, .song-controls, .song-controls .field { min-width: 0; }
.song-settings { display: grid; grid-template-columns: auto 1fr; gap: .2rem .8rem; margin: .2rem 0 .8rem; font-size: .85rem; }
.song-settings dt { color: var(--dim); } .song-settings dd { margin: 0; color: var(--text); min-width: 0; overflow-wrap: anywhere; }
.weird-meter { display: flex; align-items: center; gap: .5rem; }
.weird-meter .wm { position: relative; flex: 0 0 70px; height: 6px; border-radius: 99px; background: var(--bg3, #1f2937); overflow: hidden; }
.weird-meter .wm::after { content: ''; position: absolute; inset: 0 auto 0 0; width: var(--w); background: var(--grad); }
