/* Writers Desk: Progression Studio layout system + BarForge brand red. Self-hosted, no frameworks. */
:root {
  --bg: #FFFFFF;
  --surface: #FFFFFF;
  --surface-2: #F3F4F6;
  --surface-3: #E9EAEE;
  --border: #E4E6EB;
  --border-strong: #D1D5DB;
  --text: #14161A;
  --muted: #6B7280;
  --faint: #9CA3AF;
  --ink: #14161A;
  --ink-contrast: #FFFFFF;
  --accent: #C21E1E;
  --accent-2: #A51818;
  --accent-soft: rgba(194, 30, 30, .09);
  --ok: #0F9D58;
  --warn: #B26A00;
  --danger: #DC2626;
  --radius: 14px;
  --pill: 999px;
  --shadow: 0 1px 2px rgba(16,24,40,.06), 0 8px 24px rgba(16,24,40,.08);
  --font-display: 'Poppins', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', 'Segoe UI', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', ui-monospace, Consolas, monospace;
  --maxw: 1240px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0E0E0F; --surface: #151517; --surface-2: #1C1C1F; --surface-3: #242428;
    --border: #2A2A2F; --border-strong: #3A3A40; --text: #F1F1F3; --muted: #A1A1AA; --faint: #6B6B74;
    --ink: #F1F1F3; --ink-contrast: #0E0E0F; --accent: #E0403F; --accent-2: #F05A59; --accent-soft: rgba(224, 64, 63, .14);
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35); color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0E0E0F; --surface: #151517; --surface-2: #1C1C1F; --surface-3: #242428;
  --border: #2A2A2F; --border-strong: #3A3A40; --text: #F1F1F3; --muted: #A1A1AA; --faint: #6B6B74;
  --ink: #F1F1F3; --ink-contrast: #0E0E0F; --accent: #E0403F; --accent-2: #F05A59; --accent-soft: rgba(224, 64, 63, .14);
  --shadow: 0 1px 2px rgba(0,0,0,.4), 0 8px 24px rgba(0,0,0,.35); color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }
body { font: 15px/1.55 var(--font-body); background: var(--bg); color: var(--text); -webkit-font-smoothing: antialiased; min-height: 100dvh; }
a { color: inherit; text-decoration: none; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; cursor: pointer; }
img, svg { display: block; flex-shrink: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.15; letter-spacing: -.015em; }
h1 { font-size: clamp(2rem, 5vw, 3.1rem); letter-spacing: -.02em; }
h2 { font-size: 1.45rem; }
h3 { font-size: 1.1rem; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 6px; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 24px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.row-gap { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.stack > * + * { margin-top: 14px; }
.spacer { flex: 1; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.center { text-align: center; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.note { color: var(--muted); font-size: .84rem; line-height: 1.5; }
.note.error, .form-error { color: var(--danger); font-size: .86rem; }
.form-error:empty { display: none; }
.accent { color: var(--accent); }
.eyebrow { font-family: var(--font-display); font-size: .75rem; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); margin-bottom: 12px; }
.lead { font-size: 1.12rem; color: var(--muted); max-width: 60ch; margin-top: 16px; }
.link { color: var(--accent); font-weight: 600; text-decoration: underline; text-underline-offset: 3px; padding: 0; }

/* buttons (Progression Studio pills) */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 20px; border-radius: var(--pill);
  font-family: var(--font-display); font-weight: 600; font-size: .9rem; border: 1px solid transparent; white-space: nowrap;
  transition: background .15s, border-color .15s, opacity .15s; touch-action: manipulation; }
.btn-primary { background: var(--ink); color: var(--ink-contrast); }
.btn-primary:hover { opacity: .88; }
.btn-accent { background: var(--accent); color: #fff; }
.btn-accent:hover { background: var(--accent-2); }
.btn-ghost { border-color: var(--border); background: var(--surface); }
.btn-ghost:hover { background: var(--surface-2); }
.btn-sm { padding: 6px 13px; font-size: .82rem; }
.btn-block { width: 100%; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.icon-btn { display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 10px; color: var(--muted); flex-shrink: 0; }
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn:disabled { opacity: .35; cursor: default; }
.icon-btn:disabled:hover { background: transparent; color: var(--muted); }

/* forms */
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
input:focus, select:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
input[type=range] { width: 100%; accent-color: var(--accent); }
.field { display: grid; gap: 5px; font-size: .85rem; font-weight: 500; }
.field > span { color: var(--muted); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 12px; }
.form-grid .field:last-child { grid-column: span 2; }

/* brand */
.brand { display: inline-flex; align-items: center; gap: 10px; }
.brand-name { font-family: var(--font-display); font-weight: 800; letter-spacing: .02em; font-size: 1.02rem; }
.brand-name b { font-weight: 500; }

/* library */
.site-header { border-bottom: 1px solid var(--border); background: var(--surface); position: sticky; top: 0; z-index: 5; }
.site-header .wrap { height: 64px; }
.account-chip { display: flex; align-items: center; gap: 10px; font-weight: 500; }
.avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font: 700 .78rem var(--font-display); }
.hero { padding: 56px 0 28px; background: radial-gradient(900px 300px at 85% -10%, var(--accent-soft), transparent 70%); }
.notice { margin-top: 22px; display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 12px; background: var(--surface-2); color: var(--muted); font-size: .9rem; max-width: 720px; }
.notice svg { margin-top: 3px; color: var(--accent); }
.library-section { padding-bottom: 64px; }
.section-head { margin: 18px 0 18px; }
.song-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 16px; }
.song-card { display: flex; flex-direction: column; gap: 10px; min-height: 168px; padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface);
  transition: box-shadow .15s, transform .15s, border-color .15s; }
.song-card:hover { box-shadow: var(--shadow); transform: translateY(-2px); }
.card-top { display: flex; align-items: flex-start; gap: 8px; }
.card-title { font-family: var(--font-display); font-size: 1.02rem; flex: 1; min-width: 0; overflow-wrap: anywhere; }
.card-del { width: 30px; height: 30px; opacity: 0; }
.song-card:hover .card-del, .card-del:focus-visible { opacity: 1; }
.card-preview { flex: 1; color: var(--muted); font-size: .88rem; line-height: 1.5; font-family: var(--font-mono); display: grid; }
.card-foot { display: flex; justify-content: space-between; font-size: .78rem; color: var(--faint); }
.offline-badge { color: var(--accent); font-weight: 600; text-transform: uppercase; letter-spacing: .04em; font-size: .7rem; }
.new-card { align-items: center; justify-content: center; text-align: center; border-style: dashed; border-width: 2px; color: var(--text); }
.new-plus { width: 52px; height: 52px; border-radius: 50%; background: var(--accent-soft); color: var(--accent); display: grid; place-items: center; }

/* editor workspace */
.editor-view { display: flex; flex-direction: column; height: var(--vvh, 100dvh); overflow: hidden; }
.topbar { height: 56px; display: flex; align-items: center; gap: 8px; padding: 0 10px; border-bottom: 1px solid var(--border); background: var(--surface); flex-shrink: 0; }
.topbar .logo-mark { margin: 0 2px; }
.title-input { flex: 0 1 380px; min-width: 80px; font: 600 1.02rem var(--font-display); border: 1px solid transparent !important; background: transparent !important; padding: 6px 8px !important; }
.title-input:hover { border-color: var(--border) !important; }
.title-input:focus { border-color: var(--accent) !important; }
.group-select { flex: 0 1 160px; min-width: 0; font: 500 .85rem var(--font-body); color: var(--muted); border: 1px solid var(--border); border-radius: 8px; background: var(--surface-2); padding: 5px 8px; }
.group-select:hover, .group-select:focus { border-color: var(--accent); color: var(--text); }
.save-state { font-size: .78rem; color: var(--faint); white-space: nowrap; }
.save-state.ok { color: var(--ok); }
.save-state.err { color: var(--danger); }
.workspace { flex: 1; display: flex; min-height: 0; }
.write-area { flex: 1; min-width: 0; overflow-y: auto; background: var(--bg); }
.tools { width: clamp(330px, 30vw, 430px); flex-shrink: 0; border-left: 1px solid var(--border); background: var(--surface); display: flex; min-height: 0; }
.tools > * { flex: 1; min-width: 0; }

.editor { max-width: 860px; margin: 0 auto; padding: 28px 12px 120px; font-family: var(--font-mono); }
.line { display: flex; align-items: flex-start; position: relative; border-radius: 8px; }
.line.active { background: var(--surface-2); }
.line.bar-start { margin-top: 26px; }
.line.bar-start::before { content: attr(data-bar); position: absolute; left: 50px; right: 52px; top: -19px; display: flex; align-items: center;
  font: 700 .64rem var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--faint);
  background: linear-gradient(var(--border), var(--border)) left 50% / 100% 1px no-repeat; }
