/* ── Recent sessions ────────────────────────── */
#recentCard {
  display: none;
}

.session-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.session-row:last-child {
  border-bottom: none;
}

.session-meta {
  flex: 1;
  font-size: 0.85em;
  color: var(--text-2);
}

.pagination-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.85em;
  color: var(--text-2);
}

.pagination-bar button {
  padding: 3px 11px;
  font-size: 0.85em;
}

/* ── Upload card (tabbed) ───────────────────── */
.upload-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}

.upload-tab {
  padding: 4px 12px;
  border-radius: 20px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  font-size: 0.82em;
  cursor: pointer;
  white-space: nowrap;
}

.upload-tab.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-strong);
}

.upload-pane {
  display: none;
}

.upload-pane.active {
  display: block;
}

/* ── Master timeline ─────────────────────────── */
.master-tl {
  position: relative;
  height: 64px;
  background: var(--surface-3);
  border-radius: 8px;
  overflow: hidden;
  margin: 10px 0;
  user-select: none;
  cursor: crosshair;
}

#masterWaveform {
  display: block;
  width: 100%;
  height: 80px;
  border-radius: 8px;
  background: var(--surface-2);
  margin: 10px 0 0;
  cursor: default;
}

/* existing clip bands */
.band {
  position: absolute;
  top: 0;
  height: 100%;
  opacity: .75;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: #fff;
  font-weight: bold;
  border-right: 1px solid rgba(255, 255, 255, .35);
  overflow: hidden;
  pointer-events: none;
  /* selection happens on the tl itself */
}

/* drag selection overlay */
.tl-selection {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(235, 71, 153, .28);
  border: 2px solid var(--primary);
  pointer-events: none;
  display: none;
}

/* playhead */
.tl-playhead {
  position: absolute;
  top: 0;
  z-index: 10;
  width: 2px;
  height: 100%;
  background: var(--surface-inverse);
  transform: translateX(-50%);
  pointer-events: none;
}

.tl-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.72em;
  color: var(--muted);
  padding: 1px 2px 0;
}

.extract-info {
  font-size: .85em;
  color: #16a34a;
  font-weight: bold;
}

/* ── Sentence cards ─────────────────────────── */
.s-text {
  font-size: 1em;
  line-height: 1.5;
  margin-bottom: 3px;
}

.s-meta {
  font-size: 0.76em;
  color: var(--muted);
  margin-bottom: 6px;
}

.clip-select-row {
  display: inline-flex;
  align-items: center;
  margin-bottom: 0;
}

.clip-select-row input[type=checkbox] {
  display: none;
}

.clip-select-row label {
  font-size: 0.82em;
  font-weight: 500;
  color: var(--muted);
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  padding: 3px 10px;
  cursor: pointer;
  user-select: none;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: all 0.2s ease;
}

.clip-select-row label:hover {
  background: var(--surface-2);
  border-color: var(--border-strong);
}

/* Custom Checkmark Circle */
.clip-select-row label::before {
  content: "";
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border-strong);
  background: var(--surface);
  transition: all 0.2s ease;
}

/* Checked State */
.clip-select-row input[type=checkbox]:checked + label {
  background: var(--primary-soft);
  color: var(--primary-text);
  border-color: var(--primary-border);
}

.clip-select-row input[type=checkbox]:checked + label::before {
  border-color: var(--primary);
  background: var(--primary);
  box-shadow: inset 0 0 0 2px #eff6ff;
}

.card.clip-selected {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.clip-bar {
  position: relative;
  height: 34px;
  background: var(--surface-3);
  border-radius: 5px;
  overflow: hidden;
  margin: 6px 0;
  cursor: crosshair;
  user-select: none;
}

.clip-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  background: var(--primary-soft);
  pointer-events: none;
}

.clip-head {
  position: absolute;
  top: 0;
  width: 2px;
  height: 100%;
  background: var(--primary);
  transform: translateX(-50%);
  pointer-events: none;
}

.clip-range-sel {
  position: absolute;
  top: 0;
  height: 100%;
  background: rgba(245, 158, 11, .35);
  border: 2px solid #f59e0b;
  pointer-events: none;
  display: none;
}

.clip-range-info {
  font-size: 0.72em;
  color: var(--warn-text);
  font-weight: bold;
  min-height: 1.1em;
  margin: 1px 0 3px;
}

