/* YuE2 Studio. Design tokens first; every colour below reads from them, so light and dark share one set of rules. */
:root {
  --bg: #f8f8f9;
  --surface: #ffffff;
  --surface-2: #f3f3f5;
  --surface-3: #eaeaee;
  --hover: rgba(24, 24, 32, .05);
  --active: rgba(24, 24, 32, .08);
  --border: #e6e6ea;
  --border-strong: #d6d6dc;
  --text: #17171c;
  --text-2: #55555f;
  --text-3: #8a8a94;
  --accent: #5b55e6;
  --accent-hover: #4b45d4;
  --accent-soft: #efeefe;
  --accent-text: #4a43cf;
  --on-accent: #ffffff;
  --ok: #18884a;  --ok-soft: #e8f6ee;
  --warn: #a35a00; --warn-soft: #fdf3e2;
  --bad: #d4342c;  --bad-soft: #fdecea;
  --wave-played: var(--accent);
  --wave-rest: #d4d4dc;
  --sheet: #ffffff;
  --ink-on-sheet: #1c1c22;
  --shadow-sm: 0 1px 2px rgba(16, 16, 24, .06);
  --shadow-md: 0 1px 2px rgba(16, 16, 24, .04), 0 4px 16px -4px rgba(16, 16, 24, .08);
  --shadow-lg: 0 2px 6px rgba(16, 16, 24, .05), 0 16px 40px -12px rgba(16, 16, 24, .18);
  --ring: 0 0 0 3px color-mix(in srgb, var(--accent) 22%, transparent);
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  --ui: "Geist", ui-sans-serif, system-ui, -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, monospace;
  --col: 760px;
  --left: 260px;
  --right: 320px;
  color-scheme: light;
}
:root[data-theme="dark"] {
  --bg: #0f0f12; --surface: #18181c; --surface-2: #131316; --surface-3: #222228;
  --hover: rgba(255, 255, 255, .05); --active: rgba(255, 255, 255, .08);
  --border: #26262d; --border-strong: #35353e;
  --text: #ececf1; --text-2: #a4a4ae; --text-3: #73737e;
  --accent: #7d78ff; --accent-hover: #918dff; --accent-soft: rgba(125, 120, 255, .14); --accent-text: #aeabff; --on-accent: #ffffff;
  --ok: #4cc27f; --ok-soft: rgba(76, 194, 127, .12); --warn: #e7a744; --warn-soft: rgba(231, 167, 68, .12); --bad: #ff6b62; --bad-soft: rgba(255, 107, 98, .12);
  --wave-rest: #3a3a44;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px -6px rgba(0, 0, 0, .5);
  --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 20px 48px -12px rgba(0, 0, 0, .7);
  color-scheme: dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f0f12; --surface: #18181c; --surface-2: #131316; --surface-3: #222228;
    --hover: rgba(255, 255, 255, .05); --active: rgba(255, 255, 255, .08);
    --border: #26262d; --border-strong: #35353e;
    --text: #ececf1; --text-2: #a4a4ae; --text-3: #73737e;
    --accent: #7d78ff; --accent-hover: #918dff; --accent-soft: rgba(125, 120, 255, .14); --accent-text: #aeabff; --on-accent: #ffffff;
    --ok: #4cc27f; --ok-soft: rgba(76, 194, 127, .12); --warn: #e7a744; --warn-soft: rgba(231, 167, 68, .12); --bad: #ff6b62; --bad-soft: rgba(255, 107, 98, .12);
    --wave-rest: #3a3a44;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .4); --shadow-md: 0 1px 2px rgba(0, 0, 0, .3), 0 6px 20px -6px rgba(0, 0, 0, .5);
    --shadow-lg: 0 2px 6px rgba(0, 0, 0, .3), 0 20px 48px -12px rgba(0, 0, 0, .7);
    color-scheme: dark;
  }
}

