/* Chartroom. Shares the Original Noises tokens with ClickSplit and Tonic Pads; accent is gold. */
:root {
  --ink: #0f0f0f; --panel: #1c1c1c; --panel-2: #2a2a2a; --line: #2f2f2f;
  --text: #ffffff; --muted: #a3a3a3; --graphite: #616161;
  --accent: #f0b429; --accent-ink: #0f0f0f; --red: #e5484d;
  --sans: "Instrument Sans", system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --serif: "Instrument Serif", "Iowan Old Style", "Palatino Linotype", Georgia, serif;
  --slate: #8b9bb0; --blue: #3e8be2; --teal: #2bb3a3; --amber: #f0b429; --violet: #8b5cf6;
  --rose: #e2557a; --green: #3fb950; --redp: #e5484d;
  --chart-scale: 1;
  --r: 14px;
  color-scheme: dark;
}
[data-theme="paper"] {
  --ink: #f5f0e6; --panel: #fffdf8; --panel-2: #ebe4d6; --line: #e0d8c8;
  --text: #1a1a1a; --muted: #6b655c; --graphite: #9b948a;
  --accent: #c98a0b; --accent-ink: #ffffff;
  --slate: #5d6b7e; --blue: #2369c2; --teal: #128577; --amber: #b7791f; --violet: #6d3fd6; --rose: #c23662; --green: #2a8a3e; --redp: #c9302c;
  color-scheme: light;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { background: var(--ink); }
body { margin: 0; background: var(--ink); color: var(--text); font: 16px/1.45 var(--sans); -webkit-font-smoothing: antialiased; min-height: 100dvh;
  padding-bottom: env(safe-area-inset-bottom); }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
svg { width: 20px; height: 20px; flex: none; }
.muted { color: var(--muted); }
code { background: var(--panel-2); padding: 1px 6px; border-radius: 6px; font-size: .92em; }

/* top bar */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: calc(env(safe-area-inset-top) + 10px) 14px 10px;
  background: color-mix(in srgb, var(--ink) 88%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }
.brand { font: italic 26px/1 var(--serif); letter-spacing: -.01em; }
.brand b, .on b { color: var(--accent); font-weight: 400; }
.top-title { flex: 1; min-width: 0; }
.top-title h1 { margin: 0; font: 600 17px/1.2 var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-title .sub { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.top-right { display: flex; align-items: center; gap: 6px; }
.icon-btn { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 12px; border: 0; background: var(--panel); cursor: pointer; }
.icon-btn.sm { width: 32px; height: 32px; border-radius: 10px; background: transparent; }
.icon-btn.sm svg { width: 18px; height: 18px; }

.sync { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); padding: 6px 10px; border-radius: 99px; background: var(--panel); white-space: nowrap; }
.sync i, .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--graphite); display: inline-block; }
.sync.live i, .dot.live { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.sync.connecting i { background: var(--accent); animation: pulse 1s infinite alternate; }
@keyframes pulse { to { opacity: .3; } }

/* layout */
.wrap { max-width: 760px; margin: 0 auto; padding: 8px 16px 40px; display: flex; flex-direction: column; gap: 12px; }
.wrap.narrow { max-width: 460px; }
.hero { padding: 28px 2px 8px; }
.hero h2 { font: 400 44px/1.02 var(--serif); margin: 0 0 12px; letter-spacing: -.015em; }
.hero h2 em { color: var(--accent); }
.hero p { color: var(--muted); margin: 0; font-size: 17px; max-width: 34em; }
.label { font: 600 12px/1 var(--sans); text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 14px 2px 2px; }
.actions { display: flex; gap: 10px; flex-wrap: wrap; }
.list { display: flex; flex-direction: column; gap: 8px; }
.card { background: var(--panel); border-radius: var(--r); }
.card.pad { padding: 16px; display: flex; flex-direction: column; gap: 10px; }
.card.pad .label { margin-top: 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px; min-height: 64px; }
.row-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; }
.row-main > div { min-width: 0; }
a.row-main, .row > .row-main:only-child { flex-direction: row; }
.row .row-main { flex-direction: column; align-items: flex-start; gap: 2px; }
.set-item .row-main { flex-direction: row; align-items: center; gap: 12px; }
.row-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.row-sub { color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.row svg { color: var(--graphite); }
.num { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; font-weight: 600; font-size: 13px; flex: none; }
.meta { display: flex; gap: 6px; align-items: center; flex: none; }
.pill { font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 99px; background: var(--panel-2); color: var(--text); white-space: nowrap; }
.pill.accent { background: var(--accent); color: var(--accent-ink); }
.btn-pill { border: 0; cursor: pointer; min-width: 44px; }
.empty { display: flex; flex-direction: column; gap: 4px; align-items: center; text-align: center; padding: 36px 16px; color: var(--muted); border: 1.5px dashed var(--line); border-radius: var(--r); }
.empty b { color: var(--text); }
.hint { color: var(--muted); font-size: 14px; margin: 0; }

/* buttons + forms */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px; border-radius: 12px; border: 0; background: var(--panel-2); font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.danger { background: transparent; color: var(--red); border: 1.5px solid color-mix(in srgb, var(--red) 40%, transparent); }
.btn.wide { width: 100%; }
.btn.sm { min-height: 38px; padding: 0 14px; }
.btn svg { width: 18px; height: 18px; }
.link { background: none; border: 0; color: var(--accent); font-weight: 600; cursor: pointer; padding: 0 4px; }
.form { display: flex; flex-direction: column; gap: 14px; padding-top: 12px; }
label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--muted); }
label.block { margin-top: 8px; }
input, select, textarea { background: var(--panel-2); border: 1.5px solid transparent; border-radius: 10px; padding: 12px; font-size: 16px; color: var(--text); width: 100%; outline: none; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); }
select { appearance: none; padding-right: 30px; 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; }
.inline { display: flex; gap: 8px; }
.inline input { flex: 1; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1; }
.code { font: 600 26px/1 var(--sans); letter-spacing: .12em; font-variant-numeric: tabular-nums; padding: 6px 0; }
.people { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 8px; }
.people li { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.people .muted { font-size: 14px; }

/* tabs */
.tabs { position: sticky; top: calc(env(safe-area-inset-top) + 60px); z-index: 15; display: flex; gap: 4px; max-width: 760px; margin: 0 auto; padding: 4px 16px 8px; background: var(--ink); }
.tabs a { flex: 1; text-align: center; padding: 10px 0; border-radius: 10px; font-weight: 600; color: var(--muted); background: var(--panel); }
.tabs a.on { background: var(--text); color: var(--ink); }

/* explainer (home) */
.explain { display: grid; gap: 10px; margin-top: 10px; }
.ex { background: var(--panel); border-radius: var(--r); padding: 16px; }
.ex h4 { margin: 12px 0 4px; font-size: 17px; }
.ex p { margin: 0; color: var(--muted); }
.ex-art { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; background: var(--ink); border-radius: 10px; padding: 14px; min-height: 58px; }
.mono { font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .02em; }
.arrow { color: var(--accent); font-weight: 700; }
.foot { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; color: var(--muted); font-size: 13px; padding: 40px 0 10px; }
.foot a { text-decoration: underline; text-underline-offset: 3px; }
.foot .on { font: italic 28px/1 var(--serif); text-decoration: none; color: var(--text); }

/* part colours */
.c-slate { --pc: var(--slate); } .c-blue { --pc: var(--blue); } .c-teal { --pc: var(--teal); } .c-amber { --pc: var(--amber); }
.c-violet { --pc: var(--violet); } .c-rose { --pc: var(--rose); } .c-green { --pc: var(--green); } .c-red { --pc: var(--redp); }
.chip { display: inline-flex; align-items: center; justify-content: center; min-width: 34px; height: 30px; padding: 0 9px; border-radius: 8px; font-weight: 700; font-size: 13px;
  background: var(--pc, var(--slate)); color: #fff; border: 0; cursor: pointer; white-space: nowrap; }
[data-theme="dark"] .c-amber .chip, [data-theme="dark"] .chip.c-amber { color: #0f0f0f; }
.chip.ghost { background: transparent; color: var(--pc); box-shadow: inset 0 0 0 1.5px var(--pc); }
.tint { background: color-mix(in srgb, var(--pc) 18%, var(--panel)) !important; box-shadow: inset 3px 0 0 var(--pc); }

/* chart */
.chart-bar { position: sticky; top: calc(env(safe-area-inset-top) + 60px); z-index: 15; display: flex; align-items: center; gap: 10px; max-width: 760px; margin: 0 auto; padding: 4px 16px 10px; background: var(--ink); }
.key-btn { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; min-width: 74px; min-height: 52px; padding: 4px 12px; border-radius: 12px; border: 0; background: var(--accent); color: var(--accent-ink); cursor: pointer; text-align: left; }
.key-btn small { font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; opacity: .75; line-height: 1.2; }
.key-btn b { font-size: 22px; line-height: 1.1; }
.seg { display: flex; background: var(--panel); border-radius: 12px; padding: 4px; }
.seg button { border: 0; background: transparent; padding: 0 12px; min-height: 44px; border-radius: 9px; font-weight: 700; color: var(--muted); cursor: pointer; white-space: nowrap; }
.seg button.on { background: var(--text); color: var(--ink); }
.facts { margin-left: auto; display: flex; flex-direction: column; align-items: flex-end; font-size: 13px; color: var(--muted); line-height: 1.3; }
.facts b { color: var(--text); font-size: 15px; }
.flow { display: flex; gap: 6px; overflow-x: auto; padding: 0 16px 8px; max-width: 760px; margin: 0 auto; scrollbar-width: none; }
.flow::-webkit-scrollbar { display: none; }
.flow .chip { opacity: .55; }
.flow .chip.on { opacity: 1; outline: 2px solid var(--text); outline-offset: 2px; }
.flow.edit .chip, .flow.add .chip { opacity: 1; }
.flow.edit, .flow.add { flex-wrap: wrap; padding: 0; overflow: visible; }
.lead-banner { max-width: 728px; margin: 0 auto 8px; padding: 10px 14px; border-radius: 12px; background: color-mix(in srgb, var(--accent) 16%, var(--panel)); font-size: 14px; font-weight: 600; width: calc(100% - 32px); }
.chart { gap: 10px; padding-bottom: 120px; }
.part { position: relative; background: var(--panel); border-radius: var(--r); padding: 12px 14px 14px 18px; overflow: hidden; scroll-margin-top: 150px; transition: box-shadow .2s; }
.part::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 5px; background: var(--pc); }
.part.here { box-shadow: 0 0 0 2.5px var(--pc); background: color-mix(in srgb, var(--pc) 12%, var(--panel)); }
.part-head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.part-name { font-weight: 600; color: var(--muted); font-size: 14px; }
.here-tag { margin-left: auto; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em; color: var(--pc); }
.chords { display: flex; flex-direction: column; gap: 2px; font-size: calc(26px * var(--chart-scale)); font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: .01em; }
.ln { display: flex; flex-wrap: wrap; align-items: baseline; column-gap: .55em; row-gap: 0; line-height: 1.35; }
.ln.blank { height: .5em; }
.ln.note, .part-notes { font-size: 15px; font-weight: 500; color: var(--muted); font-style: italic; }
.part-notes { margin-top: 6px; }
.tk.bar { color: var(--graphite); font-weight: 400; }
.tk.text, .tk.repeat { font-size: .62em; color: var(--muted); font-weight: 600; }
.tk.repeat { color: var(--pc); }
.tk.push::before { content: "<"; color: var(--pc); font-size: .7em; margin-right: 1px; }
.song-notes { color: var(--muted); padding: 4px 2px; white-space: pre-wrap; }

.play-nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; display: flex; align-items: center; gap: 10px; padding: 10px 14px calc(env(safe-area-inset-bottom) + 10px);
  background: color-mix(in srgb, var(--ink) 92%, transparent); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); border-top: 1px solid var(--line); }
