/* Tabs — a practice tool. Neutral chrome, hairline structure, one accent reserved for playback and loops. */

:root {
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;

  --chrome: #ffffff;        /* bars, sidebar, menus */
  --canvas: #f1f1ee;        /* behind the sheet */
  --sheet: #ffffff;
  --hover: #f1f1ee;
  --press: #e8e8e4;
  --line: #e6e6e1;          /* hairlines */
  --line-strong: #d4d4ce;
  --text: #1b1b19;
  --text-2: #55554f;        /* >= 7:1 on chrome */
  --text-3: #7f7f78;        /* >= 4.5:1, for counts and hints only */
  --accent: #e8590c;        /* playhead, loop, active practice state */
  --accent-text: #b5410a;
  --accent-wash: rgb(232 89 12 / .10);
  --good: #2f6fb0;          /* progress: blue, so it never gets confused with the orange accent (red/green safe) */
  --paper: #fbf8f1;
  --ink: #1b1b19;           /* primary buttons are ink, not accent */
  --on-ink: #ffffff;
  --shadow: 0 1px 2px rgb(0 0 0 / .06), 0 8px 24px rgb(0 0 0 / .10);

  --hover-bg: var(--hover);
  --hover-press: var(--press);
  /* Layering: the sheet (and everything alphaTab draws into it) is always at the bottom; UI is always on top. */
  --z-sheet: 0; --z-chrome: 10; --z-loading: 20; --z-menu: 1000; --z-toast: 1100;
  --r: 6px;
  --h: 32px;                /* control height */
  --bar: 52px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --chrome: #171716;
    --canvas: #0e0e0d;
    --sheet: #ffffff;
    --hover: #222220;
    --press: #2a2a28;
    --line: #262624;
    --line-strong: #353532;
    --text: #ecece8;
    --text-2: #b6b6af;
    --text-3: #8a8a83;
    --accent: #ff6d1f;
    --accent-text: #ff9a5f;
    --accent-wash: rgb(255 109 31 / .14);
    --good: #6aa6e6;
    --paper: #1b1a17;
    --ink: #ecece8;
    --on-ink: #171716;
    --shadow: 0 1px 2px rgb(0 0 0 / .4), 0 12px 32px rgb(0 0 0 / .5);
    color-scheme: dark;
  }
}
@media (pointer: coarse) { :root { --h: 44px; } }

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 400 14px/20px var(--font); font-feature-settings: "cv11", "ss01"; letter-spacing: -0.003em;
  color: var(--text); background: var(--chrome); -webkit-font-smoothing: antialiased; overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button, input, select { font: inherit; color: inherit; letter-spacing: inherit; }
/* iOS Safari applies its own button/select chrome (and a blue text color) unless told not to. */
button, select, input[type="search"] { -webkit-appearance: none; appearance: none; }
select.mini-select { padding-right: 22px; background-image: linear-gradient(45deg, transparent 50%, currentColor 50%), linear-gradient(135deg, currentColor 50%, transparent 50%);
  background-position: calc(100% - 12px) 55%, calc(100% - 8px) 55%; background-size: 4px 4px; background-repeat: no-repeat; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
[hidden] { display: none !important; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
.meta { color: var(--text-2); }
.num, .time, .tempo, .count { font-variant-numeric: tabular-nums; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; border-radius: var(--r); }
:focus:not(:focus-visible) { outline: none; }

/* ---------- icons */
.i { width: 16px; height: 16px; flex: none; display: block; }

/* ---------- buttons: quiet by default; only primary and toggles carry state */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; flex: none;
  height: var(--h); padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r);
  background: var(--chrome); font-weight: 500; white-space: nowrap; text-decoration: none; color: var(--text);
  transition: background-color .12s, color .12s, border-color .12s;
}
.btn:hover { background: var(--hover-bg); }
.btn:active { background: var(--press); }
.btn:disabled { opacity: .4; cursor: default; background: none; }
.btn.ghost { border-color: transparent; background: none; color: var(--text-2); }
.btn.ghost:hover { background: var(--hover-bg); color: var(--text); }
.btn.icon { width: var(--h); padding: 0; }
.btn.sm { height: 24px; width: 24px; }
.btn.primary { background: var(--ink); border-color: var(--ink); color: var(--on-ink); }
.btn.primary:hover { opacity: .88; }
.btn.toggle { border-color: transparent; background: none; color: var(--text-2); }
.btn.toggle:hover { background: var(--hover-bg); color: var(--text); }
.btn.toggle[aria-pressed="true"] { color: var(--accent-text); background: var(--accent-wash); }

kbd { font: 500 12px/16px var(--font); padding: 0 5px; border-radius: 4px; border: 1px solid var(--line-strong); color: var(--text-3); }

