/* Layout: one column — top bar, title, Opzoeken / Herkennen / Favorieten, then the chord card with the big diagram, the root and type pickers, all voicings, chord facts and recent chords */
:root {
  --bg: #17110e;
  --surface: #241a15;
  --surface-2: #2f231c;
  --line: #4a3a30;
  --accent: #ff6b2c;
  --accent-text: #ff8a55;
  --accent-deep: #b8461c;
  --on-accent: #17110e;
  --focus: #ffbd4a;
  --text: #f7ede1;
  --muted: #b5a191;
  --bust: #c0392b;
  --on-bust: #ffffff;
  --danger-text: #ff9a8f;
  --glow: rgba(255, 107, 44, .16);
  --scrim: rgba(8, 5, 4, .6);
  --shadow: rgba(0, 0, 0, .5);
  --switch-off: #4a3a30;
  --switch-knob: #f7ede1;
  --star: #ffbd4a;
  --dg-grid: #8b7563;
  --dg-string: #cdbcaa;
  --dg-nut: #f7ede1;
  --dg-dot: #f7ede1;
  --dg-dot-ink: #17110e;
  --dg-root: #ff6b2c;
  --dg-root-ink: #17110e;
  --dg-mute: #b5a191;
  --dg-label: #b5a191;
  --dg-label-root: #ff8a55;
  --display: 'Bagel Fat One', 'Arial Black', system-ui, sans-serif;
  --body: 'Rethink Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --chord-font: var(--display);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { overflow-x: hidden; }
body {
  margin: 0; min-height: 100vh; overflow-x: hidden; overscroll-behavior: none;
  background: radial-gradient(130% 55% at 50% 105%, var(--glow), transparent 62%), var(--bg);
  color: var(--text); font-family: var(--body); font-size: 16px; line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; }
button:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible, [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
h1, h2, h3, p, figure, dl, dd { margin: 0; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
#app {
  max-width: 560px; margin: 0 auto; min-height: 100vh; min-height: 100dvh;
  padding-top: env(safe-area-inset-top, 0px);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(48px + env(safe-area-inset-bottom, 0px));
  display: flex; flex-direction: column; gap: 12px;
}
.view { display: grid; gap: 12px; min-width: 0; }

/* ---------- buttons and controls ---------- */
.btn {
  appearance: none; border: 0; cursor: pointer; width: 100%; min-height: 50px; padding: 0 18px; border-radius: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; font-weight: 800; font-size: 17px;
}
.btn:active { transform: translateY(2px); }
.btn:disabled { opacity: .5; cursor: default; transform: none; }
.btn.primary { background: var(--accent); color: var(--on-accent); box-shadow: 0 3px 0 var(--accent-deep); }
.btn.ghost { background: var(--surface); color: var(--text); border: 1.5px solid var(--line); }
.btn.text { background: transparent; color: var(--accent-text); min-height: 44px; }
.btn.small { width: auto; min-height: 44px; padding: 0 10px; font-size: 15px; border-radius: 12px; }
.btn svg { width: 18px; height: 18px; flex: none; }
.icon-btn { appearance: none; flex: none; width: 46px; height: 46px; border-radius: 14px; cursor: pointer; border: 1.5px solid var(--line); background: var(--surface); color: var(--text); display: grid; place-items: center; padding: 0; }
.icon-btn svg { width: 22px; height: 22px; }
.icon-btn:disabled { opacity: .4; cursor: default; }
.segmented { display: inline-flex; flex: none; gap: 2px; padding: 3px; border-radius: 13px; background: var(--bg); }
.segmented button { appearance: none; border: 0; cursor: pointer; min-height: 44px; padding: 0 12px; border-radius: 10px; background: none; color: var(--muted); font-weight: 700; font-size: 15px; white-space: nowrap; }
.segmented button[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }
.segmented.wide { display: flex; width: 100%; }
.segmented.wide button { flex: 1 1 0; min-width: 0; padding: 0 4px; }
.view-switch { background: var(--surface); }
.view-switch .count { display: inline-grid; place-items: center; min-width: 22px; height: 22px; padding: 0 6px; margin-left: 2px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-size: 13px; }
.view-switch button[aria-checked="true"] .count { background: var(--on-accent); color: var(--accent); }
.switch { appearance: none; position: relative; flex: none; width: 60px; height: 44px; padding: 0; border: 0; background: none; cursor: pointer; }
.switch::before { content: ''; position: absolute; left: 4px; right: 4px; top: 7px; bottom: 7px; border-radius: 999px; background: var(--switch-off); transition: background-color .2s ease; }
.switch[aria-checked="true"]::before { background: var(--accent); }
.switch-knob { position: absolute; left: 7px; top: 10px; width: 24px; height: 24px; border-radius: 50%; background: var(--switch-knob); box-shadow: 0 2px 4px var(--shadow); transition: translate .2s ease; }
.switch[aria-checked="true"] .switch-knob { translate: 22px 0; }

/* ---------- top ---------- */
.topbar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; padding-top: 10px; }
.topbar > :first-child { justify-self: start; }
.topbar .icon-btn { justify-self: end; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; padding: 0 4px; color: var(--muted); font-weight: 700; text-decoration: none; }
.title { font-family: var(--display); font-weight: 400; font-size: clamp(28px, 8vw, 38px); line-height: 1; text-align: center; white-space: nowrap; }
.box { background: var(--surface); border-radius: 18px; padding: 14px; display: grid; gap: 12px; min-width: 0; }
.box-title { font-weight: 800; font-size: 17px; padding-left: 2px; }
.box-title .muted, .muted { color: var(--muted); font-weight: 700; }
.hint { color: var(--muted); font-size: 14.5px; }

/* ---------- search ---------- */
.search {
  display: flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 6px 0 14px; border-radius: 16px;
  background: var(--surface); border: 1.5px solid var(--line); cursor: text;
}
.search:focus-within { border-color: var(--accent-text); }
.search-icon { display: grid; place-items: center; color: var(--muted); }
.search-icon svg { width: 20px; height: 20px; }
.search input {
  flex: 1; min-width: 0; min-height: 48px; border: 0; background: none; padding: 0; outline: none;
  font-size: 18px; font-weight: 700; color: var(--text);
}
.search input::placeholder { color: var(--muted); font-weight: 500; }
.search input:focus-visible { outline: none; }
.search-msg { margin-top: -6px; padding: 0 4px; }
.search-msg:empty { display: none; }

/* ---------- chord card ---------- */
.chord-card { gap: 10px; padding-bottom: 12px; }
.chord-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; }
.chord-title { min-width: 0; padding: 2px 0 0 2px; }
.chord-name { font-family: var(--chord-font); font-weight: 400; font-size: 42px; line-height: 1; overflow-wrap: anywhere; }
.chord-full { color: var(--muted); font-weight: 600; font-size: 15px; margin-top: 4px; }
.chord-full b { color: var(--text); }
.star svg { width: 24px; height: 24px; fill: none; }
.star.on { color: var(--star); border-color: var(--star); }
.star.on svg { fill: currentColor; }
.capo-line { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; color: var(--muted); font-weight: 600; font-size: 15px; }
.capo-line b { color: var(--text); font-size: 17px; }
.tag { display: inline-flex; align-items: center; min-height: 26px; padding: 0 10px; border-radius: 999px; background: var(--surface-2); color: var(--text); font-weight: 700; font-size: 14px; }
.diagram-stage { display: grid; place-items: center; touch-action: pan-y; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; padding-top: 2px; }
.diagram-stage .diagram { width: min(100%, 262px); height: auto; overflow: visible; }
.empty-diagram { display: grid; place-items: center; min-height: 140px; text-align: center; color: var(--muted); font-weight: 600; padding: 12px; border-radius: 14px; background: var(--surface-2); }
.voicing-nav { display: grid; grid-template-columns: 46px 1fr 46px; align-items: center; gap: 8px; }
.voicing-meta { display: grid; justify-items: center; text-align: center; gap: 1px; min-width: 0; }
.voicing-pos { font-weight: 800; font-size: 16px; }
.voicing-sub { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 2px 10px; color: var(--muted); font-weight: 600; font-size: 14px; }
.voicing-label:empty { display: none; }
.diff { display: inline-flex; align-items: center; gap: 5px; }
.diff-dots { display: inline-flex; gap: 3px; }
.diff-dots i { width: 7px; height: 7px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px var(--muted); }
.diff-dots i.on { background: var(--muted); }
.card-actions { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.card-actions .segmented button { font-size: 14px; padding: 0 10px; }
.btn.play { width: auto; min-height: 50px; padding: 0 18px; flex: none; }
.sound-hint {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 4px 8px;
  padding: 2px 4px 2px 14px; border-radius: 12px; background: var(--surface-2); color: var(--text); font-weight: 600; font-size: 15px;
}

/* ---------- diagram ---------- */
.diagram { display: block; font-family: var(--body); }
.dg-fret { stroke: var(--dg-grid); stroke-width: 1.5; shape-rendering: crispEdges; }
.dg-string { stroke: var(--dg-string); shape-rendering: crispEdges; }
.dg-string.muted { opacity: .55; }
.dg-nut { fill: var(--dg-nut); }
.dg-fr { fill: var(--muted); font-weight: 800; font-size: 14px; }
.dg-mute { stroke: var(--dg-mute); stroke-width: 2.4; stroke-linecap: round; fill: none; }
.dg-open { fill: none; stroke: var(--dg-nut); stroke-width: 2.2; }
.dg-open.root { stroke: var(--dg-root); stroke-width: 3; }
.dg-dot, .dg-barre { fill: var(--dg-dot); }
.dg-dot.root { fill: var(--dg-root); }
.dg-root-ring { fill: none; stroke: var(--dg-root); stroke-width: 3; }
.dg-finger { fill: var(--dg-dot-ink); font-weight: 800; font-size: 15px; }
.dg-finger.root { fill: var(--dg-root-ink); }
.dg-label { fill: var(--dg-label); font-weight: 700; font-size: 14px; }
.dg-label.root { fill: var(--dg-label-root); font-weight: 800; }
.dg-hit { fill: transparent; cursor: pointer; }
.diagram.small .dg-fret { stroke-width: 2; }
.diagram.small .dg-dot, .diagram.small .dg-barre { fill: var(--dg-dot); }
.diagram.small .dg-dot.root { fill: var(--dg-root); }
.diagram.small .dg-fr { font-size: 17px; }

/* ---------- pickers ---------- */
.pickers { gap: 10px; }
.picker-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.segmented.accidental button { min-width: 48px; font-size: 18px; padding: 0 10px; }
.root-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 6px; }
.root-btn {
  appearance: none; cursor: pointer; min-width: 0; min-height: 52px; padding: 0 2px; border-radius: 13px;
  border: 0; background: var(--surface-2); color: var(--text); font-family: var(--chord-font); font-size: 22px; line-height: 1;
}
.root-btn.black { background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--line); }
.root-btn[aria-checked="true"] { background: var(--accent); color: var(--on-accent); box-shadow: none; }
.group-tabs { display: flex; gap: 2px; padding: 3px; border-radius: 13px; background: var(--bg); overflow-x: auto; scrollbar-width: none; }
.group-tabs::-webkit-scrollbar { display: none; }
.group-tabs button {
  appearance: none; border: 0; cursor: pointer; flex: 1 0 auto; min-height: 44px; padding: 0 7px; border-radius: 10px;
  background: none; color: var(--muted); font-weight: 700; font-size: 13.5px; white-space: nowrap;
}
.group-tabs button[aria-selected="true"] { background: var(--surface-2); color: var(--text); box-shadow: inset 0 0 0 1.5px var(--line); }
.type-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.type-chip {
  appearance: none; cursor: pointer; flex: 1 0 auto; min-width: 72px; min-height: 46px; padding: 0 12px; border-radius: 12px; border: 0;
  background: var(--surface-2); color: var(--text); font-weight: 800; font-size: 16px; white-space: nowrap; line-height: 1.1;
}
.type-chip[aria-checked="true"] { background: var(--accent); color: var(--on-accent); }

