/* ============================================================================
 * Speech Stats Panel — R3-B Studio
 *
 * Visual definitions for the speech-writing stats panel mounted via
 * margin-panels.js. Every color is sourced from existing CivNode theme
 * variables (`--bg-*`, `--text-*`, `--border*`, `--accent*`, `--success`,
 * plus the five `--craft-*` / `--rhetoric-device` variables added at the
 * bottom of `themes.css`). No hardcoded hex values.
 *
 * Layout reference: `/Desktop/mockups/speech-writing/round-3/r3-b-studio.html`
 * ============================================================================ */

.speech-stats-panel {
  font-family: var(--font-sans);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  gap: 0;
  min-width: 340px;
}

/* Hero block: delivery time + facts column on top, pacing bar, waveform,
   and audience chips. Single bordered surface so the four sub-sections
   read as a cohesive "studio" instead of four loose cards. */
.speech-stats-panel .studio-hero {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 1.3rem 1.4rem 1.1rem;
}

.speech-stats-panel .hero-topline {
  display: flex;
  align-items: stretch;
  gap: 1.1rem;
}

.speech-stats-panel .hero-time-col {
  flex-shrink: 0;
}

.speech-stats-panel .hero-time-label {
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.25rem;
}

.speech-stats-panel .hero-time {
  font-family: var(--font-serif);
  font-size: 2.8rem;
  color: var(--accent);
  line-height: 0.95;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.speech-stats-panel .hero-time-sub {
  font-size: 0.66rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
  font-style: italic;
}

.speech-stats-panel .hero-facts-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 1.1rem;
  border-left: 1px solid var(--border-subtle);
  font-size: 0.72rem;
  color: var(--text-secondary);
  line-height: 1.5;
  gap: 0.32rem;
}

.speech-stats-panel .hero-facts-col .fact {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  align-items: baseline;
}

.speech-stats-panel .hero-facts-col b {
  color: var(--text-primary);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
  font-family: var(--font-serif);
  font-size: 0.88rem;
}

.speech-stats-panel .hero-facts-col .fact-lang b {
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.74rem;
  font-family: var(--font-sans);
  font-weight: 500;
  font-style: normal;
}

/* Pacing bar — the slow→rapid spectrum strip with the active position
   highlighted by a vertical tick over the gradient fill. */
.speech-stats-panel .pacing-bar {
  margin-top: 1.1rem;
  height: 6px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  position: relative;
}

.speech-stats-panel .pacing-bar-fill {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    color-mix(in srgb, var(--accent) 40%, transparent),
    var(--accent)
  );
  transition: width 240ms ease;
}

.speech-stats-panel .pacing-bar-indicator {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  background: var(--text-primary);
  box-shadow: 0 0 0 1px var(--bg-surface);
  transition: left 240ms ease;
}

.speech-stats-panel .pacing-bar-marks {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  justify-content: space-between;
  padding: 0 1px;
  pointer-events: none;
}

.speech-stats-panel .pacing-bar-mark {
  width: 1px;
  background: var(--bg-primary);
}

.speech-stats-panel .pacing-scale {
  display: flex;
  justify-content: space-between;
  font-size: 0.58rem;
  color: var(--text-muted);
  margin-top: 0.3rem;
  letter-spacing: 0.02em;
}

.speech-stats-panel .pacing-scale .active {
  color: var(--accent);
}

/* Waveform timeline — per-sentence syllable bars and rhetoric markers.
   Background gradient gives a soft horizon line so empty bars still
   read as part of the timeline rather than as a flat block. */
.speech-stats-panel .wave {
  position: relative;
  height: 82px;
  margin: 1rem -0.1rem 0.4rem;
  border-top: 1px solid var(--border-subtle);
  border-bottom: 1px solid var(--border-subtle);
  background: linear-gradient(
    180deg,
    transparent 0%,
    var(--bg-elevated) 50%,
    transparent 100%
  );
}

