:root {
  --bg: #0c0d11; --bg2: #111319; --panel: #161920; --panel2: #1d2129; --panel3: #252a34;
  --line: #262b35; --line2: #333a47; --text: #e6e8ee; --dim: #8b92a1; --faint: #5b6271;
  --accent: #f5a524; --accent-ink: #1b1204; --accent-soft: rgba(245,165,36,.14);
  --teal: #34d399; --blue: #60a5fa; --red: #f43f5e;
  --r: 10px; --mono: ui-monospace, 'JetBrains Mono', 'SF Mono', Menlo, monospace;
}
* { box-sizing: border-box; }
html { color-scheme: dark; }
body { margin: 0; background: var(--bg); color: var(--text); font: 13.5px/1.45 Inter, system-ui, -apple-system, 'Segoe UI', sans-serif; -webkit-font-smoothing: antialiased; }
button, select, input { font: inherit; color: inherit; }
h2 { margin: 0; font-size: 14px; font-weight: 650; letter-spacing: .01em; }
h3 { margin: 16px 0 8px; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .08em; color: var(--dim); }
.dim { color: var(--dim); font-size: 12.5px; }
.mono { font-family: var(--mono); }
.grow { flex: 1; }
[hidden] { display: none !important; }
kbd { font-family: var(--mono); font-size: 11px; background: var(--panel3); border: 1px solid var(--line2); border-bottom-width: 2px; border-radius: 4px; padding: 0 5px; color: var(--text); }

/* controls */
button, .btn {
  background: var(--panel2); border: 1px solid var(--line2); border-radius: 7px; padding: 5px 11px; cursor: pointer;
  transition: background .12s, border-color .12s, color .12s; white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
button:hover, .btn:hover { background: var(--panel3); border-color: #444c5c; }
button:active { transform: translateY(1px); }
button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 650; }
button.primary:hover { background: #ffb43d; }
button.danger:hover { border-color: var(--red); color: #fda4af; }
button.on, button.tog.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
button.primary.on { background: #ffb43d; }
button.recb.on { background: rgba(244,63,94,.18); border-color: var(--red); color: #fda4af; }
select, input[type=number], input:not([type]), input[type=text] {
  background: var(--bg2); border: 1px solid var(--line2); border-radius: 7px; padding: 5px 8px; outline: none; min-width: 0;
}
select:focus, input:focus { border-color: var(--accent); }
input[type=number] { width: 64px; }
input[type=range] { accent-color: var(--accent); width: 90px; }
.field { display: inline-flex; align-items: center; gap: 7px; }
.field > span:first-child { color: var(--dim); font-size: 12px; }
.field.full { display: flex; margin-bottom: 8px; } .field.full > span:first-child { width: 46px; } .field.full input { flex: 1; }
.chk { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); cursor: pointer; }
.seg { display: inline-flex; }
.seg > button { border-radius: 0; margin-left: -1px; }
.seg > button:first-child { border-radius: 7px 0 0 7px; margin-left: 0; }
.seg > button:last-child { border-radius: 0 7px 7px 0; }
.segLabel { padding: 5px 10px; border-top: 1px solid var(--line2); border-bottom: 1px solid var(--line2); font-size: 12px; color: var(--dim); }
.row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; margin: 8px 0; }

/* header */
header.top { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 10px 18px; background: var(--bg2); border-bottom: 1px solid var(--line); }
.brand { font-weight: 800; font-size: 15px; letter-spacing: .02em; display: flex; align-items: center; gap: 7px; margin-right: 6px; }
.logo { color: var(--accent); }
.tuning { gap: 8px; }
#tuneStrings { display: flex; gap: 3px; }
.tstr { display: flex; flex-direction: column; align-items: center; background: var(--bg); border: 1px solid var(--line2); border-radius: 7px; overflow: hidden; width: 40px; }
.tstr b { font-family: var(--mono); font-size: 11.5px; padding: 1px 0; }
.tstr button { border: 0; border-radius: 0; padding: 0; width: 100%; justify-content: center; height: 14px; font-size: 10px; line-height: 1; background: var(--panel2); color: var(--dim); }
.tstr button:hover { background: var(--accent-soft); color: var(--accent); }
.knob input { width: 80px; }

/* guitar */
#stage { position: relative; background: radial-gradient(ellipse at 50% 0%, #1b1d24, var(--bg) 70%); padding: 10px 0 6px; }
#guitar { width: 100%; height: 250px; display: block; touch-action: none; cursor: crosshair; }
#startHint { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(12,13,17,.85); border-color: var(--accent); color: var(--accent); border-radius: 20px; padding: 6px 16px; backdrop-filter: blur(4px); }

/* play bar */
#playbar { position: sticky; top: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: center; padding: 8px 18px; background: rgba(17,19,25,.92); backdrop-filter: blur(8px); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
#chordBadge { --h: 30; min-width: 74px; text-align: center; font-weight: 800; font-size: 20px; padding: 2px 12px; border-radius: 8px; background: hsl(var(--h) 55% 22%); color: hsl(var(--h) 90% 78%); border: 1px solid hsl(var(--h) 50% 35%); }
.pb { display: flex; align-items: center; gap: 8px; }
.lbl { color: var(--dim); font-size: 12px; display: inline-flex; gap: 4px; align-items: center; }
.meter { width: 110px; height: 6px; background: var(--bg); border-radius: 6px; overflow: hidden; border: 1px solid var(--line2); }
#speedBar { height: 100%; background: linear-gradient(90deg, var(--teal), var(--accent), var(--red)); transition: width .12s; }
.toggles { gap: 6px; }
.transport button { min-width: 36px; justify-content: center; }
#posInfo { min-width: 70px; }
#recInd { color: #fda4af; font-weight: 700; }

/* panels */
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--r); padding: 14px; margin: 14px 18px; }
.panelHead { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 12px; }
main .panel { margin: 14px 0; }
main { padding: 0 18px 40px; }
.cols { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); gap: 14px; }
.cols > .panel { margin: 14px 0 0; }
@media (max-width: 950px) { .cols { grid-template-columns: 1fr; } }
.tip { margin-top: 8px; }
.nameInput { font-weight: 600; width: 200px; }

