:root {
  --paper: #f6f2ea; --card: #fffdf8; --ink: #1d2433; --muted: #6b6f7b; --line: #ded7c8;
  --accent: #7a2e2a; --accent-ink: #fff; --accent-soft: #f1e0dc; --blue: #2d4a5e; --ok: #2f6b45; --warn: #a15c00; --bad: #b3261e;
  --radius: 10px; --shadow: 0 1px 2px rgba(29,36,51,.08), 0 6px 18px rgba(29,36,51,.06);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root { --paper: #15181f; --card: #1d212b; --ink: #ece8df; --muted: #9aa0ad; --line: #323847; --accent: #d0766d; --accent-ink: #1a0f0e; --accent-soft: #3a2523; --blue: #8fb3cc; --ok: #7bc496; --warn: #e0a24a; --bad: #f2837b; --shadow: 0 1px 2px rgba(0,0,0,.4); }
}
* { box-sizing: border-box; }
html { color-scheme: light dark; }
body { margin: 0; background: var(--paper); color: var(--ink); font: 16px/1.45 var(--sans); }
button, select, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
[hidden] { display: none !important; }

.top { display: flex; align-items: center; justify-content: space-between; padding: 10px 20px; border-bottom: 1px solid var(--line); background: var(--card); }
.brand { font: 700 1.35rem var(--serif); color: var(--ink); text-decoration: none; letter-spacing: .2px; }
.brand span { color: var(--accent); }
.who { display: flex; gap: 12px; align-items: center; color: var(--muted); }
.link { background: none; border: 0; color: var(--accent); text-decoration: underline; padding: 4px; }

main { padding: 20px; max-width: 1280px; margin: 0 auto; }
h1, h2 { font-family: var(--serif); font-weight: 700; margin: 0 0 .4em; }
h1 { font-size: 1.9rem; }
h2 { font-size: 1.25rem; }
.muted { color: var(--muted); }
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }

.btn { border: 1px solid var(--line); background: var(--card); border-radius: 8px; padding: 8px 14px; min-height: 40px; }
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn[disabled] { opacity: .45; cursor: not-allowed; }
.btn.small { min-height: 32px; padding: 3px 10px; font-size: .9rem; }
.btn.icon { min-width: 44px; padding: 8px; font-size: 1.15rem; line-height: 1; }

/* login */
.login { max-width: 380px; margin: 8vh auto; }
.login form { display: grid; gap: 12px; }
label.field { display: grid; gap: 4px; font-size: .9rem; color: var(--muted); }
input[type=text], input[type=password] { padding: 10px 12px; border: 1px solid var(--line); border-radius: 8px; background: var(--paper); color: var(--ink); }
.error { color: var(--bad); min-height: 1.3em; margin: 0; }

/* library */
.lib-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.songs { list-style: none; padding: 0; margin: 0; display: grid; gap: 10px; }
.song { display: grid; grid-template-columns: 1fr auto; gap: 8px 16px; align-items: center; }
.song a.title { font: 600 1.15rem var(--serif); color: var(--ink); text-decoration: none; }
.song a.title:hover { color: var(--accent); text-decoration: underline; }
.song .meta { color: var(--muted); font-size: .9rem; }
.song .actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.badge { display: inline-block; font-size: .78rem; padding: 1px 8px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); margin-left: 6px; }
.badge.warn { background: #f6e6c8; color: var(--warn); }
.dropzone { border: 2px dashed var(--line); border-radius: var(--radius); padding: 18px; text-align: center; color: var(--muted); margin-bottom: 16px; }
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }

/* player */
.player { display: grid; gap: 14px; }
.stickytop { position: sticky; top: 0; z-index: 5; display: grid; gap: 8px; }
.stickytop .editor { max-height: 42vh; overflow: auto; }
.transport { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 10px 14px; background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }
.transport .group { display: flex; align-items: center; gap: 8px; }
.transport .title { font: 700 1.1rem var(--serif); margin-right: auto; min-width: 0; }
.transport .title small { display: block; font: .8rem var(--sans); color: var(--muted); font-weight: 400; }
.readout { font-variant-numeric: tabular-nums; color: var(--muted); min-width: 7.5em; }
input[type=range] { accent-color: var(--accent); }
select { padding: 7px 8px; border: 1px solid var(--line); border-radius: 8px; background: var(--card); }
.layout { display: grid; grid-template-columns: 300px 1fr; gap: 14px; align-items: start; }
@media (max-width: 900px) { .layout { grid-template-columns: 1fr; } }
.mixer { padding: 12px; position: sticky; top: calc(var(--stickyH, 76px) + 12px); max-height: calc(100vh - var(--stickyH, 76px) - 28px); overflow: auto; }
@media (max-width: 900px) { .mixer { position: static; max-height: none; } }
.mixer h2 { font-size: 1rem; margin-bottom: 8px; }
.voice { display: grid; grid-template-columns: 1fr auto auto; gap: 4px 6px; align-items: center; padding: 8px 0; border-top: 1px solid var(--line); }
.voice .name { font-weight: 600; }
.voice input[type=range] { grid-column: 1 / -1; width: 100%; }
.voice select { grid-column: 1 / -1; font-size: .85rem; padding: 3px 6px; }
.tog { min-width: 34px; min-height: 30px; padding: 0 6px; border: 1px solid var(--line); background: var(--card); border-radius: 6px; font-weight: 700; font-size: .85rem; }
.tog[aria-pressed=true].m { background: var(--bad); color: #fff; border-color: var(--bad); }
.tog[aria-pressed=true].s { background: var(--warn); color: #fff; border-color: var(--warn); }
.scorewrap { position: relative; background: #fff; color: #000; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 8px; overflow-x: auto; min-height: 240px; }
#osmd svg { display: block; max-width: none; }
.rendering { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(255,255,255,.8); color: #333; z-index: 3; font-weight: 600; }
.hint { font-size: .9rem; color: var(--muted); margin: 0 4px; }
.sel-note { outline: none; }
.sel-note * { fill: #c2185b !important; stroke: #c2185b !important; }

/* editor */
.editor { padding: 12px 14px; display: grid; gap: 10px; }
.editor .row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.editor .sel { font-weight: 600; }
.issues { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.issues li { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 6px 10px; background: #fdecea; color: #7a1a14; border-radius: 8px; font-size: .92rem; }
@media (prefers-color-scheme: dark) { .issues li { background: #3d1f1c; color: #f7c9c4; } }
.okline { color: var(--ok); font-weight: 600; }

#toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 10px; box-shadow: var(--shadow); z-index: 20; max-width: 90vw; }
.sr { position: absolute; left: -9999px; }
