/* Layout: one landscape screen. Thin toolbar, a scrolling single-staff strip, a one-octave keyboard on a felt strip. */
:root {
  --bg: #e7e9ec;
  --paper: #fbfbf8;
  --ink: #17191e;
  --muted: #9aa0a8;
  --rule: #2b2e35;
  --accent: #2456c4;
  --accent-soft: rgba(36, 86, 196, .11);
  --good: #18804a;
  --bad: #c2361f;
  --felt: #7c1d22;
  --wk: #fcfcfa;
  --wk-edge: #c9ccd1;
  --bk: #1b1b1e;
  --chip: #dde0e5;
  --sheet: #f6f7f8;
  --font-ui: "Figtree", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-music: "Noto Music", "Bravura", serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111317; --paper: #1a1d23; --ink: #e9eaed; --muted: #5f6570; --rule: #b9bdc5;
    --accent: #86a8ff; --accent-soft: rgba(134, 168, 255, .14); --good: #4fc584; --bad: #ff7b62;
    --felt: #8e2a2f; --wk: #e4e4e0; --wk-edge: #8a8d92; --bk: #0a0a0b; --chip: #262a31; --sheet: #1d2026;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #111317; --paper: #1a1d23; --ink: #e9eaed; --muted: #5f6570; --rule: #b9bdc5;
  --accent: #86a8ff; --accent-soft: rgba(134, 168, 255, .14); --good: #4fc584; --bad: #ff7b62;
  --felt: #8e2a2f; --wk: #e4e4e0; --wk-edge: #8a8d92; --bk: #0a0a0b; --chip: #262a31; --sheet: #1d2026;
  color-scheme: dark;
}
html, body { height: 100%; }
[hidden] { display: none !important; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--font-ui);
  overflow: hidden; touch-action: manipulation; user-select: none; -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; }
#app {
  height: 100%; display: grid; grid-template-rows: auto minmax(0, 1fr) minmax(110px, 40%);
  padding-left: max(12px, env(safe-area-inset-left, 0px));
  padding-right: max(12px, env(safe-area-inset-right, 0px));
  padding-block: 6px 0; gap: 6px; box-sizing: border-box;
}

