:root {
  --bg: #faf8f5;
  --surface: #ffffff;
  --text: #1f1d1a;
  --muted: #6b665e;
  --line: #e4dfd7;
  --accent: #7a3e9d;
  --accent-soft: #f1e7f7;
  --danger: #b3261e;
  --radius: 12px;
  --shadow: 0 1px 3px rgb(0 0 0 / 0.08);
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17151a;
    --surface: #221f26;
    --text: #ece8f0;
    --muted: #a49eab;
    --line: #36313c;
    --accent: #c79be3;
    --accent-soft: #3a2c45;
    --shadow: none;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 16px/1.5 var(--font); -webkit-text-size-adjust: 100%; }
a { color: var(--accent); }
button, input, select { font: inherit; color: inherit; }

.wrap { max-width: 960px; margin: 0 auto; padding: 16px; }
header.bar { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); background: var(--surface); position: sticky; top: 0; z-index: 10; }
header.bar h1 { font-size: 1.1rem; margin: 0; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
header.bar a.back { text-decoration: none; font-size: 1.4rem; line-height: 1; }

.btn { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 8px 16px; cursor: pointer; min-height: 40px; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
@media (prefers-color-scheme: dark) { .btn.primary { color: #17151a; } }
.btn:disabled { opacity: 0.5; cursor: default; }
.btn.small { padding: 4px 10px; min-height: 32px; font-size: 0.85rem; }
.btn.danger { color: var(--danger); }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.muted { color: var(--muted); }
.error { color: var(--danger); min-height: 1.5em; }

/* login */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 16px; }
.login form { width: min(360px, 100%); display: grid; gap: 12px; text-align: center; }
.login h1 { margin: 0; font-size: 1.5rem; }
.login input { width: 100%; padding: 12px 48px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); text-align: center; font-size: 1.1rem; }
.keyfield { position: relative; }
.keyfield button { position: absolute; right: 4px; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border: 0; background: none; color: var(--muted); cursor: pointer; display: grid; place-items: center; border-radius: 8px; }
.keyfield button[aria-pressed=true] .slash { display: none; }

/* song list */
.search { width: 100%; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--surface); margin-bottom: 12px; }
.songs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.songs a { display: block; padding: 14px 16px; text-decoration: none; color: inherit; }
.songs a:hover { border-color: var(--accent); }
.songs .title { font-weight: 600; }
.upload { margin-top: 24px; display: grid; gap: 10px; }
.upload h2 { margin: 0; font-size: 1rem; }
.upload input[type=text] { padding: 10px 12px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); }

/* player */
.player { display: grid; grid-template-rows: auto 1fr auto; height: 100dvh; }
.player main { overflow: auto; -webkit-overflow-scrolling: touch; }
#score { background: #fff; min-height: 50vh; }
#score svg { max-width: 100%; height: auto; }
.status { padding: 24px; text-align: center; }

.controls[hidden] { display: none; }
.controls { background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 10px; z-index: 10; }
.transport { display: flex; flex-wrap: nowrap; align-items: center; gap: 10px; }
.transport .play { width: 48px; height: 48px; border-radius: 50%; font-size: 1.3rem; padding: 0; flex: none; }
.transport input[type=range] { flex: 1; min-width: 0; }
.transport .time { font-variant-numeric: tabular-nums; font-size: 0.85rem; color: var(--muted); min-width: 4.5em; text-align: right; }

.mixer { display: grid; gap: 6px; }
.panel { display: grid; gap: 10px; max-height: 45dvh; overflow: auto; }
.mixer-toggle { justify-self: start; }
.channel { display: grid; grid-template-columns: 7.5em auto 1fr; align-items: center; gap: 8px; }
.channel .name { border: 1px solid var(--line); background: var(--bg); border-radius: 999px; padding: 4px 10px; text-align: left; cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-height: 36px; }
.channel.focused .name { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.channel .toggles { display: flex; gap: 4px; }
.channel .toggles button { width: 34px; height: 34px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); cursor: pointer; font-size: 0.8rem; font-weight: 700; padding: 0; }
.channel .toggles button[aria-pressed=true].mute { background: var(--danger); border-color: var(--danger); color: #fff; }
.channel .toggles button[aria-pressed=true].solo { background: #e0a200; border-color: #e0a200; color: #000; }
.channel.silent .name { opacity: 0.45; }
.channel input[type=range] { width: 100%; }

.settings { display: flex; flex-wrap: wrap; gap: 8px 16px; font-size: 0.9rem; align-items: center; }
.settings label { display: flex; align-items: center; gap: 6px; }
.settings input[type=range] { width: 110px; }
.hidden { display: none !important; }

input[type=range] { accent-color: var(--accent); height: 28px; }

@media (max-width: 480px) {
  .channel { grid-template-columns: 6em auto 1fr; }
}