.clip-labels {
  display: flex;
  justify-content: space-between;
  font-size: 0.7em;
  color: var(--muted);
  padding: 0 2px;
}

.pitch-canvas {
  display: block;
  width: 100%;
  height: 64px;
  border-radius: 6px;
  background: var(--surface-2);
  cursor: crosshair;
  margin: 6px 0 2px;
}

.s-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 8px;
}

.speed-btns {
  display: inline-flex;
  gap: 3px;
}

.speed-btns button {
  padding: 3px 8px;
  font-size: 0.78em;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--border-strong);
}

.speed-btns button.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary-strong);
}

/* ── Video clip side-by-side layout ─────────── */
.card-video-layout {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.card-video-thumb {
  flex: 0 0 450px;
  width: 450px;
}

.card-video-thumb video {
  width: 100%;
  border-radius: 6px;
  background: #000;
  display: block;
}

.card-video-content {
  flex: 1 1 0;
  min-width: 0;
}

@media (max-width: 780px) {
  .card-video-layout {
    flex-direction: column;
  }

  .card-video-thumb {
    flex: none;
    width: 100%;
  }
}

/* ── Notes box ──────────────────────────── */
.notes-box {
  margin-top: 8px;
}

.notes-toggle {
  font-size: 0.78em;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  text-decoration: underline dotted;
}

.notes-toggle:hover {
  color: var(--text-2);
  background: var(--surface-2);
}

.notes-area {
  width: 100%;
  margin-top: 5px;
  padding: 7px 9px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 0.88em;
  font-family: inherit;
  resize: vertical;
  background: var(--surface);
  color: var(--text);
  line-height: 1.5;
  min-height: 60px;
}

.notes-area:focus {
  outline: none;
  border-color: var(--primary);
  background: var(--surface);
  box-shadow: 0 0 0 2px rgba(235, 71, 153, .12);
}

.notes-saved-indicator {
  font-size: 0.72em;
  color: #16a34a;
  margin-left: 5px;
  opacity: 0;
  transition: opacity 0.4s;
}

.notes-saved-indicator.show {
  opacity: 1;
}

/* ── Recording section ──────────────────── */
.rec-indicator {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #dc2626;
  margin-right: 5px;
  vertical-align: middle;
  animation: rec-pulse 1s ease-in-out infinite;
}

@keyframes rec-pulse {

  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(220, 38, 38, .5);
  }

  50% {
    opacity: 0.3;
    box-shadow: 0 0 0 5px rgba(220, 38, 38, 0);
  }
}

.rec-status-text {
  font-size: 0.8em;
  color: #dc2626;
  font-weight: bold;
  vertical-align: middle;
}

.rec-take { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.rec-take + .rec-take { border-top: 1px dashed var(--border); }
.rec-take-label { flex-shrink: 0; min-width: 120px; font-size: .8em; color: var(--muted); }
.rec-take.latest .rec-take-label { color: var(--text); font-weight: 700; }
.rec-take audio { flex: 1; min-width: 0; height: 32px; }
.rec-take button { flex-shrink: 0; padding: 2px 8px; font-size: .78em; }
.rec-take-wrap + .rec-take-wrap { border-top: 1px dashed var(--border); }
.rec-take-wrap .rec-take + .rec-take { border-top: none; }
.rec-score-badge { font-weight: 800; border-radius: 999px; padding: 2px 10px; }
.rec-score-badge.high { background: var(--success-soft); color: var(--success-text); border-color: var(--success-border); }
.rec-score-badge.mid  { background: var(--warn-soft); color: var(--warn-text); border-color: var(--warn-border); }
.rec-score-badge.low  { background: var(--danger-soft); color: var(--danger-text); border-color: var(--danger-border); }
.rec-score-detail { margin: 2px 0 8px 128px; font-size: .85em; }
.rec-score-detail .spk-score-words { margin-bottom: 6px; }
.rec-score-detail .spk-score-word { font-size: .9em; padding: 2px 8px; }
@media (max-width: 820px) { .rec-score-detail { margin-left: 0; } }
.recording-player {
  margin-top: 7px;
  padding: 8px 10px;
  background: var(--success-soft);
  border: 1px solid var(--success-border);
  border-radius: 7px;
}

.recording-player-label {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--success-text);
  font-weight: bold;
  margin-bottom: 4px;
  display: block;
}

.recording-player audio {
  width: 100%;
  height: 36px;
  display: block;
}