/* ---------- all voicings ---------- */
.mini-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.mini {
  appearance: none; cursor: pointer; min-width: 0; padding: 8px 6px 6px; border-radius: 14px; border: 2px solid transparent;
  background: var(--surface-2); color: var(--text); display: grid; justify-items: center; gap: 2px;
}
.mini .diagram { width: 100%; max-width: 110px; height: auto; }
.mini.on { border-color: var(--accent); background: var(--bg); }
.mini-cap { display: block; font-size: 12px; font-weight: 700; color: var(--muted); max-width: 100%; text-align: center; line-height: 1.2; text-wrap: balance; }
.mini-cap b { color: var(--text); font-size: 14px; }

/* ---------- info ---------- */
.note-chips { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.note-chips li {
  min-width: 52px; padding: 6px 10px; border-radius: 12px; background: var(--surface-2); display: grid; justify-items: center; line-height: 1.15;
}
.note-chips b { font-family: var(--chord-font); font-weight: 400; font-size: 22px; }
.note-chips span { color: var(--muted); font-weight: 700; font-size: 13px; }
.note-chips li.root { box-shadow: inset 0 0 0 2px var(--dg-root); }
.note-chips li.root span { color: var(--dg-label-root); }
.facts { display: grid; gap: 8px; }
.facts div { display: grid; gap: 1px; }
.facts dt { color: var(--muted); font-weight: 700; font-size: 13.5px; }
.facts dd { font-weight: 700; overflow-wrap: anywhere; }
.facts .tab { font-variant-numeric: tabular-nums; letter-spacing: .12em; }
.chord-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chord-chip {
  appearance: none; cursor: pointer; min-height: 44px; min-width: 52px; padding: 0 14px; border-radius: 999px; border: 0;
  background: var(--surface-2); color: var(--text); font-weight: 800; font-size: 16px;
}

/* ---------- herkennen ---------- */
.id-result { justify-items: center; text-align: center; gap: 6px; min-height: 132px; align-content: center; }
.id-name { font-family: var(--chord-font); font-size: 52px; line-height: 1; overflow-wrap: anywhere; }
.id-name.empty { font-size: 30px; color: var(--muted); }
.id-alts { justify-content: center; }
.fretboard-box { gap: 10px; }
.fretboard {
  display: grid; grid-template-columns: 30px repeat(6, minmax(0, 1fr)); justify-items: stretch; align-items: stretch;
  margin-right: 30px; touch-action: manipulation;
}
.fret-no { display: grid; place-items: center; color: var(--muted); font-weight: 700; font-size: 13px; }
.string-mark {
  appearance: none; border: 0; cursor: pointer; min-height: 44px; min-width: 0; background: none; color: var(--text);
  font-weight: 800; font-size: 20px; line-height: 1; border-radius: 10px;
}
.string-mark.muted { color: var(--muted); }
.string-mark.away { color: var(--dg-root); }
.fret-cell {
  appearance: none; border: 0; cursor: pointer; position: relative; min-width: 0; min-height: 50px; padding: 0; background: none;
  display: grid; place-items: center;
  border-bottom: 2px solid var(--dg-grid);
}
.fret-cell::before { content: ''; position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--dg-string); }
.fretboard.at-nut .fret-cell.first { border-top: 6px solid var(--dg-nut); }
.fretboard:not(.at-nut) .fret-cell.first { border-top: 2px solid var(--dg-grid); }
.fret-dot { position: relative; width: 30px; height: 30px; border-radius: 50%; transform: scale(0); transition: transform .12s ease; background: var(--dg-dot); }
.fret-cell.on .fret-dot { transform: scale(1); }
.fret-cell:hover .fret-dot { transform: scale(.45); opacity: .5; }
.fret-cell.on:hover .fret-dot { transform: scale(1); opacity: 1; }
.string-note { display: grid; place-items: center; min-height: 28px; color: var(--muted); font-weight: 700; font-size: 14px; }
.pos-row { display: flex; align-items: center; justify-content: center; gap: 14px; }
.pos-text { min-width: 92px; text-align: center; font-weight: 800; }
.btn-row { display: grid; grid-template-columns: auto 1fr; gap: 8px; }
.btn-row .btn.ghost { width: auto; }
.btn-row .btn.play { width: 100%; }