.nav-btn { display: grid; place-items: center; width: 64px; height: 56px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); }
.nav-btn svg { width: 28px; height: 28px; }
.nav-btn.off { background: var(--panel); color: var(--graphite); pointer-events: none; }
.nav-mid { flex: 1; min-width: 0; text-align: center; display: flex; flex-direction: column; }
.nav-mid span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* editor */
.editor .grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.editor .grid .span2 { grid-column: span 3; }
.part.edit { display: flex; flex-direction: column; gap: 8px; }
.part.edit .part-head select { width: auto; padding: 8px 30px 8px 10px; font-weight: 600; }
.part.edit .tiny { width: 56px; padding: 8px; text-align: center; }
.part.edit textarea { font-weight: 700; font-size: 20px; font-variant-numeric: tabular-nums; line-height: 1.4; resize: vertical; }
.grow { flex: 1; }
.help { background: var(--panel); border-radius: var(--r); padding: 12px 16px; color: var(--muted); font-size: 14px; }
.help summary { cursor: pointer; font-weight: 600; color: var(--text); }
.help p { margin: 8px 0 0; line-height: 1.7; }

/* sheets */
.sheet-wrap { position: fixed; inset: 0; z-index: 50; }
.sheet-bg { position: absolute; inset: 0; background: rgba(0,0,0,.5); opacity: 0; transition: opacity .2s; }
.sheet { position: absolute; left: 0; right: 0; bottom: 0; max-height: 86dvh; overflow: auto; background: var(--panel); border-radius: 20px 20px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px);
  transform: translateY(100%); transition: transform .24s cubic-bezier(.2,.8,.2,1); max-width: 560px; margin: 0 auto; }
