/* Transcriber page. Colours come from the site's theme tokens (assets/theme.css);
   the fallbacks only apply if a token is missing. */
.tx-root [hidden], .tx-menu[hidden] { display: none !important; }
:root {
  --tx-bg: var(--bg, #f7f5f1);
  --tx-panel: var(--surface, #ffffff);
  --tx-panel2: var(--surface-2, #f0ece5);
  --tx-ink: var(--ink, #23201c);
  --tx-muted: var(--ink-2, #5c564d);
  --tx-line: var(--line, #e3ded5);
  --tx-accent: var(--accent, #274180);
  --tx-accent-ink: var(--on-accent, #ffffff);
  --tx-ok: var(--green, #2c7550);
  --tx-danger: var(--danger, #b0403c);
  --tx-roll-bg: var(--roll-nat, var(--tx-panel));
  --tx-roll-black: var(--roll-acc, #f4eee2);
  --tx-roll-line: var(--roll-line, #efe8da);
  --tx-roll-bar: var(--line-2, #ccc5b9);
  --tx-note: var(--note, #274180);
  --tx-note-sel: var(--gold-fill, #eaa21a);
  --tx-doubt: #b4530a;
  --tx-trace: var(--purple, #5f45a4);
  --tx-play: var(--danger, #b0403c);
  --tx-ghost: var(--accent-soft, #e9edf8);
  --tx-radius: var(--radius, 14px);
  --tx-radius-sm: var(--radius-sm, 9px);
}
.tx-root {
  color: var(--tx-ink);
  max-width: 1500px;
  margin: 0 auto;
  padding: 16px 16px 120px;
  box-sizing: border-box;
}
.tx-root *, .tx-root *::before, .tx-root *::after { box-sizing: border-box; }
.tx-root h1 { font-family: var(--font-display, Georgia, serif); font-size: 1.75rem; font-weight: 600; margin: 2px 0 2px; letter-spacing: -0.01em; }
.tx-root h2 { font-size: 1.05rem; margin: 0 0 12px; }
.tx-root h3 { font-size: 0.95rem; margin: 18px 0 6px; }
.tx-root h4 { font-size: 0.85rem; margin: 16px 0 6px; color: var(--tx-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tx-sub, .tx-note { color: var(--tx-muted); }
.tx-note { font-size: 0.85rem; margin: 6px 0; }
.tx-mode { background: var(--tx-panel2); border: 1px solid var(--tx-line); border-radius: 10px; padding: 10px 14px; margin: 0 0 14px; font-size: 0.9rem; }
.tx-loading { color: var(--tx-muted); padding: 30px 0; text-align: center; }
.tx-error { color: var(--tx-danger); }

/* buttons & fields */
.tx-btn { font: inherit; font-size: 0.9rem; line-height: 1.2; padding: 8px 12px; min-height: 38px; border-radius: var(--tx-radius-sm); border: 1px solid var(--tx-line); background: var(--tx-panel); color: var(--tx-ink); cursor: pointer; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 6px; white-space: nowrap; }
.tx-btn:hover { border-color: var(--tx-muted); }
.tx-btn:focus-visible, .tx-root select:focus-visible, .tx-root input:focus-visible, .tx-dialog select:focus-visible, .tx-dialog input:focus-visible { outline: 2px solid var(--tx-accent); outline-offset: 2px; }
.tx-btn:disabled { opacity: 0.55; cursor: default; }
.tx-btn.on, .tx-btn[aria-pressed="true"] { background: color-mix(in srgb, var(--tx-accent) 14%, var(--tx-panel)); border-color: var(--tx-accent); }
.tx-primary { background: var(--tx-accent); border-color: var(--tx-accent); color: var(--tx-accent-ink); font-weight: 600; }
.tx-primary:hover { background: var(--accent-hover, var(--tx-accent)); border-color: var(--accent-hover, var(--tx-accent)); }
.tx-danger { color: var(--tx-danger); }
.tx-danger-solid { background: var(--tx-danger); border-color: var(--tx-danger); color: #fff; font-weight: 600; }
.tx-quiet { border-color: transparent; background: transparent; color: var(--tx-muted); }
.tx-big { padding: 12px 18px; font-size: 1rem; }
.tx-icon { min-width: 38px; padding: 8px; }
.tx-root select, .tx-root input[type="text"], .tx-root input[type="number"], .tx-dialog select, .tx-dialog input[type="number"] { font: inherit; font-size: 0.95rem; padding: 8px 10px; min-height: 38px; border-radius: 9px; border: 1px solid var(--tx-line); background: var(--tx-panel); color: var(--tx-ink); max-width: 100%; }
.tx-root input[type="number"], .tx-dialog input[type="number"] { width: 5.5em; }
.tx-field { display: flex; flex-direction: column; gap: 5px; font-size: 0.85rem; color: var(--tx-muted); min-width: 0; }
.tx-field > span:first-child { font-weight: 600; }
.tx-field small { color: var(--tx-muted); }
.tx-wide input { width: 100%; font-size: 1.05rem; }
.tx-fields { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px 16px; margin-top: 14px; }
.tx-check { display: flex; align-items: center; gap: 8px; font-size: 0.9rem; min-height: 38px; }
.tx-check input { width: 18px; height: 18px; accent-color: var(--tx-accent); }
.tx-small { font-size: 0.85rem; color: var(--tx-muted); display: inline-flex; align-items: center; gap: 6px; }
.tx-tempo { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tx-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px; }
.tx-chip { font-size: 0.75rem; font-weight: 600; padding: 3px 9px; border-radius: 999px; background: var(--tx-panel2); color: var(--tx-muted); border: 1px solid var(--tx-line); white-space: nowrap; }
.tx-chip-ok { color: var(--tx-ok); border-color: color-mix(in srgb, var(--tx-ok) 40%, transparent); background: color-mix(in srgb, var(--tx-ok) 10%, var(--tx-panel)); }
.tx-back { color: var(--tx-muted); text-decoration: none; font-size: 0.9rem; }
.tx-card { background: var(--tx-panel); border: 1px solid var(--tx-line); border-radius: var(--tx-radius); padding: 18px; min-width: 0; box-shadow: var(--shadow, none); }

/* library */
.tx-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 6px 0 18px; }
.tx-head p { margin: 4px 0 0; }
.tx-lib-grid { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tx-list { display: flex; flex-direction: column; }
.tx-item { display: flex; justify-content: space-between; gap: 12px; padding: 12px 6px; border-top: 1px solid var(--tx-line); text-decoration: none; color: inherit; border-radius: 6px; }
.tx-item:first-child { border-top: 0; }
.tx-item:hover { background: var(--tx-panel2); }
.tx-item-main { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.tx-item-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tx-item-meta, .tx-item-date { font-size: 0.82rem; color: var(--tx-muted); }
.tx-item-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; flex-shrink: 0; }
.tx-empty { color: var(--tx-muted); padding: 10px 0; }
.tx-empty p { margin: 4px 0; }
.tx-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.tx-stat { display: flex; flex-direction: column; gap: 2px; }
.tx-stat-n { font-size: 1.7rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.tx-muted-n { color: var(--tx-muted); }
.tx-stat-l { font-size: 0.78rem; color: var(--tx-muted); line-height: 1.3; }
.tx-learned { margin: 0; padding-left: 18px; font-size: 0.9rem; }
.tx-learned li { margin: 4px 0; }
.tx-chart { margin: 12px 0 0; }
.tx-chart svg { width: 100%; height: auto; display: block; }
.tx-chart .ln { fill: none; stroke: var(--tx-accent); stroke-width: 2; }
.tx-chart circle { fill: var(--tx-accent); }
.tx-chart .ax { stroke: var(--tx-line); }
.tx-chart .grid { stroke: var(--tx-line); stroke-dasharray: 3 3; }
.tx-chart text { font-size: 9px; fill: var(--tx-muted); }
.tx-chart figcaption { font-size: 0.78rem; color: var(--tx-muted); }

/* new */
.tx-new { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: 16px; align-items: start; }
.tx-tabs { display: flex; gap: 6px; margin-top: 14px; border-bottom: 1px solid var(--tx-line); }
.tx-tab { font: inherit; font-size: 0.95rem; padding: 9px 12px; border: 0; background: none; color: var(--tx-muted); border-bottom: 2px solid transparent; cursor: pointer; margin-bottom: -1px; }
.tx-tab.on { color: var(--tx-ink); border-bottom-color: var(--tx-accent); font-weight: 600; }
.tx-capture { min-height: 280px; display: flex; flex-direction: column; justify-content: center; }
.tx-rec-ui { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 10px 0; }
.tx-rec-btn { width: 96px; height: 96px; border-radius: 50%; border: 3px solid var(--tx-line); background: var(--tx-panel); cursor: pointer; display: grid; place-items: center; }
.tx-rec-btn span { width: 38px; height: 38px; border-radius: 50%; background: var(--tx-danger); transition: all 0.15s; }
.tx-rec-btn.on span { border-radius: 6px; width: 30px; height: 30px; }
.tx-rec-btn.on { border-color: var(--tx-danger); }
.tx-rec-status { text-align: center; min-height: 2.4em; color: var(--tx-muted); }
.tx-count { font-size: 2.2rem; font-weight: 700; color: var(--tx-ink); font-variant-numeric: tabular-nums; }
.tx-live { color: var(--tx-danger); font-weight: 600; }
.tx-meter { width: min(280px, 80%); height: 6px; border-radius: 3px; background: var(--tx-panel2); overflow: hidden; }
.tx-meter div { height: 100%; width: 0; background: var(--tx-ok); transition: width 0.06s; }
.tx-tips { color: var(--tx-muted); font-size: 0.85rem; margin: 14px 0 0; padding-left: 18px; }
.tx-drop { border: 2px dashed var(--tx-line); border-radius: 12px; padding: 34px 16px; display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; cursor: pointer; }
.tx-drop.over, .tx-drop:hover { border-color: var(--tx-accent); background: var(--tx-ghost); }
.tx-drop-icon { font-size: 2rem; color: var(--tx-accent); }
.tx-drop small { color: var(--tx-muted); }
.tx-progress { display: flex; flex-direction: column; gap: 12px; align-items: stretch; text-align: center; }
.tx-progress.err .tx-progress-msg { color: var(--tx-danger); }
.tx-bar { height: 8px; border-radius: 4px; background: var(--tx-panel2); overflow: hidden; }
.tx-bar div { height: 100%; background: var(--tx-accent); transition: width 0.2s; }

/* editor */
.tx-ed { display: flex; flex-direction: column; gap: 10px; }
.tx-toolbar { display: flex; flex-direction: column; gap: 8px; position: sticky; top: 0; z-index: 5; background: var(--tx-bg); padding: 8px 0; border-bottom: 1px solid var(--tx-line); }
.tx-tb-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.tx-tb-tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.tx-title-input { font-weight: 600; font-size: 1.05rem !important; min-width: 0; flex: 1; max-width: 26em; }
.tx-save-state { font-size: 0.8rem; color: var(--tx-muted); margin-right: auto; white-space: nowrap; }
.tx-sep { width: 1px; height: 24px; background: var(--tx-line); margin: 0 4px; }
.tx-menu-wrap { position: relative; }
.tx-menu { position: fixed; background: var(--tx-panel); border: 1px solid var(--tx-line); border-radius: 10px; padding: 6px; min-width: 250px; z-index: 20; box-shadow: 0 8px 24px rgb(0 0 0 / 0.14); display: flex; flex-direction: column; }
.tx-menu button { font: inherit; text-align: left; padding: 9px 10px; border: 0; background: none; color: var(--tx-ink); border-radius: 7px; cursor: pointer; }
.tx-menu button:hover { background: var(--tx-panel2); }
.tx-menu .tx-danger { color: var(--tx-danger); }
.tx-menu hr { border: 0; border-top: 1px solid var(--tx-line); margin: 4px 0; width: 100%; }
.tx-panes { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 12px; align-items: start; }
.tx-pane { background: var(--tx-panel); border: 1px solid var(--tx-line); border-radius: 12px; overflow: hidden; min-width: 0; }
.tx-pane-scroll { max-height: calc(100vh - 260px); min-height: 220px; overflow: auto; padding: 4px; }
.tx-notation { color: var(--tx-ink); }
.tx-notation svg { display: block; }
.tx-svg path:not([fill="none"]), .tx-svg rect:not([fill="none"]), .tx-svg text { fill: var(--tx-ink); }
.tx-svg path:not([stroke="none"]), .tx-svg line { stroke: var(--tx-ink); }
.tx-svg .vf-stave path:not([fill="none"]), .tx-svg .vf-stave rect { fill: color-mix(in srgb, var(--tx-ink) 55%, transparent); }
.tx-svg .vf-stave path:not([stroke="none"]) { stroke: color-mix(in srgb, var(--tx-ink) 55%, transparent); }
.tx-svg .tx-hit { cursor: pointer; }
.tx-svg rect.tx-hitbox { fill: transparent !important; stroke: none !important; }
.tx-svg .tx-rest path:not([fill="none"]) { fill: color-mix(in srgb, var(--tx-ink) 75%, transparent); }
.tx-svg .tx-doubt path:not([fill="none"]) { fill: var(--tx-doubt); }
.tx-svg .tx-doubt path:not([stroke="none"]) { stroke: var(--tx-doubt); }
.tx-svg .tx-sel path:not([fill="none"]) { fill: var(--tx-note-sel); }
.tx-svg .tx-sel path:not([stroke="none"]) { stroke: var(--tx-note-sel); }
.tx-svg .tx-sel rect.tx-hitbox { fill: var(--tx-ghost) !important; }
.tx-svg .tx-playing path:not([fill="none"]) { fill: var(--tx-play); }
.tx-svg .tx-playing path:not([stroke="none"]) { stroke: var(--tx-play); }
.tx-roll-wrap { position: relative; overflow: auto; touch-action: none; user-select: none; -webkit-user-select: none; }
.tx-roll { position: sticky; left: 0; top: 0; display: block; }
.tx-roll-spacer { pointer-events: none; }
.tx-roll-legend { font-size: 0.75rem; color: var(--tx-muted); padding: 6px 10px; border-top: 1px solid var(--tx-line); display: flex; align-items: center; gap: 6px; }
.tx-key { display: inline-block; width: 14px; height: 8px; border-radius: 2px; margin-left: 8px; }
.tx-key-note { background: var(--tx-note); margin-left: 0; }
.tx-key-trace { background: var(--tx-trace); height: 4px; }
.tx-key-doubt { background: var(--tx-doubt); }
.tx-doubt-count { margin-left: 14px; display: inline-flex; align-items: center; gap: 6px; }
.tx-doubt-count[hidden] { display: none; }
.tx-insp-doubt { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 6px 0; padding: 6px 10px; border-left: 3px solid var(--tx-doubt); background: var(--surface-2, rgba(180,83,10,.08)); font-size: .9rem; }
.tx-tuning-note { margin: 0 0 8px; padding: 8px 12px; border-left: 3px solid var(--tx-trace); background: var(--surface-2, rgba(95,69,164,.07)); font-size: .9rem; }
.tx-inspector { position: sticky; bottom: 0; z-index: 6; background: var(--tx-panel); border: 1px solid var(--tx-line); border-radius: 12px; padding: 10px 12px; box-shadow: 0 -4px 18px rgb(0 0 0 / 0.06); }
.tx-insp-head { font-size: 0.95rem; margin-bottom: 8px; }
.tx-insp-empty { color: var(--tx-muted); font-size: 0.9rem; }
.tx-insp-row { display: inline-flex; gap: 6px; flex-wrap: wrap; margin: 0 14px 6px 0; vertical-align: top; }
.tx-insp-tabs { display: none; }
.tx-dur { font-family: 'Bravura', 'Noto Music', 'Segoe UI Symbol', serif; font-size: 1.15rem; min-width: 40px; }

/* dialogs & toast */
.tx-dialog { border: 1px solid var(--tx-line); border-radius: 14px; background: var(--tx-panel); color: var(--tx-ink); padding: 20px; max-width: min(560px, calc(100vw - 32px)); width: 100%; }
.tx-dialog::backdrop { background: rgb(0 0 0 / 0.35); }
.tx-dialog h3 { margin: 0 0 8px; font-size: 1.1rem; }
.tx-dialog p { margin: 6px 0; color: var(--tx-muted); }
.tx-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }
#tx-toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 30px); background: var(--tx-ink); color: var(--tx-bg); padding: 10px 16px; border-radius: 10px; font-size: 0.9rem; opacity: 0; pointer-events: none; transition: all 0.2s; z-index: 50; max-width: calc(100vw - 32px); }
#tx-toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 1000px) {
  .tx-panes { grid-template-columns: minmax(0, 1fr); }
  .tx-pane-scroll { max-height: 46vh; }
  .tx-lib-grid, .tx-new { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 640px) {
  .tx-root { padding: 10px 16px 150px; }
  .tx-tb-main { flex-wrap: wrap; }
  .tx-title-input { flex-basis: calc(100% - 50px); max-width: none; }
  .tx-save-state { order: 5; }
  .tx-tb-tools { flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 2px 16px 6px; scrollbar-width: thin; }
  .tx-tb-tools > * { flex-shrink: 0; }
  .tx-toolbar { position: static; }
  .tx-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .tx-stat-n { font-size: 1.35rem; }
  .tx-insp-tabs { display: flex; gap: 4px; margin: 0 0 8px; border-bottom: 1px solid var(--tx-line); }
  .tx-insp-tabs button { font: inherit; font-size: 0.85rem; flex: 1; padding: 7px 4px; border: 0; background: none; color: var(--tx-muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
  .tx-insp-tabs button.on { color: var(--tx-ink); border-bottom-color: var(--tx-accent); font-weight: 600; }
  .tx-insp-row { display: none; margin: 0; flex-wrap: nowrap; overflow-x: auto; max-width: 100%; }
  .tx-insp-row.on { display: flex; }
  .tx-insp-row > * { flex-shrink: 0; }
  .tx-inspector { margin: 0 -8px; }
  .tx-inspector .tx-btn { min-height: 42px; padding: 8px 10px; }
}
@media print {
  body * { visibility: hidden; }
  .tx-pane-notation, .tx-pane-notation * { visibility: visible; }
  .tx-pane-notation { position: absolute; left: 0; top: 30px; width: 100%; border: 0; }
  .tx-pane-scroll { max-height: none; overflow: visible; }
  body::before { content: attr(data-print-title); visibility: visible; position: absolute; top: 0; left: 0; font: 600 16pt serif; }
  .tx-svg path:not([fill="none"]), .tx-svg rect:not(.tx-hitbox), .tx-svg text { fill: #000 !important; }
  .tx-svg path:not([stroke="none"]) { stroke: #000 !important; }
  .tx-svg rect.tx-hitbox { fill: transparent !important; }
}
.tx-gate { max-width: 560px; margin: 40px auto; text-align: center; }
.tx-gate p { color: var(--tx-muted); }

:root[data-theme="dark"] .tx-root, :root[data-theme="dark"] .tx-dialog { --tx-doubt: #ff8f6b; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .tx-root, :root:not([data-theme="light"]) .tx-dialog { --tx-doubt: #ff8f6b; } }

.tx-steps { margin: 8px 0 8px 1.2em; padding: 0; font-size: .92rem; } .tx-steps li { margin: 4px 0; }
.tx-linkbtn { font: inherit; background: none; border: 0; padding: 0; color: var(--tx-accent); text-decoration: underline; cursor: pointer; }

/* live notation while recording */
.tx-live-score { margin-top: 1rem; border-top: 1px solid var(--line, rgba(127,127,127,.25)); padding-top: .75rem; }
.tx-live-head { font-size: .88rem; opacity: .8; margin: 0 0 .5rem; }
.tx-live { color: #c0392b; font-weight: 600; margin-right: .4rem; animation: txLive 1.2s ease-in-out infinite; }
@keyframes txLive { 50% { opacity: .35; } }
.tx-live-ed { min-height: 220px; pointer-events: none; }
.tx-live-ed .tx-pane-roll, .tx-live-ed .tx-inspector { display: none; }
.tx-live-ed .tx-panes { display: block; }
@media (prefers-reduced-motion: reduce) { .tx-live { animation: none; } }
.tx-live-ed .tx-pane-scroll { max-height: 340px; overflow: auto; }
.tx-kstep{margin:12px 0 0}