/* ---------- favorieten ---------- */
.fav-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.fav-card { position: relative; min-width: 0; }
.fav-open {
  appearance: none; cursor: pointer; width: 100%; height: 100%; padding: 12px 10px 14px; border-radius: 18px; border: 0;
  background: var(--surface); color: var(--text); display: grid; justify-items: center; align-content: start; gap: 2px; text-align: center;
}
.fav-open .diagram { width: 100%; max-width: 128px; height: auto; margin-top: 18px; }
.fav-name { font-family: var(--chord-font); font-size: 26px; line-height: 1.1; margin-top: 4px; overflow-wrap: anywhere; }
.fav-sub { color: var(--muted); font-weight: 600; font-size: 13px; line-height: 1.2; }
.fav-card .star { position: absolute; top: 6px; right: 6px; width: 44px; height: 44px; border: 0; background: none; }
.empty-favs { text-align: center; justify-items: center; padding: 28px 18px; }
@media (min-width: 640px) {
  #app { max-width: 760px; }
  .mini-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .fav-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

/* ---------- sheets, modal ---------- */
.backdrop { position: fixed; inset: 0; z-index: 20; background: var(--scrim); animation: fade .2s ease; }
.sheet {
  position: fixed; z-index: 21; bottom: 0; left: 50%; translate: -50% 0; width: min(100%, 560px); max-height: 88%; overflow-y: auto;
  border-radius: 22px 22px 0 0; background: var(--surface); display: grid; gap: 14px;
  padding-top: 10px; padding-left: max(18px, env(safe-area-inset-left, 0px)); padding-right: max(18px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  box-shadow: 0 -10px 40px var(--shadow); animation: rise .25s cubic-bezier(.2, .9, .3, 1);
}
.grabber { width: 40px; height: 5px; border-radius: 3px; background: var(--line); justify-self: center; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.sheet-head h3 { font-family: var(--display); font-weight: 400; font-size: 24px; }
.close-btn { appearance: none; border: 0; width: 44px; height: 44px; border-radius: 12px; background: var(--surface-2); color: var(--text); cursor: pointer; display: grid; place-items: center; }
.close-btn svg { width: 18px; height: 18px; }
.menu-list { display: grid; gap: 6px; }
.menu-group { color: var(--muted); font-weight: 700; font-size: 13.5px; padding: 0 4px; }
.menu-item {
  appearance: none; border: 0; cursor: pointer; width: 100%; min-height: 54px; padding: 0 14px; border-radius: 14px;
  background: var(--surface-2); color: var(--text); text-align: left; font-weight: 700; font-size: 16.5px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.menu-item.static { cursor: default; padding-block: 8px; }
.menu-item.home { color: var(--accent-text); }
.select {
  appearance: none; min-height: 44px; max-width: 100%; padding: 0 34px 0 12px; border-radius: 12px; border: 1.5px solid var(--line); cursor: pointer;
  background: var(--bg) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%23999' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
  color: var(--text); font-weight: 700; font-size: 16px;
}
.stepper { display: inline-flex; align-items: center; gap: 4px; padding: 3px; border-radius: 13px; background: var(--bg); }
.step-btn { appearance: none; border: 0; cursor: pointer; width: 44px; height: 44px; border-radius: 10px; background: var(--surface-2); color: var(--text); font-size: 22px; font-weight: 700; line-height: 1; }
.step-btn:disabled { opacity: .4; cursor: default; }
.step-val { min-width: 56px; text-align: center; font-weight: 800; }
.modal-backdrop { position: fixed; inset: 0; z-index: 40; background: var(--scrim); animation: fade .2s ease; }
.modal {
  position: fixed; z-index: 41; left: 50%; top: 50%; translate: -50% -50%; width: min(calc(100% - 48px), 360px);
  padding: 20px; border-radius: 20px; background: var(--surface); box-shadow: 0 20px 60px var(--shadow);
  display: grid; gap: 10px; animation: pop .2s ease;
}
.modal h3 { font-family: var(--display); font-weight: 400; font-size: 24px; line-height: 1.1; }
.modal p { color: var(--muted); }
.modal-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 6px; }
.modal-actions .btn { min-height: 48px; font-size: 16px; padding: 0 10px; }

@keyframes rise { from { translate: -50% 30px; opacity: 0; } to { translate: -50% 0; opacity: 1; } }
@keyframes fade { from { opacity: 0; } }
@keyframes pop { from { opacity: 0; scale: .95; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
