/* Shared look for the touch views (tools/views). */
:root {
  --bg: #0e1115; --surface: #161a20; --surface-2: #1d222a; --surface-3: #262c35;
  --ink: #e9edf1; --muted: #8b96a3; --faint: #5b6572; --rule: #2a313b;
  --accent: #6cb6cf; --hit: #4aa3ff; --on: #43d17a; --warn: #f0b04a; --danger: #ff6b5b;
  --lcd: #c9d8c2; --lcd-ink: #1c2a1a;
  --sans: system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;
  /* one colour per effect type, shared by vocal and guitar */
  --c-hardtune: #e2583f; --c-transducer: #d4a72c; --c-double: #36a77f; --c-harmony: #3f7fe2;
  --c-umod: #8c5ed8; --c-delay: #2aa8bb; --c-reverb: #b9c2cc; --c-bodyrez: #b67b45; --c-comp: #6f7b88;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.4 var(--sans); -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
.mono { font-family: var(--mono); }

/* Common top bar: preset selector + view switcher (same on every view; .big = stage size) */
:root { --barh: 58px; }
.pbar { position: sticky; top: 0; z-index: 60; height: var(--barh); display: flex; align-items: center; gap: 12px; padding: 0 12px; background: #0a0c0ff0; backdrop-filter: blur(8px); border-bottom: 1px solid var(--rule); }

.pbar .tag { font: 600 10px var(--mono); letter-spacing: .08em; color: var(--warn); border: 1px solid #f0b04a55; border-radius: 4px; padding: 2px 5px; white-space: nowrap; }
.pbar .sp { flex: 1; }
.psel { position: relative; display: flex; align-items: center; gap: 6px; min-width: 0; }
.pstep { width: 42px; height: 42px; border-radius: 10px; border: 1px solid var(--rule); background: var(--surface-2); color: var(--ink); font-size: 15px; cursor: pointer; flex: none; }
.pstep:active { background: var(--surface-3); }
.pname { display: flex; align-items: baseline; gap: 10px; height: 42px; padding: 0 12px; border-radius: 10px; border: 1px solid transparent; background: none; cursor: pointer; min-width: 0; touch-action: pan-y; }
.pname:hover, .pname[aria-expanded=true] { border-color: var(--rule); background: var(--surface); }
.pnum { font: 700 20px var(--mono); color: var(--accent); }
.pnm { font: 700 19px var(--sans); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 32vw; }
.car { color: var(--muted); font-size: 12px; }
.pinfo { font: 600 14px var(--mono); color: var(--muted); white-space: nowrap; }
.plist { position: absolute; top: calc(100% + 8px); left: 48px; width: 320px; max-height: 60vh; display: grid; grid-template-rows: auto 1fr; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; box-shadow: 0 16px 40px #000c; overflow: hidden; z-index: 70; }
.plist[hidden] { display: none; }
.plist input { margin: 10px; background: var(--bg); border: 1px solid var(--rule); border-radius: 8px; color: var(--ink); padding: 9px 10px; font: inherit; }
.pitems { overflow: auto; padding: 0 6px 8px; }
.pitems button { display: flex; gap: 12px; width: 100%; text-align: left; background: none; border: 0; border-radius: 8px; padding: 10px; cursor: pointer; font-size: 15px; }
.pitems button span { font: 600 14px var(--mono); color: var(--muted); width: 26px; }
.pitems button:hover { background: var(--surface-2); }
.pitems button.sel { background: var(--surface-3); } .pitems button.sel span { color: var(--accent); }
.pitems .none { padding: 12px; color: var(--muted); font-size: 13px; }
.views { display: flex; gap: 2px; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; padding: 3px; flex: none; }
.views a { display: grid; justify-items: center; gap: 0; min-width: 56px; padding: 4px 8px; border-radius: 9px; color: var(--muted); text-decoration: none; font: 600 10px var(--sans); letter-spacing: .04em; }
.views a b { font-size: 16px; line-height: 1.1; font-weight: 400; }
.views a:hover { color: var(--ink); }
.views a.on { background: var(--surface-3); color: var(--ink); }
.pbar.big .pstep { width: 84px; height: 84px; border-radius: 18px; font-size: 32px; }
.pbar.big .pname { height: 84px; }
.pbar.big .pnum { font-size: 24px; } .pbar.big .pnm { font-size: 40px; font-weight: 800; max-width: 46vw; }
.pbar.big .plist { left: 92px; width: 380px; }
.pbar.big .pitems button { padding: 14px 10px; font-size: 18px; }
html.bigbar { --barh: 104px; }
@media (max-width: 760px) {
  :root { --barh: 104px; } html.bigbar { --barh: 128px; }
  .pbar { flex-wrap: wrap; align-content: center; row-gap: 6px; gap: 6px; padding: 6px 10px; }
  .pinfo, .pbar .sp, .busy { display: none; } .conn span { display: none; }
  .psel { flex: 1; } .pname { flex: 1; } .pnm { max-width: none; font-size: 17px; } .pbar.big .pnm { font-size: 24px; }
  .pbar.big .pstep { width: 60px; height: 60px; font-size: 24px; } .pbar.big .pname { height: 60px; }
  .views { width: 100%; } .views a { flex: 1; min-width: 0; grid-auto-flow: column; gap: 6px; align-items: center; justify-content: center; padding: 6px 4px; }
  .plist { left: 0; width: min(340px, calc(100vw - 20px)); }
}

/* Firmware pictures (92x48, lit pixels opaque): drawn with the picture as a mask so they take any colour */
.art { display: block; aspect-ratio: 92 / 48; background: currentColor; -webkit-mask: var(--m) center / contain no-repeat; mask: var(--m) center / contain no-repeat; image-rendering: pixelated; }

/* Knob */
.knob { display: inline-grid; justify-items: center; gap: 2px; touch-action: none; user-select: none; cursor: ns-resize; --kc: var(--accent); }
.knob svg { display: block; overflow: visible; }
.knob .kv { font: 600 12px var(--mono); color: var(--ink); white-space: nowrap; }
.knob .kl { font: 600 10px var(--sans); letter-spacing: .06em; color: var(--muted); text-transform: uppercase; white-space: nowrap; }
.knob:focus-visible { outline: 2px solid var(--accent); outline-offset: 4px; border-radius: 8px; }

/* State chip OFF / ON / HIT */
.st { font: 700 10px var(--mono); letter-spacing: .08em; padding: 2px 6px; border-radius: 4px; background: var(--surface-3); color: var(--faint); }
.st.on { background: #43d17a22; color: var(--on); }
.st.hit { background: #4aa3ff22; color: var(--hit); }

.note { font-size: 12px; color: var(--muted); }
.note b { color: var(--ink); font-weight: 600; }

/* ── connection chip + popover ── */
.cwrap { position: relative; flex: none; }
.conn { display: flex; align-items: center; gap: 6px; height: 34px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--rule); background: var(--surface); cursor: pointer; font: 700 11px var(--mono); letter-spacing: .06em; color: var(--muted); text-transform: uppercase; }
.conn i { width: 8px; height: 8px; border-radius: 50%; background: var(--warn); }
.conn[data-s=ready] { color: var(--ink); } .conn[data-s=ready] i { background: var(--on); box-shadow: 0 0 8px var(--on); }
.conn[data-s=connecting] i { background: var(--accent); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }
.cpop { position: absolute; top: calc(100% + 10px); left: 0; width: 320px; z-index: 75; background: var(--surface); border: 1px solid var(--rule); border-radius: 12px; box-shadow: 0 16px 40px #000c; padding: 14px; display: grid; gap: 10px; }
.cpop[hidden] { display: none; }
.cpop label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.cpop label.chk { display: flex; align-items: center; gap: 8px; }
.cpop select { background: var(--bg); color: var(--ink); border: 1px solid var(--rule); border-radius: 8px; padding: 8px; font: 13px var(--sans); }
.cmsg { font: 600 13px var(--sans); }
.crow { display: flex; gap: 8px; }
.crow button, .pfoot button, .busy button { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 12px; cursor: pointer; font-size: 13px; }
.crow button.pri { background: var(--accent); color: #06212b; border-color: var(--accent); font-weight: 700; }
.pfoot { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 10px; border-top: 1px solid var(--rule); }
.plist { grid-template-rows: auto 1fr auto; }
.busy { font: 600 12px var(--mono); color: var(--accent); white-space: nowrap; }
.busy[hidden] { display: none; }

/* ── fader ── */
.fader { display: grid; grid-template-columns: 1fr 76px; align-items: center; gap: 10px; min-height: 34px; cursor: ew-resize; }
.ftrack { position: relative; height: 26px; border-radius: 8px; background: var(--bg); border: 1px solid var(--rule); overflow: hidden; }
.ffill { position: absolute; top: 0; bottom: 0; background: var(--fc, var(--accent)); opacity: .75; }
.fader.active .ftrack { border-color: var(--fc, var(--accent)); box-shadow: 0 0 0 3px color-mix(in srgb, var(--fc, var(--accent)) 25%, transparent); }
.fval, .ftype { font: 600 12px var(--mono); text-align: right; color: var(--ink); }
.ftype { width: 100%; background: var(--bg); border: 1px solid var(--accent); border-radius: 5px; padding: 3px 6px; }

/* knob feedback */
.knob.active svg, .knob.fine svg { filter: drop-shadow(0 0 6px var(--kc)); }
.knob.fine .kv::after { content: " · fine"; color: var(--warn); }

/* toast */
.patoast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 100; background: var(--surface-3); color: var(--ink); font: 600 14px var(--mono); padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 24px #000a; opacity: 0; pointer-events: none; transition: opacity .3s; white-space: nowrap; }
.patoast.show { opacity: 1; transition: none; }
/* detail sheet */
.sheet-bg { position: fixed; inset: 0; background: #000a; display: none; z-index: 80; }
.sheet { position: fixed; left: 0; right: 0; bottom: 0; max-height: 78vh; overflow: auto; z-index: 90; background: var(--surface); border-top: 3px solid var(--pc); border-radius: 18px 18px 0 0; padding: 18px 20px 28px; transform: translateY(105%); transition: transform .25s ease; }
.sheet.open { transform: none; } .sheet.open + .sheet-bg, .sheet-bg.open { display: block; }
.sh-head { display: flex; align-items: center; gap: 16px; }
.sh-head .art { width: 120px; color: var(--pc); }
.sh-head h3 { margin: 0; font-size: 22px; }
.sh-head .x { margin-left: auto; background: var(--surface-3); border: 0; border-radius: 50%; width: 36px; height: 36px; cursor: pointer; font-size: 18px; }
.seg { display: inline-flex; border: 1px solid var(--rule); border-radius: 8px; overflow: hidden; }
.seg button { background: none; border: 0; padding: 8px 14px; cursor: pointer; font: 700 12px var(--mono); color: var(--muted); }
.seg button.sel { background: var(--surface-3); color: var(--ink); }
.seg button.sel[data-s="on"] { color: var(--on); } .seg button.sel[data-s="hit"] { color: var(--hit); }
.sh-sec { margin-top: 18px; } .sh-sec h4 { margin: 0 0 8px; font-size: 11px; letter-spacing: .12em; color: var(--muted); text-transform: uppercase; }
.styles { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: 8px; }
.styles button { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 8px; padding: 8px 6px 6px; cursor: pointer; display: grid; gap: 4px; color: var(--muted); font: 600 10px var(--mono); }
.styles button .art { color: #cfd6dd; width: 72px; justify-self: center; }
.styles button.sel { border-color: var(--pc); color: var(--ink); background: color-mix(in srgb, var(--pc) 18%, var(--surface-2)); }
.styles button.sel .art { color: var(--pc); }
.bigknobs { display: flex; gap: 22px; flex-wrap: wrap; }
.pitems .inlib { margin-left: auto; color: var(--on); font-style: normal; font-size: 9px; align-self: center; }
.libinfo { line-height: 1.4; }

/* no pedal yet: cover the view (values are never made up) */
.nopedal { position: fixed; left: 0; right: 0; bottom: 0; top: var(--barh); z-index: 55; background: var(--bg); display: grid; place-items: center; padding: 24px 16px; }
.nopedal[hidden], .offbar[hidden] { display: none; }
.npbox { max-width: 460px; display: grid; gap: 12px; text-align: center; justify-items: center; }
.npbox h2 { margin: 0; font-size: 24px; } .npbox .npmsg { margin: 0; color: var(--muted); } .npbox .note a { color: var(--accent); }
.npbox .crow[hidden] { display: none; } .npbox .crow button { padding: 12px 18px; font-size: 15px; }
.offbar { position: fixed; top: var(--barh); left: 0; right: 0; z-index: 58; display: flex; align-items: center; justify-content: center; gap: 12px; padding: 6px 12px; background: #3a2a0b; color: var(--warn); font: 600 13px var(--sans); }
.offbar button { background: var(--warn); color: #241800; border: 0; border-radius: 6px; padding: 5px 10px; font: 700 12px var(--sans); cursor: pointer; }
.npsim { display: flex; align-items: center; gap: 10px; margin-top: 6px; padding-top: 14px; border-top: 1px solid var(--rule); }
.npsim button { background: var(--surface-2); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 14px; cursor: pointer; font-size: 14px; color: var(--ink); }
/* hide a view's own markup until its script has drawn it (no half-built page on a view switch) */
html:not(.pa-drawn) body > :not(.pbar):not(.nopedal):not(.offbar) { visibility: hidden; }
/* Touch app, not a document: a long press shouldn't select text, show the iOS copy/lookup callout or flash a grey tap box.
   Text fields keep normal selection so you can still edit what you type. */
html { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
input, textarea, select, [contenteditable] { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