.sheet-wrap.open .sheet { transform: none; }
.sheet-wrap.open .sheet-bg { opacity: 1; }
.sheet-title { margin: 0 0 14px; font: italic 26px/1.1 var(--serif); font-weight: 400; }
.menu { display: flex; flex-direction: column; }
.menu button { display: flex; align-items: center; gap: 10px; min-height: 54px; padding: 0 6px; border: 0; background: none; text-align: left; font-size: 17px; font-weight: 500; border-bottom: 1px solid var(--line); cursor: pointer; }
.menu button:last-child { border: 0; justify-content: center; }
.menu .danger { color: var(--red); }
.key-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.key-grid.wide { grid-template-columns: repeat(2, 1fr); }
.key-grid button { min-height: 56px; border-radius: 12px; border: 0; background: var(--panel-2); font-size: 18px; font-weight: 700; cursor: pointer; }
.key-grid.wide button { font-size: 15px; text-align: left; padding: 0 14px; }
.key-grid button.on { background: var(--accent); color: var(--accent-ink); }
.sheet-search { margin-bottom: 10px; }
.pick { display: flex; flex-direction: column; margin-bottom: 12px; }
.pick button { display: flex; align-items: center; gap: 10px; min-height: 54px; border: 0; border-bottom: 1px solid var(--line); background: none; text-align: left; font-size: 16px; font-weight: 600; cursor: pointer; padding: 0 4px; }
.pick button span:first-child { flex: 1; }
.pick .added { width: 28px; height: 28px; border-radius: 50%; background: var(--panel-2); display: grid; place-items: center; }

#toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 92px); transform: translate(-50%, 20px); opacity: 0; z-index: 60; pointer-events: none;
  background: var(--text); color: var(--ink); padding: 10px 16px; border-radius: 12px; font-weight: 600; font-size: 14px; transition: .2s; max-width: calc(100% - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 720px) {
  .explain { grid-template-columns: repeat(3, 1fr); }
  .hero h2 { font-size: 60px; }
}
@media print {
  .top, .chart-bar, .flow, .play-nav, .lead-banner { display: none !important; }
  body { background: #fff; color: #000; }
  .part { break-inside: avoid; background: #fff; border: 1px solid #ddd; }
}

.hint.preview { background: var(--panel); border-radius: 12px; padding: 12px 14px; border: 1.5px dashed var(--accent); }

.pad-btn { display: inline-flex; align-items: center; gap: 7px; min-height: 44px; padding: 0 12px; border-radius: 12px; border: 0; background: var(--panel); font-weight: 700; font-size: 14px; color: var(--muted); cursor: pointer; white-space: nowrap; }
.pad-btn i { width: 8px; height: 8px; border-radius: 50%; background: var(--graphite); }
.pad-btn.waiting i { background: var(--accent); animation: pulse 1s infinite alternate; }
.pad-btn.linked { color: var(--text); box-shadow: inset 0 0 0 1.5px var(--violet); }
.pad-btn.linked i { background: var(--violet); box-shadow: 0 0 0 3px color-mix(in srgb, var(--violet) 30%, transparent); }

.tool { gap: 14px; }
.tool .row-main { flex-direction: column; align-items: flex-start; }
.tool .row-sub { white-space: normal; }
.tool-art { width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 18%, var(--panel-2)); color: var(--accent); flex: none; }
.tool-art.big { width: 64px; height: 64px; border-radius: 18px; }
.tool-art.big svg { width: 30px; height: 30px; }
.drop { align-items: center; text-align: center; padding: 28px 18px; }
.drop .inline { width: 100%; }
.drop-title { font: italic 400 30px/1.1 var(--serif); margin: 4px 0 0; }
.file-btn { cursor: pointer; }
.hint.err { color: var(--red); }
.hint.small { text-align: center; font-size: 13px; }
.pdf-head { padding: 4px 2px; }
.pdf-head .row-title { white-space: normal; }
.pdf-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.pdf-bar .btn.primary { margin-left: auto; }
.key-btn.ghost { background: var(--panel); color: var(--text); }
.arrow-big { color: var(--muted); display: grid; }
.step { display: flex; align-items: center; gap: 6px; }
.step .icon-btn { font-size: 22px; font-weight: 600; width: 44px; height: 52px; }
.pdf-pages { display: flex; flex-direction: column; gap: 12px; }
.pdf-page { display: block; border-radius: 6px; background: #fff; box-shadow: 0 1px 0 var(--line), 0 8px 30px rgba(0,0,0,.25); }
