* { box-sizing: border-box; margin: 0; }
html, body { height: 100%; }
body { background: var(--bg); color: var(--ink); font: 15px/1.4 var(--font-ui); -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
button, input, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; -webkit-tap-highlight-color: transparent; }
a { color: inherit; text-decoration: none; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
mark { background: var(--accent-soft); color: var(--accent); border-radius: 3px; }
.grow { flex: 1; }
.mute { color: var(--ink-3); }
#app, .shell { height: 100%; }

/* ---------- shell ---------- */
.shell { display: flex; flex-direction: column; max-width: 100%; }
.main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view { flex: 1; min-height: 0; display: flex; flex-direction: column; padding-top: env(safe-area-inset-top); }
.scroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.tabbar { flex: none; display: flex; border-top: 1px solid var(--line); background: var(--surface); padding: 6px 0 calc(8px + env(safe-area-inset-bottom)); }
.tabbar a { flex: 1; text-align: center; font-size: 11px; color: var(--ink-3); min-height: var(--tap); }
.tabbar a i { display: block; font-style: normal; font-size: 20px; line-height: 26px; }
.tabbar a.on { color: var(--accent); font-weight: 600; }
.shell.wide { flex-direction: row; }
.shell.wide .side { width: 280px; flex: none; border-right: 1px solid var(--line); background: var(--surface); display: flex; flex-direction: column; min-height: 0; }
.shell.wide .side .library { flex: 1; }
.shell.wide .side .fab { display: none; }
.side-nav { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.side-nav a { flex: 1; text-align: center; padding: 10px 0; border-radius: 12px; background: var(--surface-2); font-size: 14px; }
.shell.wide .panel { width: 320px; flex: none; border-left: 1px solid var(--line); background: var(--surface); padding: 16px; overflow-y: auto; }
.panel h5, .glabel { font: 600 12px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.panel h5 { margin-bottom: 10px; }
.empty-main { display: grid; place-items: center; color: var(--ink-2); }

/* ---------- common ---------- */
.appbar { display: flex; align-items: center; gap: 6px; padding: 6px 14px; min-height: 52px; }
.appbar h1 { font: 700 26px var(--font-serif); flex: 1; }
.appbar h1.small { flex: none; font-size: 18px; }
.ib { width: var(--tap); height: var(--tap); border-radius: 50%; display: grid; place-items: center; font-size: 22px; }
.ib.fav.on { color: var(--accent); }
.chip { display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 36px; padding: 0 14px; border-radius: 18px; background: var(--surface-2); font-size: 13px; white-space: nowrap; }
.chip.on { background: var(--ink); color: var(--bg); }
.chip.acc { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.chip.ch { color: var(--accent); font-weight: 700; }
.chip.dd { min-height: 40px; font-weight: 600; }
.chip.dd.f { background: var(--accent-soft); color: var(--accent); }
.chip.wide { flex: 1; min-height: var(--tap); }
.btn { min-height: 48px; padding: 0 22px; border-radius: 24px; background: var(--accent); color: var(--accent-ink); font-weight: 600; font-size: 16px; display: inline-grid; place-items: center; }
.btn.ghost { background: var(--surface-2); color: var(--ink); }
.btn.small { min-height: 36px; font-size: 14px; padding: 0 18px; }
.btn:disabled { opacity: .4; }
.row2 { display: flex; gap: 10px; margin-top: 12px; }
.row2.pad { padding: 10px 14px; margin: 0; }
.hint { color: var(--ink-3); font-size: 12px; text-align: center; margin: 6px 0; }
.empty { text-align: center; padding: 40px 24px; color: var(--ink-2); display: flex; flex-direction: column; gap: 16px; align-items: center; }

/* sheets, snackbar */
.dim { position: fixed; inset: 0; background: #0006; z-index: 40; }
.sheet { position: fixed; z-index: 41; left: 0; right: 0; bottom: 0; max-height: 86vh; overflow-y: auto; background: var(--surface); border-radius: 24px 24px 0 0; padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); box-shadow: 0 -8px 30px #0004; animation: up .18s ease-out; }
@keyframes up { from { transform: translateY(24px); opacity: .6; } }
@media (prefers-reduced-motion: reduce) { .sheet { animation: none; } }
@media (min-width: 600px) { .sheet { left: 50%; right: auto; width: 440px; transform: translateX(-50%); bottom: 24px; border-radius: 24px; animation: none; } }
.grab { width: 40px; height: 4px; border-radius: 2px; background: var(--line); margin: 0 auto 12px; }
.sheet-title { font: 700 22px var(--font-serif); margin-bottom: 8px; }
.pick-row { display: flex; width: 100%; justify-content: space-between; align-items: center; min-height: 50px; padding: 0 6px; border-bottom: 1px solid var(--line); text-align: left; font-size: 16px; }
.pick-row.on { color: var(--accent); font-weight: 600; }
.snack { position: fixed; z-index: 60; left: 50%; transform: translateX(-50%); bottom: calc(84px + env(safe-area-inset-bottom)); background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: 14px; display: flex; gap: 16px; align-items: center; box-shadow: 0 6px 20px #0005; }
.snack button { color: var(--accent); font-weight: 700; background: none; filter: brightness(1.4); }

/* ---------- library ---------- */
.search { margin: 4px 14px 10px; height: 44px; border-radius: 22px; background: var(--surface-2); display: flex; align-items: center; padding: 0 16px; color: var(--ink-3); gap: 8px; }
.search input { flex: 1; min-width: 0; background: none; border: 0; outline: none; color: var(--ink); height: 100%; }
.chips { display: flex; gap: 8px; padding: 0 14px 10px; overflow-x: auto; scrollbar-width: none; }
.chips::-webkit-scrollbar, .strip::-webkit-scrollbar, .toolrow::-webkit-scrollbar { display: none; }
.sync { font-size: 11px; color: var(--ok); padding: 0 14px 6px; }
.library .list { flex: 1; overflow-y: auto; padding-bottom: 90px; }
.item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; min-height: 64px; border-bottom: 1px solid var(--line); }
.item.active { background: var(--accent-soft); }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font: 600 17px var(--font-serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t small { display: block; color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item .t small.snippet { font-style: italic; color: var(--ink-3); }
.keybadge { min-width: 48px; text-align: center; padding: 4px 8px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 14px; }
.keybadge small { display: block; font-size: 10px; font-weight: 500; opacity: .85; white-space: nowrap; }
.fab { position: fixed; right: 16px; bottom: calc(84px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 18px; background: var(--accent); color: var(--accent-ink); font-size: 30px; display: grid; place-items: center; box-shadow: 0 6px 16px #0004; z-index: 5; }

/* ---------- song view ---------- */
.song-head { padding: 0 16px 6px; }
.song-head h1 { font: 700 24px/1.15 var(--font-serif); }
.song-head p { color: var(--ink-2); font-size: 14px; margin-top: 2px; }
.ctrl { display: flex; gap: 8px; padding: 6px 12px 8px; align-items: center; flex-wrap: wrap; }
.note { font-size: 12px; color: var(--ink-2); padding: 0 16px 6px; }
.stepper { display: inline-flex; align-items: center; height: 44px; border-radius: 22px; background: var(--surface-2); }
.stepper button { width: 40px; height: 44px; font-size: 22px; color: var(--accent); }
.stepper .val { min-width: 40px; text-align: center; font-weight: 700; font-size: 15px; user-select: none; }
.stepper .val small { display: block; font-size: 10px; font-weight: 500; color: var(--ink-2); line-height: 1; }
.striphead, .collapsed { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 16px; background: var(--surface); border-top: 1px solid var(--line); }
.collapsed { padding: 5px 16px; }
.lbl { font: 600 11px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.collapsed .nm { flex: 1; font-size: 12px; color: var(--ink-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.eyebtn { font-size: 12px; color: var(--ink-2); background: var(--surface-2); border-radius: 12px; padding: 6px 12px; white-space: nowrap; }
.strip { scrollbar-width: none; display: flex; gap: 6px; padding: 4px 12px 8px; overflow-x: auto; background: var(--surface); border-bottom: 1px solid var(--line); }
.mini { flex: none; width: 58px; text-align: center; border-radius: 10px; padding: 2px 0; }
.mini.sel { background: var(--accent-soft); }
.mini b { display: block; color: var(--accent); font-size: 14px; position: relative; }
.mini .mini-d svg { width: 100%; height: auto; display: block; }
.mini .mini-d .pk { margin: 14px 0 4px; }
.dotmark { position: absolute; top: 4px; margin-left: 3px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.nofing { height: 70px; display: grid; place-items: center; color: var(--ink-3); font-size: 22px; }
.strumbar { display: flex; align-items: center; gap: 8px; padding: 6px 16px; background: var(--surface); border-bottom: 1px solid var(--line); }
.strum { display: grid; grid-template-columns: repeat(8, 1fr); flex: 1; text-align: center; }
.strum i { font-style: normal; font-size: 20px; line-height: 22px; }
.strum i.u { color: var(--ink-2); } .strum i.x { color: var(--line); } .strum i.ac { color: var(--accent); font-weight: 800; }
.strum small { display: block; font-size: 9px; color: var(--ink-3); line-height: 11px; }
.strum.small i { font-size: 16px; }
.pat { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 12px; border: 1.5px solid var(--line); border-radius: var(--r-md); margin-bottom: 8px; text-align: left; }
.pat.on { border-color: var(--accent); background: var(--accent-soft); }
.pat b { width: 70px; font-size: 13px; }
.pat .strum { flex: 1; }
.slot { min-height: 44px; }
.set { display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 8px 14px; border-bottom: 1px solid var(--line); }
.sheet .set { padding: 8px 0; }
.set:last-child { border: 0; }
.set .l { flex: 1; } .set small { display: block; color: var(--ink-2); font-size: 12px; }
.text-wrap { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.text-scroll { padding: 0 16px 120px; touch-action: pan-y; }
.reading .chrome { display: none; }
.lyrics { padding: 14px 0; font-size: var(--lyric-size); line-height: 1; }
.sec { font: 600 12px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); margin: 18px 0 8px; }
.gap { height: .8em; }
.ln { margin-bottom: 10px; }
.s { display: inline-flex; flex-direction: column; vertical-align: bottom; white-space: pre; }
.s .c { color: var(--accent); font-weight: 700; font-size: .86em; line-height: 1.35; min-height: 1.35em; padding: 0 .5em 0 0; text-align: left; border-radius: 6px; }
.s button.c { min-width: 1.4em; }
.s .c.sel { background: var(--accent-soft); }
.s .c { align-self: flex-start; }
.s .w { line-height: 1.3; }
.bottom-actions { flex: none; display: flex; gap: 10px; padding: 8px 14px calc(12px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.bottom-actions .btn { flex: 1; min-height: 44px; font-size: 15px; padding: 0 8px; }
.play-fab { position: absolute; right: 14px; bottom: 14px; height: 52px; padding: 0 18px; border-radius: 26px; background: var(--accent); color: var(--accent-ink); font-weight: 700; box-shadow: 0 6px 16px #0004; z-index: 2; }
.scrollbar { position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 3; background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 10px 14px; box-shadow: 0 8px 24px #0004; }
.scrollbar .top { display: flex; align-items: center; gap: 10px; }
.scrollbar input { flex: 1; accent-color: var(--accent); }
.scrollbar .pp { width: 44px; height: 44px; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 18px; flex: none; }
.scrollbar .sm { font-size: 12px; color: var(--ink-2); }
.scrollbar .hint { margin: 6px 0 0; }
.tsample { background: var(--bg); border-radius: var(--r-md); padding: 10px 12px; margin-bottom: 10px; }
.asl { display: flex; align-items: center; gap: 12px; margin: 4px 0 12px; }
.asl input { flex: 1; accent-color: var(--accent); }
.asl .big { font-size: 22px; } .asl .val { min-width: 48px; text-align: right; color: var(--ink-2); font-size: 13px; }

/* chord sheet / panel */
.chord-name { font: 700 34px var(--font-serif); color: var(--accent); }
.chord-name small { display: block; font: 500 13px var(--font-ui); color: var(--ink-2); }
.variants { display: flex; gap: 10px; margin: 12px 0; }
.variant { flex: 1; border: 1.5px solid var(--line); border-radius: var(--r-md); padding: 8px 4px 6px; text-align: center; font-size: 11px; color: var(--ink-2); min-width: 0; }
.variant.on { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.variant svg, .chord-content > .variants svg { width: 100%; height: auto; display: block; }
.nofing-big { padding: 28px; text-align: center; color: var(--ink-3); }
.notes { text-align: center; color: var(--ink-2); font-size: 15px; margin-top: 4px; letter-spacing: .06em; }
.notes.small { font-size: 12px; color: var(--ink-3); letter-spacing: 0; }
.pk { margin: 6px 0; }
.variant .pk { margin: 28px 0 14px; }

/* diagrams */
svg .ln { stroke: var(--ink-3); stroke-width: 1; fill: none; }
svg .nut { fill: var(--ink); }
svg .dot { fill: var(--accent); }
svg .open { fill: none; stroke: var(--ink-2); stroke-width: 1.5; }
svg .mk { fill: var(--ink-2); font: 700 13px var(--font-ui); text-anchor: middle; }
svg .fr { fill: var(--ink-2); font: 600 11px var(--font-ui); }
svg .wk { fill: var(--surface); stroke: var(--ink-3); stroke-width: .6; }
svg .wk.on { fill: var(--accent); }
svg .bk { fill: var(--ink); }
svg .bk.on { fill: var(--accent); stroke: var(--ink); stroke-width: .5; }

/* ---------- add / editor ---------- */
.banner { margin: 0 14px 8px; border-radius: var(--r-md); padding: 10px 12px; font-size: 13px; display: flex; gap: 10px; align-items: center; background: var(--surface-2); }
.banner.warn { background: var(--warn-soft); } .banner.ok { background: var(--accent-soft); }
.banner .act { margin-left: auto; font-weight: 700; color: var(--accent); white-space: nowrap; min-height: 36px; padding: 0 6px; }
.banner .act + .act { margin-left: 0; } .banner .act.mute { color: var(--ink-2); font-weight: 500; }
.banners { padding-top: 6px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 0 14px 10px; }
.field { display: block; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 6px 12px; }
.field.wide { grid-column: span 2; }
.field small { display: block; font-size: 11px; color: var(--ink-3); }
.field input { width: 100%; background: none; border: 0; outline: none; font-size: 16px; min-height: 28px; }
.paste { display: block; width: calc(100% - 28px); margin: 0 14px; min-height: 160px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; font: 14px/1.5 var(--font-mono); resize: vertical; }
.preview { padding: 0 16px 80px; }
.editor .ed-scroll { padding: 0 14px; }
.ed-box { position: relative; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); min-height: 55vh; }
.ed-box pre, .ed-box textarea { font: 14px/1.7 var(--font-mono); padding: 12px; margin: 0; white-space: pre-wrap; word-wrap: break-word; overflow-wrap: anywhere; letter-spacing: 0; border: 0; }
.ed-box pre { position: absolute; inset: 0; overflow: hidden; pointer-events: none; color: var(--ink); }
.ed-box textarea { position: relative; display: block; width: 100%; min-height: 55vh; background: transparent; color: transparent; caret-color: var(--ink); resize: none; outline: none; -webkit-text-fill-color: transparent; }
.ed-box .ch { color: var(--accent); background: var(--accent-soft); border-radius: 4px; font-weight: 700; }
.ed-box .dir { color: var(--ink-3); }
.toolrow { flex: none; display: flex; gap: 8px; padding: 8px 14px calc(8px + env(safe-area-inset-bottom)); overflow-x: auto; border-top: 1px solid var(--line); background: var(--surface); }
.row-ch { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.preview-box { padding-bottom: 80px; }

/* ---------- settings ---------- */
.settings .scroll { padding-bottom: 24px; }
.glabel { padding: 10px 28px 6px; }
.grp { margin: 0 14px 10px; background: var(--surface); border-radius: var(--r-md); overflow: hidden; }
.tog { flex: none; width: 46px; height: 28px; border-radius: 14px; background: var(--line); position: relative; transition: background .15s; }
.tog.on { background: var(--accent); }
.tog::after { content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%; background: #fff; transition: left .15s; }
.tog.on::after { left: 21px; }
.seg { display: inline-flex; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button { padding: 6px 12px; min-height: 32px; border-radius: 8px; font-size: 13px; color: var(--ink-2); }
.seg button.on { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: 0 1px 2px #0002; }
.set input[type=range] { width: 120px; accent-color: var(--accent); }

@media (min-width: 900px) {
  .song-head, .ctrl, .note { max-width: 720px; }
  .text-scroll { padding-left: 16px; padding-right: 32px; }
}

/* ---------- v0.6: anchored popovers ---------- */
.pop-dim { position: fixed; inset: 0; z-index: 44; }
.pop { position: absolute; z-index: 45; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: 0 10px 30px #0005; padding: 6px 0; min-width: 200px; max-width: calc(100vw - 16px); }
.pop::before { content: ""; position: absolute; top: -6px; left: var(--ax, 24px); width: 10px; height: 10px; background: var(--surface); border-left: 1px solid var(--line); border-top: 1px solid var(--line); transform: rotate(45deg); }
.pop .it { display: flex; align-items: center; gap: 10px; width: 100%; padding: 0 14px; min-height: 44px; font-size: 15px; text-align: left; }
.pop .it.dis { color: var(--ink-3); }
.pop .it.accent { color: var(--accent); font-size: 14px; }
.pop .it .ck { margin-left: auto; color: var(--accent); font-weight: 700; }
.pop .sep { height: 1px; background: var(--line); margin: 4px 0; }
.pop .row { display: flex; align-items: center; gap: 10px; padding: 8px 14px; min-height: 44px; }
.pop .row .l { flex: 1; }
.pop .row.col { flex-direction: column; align-items: stretch; gap: 4px; }
.pop .row.col small { color: var(--ink-3); font-size: 11px; letter-spacing: .08em; text-transform: uppercase; }
.pop .asl { display: flex; align-items: center; gap: 10px; }
.pop .asl input { flex: 1; accent-color: var(--accent); }
.pop .asl .big { font-size: 22px; }
.pop .pats { padding: 8px 12px; min-width: 300px; }
.pop .pats .pat:last-child { margin-bottom: 0; }
.ctrl { gap: 5px; }
.ctrl .stepper button { width: 32px; }
.ctrl .stepper .val { min-width: 34px; }
.chip.dd { padding: 0 10px; }
.mini.pkm { width: 92px; }
.strumbar { cursor: default; }
.strumbar .strum { background: none; text-align: center; }
@media (min-width: 900px) {
  /* desktop: same band as on the phone, the pattern itself is capped to a text-like width, flush left */
  .strumbar .strum { flex: none; width: 320px; }
}

.pop .cap { padding: 8px 14px 0; font: 600 11px var(--font-ui); letter-spacing: .08em; text-transform: uppercase; color: var(--ink-3); }
.play-fab { bottom: calc(14px + env(safe-area-inset-bottom)); }

.strum-empty { color: var(--ink-3); font-size: 13px; text-align: left; min-height: 44px; flex: 1; }
.strum-empty.small { min-height: 0; flex: none; }
.strumbar .strum-empty { min-height: 44px; display: flex; align-items: center; }
