:root {
  --bg: #0d0e12;
  --bg-2: #13151b;
  --panel: #181b23;
  --panel-2: #1f232d;
  --line: #2a2f3b;
  --text: #ece6d8;
  --muted: #9a9686;
  --faint: #6b6a62;
  --ivory: #ece6d8;
  --right: #5ad1a8;
  --left: #f2a65a;
  --accent: #e9c46a;
  --danger: #ef6f6c;
  --ok: #5ad1a8;
  --radius: 12px;
  --display: "Fraunces", Georgia, serif;
  --body: "Manrope", system-ui, sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 80% -10%, #1a1d27 0%, transparent 60%), var(--bg);
  color: var(--text);
  font: 15px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { font-family: var(--display); font-weight: 600; letter-spacing: -0.01em; margin: 0; }

/* ---------------------------------------------------------------- top bar */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 28px;
  padding: 12px 24px;
  background: rgba(13, 14, 18, 0.86);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; font: 700 20px var(--display); text-decoration: none; }
.brand-mark { display: inline-flex; align-items: flex-end; gap: 3px; height: 20px; }
.brand-mark i { display: block; width: 5px; border-radius: 2px; background: var(--right); }
.brand-mark i:nth-child(1) { height: 13px; }
.brand-mark i:nth-child(2) { height: 8px; background: var(--left); }
.brand-mark i:nth-child(3) { height: 18px; }
.nav { display: flex; gap: 4px; }
.nav a { padding: 6px 12px; border-radius: 999px; text-decoration: none; color: var(--muted); font-weight: 600; font-size: 14px; }
.nav a:hover { color: var(--text); }
.nav a.active { color: var(--bg); background: var(--ivory); }
.account { margin-left: auto; display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--muted); }
.account strong { color: var(--text); }

main { min-height: calc(100vh - 57px); outline: none; }
.page { max-width: 1160px; margin: 0 auto; padding: 36px 24px 80px; }

