:root {
  --bg: #f6f2ea;
  --surface: #fffdf8;
  --ink: #1f1b16;
  --muted: #6b6257;
  --line: #e2d9cb;
  --accent: #8a2c1f;
  --accent-ink: #fff;
  --rec: #c0392b;
  --paper: #ffffff;
  --focus: #2f6f9f;
  --radius: 10px;
  --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:not([data-theme="light"]) {
    --bg: #171512;
    --surface: #211e1a;
    --ink: #eee7dc;
    --muted: #a99f92;
    --line: #3a342d;
    --accent: #e0917f;
    --accent-ink: #1b1411;
    --rec: #ff6b5a;
    --paper: #fbf9f4;
    --focus: #8cc3ec;
  }
}
:root[data-theme="dark"] {
  --bg: #171512; --surface: #211e1a; --ink: #eee7dc; --muted: #a99f92; --line: #3a342d;
  --accent: #e0917f; --accent-ink: #1b1411; --rec: #ff6b5a; --paper: #fbf9f4; --focus: #8cc3ec;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 var(--sans);
}
.wrap { max-width: 1100px; margin: 0 auto; padding: 0 16px; }
.top { padding: 28px 0 8px; }
h1 { font: 600 30px/1.15 var(--serif); margin: 0 0 6px; letter-spacing: -0.01em; }
h2 { font: 600 19px/1.2 var(--serif); margin: 0; }
h3 { font: 600 16px/1.2 var(--serif); margin: 0 0 4px; }
.lede { color: var(--muted); margin: 0; max-width: 60ch; }

.brand { display: flex; align-items: center; gap: 18px; }
.logo { flex: none; width: 92px; height: auto; color: var(--ink); }
.logo-note { fill: var(--accent); }
.brand-text { border-left: 1px solid var(--line); padding-left: 18px; min-width: 0; }

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  margin: 16px 0;
}
.panel > h2 { margin-bottom: 12px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; margin-bottom: 10px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 14px 18px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field > span { font-weight: 600; }
.field.check, .check { flex-direction: row; align-items: center; gap: 8px; color: var(--ink); }
.check.small { font-size: 13px; color: var(--muted); margin-top: 10px; }
.row { display: flex; gap: 8px; align-items: center; }
.wrap-row { flex-wrap: wrap; }
small { font-weight: 400; color: var(--muted); }

input, select, button, .file {
  font: inherit;
  color: var(--ink);
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 7px 10px;
  min-height: 36px;
}
select { flex: 1; min-width: 0; }
input[type="range"] { flex: 1; padding: 0; border: 0; background: transparent; accent-color: var(--accent); }
input[type="checkbox"] { width: 18px; height: 18px; min-height: 0; accent-color: var(--accent); }
.num { width: 84px; }
button, .file { cursor: pointer; white-space: nowrap; }
button:hover, .file:hover { border-color: var(--muted); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
.ghost { background: transparent; }

.rec { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.rec.on { background: var(--rec); border-color: var(--rec); color: #fff; animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.72; } }
@media (prefers-reduced-motion: reduce) { .rec.on { animation: none; } }

.hint { color: var(--muted); font-size: 13px; margin: 0 0 12px; }
.hands { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 14px; }
.hand { border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; }
.clef { font: 400 13px var(--sans); color: var(--muted); margin-left: 6px; }
.hand-status { margin: 0 0 8px; font-size: 13px; color: var(--muted); min-height: 1.5em; }
.level { height: 4px; background: var(--line); border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.level-bar { height: 100%; width: 0; background: var(--accent); transition: width 80ms linear; }

.beats { display: flex; gap: 6px; }
.beats span { width: 12px; height: 12px; border-radius: 50%; border: 1.5px solid var(--muted); }
.beats span.on { background: var(--accent); border-color: var(--accent); }
.beats span.down.on { background: var(--rec); border-color: var(--rec); }

.paper { background: var(--paper); border-radius: 8px; padding: 6px; overflow-x: auto; color: #111; }
.score svg { display: block; max-width: none; }
.empty { color: #776d62; text-align: center; padding: 40px 10px; margin: 0; }
.status { color: var(--muted); min-height: 1.5em; }
.status.err { color: var(--rec); }
.foot { color: var(--muted); font-size: 12px; padding-bottom: 32px; }

@media (max-width: 520px) {
  h1 { font-size: 24px; }
  .panel { padding: 12px; }
  .brand { gap: 12px; }
  .logo { width: 64px; }
  .brand-text { padding-left: 12px; }
}