/* ------------------------------------------------------------------ base */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; }
body { background: var(--bg); color: var(--text); font: 14px/1.55 var(--ui); -webkit-font-smoothing: antialiased; font-feature-settings: "ss01", "cv11"; }
button, input, textarea { font: inherit; color: inherit; }
p { margin: 0; }
a { color: var(--accent-text); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { background: color-mix(in srgb, var(--accent) 25%, transparent); }
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
kbd { font: 500 11px var(--mono); padding: 1px 5px; border-radius: 4px; border: 1px solid var(--border); background: var(--surface-2); color: var(--text-2); }
* { scrollbar-width: thin; scrollbar-color: var(--border-strong) transparent; }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px; height: 32px; padding: 0 12px;
  border-radius: var(--r-sm); border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font-size: 13px; font-weight: 500; line-height: 1; cursor: pointer; white-space: nowrap; text-decoration: none;
  box-shadow: var(--shadow-sm); transition: background .12s, border-color .12s, color .12s;
}
.btn:hover { background: var(--surface-2); border-color: var(--border-strong); }
.btn:active { background: var(--surface-3); }
.btn[disabled] { opacity: .5; cursor: default; }
.btn-primary { background: var(--accent); border-color: transparent; color: var(--on-accent); box-shadow: 0 1px 2px rgba(40, 30, 160, .25), inset 0 1px 0 rgba(255, 255, 255, .14); }
.btn-primary:hover { background: var(--accent-hover); border-color: transparent; }
.btn-primary:active { background: var(--accent-hover); }
.btn-ghost { background: transparent; border-color: transparent; box-shadow: none; color: var(--text-2); }
.btn-ghost:hover { background: var(--hover); border-color: transparent; color: var(--text); }
.btn-sm { height: 28px; padding: 0 9px; font-size: 12.5px; gap: 6px; }
.btn-sm .i { width: 14px; height: 14px; }
.btn-block { width: 100%; }
.btn.is-on { color: var(--ok); border-color: color-mix(in srgb, var(--ok) 35%, var(--border)); background: var(--ok-soft); }
.icon-btn {
  display: inline-grid; place-items: center; width: 32px; height: 32px; border: 0; border-radius: var(--r-sm);
  background: none; color: var(--text-3); cursor: pointer; flex: none; transition: background .12s, color .12s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.danger:hover { color: var(--bad); background: var(--bad-soft); }
.badge { display: inline-block; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: var(--on-accent); font: 600 11px/18px var(--ui); text-align: center; }
.spin { width: 13px; height: 13px; border-radius: 50%; border: 2px solid currentColor; border-right-color: transparent; animation: rot .8s linear infinite; display: inline-block; flex: none; }
@keyframes rot { to { transform: rotate(360deg); } }

/* ------------------------------------------------------------------ layout */
.app { display: grid; grid-template-columns: var(--left) minmax(0, 1fr) var(--right); height: 100vh; height: 100dvh; transition: grid-template-columns .22s ease; }
.app.drafts-folded { grid-template-columns: var(--left) minmax(0, 1fr) 44px; }

/* ------------------------------------------------------------------ left sidebar */
.sidebar { background: var(--surface-2); border-right: 1px solid var(--border); display: flex; flex-direction: column; gap: 10px; min-height: 0; padding: 14px 12px 12px; }
.brand { display: flex; align-items: center; gap: 10px; padding: 2px 4px 6px; }
.logo { width: 28px; height: 28px; border-radius: 8px; display: grid; place-items: center; color: #fff; background: linear-gradient(135deg, #7d78ff, #4b45d4 60%, #2f2aa8); box-shadow: 0 2px 6px -1px rgba(75, 69, 212, .5), inset 0 1px 0 rgba(255, 255, 255, .25); }
.brand-name { font-weight: 650; font-size: 15px; letter-spacing: -.01em; }
.search { display: flex; align-items: center; gap: 8px; height: 32px; padding: 0 10px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); color: var(--text-3); }
.search:focus-within { border-color: var(--accent); box-shadow: var(--ring); }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 13px; color: var(--text); }
.search input::placeholder { color: var(--text-3); }
.search input::-webkit-search-cancel-button { display: none; }
.chat-nav { flex: 1; overflow: auto; margin: 0 -6px; padding: 0 6px; }
.chat-group { font-size: 11px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); padding: 12px 8px 4px; }
.chat-group:first-child { padding-top: 4px; }
.chat-list ol { list-style: none; margin: 0; padding: 0; display: grid; gap: 1px; }
.chat-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 0; background: none; cursor: pointer;
  padding: 7px 8px; border-radius: var(--r-sm); color: var(--text-2); transition: background .12s;
}
.chat-item:hover { background: var(--hover); color: var(--text); }
.chat-item.current { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm), 0 0 0 1px var(--border); }
.chat-item .thumb { width: 26px; height: 26px; border-radius: 6px; flex: none; display: grid; place-items: center; color: rgba(255, 255, 255, .92); }
.chat-item .thumb .i { width: 13px; height: 13px; stroke-width: 2.2; }
.chat-item .meta { min-width: 0; flex: 1; display: grid; }
.chat-item .name { font-size: 13px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-item small { font-size: 11.5px; color: var(--text-3); }
.chat-empty { font-size: 12.5px; color: var(--text-3); padding: 10px 8px; }
.sidebar-foot { border-top: 1px solid var(--border); padding-top: 10px; display: grid; gap: 10px; }
.health { font-size: 11.5px; color: var(--text-3); display: grid; gap: 3px; min-width: 0; }
.health span { display: flex; align-items: center; gap: 7px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.health .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 3px var(--ok-soft); flex: none; }
.health .dot.off { background: var(--bad); box-shadow: 0 0 0 3px var(--bad-soft); }
.health .mock { color: var(--warn); font-weight: 600; }
.foot-actions { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.foot-actions .btn { margin-left: -6px; }
.foot-actions .theme-switch { margin-left: auto; }
.auth-off { color: var(--text-3); }
.theme-switch { display: inline-flex; padding: 2px; border-radius: 8px; background: var(--surface-3); flex: none; }
.theme-switch button { width: 26px; height: 24px; border: 0; border-radius: 6px; background: none; color: var(--text-3); cursor: pointer; display: grid; place-items: center; }
.theme-switch button .i { width: 14px; height: 14px; }
.theme-switch button:hover { color: var(--text); }
.theme-switch button[aria-checked="true"] { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ------------------------------------------------------------------ main column */
.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.topbar { display: flex; align-items: center; gap: 8px; height: 52px; padding: 0 12px 0 16px; border-bottom: 1px solid var(--border); background: color-mix(in srgb, var(--bg) 85%, transparent); backdrop-filter: blur(8px); }
.crumbs { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; }
.crumb-root { font-size: 13.5px; color: var(--text-3); flex: none; }
.crumb-sep { width: 14px; height: 14px; color: var(--text-3); }
.chat-title {
  flex: 1; min-width: 0; max-width: 520px; font: 600 14.5px/1.3 var(--ui); letter-spacing: -.005em; border: 1px solid transparent; background: transparent;
  border-radius: var(--r-sm); padding: 5px 8px; margin-left: -4px; color: var(--text); text-overflow: ellipsis;
}
.chat-title:hover { background: var(--hover); }
.chat-title:focus { outline: none; border-color: var(--accent); background: var(--surface); box-shadow: var(--ring); }
.topbar-actions { display: flex; align-items: center; gap: 4px; }
.topbar .divider { width: 1px; height: 20px; background: var(--border); margin: 0 4px; }
.drafts-toggle .badge { margin-left: 1px; }
.app:not(.drafts-folded) .drafts-toggle { color: var(--accent-text); background: var(--accent-soft); }
.menu { display: none; }
.banner { margin: 12px auto 0; width: min(var(--col), calc(100% - 40px)); padding: 10px 14px; border-radius: var(--r-md); background: var(--bad-soft); color: var(--bad); font-size: 13px; border: 1px solid color-mix(in srgb, var(--bad) 22%, transparent); }
.banner.info { background: var(--accent-soft); color: var(--accent-text); border-color: color-mix(in srgb, var(--accent) 22%, transparent); }

.thread { flex: 1; overflow-y: auto; overscroll-behavior: contain; scroll-behavior: auto; }
.messages { width: min(var(--col), calc(100% - 40px)); margin: 0 auto; padding: 28px 0 32px; display: flex; flex-direction: column; gap: 26px; }

/* welcome */
.welcome { padding: 9vh 0 0; }
.welcome .hero-mark { width: 44px; height: 44px; border-radius: 12px; margin-bottom: 18px; }
.welcome .hero-mark .i { width: 22px; height: 22px; }
.welcome h1 { font-size: 28px; line-height: 1.2; letter-spacing: -.025em; font-weight: 650; margin: 0 0 8px; }
.welcome > p { color: var(--text-2); max-width: 56ch; font-size: 15px; }
.starters { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin-top: 28px; }
.starters button {
  text-align: left; padding: 16px; border-radius: var(--r-lg); border: 1px solid var(--border); background: var(--surface);
  cursor: pointer; display: grid; gap: 6px; align-content: start; box-shadow: var(--shadow-sm); transition: border-color .15s, box-shadow .15s, transform .15s;
}
.starters button:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.starters .s-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); margin-bottom: 6px; }
.starters b { font-size: 14px; font-weight: 600; }
.starters span { font-size: 13px; color: var(--text-2); line-height: 1.5; }

/* messages */
.msg.user { align-self: flex-end; max-width: min(80%, 600px); display: grid; gap: 6px; justify-items: end; }
.bubble { background: var(--surface); border: 1px solid var(--border); border-radius: 16px 16px 4px 16px; padding: 9px 14px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14.5px; box-shadow: var(--shadow-sm); }
.att-chips { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-end; }
.att-chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; padding: 5px 10px; border-radius: var(--r-sm); background: var(--surface); border: 1px solid var(--border); max-width: 100%; color: var(--text-2); }
.att-chip .i { width: 14px; height: 14px; color: var(--accent-text); }
.att-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.msg.event { display: grid; gap: 10px; }
.event-line { font-size: 12.5px; color: var(--text-3); display: flex; align-items: center; gap: 10px; }
.event-line::before, .event-line::after { content: ""; flex: 1; height: 1px; background: var(--border); }
.msg.assistant { display: grid; gap: 12px; }
.who { display: flex; align-items: center; gap: 9px; font-size: 13px; font-weight: 600; color: var(--text); margin-bottom: -2px; }
.who .avatar { width: 24px; height: 24px; border-radius: 7px; }
.who .avatar .i { width: 12px; height: 12px; stroke-width: 2.2; }
.md { overflow-wrap: anywhere; font-size: 14.5px; line-height: 1.65; }
.md p + p, .md ul, .md ol, .md pre { margin-top: 8px; }
.md ul, .md ol { padding-left: 22px; margin-bottom: 0; }
.md code { font: 12.5px var(--mono); background: var(--surface-3); padding: 1px 5px; border-radius: 4px; }
.md pre { font: 12.5px/1.55 var(--mono); background: var(--surface); border: 1px solid var(--border); padding: 12px; border-radius: var(--r-md); overflow: auto; }
.md pre code { background: none; padding: 0; }
.md h4 { margin: 12px 0 2px; font-size: 14.5px; }
.msg-error { display: flex; gap: 10px; align-items: flex-start; color: var(--bad); background: var(--bad-soft); padding: 10px 12px; border-radius: var(--r-md); font-size: 13px; border: 1px solid color-mix(in srgb, var(--bad) 20%, transparent); }
.typing { display: inline-flex; gap: 4px; padding: 8px 0; }
.typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.typing i:nth-child(2) { animation-delay: .15s; } .typing i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* shared avatar / cover tiles */
.tile { display: grid; place-items: center; color: #fff; flex: none; position: relative; overflow: hidden; }
.tile::after { content: ""; position: absolute; inset: 0; background: radial-gradient(120% 90% at 20% 10%, rgba(255, 255, 255, .28), transparent 55%); pointer-events: none; }
.avatar { background: linear-gradient(135deg, #7d78ff, #4b45d4); }

/* ------------------------------------------------------------------ cards */
.card { border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--border); box-shadow: var(--shadow-md); overflow: hidden; }
.card-head { display: flex; align-items: center; gap: 12px; padding: 14px 16px; }
.card-icon { width: 32px; height: 32px; border-radius: 8px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent-text); flex: none; }
.card-headtext { flex: 1; min-width: 0; }
.card-title { font-weight: 600; font-size: 14px; letter-spacing: -.005em; }
.card-sub { font-size: 12.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; }
.card-body { padding: 0 16px 14px; display: grid; gap: 12px; }
.card-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 10px 12px; border-top: 1px solid var(--border); background: var(--surface-2); }
.card-foot .spacer { flex: 1; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.status-line { font-size: 12.5px; color: var(--text-2); display: flex; align-items: center; gap: 8px; }
.card-error { color: var(--bad); font-size: 13px; }
.stats { display: flex; flex-wrap: wrap; gap: 6px; }
.stat { display: inline-flex; align-items: baseline; gap: 5px; font-size: 12px; padding: 3px 8px; border-radius: 6px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); }
.stat b { font-weight: 600; color: var(--text); font-feature-settings: "tnum"; }
.status { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 500; padding: 3px 9px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.run { color: var(--accent-text); background: var(--accent-soft); }
.status.run::before { animation: blink 1.2s infinite; }
.status.ok { color: var(--ok); background: var(--ok-soft); }
.status.warn { color: var(--warn); background: var(--warn-soft); }
.status.bad { color: var(--bad); background: var(--bad-soft); }

/* score card */
.card.score .sheet-wrap { margin: 0 12px; border-radius: var(--r-md); background: var(--sheet); border: 1px solid var(--border); overflow: hidden; }
.sheet { padding: 8px 10px 4px; min-height: 90px; overflow-x: auto; color: var(--ink-on-sheet); }
.sheet svg { display: block; max-width: 100%; height: auto; }
.sheet .changed, .sheet .changed path { fill: #4b45d4; }
.sheet .changed-bg { fill: #ecebfe; }
.sheet .playing, .sheet .playing path { fill: #e8590c !important; }
.sheet-fallback { font: 12px/1.5 var(--mono); white-space: pre-wrap; margin: 0; padding: 8px 6px; }
.card.score.writing .sheet { min-height: 150px; }
.score-info { padding: 12px 16px 14px; display: grid; gap: 10px; }
.diff { font-size: 12.5px; color: var(--accent-text); display: flex; align-items: center; gap: 7px; }
.diff .swatch { display: inline-block; width: 10px; height: 10px; border-radius: 3px; background: var(--accent); }
.checker { font-size: 12.5px; display: flex; align-items: center; gap: 7px; }
.checker .i { width: 14px; height: 14px; }
details.checker { display: block; padding: 8px 10px; border-radius: var(--r-sm); }
details.checker summary { cursor: pointer; display: flex; align-items: center; gap: 7px; font-weight: 500; }
.checker.ok { color: var(--ok); }
.checker.warn { color: var(--warn); background: var(--warn-soft); }
.checker.bad { color: var(--bad); background: var(--bad-soft); }
.checker ul { margin: 6px 0 2px; padding-left: 20px; color: var(--text-2); }
.abc-audio:empty { display: none; }
.abcjs-inline-audio { border-radius: var(--r-sm); background: var(--text) !important; }
.abc-edit { display: grid; gap: 8px; padding: 0 16px 14px; }
.abc-edit textarea {
  width: 100%; min-height: 240px; font: 12.5px/1.6 var(--mono); padding: 12px; border: 1px solid var(--border); border-radius: var(--r-md);
  resize: vertical; white-space: pre; overflow-x: auto; background: var(--surface-2); color: var(--text);
}
.abc-edit textarea:focus { outline: none; border-color: var(--accent); box-shadow: var(--ring); }

/* take card */
.card.song .card-head { align-items: flex-start; }
.cover { width: 52px; height: 52px; border-radius: 10px; font: 650 15px/1 var(--ui); letter-spacing: -.02em; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .08); }
.cover svg { position: absolute; left: 6px; right: 6px; bottom: 7px; width: calc(100% - 12px); height: 14px; opacity: .55; }
.cover span { position: relative; top: -6px; z-index: 1; }
.cover.sm { width: 40px; height: 40px; border-radius: 8px; font-size: 12px; }
.cover.sm svg { bottom: 5px; height: 10px; }
.cover.sm span { top: -4px; }
.take-meta { display: flex; flex-wrap: wrap; gap: 4px 6px; margin-top: 6px; }
.tag { font-size: 11.5px; padding: 2px 7px; border-radius: 5px; background: var(--surface-2); border: 1px solid var(--border); color: var(--text-2); white-space: nowrap; }
.progress { height: 4px; border-radius: 2px; background: var(--surface-3); overflow: hidden; position: relative; }
.progress::after { content: ""; position: absolute; inset: 0; width: 30%; border-radius: 2px; background: var(--accent); animation: slide 1.6s ease-in-out infinite; }
@keyframes slide { from { transform: translateX(-100%); } to { transform: translateX(340%); } }
.song-note { font-size: 12.5px; color: var(--text-3); }
.song-error { font-size: 12.5px; color: var(--bad); }
.cand { display: grid; gap: 10px; }
.cand + .cand { padding-top: 12px; border-top: 1px dashed var(--border); }
.cand-label { font-size: 12px; font-weight: 600; color: var(--text-2); }
.disclosure { font-size: 12.5px; color: var(--text-2); }
.disclosure summary { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; list-style: none; user-select: none; }
.disclosure summary::-webkit-details-marker { display: none; }
.disclosure summary .i { width: 14px; height: 14px; transition: transform .15s; }
.disclosure[open] summary .i { transform: rotate(90deg); }
.disclosure summary:hover { color: var(--text); }
.disclosure pre { white-space: pre-wrap; font: 12.5px/1.6 var(--ui); color: var(--text); margin: 8px 0 0; max-height: 220px; overflow: auto; background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--r-sm); padding: 10px 12px; }

/* waveform player */
.player { display: grid; grid-template-columns: 40px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 10px 12px; border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); }
.player .pp {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer; display: grid; place-items: center;
  background: var(--accent); color: var(--on-accent); box-shadow: 0 2px 8px -2px color-mix(in srgb, var(--accent) 60%, transparent); transition: transform .12s, background .12s;
}
.player .pp:hover { transform: scale(1.05); background: var(--accent-hover); }
.player canvas { width: 100%; height: 40px; display: block; cursor: pointer; }
.player .time { font: 500 11.5px var(--mono); color: var(--text-3); min-width: 82px; text-align: right; font-feature-settings: "tnum"; }

/* transcription card */
.card.tx .ref { padding: 0 16px; }
.card.tx .ref:empty { display: none; }
.card.tx .disclosure pre { font: 11.5px/1.5 var(--mono); max-height: 160px; }

/* lyrics card */
.card.details .card-body { gap: 14px; }
.style-tags { display: flex; flex-wrap: wrap; gap: 6px; }
.style-tags .tag { font-size: 12px; padding: 3px 9px; border-radius: 999px; background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.lyrics-sheet { border-radius: var(--r-md); background: var(--surface-2); border: 1px solid var(--border); padding: 14px 16px; display: grid; gap: 2px; font-size: 14px; line-height: 1.75; max-height: 460px; overflow: auto; }
.lyrics-sheet .sec { font: 600 10.5px/1 var(--ui); letter-spacing: .08em; text-transform: uppercase; color: var(--accent-text); margin: 12px 0 4px; }
.lyrics-sheet .sec:first-child { margin-top: 0; }
.lyrics-sheet .gap { height: 6px; }
.lyrics-actions { display: flex; gap: 6px; }

/* ------------------------------------------------------------------ drafts (right sidebar) */
.drafts { background: var(--surface-2); border-left: 1px solid var(--border); min-height: 0; min-width: 0; display: flex; overflow: hidden; }
.drafts-rail {
  display: none; width: 100%; border: 0; background: none; cursor: pointer; color: var(--text-3);
  flex-direction: column; align-items: center; gap: 12px; padding: 16px 0;
}
.drafts-rail:hover { color: var(--accent-text); background: var(--hover); }
.rail-label { writing-mode: vertical-rl; font-size: 12px; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; }
.app.drafts-folded .drafts-rail { display: flex; }
.app.drafts-folded .drafts-panel { display: none; }
.drafts-panel { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.drafts-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; padding: 14px 10px 12px 16px; border-bottom: 1px solid var(--border); min-height: 52px; }
.drafts-head h2 { margin: 0; font-size: 14px; font-weight: 600; display: flex; align-items: center; gap: 6px; }
.drafts-head p { font-size: 12px; color: var(--text-3); }
.drafts-head .icon-btn { margin-top: -4px; }
.drafts-count { font-size: 12px; color: var(--text-3); font-weight: 500; }
.draft-list { list-style: none; margin: 0; padding: 12px; overflow-y: auto; flex: 1; display: grid; gap: 10px; align-content: start; }
.draft-empty { text-align: center; padding: 36px 16px; color: var(--text-3); font-size: 13px; line-height: 1.55; display: grid; justify-items: center; gap: 10px; }
.draft-empty .empty-icon { width: 40px; height: 40px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-3); color: var(--text-3); }
.draft-empty b { color: var(--text-2); font-weight: 600; }
.draft { background: var(--surface); border: 1px solid var(--border); border-radius: var(--r-md); padding: 10px; display: grid; gap: 10px; box-shadow: var(--shadow-sm); transition: border-color .15s; }
.draft:hover { border-color: var(--border-strong); }
.draft.current { border-color: color-mix(in srgb, var(--accent) 50%, var(--border)); box-shadow: var(--shadow-sm), 0 0 0 3px var(--accent-soft); }
.draft-top { display: flex; gap: 10px; align-items: center; min-width: 0; }
.draft-text { flex: 1; min-width: 0; }
.draft-title {
  display: block; font: 600 13px/1.3 var(--ui); color: var(--text); border: 1px solid transparent; background: transparent; border-radius: 4px;
  padding: 2px 4px; margin: -2px -4px; width: calc(100% + 8px); min-width: 0; text-overflow: ellipsis;
}
.draft-title:hover { background: var(--hover); }
.draft-title:focus { outline: none; border-color: var(--accent); background: var(--surface); }
.draft-sub { font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; margin-top: 2px; }
.draft .player { grid-template-columns: 30px minmax(0, 1fr) auto; gap: 8px; padding: 6px 8px; background: var(--surface-2); }
.draft .player .pp { width: 30px; height: 30px; box-shadow: none; }
.draft .player .pp svg { width: 12px; height: 12px; }
.draft .player canvas { height: 28px; }
.draft .player .time { min-width: 0; font-size: 10.5px; }
.draft-actions { display: flex; gap: 2px; justify-content: flex-end; margin: -2px -2px -4px; }
.draft-actions .icon-btn { width: 28px; height: 28px; }
.draft-actions .icon-btn .i { width: 15px; height: 15px; }

/* ------------------------------------------------------------------ composer */
.composer {
  width: min(var(--col), calc(100% - 40px)); margin: 0 auto 18px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 16px; padding: 10px 10px 8px 14px; box-shadow: var(--shadow-lg); transition: border-color .15s, box-shadow .15s;
}
.composer:focus-within { border-color: var(--border-strong); }
.composer textarea { width: 100%; border: 0; resize: none; font: 14.5px/1.55 var(--ui); padding: 4px 0 6px; max-height: 240px; background: transparent; color: var(--text); display: block; }
.composer textarea::placeholder { color: var(--text-3); }
.composer textarea:focus { outline: none; }
.composer-bar { display: flex; align-items: center; gap: 8px; margin-left: -6px; }
.composer-hint { flex: 1; font-size: 11.5px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right; }
.send { margin-left: auto; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--accent); color: var(--on-accent); display: grid; place-items: center; cursor: pointer; flex: none; transition: background .12s, opacity .12s; }
.send .i { stroke-width: 2.2; }
.send:hover { background: var(--accent-hover); }
.send[disabled] { background: var(--surface-3); color: var(--text-3); cursor: default; }
.send .i-stop { display: none; }
.send.stop { background: var(--text); color: var(--bg); }
.send.stop .i-send { display: none; }
.send.stop .i-stop { display: block; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chips:not(:empty) { padding: 0 0 8px; }
.chip { display: inline-flex; align-items: center; gap: 7px; font-size: 12.5px; padding: 4px 4px 4px 9px; border-radius: var(--r-sm); background: var(--surface-2); border: 1px solid var(--border); max-width: 100%; }
.chip .i { width: 14px; height: 14px; color: var(--accent-text); }
.chip.err { background: var(--bad-soft); border-color: color-mix(in srgb, var(--bad) 30%, transparent); color: var(--bad); }
.chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 240px; }
.chip button { border: 0; background: none; cursor: pointer; width: 20px; height: 20px; border-radius: 4px; color: var(--text-3); line-height: 1; }
.chip button:hover { background: var(--hover); color: var(--text); }
/* hum recorder: replaces the composer's contents while recording */
.composer.recording > :not(.recorder):not(input) { display: none !important; }
.recorder { display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 2px 0 2px 2px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--bad); box-shadow: 0 0 0 4px var(--bad-soft); animation: blink 1.2s infinite; flex: none; }
.rec-time { font: 600 13px var(--mono); font-feature-settings: "tnum"; min-width: 38px; }
.rec-meter { flex: 1; min-width: 60px; height: 32px; }
.rec-hint { font-size: 12px; color: var(--text-3); white-space: nowrap; }
.recorder.processing .rec-dot { animation: none; background: var(--text-3); box-shadow: none; }
#record.live { color: var(--bad); }
.drop-overlay { position: absolute; inset: 0; background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 20; pointer-events: none; }
.drop-overlay > div { display: grid; justify-items: center; gap: 10px; padding: 36px 56px; border: 2px dashed var(--accent); border-radius: var(--r-lg); background: var(--surface); color: var(--accent-text); box-shadow: var(--shadow-lg); }
.drop-overlay .i { width: 28px; height: 28px; }
.drop-overlay p { font-weight: 600; font-size: 15px; }