/* ---------------------------------------------------------------- buttons, forms */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 9px 16px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--panel-2); color: var(--text); font-weight: 600; font-size: 14px;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background .15s, border-color .15s, transform .05s;
}
.btn:hover { border-color: #3a4050; background: #252a35; }
.btn:active { transform: translateY(1px); }
.btn.primary { background: var(--ivory); color: #15161a; border-color: var(--ivory); }
.btn.primary:hover { background: #fff; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--danger); }
.btn.small { padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn[disabled] { opacity: .45; cursor: not-allowed; }

label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=search], textarea, select {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: var(--bg-2); color: var(--text); font-size: 15px;
}
input:focus, textarea:focus, select:focus { outline: 2px solid rgba(233, 196, 106, .45); outline-offset: 1px; border-color: transparent; }
textarea { min-height: 84px; resize: vertical; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: 14px; cursor: pointer; }
.check input { margin-top: 3px; accent-color: var(--accent); }
.check small { display: block; color: var(--muted); }
.error { color: var(--danger); font-size: 14px; min-height: 1.2em; }

/* ---------------------------------------------------------------- library */
.hero { display: grid; grid-template-columns: 1.2fr 1fr; gap: 40px; align-items: center; margin-bottom: 40px; }
.hero h1 { font-size: clamp(34px, 5vw, 54px); line-height: 1.05; }
.hero h1 em { font-style: italic; color: var(--accent); }
.hero p { color: var(--muted); font-size: 17px; max-width: 46ch; }
.hero-art { height: 200px; border-radius: 16px; overflow: hidden; border: 1px solid var(--line); background: #0a0b0f; }
.hero-art canvas { width: 100%; height: 100%; display: block; }
.toolbar { display: flex; gap: 12px; align-items: center; margin-bottom: 20px; }
.toolbar h2 { font-size: 24px; margin-right: auto; }
.toolbar input { max-width: 280px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.card {
  position: relative; display: flex; flex-direction: column; gap: 10px;
  padding: 18px; border-radius: var(--radius); border: 1px solid var(--line);
  background: linear-gradient(180deg, var(--panel) 0%, var(--bg-2) 100%);
  text-decoration: none; transition: border-color .15s, transform .15s;
}
a.card:hover { border-color: #3b4252; transform: translateY(-2px); }
.card h3 { font-size: 19px; line-height: 1.2; }
.card .by { color: var(--muted); font-size: 13px; }
.card .bars { height: 46px; display: flex; align-items: flex-end; gap: 3px; }
.card .bars i { flex: 1; border-radius: 2px 2px 0 0; opacity: .85; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; font-weight: 600; padding: 2px 8px; border-radius: 999px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.chip.band { color: var(--left); border-color: rgba(242, 166, 90, .35); }
.chip.solo { color: var(--right); border-color: rgba(90, 209, 168, .35); }
.chip.st-ready { color: var(--ok); }
.chip.st-failed { color: var(--danger); }
.chip.st-queued, .chip.st-processing, .chip.st-uploading { color: var(--accent); }
.empty { padding: 48px; text-align: center; color: var(--muted); border: 1px dashed var(--line); border-radius: var(--radius); }

/* ---------------------------------------------------------------- auth & upload */
.narrow { max-width: 460px; margin: 40px auto; }
.panel { padding: 28px; border-radius: 16px; border: 1px solid var(--line); background: var(--panel); }
.panel h1 { font-size: 30px; margin-bottom: 6px; }
.panel .lede { color: var(--muted); margin: 0 0 22px; }
.stack { display: grid; gap: 16px; }
.tabs { display: flex; gap: 4px; padding: 4px; border-radius: 12px; background: var(--bg-2); margin-bottom: 22px; }
.tabs button { flex: 1; padding: 8px; border-radius: 9px; border: 0; background: transparent; color: var(--muted); font-weight: 700; cursor: pointer; }
.tabs button.on { background: var(--panel-2); color: var(--text); }

.upload-grid { display: grid; grid-template-columns: 1fr 340px; gap: 24px; align-items: start; }
.drop {
  display: grid; place-items: center; text-align: center; gap: 6px;
  padding: 30px 16px; border: 1.5px dashed #3a4050; border-radius: 14px; cursor: pointer;
  background: var(--bg-2); transition: border-color .15s, background .15s;
}
.drop.over, .drop:hover { border-color: var(--accent); background: #191b21; }
.drop strong { font-size: 16px; }
.drop span { color: var(--muted); font-size: 13px; }
.drop.has { border-style: solid; border-color: var(--right); }
.seg { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.seg label { display: block; padding: 12px; border-radius: 10px; border: 1px solid var(--line); cursor: pointer; background: var(--bg-2); }
.seg label:has(input:checked) { border-color: var(--accent); background: #1d1c18; }
.seg input { position: absolute; opacity: 0; pointer-events: none; }
.seg b { display: block; font-size: 14px; }
.seg small { color: var(--muted); font-size: 12px; }
.howto { font-size: 14px; color: var(--muted); }
.howto h3 { font-size: 18px; color: var(--text); margin-bottom: 10px; }
.howto ol { padding-left: 18px; margin: 0; display: grid; gap: 8px; }
.progress { height: 6px; border-radius: 3px; background: var(--bg-2); overflow: hidden; }
.progress i { display: block; height: 100%; width: 0; background: var(--accent); transition: width .2s; }

/* ---------------------------------------------------------------- my songs */
.rows { display: grid; gap: 10px; }
.row { display: grid; grid-template-columns: 1fr auto; gap: 16px; align-items: center; padding: 16px 18px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--panel); }
.row h3 { font-size: 18px; }
.row .meta { color: var(--muted); font-size: 13px; margin-top: 4px; }
.row .err { color: var(--danger); font-size: 13px; margin-top: 6px; white-space: pre-wrap; }
.row .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.spinner { display: inline-block; width: 12px; height: 12px; border-radius: 50%; border: 2px solid var(--accent); border-right-color: transparent; animation: spin .8s linear infinite; vertical-align: -1px; margin-right: 6px; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- player */
.player { display: grid; grid-template-columns: 1fr 280px; grid-template-rows: auto 1fr auto; height: calc(100vh - 57px); }
.player.no-side { grid-template-columns: 1fr 0; }
.p-head { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 10px 18px; border-bottom: 1px solid var(--line); background: var(--bg-2); }
.p-head h1 { font-size: 20px; }
.p-head .by { color: var(--muted); font-size: 13px; }
.p-head .spacer { flex: 1; }
.stage-wrap { position: relative; display: flex; flex-direction: column; min-height: 0; background: #08090c; }
.stage { position: relative; flex: 1; min-height: 160px; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage .overlay { position: absolute; inset: 0; display: grid; place-items: center; pointer-events: none; }
.stage .overlay .big { pointer-events: auto; padding: 14px 26px; font-size: 17px; border-radius: 999px; }
.wait-badge { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); padding: 4px 12px; border-radius: 999px; background: rgba(233, 196, 106, .15); color: var(--accent); font-size: 13px; font-weight: 700; display: none; }
.wait-badge.on { display: block; }
.sheet { height: 0; overflow: auto; background: #f6f2e8; color: #111; transition: height .2s; }
.sheet.open { height: 36%; border-top: 1px solid var(--line); }
.sheet .msg { padding: 20px; font-size: 14px; color: #555; }

.side { grid-row: 2 / 4; grid-column: 2; border-left: 1px solid var(--line); background: var(--bg-2); overflow: auto; padding: 16px; display: grid; gap: 22px; align-content: start; }
.player.no-side .side { display: none; }
.side h4 { margin: 0 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); }
.bm-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.bm-list li { display: grid; grid-template-columns: auto 1fr auto; gap: 8px; align-items: center; padding: 6px 8px; border-radius: 8px; cursor: pointer; font-size: 14px; }
.bm-list li:hover { background: var(--panel-2); }
.bm-list .k { font: 700 11px var(--body); color: var(--bg); background: var(--accent); border-radius: 5px; padding: 1px 6px; }
.bm-list .tm { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 12px; }
.bm-list .x { border: 0; background: none; color: var(--faint); cursor: pointer; padding: 2px 4px; }
.bm-list .x:hover { color: var(--danger); }
.bm-add { display: flex; gap: 6px; margin-top: 8px; }
.bm-add input { padding: 6px 10px; font-size: 13px; }
.hand-row { display: grid; grid-template-columns: 70px 1fr; gap: 8px; align-items: center; margin-bottom: 8px; font-size: 13px; font-weight: 700; }
.hand-row .dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 6px; }
.hand-row select { padding: 6px 8px; font-size: 13px; }
.toggles { display: grid; gap: 8px; font-size: 14px; }
.toggles label { display: flex; align-items: center; justify-content: space-between; gap: 10px; cursor: pointer; }
.toggles input[type=checkbox] { accent-color: var(--accent); width: 16px; height: 16px; }
.sliders { display: grid; gap: 10px; font-size: 13px; color: var(--muted); }
.sliders label { display: grid; gap: 2px; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.loop-box { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 13px; }
.loop-box .val { grid-column: 1 / -1; color: var(--muted); font-variant-numeric: tabular-nums; }
.stat { font-size: 13px; color: var(--muted); }
.stat b { color: var(--text); font-size: 18px; font-family: var(--display); }
.kbd { font-size: 12px; color: var(--muted); display: grid; grid-template-columns: auto 1fr; gap: 3px 10px; }
.kbd kbd { font: 600 11px var(--body); background: var(--panel-2); border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; padding: 0 5px; color: var(--text); justify-self: start; }

.controls { grid-column: 1; display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-top: 1px solid var(--line); background: var(--bg-2); }
.ctl { width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line); background: var(--panel-2); display: grid; place-items: center; cursor: pointer; padding: 0; }
.ctl:hover { border-color: #3a4050; }
.ctl svg { width: 18px; height: 18px; fill: var(--text); }
.ctl.play { width: 46px; height: 46px; border-radius: 50%; background: var(--ivory); border-color: var(--ivory); }
.ctl.play svg { fill: #111; width: 20px; height: 20px; }
.time { font-variant-numeric: tabular-nums; font-size: 13px; color: var(--muted); min-width: 92px; text-align: center; }
.seek { position: relative; flex: 1; height: 30px; cursor: pointer; }
.seek .track { position: absolute; left: 0; right: 0; top: 13px; height: 4px; border-radius: 2px; background: var(--line); }
.seek .fill { position: absolute; left: 0; top: 13px; height: 4px; border-radius: 2px; background: var(--ivory); }
.seek .loop { position: absolute; top: 9px; height: 12px; border-radius: 3px; background: rgba(233, 196, 106, .22); border: 1px solid rgba(233, 196, 106, .6); display: none; }
.seek .loop.on { display: block; }
.seek .mark { position: absolute; top: 4px; width: 2px; height: 22px; margin-left: -1px; background: var(--accent); border-radius: 1px; }
.seek .mark::after { content: attr(data-k); position: absolute; top: -2px; left: 4px; font-size: 10px; font-weight: 700; color: var(--accent); }
.seek .knob { position: absolute; top: 8px; width: 14px; height: 14px; margin-left: -7px; border-radius: 50%; background: var(--ivory); box-shadow: 0 0 0 4px rgba(236, 230, 216, .12); }
.speed { width: auto; padding: 7px 8px; font-size: 13px; }

.toast { position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 20px); opacity: 0; padding: 10px 16px; border-radius: 10px; background: var(--ivory); color: #111; font-weight: 600; font-size: 14px; pointer-events: none; transition: all .2s; z-index: 50; }
.toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---------------------------------------------------------------- responsive */
@media (max-width: 900px) {
  .hero, .upload-grid { grid-template-columns: 1fr; }
  .player, .player.no-side { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 62vh auto auto; height: auto; min-height: calc(100vh - 57px); }
  .p-head { flex-wrap: wrap; gap: 8px 10px; padding: 10px 16px; }
  .p-head > div:nth-child(2) { flex: 1 1 60%; min-width: 0; }
  .p-head .spacer { display: none; }
  .stage-wrap { grid-row: 2; }
  .controls { grid-row: 3; flex-wrap: wrap; padding: 10px 16px; }
  .side { grid-row: 4; grid-column: 1; border-left: 0; border-top: 1px solid var(--line); }
  .player.no-side .side { display: grid; }
  #side-toggle { display: none; }
  .seek { order: 10; flex-basis: 100%; }
}
@media (max-width: 640px) {
  .topbar { gap: 12px; padding: 10px 16px; flex-wrap: wrap; }
  .nav a { padding: 5px 9px; font-size: 13px; }
  .page { padding: 24px 16px 60px; }
  .row { grid-template-columns: 1fr; }
  .row .actions { justify-content: flex-start; }
  .toolbar { flex-wrap: wrap; }
  .toolbar input { max-width: none; }
}
