:root {
  --bg: #eef5fb;
  --card: #ffffff;
  --ink: #1d2b3a;
  --muted: #5b6b7c;
  --brand: #2f6fb0;
  --brand-2: #4caf50;
  --accent: #ffb300;
  --left: #2f6fb0;
  --right: #e07a1f;
  --oca-body-1: #a9d3f5;
  --oca-body-2: #4d8fd1;
  --oca-edge: #2a5d8f;
  --hole-open: #ffffff;
  --hole-closed: #1b1b1b;
  --tab-h: 72px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101820;
    --card: #1b2733;
    --ink: #e8f0f7;
    --muted: #9fb0c0;
    --oca-edge: #9cc8f0;
    --hole-open: #f4f8fb;
    --hole-closed: #05080b;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  font-size: 18px;
  display: flex;
  flex-direction: column;
}
button { font: inherit; color: inherit; cursor: pointer; }
.hidden { display: none !important; }

.topbar {
  display: flex; align-items: center; gap: 8px;
  padding: calc(env(safe-area-inset-top) + 8px) 16px 8px;
  background: var(--brand); color: #fff;
}
.topbar h1 { font-size: 22px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.back { background: rgba(255,255,255,.2); border: 0; border-radius: 12px; width: 44px; height: 44px; font-size: 24px; color: #fff; }

main { flex: 1; overflow-y: auto; padding: 12px 16px calc(var(--tab-h) + 16px); }
.screen { max-width: 560px; margin: 0 auto; }

/* Onderbalk */
.tabs {
  position: fixed; left: 0; right: 0; bottom: 0;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: var(--card); border-top: 1px solid rgba(0,0,0,.1);
  padding-bottom: env(safe-area-inset-bottom);
  height: calc(var(--tab-h) + env(safe-area-inset-bottom));
}
.tabs button { background: none; border: 0; font-size: 14px; color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; }
.tabs button span { font-size: 26px; }
.tabs button.active { color: var(--brand); font-weight: 700; }

/* Liedjeslijst */
.song-list { display: grid; gap: 12px; }
.song-card {
  display: flex; align-items: center; gap: 14px;
  background: var(--card); border: 0; border-radius: 18px; padding: 16px;
  text-align: left; box-shadow: 0 2px 6px rgba(0,0,0,.08); min-height: 76px;
}
.song-card .emoji { font-size: 34px; }
.song-card .name { font-size: 20px; font-weight: 700; }
.song-card .sub { font-size: 14px; color: var(--muted); }
.section-title { margin: 18px 4px 4px; font-size: 16px; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }

/* Ocarina-tekening */
.oca-wrap { background: var(--card); border-radius: 20px; padding: 8px 8px 4px; box-shadow: 0 2px 6px rgba(0,0,0,.08); }
.oca-svg { width: 100%; height: auto; display: block; }
.oca-small { font-size: 15px; fill: var(--muted); }
.oca-hand { font-size: 15px; font-weight: 700; }
.oca-left { fill: var(--left); }
.oca-right { fill: var(--right); }
.hole { fill: var(--hole-open); stroke-width: 4; transition: fill .08s; }
.hole.left { stroke: var(--left); }
.hole.right { stroke: var(--right); }
.hole.closed { fill: var(--hole-closed); }
.hole.unknown { fill: #ccc; }

.now-note { text-align: center; font-size: 40px; font-weight: 800; margin: 8px 0; min-height: 52px; }
.now-note small { font-size: 18px; color: var(--muted); font-weight: 600; margin-left: 6px; }

/* Notenstrook bij een liedje */
.note-strip { display: flex; flex-wrap: wrap; gap: 6px; padding: 8px 0; }
.nc {
  border: 2px solid transparent; background: var(--card); border-radius: 12px;
  padding: 6px 4px; min-width: 46px; text-align: center; font-weight: 700; font-size: 18px;
  box-shadow: 0 1px 3px rgba(0,0,0,.1); line-height: 1.1;
}
.nc .oct { display: block; font-size: 11px; color: var(--muted); font-weight: 600; min-height: 12px; }
.nc .len { display: block; height: 5px; margin: 4px auto 0; border-radius: 3px; background: var(--brand); opacity: .5; }
.nc.rest { color: var(--muted); font-weight: 400; }
.nc.current { background: var(--accent); color: #1d2b3a; transform: scale(1.12); }
.nc.current .oct { color: #1d2b3a; }
.nc.in-loop { border-color: var(--brand-2); }
.nc.selected { border-color: var(--brand); }

.sticky-top { position: sticky; top: -12px; z-index: 2; background: var(--bg); padding-top: 12px; margin-top: -12px; padding-bottom: 4px; }
.now-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-items: center; margin-top: 8px; }
.now-row .now-note { margin: 0; }
/* Notenschrift */
.sheet { background: #fffdf7; border-radius: 16px; padding: 8px 4px 2px; margin: 8px 0; box-shadow: 0 2px 6px rgba(0,0,0,.08); color: #1d2b3a; min-height: 40px; }
.sheet svg { display: block; }
.sheet .abcjs-annotation { fill: #2f6fb0; }
.sheet .abcjs-note.cur, .sheet .abcjs-rest.cur { fill: #e67e00; stroke: #e67e00; }
.sheet .abcjs-note.cur path { stroke-width: 1.5px; }
.sheet .abcjs-note.in-loop, .sheet .abcjs-rest.in-loop { fill: #2e8b3a; }
.sheet .abcjs-note.sel { fill: #e67e00; }
.sheet .abcjs-note.cur.in-loop { fill: #e67e00; }
.meter-row { display: flex; gap: 8px; margin-top: 4px; }
.meter-row .small-btn.on { background: var(--brand); color: #fff; }
.controls { display: grid; gap: 10px; margin: 8px 0; }
.small-btn.on { background: var(--brand); color: #fff; }
.big-btn {
  border: 0; border-radius: 18px; padding: 16px; font-size: 22px; font-weight: 800;
  background: var(--card); box-shadow: 0 2px 6px rgba(0,0,0,.12); min-height: 64px;
}
.big-btn.play { background: var(--brand-2); color: #fff; }
.big-btn.on { background: var(--brand); color: #fff; }
.small-btn { border: 0; border-radius: 14px; padding: 12px 16px; font-size: 18px; background: var(--card); box-shadow: 0 1px 4px rgba(0,0,0,.12); min-height: 52px; }
.small-btn.danger { background: #d9534f; color: #fff; }
.row-btns { display: flex; flex-wrap: wrap; gap: 10px; margin: 10px 0; }
.row-btns .big-btn { flex: 1; }
.loop-help { background: #e7f6e8; color: #1d4d20; border-radius: 12px; padding: 10px 12px; font-size: 16px; }

.tempo { display: flex; align-items: center; gap: 10px; background: var(--card); border-radius: 16px; padding: 12px; font-size: 26px; }
.tempo input { flex: 1; height: 36px; }
.tempo output { font-size: 18px; font-weight: 700; min-width: 56px; text-align: right; }

/* Notenknoppen */
.note-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 10px 0; }
.nb { border: 0; border-radius: 14px; padding: 10px 4px; background: var(--card); font-size: 22px; font-weight: 800; box-shadow: 0 1px 4px rgba(0,0,0,.12); min-height: 60px; line-height: 1.1; }
.nb small { display: block; font-size: 12px; color: var(--muted); font-weight: 600; }
.nb.sharp { background: #dde6ee; }
@media (prefers-color-scheme: dark) { .nb.sharp { background: #26384a; } }
.nb.active { background: var(--accent); color: #1d2b3a; }

.switch { display: flex; align-items: center; gap: 8px; font-size: 16px; color: var(--muted); margin: 6px 2px; }
.switch input { width: 22px; height: 22px; }
.legend { font-size: 15px; color: var(--muted); display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.dot { display: inline-block; width: 18px; height: 18px; border-radius: 50%; border: 3px solid var(--left); }
.dot.closed { background: var(--hole-closed); }
.dot.open { background: var(--hole-open); margin-left: 10px; }

/* Editor */
.field { display: block; font-size: 16px; color: var(--muted); margin: 8px 0; }
.field input[type=text] { display: block; width: 100%; font-size: 20px; padding: 12px; border-radius: 12px; border: 2px solid #c8d6e3; margin-top: 4px; background: var(--card); color: var(--ink); }
.field input[type=range] { display: block; width: 100%; height: 36px; }
.edit-notes { min-height: 70px; background: var(--card); border-radius: 14px; padding: 8px; display: flex; flex-wrap: wrap; gap: 6px; align-content: flex-start; }
.edit-notes .empty { color: var(--muted); font-size: 16px; padding: 8px; }
.dur-row { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; margin: 10px 0; }
.dur { border: 2px solid transparent; border-radius: 12px; background: var(--card); padding: 6px 2px; font-size: 26px; line-height: 1; min-height: 58px; }
.dur small { display: block; font-size: 11px; color: var(--muted); }
.dur.active { border-color: var(--brand); background: #dceafa; }
@media (prefers-color-scheme: dark) { .dur.active { background: #22415f; } }

.soon { text-align: center; padding: 40px 10px; font-size: 20px; }
.soon-icon { font-size: 80px; }

.toast { position: fixed; left: 50%; bottom: calc(var(--tab-h) + 20px); transform: translateX(-50%); background: #222; color: #fff; padding: 12px 18px; border-radius: 14px; font-size: 17px; z-index: 10; }