/* tabs */
.tabs { display: flex; gap: 4px; padding: 0 18px; border-bottom: 1px solid var(--line); }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; border-radius: 0; padding: 10px 12px; color: var(--dim); font-weight: 550; }
.tabs button:hover { color: var(--text); background: none; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); }
.tab { display: none; } .tab.on { display: block; }

/* keyboard map */
#kb { display: flex; flex-direction: column; gap: 5px; overflow-x: auto; padding-bottom: 2px; }
.kbRow { display: flex; gap: 5px; }
.kbRow.r1 { padding-left: 26px; } .kbRow.r2 { padding-left: 40px; } .kbRow.r3 { padding-left: 60px; } .kbRow.r4 { margin-top: 4px; align-items: flex-end; }
.key {
  --h: 220; position: relative; width: 62px; height: 50px; flex: none; padding: 4px 6px; display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; gap: 0;
  border-radius: 8px; background: var(--panel2); border: 1px solid var(--line2); border-bottom: 3px solid #0a0b0e; text-align: left; overflow: hidden;
}
.key .kl { font-family: var(--mono); font-size: 10.5px; color: var(--faint); line-height: 1; }
.key .kc { font-size: 13px; font-weight: 700; line-height: 1.1; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.key .ks { position: absolute; right: 6px; top: 4px; font-size: 10px; color: var(--teal); font-family: var(--mono); }
.key.chord { background: linear-gradient(180deg, hsl(var(--h) 35% 20%), hsl(var(--h) 30% 15%)); border-color: hsl(var(--h) 35% 30%); }
.key.chord .kc { color: hsl(var(--h) 85% 80%); }
.key.chord .kl { color: hsl(var(--h) 25% 60%); }
.key.chord:hover { border-color: hsl(var(--h) 60% 55%); background: linear-gradient(180deg, hsl(var(--h) 40% 24%), hsl(var(--h) 35% 18%)); }
.key.empty .kc { color: var(--faint); font-weight: 400; font-size: 16px; }
.key.empty { background: var(--bg2); border-style: dashed; border-bottom-style: solid; }
.key.empty:hover { border-color: var(--accent); }
.key.empty:hover .kc { color: var(--accent); }
.key.func { background: #13151b; }
.key.func .kc { font-size: 10.5px; font-weight: 500; color: var(--dim); }
.key.pick .kc { color: var(--teal); }
.key.cur { box-shadow: 0 0 0 2px var(--accent), 0 0 18px rgba(245,165,36,.3); }
.key.down { transform: translateY(2px); border-bottom-width: 1px; margin-bottom: 2px; box-shadow: 0 0 0 2px var(--accent); }
.key.wide { width: 100px; } .key.space { width: 300px; }
.arrows { display: grid; grid-template-columns: repeat(3, 62px); grid-template-rows: 50px 50px; gap: 5px; }
.arrows .key[data-code=ArrowUp] { grid-column: 2; grid-row: 1; }
.arrows .key[data-code=ArrowLeft] { grid-column: 1; grid-row: 2; }
.arrows .key[data-code=ArrowDown] { grid-column: 2; grid-row: 2; }
.arrows .key[data-code=ArrowRight] { grid-column: 3; grid-row: 2; }
.arrows .key .kl { font-size: 14px; color: var(--text); }

/* timeline */
.timeline { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; background: var(--bg2); }
.tlLabels { flex: none; width: 76px; border-right: 1px solid var(--line); background: var(--panel); }
.tlLabels > div, .tlCol > div { height: 30px; display: flex; align-items: center; }
.tlLabels > div { padding-left: 10px; font-size: 11.5px; color: var(--dim); }
.tlLabels .tlNum, .tlCol .tlNum { height: 22px; }
.tlScroll { overflow-x: auto; flex: 1; }
#tl { display: flex; min-width: max-content; }
.tlCol { width: 58px; flex: none; border-right: 1px solid var(--line); cursor: pointer; user-select: none; }
.tlCol.four { border-left: 1px solid var(--line2); }
.tlCol > div { justify-content: center; margin: 2px 3px; border-radius: 5px; font-size: 12.5px; }
.tlCol .tlNum { font-family: var(--mono); font-size: 10.5px; color: var(--faint); margin: 0; border-radius: 0; }
.tlChord { --h: 220; height: 26px !important; font-weight: 700; background: hsl(var(--h) 35% 18%); color: hsl(var(--h) 85% 78%); white-space: nowrap; overflow: hidden; }
.tlPat { --h: 200; height: 26px !important; font-family: var(--mono); font-weight: 700; background: hsl(var(--h) 45% 20%); color: hsl(var(--h) 85% 75%); }
.tlTempo { font-family: var(--mono); font-size: 11px !important; color: var(--accent); }
.tlCol:hover { background: rgba(255,255,255,.03); }
.tlCol.sel { background: var(--accent-soft); }
.tlCol.sel .tlNum { color: var(--accent); font-weight: 700; }
.tlCol.ph { box-shadow: inset 0 0 0 2px var(--teal); }
.tlCol.ph .tlNum { background: var(--teal); color: #04140d; }
.tlAdd { width: 40px; margin: 26px 8px; height: 60px; justify-content: center; font-size: 18px; color: var(--dim); background: none; border-style: dashed; }

/* inspector + pattern editor */
.inspector, .patHead { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; }
.inspector { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid var(--line); }
.inspector h2 { min-width: 80px; }
.chordBtn { --h: 220; font-weight: 700; background: hsl(var(--h) 35% 18%); color: hsl(var(--h) 85% 78%); border-color: hsl(var(--h) 35% 30%); min-width: 80px; }
.chordBtn:hover { background: hsl(var(--h) 40% 23%); }
.patHead { margin-bottom: 10px; }
.patTitle { --h: 200; font-family: var(--mono); font-weight: 700; padding: 4px 10px; border-radius: 6px; background: hsl(var(--h) 45% 20%); color: hsl(var(--h) 85% 75%); }
.gridWrap { overflow-x: auto; }
.pg { display: grid; grid-template-columns: 112px repeat(var(--n), minmax(24px, 1fr)); gap: 2px; min-width: max-content; user-select: none; }
.pgLab { font-size: 11.5px; color: var(--dim); display: flex; align-items: center; justify-content: flex-end; padding-right: 10px; height: 22px; white-space: nowrap; }
.pgLab.k-strum { color: #fcd38d; } .pgLab.k-pick { color: #8ee5c1; } .pgLab.k-mod { color: #a5c8fd; }
.pgHead { height: 18px; font-family: var(--mono); font-size: 10px; color: var(--faint); display: flex; align-items: center; justify-content: center; border-radius: 3px; }
.pgHead.beat { color: var(--dim); font-weight: 700; }
.pgHead.ph { background: var(--teal); color: #04140d; }
.pgCell { height: 22px; min-width: 24px; background: #1a1d25; border-radius: 3px; cursor: pointer; transition: background .06s; }
.pgCell.odd { background: #15181f; }
.pgCell.beat { box-shadow: inset 2px 0 0 #2c3240; }
.pgCell:hover { background: #2a2f3b; }
.pgCell.on.k-strum { background: var(--accent); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); }
.pgCell.on.k-pick { background: var(--teal); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); }
.pgCell.on.k-mod { background: var(--blue); box-shadow: inset 0 -2px 0 rgba(0,0,0,.25); }
.pgCell.ph { outline: 1px solid rgba(52,211,153,.55); outline-offset: -1px; }
.pgCell.ph.on { filter: brightness(1.35); }
.pg > .pgLab:nth-of-type(n) { }

/* chord cards */
.cardGrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; max-height: 480px; overflow: auto; padding: 2px; }
.cardGrid.small { max-height: 260px; }
.chordCard { --h: 220; flex-direction: column; gap: 2px; padding: 6px 4px 6px; background: var(--bg2); border: 1px solid var(--line); border-radius: 8px; position: relative; justify-content: center; }
.chordCard:hover { border-color: hsl(var(--h) 60% 55%); background: hsl(var(--h) 25% 13%); }
.chordCard.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.chordCard .cn { font-weight: 700; font-size: 12.5px; color: hsl(var(--h) 80% 80%); }
.chordCard .tag { position: absolute; top: 3px; right: 5px; font-size: 9px; color: var(--teal); text-transform: uppercase; letter-spacing: .05em; }
#chordSearch { width: 160px; }
.edWrap { display: flex; gap: 22px; flex-wrap: wrap; }
.edLeft { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.edSide { flex: 1; min-width: 260px; }
#edDiagram { background: var(--bg2); border-radius: 10px; border: 1px solid var(--line); }
#edDiagram .hit { cursor: pointer; }
#edDiagram .hit:hover { fill: rgba(245,165,36,.12); }

/* files / help */
.songRow { display: flex; gap: 10px; align-items: center; padding: 8px 4px; border-bottom: 1px solid var(--line); }
.songRow:last-child { border-bottom: 0; }
.sn { font-weight: 650; }
table.keys { border-collapse: collapse; width: 100%; }
table.keys td { padding: 7px 6px; border-bottom: 1px solid var(--line); }
table.keys td:first-child { white-space: nowrap; width: 160px; }
ul { padding-left: 18px; margin: 0; } li { margin: 6px 0; color: #c9cdd6; }

/* modal / overlays */
#modal { position: fixed; inset: 0; background: rgba(5,6,8,.7); backdrop-filter: blur(3px); display: flex; align-items: flex-start; justify-content: center; z-index: 20; padding-top: 8vh; }
.modalBox { width: min(760px, 94vw); max-height: 80vh; overflow: hidden; display: flex; flex-direction: column; background: var(--panel); border: 1px solid var(--line2); border-radius: 14px; padding: 16px; box-shadow: 0 20px 60px rgba(0,0,0,.6); }
.modalBox .cardGrid { max-height: none; overflow: auto; }
#bindOverlay { position: fixed; inset: 0; background: rgba(5,6,8,.75); display: flex; align-items: center; justify-content: center; z-index: 20; font-size: 18px; }
#bindOverlay > div { background: var(--panel); border: 1px solid var(--accent); padding: 22px 30px; border-radius: 14px; }
#toast { position: fixed; bottom: 22px; left: 50%; transform: translate(-50%, 20px); opacity: 0; background: var(--panel3); border: 1px solid var(--line2); padding: 9px 16px; border-radius: 10px; transition: .2s; pointer-events: none; z-index: 30; box-shadow: 0 10px 30px rgba(0,0,0,.5); }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #2b303b; border-radius: 10px; border: 2px solid var(--bg); }
::-webkit-scrollbar-track { background: transparent; }

/* v3 additions */
.key.pick { background: linear-gradient(180deg, #11261f, #0e1d18); border-color: #1f4d3c; }
.key.pick .kc, .key.note .kc { color: #8ee5c1; }
.key.note { background: linear-gradient(180deg, #0f2430, #0c1b24); border-color: #1d4a5e; }
.key.note .kc { color: #7dd3fc; }
.key.note .ks { color: #7dd3fc; }
.key.patk { background: linear-gradient(180deg, #2a2110, #1f190c); border-color: #5a4518; }
.key.patk .kc { color: #fcd38d; font-size: 11px; white-space: normal; line-height: 1.05; }
#pickTabs button.on { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.pickList { display: flex; flex-direction: column; gap: 6px; overflow: auto; }
.pickOpt { justify-content: space-between; padding: 9px 12px; }
.pickOpt span { color: var(--dim); }
.noteBoard { overflow: auto; }
.nb { display: grid; grid-template-columns: 74px repeat(16, minmax(34px, 1fr)); gap: 3px; margin-top: 8px; }
.nbHead { font-family: var(--mono); font-size: 10.5px; color: var(--faint); text-align: center; }
.nbLab { font-size: 11.5px; color: var(--dim); display: flex; align-items: center; }
.nbCell { padding: 5px 0; justify-content: center; font-size: 11px; font-family: var(--mono); background: var(--bg2); }
.nbCell.dot { background: #1c2029; }
.nbCell:hover { background: rgba(125,211,252,.15); border-color: #7dd3fc; color: #7dd3fc; }
.pgLab.k-chord { color: var(--text); font-weight: 650; }
.pgChord { height: 24px; border-radius: 4px; background: #13161c; border: 1px dashed #2a2f3b; cursor: pointer; font-size: 11px; font-weight: 700; display: flex; align-items: center; justify-content: center; overflow: hidden; white-space: nowrap; }
.pgChord:hover { border-color: var(--accent); }
.pgChord.on { --h: 220; background: hsl(var(--h) 35% 20%); color: hsl(var(--h) 85% 80%); border: 1px solid hsl(var(--h) 40% 35%); }
.pgCell.k-pick { font-family: var(--mono); font-size: 10.5px; font-weight: 800; color: #03140c; display: flex; align-items: center; justify-content: center; }
.tlChord.chg::after { content: '•'; margin-left: 3px; color: var(--accent); }
#cellPop { position: fixed; z-index: 25; width: 260px; background: var(--panel); border: 1px solid var(--line2); border-radius: 12px; padding: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.6); display: flex; flex-direction: column; gap: 10px; }
.popHead { font-weight: 650; }
.popTech { display: flex; flex-wrap: wrap; gap: 5px; }
.popTech button { padding: 4px 8px; font-size: 12px; }
.presetRow { display: flex; gap: 10px; align-items: center; padding: 6px 4px; border-bottom: 1px solid var(--line); }
.presetRow:last-child { border-bottom: 0; }
.pn { font-weight: 600; min-width: 170px; }
.star { color: var(--accent); }
#presetLib { max-height: 360px; overflow: auto; }
#pickStyle { max-width: 170px; }
#saveState { color: var(--teal); }

.key.move { background: linear-gradient(180deg, #24173a, #1b122c); border-color: #4a3378; }
.key.move .kc { color: #c4b5fd; }
/* Smaller key labels */
.key.pick .kc, .key.move .kc, .key.note .kc { font-size: 11px; }
.key.pick .ks, .key.note .ks { font-size: 9.5px; }