.speech-stats-panel .wave-bars {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 100%;
  gap: 1px;
  padding: 0 0.15rem;
}

.speech-stats-panel .wave-bar {
  flex: 1;
  background: color-mix(in srgb, var(--text-primary) 22%, transparent);
  min-width: 2px;
}

.speech-stats-panel .wave-markers {
  position: absolute;
  top: 0;
  left: 0.15rem;
  right: 0.15rem;
  bottom: 0;
  pointer-events: none;
}

.speech-stats-panel .wave-marker {
  position: absolute;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--rhetoric-device);
  transform: translate(-50%, -50%);
  border: 2px solid var(--bg-surface);
  box-shadow: 0 0 0 1px var(--rhetoric-device);
  cursor: pointer;
  pointer-events: auto;
}

.speech-stats-panel .wave-marker.tricolon {
  background: color-mix(in srgb, var(--accent) 70%, var(--text-primary) 30%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 70%, var(--text-primary) 30%);
}

.speech-stats-panel .wave-marker.epistrophe {
  background: color-mix(in srgb, var(--accent) 80%, var(--bg-elevated) 20%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 80%, var(--bg-elevated) 20%);
}

.speech-stats-panel .wave-marker.chiasmus {
  background: color-mix(in srgb, var(--accent) 50%, var(--text-secondary) 50%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 50%, var(--text-secondary) 50%);
}

.speech-stats-panel .wave-marker.alliteration {
  background: var(--craft-passive);
  box-shadow: 0 0 0 1px var(--craft-passive);
}

.speech-stats-panel .wave-marker.callback {
  background: color-mix(in srgb, var(--accent) 70%, var(--text-primary) 15%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 70%, var(--text-primary) 15%);
}

.speech-stats-panel .wave-marker.asyndeton,
.speech-stats-panel .wave-marker.polysyndeton,
.speech-stats-panel .wave-marker.antithesis,
.speech-stats-panel .wave-marker.hypophora {
  background: color-mix(in srgb, var(--accent) 60%, var(--text-secondary) 40%);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 60%, var(--text-secondary) 40%);
}

/* Breath-violation bands — translucent error band with sharp side rules
   so even one is impossible to miss. */
.speech-stats-panel .wave-breath {
  position: absolute;
  top: 0;
  bottom: 0;
  background: color-mix(in srgb, var(--craft-breath) 28%, transparent);
  border-left: 2px solid var(--craft-breath);
  border-right: 2px solid var(--craft-breath);
}

.speech-stats-panel .wave-axis {
  display: flex;
  justify-content: space-between;
  font-size: 0.58rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  padding: 0 0.15rem;
  margin-bottom: 0.75rem;
}

/* Audience preset chips — three equal-width pills under the waveform. */
.speech-stats-panel .audience-row {
  display: flex;
  gap: 0.35rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border-subtle);
}

.speech-stats-panel .audience-chip {
  flex: 1;
  padding: 0.45rem;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 0.66rem;
  color: var(--text-secondary);
  text-align: center;
  cursor: pointer;
  letter-spacing: 0.02em;
  user-select: none;
  transition: background-color 200ms ease, color 200ms ease, border-color 200ms ease;
}

.speech-stats-panel .audience-chip:hover {
  color: var(--text-primary);
}

.speech-stats-panel .audience-chip.active {
  background: var(--accent-subtle);
  border-color: color-mix(in srgb, var(--accent) 50%, transparent);
  color: var(--accent);
}

/* 2×2 metric cards. Single border around the grid; the cards inside use
   1px gaps over the border color so the four cells read as one block. */
.speech-stats-panel .metric-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-top: none;
}

