/* TTS Composer — the script editor and the segments list side by side as two
   cards, then the timeline card and the export tray (layout from
   styles/components/form.css); the Options sheet is a dense form. The script
   field is styles/components/editor.css; only the tinted segment entries and
   the timeline strip are the page's own. */

textarea.tts-script {
  min-height: 300px;
}

.tts-stats {
  align-self: center;
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

/* The segment count is a styles/components/tag.css pill beside the title. */
.tts-count { margin-left: 4px; }

/* Load sample / Parse stay together at the end of the tray. */
.tts-tray {
  display: inline-flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Segment list: one tinted entry per segment inside the card. */
ul.tts-segment-list {
  list-style: none;
  margin: 0;
  padding: var(--space-2);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.tts-segment-item {
  /* Single gutter: text + settings align under the speaker name, i.e.
     top-row left padding (10px) + number column (16px) + gap (8px). */
  --tts-seg-gutter: 34px;
  border: 1px solid color-mix(in srgb, var(--seg-color, var(--border)) 30%, var(--border));
  border-radius: var(--radius-md);
  overflow: hidden;
  background: var(--seg-bg, var(--bg-fill-2));
  transition: box-shadow var(--duration-snap) var(--ease-standard);
}

.tts-segment-item.is-speaking {
  box-shadow: 0 0 0 2px var(--seg-color, var(--accent));
}

.tts-seg-top {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 7px 10px 5px;
}

.tts-seg-num {
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  width: 16px;
  text-align: right;
  flex-shrink: 0;
}

.tts-seg-speaker {
  flex: 1;
  font-size: 12px;
  font-weight: 600;
  color: var(--seg-color, var(--accent));
  letter-spacing: -0.005em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tts-seg-actions {
  display: flex;
  gap: var(--space-1);
  flex-shrink: 0;
}

.tts-seg-text {
  padding: 0 10px 8px var(--tts-seg-gutter);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text);
  margin: 0;
  letter-spacing: -0.008em;
  outline: none;
  border-radius: 4px;
}

.tts-seg-text:focus { background: var(--bg-hover); }

.tts-seg-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  column-gap: var(--space-4);
  row-gap: var(--space-2);
  padding: 8px 10px 8px var(--tts-seg-gutter);
  border-top: 1px solid color-mix(in srgb, var(--seg-color, var(--border)) 15%, transparent);
}

/* Voice picker spans the full settings width on its own row. */
.tts-seg-label--voice {
  grid-column: 1 / -1;
}

.tts-seg-label {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 500;
}

/* Rate/Pitch labels share a fixed-width caption so the two sliders line up. */
.tts-seg-label--slider > .tts-seg-name {
  min-width: 32px;
  flex-shrink: 0;
}

/* dropdown.js replaces the native select with an Apple-style menu; let its
   trigger fill the voice row so long voice names truncate cleanly. */
.tts-seg-label--voice .dropdown { flex: 1; min-width: 0; }

.tts-seg-rate, .tts-seg-pitch {
  flex: 1;
  min-width: 0;
}

.tts-seg-val {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 30px;
  text-align: right;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}

/* Timeline strip */
.tts-timeline {
  display: flex;
  height: 44px;
  overflow: hidden;
}

.tts-timeline-seg {
  display: flex;
  align-items: center;
  padding: 0 6px;
  min-width: 0;
  overflow: hidden;
  cursor: default;
  transition: filter var(--duration-snap) var(--ease-standard);
}

.tts-timeline-seg:hover { filter: brightness(0.92); }

.tts-timeline-label {
  font-size: 10px;
  font-weight: 600;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}

/* API key field + Save / Clear (Options sheet) */
.tts-key-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}
.tts-key-input-row input { flex: 1; min-width: 0; }
.tts-key-input-row .btn { flex-shrink: 0; }

/* Phones: keep the two-stage workflow close together — trim the editor so
   the segments and the export tray sit nearer the fold. */
@media (max-width: 720px) {
  textarea.tts-script { min-height: 200px; }
}

/* Phones: the two download buttons don't fit one line in every locale. Let
   each wrapped line fill the tray so a wrap reads as a deliberate stack
   (primary last, full width) rather than a ragged half-empty row. */
@media (max-width: 480px) {
  .tts-download-row > .btn { flex: 1 1 auto; }
}