.line-num { width: 40px; flex-shrink: 0; text-align: right; padding: 9px 10px 0 0; font-size: .74rem; color: var(--faint); font-variant-numeric: tabular-nums; user-select: none; }
.line.active .line-num { color: var(--muted); }
.line-bar { width: 3px; align-self: stretch; margin: 5px 0; border-radius: 2px; flex-shrink: 0; transition: background .2s; }

/* One editable line of plain text; rhyming words are coloured in place (see ::highlight in editor.ts) */
.line-input { flex: 1; min-width: 0; outline: none; font: 15.5px/1.7 var(--font-mono); padding: 5px 10px; min-height: 36px;
  white-space: pre-wrap; overflow-wrap: anywhere; caret-color: var(--accent); cursor: text; }
.line-input.blank[data-placeholder]::before { content: attr(data-placeholder); color: var(--faint); font-style: italic; pointer-events: none; }

.line-meta { width: 52px; flex-shrink: 0; display: flex; justify-content: flex-end; gap: 6px; padding: 10px 6px 0 0; font-size: .72rem; user-select: none; font-variant-numeric: tabular-nums; }
.line-syl { color: var(--muted); }
.line-letter { font-weight: 800; color: var(--faint); min-width: 10px; text-align: center; }
.line-letter.alone { font-weight: 600; opacity: .7; }
.line[style*="--rhyme"] .line-letter { color: var(--rhyme); }
.line.section { margin-top: 22px; }
.line.section .line-input { font: 700 .82rem/2 var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--accent); }
.line.section .line-bar { background: transparent !important; }

.statusbar { height: 30px; flex-shrink: 0; display: flex; align-items: center; gap: 16px; padding: 0 14px; border-top: 1px solid var(--border); background: var(--surface); font-size: .72rem; color: var(--muted); overflow: hidden; white-space: nowrap; }
.statusbar .st b { font-size: .64rem; letter-spacing: .12em; color: var(--faint); margin-right: 5px; }
.statusbar .hint { color: var(--faint); }