.speech-stats-panel .metric-card {
  background: var(--bg-surface);
  padding: 0.85rem 0.95rem 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.speech-stats-panel .metric-label {
  font-size: 0.6rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.speech-stats-panel .metric-value {
  font-family: var(--font-serif);
  font-size: 1.55rem;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  line-height: 1.15;
}

.speech-stats-panel .metric-hint {
  font-size: 0.66rem;
  color: var(--text-secondary);
  margin-top: 0.1rem;
  line-height: 1.4;
}

.speech-stats-panel .metric-hint.warn {
  color: var(--craft-filler);
}

.speech-stats-panel .metric-hint.ok {
  color: var(--success);
}

/* Rhetoric chip row at the bottom of the panel. */
.speech-stats-panel .rhetoric-row {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-top: none;
  padding: 0.9rem 1.1rem;
}

.speech-stats-panel .rhetoric-row .label {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.55rem;
  display: flex;
  justify-content: space-between;
}

.speech-stats-panel .rhetoric-row .label b {
  color: var(--accent);
  font-weight: 500;
}

.speech-stats-panel .rhetoric-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.speech-stats-panel .rhetoric-chip {
  padding: 0.26rem 0.55rem;
  background: color-mix(in srgb, var(--rhetoric-device) 8%, transparent);
  border: 1px solid color-mix(in srgb, var(--rhetoric-device) 28%, transparent);
  font-size: 0.68rem;
  color: var(--rhetoric-device);
  cursor: pointer;
  transition: background-color 200ms ease, border-color 200ms ease;
}

.speech-stats-panel .rhetoric-chip:hover {
  background: color-mix(in srgb, var(--rhetoric-device) 14%, transparent);
  border-color: color-mix(in srgb, var(--rhetoric-device) 42%, transparent);
}

.speech-stats-panel .rhetoric-chip b {
  font-weight: 600;
  margin-right: 0.25rem;
  font-variant-numeric: tabular-nums;
}

/* Status line for loading/error feedback. Stays out of the way when
   metrics render successfully. */
.speech-stats-panel .speech-status {
  font-size: 0.7rem;
  color: var(--text-muted);
  padding: 0.7rem 0.4rem 0.2rem;
  font-style: italic;
}

.speech-stats-panel .speech-status.error {
  color: var(--craft-filler);
  font-style: normal;
}

/* ============================================================================
 * Stage-cue inline pills (Tier 3b)
 *
 * Atomic inline nodes that sit inside prose paragraphs. Each pill is an
 * icon + short label, sized to read as a comma in the sentence — visible
 * but never dominant. Colors derive from the existing --craft-* and
 * --rhetoric-device theme variables so pills pick up every theme for
 * free.
 * ============================================================================ */

.ProseMirror span.sc {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.05em 0.45em;
  margin: 0 0.1em;
  border-radius: 999px;
  background: color-mix(in srgb, var(--sc-color, var(--text-muted)) 9%, transparent);
  border: 1px solid color-mix(in srgb, var(--sc-color, var(--text-muted)) 35%, transparent);
  color: var(--sc-color, var(--text-muted));
  font-family: var(--font-sans, inherit);
  font-size: 0.78em;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: 0.02em;
  user-select: none;
  cursor: default;
  vertical-align: baseline;
  white-space: nowrap;
}

.ProseMirror span.sc .sc-icon {
  display: inline-block;
  width: 0.9em;
  height: 0.9em;
  flex: 0 0 auto;
  background-color: var(--sc-color, var(--text-muted));
  -webkit-mask-image: var(--sc-mask);
          mask-image: var(--sc-mask);
  -webkit-mask-repeat: no-repeat;
          mask-repeat: no-repeat;
  -webkit-mask-position: center;
          mask-position: center;
  -webkit-mask-size: contain;
          mask-size: contain;
}

.ProseMirror span.sc .sc-label {
  font-variant-numeric: tabular-nums;
}

.ProseMirror span.sc-pause,
.ProseMirror span.sc-beat {
  --sc-color: var(--text-muted);
}

.ProseMirror span.sc-applause {
  --sc-color: var(--accent);
}

.ProseMirror span.sc-stage {
  --sc-color: var(--craft-passive);
}

.ProseMirror span.sc-media {
  --sc-color: var(--craft-repetition);
}

/* ============================================================================
 * Rhetoric device inline decorations (Tier 3b)
 *
 * Detected rhetorical devices — anaphora, tricolon, chiasmus, and so on —
 * surface as subtle dashed underlines inside the editor prose. The style
 * is deliberately celebratory, not corrective: rhetoric is a feature of
 * strong speech writing, not a mistake to fix.
 *
 * Colors derive from var(--rhetoric-device), which themes.css defines as
 * color-mix(accent ...). A faint chip background and a 1px dashed under-
 * line are both sourced from that single variable.
 * ============================================================================ */

.ProseMirror .rhetoric-device {
  background: color-mix(in srgb, var(--rhetoric-device) 6%, transparent);
  border-bottom: 1px dashed color-mix(in srgb, var(--rhetoric-device) 75%, transparent);
  padding-bottom: 1px;
  border-radius: 2px;
  transition: background 150ms ease, border-color 150ms ease;
}

.ProseMirror .rhetoric-device--active {
  background: color-mix(in srgb, var(--rhetoric-device) 18%, transparent);
  border-bottom-color: var(--rhetoric-device);
}

/* ============================================================================
 * Speaker notes margin column (Tier 3b)
 *
 * Full CRUD UI for anchored notes on any chapter. Mounted via
 * margin-panels.js so it inherits the same tabbed tool-column layout
 * as every other right-side tool. Cards are tight stacks of anchor
 * quote + body + actions, sorted by anchor position.
 *
 * Colors derive from existing theme variables — no hardcoded hex.
 * ============================================================================ */

.speaker-notes-margin {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  padding: 0.2rem 0.4rem 1rem;
}

.speaker-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.6rem;
}

.speaker-notes-title {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

.speaker-notes-add {
  background: transparent;
  color: var(--accent);
  border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent);
  border-radius: 999px;
  padding: 0.2rem 0.7rem;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease;
}

.speaker-notes-add:hover {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-color: var(--accent);
}

.speaker-notes-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  padding: 1rem 0.4rem;
  line-height: 1.5;
}

