
/* Transcript panel — right column, full height */
.transcript-panel {
  flex: 1;
  min-width: 350px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.transcript-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}

.transcript-header h2 {
  display: flex;
  align-items: center;
  gap: 0.6em;
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}


.transcript-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
  position: relative;
  isolation: isolate;
}

.transcript-body::-webkit-scrollbar { width: 4px; }
.transcript-body::-webkit-scrollbar-track { background: transparent; }
.transcript-body::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.transcript-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 0.75rem;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--fs-body);
  letter-spacing: 0.06em;
  text-align: center;
  opacity: 0.5;
}

.transcript-empty .t-icon { font-size: var(--fs-display); opacity: 0.4; }


/* Paragraph row: handle bar + paragraph text */
.para-row {
  display: flex;
  align-items: stretch;
  gap: 0.85rem;
  margin-bottom: 0.65rem;
}

.para-handle {
  position: relative;
  width: 5px;
  flex-shrink: 0;
  border-radius: 2px;
  opacity: 0.3;
  cursor: pointer;
  transition: opacity 0.15s;
  /* Inset by half-leading so the bar aligns with the text glyph area.
     .t-seg uses font-size 0.875rem and line-height 1.7, so
     half-leading = 0.875rem * (1.7 - 1) / 2 = 0.875rem * 0.35 */
  margin-top: calc(0.875rem * 0.35);
  margin-bottom: calc(0.875rem * 0.35);
}

.para-handle::after {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 100%;
  width: 0.85rem; /* covers the gap between handle and text */
}

.para-handle:hover {
  opacity: 1;
}

.para-handle:hover ~ .transcript-para .t-seg {
  color: var(--text);
}

/* Paragraphs within a speaker block */
.transcript-para {
  flex: 1;
  min-width: 0;
  margin-bottom: 0;
  text-align: justify;
}

.export-btn {
  font-family: var(--font-mono);
  font-size: var(--fs-secondary);
  color: var(--accent2);
  letter-spacing: 0.06em;
  cursor: pointer;
  position: relative;
  padding: 0.2rem 0.4rem;
  margin: -0.2rem -0.4rem;
  border-radius: 2px;
  transition: background 0.15s, color 0.15s;
  background: transparent;
}

/* ── Paragraph speaker popup ─────────────────────────────────────────────── */

.para-speaker-popup {
  position: fixed;
  z-index: 2000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 4px 0;
  min-width: 160px;
  box-shadow: 0 6px 24px var(--shadow-md);
  font-family: var(--font-mono);
  font-size: var(--fs-body);
}

.para-speaker-popup-header {
  padding: 0.35rem 1rem;
  color: var(--muted);
  font-size: var(--fs-secondary);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  margin-bottom: 2px;
}

/* Individual word segments — each row is a clickable span */
.t-seg {
  cursor: pointer;
  border-radius: 2px;
  transition: background 0.1s, color 0.1s;
  line-height: 1.7;
  font-size: var(--fs-prose);
  color: var(--muted);
  padding: 0.35em 0;
}

.t-seg:hover {
  color: var(--text);
}

.t-seg.active  { color: var(--text); }
.t-seg.hovered { color: var(--text); }

.t-seg-hl {
  border-radius: 2px;
  padding: 0 2px;
  margin: 0 -2px;
}

/* Word-level spans — rendered inside .t-seg-hl when word timestamps are available */
.t-word {
  border-radius: 2px;
}

.t-word.active-word {
  outline: 1px solid var(--accent);
  border-radius: 2px;
}

.t-seg.active .t-seg-hl {
  background: var(--accent-subtle);
}

.t-seg.hovered .t-seg-hl {
  background: var(--hover-overlay);
}

.t-seg.active.hovered .t-seg-hl {
  background: var(--accent-hover);
}

.t-seg.selected .t-seg-hl {
  outline: 1px solid var(--accent-select);
  background: var(--accent-subtle);
}

.t-seg.editing {
  outline: 1px solid var(--accent-glow);
  background: var(--accent-faint);
  border-radius: 2px;
  padding: 0.35em 2px;
  margin: 0 -2px;
  white-space: pre-wrap;
  min-width: 2px;
  color: var(--text);
  caret-color: var(--accent);
}

