* { box-sizing: border-box; margin: 0; padding: 0; }
body { font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; background: #1c1c2e; color: #f2f2f7; padding-bottom: 40px; }
header { padding: 18px 16px 0; }
h1 { font-size: 24px; margin-bottom: 14px; }
.tabs { display: flex; gap: 8px; }
.tab { flex: 1; padding: 12px 6px; min-height: 48px; font-size: 15px; font-weight: 700; border: none; border-radius: 12px 12px 0 0; background: #2c2c44; color: #aeaeb8; }
.tab.active { background: #3a3a5c; color: #fff; }
main { padding: 0 16px; }
.view { display: none; }
.view.active { display: block; }
.card { background: #2c2c44; border-radius: 0 0 14px 14px; padding: 22px 18px; margin-bottom: 20px; }
.sec-head { font-weight: 800; font-size: 13px; letter-spacing: 1.5px; text-transform: uppercase; color: #aeaeb8; margin-bottom: 12px; }
.lbl { font-weight: 700; font-size: 14px; margin-bottom: 10px; display: block; }
.row { display: flex; gap: 12px; margin-top: 14px; flex-wrap: wrap; }
.primary, .secondary { border: none; border-radius: 10px; padding: 12px 16px; min-height: 44px; font-size: 16px; font-weight: 700; }
.primary { background: #34c759; color: #06280f; flex: 1; }
.secondary { background: #48485e; color: #fff; }
.preset { background: #48485e; color: #d6d6de; border: 2px solid transparent; border-radius: 8px; padding: 10px 12px; font-size: 13px; font-weight: 600; margin: 2px; min-height: 40px; }
.preset.active { border-color: #34c759; color: #fff; }
.preset-row { margin-top: 14px; }
.preset-row .lbl { display: inline; margin-right: 4px; }
.tuner-readout { text-align: center; }
#tune-note { font-size: 84px; font-weight: 800; line-height: 1; }
#tune-freq { font-size: 16px; color: #aeaeb8; margin-top: 4px; }
.needle-wrap { position: relative; height: 70px; margin: 10px auto 0; max-width: 320px; }
#needle { position: absolute; left: 50%; bottom: 0; width: 4px; height: 64px; background: #ff9f0a; border-radius: 2px; transform-origin: bottom center; transform: rotate(0deg); transition: transform 60ms linear; margin-left: -2px; }
.needle-ticks { position: absolute; bottom: -4px; left: 0; right: 0; display: flex; justify-content: space-between; font-size: 11px; color: #8e8e9a; }
#tune-cents { font-size: 18px; font-weight: 700; margin-top: 18px; }
.state { margin-top: 8px; font-size: 14px; color: #aeaeb8; }
.state.intune { color: #34c759; font-weight: 700; }
.state.off { color: #ff9f0a; }
.error { background: #4a1f1f; border: 1px solid #a33; border-radius: 10px; padding: 12px; margin-top: 12px; font-size: 14px; }
.hidden { display: none !important; }
.strings { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.string-chip { background: #48485e; border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 700; border: 2px solid transparent; }
.string-chip b { display: block; font-size: 15px; }
.string-chip span { font-size: 11px; color: #aeaeb8; font-weight: 400; }
.string-chip.near { border-color: #ff9f0a; }
.string-chip.hit { border-color: #34c759; background: #1e3d27; }
.fine { font-size: 12px; color: #8e8e9a; margin-top: 16px; line-height: 1.6; }
.status { font-size: 14px; color: #aeaeb8; margin-top: 12px; line-height: 1.5; }
#chart-file { margin-top: 6px; color: #d6d6de; }
.chart { background: #14141f; border-radius: 10px; padding: 12px; margin-top: 12px; font-size: 14px; line-height: 1.7; white-space: pre; overflow-x: auto; font-family: ui-monospace, Menlo, Consolas, monospace; }
.chart mark { background: #34c759; color: #06280f; border-radius: 3px; padding: 0 2px; font-weight: 700; }
.keyrow label { font-size: 14px; }
.keyrow select { background: #48485e; color: #fff; border: none; border-radius: 8px; padding: 8px; font-size: 15px; }
footer { text-align: center; color: #6e6e7a; font-size: 12px; }

/* ---------- setlist ---------- */
.hiddenfile { display: none; }
.filelbl { cursor: pointer; display: inline-block; }
#play-open:disabled { opacity: .4; }
.song { background: #1e1e33; border-radius: 10px; padding: 14px; margin-top: 14px; }
.song-head { display: flex; gap: 8px; align-items: center; }
.song-title { flex: 1; min-width: 0; background: #14141f; color: #fff; border: 1px solid #48485e; border-radius: 8px; padding: 10px; font-size: 16px; font-weight: 700; }
.song-mv { display: flex; gap: 6px; }
.sm { padding: 8px 10px; font-size: 14px; }
.sm:disabled { opacity: .35; }
.danger { background: #5c2b2b; }
.meta { font-size: 13px; color: #aeaeb8; margin-top: 8px; }
.meta b { color: #fff; }
.capo-badge { display: inline-block; background: #3d2f14; color: #ffcc66; border-radius: 6px; padding: 2px 8px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.capo-panel { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.capo-chip { background: #48485e; color: #fff; border: 2px solid transparent; border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 600; }
.capo-chip.active { border-color: #ffcc66; }
.setchart { font-size: 13px; max-height: 220px; overflow-y: auto; }

/* ---------- play mode ---------- */
#playmode { position: fixed; inset: 0; background: #14141f; z-index: 50; overflow-y: auto; padding: 0 16px 80px; }
body.playing { overflow: hidden; }
.playbar { position: sticky; top: 0; display: flex; gap: 10px; align-items: center; background: #14141f; padding: 12px 0; z-index: 3; }
.playbar span { font-weight: 700; font-size: 16px; }
.play-title { position: sticky; top: 62px; background: #1e1e33; padding: 10px 12px; border-radius: 8px; font-size: 18px; margin: 14px 0 6px; z-index: 2; }
.play-chart { background: #1e1e33; border-radius: 10px; padding: 14px; font-size: 19px; line-height: 2; white-space: pre; overflow-x: auto; font-family: ui-monospace, Menlo, Consolas, monospace; }
.play-chart mark { background: #34c759; color: #06280f; border-radius: 3px; padding: 0 2px; font-weight: 700; }

/* ---------- v4: print setlist ---------- */
#printdoc { display: none; }
#printactions { display: flex; gap: 10px; margin: 16px 0; }
#printactions .btn { background: #34c759; color: #06280f; border: none; border-radius: 10px; padding: 12px 18px; font-size: 16px; font-weight: 700; }
#printactions .ghost { background: #48485e; color: #fff; border: none; border-radius: 10px; padding: 12px 18px; font-size: 16px; }
.p-title { font-size: 22px; font-weight: 800; margin: 18px 0 4px; color: #111; }
.p-sub { font-size: 13px; color: #555; margin-bottom: 12px; }
.p-song { break-inside: avoid; border: 1px solid #ddd; border-radius: 8px; padding: 12px; margin: 12px 0; }
.p-songhead { display: flex; gap: 10px; align-items: baseline; margin-bottom: 6px; }
.p-num { font-size: 18px; font-weight: 800; color: #111; min-width: 28px; }
.p-songtitle { font-size: 17px; font-weight: 700; color: #111; flex: 1; }
.p-meta { font-size: 12px; color: #555; margin-bottom: 8px; }
.p-chart { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; line-height: 1.7; white-space: pre-wrap; color: #111; background: #f7f7f7; border-radius: 6px; padding: 10px; }
.p-foot { font-size: 11px; color: #888; margin-top: 18px; text-align: center; }
.p-empty { font-size: 15px; color: #555; text-align: center; margin: 40px 20px; line-height: 1.6; }
@media print {
  body > *:not(#printdoc) { display: none !important; }
  #printdoc { display: block !important; max-width: 700px; margin: 0 auto; padding: 0 12px; background: #fff; color: #111; }
  #printactions { display: none !important; }
  .p-song { break-inside: avoid; }
}

/* ---------- v5: chord diagram library ---------- */
#chord-instruments { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }
#chord-instruments .preset { font-size: 14px; padding: 10px 14px; }
.chord-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; margin-top: 14px; }
.chord-card { background: #1e1e33; border-radius: 12px; padding: 12px 6px 10px; text-align: center; }
.chord-name { font-size: 20px; font-weight: 800; margin-bottom: 8px; }
.chord-card svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.chord-note { font-size: 12.5px; color: #8e8e9a; margin-top: 10px; line-height: 1.5; }