/* segmented control */
.seg { display: inline-flex; padding: 2px; gap: 2px; border-radius: var(--r); background: var(--hover); }
.seg button { height: calc(var(--h) - 4px); padding: 0 10px; border: 0; border-radius: 4px; background: none; color: var(--text-2); font-weight: 500; }
.seg button:hover { color: var(--text); }
.seg button[aria-checked="true"] { background: var(--chrome); color: var(--text); box-shadow: 0 0 0 1px var(--line-strong); }

/* ---------- screens */
.screen { display: none; height: 100%; }
body[data-screen="library"] #library, body[data-screen="song"] #song { display: grid; }

.bar { display: flex; align-items: center; gap: 8px; height: var(--bar); padding: 0 12px; padding-top: env(safe-area-inset-top); border-bottom: 1px solid var(--line); background: var(--chrome); min-width: 0; }
.grow { flex: 1; }

/* ================= Library ================= */
#library { grid-template-rows: auto 1fr; }
/* wordmark width puts the search box on the same left edge as the page content (sidebar 228 + page padding 32) */
.wordmark { display: flex; align-items: center; color: var(--text); text-decoration: none; padding: 0 8px 0 4px; width: 240px; flex: none; }
.wordmark .logo { height: 34px; width: auto; display: block; overflow: visible; }
.search { position: relative; flex: 1; max-width: 520px; }
.search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); pointer-events: none; }
.search input { width: 100%; height: var(--h); padding: 0 34px; border: 1px solid transparent; border-radius: var(--r); background: var(--hover); outline: none; }
.search input::placeholder { color: var(--text-3); }
.search input:focus { background: var(--chrome); border-color: var(--line-strong); }
.search input::-webkit-search-cancel-button { display: none; }
.search-kbd { position: absolute; right: 8px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.search input:focus ~ .search-kbd, .search input:not(:placeholder-shown) ~ .search-kbd { display: none; }
.who { margin-left: auto; gap: 8px; color: var(--text); }
.who .meta { font-weight: 400; }

.lib { display: grid; grid-template-columns: 228px 1fr; min-height: 0; }
.side { border-right: 1px solid var(--line); padding: 12px 8px; overflow: auto; }
.side-item { display: flex; align-items: center; justify-content: space-between; gap: 8px; height: 32px; padding: 0 10px; border-radius: var(--r); color: var(--text-2); text-decoration: none; font-weight: 500; }
.side-item span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item:hover { background: var(--hover-bg); color: var(--text); }
.side-item[aria-current="true"] { background: var(--hover); color: var(--text); }
.side-item .count { color: var(--text-3); font-weight: 400; font-variant-numeric: tabular-nums; }
.side-head { display: flex; align-items: center; justify-content: space-between; height: 32px; margin-top: 16px; padding: 0 4px 0 10px; color: var(--text-3); font-size: 12px; font-weight: 500; }

.lib-main { overflow: auto; background: var(--chrome); }
.page { max-width: 1080px; padding: 28px 32px 64px; }
.page-head { display: flex; align-items: center; gap: 12px; height: 40px; margin-bottom: 16px; }
.page-head .title { display: flex; align-items: baseline; gap: 12px; min-width: 0; flex: 1; }
.page-head h1 { font-size: 22px; line-height: 28px; font-weight: 600; letter-spacing: -0.02em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-head .meta { white-space: nowrap; }
.page-head .actions { margin-left: auto; display: flex; gap: 8px; }
.title-input { font: 600 22px/28px var(--font); letter-spacing: -0.02em; border: 0; border-bottom: 1px solid var(--line-strong); background: none; padding: 0; outline: none; min-width: 0; width: 100%; max-width: 420px; color: var(--text); }

/* song table */
.table { border-top: 1px solid var(--line); }
.row { display: grid; grid-template-columns: var(--cols); align-items: center; gap: 16px; min-height: 52px; padding: 6px 8px; border-bottom: 1px solid var(--line); text-decoration: none; color: inherit; cursor: pointer; position: relative; background: var(--chrome); }
.row:hover { background: var(--hover-bg); }
.row.head { min-height: 32px; cursor: default; color: var(--text-2); font-size: 12px; font-weight: 500; }
.row.head:hover { background: var(--chrome); }
.row.head button { border: 0; background: none; padding: 0; color: inherit; font-weight: inherit; display: inline-flex; gap: 4px; align-items: center; }
.row.head button:hover, .row.head button[aria-sort] { color: var(--text); }
.table.songs { --cols: minmax(0, 3fr) minmax(0, 2fr) 120px 104px 32px; }
.table.set { --cols: 16px 20px minmax(0, 3fr) minmax(0, 2fr) 120px 32px; }
.cell { min-width: 0; }
.cell .t { display: block; font-size: 15px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .s { display: block; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cell .s.warn { color: var(--accent-text); }
.cell.faint, .cell .faint { color: var(--text-3); }
.cell.idx { color: var(--text-3); text-align: right; font-variant-numeric: tabular-nums; }
.grip { color: var(--text-3); cursor: grab; touch-action: none; display: flex; }
.row.dragging { box-shadow: var(--shadow); z-index: 2; cursor: grabbing; }
.row .btn.icon { opacity: 0; }
.row:hover .btn.icon, .row .btn.icon[aria-expanded="true"] { opacity: 1; }
@media (pointer: coarse) { .row .btn.icon { opacity: 1; } }

.progress { display: flex; align-items: center; gap: 8px; color: var(--text-2); font-variant-numeric: tabular-nums; font-size: 12px; }
.progress .track { flex: 1; height: 3px; border-radius: 2px; background: var(--line); overflow: hidden; max-width: 64px; }
.progress .track i { display: block; height: 100%; background: var(--good); }

.empty { padding: 40px 0; color: var(--text-2); max-width: 440px; }
.empty h2 { color: var(--text); font-size: 15px; font-weight: 600; margin-bottom: 4px; }
.empty .btn { margin-top: 16px; }


/* ================= Menus (popovers) ================= */
.menu { position: fixed; z-index: var(--z-menu); min-width: 220px; max-width: min(420px, calc(100vw - 16px)); max-height: min(70vh, 560px); overflow: auto;
  padding: 4px; border-radius: 8px; background: var(--chrome); border: 1px solid var(--line-strong); box-shadow: var(--shadow); }
.menu-label { padding: 8px 8px 4px; font-size: 12px; font-weight: 500; color: var(--text-3); }
.menu-item { display: flex; align-items: center; gap: 8px; width: 100%; min-height: 32px; padding: 6px 8px; border: 0; border-radius: 4px; background: none; text-align: left; color: var(--text); text-decoration: none; }
.menu-item:hover, .menu-item.active { background: var(--hover-bg); }
.menu-item .grow { min-width: 0; }
.menu-item .meta { font-size: 12px; white-space: nowrap; }
.menu-item .check { width: 16px; color: var(--text); flex: none; }
.menu-item.danger { color: #d23c3c; }
.menu-sep { height: 1px; margin: 4px -4px; background: var(--line); }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 6px 8px; min-height: 40px; }
.menu-row > span { color: var(--text-2); }
.menu .stack { display: flex; flex-direction: column; min-width: 0; }
.menu .stack .meta { font-size: 12px; line-height: 16px; }
.menu-item .also { margin-left: auto; opacity: 0; }
.menu-item:hover .also, .menu-item .also[aria-pressed="true"] { opacity: 1; }
@media (pointer: coarse) { .menu-item .also { opacity: 1; } }
.menu .fader { justify-content: space-between; padding: 6px 8px; min-height: 40px; }
.menu .fader input { width: 160px; }

/* search results */
.menu.results { max-width: none; }
.result { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 6px 6px 6px 8px; border-radius: 4px; cursor: pointer; }
.result:hover, .result.active { background: var(--hover-bg); }
.result .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .s { color: var(--text-2); font-size: 12px; line-height: 16px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.result .btn { height: 28px; border-color: transparent; background: none; color: var(--text-2); }
.result .btn:hover { background: var(--chrome); border-color: var(--line-strong); color: var(--text); }
.result .added { display: inline-flex; align-items: center; gap: 4px; height: 28px; padding: 0 8px; color: var(--text-3); font-weight: 500; }
.note { padding: 10px 8px; color: var(--text-2); }

/* ================= Song ================= */
#song { grid-template-rows: auto auto 1fr auto auto; background: var(--canvas); }
.songbar { gap: 4px; }
.back { padding: 0 8px 0 4px; gap: 2px; max-width: 200px; }
.back span { overflow: hidden; text-overflow: ellipsis; }
.song-id { display: flex; align-items: center; gap: 8px; min-width: 0; height: var(--h); padding: 0 8px 0 10px; margin-left: 4px; border: 0; border-radius: var(--r); background: none; }
.song-id:hover, .song-id[aria-expanded="true"] { background: var(--hover-bg); }
.song-id .i { color: var(--text-3); }
#s-title { font-size: 15px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#s-artist { color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.part { border-color: transparent; background: var(--hover); gap: 8px; padding: 0 8px 0 10px; max-width: 360px; }
.part:hover { background: var(--hover-press); }
.part > span { overflow: hidden; text-overflow: ellipsis; }
.part .meta { font-weight: 400; }
.part .meta.warn, .menu .warn { color: var(--accent-text); }
.part .i { color: var(--text-3); }
.setnav { display: flex; align-items: center; gap: 2px; margin-right: 8px; padding-right: 8px; border-right: 1px solid var(--line); }
.setnav .meta { min-width: 44px; text-align: center; font-variant-numeric: tabular-nums; }

/* song map: sections drawn to scale */
.map { position: relative; height: 40px; background: var(--chrome); border-bottom: 1px solid var(--line); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.map::-webkit-scrollbar { display: none; }
.map-track { position: relative; display: flex; height: 100%; min-width: 100%; }
.sec { position: relative; flex: var(--w) 0 0; min-width: 64px; display: flex; align-items: center; padding: 0 10px; border: 0; border-right: 1px solid var(--line); background: none;
  font-size: 13px; font-weight: 500; color: var(--text-2); white-space: nowrap; overflow: hidden; text-align: left; user-select: none; -webkit-touch-callout: none; }
.sec span { overflow: hidden; text-overflow: ellipsis; }
.sec:hover { background: var(--hover-bg); color: var(--text); }
.sec.now { color: var(--text); }
.sec.loop { background: var(--accent-wash); color: var(--accent-text); }
.sec .best { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--good); }
.playhead { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--accent); pointer-events: none; }

.viewport { overflow: auto; position: relative; padding: 24px; overscroll-behavior: contain; }
.sheet { max-width: 1240px; margin: 0 auto; min-height: 320px; background: var(--paper); border-radius: 3px; box-shadow: 0 0 0 1px var(--line); user-select: none; -webkit-touch-callout: none; transition: background-color .2s; }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 10px; color: var(--text-2); background: var(--canvas); z-index: var(--z-loading); }
.spinner { width: 14px; height: 14px; border-radius: 50%; border: 1.5px solid var(--line-strong); border-top-color: var(--text-2); animation: spin .7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* alphaTab. alphaTab fonts can only be regular or bold; Comfort's tab digits read best at semibold, where
   0 and 8 keep open counters. Override the weight of the SVG text it emits (alphaTab sets the font inline). */
.sheet text[style*="Atkinson"][style*="bold"] { font-weight: 600 !important; }
.at-cursor-bar { background: rgb(232 89 12 / .07); }
.at-cursor-beat { background: var(--accent); width: 2px; }
.at-selection div { background: rgb(232 89 12 / .12); }
.at-highlight * { fill: var(--accent); stroke: var(--accent); }

/* string names next to the tab lines (positioned from alphaTab's layout) */
/* alphaTab puts its cursor/selection layers at z-index 1000. isolation seals the sheet into its own stacking
   context, so nothing drawn in it can ever rise above the app's bars, menus or toasts. */
.sheet { position: relative; isolation: isolate; z-index: var(--z-sheet); }
.viewport { isolation: isolate; }
.bar, .map, .practice, .transport { position: relative; z-index: var(--z-chrome); }
.string-labels { position: absolute; inset: 0; pointer-events: none; }
.string-labels span { position: absolute; transform: translate(-100%, -50%); font: 600 11px/1 "Atkinson Hyperlegible Next", var(--font); color: var(--label-ink, #6f6a62); letter-spacing: 0; }

/* practice strip: appears when you're looping something */
.practice { display: flex; align-items: center; gap: 20px; min-height: 44px; padding: 6px 12px 6px 16px; background: var(--chrome); border-top: 1px solid var(--line); flex-wrap: wrap; }
.pr-what { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.pr-what b { font-weight: 600; white-space: nowrap; }
.pr-what .meta { white-space: nowrap; }
.pr-group { display: flex; align-items: center; gap: 8px; color: var(--text-2); white-space: nowrap; }
.pr-group b { color: var(--text); font-weight: 500; font-variant-numeric: tabular-nums; }
.pr-group label { display: flex; align-items: center; gap: 8px; cursor: pointer; }
.pr-sep { width: 1px; height: 20px; background: var(--line); }
.pr-end { margin-left: auto; display: flex; gap: 4px; align-items: center; }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 6px; height: 6px; border-radius: 50%; background: var(--line-strong); }
.pips i.on { background: var(--good); }
.mini-select { height: 24px; padding: 0 4px; border: 0; border-radius: 4px; background: var(--hover); color: var(--text); font-variant-numeric: tabular-nums; cursor: pointer; }
.switch { position: relative; width: 28px; height: 16px; flex: none; appearance: none; -webkit-appearance: none; margin: 0; border-radius: 8px; background: var(--line-strong); cursor: pointer; transition: background .15s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 12px; height: 12px; border-radius: 50%; background: #fff; transition: transform .15s; }
.switch:checked { background: var(--text); }
.switch:checked::after { transform: translateX(12px); background: var(--chrome); }

/* transport */
.transport { position: relative; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; height: 56px; padding: 0 12px; padding-bottom: env(safe-area-inset-bottom); box-sizing: content-box; background: var(--chrome); border-top: 1px solid var(--line); }
.t-play, .t-tools, .t-mix { display: flex; align-items: center; gap: 4px; }
.t-mix { justify-content: flex-end; gap: 20px; }
.btn.play { width: 40px; height: 40px; padding: 0; border: 0; border-radius: 50%; background: var(--ink); color: var(--on-ink); margin-left: 2px; }
.btn.play .i { width: 14px; height: 14px; }
.btn.play:hover { opacity: .88; background: var(--ink); }
.btn.play:disabled { opacity: .3; background: var(--ink); }
.time { margin-left: 10px; color: var(--text); min-width: 88px; }
.time .meta { color: var(--text-3); }
.stepper { display: flex; align-items: center; margin: 0 4px; }
.tempo { display: flex; flex-direction: column; align-items: center; justify-content: center; height: var(--h); min-width: 56px; border: 0; background: none; padding: 0 2px; line-height: 14px; border-radius: var(--r); }
.tempo:hover { background: var(--hover-bg); }
.tempo #sp-pct { font-weight: 500; }
.tempo .meta { font-size: 12px; }
.tempo.changed #sp-pct { color: var(--accent-text); }
.fader { display: flex; align-items: center; gap: 10px; color: var(--text-2); font-weight: 500; }
#mix-btn { display: none; }
input[type="range"] { -webkit-appearance: none; appearance: none; width: 96px; height: 20px; background: none; margin: 0; cursor: pointer; }
input[type="range"]::-webkit-slider-runnable-track { height: 2px; border-radius: 1px; background: linear-gradient(var(--text-2), var(--text-2)) 0 / var(--fill, 100%) 100% no-repeat, var(--line-strong); }
input[type="range"]::-moz-range-track { height: 2px; border-radius: 1px; background: var(--line-strong); }
input[type="range"]::-moz-range-progress { height: 2px; background: var(--text-2); }
input[type="range"]::-webkit-slider-thumb { -webkit-appearance: none; width: 12px; height: 12px; margin-top: -5px; border-radius: 50%; background: var(--chrome); border: 1.5px solid var(--text); }
input[type="range"]::-moz-range-thumb { width: 10px; height: 10px; border-radius: 50%; background: var(--chrome); border: 1.5px solid var(--text); }
.sf { position: absolute; right: 12px; bottom: 100%; margin-bottom: 8px; display: flex; align-items: center; gap: 8px; padding: 4px 10px; border-radius: var(--r); background: var(--chrome); border: 1px solid var(--line); color: var(--text-2); font-size: 12px; }
.sf-bar { width: 64px; height: 2px; background: var(--line); overflow: hidden; }
.sf-bar i { display: block; height: 100%; width: 0; background: var(--text-2); }

/* stage mode: band play. Sheet, map, play, set navigation. */
body.stage #part-btn, body.stage #view-btn, body.stage #more-btn, body.stage #add-song, body.stage .t-tools, body.stage .t-mix, body.stage .practice { display: none !important; }
body.stage .viewport { padding: 12px; }

/* ================= Dialog, toast ================= */
.dialog { width: min(420px, calc(100vw - 32px)); padding: 24px; border: 1px solid var(--line-strong); border-radius: 10px; background: var(--chrome); color: var(--text); box-shadow: var(--shadow); }
.dialog::backdrop { background: rgb(0 0 0 / .35); }
.dialog h2 { font-size: 17px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; }
.dialog form > .meta { margin-top: 4px; }
.field { display: flex; flex-direction: column; gap: 6px; margin-top: 20px; }
.field > span { font-weight: 500; }
.field input { height: 36px; padding: 0 10px; border: 1px solid var(--line-strong); border-radius: var(--r); background: var(--chrome); font-size: 14px; outline: none; }
.field input:focus { border-color: var(--text-2); }
.field .seg { align-self: flex-start; flex-wrap: wrap; }
.actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 24px; }
.toast { position: fixed; left: 50%; bottom: 76px; z-index: var(--z-toast); transform: translate(-50%, 8px); padding: 8px 14px; border-radius: var(--r); background: var(--ink); color: var(--on-ink); font-weight: 500;
  opacity: 0; pointer-events: none; transition: opacity .15s, transform .15s; max-width: calc(100vw - 32px); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* ================= Song switcher ================= */
.switcher { width: 420px; padding: 0; overflow: hidden; display: flex; flex-direction: column; }
.switcher .sw-search { position: relative; border-bottom: 1px solid var(--line); }
.switcher .sw-search .i { position: absolute; left: 12px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.switcher input { width: 100%; height: 44px; padding: 0 12px 0 36px; border: 0; background: none; font-size: 15px; outline: none; }
.switcher .sw-list { overflow: auto; padding: 4px; max-height: min(60vh, 480px); }
.sw-item { display: grid; grid-template-columns: 20px 1fr auto; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; border: 0; border-radius: 4px; background: none; text-align: left; }
.sw-item:hover, .sw-item.active { background: var(--hover-bg); }
.sw-item .n { color: var(--text-3); font-variant-numeric: tabular-nums; text-align: right; }
.sw-item .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.sw-item .s { color: var(--text-2); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: block; }
.sw-item .tag { font-size: 12px; color: var(--text-3); }
.sw-item[aria-current="true"] .t { color: var(--accent-text); }

/* ================= Reordering ================= */
.table.reordering .row:not(.lifted) { transition: transform .2s cubic-bezier(.2, .8, .2, 1); }
.row.lifted { z-index: 3; background: var(--chrome); box-shadow: 0 2px 4px rgb(0 0 0 / .08), 0 12px 28px rgb(0 0 0 / .18); border-radius: var(--r); cursor: grabbing; }
.row.settling { transition: transform .18s cubic-bezier(.2, .8, .2, 1), box-shadow .18s; box-shadow: none; }
body.dragging, body.dragging * { cursor: grabbing !important; user-select: none !important; }

/* ================= Accessibility preferences ================= */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition-duration: 0s !important; animation-duration: 0s !important; scroll-behavior: auto !important; }
}
/* Increase Contrast (iOS/macOS/Windows): push secondary text and hairlines further, in both color schemes. */
/* A gentle step up, not a different look: secondary text and hairlines get a little stronger, the hierarchy stays. */
@media (prefers-contrast: more) {
  :root { --line: #dad9d2; --line-strong: #c2c1b9; --text-2: #4a4a44; --text-3: #6c6c65; }
}
@media (prefers-contrast: more) and (prefers-color-scheme: dark) {
  :root { --line: #2c2c2a; --line-strong: #3f3f3b; --text-2: #c2c2bb; --text-3: #979790; }
}

/* ================= Narrow screens ================= */
@media (max-width: 1080px) {
  .t-mix .fader { display: none; }
  #mix-btn { display: inline-flex; }
}
@media (max-width: 760px) {
  .bar { padding: 0 8px; }
  .wordmark { width: auto; }
  .who .meta { display: none; }
  .lib { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .side { display: flex; gap: 4px; align-items: center; padding: 8px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .side-item { flex: none; }
  .side-head { margin: 0 0 0 4px; padding: 0; order: 9; } .side-head > span { display: none; }
  #side-sets { display: contents; }
  .page { padding: 20px 16px 48px; }
  .page-head { flex-wrap: wrap; height: auto; min-height: 40px; }
  .page-head .actions { width: 100%; justify-content: flex-start; }
  .table.songs { --cols: minmax(0, 1fr) 72px 32px; }
  .table.set { --cols: 16px minmax(0, 1fr) 72px 32px; }
  .table .hide-sm { display: none; }

  .songbar .song-id { flex: 1; min-width: 0; padding: 0 6px; margin: 0; } #s-artist { display: none; }
  .back span { display: none; }
  .part { max-width: 40%; } .part .meta { display: none; }
  .switcher { width: calc(100vw - 16px); }
  #stage-btn, .setnav .meta { display: none; }
  .setnav { margin-right: 0; padding-right: 4px; }
  .viewport { padding: 8px; }
  .practice { gap: 8px 16px; padding: 8px 12px; }
  .pr-sep { display: none; }
  .transport { grid-template-columns: auto 1fr auto; gap: 8px; padding: 0 8px; }
  .time { min-width: 0; font-size: 12px; margin-left: 6px; } .time .meta { display: none; }
  .t-tools { justify-content: center; gap: 0; }
  .t-tools .btn.toggle { padding: 0 8px; }
  #t-count, #t-click { display: none; }
}


/* ================= Touch (iPad / phone) =================
   Apple HIG sizes, no sticky hover after a tap, real pressed states, no accidental selection or callouts,
   no rubber-banding of the whole page, and controls you can hit with a thumb on a music stand. */
html, body { overscroll-behavior: none; }
button, a, input, select, .row, .sec, .chip { touch-action: manipulation; }
.bar, .map, .transport, .practice, .side, .menu, .page-head, .row, .switcher, .dialog h2 { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
@media (hover: none) {
  :root { --hover-bg: transparent; --hover-press: transparent; }
  .btn:active, .btn.ghost:active, .btn.toggle:active, .menu-item:active, .sw-item:active, .result:active,
  .row:active, .side-item:active, .sec:active, .tempo:active, .song-id:active, .part:active, .seg button:active { background-color: var(--press); }
  .btn.play:active { opacity: .8; }
}
@media (pointer: coarse) {
  .bar { height: 60px; }
  .btn.sm { height: 36px; width: 36px; }
  .menu { padding: 6px; }
  .menu-item, .sw-item, .result { min-height: 48px; }
  .menu-row { min-height: 52px; }
  .side-item { height: 44px; }
  .row { min-height: 64px; }
  .map { height: 48px; }
  .sec { min-width: 76px; font-size: 14px; }
  .transport { height: 68px; gap: 12px; }
  .btn.play { width: 52px; height: 52px; }
  .btn.play .i { width: 18px; height: 18px; }
  .i { width: 18px; height: 18px; }
  .tempo { min-width: 64px; }
  .practice { min-height: 56px; }
  .mini-select { height: 36px; padding: 0 8px; font-size: 15px; }
  .switch { width: 44px; height: 26px; border-radius: 13px; }
  .switch::after { width: 20px; height: 20px; top: 3px; left: 3px; }
  .switch:checked::after { transform: translateX(18px); }
  .seg button { padding: 0 14px; }
  /* Faders: a tall hit area and a big thumb; touch anywhere on the track to set it (see main.js). */
  input[type="range"] { height: 44px; width: 140px; touch-action: none; }
  input[type="range"]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; }
  input[type="range"]::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: -12px; border-width: 2px; box-shadow: 0 1px 4px rgb(0 0 0 / .25); }
  .menu .fader input { width: 200px; }
}
.retune-menu .menu-row > span { white-space: nowrap; }
.retune-menu .note { max-width: 380px; }
.retune-menu select { max-width: 200px; }

/* Middle widths (iPad portrait, small laptops): drop secondary text before anything crowds. */
@media (max-width: 1100px) and (min-width: 761px) {
  #s-artist { display: none; }
  #add-song { width: var(--h); padding: 0; font-size: 0; gap: 0; }
  .part { max-width: 260px; }
  .page { padding: 24px 24px 56px; }
  .lib { grid-template-columns: 200px 1fr; }
  .wordmark { width: 212px; }
  .table.songs { --cols: minmax(0, 3fr) minmax(0, 2fr) 104px 32px; }
  .table.songs .row > :nth-child(4) { display: none; }
  .table.set { --cols: 16px 20px minmax(0, 3fr) minmax(0, 2fr) 104px 32px; }
}

/* ================= Sessions ================= */
/* Avatar: initials on a soft tint of the person's session color, with a ring in that color.
   The inner gap is the surface color, so stacked avatars read as separate coins. */
.av { --c: var(--text-3); --size: 26px; position: relative; display: inline-grid; place-items: center; flex: none; width: var(--size); height: var(--size); border-radius: 50%;
  font: 600 calc(var(--size) * .4)/1 var(--font); letter-spacing: 0; color: var(--text);
  background: color-mix(in srgb, var(--c) 22%, var(--chrome)); box-shadow: 0 0 0 2px var(--chrome), 0 0 0 4px var(--c); }
.av.sm { --size: 18px; font-size: 9px; box-shadow: 0 0 0 1.5px var(--chrome), 0 0 0 3px var(--c); }
.av.lg { --size: 34px; }
.av.head { --size: 28px; align-self: center; margin: 0 6px 0 4px; }
.av.away { filter: grayscale(1); opacity: .5; }
.av.more { --c: var(--line-strong); background: var(--hover); color: var(--text-2); font-size: 10px; }

/* The session button in both top bars */
.session-btn { flex: none; }
.session-btn.on { display: inline-flex; align-items: center; gap: 8px; height: var(--h); padding: 0 10px 0 12px; border: 0; border-radius: 999px; background: none; }
.session-btn.on:hover, .session-btn.on[aria-expanded="true"] { background: var(--hover-bg); }
.av-stack { display: inline-flex; align-items: center; }
.av-stack .av + .av { margin-left: -5px; }
.av-stack .av.pop { animation: av-in .32s cubic-bezier(.2, .9, .3, 1.3); }
@keyframes av-in { from { transform: scale(.4); opacity: 0; } }
.live { width: 7px; height: 7px; border-radius: 50%; background: #2fb36d; box-shadow: 0 0 0 0 rgb(47 179 109 / .5); animation: live 2.4s ease-out infinite; }
.live.wait { background: #f5a524; animation: none; }
@keyframes live { 0% { box-shadow: 0 0 0 0 rgb(47 179 109 / .45); } 70%, 100% { box-shadow: 0 0 0 6px rgb(47 179 109 / 0); } }
#library .session-btn { margin-left: auto; }
#library .session-btn + .who { margin-left: 0; }
body.stage .session-btn { display: none !important; }

/* The session panel */
.menu.session-menu { width: 380px; max-width: calc(100vw - 16px); max-height: min(80vh, 640px); padding: 6px; }
.ses-start { padding: 18px 16px 14px; text-align: center; }
.ses-art { display: flex; justify-content: center; margin: 4px 0 16px; }
.ses-art .av { --size: 34px; }
.ses-art .av + .av { margin-left: -8px; }
.ses-art .av:nth-child(1) { transform: translateY(3px); } .ses-art .av:nth-child(4) { transform: translateY(3px); }
.ses-start h3, .ses-head h3 { font-size: 17px; line-height: 24px; font-weight: 600; letter-spacing: -0.01em; }
.ses-start p { margin-top: 6px; color: var(--text-2); }
.ses-start .fine { font-size: 12px; color: var(--text-3); margin-top: 10px; }
.btn.wide { width: 100%; margin-top: 16px; height: 40px; }
.ses { padding: 6px 6px 2px; }
.ses-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 4px 4px 10px; }
.ses-state { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); white-space: nowrap; }
.dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; }
.dot.live { background: #2fb36d; } .dot.wait { background: #f5a524; }
.ses-invite { display: flex; gap: 14px; align-items: center; padding: 12px; border-radius: 8px; background: var(--hover); }
.qr { width: 104px; height: 104px; flex: none; padding: 7px; border-radius: 6px; background: #fff; }  /* dark-on-white in any theme: every camera reads it */
.qr svg { display: block; width: 100%; height: 100%; }
.ses-invite-text { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.ses-invite-text .meta { font-size: 12px; line-height: 16px; }
.ses-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.ses-actions .btn { height: 30px; padding: 0 10px; }
.ses-people { display: flex; flex-direction: column; padding: 2px 0 4px; }
.ses-person { display: flex; align-items: center; gap: 12px; padding: 8px 6px 8px 8px; border-radius: 6px; min-height: 52px; }
.ses-person .stack { display: flex; flex-direction: column; min-width: 0; }
.ses-person .name { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ses-person .stack > .meta { font-size: 12px; line-height: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ses-person.is-away .name { color: var(--text-2); }
.tag { display: inline-block; margin-left: 4px; padding: 0 6px; border-radius: 4px; font-size: 11px; line-height: 17px; font-weight: 500; color: var(--text-2); background: var(--hover); vertical-align: 1px; }
.btn.sm-text { height: 28px; padding: 0 10px; font-size: 13px; }

/* Shared libraries in the sidebar */
.side-peer { margin-top: 4px; }
.side-head.peer { justify-content: flex-start; gap: 10px; margin-top: 20px; padding-left: 12px; color: var(--text-2); }
.side-head.peer > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-peer .side-item[aria-current="true"] { background: color-mix(in srgb, var(--c) 14%, var(--chrome)); }
.side-item .i.saved { width: 14px; height: 14px; color: var(--text-3); }

/* Someone else's songs / setlist */
.table.peer { --cols: minmax(0, 3fr) minmax(0, 2fr) 120px 84px; }
.table.set.remote { --cols: 20px minmax(0, 3fr) minmax(0, 2fr) 120px 44px; }
.cell.end { display: flex; justify-content: flex-end; }
.btn.quiet { height: 28px; border-color: transparent; background: none; color: var(--text-2); padding: 0 8px; }
.btn.quiet:hover { background: var(--chrome); border-color: var(--line-strong); color: var(--text); }
.row:hover .btn.quiet { border-color: var(--line-strong); background: var(--chrome); color: var(--text); }
.added { display: inline-flex; align-items: center; gap: 4px; color: var(--text-3); font-weight: 500; padding: 0 8px; }
.saved-note { display: inline-flex; align-items: center; gap: 6px; height: var(--h); color: var(--text-2); font-weight: 500; }
.saved-link { color: var(--text-2); }

@media (max-width: 760px) {
  #side-peers, .side-peer { display: contents; }
  .side-head.peer { margin: 0 0 0 10px; padding: 0 2px 0 6px; order: 0; flex: none; }
  .side-head.peer > span:last-child { display: none; }
  .side-head.peer > .av { display: inline-grid; }
  .table.peer { --cols: minmax(0, 1fr) 72px 48px; }
  .table.set.remote { --cols: minmax(0, 1fr) 72px 32px; }
  .session-btn.on { padding: 0 6px; }
  .songbar .session-btn.on .live { display: none; }
}
@media (pointer: coarse) {
  .ses-person { min-height: 60px; }
  .btn.sm-text { height: 36px; }
  .ses-actions .btn { height: 38px; }
}
