:root {
  --ink: #f5f1e7;
  --muted: #9eb1ac;
  --bg: #061211;
  --surface: #0b201e;
  --surface-2: #102b28;
  --line: #22413d;
  --gold: #f3c969;
  --lime: #b9ef4a;
  --teal: #43c8b4;
  --danger: #ff7c78;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; width: 100%; height: 100%; min-height: 0; overflow: hidden; background: var(--bg); color: var(--ink); }
body {
  min-height: 100vh;
  min-height: 100dvh;
  overflow: hidden;
  background:
    radial-gradient(circle at 90% 0%, rgba(67, 200, 180, .13), transparent 32%),
    linear-gradient(180deg, #071a19 0%, var(--bg) 50%);
}
button, input, select, textarea { font: inherit; }
button { color: inherit; }
.hidden { display: none !important; }

#app { width: 100%; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
.topbar {
  padding: calc(12px + var(--safe-top)) 18px 12px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid rgba(255,255,255,.06);
  background: rgba(6,18,17,.92);
  backdrop-filter: blur(18px);
  z-index: 10;
}
.brand { min-width: 0; flex: 1; display: flex; align-items: center; gap: 10px; }
.brand-button { padding: 0; border: 0; color: inherit; text-align: left; background: transparent; }
.brand-mark { width: 36px; height: 36px; border-radius: 10px; object-fit: cover; box-shadow: 0 0 0 1px rgba(255,255,255,.1); }
.eyebrow { color: var(--gold); font-size: 9px; font-weight: 800; letter-spacing: .16em; }
h1 { margin: 1px 0 0; font-size: 18px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 42px; height: 42px; border: 1px solid var(--line); border-radius: 13px;
  background: var(--surface); font-size: 24px; display: grid; place-items: center;
}
.icon-btn:active, .nav-item:active, .button:active { transform: scale(.97); }

main { min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 18px 16px 28px; scroll-behavior: smooth; scrollbar-width: none; }
main::-webkit-scrollbar { display: none; }
.bottom-nav {
  display: grid; grid-template-columns: repeat(5, 1fr);
  padding: 7px 8px calc(7px + var(--safe-bottom));
  background: rgba(6,18,17,.96); border-top: 1px solid var(--line); z-index: 10;
}
.nav-item {
  min-height: 54px; border: 0; border-radius: 14px; background: transparent; color: var(--muted);
  display: grid; place-content: center; gap: 2px;
}
.nav-item span { font-size: 19px; font-weight: 800; line-height: 1; }
.nav-item small { font-size: 10px; }
.nav-item.active { color: var(--gold); background: rgba(243,201,105,.09); }

.hero {
  position: relative; overflow: hidden; border: 1px solid rgba(243,201,105,.24); border-radius: 24px;
  padding: 24px 20px; background:
    linear-gradient(135deg, rgba(243,201,105,.16), rgba(67,200,180,.06)),
    var(--surface);
  box-shadow: 0 18px 50px rgba(0,0,0,.24);
}
.hero::after { content: "♩"; position: absolute; right: 18px; bottom: -28px; font-size: 130px; color: rgba(243,201,105,.07); transform: rotate(8deg); }
.kicker { margin: 0 0 7px; color: var(--gold); font-size: 11px; letter-spacing: .14em; font-weight: 800; }
.hero h2 { margin: 0; max-width: 290px; font-size: 29px; line-height: 1.06; }
.hero p { max-width: 300px; color: var(--muted); line-height: 1.45; margin: 10px 0 18px; }
.button {
  min-height: 46px; padding: 0 16px; border: 1px solid var(--line); border-radius: 14px;
  background: var(--surface-2); font-weight: 800;
}
.button.primary { color: #17200b; border-color: transparent; background: linear-gradient(135deg, var(--gold), var(--lime)); }
.button.ghost { background: transparent; }
.button.danger { color: var(--danger); }
.button.full { width: 100%; }
.button.small { min-height: 36px; padding: 0 12px; font-size: 12px; }
.button-row { display: flex; gap: 10px; flex-wrap: wrap; }
.section-head { margin: 25px 2px 11px; display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.section-head h2 { margin: 0; font-size: 18px; }
.section-head p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }
.text-link { border: 0; background: transparent; color: var(--gold); font-weight: 750; }

.quick-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-card {
  min-height: 112px; padding: 16px; text-align: left; border: 1px solid var(--line); border-radius: 19px;
  background: linear-gradient(145deg, var(--surface-2), var(--surface));
}
.quick-card strong { display: block; font-size: 15px; margin: 10px 0 4px; }
.quick-card small { color: var(--muted); line-height: 1.35; }
.quick-icon { display: grid; place-items: center; width: 33px; height: 33px; border-radius: 10px; background: rgba(67,200,180,.13); color: var(--teal); font-weight: 900; }

.list { display: grid; gap: 10px; }
.song-card, .setlist-card {
  width: 100%; display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 13px;
  padding: 13px; text-align: left; border: 1px solid var(--line); border-radius: 17px; background: var(--surface);
}
.key-badge {
  width: 44px; height: 44px; display: grid; place-items: center; border-radius: 13px;
  background: rgba(243,201,105,.12); color: var(--gold); font-weight: 900;
}
.song-copy { min-width: 0; }
.song-copy strong { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.song-copy small { display: block; margin-top: 3px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chev { color: var(--muted); font-size: 22px; }
.empty { padding: 26px 18px; border: 1px dashed var(--line); border-radius: 18px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); margin-bottom: 5px; }

.search { display: flex; gap: 9px; margin-bottom: 14px; }
.field, .search input, .search select, textarea {
  width: 100%; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 14px; outline: none;
}
.search input, .search select { min-height: 46px; padding: 0 14px; }
.search input:focus, .field:focus, textarea:focus { border-color: var(--teal); box-shadow: 0 0 0 3px rgba(67,200,180,.1); }

.form { display: grid; gap: 14px; }
.form label { display: grid; gap: 7px; color: var(--muted); font-size: 12px; font-weight: 700; }
.field { min-height: 48px; padding: 0 13px; }
textarea.field { min-height: 210px; resize: vertical; padding: 13px; line-height: 1.5; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; }
.help-card { padding: 14px; border-radius: 16px; background: rgba(67,200,180,.08); border: 1px solid rgba(67,200,180,.2); color: var(--muted); font-size: 12px; line-height: 1.5; }
.help-card code { color: var(--gold); }
.chip-row { display: flex; gap: 7px; overflow-x: auto; padding-bottom: 3px; scrollbar-width: none; }
.chip {
  flex: none; min-height: 38px; padding: 0 13px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--surface); color: var(--muted); font-size: 12px; font-weight: 800;
}
.chip.active { color: #071211; background: var(--gold); border-color: var(--gold); }
.segment { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 4px; border-radius: 14px; background: var(--surface); }
.segment button { min-height: 39px; border: 0; border-radius: 10px; background: transparent; color: var(--muted); font-size: 12px; font-weight: 800; }
.segment button.active { color: var(--ink); background: var(--surface-2); box-shadow: 0 1px 4px rgba(0,0,0,.25); }

.song-toolbar { position: sticky; top: -18px; z-index: 5; margin: -18px -16px 14px; padding: 10px 16px; background: rgba(6,18,17,.95); border-bottom: 1px solid var(--line); backdrop-filter: blur(15px); }
.song-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.meta-pill { padding: 6px 9px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; color: var(--muted); font-size: 11px; }
.chart { padding-bottom: 100px; font-size: var(--chart-size, 20px); }
.chart-section { margin: 22px 0; }
.chart-section h3 { margin: 0 0 10px; color: var(--gold); font-size: .72em; letter-spacing: .12em; text-transform: uppercase; }
.chart-line { display: flex; flex-wrap: wrap; align-items: baseline; gap: .48em; min-height: 2.2em; margin: .25em 0; padding: .32em .45em; border-radius: 10px; }
.chart-line:nth-child(even) { background: rgba(255,255,255,.018); }
.chord { position: relative; display: inline-flex; align-items: baseline; min-width: 1.7em; padding: .18em .12em .26em; font-weight: 850; letter-spacing: .015em; }
.chord.full::after { content: ""; position: absolute; left: .06em; right: .06em; bottom: .08em; height: 2px; background: var(--teal); }
.chord.double::after { right: -1.2em; }
.chord.quick { padding: .25em .4em; margin: 0 -.2em; color: var(--gold); background: rgba(243,201,105,.1); }
.chord.hold::after { content: ""; position: absolute; left: .1em; bottom: .05em; width: 3em; border-bottom: 2px dashed var(--gold); }
.dash { color: #607a75; }
.repeat { color: var(--muted); font-size: .7em; }
.chart-note { color: var(--muted); font-size: .76em; font-style: italic; }
.instrument-tip { margin: 8px 0 18px; padding: 12px 13px; border-left: 3px solid var(--lime); background: rgba(185,239,74,.06); color: var(--muted); font-size: 12px; line-height: 1.45; }

.lead-grid { display: grid; gap: 12px; }
.measure-row { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.measure { position: relative; min-height: 84px; padding: 12px 10px 10px; border-left: 2px solid var(--muted); border-right: 2px solid var(--muted); background: rgba(255,255,255,.018); }
.measure::before, .measure::after { content: ""; position: absolute; left: 0; right: 0; height: 1px; background: #54706a; }
.measure::before { top: 24px; box-shadow: 0 7px #54706a, 0 14px #54706a, 0 21px #54706a, 0 28px #54706a; opacity: .55; }
.measure-chords { position: relative; z-index: 1; display: flex; justify-content: space-around; gap: 4px; font-weight: 900; color: var(--gold); }
.measure-slashes { position: relative; z-index: 1; display: flex; justify-content: space-around; padding-top: 18px; color: var(--muted); }

.family-hero { padding: 18px; border-radius: 20px; background: linear-gradient(135deg, rgba(67,200,180,.14), rgba(185,239,74,.05)); border: 1px solid rgba(67,200,180,.25); }
.family-hero h2 { margin: 5px 0; font-size: 26px; }
.family-hero p { color: var(--muted); margin: 0; font-size: 13px; line-height: 1.45; }
.degree-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.degree-card { padding: 12px 5px; text-align: center; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; }
.degree-card b { display: block; color: var(--gold); font-size: 18px; }
.degree-card small { display: block; margin-top: 4px; color: var(--muted); font-size: 10px; }
.progression-card { padding: 14px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); }
.progression-card strong { display: block; margin-bottom: 7px; }
.progression-chords { color: var(--gold); font-size: 20px; font-weight: 850; word-spacing: .3em; }
.progression-card small { display: block; margin-top: 7px; color: var(--muted); }
.quiz { padding: 18px; border-radius: 20px; background: var(--surface); border: 1px solid var(--line); text-align: center; }
.quiz-question { font-size: 21px; font-weight: 800; margin: 10px 0 18px; }
.quiz-options { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.quiz-options button { min-height: 48px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface-2); font-weight: 800; }

.player-card { padding: 17px; border: 1px solid var(--line); border-radius: 20px; background: var(--surface); }
.now-playing { display: grid; grid-template-columns: 48px 1fr; gap: 12px; align-items: center; margin-bottom: 13px; }
.album { width: 48px; height: 48px; border-radius: 13px; display: grid; place-items: center; color: var(--gold); background: rgba(243,201,105,.12); font-size: 22px; }
.now-playing strong, .now-playing small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.now-playing small { color: var(--muted); margin-top: 3px; }
audio { width: 100%; height: 42px; }
.range-row { display: grid; grid-template-columns: 66px 1fr 42px; align-items: center; gap: 8px; margin-top: 12px; color: var(--muted); font-size: 11px; }
input[type="range"] { accent-color: var(--gold); }
.callout { padding: 14px; border: 1px solid rgba(243,201,105,.22); border-radius: 16px; background: rgba(243,201,105,.07); color: var(--muted); font-size: 12px; line-height: 1.45; }

.toast {
  position: fixed; left: 50%; bottom: calc(82px + var(--safe-bottom)); z-index: 50;
  max-width: calc(100% - 32px); padding: 11px 15px; border-radius: 12px; background: #e9f4ef; color: #10221f;
  font-size: 13px; font-weight: 750; transform: translate(-50%, 18px); opacity: 0; pointer-events: none; transition: .22s ease;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.menu-overlay {
  position: fixed; inset: 0; z-index: 100; display: flex; justify-content: flex-end;
  background: rgba(0,0,0,.7); backdrop-filter: blur(6px);
}
.menu-sheet {
  width: min(92vw, 410px); height: 100%; overflow-y: auto;
  padding: calc(18px + var(--safe-top)) 16px calc(22px + var(--safe-bottom));
  background: linear-gradient(180deg, #0c2522, #061211 72%); border-left: 1px solid var(--line);
  box-shadow: -24px 0 60px rgba(0,0,0,.42);
}
.menu-head { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 18px; }
.menu-head h2 { margin: 4px 0 0; font-size: 22px; }
.menu-list { display: grid; gap: 9px; }
.menu-list button {
  display: grid; grid-template-columns: 42px 1fr; grid-template-rows: auto auto; column-gap: 12px;
  min-height: 72px; padding: 11px 13px; text-align: left; color: var(--ink);
  border: 1px solid var(--line); border-radius: 16px; background: var(--surface);
}
.menu-list button > span {
  grid-row: 1 / 3; align-self: center; width: 38px; height: 38px; display: grid; place-items: center;
  border-radius: 11px; color: var(--gold); background: rgba(243,201,105,.1); font-size: 19px; font-weight: 900;
}
.menu-list strong { align-self: end; }
.menu-list small { align-self: start; margin-top: 3px; color: var(--muted); }
.menu-credit { margin: 22px 0 0; text-align: center; color: var(--muted); font-size: 11px; }

@media (min-width: 700px) {
  #app { max-width: 720px; margin: 0 auto; box-shadow: 0 0 60px rgba(0,0,0,.45); }
  .measure-row { grid-template-columns: repeat(4, 1fr); }
}
