/* CheerBook web editor. Shares the site's colours and fonts (style.css); member colours are only
   marks, set from script through custom properties, and text stays in the theme's colours. */
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.editor { --ghost: #7a4dd8; --record: #d92d3a; --dock-h: 0px; display: grid; gap: 16px; padding-bottom: calc(var(--dock-h) + 16px); }
@media (prefers-color-scheme: dark) { .editor { --ghost: #b392ff; --record: #ff6b73; } }
.editor button, .editor select, .editor input, .editor textarea { font: inherit; color: var(--text); }
.editor button { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 6px 12px; cursor: pointer; }
.editor button:hover:not(:disabled) { border-color: var(--muted); }
.editor button:disabled { opacity: 0.5; cursor: default; }
.editor button.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.editor button.danger { color: var(--record); }
.editor button:focus-visible, .editor select:focus-visible, .editor input:focus-visible, .editor textarea:focus-visible, .editor [tabindex]:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.editor input, .editor select, .editor textarea { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 5px 8px; }
.ed-field { display: inline-flex; flex-direction: column; gap: 2px; font-size: 0.9rem; }
.ed-field > span { color: var(--muted); font-size: 0.82rem; }
.ed-field.block { display: flex; }
.ed-field.block textarea { width: 100%; font-family: var(--mono); font-size: 0.88rem; }
.ed-field.color input { padding: 0; width: 44px; height: 32px; }

.ed-toolbar { display: grid; gap: 10px; }
.ed-song { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 10px 14px; }
.ed-song input { min-width: 14em; }
.ed-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.ed-status { margin: 0; min-height: 1.5em; color: var(--muted); font-size: 0.92rem; }
.ed-status.flash { color: var(--text); }
.ed-welcome .steps li { margin: 6px 0; }
.editor[data-ready="true"] .ed-welcome { display: none; }

.ed-main { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 16px; align-items: start; }
.ed-lyrics { position: relative; padding: 0; min-height: 50vh; max-height: calc(100vh - var(--dock-h) - 140px); overflow-y: auto; overscroll-behavior: contain; --dim-ink: 0.42; }
/* Room above and below so the first and last lines can reach the focus position (30%). */
.ed-lyrics .timeline { padding: calc(var(--lyrics-h, 50vh) * 0.3) 0 calc(var(--lyrics-h, 50vh) * 0.7); }
.ed-side { display: grid; gap: 12px; position: sticky; top: 12px; max-height: calc(100vh - var(--dock-h) - 40px); overflow-y: auto; }
.ed-panel h2 { font-size: 1rem; margin: 0 0 8px; }
.timeline { list-style: none; margin: 0; padding: 0; }
.timeline-empty { color: var(--muted); padding: 16px 20px; margin: 0; }
.row { display: grid; grid-template-columns: 4.2em 6px minmax(0, 1fr); gap: 0 10px; align-items: start; padding: 6px 16px; border-left: 3px solid transparent; cursor: pointer; }
.row:hover { background: var(--accent-soft); }
.row .time { color: var(--muted); font-family: var(--mono); font-size: 0.8rem; padding-top: 4px; }
.row .singers { display: flex; gap: 2px; height: 100%; min-height: 1.6em; }
.row .singers i { flex: 1; border-radius: 3px; background: var(--member, var(--line)); }
.row .body { min-width: 0; overflow-wrap: anywhere; }
/* Every lyric is one dim ink; the focus line's characters fill to full ink (--b, 0–1). */
.row .text { font-size: 1.2rem; line-height: 1.45; font-weight: 700; color: var(--text); transform: scale(0.98); transform-origin: left center; transition: transform 0.25s ease-out; }
.row .text .ink, .row .text .ch { opacity: calc(var(--dim-ink) + (1 - var(--dim-ink)) * var(--b, 0)); }
.row .text.settling .ch { transition: opacity 0.45s ease-out; }
.row:hover .text .ink, .row:hover .text .ch { opacity: 1; }
.row.focus { border-left-color: var(--accent); }
.row.focus .text, .timeline.browsing .row .text { transform: none; }
.row.gap .text { font-style: italic; font-size: 0.9rem; font-weight: 400; color: var(--muted); transform: none; }
.row .tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.tag { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-left: 4px solid var(--member, var(--accent)); border-radius: 8px; padding: 2px 8px; background: var(--surface); font-size: 0.88rem; max-width: 100%; }
.tag .kind { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.04em; color: var(--muted); }
.tag .when { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.tag[aria-pressed="true"] { outline: 2px solid var(--accent); }
.tag.recording { border-style: dashed; border-color: var(--record); color: var(--record); }
.tag.ghost { border-style: dashed; border-color: var(--ghost); border-left-color: var(--ghost); color: var(--ghost); background: transparent; }
.tag.ghost { flex-wrap: wrap; }
.tag.ghost button { padding: 1px 8px; font-size: 0.82rem; border-radius: 6px; white-space: nowrap; }
.tag.fresh { animation: fresh 0.9s ease-out; }
@keyframes fresh { from { background: var(--accent-soft); } to { background: var(--surface); } }

.issues { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; font-size: 0.9rem; }
.issues li { padding: 6px 8px; border-radius: 8px; background: var(--bg); border-left: 3px solid var(--muted); }
.issues li.error { border-left-color: var(--record); }
.issues li.ok { border-left-color: #2e9d57; }
.issues li button { margin-left: 6px; font-size: 0.8rem; padding: 0 6px; }
.members, .mix-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.members li { display: flex; align-items: center; gap: 8px; }
.members .swatch { width: 14px; height: 14px; border-radius: 50%; background: var(--member); border: 1px solid var(--line); flex: none; }
.members .name { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.members .key { font-family: var(--mono); font-size: 0.8rem; color: var(--muted); }
.members li[aria-current="true"] .name { font-weight: 700; }
.add-member { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 10px; }
.mix-list button { width: 100%; text-align: left; display: grid; gap: 2px; }
.mix-list .mix-name { font-weight: 600; }
.mix-list .mix-meta { color: var(--muted); font-size: 0.8rem; }
.selected-grid { display: grid; gap: 8px; }
.selected-grid .row2 { display: flex; flex-wrap: wrap; gap: 6px; align-items: flex-end; }
.selected-grid textarea { width: 100%; }
.nudge { display: inline-flex; gap: 4px; align-items: center; }
.nudge button { padding: 2px 8px; }
.member-picks { display: flex; flex-wrap: wrap; gap: 6px; }
.member-picks label { display: inline-flex; align-items: center; gap: 4px; border: 1px solid var(--line); border-radius: 8px; padding: 2px 8px; }

.ed-dock { position: fixed; left: 0; right: 0; bottom: 0; z-index: 3; background: var(--surface); border-top: 1px solid var(--line); padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); display: grid; gap: 8px; }
.band { min-height: 3.2em; display: flex; flex-wrap: wrap; align-items: center; gap: 8px 16px; font-size: 1.15rem; }
.band .item { display: inline-flex; flex-wrap: wrap; align-items: baseline; column-gap: 0.4em; row-gap: 2px; border-left: 4px solid var(--member, var(--accent)); padding-left: 8px; max-width: 100%; }
.band .item .w { white-space: nowrap; display: inline-grid; justify-items: center; color: var(--muted); }
.band .item .w.on { color: var(--text); }
.band .item .w .kana, .band .item .w .romaji { font-size: 0.58em; line-height: 1.2; }
.band .item .w .orig { font-weight: inherit; }
.band .item .w.on .orig { font-weight: 700; }
.band .next { color: var(--muted); font-size: 0.95rem; }
.band .count { font-family: var(--mono); font-weight: 700; color: var(--accent); }
.band .idle { color: var(--muted); font-size: 0.95rem; }
.transport { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; }
.transport .clock { font-family: var(--mono); font-size: 0.9rem; min-width: 9.5em; }
.transport input[type="range"] { flex: 1 1 240px; accent-color: var(--accent); }
.transport .play { min-width: 5.5em; }
.transport .ed-field.rate { flex-direction: row; align-items: center; gap: 6px; }
.sticks { display: flex; flex-wrap: wrap; gap: 8px; }
.stick { touch-action: none; user-select: none; -webkit-user-select: none; min-width: 6.5em; padding: 10px 14px !important; border-radius: 12px !important; border-bottom: 4px solid var(--member, var(--accent)) !important; display: inline-grid; justify-items: start; }
.stick .k { font-family: var(--mono); font-size: 0.75rem; color: var(--muted); }
.stick.down { background: var(--accent-soft); border-color: var(--record) !important; }

dialog { border: 1px solid var(--line); border-radius: 14px; padding: 0; background: var(--surface); color: var(--text); width: min(640px, calc(100vw - 32px)); }
dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog-body { padding: 18px 20px; display: grid; gap: 10px; }
.dialog-body h2 { margin: 0; font-size: 1.2rem; }
.dialog-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.dialog-row.end { justify-content: flex-end; }
.ed-choice { border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; display: flex; flex-wrap: wrap; gap: 6px 16px; }
.ed-choice legend { color: var(--muted); font-size: 0.85rem; padding: 0 4px; }
.share-outcome { margin: 0; padding: 8px 10px; border-radius: 8px; background: var(--bg); }
.check { display: flex; gap: 8px; align-items: flex-start; }

.editor[data-mode="watch"] .ed-side, .editor[data-mode="watch"] .sticks, .editor[data-mode="watch"] .ed-actions > :not(#toggle-mode):not(#pick-audio):not(#open-lyrics):not(#open-import) { display: none; }
.editor[data-mode="watch"] .ed-main { grid-template-columns: 1fr; }
.editor[data-mode="watch"] .row { grid-template-columns: 6px minmax(0, 1fr); padding: 10px 24px; border-left-color: transparent; }
.editor[data-mode="watch"] .row .time, .editor[data-mode="watch"] .row .tags, .editor[data-mode="watch"] .row.gap { display: none; }
.editor[data-mode="watch"] .row .text { font-size: clamp(1.5rem, 2.6vw, 2.2rem); line-height: 1.3; }
.editor[data-mode="watch"] .band { font-size: 1.6rem; min-height: 4.2em; }

@media (max-width: 900px) {
  .ed-main { grid-template-columns: 1fr; }
  .ed-side { position: static; max-height: none; }
  .ed-lyrics { max-height: 60vh; }
  .stick { min-width: 5em; }
}
@media (prefers-reduced-motion: reduce) {
  .tag.fresh { animation: none; }
  .row .text { transform: none; transition: none; }
  .row .text.settling .ch { transition: none; }
}
@media (prefers-contrast: more) {
  .tag, .stick, .row .singers i { outline: 1px solid var(--text); }
  .ed-lyrics { --dim-ink: 0.65; }
  .row .text { transform: none; }
}
.beat-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--line); flex: none; }
.beat-dot[data-on="beat"] { background: var(--muted); }
.beat-dot[data-on="bar"] { background: var(--accent); }
.grid-fix { display: inline-flex; gap: 4px; }
.grid-fix button { padding: 2px 8px; font-size: 0.85rem; }
.band .item.singing { font-size: 0.95rem; color: var(--muted); }
@media (max-width: 600px) {
  .ed-dock { padding: 6px 10px calc(6px + env(safe-area-inset-bottom)); gap: 6px; }
  .band { font-size: 1rem; min-height: 2.4em; }
  .transport { gap: 6px 8px; }
  .transport .clock { min-width: 0; font-size: 0.8rem; }
  .transport input[type="range"] { flex-basis: 100%; order: 5; }
  .transport .ed-field.rate > span { display: none; }
  #grid-status { font-size: 0.78rem; flex: 1 1 10em; }
  .sticks { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 2px; }
  .stick { min-width: 4.2em; padding: 8px 10px !important; flex: none; }
  .ed-actions button { padding: 5px 9px; }
}
