:root {
  --bg: #0E0F13; --card: #181A20; --card2: #1F2128; --line: #2A2D38;
  --text: #F2F2F4; --mute: #8B8E99; --soft: #C9CBD3;
  --accent: #FF5A3C; --on-accent: #0E0F13; --bad: #F87171;
  --drums: #FF5A3C; --bass: #2DD4BF; --vocals: #FBBF24; --other: #A78BFA;
  --r: 14px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); }
body { font-size: 16px; line-height: 1.45; -webkit-text-size-adjust: 100%; overscroll-behavior-y: none; }
.app { min-height: 100dvh; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
[hidden] { display: none !important; }
h1 { font-size: 24px; font-weight: 600; margin: 0 0 4px; letter-spacing: -0.01em; }
.sub { color: var(--mute); margin: 0; font-size: 15px; }
.hint { color: var(--mute); font-size: 13px; margin: 8px 0 0; }
.foot { color: var(--mute); font-size: 12.5px; margin: 14px 4px 0; }

.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px; padding: 12px 18px; background: rgba(14,15,19,0.92); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border-bottom: 1px solid #1a1c23; }
.brand { display: flex; align-items: center; gap: 9px; }
.logo { width: 28px; height: 28px; border-radius: 9px; background: var(--accent); display: inline-flex; align-items: center; justify-content: center; }
.logo::after { content: ""; width: 14px; height: 12px; background:
  linear-gradient(var(--on-accent), var(--on-accent)) 0 50% / 2px 4px no-repeat,
  linear-gradient(var(--on-accent), var(--on-accent)) 4px 50% / 2px 12px no-repeat,
  linear-gradient(var(--on-accent), var(--on-accent)) 8px 50% / 2px 8px no-repeat,
  linear-gradient(var(--on-accent), var(--on-accent)) 12px 50% / 2px 10px no-repeat; }
.name { font-weight: 600; font-size: 17px; }
.top-title { flex: 1; min-width: 0; font-weight: 600; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-title small { display: block; font-weight: 400; color: var(--mute); font-size: 12px; }
.top-actions { margin-left: auto; display: flex; gap: 8px; }
.top.sub .brand { display: none; }
.top:not(.sub) .top-title, .top:not(.sub) .top-actions { display: none; }
.btn:disabled { opacity: .45; }

main { max-width: 860px; margin: 0 auto; padding: 18px 18px 60px; }
.card { background: var(--card); border-radius: var(--r); padding: 14px; margin-top: 12px; }

.btn { appearance: none; border: 0; border-radius: 12px; padding: 12px 18px; font: inherit; font-weight: 600; font-size: 15px; background: var(--card2); color: var(--text); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn.primary { background: var(--accent); color: var(--on-accent); }
.btn.wide { width: 100%; margin-top: 12px; }
.btn:active, .chip:active, .icon-btn:active, .play-btn:active { transform: scale(0.97); }
.btn svg { width: 18px; height: 18px; }
.chip { appearance: none; border: 0; border-radius: 10px; padding: 9px 14px; font: inherit; font-size: 14px; font-weight: 500; background: var(--card2); color: var(--soft); cursor: pointer; white-space: nowrap; }
.chip.on { background: var(--accent); color: var(--on-accent); font-weight: 600; }
.icon-btn { appearance: none; border: 0; width: 40px; height: 40px; border-radius: 12px; background: transparent; color: var(--soft); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn.lg { width: 56px; height: 56px; background: var(--card2); border-radius: 50%; flex-direction: column; font-size: 11px; font-weight: 600; }
.icon-btn.lg svg { width: 24px; height: 24px; }
.play-btn { appearance: none; border: 0; width: 72px; height: 72px; border-radius: 50%; background: var(--accent); color: var(--on-accent); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }
.play-btn svg { width: 32px; height: 32px; }

.lib-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.song-list { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.song { background: var(--card); border-radius: var(--r); padding: 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; }
.song:active { background: var(--card2); }
.song .meta { flex: 1; min-width: 0; }
.song .t { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song .s { color: var(--mute); font-size: 13px; }
.song .dots { display: flex; gap: 4px; margin-top: 6px; }
.song .dots i { width: 22px; height: 4px; border-radius: 2px; display: block; }
.empty { background: var(--card); border-radius: var(--r); padding: 36px 20px; text-align: center; color: var(--mute); grid-column: 1 / -1; }
.empty b { display: block; color: var(--text); font-size: 18px; margin-bottom: 6px; }

.drop { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 34px 16px; border: 1.5px dashed var(--line); border-radius: var(--r); cursor: pointer; text-align: center; }
.drop.has { border-style: solid; border-color: var(--accent); }
.drop-icon svg { width: 34px; height: 34px; color: var(--accent); }
.drop-text { font-weight: 600; word-break: break-word; }
.drop-sub { color: var(--mute); font-size: 13px; }
.field { display: block; margin-bottom: 12px; }
.field span { display: block; color: var(--mute); font-size: 13px; margin-bottom: 5px; }
input[type=text], input[type=number], select { width: 100%; background: #0E0F13; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 16px; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.row3 { display: grid; grid-template-columns: 1.2fr 1fr auto; gap: 8px; align-items: center; }
.prog-title { font-weight: 600; margin-bottom: 10px; }
.bar { height: 8px; background: #23252C; border-radius: 4px; overflow: hidden; }
.bar > div { height: 100%; width: 0; background: var(--accent); border-radius: 4px; transition: width .25s; }
.prog-meta { display: flex; justify-content: space-between; color: var(--mute); font-size: 13px; margin-top: 6px; }

.presets { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.presets::-webkit-scrollbar { display: none; }
.stack { position: relative; margin-top: 10px; display: grid; gap: 8px; touch-action: pan-y; user-select: none; -webkit-user-select: none; }
.stem { background: var(--card); border-radius: 12px; overflow: hidden; }
.stem .sh { display: flex; align-items: center; gap: 10px; padding: 9px 12px 4px; }
.stem .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.stem .nm { font-weight: 600; font-size: 14px; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.stem .vol { width: 110px; flex: none; }
.ms { appearance: none; border: 0; width: 34px; height: 30px; border-radius: 8px; background: var(--card2); color: var(--mute); font: inherit; font-size: 13px; font-weight: 700; cursor: pointer; }
.ms.m.on { background: var(--accent); color: var(--on-accent); }
.ms.s.on { background: var(--vocals); color: var(--on-accent); }
.stem canvas { display: block; width: 100%; height: 54px; transition: opacity .15s; }
.stem.off canvas { opacity: 0.22; }
.stem.off .nm { color: var(--mute); }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; background: #fff; box-shadow: 0 0 6px rgba(255,255,255,.5); pointer-events: none; left: 0; }
.loopbox { position: absolute; top: 0; bottom: 0; background: rgba(255,90,60,0.16); border-left: 2px solid var(--accent); border-right: 2px solid var(--accent); pointer-events: none; display: none; }
.loopbox.on { background: rgba(255,90,60,0.26); }

.timeline { display: flex; justify-content: space-between; color: var(--soft); font-variant-numeric: tabular-nums; font-size: 14px; }
.loop-info { color: var(--accent); font-size: 13px; }
.main-btns { display: flex; justify-content: center; align-items: center; gap: 24px; margin: 12px 0; }
.loop-btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.controls { display: grid; gap: 12px; grid-template-columns: 1fr 1fr; }
.ctl-head { display: flex; justify-content: space-between; color: var(--mute); font-size: 13px; margin-bottom: 8px; }
.ctl-head b { color: var(--text); font-size: 15px; }
input[type=range] { width: 100%; accent-color: var(--accent); }

.toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translate(-50%, 20px); background: #2A2D38; color: var(--text); padding: 11px 16px; border-radius: 12px; font-size: 14px; opacity: 0; pointer-events: none; transition: all .2s; max-width: 90vw; z-index: 20; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.err { background: #5b2323; }

@media (max-width: 640px) {
  .controls { grid-template-columns: 1fr; }
  .stem .vol { width: 80px; }
  .song-list { grid-template-columns: 1fr; }
}
@media (min-width: 1000px) {
  main { max-width: 980px; }
  .stem canvas { height: 64px; }
}

.or { display: flex; align-items: center; gap: 10px; color: var(--mute); font-size: 13px; margin: 14px 0; }
.or::before, .or::after { content: ""; flex: 1; height: 1px; background: var(--line); }
.linkrow { display: flex; gap: 8px; }
.linkrow input { flex: 1; min-width: 0; background: #0E0F13; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 11px 12px; font: inherit; font-size: 16px; }
#url-bar { margin-top: 10px; }
#url-bar > div { background: var(--accent); }
#url-msg.err { color: var(--bad); }