/* forge panel */
.forge { display: flex; flex-direction: column; min-height: 0; }
.forge-head { padding: 12px 12px 0; border-bottom: 1px solid var(--border); }
.forge-search { display: flex; align-items: center; gap: 8px; padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface-2); color: var(--muted); }
.forge-search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.forge-search-input { border: 0 !important; background: transparent !important; box-shadow: none !important; padding: 9px 0 !important; font-family: var(--font-mono); color: var(--text); }
.forge-tabs { display: flex; gap: 2px; margin-top: 10px; }
.forge-tab { flex: 1; padding: 9px 4px; font: 600 .82rem var(--font-display); color: var(--muted); border-bottom: 2px solid transparent; }
.forge-tab[aria-selected="true"] { color: var(--text); border-color: var(--accent); }
.forge-body { flex: 1; overflow-y: auto; padding: 14px 14px 32px; }
.forge-word { display: flex; align-items: center; gap: 10px; margin-bottom: 8px; }
.forge-word-text { font: 700 1.3rem var(--font-mono); color: var(--accent); }
.stress { display: inline-flex; align-items: center; gap: 3px; }
.stress i { width: 6px; height: 6px; border-radius: 50%; background: var(--border-strong); }
.stress i.mid { width: 7px; height: 7px; background: var(--muted); }
.stress i.on { width: 9px; height: 9px; background: var(--accent); }
.forge-word .icon-btn { margin-left: auto; width: 32px; height: 32px; }
.pills { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0 4px; }
.pill { padding: 3px 11px; border-radius: var(--pill); border: 1px solid var(--border); font-size: .78rem; color: var(--muted); }
.pill[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.section-label { display: flex; align-items: center; gap: 8px; margin: 16px 0 8px; font: 700 .66rem var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.section-label::after { content: ''; flex: 1; height: 1px; background: var(--border); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 11px; border-radius: 8px; background: var(--surface-2); font: 500 .88rem var(--font-mono); border: 1px solid transparent; text-align: left; }
.chip:hover { border-color: var(--accent); color: var(--accent); }
.chip.common { background: var(--surface-3); font-weight: 600; }
.chip-removable { display: inline-flex; padding: 0; overflow: hidden; }
.chip-main { padding: 5px 4px 5px 11px; font: inherit; }
.chip-x { padding: 5px 9px; color: var(--faint); }
.chip-x:hover { color: var(--danger); }
.chip[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.group-bar { margin-bottom: 14px; }
.empty { display: grid; gap: 6px; text-align: center; padding: 48px 12px; color: var(--muted); font-size: .88rem; }
.empty strong { color: var(--text); font-size: .95rem; }
.stat-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.stat { padding: 12px 8px; border-radius: 12px; background: var(--surface-2); text-align: center; display: grid; }
.stat b { font: 700 1.25rem var(--font-display); }
.stat span { font-size: .72rem; color: var(--muted); text-transform: uppercase; letter-spacing: .08em; }
.meter-words { display: flex; flex-wrap: wrap; gap: 10px 14px; margin-bottom: 14px; font-family: var(--font-mono); }
.meter-word { display: grid; justify-items: center; gap: 4px; }
.ideas-out { margin-top: 12px; display: grid; gap: 10px; }
.idea-card { border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px; }
.idea-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; color: var(--accent); font-size: .82rem; }
.idea-line { display: flex; justify-content: space-between; gap: 8px; font: .86rem/1.6 var(--font-mono); }
.idea-line em { color: var(--faint); font-style: normal; font-weight: 700; }

.idea-summary { display: grid; gap: 10px; padding: 12px; border-radius: 12px; background: var(--surface-2); margin-bottom: 12px; }
.summary-facts { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.fact { display: grid; font-size: .8rem; }
.fact span { color: var(--faint); font-size: .66rem; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; }
.fact b { font-family: var(--font-mono); font-weight: 600; }
.idea-card { display: grid; gap: 8px; margin-bottom: 10px; }
.idea-title { font: 600 .9rem var(--font-display); }
.idea-sub { font-size: .74rem; color: var(--muted); font-weight: 600; margin-top: 2px; }
.idea-quote { font: .86rem/1.5 var(--font-mono); color: var(--text); padding-left: 10px; border-left: 3px solid var(--accent); }
.small-chips .chip { padding: 3px 9px; font-size: .8rem; }
.suggestion { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 10px; background: var(--surface-2); }
.suggestion-text { font: .86rem/1.45 var(--font-mono); min-width: 0; overflow-wrap: anywhere; }
.suggestion-meta { font-size: .72rem; font-variant-numeric: tabular-nums; }
.forge-tab.locked::after { content: ''; display: inline-block; width: 6px; height: 6px; margin-left: 5px; border-radius: 50%; background: var(--accent); vertical-align: middle; opacity: .8; }
.unlock { display: grid; gap: 12px; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: linear-gradient(180deg, var(--accent-soft), transparent 60%); }
.unlock h3 { font-size: 1.05rem; }
.unlock p { color: var(--muted); font-size: .88rem; line-height: 1.5; }
.unlock-badge { display: inline-flex; align-items: center; gap: 6px; width: max-content; padding: 3px 10px; border-radius: 999px; background: var(--accent); color: #fff; font: 700 .68rem var(--font-body); letter-spacing: .06em; text-transform: uppercase; }
.unlock-ways { list-style: none; display: grid; gap: 10px; }
.unlock-ways li { display: grid; gap: 2px; padding: 10px 12px; border-radius: 10px; background: var(--surface-2); font-size: .85rem; }
.unlock-ways li span { color: var(--muted); }
.ideas-loading { display: flex; align-items: center; gap: 10px; padding: 24px 8px; color: var(--muted); font-size: .88rem; }
.spinner { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.view-tabs { display: flex; align-items: center; gap: 4px; margin-bottom: 12px; }
.view-tab { padding: 5px 11px; border-radius: 999px; border: 1px solid var(--border); font: 600 .78rem var(--font-display); color: var(--muted); }
.view-tab[aria-pressed="true"] { background: var(--ink); border-color: var(--ink); color: var(--ink-contrast); }
.view-tab:disabled { opacity: .4; cursor: not-allowed; }
.doctor-facts { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: .8rem; }
.source-tag { display: inline-block; margin-left: 8px; padding: 1px 7px; border-radius: 999px; background: var(--surface-3); color: var(--muted); font: 600 .62rem var(--font-body); letter-spacing: .04em; text-transform: uppercase; vertical-align: middle; }
.fit-ok { color: var(--ok); }
.fit-off { color: var(--warn); }
.suggestion .btn { padding: 4px 10px; }

/* audio */
.audio { overflow-y: auto; padding: 4px 14px 32px; }
.panel-block { padding: 14px 0; border-bottom: 1px solid var(--border); display: grid; gap: 10px; }
.panel-block:last-child { border: 0; }
.block-label { font: 700 .66rem var(--font-body); letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.bpm-row { display: flex; align-items: baseline; gap: 6px; }
.bpm-value { font: 700 2rem var(--font-display); }
.beat-file { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.rec-row { display: flex; align-items: center; gap: 12px; }
.rec-btn { width: 56px; height: 56px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; box-shadow: 0 0 0 4px var(--accent-soft); flex-shrink: 0; }
.rec-btn.on { animation: pulse 1.2s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 10px var(--accent-soft); } }
.rec-time { font: 600 1.1rem var(--font-mono); font-variant-numeric: tabular-nums; }
.take { display: grid; gap: 8px; padding: 12px; border-radius: 12px; background: var(--surface-2); }
.take audio, .take-item audio { width: 100%; height: 36px; }
.take-item { display: grid; grid-template-columns: 1fr auto; gap: 6px 8px; align-items: center; padding: 10px 0; border-bottom: 1px solid var(--border); }
.take-item audio { grid-column: 1 / -1; grid-row: 2; }
.take-meta { display: grid; min-width: 0; }

/* modal + palette + toast */
.modal { margin: auto; width: min(440px, calc(100vw - 32px)); border: 1px solid var(--border); border-radius: 18px; padding: 22px; background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.modal::backdrop { background: rgba(10, 10, 12, .45); backdrop-filter: blur(2px); }
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; }
.tour-highlight { position: fixed; z-index: 998; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(0, 0, 0, .88), 0 0 0 2px var(--accent); pointer-events: none; transition: top .2s ease, left .2s ease, width .2s ease, height .2s ease; }
.tour-card { position: fixed; z-index: 999; width: min(300px, calc(100vw - 20px)); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: 14px; padding: 14px 16px; box-shadow: var(--shadow); transition: top .2s ease, left .2s ease; }
.tour-card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 6px; }
.tour-card-head h4 { margin: 0; font: 700 1.02rem var(--font-display); }
.tour-card p { margin: 0 0 12px; line-height: 1.45; font-size: .89rem; color: var(--muted); }
.tour-card-foot { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.tour-counter { font-size: .76rem; color: var(--faint); white-space: nowrap; }
.select-modal { width: min(640px, calc(100vw - 32px)); }
.select-text { margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); font-family: var(--font-mono); font-size: .95rem; line-height: 1.6; white-space: pre-wrap; overflow-wrap: anywhere; max-height: min(55vh, 460px); overflow: auto; user-select: text; -webkit-user-select: text; -webkit-touch-callout: default; }
.history-list { display: grid; gap: 8px; max-height: min(60vh, 520px); overflow: auto; }
.history-item { display: grid; gap: 2px; text-align: left; padding: 12px 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); color: var(--text); cursor: pointer; font: inherit; }
.history-item:hover, .history-item:focus-visible { border-color: var(--accent); outline: none; }
.history-when { color: var(--muted); font-size: .8rem; }
.history-line { color: var(--muted); font-family: var(--font-mono); font-size: .9rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-preview { margin: 0; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg); font-family: var(--font-mono); font-size: .9rem; line-height: 1.6; white-space: pre-wrap; max-height: min(50vh, 420px); overflow: auto; }
.history-actions { display: flex; justify-content: flex-end; gap: 8px; }
.palette { padding: 8px; width: min(560px, calc(100vw - 32px)); margin-top: 14vh; }
.palette-input { border: 0 !important; box-shadow: none !important; font-size: 1rem !important; padding: 12px !important; }
.palette-list { list-style: none; max-height: 50vh; overflow-y: auto; border-top: 1px solid var(--border); padding-top: 6px; }
.palette-list li { display: flex; justify-content: space-between; align-items: center; padding: 9px 12px; border-radius: 8px; cursor: pointer; font-size: .92rem; }
.palette-list li[aria-selected="true"] { background: var(--accent-soft); color: var(--accent); }
kbd { font: .72rem var(--font-mono); padding: 2px 6px; border: 1px solid var(--border); border-radius: 5px; color: var(--muted); }
#toasts { position: fixed; left: 50%; bottom: 74px; transform: translateX(-50%); display: grid; gap: 8px; z-index: 50; width: min(440px, calc(100vw - 32px)); }
.toast { padding: 11px 16px; border-radius: 12px; background: var(--ink); color: var(--ink-contrast); font-size: .9rem; box-shadow: var(--shadow); transition: opacity .3s, transform .3s; }
.toast.error { background: var(--danger); color: #fff; }
.toast.ok { background: var(--ok); color: #fff; }
.toast.out { opacity: 0; transform: translateY(8px); }

/* inside Progression Studio: the desk is the whole window there, with a link back in the song list */
html, body { overflow-x: clip; max-width: 100%; }
html { overscroll-behavior-x: none; }
body { overscroll-behavior-x: none; }
/* The editor is an app shell: vertical scrolling only, so a stray sideways drag cannot pan it. */
.editor-view { touch-action: pan-y; overscroll-behavior: contain; }
.editor-view .editor, .editor-view .tools { overflow-x: clip; max-width: 100%; }
.editor-view .rhyme-strip { touch-action: pan-x; }
.in-host { overflow: hidden; overscroll-behavior: none; }
.in-host > body { position: fixed; inset: 0; width: 100%; height: 100%; overflow: hidden; overscroll-behavior: none; }
.in-host .editor-view { height: 100vh; height: var(--vvh, 100dvh); }
.in-host .topbar { height: 48px; }
.in-host .site-header { position: static; }
.in-host .hero { padding: 28px 0 16px; }
.in-host .hero .lead, .in-host .hero .notice { display: none; }
.in-host .tools { width: 320px; }

/* mobile */
.mobile-nav { display: none; }
.genre-btn { display: none; }
@media (max-width: 860px) {
  .hide-sm { display: none !important; }
  .genre-btn:not([hidden]) { display: inline-grid; }
  .wrap { padding: 0 16px; }
  .hero { padding: 36px 0 20px; }
  .tools { display: none; }
  .editor-view.tools-open .tools { display: flex; position: fixed; left: 0; right: 0; bottom: calc(58px + env(safe-area-inset-bottom)); height: 38dvh; width: auto;
    border: 1px solid var(--border); border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px rgba(0,0,0,.15); z-index: 10; }
  .statusbar { display: none; }
  .mobile-nav { display: grid; grid-template-columns: repeat(4, 1fr); border-top: 1px solid var(--border); background: var(--surface); padding-bottom: env(safe-area-inset-bottom); flex-shrink: 0; }
  .mobile-nav button { display: grid; justify-items: center; gap: 2px; padding: 8px 0; font-size: .7rem; color: var(--muted); }
  .mobile-nav button.on { color: var(--accent); }
  .editor { padding: 18px 4px 100px; }
  .line-num { width: 28px; padding-right: 6px; }
  .line-meta { width: 44px; }
  .line.bar-start::before { left: 34px; right: 44px; }
  .card-del { opacity: 1; }
  .title-input { flex: 1; min-width: 0; }
  .editor-view .topbar .logo-mark { display: none; }
  /* One more icon (genre) joined this row than it was built for: trim gap/padding/icon size a
     touch so the title keeps roughly the same room it always had, instead of being squeezed to
     a sliver by the new button. */
  .editor-view .topbar { gap: 2px; padding: 0 7px; }
  .editor-view .topbar .icon-btn { width: 34px; height: 34px; }
  .editor-view .topbar .panel-toggle { width: auto; height: 34px; padding: 0 10px; }
  .card-del { width: 40px; height: 40px; }
  .notice .link { display: inline-block; padding: 10px 2px; }
  .editor-view .topbar .spacer { display: none; }
  .editor-view .save-state { width: 8px; height: 8px; min-width: 8px; border-radius: 50%; overflow: hidden; text-indent: -999px; white-space: nowrap; background: currentColor; color: var(--faint); margin: 0 2px; }
  .editor-view .save-state.ok { color: var(--ok); }
  .editor-view .save-state.err { color: var(--danger); }
  .brand-name { white-space: nowrap; font-size: .9rem; }
  .site-header .row-gap { gap: 6px; flex-wrap: nowrap; }
  .site-header .btn-sm { padding-left: 10px; padding-right: 10px; }
}
@media (max-width: 340px) {
  .brand-name { display: none; }
}

/* Continue with Progression Studio */
.or-rule { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: .08em; }
.or-rule::before, .or-rule::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* first visit: what Writers Desk does */
.hero-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 22px; }
.features { padding-bottom: 64px; }
.features h2 { margin-bottom: 18px; }
.feature-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 14px; }
.feature { padding: 18px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.feature strong { display: block; margin: 10px 0 6px; font-family: var(--font-display); }
.feature p { color: var(--muted); font-size: .92rem; }
.feature-icon { display: inline-grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.site-footer { border-top: 1px solid var(--border); padding: 18px 0; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* phones: quick rhymes above the bottom bar */
.rhyme-strip { display: none; }
@media (max-width: 860px) {
  .rhyme-strip:not([hidden]) { display: flex; gap: 6px; align-items: center; overflow-x: auto; padding: 8px 12px; border-top: 1px solid var(--border);
    background: var(--surface); flex-shrink: 0; scrollbar-width: none; }
  .rhyme-strip::-webkit-scrollbar { display: none; }
  .rhyme-strip .chip { flex: none; }
  .strip-label { flex: none; font-size: .72rem; font-weight: 700; color: var(--accent); text-transform: uppercase; letter-spacing: .06em; margin-right: 2px; }
  .editor-view.tools-open .rhyme-strip { display: none; }
}

/* account: 18+ setting */
.check-row { display: flex; gap: 10px; align-items: flex-start; font-size: .9rem; color: var(--muted); }
.check-row input { margin-top: 3px; accent-color: var(--accent); }

/* song coach */
.coach-note { padding: 8px 0; border-bottom: 1px solid var(--border); }
.coach-note:last-child { border-bottom: 0; }
.coach-note p { font-size: .88rem; margin-top: 3px; }
.coach-lines { font: 600 .68rem var(--font-body); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }

/* song coach */
.coach-note { padding: 8px 0; border-bottom: 1px solid var(--border); }
.coach-note:last-child { border-bottom: 0; }
.coach-note p { font-size: .88rem; margin-top: 3px; }
.coach-lines { font: 600 .68rem var(--font-body); text-transform: uppercase; letter-spacing: .06em; color: var(--accent); }

.pitch-row { display: flex; align-items: center; gap: 10px 14px; flex-wrap: wrap; }
.pitch-block .block-label { display: flex; align-items: center; gap: 8px; }
.pitch-row select { flex: 1; min-width: 180px; }
.pitch-row[hidden] { display: none; }
.pitch-readout { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.pitch-note { font: 700 2.2rem var(--font-mono); min-width: 3.2ch; color: var(--ink); }
.pitch-note.good { color: var(--ok); }
.pitch-note.warn { color: #D98E04; }
.pitch-note.bad { color: var(--accent); }
.pitch-status { font-weight: 600; font-size: .92rem; }
.pitch-meter { position: relative; height: 10px; border-radius: 6px; background: var(--surface-2); margin: 6px 0; }
.pitch-meter-mid { position: absolute; left: 50%; top: -3px; bottom: -3px; width: 2px; background: var(--muted); transform: translateX(-1px); }
.pitch-needle-dot { position: absolute; top: 50%; left: 50%; width: 18px; height: 18px; border-radius: 50%; background: var(--muted); transform: translate(-50%, -50%); transition: left .12s linear; }
.pitch-needle-dot.good { background: var(--ok); }
.pitch-needle-dot.warn { background: #D98E04; }
.pitch-needle-dot.bad { background: var(--accent); }
.pitch-sub { font: .82rem var(--font-mono); color: var(--muted); }

.switch { display: inline-flex; align-items: center; gap: 8px; font-size: .9rem; cursor: pointer; user-select: none; }
.switch input { appearance: none; width: 38px; height: 22px; border-radius: 11px; background: var(--surface-2); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.switch input::after { content: ''; position: absolute; top: 3px; left: 3px; width: 16px; height: 16px; border-radius: 50%; background: var(--muted); transition: transform .15s; }
.switch input:checked { background: var(--accent); }
.switch input:checked::after { transform: translateX(16px); background: #fff; }
.switch-sides span { color: var(--muted); font-weight: 600; }
.switch-sides:has(input:not(:checked)) > span:first-child,
.switch-sides:has(input:checked) > span:last-child { color: var(--ink); }

.fold > summary { cursor: pointer; list-style: none; }
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary::after { content: '▸'; float: right; color: var(--muted); }
.fold[open] > summary::after { content: '▾'; }
.rec-bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--accent); color: #fff; font-weight: 600; flex-shrink: 0; }
.rec-bar[hidden] { display: none; }
.rec-bar .btn { margin-left: auto; background: #fff; color: var(--accent); border-color: #fff; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: #fff; animation: rec-pulse 1.1s ease-in-out infinite; }
@keyframes rec-pulse { 50% { opacity: .25; } }


.switch-sides { gap: 6px; }
.switch-sides span { font-size: .85rem; }
@media (max-width: 860px) {
  .pitch-row { gap: 8px 12px; }
  .pitch-row select { min-width: 0; }
  .pitch-note { font-size: 1.8rem; }
  .pitch-sub { word-break: break-word; }
}

.key-hud { position: fixed; left: 50%; transform: translateX(-50%); bottom: 14px; z-index: 55;
  display: flex; align-items: center; gap: 10px; padding: 6px 14px; border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 78%, transparent); backdrop-filter: blur(10px);
  border: 1px solid var(--border); box-shadow: 0 4px 16px rgba(0,0,0,.2); font-size: .8rem; }
.key-hud[hidden] { display: none; }
.key-hud-note { font: 700 1rem var(--font-mono); min-width: 2.6ch; color: var(--muted); }
.key-hud-note.good { color: var(--ok); }
.key-hud-note.warn { color: #D98E04; }
.key-hud-note.bad { color: var(--accent); }
.key-hud-meter { position: relative; width: 96px; height: 5px; border-radius: 3px; background: var(--surface-2); }
.key-hud-mid { position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--muted); }
.key-hud-dot { position: absolute; top: 50%; left: 50%; width: 11px; height: 11px; border-radius: 50%;
  background: var(--muted); transform: translate(-50%, -50%); transition: left .12s linear; }
.key-hud-dot.good { background: var(--ok); }
.key-hud-dot.warn { background: #D98E04; }
.key-hud-dot.bad { background: var(--accent); }
.key-hud-key { color: var(--muted); white-space: nowrap; }
@media (max-width: 860px) {
  .key-hud { bottom: calc(60px + env(safe-area-inset-bottom)); }
  .editor-view.tools-open .key-hud { bottom: calc(38dvh + 62px + env(safe-area-inset-bottom)); }
}

.beat-player { display: grid; gap: 8px; }
.beat-seek { width: 100%; }
.beat-times { display: flex; justify-content: space-between; font: .78rem var(--font-mono); color: var(--muted); }
.beat-controls { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.beat-controls .btn { padding: 4px 9px; font-size: .8rem; }
.beat-controls .btn.on { background: var(--accent); color: #fff; }
.beat-rate { padding: 4px 6px; font-size: .8rem; }
.beat-vol { display: flex; align-items: center; gap: 8px; color: var(--muted); }
.beat-vol input { flex: 1; }

.take-sync { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.take-sync input[type=range] { flex: 1 1 140px; width: auto; min-width: 120px; }

.beat-play { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.beat-facts { display: flex; gap: 14px; flex-wrap: wrap; }
.beat-fact { display: flex; align-items: baseline; gap: 4px; }
.beat-fact b { font: 700 1.05rem var(--font-mono); }
.beat-fact span { font-size: .75rem; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.beat-map { display: flex; align-items: flex-end; gap: 3px; height: 34px; }
.beat-step { flex: 1; min-width: 4px; border-radius: 2px 2px 0 0; background: var(--surface-2);
  height: max(3px, var(--v)); opacity: .85; }
.beat-step.on-beat { background: var(--accent); opacity: 1; }
.beat-map-note { align-self: center; margin-left: 6px; white-space: nowrap; }

.audio-head { display: flex; align-items: center; gap: 8px; padding: 12px 0 2px; }
.audio-settings.on { color: var(--accent); }
.audio-main[hidden] { display: none; }
.take-day { font-size: .72rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); margin: 14px 0 6px; }
.take-item { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px;
  background: var(--surface-2); margin-bottom: 8px; }
.take-top { display: flex; align-items: baseline; gap: 10px; }
.take-top strong { flex: 1; min-width: 0; }
.take-when { font: .78rem var(--font-mono); color: var(--muted); white-space: nowrap; }
.take-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.take-tag { font: .72rem var(--font-mono); color: var(--muted); background: var(--surface);
  border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.take-item audio { width: 100%; height: 34px; }
.take-actions { display: flex; gap: 4px; justify-content: flex-end; }

.beat-map { position: relative; transition: box-shadow .08s linear; border-radius: 6px; }
.beat-map.hit { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 55%, transparent); }
.beat-step { transition: background .08s linear, transform .08s linear, opacity .08s linear; }
.beat-step.now { background: var(--accent); opacity: 1; transform: scaleY(1.15); transform-origin: bottom; }
.beat-step.on-beat.now { box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 70%, transparent); }

/* Beat history, A-B loop over bars */
.beat-history-row { display: flex; align-items: center; gap: 6px; }
.beat-history { flex: 1; min-width: 0; padding: 7px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface-2); font-size: .85rem; }
.seek-wrap { position: relative; display: grid; align-items: center; }
.seek-loop { position: absolute; top: 50%; height: 14px; transform: translateY(-50%); border-radius: 4px; pointer-events: none;
  background: color-mix(in srgb, var(--accent) 22%, transparent); outline: 1px solid color-mix(in srgb, var(--accent) 60%, transparent); }
.loop-out { font-family: var(--font-mono); color: var(--muted); }
.loop-out:empty { display: none; }
.coach-open { margin-left: auto; }
.facts-note { flex-basis: 100%; }
[data-role] { --role: #8B95A5; }
[data-role="verse"] { --role: #2F9BD6; }
[data-role="prechorus"] { --role: #9B6BE8; }
[data-role="chorus"] { --role: #E0407A; }
[data-role="bridge"] { --role: #E08A1E; }
.bar-grid { display: grid; grid-template-columns: repeat(16, minmax(0, 1fr)); gap: 2px; touch-action: none; user-select: none; -webkit-user-select: none; }
.bar-cell { min-width: 0; height: 22px; padding: 0; border-radius: 4px; font: 600 .62rem var(--font-mono); color: var(--muted);
  background: color-mix(in srgb, var(--role) 16%, var(--surface-2)); border-bottom: 2px solid color-mix(in srgb, var(--role) 70%, transparent); }
.bar-cell:nth-child(4n+1) { box-shadow: inset 1px 0 0 var(--border-strong); }
.bar-cell.in { background: var(--accent); color: #fff; border-bottom-color: var(--accent-2); }
.bar-cell.now { outline: 2px solid var(--ink); outline-offset: -2px; color: var(--ink); }
.bar-cell.in.now { color: #fff; outline-color: #fff; }

/* Lyric coach (Line tab) */
.lyric-coach { margin-top: 18px; border-top: 1px solid var(--border); }
.coach-head { font: 700 .72rem var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--accent); margin-top: 8px; }
.coach-line { display: grid; grid-template-columns: 34px 1fr; gap: 8px; align-items: start; padding: 6px 0; border-bottom: 1px dashed var(--border); }
.coach-line .meter-words { margin: 0; gap: 6px 10px; }
.coach-syl { font: 700 .78rem var(--font-mono); padding: 2px 0; text-align: center; border-radius: 6px; background: var(--surface-2); }
.coach-syl.dense { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.coach-syl.sparse { color: var(--warn); }
.coach-actions { margin-top: 6px; }
.meter-word { position: relative; }
.meter-word.on-beat > span:not(.stress) { font-weight: 700; text-decoration: underline 2px var(--accent); text-underline-offset: 3px; }
.meter-word.rhyme > span:not(.stress) { color: var(--accent); }
.beat-no { position: absolute; top: -6px; right: -10px; font: 700 .6rem var(--font-mono); color: #fff; background: var(--accent); border-radius: 999px; padding: 0 4px; line-height: 1.4; }

/* The word being sung over the beat, in the editor: rhyme colours stay on top of it. */
::highlight(sung) { background-color: color-mix(in srgb, var(--accent) 30%, transparent); color: var(--text); }

/* Beat Coach: a window of its own, the whole screen on a phone */
.coach { margin: auto; width: min(1040px, calc(100vw - 32px)); height: min(900px, calc(100dvh - 32px)); max-width: none; max-height: none;
  border: 1px solid var(--border); border-radius: 18px; padding: 0; background: var(--surface); color: var(--text); box-shadow: var(--shadow); overflow: hidden; }
.coach[open] { display: flex; flex-direction: column; }
.coach::backdrop { background: rgba(10, 10, 12, .55); backdrop-filter: blur(2px); }
.coach > * { flex-shrink: 0; padding-left: 16px; padding-right: 16px; }
.coach-top { display: flex; align-items: center; gap: 10px; padding-top: 10px; padding-bottom: 6px; }
.coach-title { flex: 1; min-width: 0; display: grid; }
.coach-title h2 { font-size: 1.15rem; }
.coach-facts { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.coach-transport { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding-bottom: 8px; }
.coach-time { font: 600 1rem var(--font-mono); font-variant-numeric: tabular-nums; min-width: 82px; }
.coach-speed { display: inline-flex; align-items: center; gap: 6px; }
.coach-speed input { width: 110px; }
.coach-count { display: flex; align-items: center; justify-content: center; gap: 12px; padding-top: 4px; padding-bottom: 4px; }
.coach-counter { display: flex; align-items: center; gap: 6px; }
.count { display: grid; place-items: center; font: 700 1.05rem var(--font-display); color: var(--muted); transition: transform .06s linear, background .06s linear, color .06s linear; }
.count.one { width: 54px; height: 54px; border-radius: 50%; font-size: 1.5rem; background: var(--surface-2); border: 3px solid var(--ink); color: var(--ink); }
.count.back { width: 42px; height: 42px; border-radius: 8px; border: 2px solid var(--muted); }
.count.beat { width: 42px; height: 42px; border-radius: 50%; border: 2px solid var(--muted); }
.count.and { width: 22px; height: 22px; font-size: .8rem; font-weight: 600; }
.count.now { transform: scale(1.14); color: #fff; background: var(--accent); border-color: var(--accent); }
.count.one.now { background: var(--ink); color: var(--ink-contrast); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 45%, transparent); }
.count.and.now { color: var(--accent); background: none; transform: scale(1.35); }
.kick-light { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; font: 700 .58rem var(--font-body); letter-spacing: .06em; text-transform: uppercase;
  color: var(--muted); border: 2px dashed var(--border-strong); }
.kick-light.hit { background: var(--ok); color: #fff; border: 2px solid var(--ok); }
.coach-status { text-align: center; font: 600 .9rem var(--font-body); color: var(--muted); min-height: 1.5em; padding-bottom: 6px; }
.coach-status.soon { color: var(--accent); font-size: 1rem; }
.coach-lane { overflow-x: auto; overflow-y: hidden; padding-top: 0; padding-bottom: 8px; scrollbar-width: thin; overscroll-behavior-x: contain; }
.lane-inner { position: relative; height: 72px; }
.lane-secs, .lane-bars { position: absolute; left: 0; right: 0; }
.lane-secs { top: 0; height: 30px; }
.lane-bars { top: 32px; height: 38px; }
.lane-sec { position: absolute; top: 0; height: 28px; display: flex; align-items: center; gap: 6px; padding: 0 8px; overflow: hidden; white-space: nowrap; border-radius: 6px;
  background: color-mix(in srgb, var(--role) 20%, var(--surface)); border: 1px solid color-mix(in srgb, var(--role) 55%, transparent); font-size: .78rem; text-align: left; }
.lane-sec b { color: var(--ink); }
.lane-sec span { color: var(--muted); font-family: var(--font-mono); font-size: .72rem; }
.lane-sec.drop { background-image: repeating-linear-gradient(135deg, transparent 0 6px, color-mix(in srgb, var(--role) 22%, transparent) 6px 12px); }
.lane-bar { position: absolute; top: 0; height: 38px; border-left: 2px solid var(--border-strong); padding: 0; text-align: left; }
.lane-bar > span { position: absolute; top: 2px; left: 4px; font: 600 .62rem var(--font-mono); color: var(--faint); }
.lane-bar i { position: absolute; bottom: 0; width: 2px; height: 10px; background: var(--border-strong); }
.lane-bar i.one { width: 3px; height: 22px; background: var(--ink); }
.lane-stop { position: absolute; top: 4px; width: 8px; height: 8px; margin-left: -4px; background: var(--danger); border-radius: 2px; }
.lane-loop { position: absolute; top: 30px; height: 42px; background: color-mix(in srgb, var(--accent) 16%, transparent); border: 1px solid var(--accent); border-radius: 4px; pointer-events: none; }
.lane-head { position: absolute; top: 0; left: 0; width: 2px; height: 72px; background: var(--accent); pointer-events: none; will-change: transform; }
.coach-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); }
.coach-tab { flex: 1; padding: 9px 0; font-weight: 600; font-size: .9rem; color: var(--muted); border-bottom: 2px solid transparent; }
.coach-tab[aria-selected="true"] { color: var(--accent); border-color: var(--accent); }
.coach-body { flex: 1 1 auto; min-height: 0; overflow-y: auto; overflow-x: hidden; padding-top: 12px; padding-bottom: 16px; display: grid; align-content: start; gap: 12px; }
.coach-key { display: flex; flex-wrap: wrap; gap: 2px 12px; padding-top: 8px; padding-bottom: calc(8px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--surface-2); font-size: .72rem; color: var(--muted); }
.coach-key b { font-family: var(--font-mono); color: var(--ink); }
.coach-block { display: grid; gap: 8px; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.coach-block h3 { font-size: .95rem; }
.segs { display: inline-flex; flex-wrap: wrap; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; width: max-content; max-width: 100%; }
.seg { padding: 7px 12px; font-size: .85rem; font-weight: 600; color: var(--muted); }
.seg[aria-pressed="true"] { background: var(--ink); color: var(--ink-contrast); }
.shift .small { font-family: var(--font-mono); }
.coach-pad { width: 100%; min-height: 96px; border-radius: 16px; border: 2px solid var(--accent); color: var(--accent); font: 700 1.4rem var(--font-display);
  background: var(--accent-soft); touch-action: manipulation; user-select: none; -webkit-user-select: none; transition: transform .05s, background .05s; }
.coach-pad:active { transform: scale(.98); }
.coach-pad.flash { background: var(--accent); color: #fff; }
.coach-pad.small-pad { width: 96px; min-height: 48px; font-size: 1rem; }
.sec-row { display: grid; gap: 6px; padding: 10px; border-radius: 10px; border-left: 4px solid var(--role); background: var(--surface-2); }
.sec-main { display: flex; gap: 6px; flex-wrap: wrap; }
.sec-name { flex: 1 1 140px; min-width: 0; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.sec-role, .sec-split, .pair { padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); font-size: .85rem; max-width: 100%; }
.sec-meta { display: flex; gap: 8px; align-items: center; color: var(--muted); }
.sec-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag { font-size: .7rem; font-weight: 700; padding: 1px 8px; border-radius: 999px; background: color-mix(in srgb, var(--warn) 18%, transparent); color: var(--warn); }
.lessons { display: grid; gap: 8px; }
.lesson-card { display: grid; grid-template-columns: 34px 1fr auto; gap: 10px; align-items: center; padding: 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); text-align: left; }
.lesson-card:hover { border-color: var(--accent); }
.lesson-no { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 50%; background: var(--surface-2); font-weight: 700; color: var(--accent); }
.lesson-text { display: grid; gap: 2px; }
.lesson-text span { color: var(--muted); font-size: .84rem; }
.lesson { display: grid; gap: 12px; }
.lesson-say { font: 700 1.15rem var(--font-display); min-height: 1.5em; }
.lesson-say.good { color: var(--ok); }
.lesson-say.off { color: var(--warn); }
.fit-controls .num { width: 64px; padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface); }
.fit-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.fit-controls > summary { cursor: pointer; color: var(--muted); font-weight: 600; }
.mark-bar { display: flex; flex-wrap: wrap; gap: 4px; padding-top: 4px; }
.mark-bar .btn { font-family: var(--font-mono); padding: 5px 10px; }
.fit-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-top: 6px; color: var(--accent); }
.fit-note { font-size: .84rem; color: var(--warn); }
.fit-line { display: grid; gap: 6px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); transition: border-color .1s, box-shadow .1s; }
.fit-line.now { border-color: var(--accent); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent); }
.fit-top { display: flex; align-items: center; gap: 8px; }
.fit-bar { flex: 1; font: .76rem var(--font-mono); color: var(--muted); }
.fit-syl { font: 700 .74rem var(--font-mono); padding: 1px 7px; border-radius: 999px; background: var(--surface-2); }
.fit-syl.dense { background: color-mix(in srgb, var(--danger) 18%, transparent); color: var(--danger); }
.fit-syl.sparse { color: var(--warn); }
.fit-words { display: flex; flex-wrap: wrap; gap: 4px 6px; font-family: var(--font-mono); font-size: 1rem; }
.fit-word { position: relative; padding: 2px 4px; border-radius: 6px; transition: background .06s, color .06s; }
.fit-word.beat { font-weight: 700; text-decoration: underline 2px var(--accent); text-underline-offset: 4px; }
.fit-word.rhyme { color: var(--accent); }
.fit-word sup { font-size: .6rem; color: var(--accent); margin-left: 1px; }
.fit-word.past { color: var(--muted); }
.fit-word.sung { background: var(--accent); color: #fff; }
.fit-word.sung sup { color: #fff; }
.beat-grid { display: grid; gap: 3px; }
.grid-track { position: relative; height: 24px; border-radius: 6px; overflow: hidden;
  background: repeating-linear-gradient(90deg, var(--surface-2) 0 calc(100% / var(--k, 4) - 1px), var(--border-strong) calc(100% / var(--k, 4) - 1px) calc(100% / var(--k, 4))); }
.grid-word { position: absolute; top: 3px; height: 18px; padding: 0 3px; overflow: hidden; white-space: nowrap; border-radius: 4px; font: .64rem/18px var(--font-mono);
  background: color-mix(in srgb, var(--accent) 14%, var(--surface)); border: 1px solid color-mix(in srgb, var(--accent) 35%, transparent); }
.grid-word.on { font-weight: 700; border-left: 3px solid var(--accent); }
.grid-word.hold-short { background: color-mix(in srgb, var(--accent) 26%, var(--surface)); }
.grid-word.hold-long { background: color-mix(in srgb, var(--accent) 38%, var(--surface)); }
.grid-word.split-quick, .grid-word.split-long { border-style: dashed; }
.grid-word.sung { background: var(--accent); color: #fff; }
.grid-pause { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--muted); }
.grid-pause.stop { width: 4px; background: var(--danger); }
.grid-beats { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 3px; }
.grid-beat { display: flex; gap: 4px; align-items: baseline; min-width: 0; padding: 2px 6px; border-radius: 6px; background: var(--surface-2); font: .7rem var(--font-mono);
  overflow: hidden; white-space: nowrap; text-overflow: ellipsis; cursor: grab; touch-action: none; }
.grid-beat b { color: var(--accent); }
.grid-beat.held { color: var(--faint); cursor: default; }
.grid-beat.hit { background: var(--accent); color: #fff; }
.grid-beat.hit b { color: #fff; }
.fit-edit { display: flex; gap: 6px; }
.fit-input { flex: 1; min-width: 0; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-family: var(--font-mono); }
@media (max-width: 860px) {
  .coach { width: 100vw; height: 100dvh; max-width: 100vw; max-height: 100dvh; margin: 0; border-radius: 0; border: 0; }
  .coach > * { padding-left: 12px; padding-right: 12px; }
  .count.one { width: 46px; height: 46px; font-size: 1.3rem; }
  .count.back, .count.beat { width: 36px; height: 36px; }
  .count.and { width: 16px; }
  .coach-counter { gap: 3px; }
  .kick-light { width: 34px; height: 34px; }
  .coach-speed input { width: 80px; }
  .bar-cell { height: 26px; }
  .coach-key { gap: 0 10px; font-size: .68rem; padding-top: 5px; }
  .coach-transport { gap: 8px; padding-bottom: 4px; }
  .coach-time { min-width: 0; }
}

/* Control panel */
.admin { padding: 20px 0 40px; display: grid; gap: 16px; }
.admin-stats { display: flex; gap: 22px; flex-wrap: wrap; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface-2); }
.admin-search { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); color: var(--ink); }
.admin-list { display: grid; gap: 8px; }
.admin-row { display: grid; gap: 10px; padding: 14px; border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.admin-who { display: grid; gap: 2px; min-width: 0; }
.admin-who strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.admin-tag, .admin-status { font-size: .72rem; font-weight: 600; padding: 2px 9px; border-radius: 999px; background: var(--surface-2); color: var(--muted); border: 1px solid var(--border); }
.admin-status.on { background: color-mix(in srgb, var(--ok) 18%, transparent); color: var(--ok); border-color: transparent; }
.admin-tag.admin { background: var(--accent-soft); color: var(--accent); border-color: transparent; }
.admin-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.admin-actions input { width: 72px; padding: 6px 8px; border-radius: 8px; border: 1px solid var(--border); background: var(--surface-2); color: var(--ink); }
.admin-actions .danger { color: var(--accent); }
@media (min-width: 760px) {
  .admin-row { grid-template-columns: 1fr auto auto; align-items: center; }
}

/* iOS Safari zooms the whole page into any text field under 16px the moment it is tapped, as the
   keyboard opens -- a zoomed page pushes the rhyme strip and half the editor off screen and sideways.
   On phones and other touch screens no field is smaller than that. */
@media (max-width: 860px), (pointer: coarse) {
  input:not([type=checkbox]):not([type=radio]):not([type=range]), select, textarea, .line-input { font-size: 16px !important; }
  .line.section .line-input { letter-spacing: .08em; }
}