/* Stale word-timestamp tooltip */
.stale-tooltip-msg {
  font-weight: 600;
  margin-bottom: 2px;
}
.stale-tooltip-hint {
  opacity: 0.75;
  font-size: 0.85em;
}

/* Stale word-timestamp indicator */
@keyframes stale-spin {
  from { transform: rotate(0deg); }
  to   { transform: rotate(360deg); }
}
.t-seg-stale-badge {
  font-size: 0.6rem;
  vertical-align: super;
  line-height: 1;
  margin-left: 1px;
  color: var(--warning, #e8a000);
  opacity: 0.75;
  cursor: default;
  user-select: none;
}
.t-seg--words-stale .t-seg-hl {
  text-decoration: underline dotted var(--warning, #e8a000);
  text-underline-offset: 3px;
}
.stale-badge--loading {
  display: inline-block;
  width: 7px;
  height: 7px;
  border: 1.5px solid color-mix(in srgb, var(--warning, #e8a000) 30%, transparent);
  border-top-color: var(--warning, #e8a000);
  border-radius: 50%;
  vertical-align: middle;
  animation: stale-spin 0.75s linear infinite;
  opacity: 1;
  margin-left: 1px;
  font-size: 0;
}


.transcript-btn {
  font-family: var(--font-mono);
  font-size: var(--fs-secondary);
  color: var(--accent2);
  letter-spacing: 0.06em;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0.2rem 0.4rem;
  margin: -0.2rem -0.4rem;
  border-radius: 2px;
  line-height: 1;
  transition: background 0.15s, color 0.15s;
}

.transcript-btn:hover {
  background: var(--accent2-faint);
  color: var(--accent2);
}

.transcript-btn:disabled {
  opacity: 0.3;
  cursor: default;
}

.transcript-btn:disabled:hover {
  background: none;
}

.transcript-delete-btn {
  color: var(--muted) !important;
}

.transcript-delete-btn:hover {
  background: var(--danger-subtle) !important;
  color: var(--danger) !important;
}

/* ── Transcription progress bar ──────────────────────────────────────────── */

.transcribe-progress {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  padding: 0.5rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}

.transcribe-progress-track {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}

.transcribe-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--accent2);
  border-radius: 2px;
  transition: width 0.4s ease;
}

.transcribe-status-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.5rem;
}

.transcribe-status {
  font-family: var(--font-mono);
  font-size: var(--fs-hint);
  color: var(--muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

.transcribe-elapsed {
  font-family: var(--font-mono);
  font-size: var(--fs-hint);
  color: var(--muted);
  letter-spacing: 0.04em;
  white-space: nowrap;
  flex-shrink: 0;
}

.transcript-drop {
  font-family: var(--font-mono);
  font-size: var(--fs-secondary);
  color: var(--accent2);
  letter-spacing: 0.06em;
  cursor: pointer;
  position: relative;
  padding: 0.2rem 0.4rem;
  margin: -0.2rem -0.4rem;
  border-radius: 2px;
  transition: background 0.15s, color 0.15s;
}

.transcript-drop:hover {
  background: var(--accent2-faint);
  color: var(--accent2);
}

.transcript-drop input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
  width: 100%;
}


#transcriptPanel.header-compact .transcript-header .btn-label { display: none; }

/* ── Search bar ──────────────────────────────────────────────────────────── */

.transcript-search {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  flex-shrink: 0;
}

.search-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
}

.replace-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.3rem 0.75rem 0.45rem;
  border-top: 1px solid var(--border);
}

.search-replace-toggle.active {
  color: var(--accent2);
  border-color: var(--accent2);
}

.replace-btn:not(:disabled) {
  color: var(--text);
}

.replace-btn:not(:disabled):hover {
  color: var(--accent2);
  border-color: var(--accent2);
  background: var(--accent2-faint);
}

.search-input-wrap {
  flex: 1;
  min-width: 0;
  position: relative;
  display: flex;
}

.search-input {
  flex: 1;
  min-width: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--fs-caption);
  padding: 0.22rem 1.4rem 0.22rem 0.5rem;
  outline: none;
  transition: border-color 0.15s;
}