/* ── Media row (video + subtitle side-by-side) ── */
#mediaRow {
  display: flex;
  gap: 14px;
  align-items: stretch;
  margin: 10px 0;
}

#masterCard {
  flex: 1 1 0;
  min-width: 0;
  display: none;
  /* shown by JS */
}

#srtCard {
  flex: 0 0 520px;
  width: 520px;
  display: none;
  /* shown by JS */
  flex-direction: column;
}

#srtCard.srt-visible {
  display: flex;
}

#srtCard .srt-panel {
  flex: 1 1 0;
  overflow-y: auto;
  min-height: 200px;
  height: 0;
  /* forces flex to control height, not content */
}

@media (max-width: 900px) {
  #mediaRow {
    flex-direction: column;
  }

  #srtCard {
    flex: none;
    width: 100%;
  }

  #srtCard .srt-panel {
    height: 50vh;
  }
}

/* ── Subtitle panel ─────────────────────── */
.srt-panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  margin: 4px 0;
}

.srt-row {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}

.srt-row:last-child {
  border-bottom: none;
}

.srt-row:hover {
  background: var(--primary-soft);
}

.srt-row.srt-active {
  background: var(--primary-soft);
  border-left: 3px solid var(--primary);
  padding-left: 7px;
}

.srt-row.srt-active .srt-ts {
  color: var(--primary);
}

.srt-idx {
  min-width: 28px;
  font-size: 0.72em;
  color: var(--muted);
  padding-top: 1px;
  text-align: right;
  flex-shrink: 0;
}

.srt-body {
  flex: 1;
  min-width: 0;
}

.srt-ts {
  font-size: 0.70em;
  color: var(--muted);
  font-family: monospace;
  display: block;
  margin-bottom: 1px;
}

.srt-text {
  font-size: 0.93em;
  line-height: 1.4;
  word-break: break-word;
}

.srt-extract-btn {
  padding: 2px 7px;
  font-size: 0.72em;
  border-radius: 4px;
  background: #16a34a;
  color: #fff;
  border: none;
  cursor: pointer;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.12s;
  flex-shrink: 0;
  align-self: center;
}

.srt-row:hover .srt-extract-btn,
.srt-row.srt-active .srt-extract-btn {
  opacity: 1;
}

.srt-search {
  width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--border-strong);
  border-radius: 6px;
  font-size: 0.9em;
  margin-bottom: 6px;
  box-sizing: border-box;
}

.srt-search:focus {
  outline: none;
  border-color: var(--primary);
}

.srt-controls {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 6px;
}

/* ── Phonetic respelling box ─────────────── */
.phonetic-box {
  display: none;
  margin-top: 8px;
  padding: 8px 12px;
  background: var(--warn-soft);
  border: 1px solid #fde047;
  border-radius: 7px;
  font-size: 1.08em;
  font-family: 'Segoe UI', 'Arial Unicode MS', Arial, sans-serif;
  color: var(--warn-text);
  letter-spacing: 0.03em;
  line-height: 1.6;
}

.phonetic-box .ph-label {
  font-size: 0.72em;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--warn-text);
  font-weight: bold;
  display: block;
  margin-bottom: 2px;
}