/* ------------------------------------------------------------------ narrower screens */
@media (max-width: 1180px) {
  :root { --right: 288px; --left: 240px; }
  .composer-hint { display: none; }
}
@media (max-width: 560px) { .rec-hint { display: none; } }
@media (max-width: 860px) {
  .app, .app.drafts-folded { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 30; transform: translateX(-100%); transition: transform .2s ease; box-shadow: var(--shadow-lg); }
  .sidebar.open { transform: none; }
  .scrim { position: fixed; inset: 0; background: rgba(10, 10, 16, .4); z-index: 25; }
  .menu { display: inline-grid; }
  .topbar { padding: 0 8px; }
  .crumb-root, .crumb-sep, .drafts-toggle .label { display: none; }
  .starters { grid-template-columns: 1fr; }
  .welcome { padding-top: 4vh; }
  .welcome h1 { font-size: 24px; }
  .messages, .composer, .banner { width: calc(100% - 24px); }
  .composer { margin-bottom: 12px; }
  .player .time { min-width: 0; }
  .drafts { position: fixed; inset: 0 0 0 auto; width: min(340px, 90vw); z-index: 30; transform: translateX(100%); transition: transform .2s ease; }
  .drafts.open { transform: none; box-shadow: var(--shadow-lg); }
  .app.drafts-folded .drafts-rail { display: none; }
  .app.drafts-folded .drafts-panel { display: flex; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