.speaker-notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.speaker-note-card {
  background: var(--bg-elevated, var(--bg-surface));
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.75rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  cursor: pointer;
  transition: border-color 150ms ease, background 150ms ease;
}

.speaker-note-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

.speaker-note-card.is-reply {
  margin-left: 1.1rem;
  border-left: 2px solid color-mix(in srgb, var(--accent) 30%, transparent);
}

.speaker-note-card.is-resolved {
  opacity: 0.55;
  filter: saturate(0.7);
}

.speaker-note-card.is-flashing {
  animation: speaker-note-flash 900ms ease;
}

@keyframes speaker-note-flash {
  0%, 100% { background: var(--bg-elevated, var(--bg-surface)); }
  30% {
    background: color-mix(in srgb, var(--accent) 20%, var(--bg-elevated, var(--bg-surface)));
  }
}

.speaker-note-anchor {
  font-size: 0.72rem;
  color: var(--text-muted);
  font-style: italic;
  border-left: 2px solid color-mix(in srgb, var(--accent) 40%, transparent);
  padding-left: 0.5rem;
  line-height: 1.4;
}

.speaker-note-body {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}

.speaker-note-meta {
  font-size: 0.66rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

.speaker-note-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.1rem;
}

.speaker-note-btn {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  border-radius: 3px;
  padding: 0.15rem 0.5rem;
  font-size: 0.68rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.speaker-note-btn:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.speaker-note-btn--danger:hover {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 55%, transparent);
  background: color-mix(in srgb, var(--error) 8%, transparent);
}