/* Modal */
.fc-overlay {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(0,0,0,.5);
  display: flex; align-items: center; justify-content: center;
}
.fc-modal {
  background: var(--surface); border-radius: 14px; padding: 26px 30px;
  width: min(540px, 95vw); box-shadow: 0 24px 64px rgba(0,0,0,.3);
  max-height: 92vh; overflow-y: auto;
}
.fc-modal h3 { margin: 0 0 18px; font-size: 1.15em; }
.fc-modal.fci-modal { width: min(920px, 96vw); }
.fci-modes { display: inline-flex; gap: 4px; padding: 4px; background: var(--surface-2); border: 1px solid var(--border); border-radius: 12px; margin-bottom: 12px; }
.fci-mode { border: none; background: transparent; color: var(--muted); border-radius: 9px; }
.fci-mode.active, .fci-mode.active:hover:not(:disabled) { background: var(--surface); color: var(--primary); box-shadow: 0 1px 3px rgba(15,23,42,.08); }
.fci-row { display: flex; gap: 8px; align-items: center; }
.fci-row input { flex: 1; min-width: 0; }
.fci-label { font-size: .8em; font-weight: 700; color: var(--muted); text-transform: uppercase; margin: 18px 0 6px; }
.fci-recent { display: block; width: 100%; text-align: left; margin-bottom: 6px; font-weight: 400; }
.fci-recent span { color: var(--muted); font-size: .92em; }
.link-source { margin-top: 18px; }
.dict-auto-blank { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 10px; }
.link-source-label { text-align: center; color: var(--muted); font-size: .85em; margin-bottom: 8px; }
.link-source-range { margin-top: 8px; flex-wrap: wrap; }
.link-source-range input { flex: 0 0 72px; width: 72px; }
.fci-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 8px; }
.fci-toolbar input[type="number"] { width: 64px; }
.fci-hint { font-size: .84em; color: var(--muted); margin-bottom: 10px; }
.fci-transcript { max-height: 44vh; overflow-y: auto; border: 1px solid var(--border); border-radius: 12px; padding: 6px 10px; background: var(--surface-2); }
.fci-seg { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; }
.fci-seg + .fci-seg { border-top: 1px solid var(--border); }
.fci-play { flex-shrink: 0; width: 30px; height: 30px; padding: 0; border-radius: 50%; font-size: .75em; }
.fci-words { line-height: 2; user-select: none; }
.fci-w { cursor: pointer; padding: 3px 1px; border-radius: 5px; }
.fci-w:hover { background: var(--primary-soft); }
.fci-w.picked { background: var(--primary-soft); color: var(--primary-text); border-radius: 0; }
.fci-w.picked.start { border-radius: 5px 0 0 5px; padding-left: 4px; }
.fci-w.picked.end { border-radius: 0 5px 5px 0; padding-right: 4px; }
.fci-w.picked.start.end { border-radius: 5px; }
.fci-w.dragging { background: #a5b4fc; }
.fci-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 12px 0 0; min-height: 8px; }
.fci-chip { padding: 3px 10px; border-radius: 999px; background: var(--primary-soft); border-color: var(--primary-border); color: var(--primary-text); font-size: .85em; }
.fci-chip span { color: var(--primary); }
.fci-result { min-height: 1.3em; font-size: .9em; margin-top: 10px; }
.fc-field { margin-bottom: 14px; }
.fc-field label { display: block; font-size: 0.82em; font-weight: 600; color: var(--text-2); margin-bottom: 4px; }
.fc-field input, .fc-field textarea, .fc-field select {
  width: 100%; padding: 8px 10px;
  border: 1px solid var(--border-strong); border-radius: 7px;
  font-size: 0.95em; font-family: inherit; background: var(--surface);
}
.fc-field input:focus, .fc-field textarea:focus {
  outline: none; border-color: var(--primary); background: var(--surface);
  box-shadow: 0 0 0 2px rgba(235, 71, 153,.12);
}
.fc-modal-footer { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
/* SRT flashcard button (same show/hide as extract) */
.srt-fc-btn {
  padding: 2px 7px; font-size: 0.72em; border-radius: 4px;
  background: #d97706; color: #fff; border: none; cursor: pointer;
  white-space: nowrap; opacity: 0; flex-shrink: 0; align-self: center;
}
.srt-row:hover .srt-fc-btn,
.srt-row.srt-active .srt-fc-btn { opacity: 1; }

/* Cloze styles */
.cloze-input {
  padding: 0 2px; font-size: 1em; font-family: inherit; text-align: center;
  border: none; border-bottom: 2px solid var(--border-strong); border-radius: 0; background: transparent; color: var(--text); margin: 0 2px;
  transition: all 0.2s;
}
.cloze-input:focus { outline: none; border-bottom-color: var(--primary); background: var(--primary-soft); }
.cloze-input.correct { border-bottom-color: #22c55e; color: var(--success-text); pointer-events: none; }
.cloze-input.incorrect { border-bottom-color: #ef4444; color: var(--danger-text); background: var(--danger-soft); }

#makeBlankPopup {
  position: absolute; z-index: 9999; background: var(--surface-inverse); color: white; padding: 4px 10px;
  font-size: 0.85em; border-radius: 6px; cursor: pointer; box-shadow: 0 4px 6px rgba(0,0,0,0.2);
  display: none; transform: translate(-50%, -100%); margin-top: -8px; border: 1px solid #0f172a;
}
#makeBlankPopup::after {
  content: ''; position: absolute; top: 100%; left: 50%; margin-left: -5px;
  border-width: 5px; border-style: solid; border-color: #1e293b transparent transparent transparent;
}
