/* ============================================================
   TRUE CLEF — A new notation prototype
   ============================================================ */

/* ── Toolbar ───────────────────────────────────────────────── */
.tc-toolbar {
  margin: 0 auto 18px;
  padding: 18px 22px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
}

.tc-toolbar-row {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.tc-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: 500 13px/1 var(--font);
  letter-spacing: 0.01em;
  padding: 9px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, box-shadow 0.25s ease, transform 0.12s var(--ease-spring);
  user-select: none;
}
.tc-btn:hover:not(:disabled) {
  border-color: var(--line-bright);
  background: var(--bg-alt);
}
.tc-btn:active:not(:disabled) { transform: scale(0.97); }
.tc-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.tc-btn--primary {
  background: var(--ink);
  color: var(--bg);
  border-color: var(--ink);
}
.tc-btn--primary:hover {
  box-shadow: var(--glow-soft);
  background: var(--ink);
  color: var(--bg);
}
.tc-btn--icon { padding: 9px 11px; }
.tc-btn .icon-play,
.tc-btn .icon-pause { display: block; }

.tc-divider {
  width: 1px;
  height: 22px;
  background: var(--line);
  margin: 0 4px;
}

.tc-speed {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 500 12px/1 var(--font);
  color: var(--ink-dim);
  margin-left: auto;
}
.tc-speed input[type="range"] {
  width: 130px;
  accent-color: var(--ink);
}
.tc-speed-readout {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  min-width: 44px;
  text-align: right;
}

.tc-zoom {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: 500 12px/1 var(--font);
  color: var(--ink-dim);
  margin-left: 14px;
}
.tc-zoom-btn {
  appearance: none;
  width: 26px; height: 26px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: 600 14px/1 var(--font-mono);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.tc-zoom-btn:hover { background: var(--bg-alt); border-color: var(--line-bright); }
.tc-zoom-btn:active { transform: scale(0.95); }
.tc-zoom-readout {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--ink);
  min-width: 36px;
  text-align: center;
}

.tc-model {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font: 500 12px/1 var(--font);
  color: var(--ink-dim);
  margin-left: 14px;
}
.tc-model select {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: 500 12px/1 var(--font);
  padding: 7px 26px 7px 10px;
  border-radius: 8px;
  cursor: pointer;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%235a5a5a' stroke-width='1.5' fill='none' stroke-linecap='round'/></svg>");
  background-repeat: no-repeat;
  background-position: right 9px center;
}
.tc-model select:focus { outline: none; border-color: var(--ink); }

/* ── Meta row: key / time / tempo / file ───────────────────── */
.tc-meta-row {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  font: 500 12px/1.4 var(--font);
  color: var(--ink-dim);
  letter-spacing: 0.02em;
}
.tc-meta-empty { color: var(--ink-faint); font-weight: 400; }
.tc-meta-empty b { color: var(--ink); font-weight: 600; }

.tc-meta-item {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
}
.tc-meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}
.tc-meta-value {
  font-size: 14px;
  color: var(--ink);
  font-weight: 600;
}
.tc-meta-value--mono {
  font-family: var(--font-mono);
  font-weight: 500;
  font-size: 13px;
}

/* ── Inspector strip — hover-driven facts about the staff ── */
.tc-inspector {
  margin: 0 auto 12px;
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-soft);
  transition: opacity 0.18s ease;
}
.tc-inspector[data-empty="true"] .tc-insp-value { color: var(--ink-faint); }
.tc-insp-row {
  display: flex;
  align-items: center;
  gap: 26px;
  flex-wrap: wrap;
}
.tc-insp-cell {
  display: inline-flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.tc-insp-cell--hint { margin-left: auto; }
.tc-insp-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--ink-faint);
}
.tc-insp-value {
  font: 600 13px/1.2 var(--font);
  font-family: var(--font-mono);
  color: var(--ink);
}
.tc-insp-hint {
  font: 400 11px/1 var(--font);
  color: var(--ink-faint);
  letter-spacing: 0.02em;
}

/* ── Stage: canvas wrapper ─────────────────────────────────── */
.tc-stage {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  overflow: auto;        /* horizontal + vertical scroll when canvas is wider/taller than viewport */
  min-height: 460px;
  transition: border-color 0.2s ease, box-shadow 0.25s ease;
}
/* Tighter scrollbars inside the stage so they don't dominate the design. */
.tc-stage::-webkit-scrollbar { height: 10px; width: 10px; }
.tc-stage::-webkit-scrollbar-thumb {
  background: var(--line-bright);
  border-radius: 999px;
}
.tc-stage::-webkit-scrollbar-thumb:hover { background: var(--ink-dim); }
.tc-stage::-webkit-scrollbar-track { background: transparent; }
.tc-stage.is-dragover {
  border-color: var(--ink);
  box-shadow: var(--glow-soft);
}

.tc-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  color: var(--ink-faint);
  pointer-events: none;
  padding: 40px;
  text-align: center;
}
.tc-empty[hidden] { display: none; }
#tc-canvas[hidden] { display: none; }
.tc-empty-title {
  font: 500 16px/1.3 var(--font);
  color: var(--ink-dim);
}
.tc-empty-title b { color: var(--ink); }
.tc-empty-sub {
  font: 400 13px/1.5 var(--font);
  max-width: 360px;
}

#tc-canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

/* Playhead — DOM element layered over the canvas. Position is driven by
   transform, so playback animates without redrawing the staff. */
