@font-face { font-family: 'DM Sans'; font-weight: 400; font-display: swap; src: url(../fonts/dm-sans-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 500; font-display: swap; src: url(../fonts/dm-sans-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'DM Sans'; font-weight: 700; font-display: swap; src: url(../fonts/dm-sans-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fraunces'; font-weight: 600; font-display: swap; src: url(../fonts/fraunces-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fraunces'; font-weight: 700; font-display: swap; src: url(../fonts/fraunces-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'Fraunces'; font-weight: 600; font-style: italic; font-display: swap; src: url(../fonts/fraunces-latin-600-italic.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url(../fonts/jetbrains-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 600; font-display: swap; src: url(../fonts/jetbrains-mono-latin-600-normal.woff2) format('woff2'); }

:root {
  --bg: #121418;
  --bg-2: #181b20;
  --panel: #1d2026;
  --panel-2: #23272e;
  --line: #2e333b;
  --text: #e9e6df;
  --muted: #9a9890;
  --accent: #f0a83a;
  --accent-2: #ffcf7d;
  --accent-ink: #2a1a02;
  --paper: #f5efe2;
  --paper-2: #ece4d2;
  --ink: #1f1b16;
  --ink-soft: #7a6f5d;
  --danger: #e2654f;
  --radius: 14px;
  --shadow: 0 1px 0 rgba(255,255,255,.03) inset, 0 10px 30px rgba(0,0,0,.25);
  --sans: 'DM Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  --serif: 'Fraunces', Georgia, 'Times New Roman', serif;
  --mono: 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; min-height: 100vh;
  background:
    radial-gradient(1200px 500px at 15% -10%, rgba(240,168,58,.08), transparent 60%),
    radial-gradient(900px 500px at 110% 10%, rgba(120,150,255,.05), transparent 60%),
    var(--bg);
  color: var(--text); font: 15px/1.45 var(--sans);
}
button, input, select, textarea { font: inherit; color: inherit; }
a { color: var(--accent-2); }

/* ---------- top bar */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 14px 28px; border-bottom: 1px solid var(--line);
  background: rgba(18,20,24,.7); backdrop-filter: blur(8px);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 10px; font: 700 22px/1 var(--serif); letter-spacing: .2px; color: var(--accent); }
.brand span { color: var(--text); }
.logo { width: 28px; height: 28px; }
.library { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.library select { min-width: 240px; }

main { max-width: 1180px; margin: 0 auto; padding: 22px 28px 40px; display: grid; gap: 18px; }

.panel { background: linear-gradient(180deg, var(--panel), var(--bg-2)); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); }

/* ---------- controls */
select, input[type=number], input[type=text], .title {
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; outline: none;
  transition: border-color .15s, box-shadow .15s;
}
select:focus, input[type=number]:focus, .title:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(240,168,58,.18); }
select { appearance: none; padding-right: 30px; cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%), linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 16px) 52%, calc(100% - 11px) 52%; background-size: 5px 5px; background-repeat: no-repeat; }
select option, select optgroup { background: var(--panel-2); color: var(--text); }

.head { padding: 18px 22px 20px; display: grid; gap: 14px; }
.title { font: italic 600 28px/1.2 var(--serif); background: transparent; border-color: transparent; padding: 4px 8px; margin-left: -8px; width: 100%; }
.title:hover { border-color: var(--line); }
.controls { display: flex; flex-wrap: wrap; gap: 14px 22px; align-items: flex-end; }
.field { display: grid; gap: 6px; }
.field > span { font-size: 11.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 500; }
.field select { min-width: 190px; }
.field.narrow select { min-width: 96px; }
.tempo-row { display: flex; align-items: center; gap: 6px; }
#tempo { width: 72px; text-align: center; font-family: var(--mono); font-weight: 600; -moz-appearance: textfield; }
#tempo::-webkit-inner-spin-button { -webkit-appearance: none; }
#tempoSlider { width: 150px; }
.seg { display: flex; gap: 6px; }

.btn {
  border: 1px solid var(--line); background: var(--panel-2); border-radius: 10px; padding: 8px 14px; cursor: pointer;
  transition: background .15s, border-color .15s, transform .05s; white-space: nowrap;
}
.btn:hover { border-color: #3e444e; background: #2a2f37; }
.btn:active { transform: translateY(1px); }
.btn.ghost { background: transparent; }
.btn.small { padding: 5px 11px; font-size: 13px; }
.btn.icon { width: 36px; height: 38px; padding: 0; font-size: 18px; display: grid; place-items: center; }
.btn.on { background: rgba(240,168,58,.16); border-color: rgba(240,168,58,.6); color: var(--accent-2); }

input[type=range] { -webkit-appearance: none; appearance: none; height: 6px; border-radius: 6px; background: var(--panel-2); outline: none; cursor: pointer;
  background-image: linear-gradient(var(--accent), var(--accent)); background-repeat: no-repeat; background-size: var(--fill, 50%) 100%; }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--text); border: 3px solid var(--accent); box-shadow: 0 1px 4px rgba(0,0,0,.4); }
input[type=range]::-moz-range-thumb { width: 12px; height: 12px; border-radius: 50%; background: var(--text); border: 3px solid var(--accent); }

/* ---------- transport */
.transport { display: flex; align-items: center; gap: 22px; padding: 14px 22px; }
.play {
  width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer; flex: none;
  background: radial-gradient(circle at 35% 30%, var(--accent-2), var(--accent) 60%, #c97f17);
  color: var(--accent-ink); display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(240,168,58,.35), inset 0 -3px 0 rgba(0,0,0,.15);
  transition: transform .1s, box-shadow .2s;
}
.play:hover { transform: scale(1.04); }
.play svg { width: 28px; height: 28px; grid-area: 1/1; }
.play .i-stop { display: none; }
.playing .play .i-play { display: none; }
.playing .play .i-stop { display: block; }
.playing .play { box-shadow: 0 0 0 6px rgba(240,168,58,.15), 0 6px 26px rgba(240,168,58,.5); }

.lcd { flex: 1; display: grid; grid-template-columns: auto 1fr auto; grid-template-rows: auto auto; column-gap: 20px; align-items: center;
  background: #0d0f12; border: 1px solid #262a31; border-radius: 12px; padding: 10px 18px; min-height: 64px; }
.lcd-main { grid-row: 1 / 3; font: 600 30px/1 var(--mono); color: var(--accent); display: flex; align-items: baseline; gap: 6px; min-width: 80px; }
.lcd-main small { font: 500 11px var(--sans); color: var(--muted); text-transform: uppercase; letter-spacing: .12em; }
.beats { display: flex; gap: 8px; }
.beats i { width: 12px; height: 12px; border-radius: 50%; background: #262a31; transition: background .06s, box-shadow .06s; }
.beats i.on { background: var(--accent); box-shadow: 0 0 10px rgba(240,168,58,.7); }
.beats i.on.down { background: var(--accent-2); }
.lcd-sub { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.lcd-chord { grid-column: 3; grid-row: 1 / 3; display: flex; align-items: baseline; gap: 14px; color: var(--text); }
.now-chord .chord .r { font-size: 34px; }
.now-chord .chord .q, .now-chord .chord .a { font-size: 18px; transform: translateY(-13px); }
.next-chord { color: var(--muted); font-size: 13px; display: flex; align-items: baseline; gap: 6px; }
.next-chord .chord .r { font-size: 18px; }
.next-chord .chord .q, .next-chord .chord .a { font-size: 11px; transform: translateY(-7px); }
.lcd-chord .chord .b { color: var(--muted); }

.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; color: var(--muted); font-size: 14px; }
.toggle input { display: none; }
.toggle .sw { width: 38px; height: 22px; border-radius: 22px; background: var(--panel-2); border: 1px solid var(--line); position: relative; transition: background .15s; }
.toggle .sw::after { content: ''; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s, background .15s; }
.toggle input:checked + .sw { background: rgba(240,168,58,.25); border-color: rgba(240,168,58,.6); }
.toggle input:checked + .sw::after { transform: translateX(16px); background: var(--accent); }

/* ---------- lead sheet */
.sheet-wrap { display: grid; gap: 10px; }
.sheet {
  background: linear-gradient(180deg, var(--paper), var(--paper-2)); color: var(--ink);
  border-radius: 6px; padding: 30px 36px 34px; box-shadow: 0 20px 50px rgba(0,0,0,.45), 0 0 0 1px rgba(0,0,0,.2);
  position: relative;
}
.sheet::before { /* subtle paper grain */
  content: ''; position: absolute; inset: 0; border-radius: 6px; pointer-events: none; opacity: .5;
  background-image: radial-gradient(rgba(120,100,60,.08) 1px, transparent 1px); background-size: 3px 3px;
}
.sheet-head { text-align: center; margin-bottom: 22px; position: relative; }
.sheet-title { font: italic 700 30px/1.15 var(--serif); }
.sheet-meta { margin-top: 6px; font-size: 13px; color: var(--ink-soft); letter-spacing: .08em; text-transform: uppercase; }

.grid { display: grid; grid-template-columns: repeat(4, 1fr); position: relative; }
.bar {
  position: relative; height: 84px; border-left: 2px solid var(--ink); border-top: 1px solid rgba(31,27,22,.15); border-bottom: 1px solid rgba(31,27,22,.15);
  cursor: text; transition: background .12s;
}
.bar:nth-child(4n) { border-right: 2px solid var(--ink); }
.bar:last-child { border-right: 2px solid var(--ink); box-shadow: 4px 0 0 -0px var(--paper), 6px 0 0 0 var(--ink); }
.grid .bar:nth-child(n+5) { margin-top: 10px; }
.bar:hover { background: rgba(240,168,58,.07); }
.bar .num {
  position: absolute; top: 4px; left: 6px; font: 600 10.5px var(--mono); color: var(--ink-soft); cursor: pointer; z-index: 3;
  padding: 1px 4px; border-radius: 4px;
}
.bar .num:hover { background: var(--ink); color: var(--paper); }
.bar .raw {
  position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: transparent; outline: none; z-index: 2;
  padding: 18px 12px 8px; color: transparent; caret-color: transparent; font: 500 17px var(--mono);
}
.bar .pretty { position: absolute; inset: 0; display: flex; align-items: center; padding: 14px 12px 6px; gap: 6px; pointer-events: none; overflow: hidden; }
.bar:focus-within { background: #fffaf0; box-shadow: inset 0 0 0 2px var(--accent); }
.bar:focus-within .raw { color: var(--ink); caret-color: var(--ink); }
.bar:focus-within .pretty { visibility: hidden; }
.bar.invalid .pretty { color: var(--danger); }
.bar.invalid::after { content: '?'; position: absolute; right: 6px; top: 4px; font: 700 11px var(--mono); color: var(--danger); }

.chord { flex: 1; min-width: 0; display: flex; align-items: baseline; white-space: nowrap; font-family: var(--serif); }
.chord .r { font-weight: 700; font-size: 30px; line-height: 1; }
.chord .a { font-weight: 600; font-size: 21px; transform: translateY(-7px); margin-left: 1px; }
.chord .q { font-weight: 600; font-size: 16px; transform: translateY(-11px); margin-left: 1px; letter-spacing: -.01em; }
.chord .b { font-weight: 600; font-size: 18px; margin-left: 2px; color: var(--ink-soft); }
.chord.hold { color: var(--ink-soft); font-size: 22px; flex: .5; }
.chord.sim { font: 700 26px var(--serif); color: var(--ink-soft); justify-content: center; }
.pretty.n2 .chord .r, .pretty.n3 .chord .r, .pretty.n4 .chord .r { font-size: 24px; }
.pretty.n2 .chord .q, .pretty.n3 .chord .q, .pretty.n4 .chord .q { font-size: 13.5px; transform: translateY(-9px); }
.pretty.n2 .chord .a, .pretty.n3 .chord .a, .pretty.n4 .chord .a { font-size: 17px; transform: translateY(-6px); }
.pretty.n3 .chord, .pretty.n4 .chord { flex: auto; }
.pretty.n4 .chord .r { font-size: 20px; }
.pretty.n4 .chord .q { font-size: 11.5px; }

.bar .tick { position: absolute; left: 0; right: 0; bottom: 0; height: 4px; display: flex; gap: 2px; padding: 0 2px; opacity: 0; }
.bar .tick i { flex: 1; border-radius: 2px; background: rgba(31,27,22,.12); }
.bar.now { background: rgba(240,168,58,.22); }
.bar.now .tick { opacity: 1; }
.bar.now .tick i.on { background: var(--accent); }
.bar.start .num { background: var(--accent); color: var(--accent-ink); }

.text-editor {
  width: 100%; min-height: 260px; resize: vertical; border: 1px solid rgba(31,27,22,.25); border-radius: 8px;
  background: #fffaf0; color: var(--ink); font: 500 16px/1.9 var(--mono); padding: 14px 16px; outline: none; position: relative;
}
.text-editor:focus { box-shadow: 0 0 0 2px var(--accent); }

.sheet-tools { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; color: var(--muted); font-size: 14px; }
.bars-ctl { display: flex; align-items: center; gap: 10px; }
.help { margin-left: auto; max-width: 560px; }
.help summary { cursor: pointer; color: var(--accent-2); text-align: right; list-style: none; }
.help summary::-webkit-details-marker { display: none; }
.help summary::before { content: '?'; display: inline-grid; place-items: center; width: 18px; height: 18px; margin-right: 6px; border-radius: 50%; border: 1px solid currentColor; font-size: 11px; }
.help div { background: var(--panel); border: 1px solid var(--line); border-radius: 10px; padding: 4px 16px; margin-top: 8px; color: var(--text); font-size: 13.5px; }
.help code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); border-radius: 4px; padding: 1px 5px; color: var(--accent-2); }

/* ---------- mixer */
.mixer { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; padding: 6px; }
.strip { display: grid; gap: 10px; padding: 14px 16px; border-right: 1px solid var(--line); }
.strip:last-child { border-right: 0; }
.strip-name { font-size: 11.5px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 500; }
.strip select { width: 100%; }
.inst-static { padding: 8px 0; color: var(--text); opacity: .8; }
.strip .vol, .strip #masterVol { width: 100%; }
.strip .mute { justify-self: start; }
.strip .mute.on { background: rgba(226,101,79,.18); border-color: rgba(226,101,79,.6); color: #ffb3a5; }
.mute-spacer { height: 29px; }

.foot { text-align: center; color: #5f6067; font-size: 12px; padding: 0 20px 30px; }
.foot a { color: #7d7f88; }

/* ---------- overlays */
.loading { position: fixed; inset: 0; background: rgba(10,11,14,.6); backdrop-filter: blur(4px); display: grid; place-items: center; z-index: 50; }
.loading[hidden] { display: none; }
.loading-card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 24px 28px; width: min(360px, 90vw); box-shadow: var(--shadow); }
.loading-title { font: italic 600 22px var(--serif); margin-bottom: 14px; }
.bar-outer { height: 8px; border-radius: 8px; background: var(--panel-2); overflow: hidden; }
.bar-inner { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .15s; }

.toast { position: fixed; left: 50%; bottom: 28px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none;
  background: var(--text); color: var(--bg); padding: 10px 18px; border-radius: 10px; font-weight: 500; transition: opacity .2s, transform .2s; z-index: 60; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ---------- responsive */
@media (max-width: 820px) {
  main { padding: 16px; }
  .topbar { padding: 12px 16px; }
  .library select { min-width: 0; flex: 1 1 100%; }
  .library { width: 100%; }
  .mixer { grid-template-columns: repeat(2, 1fr); }
  .strip:nth-child(2n) { border-right: 0; }
  .sheet { padding: 22px 16px 24px; }
  #tempoSlider { width: 110px; }
}
@media (max-width: 560px) {
  .grid { grid-template-columns: repeat(2, 1fr); }
  .bar:nth-child(4n) { border-right: 0; }
  .bar:nth-child(2n) { border-right: 2px solid var(--ink); }
  .grid .bar:nth-child(n+3) { margin-top: 10px; }
  .transport { flex-wrap: wrap; gap: 14px; }
  .lcd { order: 3; flex-basis: 100%; }
  .now-chord .chord .r { font-size: 26px; }
  .next-chord { display: none; }
  .field select { min-width: 150px; }
  #tempoSlider { display: none; }
  .help { margin-left: 0; }
}

/* simple band modes: the full-band mixer strips don't apply */
body[data-band="guitar"] .mixer .strip[data-part]:not([data-part="comp"]),
body[data-band="piano"] .mixer .strip[data-part]:not([data-part="comp"]) { opacity: .35; pointer-events: none; }
body[data-band="guitar"] .mixer .strip[data-part="comp"] .inst,
body[data-band="piano"] .mixer .strip[data-part="comp"] .inst { opacity: .35; pointer-events: none; }