/* ============================================================================
 * LanguageTool speech-craft decorations (Tier 3b)
 *
 * When the chapter is in speech mode, LT matches that hint at craft
 * problems — filler words, passive voice, repetition, long sentences —
 * get a distinct underline from grammar/spelling errors. Writers can
 * tell "craft warning" from "error" at a glance.
 *
 * Colors derive from the existing --craft-* theme variables which
 * themes.css already tints against --accent / --error / --text-secondary
 * via color-mix. No new hex values.
 * ============================================================================ */

.ProseMirror .lt-craft {
  background: none;
  text-decoration: none;
  padding-bottom: 1px;
}

.ProseMirror .lt-craft-filler {
  border-bottom: 2px dashed var(--craft-filler);
  background: color-mix(in srgb, var(--craft-filler) 5%, transparent);
}

.ProseMirror .lt-craft-passive {
  border-bottom: 2px dotted var(--craft-passive);
  background: color-mix(in srgb, var(--craft-passive) 5%, transparent);
}

.ProseMirror .lt-craft-breath {
  border-bottom: 2px solid var(--craft-breath);
  background: color-mix(in srgb, var(--craft-breath) 6%, transparent);
  text-decoration: underline wavy var(--craft-breath);
  text-decoration-skip-ink: auto;
}

.ProseMirror .lt-craft-repetition {
  border-bottom: 2px dashed var(--craft-repetition);
  background: color-mix(in srgb, var(--craft-repetition) 6%, transparent);
}

/* ============================================================================
 * Speech-panel action row (Tier 3c)
 *
 * Read Aloud / Teleprompter / Revisions buttons sit below the metric
 * grid, above the rhetoric chips. The row uses the same surface tones
 * as the existing speaker-note card so it reads as part of the panel.
 * ============================================================================ */

.speech-stats-panel .speech-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  padding: 0.75rem 1rem 0.25rem;
}

.speech-stats-panel .speech-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.6rem;
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid color-mix(in srgb, var(--border) 85%, transparent);
  border-radius: 3px;
  font-size: 0.72rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
  font-family: inherit;
}

.speech-stats-panel .speech-action-btn:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 55%, transparent);
  background: color-mix(in srgb, var(--accent) 6%, transparent);
}

.speech-stats-panel .speech-action-btn.active {
  color: var(--accent);
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}

.speech-stats-panel .speech-action-btn .speech-action-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  background: currentColor;
  mask-repeat: no-repeat;
  mask-size: contain;
  mask-position: center;
  -webkit-mask-repeat: no-repeat;
  -webkit-mask-size: contain;
  -webkit-mask-position: center;
}

.speech-stats-panel .speech-action-btn[data-action="read-aloud"] .speech-action-icon {
  mask-image: url('/icons/speech/read-aloud.png');
  -webkit-mask-image: url('/icons/speech/read-aloud.png');
}

.speech-stats-panel .speech-action-btn[data-action="teleprompter"] .speech-action-icon {
  mask-image: url('/icons/speech/teleprompter.png');
  -webkit-mask-image: url('/icons/speech/teleprompter.png');
}

.speech-stats-panel .speech-action-btn[data-action="revisions"] .speech-action-icon {
  mask-image: url('/icons/speech/revision-history.png');
  -webkit-mask-image: url('/icons/speech/revision-history.png');
}

.speech-stats-panel .speech-action-btn[data-action="revisions"].expanded .speech-action-icon {
  mask-image: url('/icons/speech/revision-history-filled.png');
  -webkit-mask-image: url('/icons/speech/revision-history-filled.png');
}

/* ============================================================================
 * Revision history timeline (Tier 3c)
 * ============================================================================ */

.speech-stats-panel .revision-history {
  padding: 0 1rem 1rem;
}

.revision-history-header {
  display: flex;
  align-items: center;
}