.tc-playhead {
  position: absolute;
  top: 36px;
  bottom: 16px;
  left: 0;
  width: 2px;
  background: var(--ink);
  pointer-events: none;
  will-change: transform;
  box-shadow: 0 0 6px rgba(var(--glow-rgb), 0.55);
  z-index: 2;
}
.tc-playhead[hidden] { display: none; }

/* ── Legend ────────────────────────────────────────────────── */
.tc-legend {
  margin-top: 24px;
  padding: 22px 26px 24px;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.tc-legend-title {
  font: 500 14px/1 var(--font);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  margin: 0 0 18px;
}
.tc-legend-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 18px 24px;
}
.tc-legend-cell {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}
.tc-legend-swatch {
  flex: 0 0 auto;
  width: 26px;
  height: 14px;
  border-radius: 4px;
  margin-top: 4px;
}
.tc-sw-bass    { background: #e88a4a; }
.tc-sw-harmony { background: #5fa8c8; }
.tc-sw-melody  { background: #c75c8a; }
.tc-sw-blackkey {
  background: repeating-linear-gradient(
    180deg,
    var(--line) 0 7px,
    var(--bg-alt) 7px 14px
  );
  border: 1px solid var(--line);
}
.tc-legend-h {
  font: 600 13px/1.2 var(--font);
  color: var(--ink);
  margin-bottom: 3px;
}
.tc-legend-p {
  font: 400 12px/1.45 var(--font);
  color: var(--ink-dim);
}
.tc-legend-note {
  margin: 18px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--line);
  font: 400 13px/1.6 var(--font);
  color: var(--ink-dim);
}
.tc-legend-note b { color: var(--ink); font-weight: 600; }

/* ── Page width override — give the staff some room ────────── */
.page { max-width: 1180px; }

/* ── API-key modal & OMR overlay ──────────────────────────── */
.tc-modal {
  position: fixed; inset: 0;
  z-index: 1000;
  display: flex; align-items: center; justify-content: center;
}
.tc-modal[hidden] { display: none; }
.tc-modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(20, 20, 30, 0.4);
  backdrop-filter: blur(4px);
}
.tc-modal-card {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 26px 26px 22px;
  width: min(440px, 92vw);
  display: flex; flex-direction: column; gap: 14px;
}
.tc-modal-title {
  margin: 0;
  font: 500 16px/1.2 var(--font);
  color: var(--ink);
  letter-spacing: 0.01em;
}
.tc-modal-body {
  margin: 0;
  font: 400 13px/1.55 var(--font);
  color: var(--ink-dim);
}
.tc-modal-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-alt);
  padding: 1px 5px;
  border-radius: 4px;
}
.tc-modal-body a { color: var(--ink); text-decoration: underline; }
.tc-modal-input {
  appearance: none;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: 500 13px/1 var(--font-mono);
  padding: 11px 13px;
  border-radius: 8px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.tc-modal-input:focus { border-color: var(--ink); box-shadow: var(--glow-soft); }
.tc-modal-row {
  display: flex; justify-content: flex-end; gap: 10px;
  margin-top: 4px;
}
.tc-modal-card--wide { width: min(680px, 94vw); }
.tc-modal-textarea {
  appearance: none;
  width: 100%;
  min-height: 130px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--ink);
  font: 500 11.5px/1.5 var(--font-mono);
  padding: 10px 12px;
  border-radius: 8px;
  outline: none;
  resize: vertical;
  transition: border-color 0.18s ease;
}
.tc-modal-textarea:focus { border-color: var(--ink); box-shadow: var(--glow-soft); }

.tc-paste-steps {
  display: flex; flex-direction: column; gap: 14px;
  margin: 4px 0 2px;
}
.tc-paste-step {
  display: flex; gap: 14px; align-items: flex-start;
}
.tc-paste-step-n {
  flex: 0 0 auto;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  display: inline-flex; align-items: center; justify-content: center;
  font: 600 12px/1 var(--font-mono);
  margin-top: 2px;
}
.tc-paste-step > div:nth-child(2) {
  flex: 1 1 auto; display: flex; flex-direction: column; gap: 6px;
  align-items: flex-start;
}
.tc-paste-step-title {
  font: 500 13px/1.3 var(--font);
  color: var(--ink);
}
.tc-paste-hint {
  font: 400 11px/1.4 var(--font);
  color: var(--ink-faint);
}

.tc-omr-overlay {
  position: fixed; inset: 0;
  z-index: 1100;
  background: rgba(20, 20, 30, 0.55);
  backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
}
.tc-omr-overlay[hidden] { display: none; }
.tc-omr-card {
  background: var(--bg-card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-card);
  padding: 30px 36px 26px;
  width: min(420px, 92vw);
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  text-align: center;
}
.tc-omr-spinner {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 2.5px solid var(--line);
  border-top-color: var(--ink);
  animation: tc-spin 0.9s linear infinite;
}
@keyframes tc-spin { to { transform: rotate(360deg); } }
.tc-omr-status {
  font: 500 14px/1.3 var(--font);
  color: var(--ink);
}
.tc-omr-sub {
  font: 400 12px/1.5 var(--font);
  color: var(--ink-dim);
  max-width: 320px;
}
.tc-omr-row { display: flex; gap: 10px; margin-top: 4px; }
.tc-omr-cancel, .tc-omr-retry { margin-top: 0; }
.tc-omr-overlay.is-error .tc-omr-spinner {
  border: 2.5px solid #c75c8a;
  border-radius: 50%;
  animation: none;
  background: radial-gradient(circle, #c75c8a 30%, transparent 32%);
}