/* Toolbar */
.bar { display: flex; align-items: center; gap: 8px; min-width: 0; }
.btn {
  border: 0; background: var(--chip); border-radius: 8px; padding: 6px 11px; font-size: 13px; font-weight: 600;
  cursor: pointer; display: inline-flex; align-items: center; gap: 6px; white-space: nowrap;
}
.btn:focus-visible, .seg button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.btn.primary { background: var(--accent); color: var(--paper); }
.btn svg { width: 15px; height: 15px; }
.envbadge { background: #e65100; color: #fff; font-size: 11px; font-weight: 800; letter-spacing: .08em; padding: 3px 7px; border-radius: 6px; }
.title { flex: 1; min-width: 0; font-weight: 700; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.seg { display: inline-flex; background: var(--chip); border-radius: 8px; padding: 2px; }
.seg button { border: 0; background: transparent; padding: 4px 10px; border-radius: 6px; font-size: 13px; font-weight: 600; cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--paper); box-shadow: 0 1px 2px rgba(0,0,0,.15); }
.seg button:disabled { opacity: .35; cursor: default; }
.hud { font-size: 12.5px; color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hud b { color: var(--ink); font-weight: 600; }

/* Staff */
#staff { position: relative; background: var(--paper); border-radius: 10px; overflow: hidden; cursor: pointer; }
#staff svg { position: absolute; top: 0; left: 0; height: 100%; overflow: visible; }
#content { transition: transform .22s cubic-bezier(.3,.7,.3,1); will-change: transform; }
@media (prefers-reduced-motion: reduce) { #content { transition: none; } }
#header { background: var(--paper); }
.ev { color: var(--ink); }
.ev.done { color: var(--muted); }
.ev.cur { color: var(--accent); }
.nt.found { color: var(--good); }
.ev .nt.tied { opacity: .4; }
#curBox { fill: var(--accent-soft); }
.staffline { stroke: var(--rule); }
.toast {
  position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); background: var(--ink); color: var(--paper);
  font-size: 12.5px; padding: 6px 12px; border-radius: 999px; display: flex; gap: 10px; align-items: center; white-space: nowrap;
}
.toast button { border: 0; background: transparent; color: var(--paper); font-weight: 700; text-decoration: underline; cursor: pointer; padding: 0; }

/* Keyboard */
#kbwrap { background: var(--felt); padding: 5px 4px calc(4px + env(safe-area-inset-bottom, 0px)); border-radius: 10px 10px 0 0; }
#kb { position: relative; height: 100%; display: flex; gap: 3px; }
.wk {
  flex: 1; background: var(--wk); border-radius: 0 0 7px 7px; box-shadow: inset 0 -5px 0 var(--wk-edge);
  display: flex; align-items: flex-end; justify-content: center; padding-bottom: 10px; font-weight: 600; font-size: 14px; color: #6d727a;
  position: relative; cursor: pointer;
}
.bk {
  position: absolute; top: 0; height: 60%; width: 8.4%; background: var(--bk); border-radius: 0 0 5px 5px; z-index: 2;
  box-shadow: inset 0 -4px 0 #3a3a3f, 0 2px 3px rgba(0,0,0,.35);
  display: flex; flex-direction: column; align-items: center; justify-content: flex-end; padding-bottom: 8px; box-sizing: border-box;
  font-size: 10.5px; line-height: 1.15; color: #a9adb4; font-weight: 600; cursor: pointer;
}
.wk.ok, .bk.ok { background: var(--good); color: #fff; }
.wk.bad, .bk.bad { background: var(--bad); color: #fff; }
.wk.hint, .bk.hint { outline: 3px dashed var(--accent); outline-offset: -6px; }
.wk.down { box-shadow: inset 0 -2px 0 var(--wk-edge); }
.nolabels .wk span, .nolabels .bk span { visibility: hidden; }

/* Sheets */
.scrim { position: fixed; inset: 0; background: rgba(10, 12, 16, .45); z-index: 20; display: flex; justify-content: flex-end; }
.sheet {
  background: var(--sheet); width: min(460px, 100%); height: 100%; overflow-y: auto; box-sizing: border-box;
  padding: 16px max(18px, env(safe-area-inset-right, 0px)) 24px 18px; display: flex; flex-direction: column; gap: 14px;
  box-shadow: -8px 0 30px rgba(0,0,0,.2);
}
.sheet.center { margin: auto; height: auto; max-height: 92%; border-radius: 14px; width: min(520px, 92%); }
.scrim.center { justify-content: center; align-items: center; }
.sheet h2 { margin: 0; font-size: 18px; text-wrap: balance; }
.sheet h3 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.sheet p { margin: 0; font-size: 13.5px; line-height: 1.45; max-width: 60ch; }
.sheethead { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.songs { display: flex; flex-direction: column; gap: 6px; }
.song {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; align-items: center; background: var(--paper);
  border-radius: 10px; padding: 10px 12px; cursor: pointer; border: 2px solid transparent;
}
.song.active { border-color: var(--accent); }
.song .name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.song .meta { grid-column: 1; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.song .del { grid-row: 1 / span 2; grid-column: 2; border: 0; background: transparent; color: var(--muted); font-size: 12px; font-weight: 600; cursor: pointer; padding: 6px; }
.song .del.armed { color: var(--bad); }
.tag { font-size: 10.5px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; color: var(--muted); margin-left: 6px; }
.err { color: var(--bad); font-size: 13px; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 14px; }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { background: var(--paper); border-radius: 10px; padding: 10px; }
.stat .v { font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.stat .l { font-size: 11.5px; color: var(--muted); }
.missed { display: flex; flex-wrap: wrap; gap: 6px; }
.missed span { background: var(--paper); border-radius: 999px; padding: 4px 10px; font-size: 13px; font-variant-numeric: tabular-nums; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; }
.help { font-size: 12.5px; color: var(--muted); line-height: 1.45; }

#rotate { position: fixed; inset: 0; z-index: 50; background: var(--bg); display: none; align-items: center; justify-content: center; text-align: center; padding: 24px; }
#rotate div { display: flex; flex-direction: column; gap: 12px; align-items: center; font-size: 15px; font-weight: 600; max-width: 26ch; }
#rotate svg { width: 56px; height: 56px; color: var(--accent); }
@media (orientation: portrait) and (max-width: 760px) { #rotate { display: flex; } }
@media (max-height: 420px) { .hud .long { display: none; } }