.revision-history-toggle {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  padding: 0.4rem 0;
  background: transparent;
  border: none;
  border-top: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

.revision-history-toggle:hover {
  color: var(--accent);
}

.revision-history-chevron {
  flex: 0 0 auto;
  display: inline-block;
  width: 8px;
  height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  margin-left: auto;
  transition: transform 180ms ease;
}

.revision-history-toggle.expanded .revision-history-chevron {
  transform: rotate(45deg);
}

.revision-history-label {
  flex: 0 0 auto;
}

.revision-history-list {
  margin-top: 0.5rem;
}

.revision-history-list[hidden] {
  display: none;
}

.revision-history-status {
  padding: 0.35rem 0;
  font-size: 0.74rem;
  color: var(--text-muted);
  font-style: italic;
}

.revision-history-status.error {
  color: var(--error);
  font-style: normal;
}

.revision-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.revision-item {
  padding: 0;
  margin: 0;
}

.revision-open-btn {
  display: flex;
  width: 100%;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.6rem;
  padding: 0.4rem 0.55rem;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 3px;
  color: var(--text-secondary);
  font-size: 0.74rem;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.revision-open-btn:hover {
  color: var(--text-primary);
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.revision-when {
  font-weight: 500;
}

.revision-wc {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* ============================================================================
 * Revision diff modal
 * ============================================================================ */

.revision-diff-overlay {
  position: fixed;
  inset: 0;
  z-index: 9998;
  background: color-mix(in srgb, var(--bg-primary) 82%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4vh 4vw;
}

.revision-diff-modal {
  background: var(--bg-surface, var(--bg-secondary));
  border: 1px solid var(--border);
  border-radius: var(--radius-md, 6px);
  box-shadow: 0 12px 48px var(--shadow);
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 880px;
  max-height: 86vh;
  color: var(--text-primary);
}

.revision-diff-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.revision-diff-header h3 {
  margin: 0;
  font-size: 1rem;
  font-weight: 500;
  font-family: var(--font-serif, inherit);
  color: var(--text-primary);
}

.revision-diff-close {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: 0.25rem 0.65rem;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.74rem;
  font-family: inherit;
}

.revision-diff-close:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.revision-diff-body {
  flex: 1;
  overflow: auto;
  padding: 1rem 1.25rem;
}

.revision-diff-status {
  color: var(--text-muted);
  font-style: italic;
  font-size: 0.88rem;
}

.revision-diff-status.error {
  color: var(--error);
  font-style: normal;
}

.revision-diff-text {
  font-family: var(--font-serif, Georgia, serif);
  font-size: 1rem;
  line-height: 1.6;
  white-space: pre-wrap;
  color: var(--text-primary);
}

.revision-diff-equal {
  color: var(--text-secondary);
}

.revision-diff-insert {
  color: var(--success);
  background: color-mix(in srgb, var(--success) 14%, transparent);
  padding: 0 2px;
  border-radius: 2px;
}

.revision-diff-delete {
  color: var(--error);
  background: color-mix(in srgb, var(--error) 14%, transparent);
  text-decoration: line-through;
  padding: 0 2px;
  border-radius: 2px;
}

.revision-diff-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  padding: 0.85rem 1.25rem;
  border-top: 1px solid var(--border);
}

/* Sentence highlight on waveform bar hover — applied via ProseMirror decoration */
.speech-sentence-highlight {
  background: rgba(201, 168, 76, 0.2);
  border-radius: 3px;
  outline: 1px solid rgba(201, 168, 76, 0.4);
}

/* Flash animation on waveform bar click */
.speech-sentence-flash {
  animation: sentence-flash 1.2s ease;
}
@keyframes sentence-flash {
  0% { background: rgba(201, 168, 76, 0.45); outline-color: rgba(201, 168, 76, 0.8); }
  100% { background: rgba(201, 168, 76, 0.2); outline-color: rgba(201, 168, 76, 0.4); }
}

/* Hover state on waveform bars */
.speech-stats-panel .wave-bar:hover {
  background: var(--accent);
  opacity: 0.9;
}