.search-input:focus { border-color: var(--accent-border); }
.search-input::placeholder { color: var(--muted); opacity: 0.55; }

.search-clear-btn {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 1.4rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: var(--fs-secondary);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  transition: color 0.1s;
}

.search-clear-btn:hover { color: var(--text); }
.search-input-wrap.has-value .search-clear-btn { display: flex; }

.search-speaker-select {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: var(--fs-detail);
  padding: 0.22rem 0.3rem;
  outline: none;
  cursor: pointer;
  max-width: 120px;
}

.search-speaker-select:focus { border-color: var(--accent-border); color: var(--text); }

.search-count {
  font-family: var(--font-mono);
  font-size: var(--fs-detail);
  color: var(--muted);
  white-space: nowrap;
  min-width: 3.8rem;
  text-align: center;
}

.search-nav-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: 2px;
  color: var(--muted);
  font-size: var(--fs-body);
  padding: 0.18rem 0.38rem;
  cursor: pointer;
  line-height: 1;
  transition: color 0.1s, border-color 0.1s;
}

.search-nav-btn:hover { color: var(--text); border-color: var(--accent-border); }
.search-nav-btn:disabled { opacity: 0.3; cursor: default; }


/* ── Search highlight styles ─────────────────────────────────────────────── */

.t-seg.search-match { color: var(--text); }

.t-seg.search-focused .t-seg-hl {
  background: var(--accent-subtle);
}


/* Suppress the native selection background so the custom overlay shows cleanly.
   Also covers the trailing space text node that sits directly inside .t-seg. */
.t-seg-hl::selection,
.t-seg-hl *::selection,
.t-seg::selection {
  background: transparent;
}

/* ── Custom selection overlay ────────────────────────────────────────────── */

.transcript-sel-overlay {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: -1;
}

.transcript-sel-rect {
  position: absolute;
  border-radius: 2px;
  background: var(--accent2-select);
  outline: 1px solid var(--accent2-glow);
  pointer-events: none;
  transition: background 0.1s, outline-color 0.1s;
}

.transcript-sel-connector {
  border-radius: 0;
  outline: none;
}

/* Text inside a highlighted segment gets a brightness boost — between muted and full hover. */
.t-seg--in-selection .t-seg-hl {
  color: color-mix(in oklch, var(--text) 60%, var(--muted));
}

/* Hovering any part of a segment still brings that segment's text to full hover color. */
.t-seg--in-selection:hover .t-seg-hl,
.t-seg--in-selection.hovered .t-seg-hl {
  color: var(--text);
}

/* Whole highlight brightens only when the cursor is actually over a highlight rect. */
.transcript-sel-overlay.hovered .transcript-sel-rect {
  background: oklch(from var(--accent2) l c h / 0.68);
  outline-color: oklch(from var(--accent2) l c h / 0.85);
}

mark.search-hl {
  background: var(--accent-mark);
  color: inherit;
  border-radius: 2px;
  padding: 0 1px;
  margin: 0 -1px;
}

.t-seg.search-focused mark.search-hl {
  background: var(--accent-select);
}

/* Links inside an editing segment keep their colour but use a text cursor */
.t-seg.editing .t-seg-link {
  cursor: text;
  pointer-events: none;
}

/* ── Hyperlinks ──────────────────────────────────────────────────────────── */

/* Base: always show the accent colour so links are identifiable, but no
   interactive styling until Ctrl is held. */
.t-seg-link {
  color: var(--accent2);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: var(--accent2-border);
  border-radius: 2px;
  cursor: default;
  transition: background 0.1s, text-decoration-color 0.1s;
}

/* Ctrl held: full interactive link behaviour. */
.ctrl-held .t-seg-link {
  cursor: pointer;
}

.ctrl-held .t-seg-link:hover {
  background: var(--accent2-hover);
  text-decoration-color: var(--accent2);
}

