.transcript-viewer {
  --tv-border: #d7dce2;
  --tv-header-background: #263746;
  --tv-header-text: #ffffff;
  --tv-row-hover: #f2f7fb;
  --tv-active-row: #fff3c4;
  --tv-focus: #1565c0;
  --tv-error: #a61b1b;

  max-width: 1100px;
  margin: 2rem auto;
  color: #20252a;
  font-family: Arial, Helvetica, sans-serif;
  line-height: 1.5;
}

.transcript-viewer *,
.transcript-viewer *::before,
.transcript-viewer *::after {
  box-sizing: border-box;
}

.transcript-viewer h1 {
  margin: 0 0 1rem;
  font-size: clamp(1.6rem, 4vw, 2.25rem);
  line-height: 1.2;
}

.transcript-viewer .tv-controls {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) repeat(2, minmax(150px, 1fr));
  gap: 1rem;
  align-items: end;
  margin-bottom: 1rem;
  padding: 1rem;
  border: 1px solid var(--tv-border);
  border-radius: 0.4rem;
  background: #f8f9fa;
}

.transcript-viewer .tv-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  margin: 0;
  font-weight: 700;
}

.transcript-viewer input[type="text"],
.transcript-viewer input[type="time"] {
  width: 100%;
  min-height: 2.65rem;
  padding: 0.55rem 0.7rem;
  border: 1px solid #8b949e;
  border-radius: 0.25rem;
  background: #ffffff;
  color: inherit;
  font: inherit;
}

.transcript-viewer input:focus {
  border-color: var(--tv-focus);
  outline: 3px solid color-mix(in srgb, var(--tv-focus) 25%, transparent);
  outline-offset: 1px;
}

.transcript-viewer input:disabled {
  cursor: not-allowed;
  opacity: 0.65;
  background: #eceff1;
}

.transcript-viewer audio {
  display: block;
  width: 100%;
  margin: 0 0 0.75rem;
}

.transcript-viewer #transport-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin: 0 0 1rem;
}

.transcript-viewer #transport-controls button {
  min-height: 2.5rem;
  padding: 0.45rem 0.9rem;
  border: 1px solid #68737d;
  border-radius: 0.3rem;
  background: #ffffff;
  color: #1d252c;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.transcript-viewer #transport-controls button:hover:not(:disabled) {
  background: #eef3f7;
}

.transcript-viewer #transport-controls button:focus-visible {
  outline: 3px solid var(--tv-focus);
  outline-offset: 2px;
}

.transcript-viewer #transport-controls button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.transcript-viewer .tv-table {
  width: 100%;
  margin: 0;
  border-spacing: 0;
  border-collapse: collapse;
  table-layout: fixed;
  border: 1px solid var(--tv-border);
}

.transcript-viewer .tv-table th,
.transcript-viewer .tv-table td {
  padding: 0.75rem;
  border: 1px solid var(--tv-border);
  text-align: left;
  vertical-align: top;
}

.transcript-viewer .tv-table th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--tv-header-background);
  color: var(--tv-header-text);
  font-weight: 700;
}

.transcript-viewer .tv-table th:nth-child(1),
.transcript-viewer .tv-table th:nth-child(2),
.transcript-viewer .tv-table td:nth-child(1),
.transcript-viewer .tv-table td:nth-child(2) {
  width: 8.5rem;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.transcript-viewer .tv-table tbody tr {
  transition:
    background-color 120ms ease,
    box-shadow 120ms ease;
}

.transcript-viewer .tv-table tbody tr:nth-child(even) {
  background: #fafbfc;
}

.transcript-viewer .tv-table tbody tr:hover {
  background: var(--tv-row-hover);
}

.transcript-viewer .tv-table tbody tr:focus-visible {
  position: relative;
  outline: 3px solid var(--tv-focus);
  outline-offset: -3px;
}

.transcript-viewer .tv-table tbody tr.is-active,
.transcript-viewer .tv-table tbody tr.is-active:hover {
  background: var(--tv-active-row);
  box-shadow: inset 5px 0 0 #d09a00;
}

.transcript-viewer mark {
  padding: 0 0.08em;
  border-radius: 0.1em;
  background: #ffe66d;
  color: inherit;
}

.transcript-viewer #no-results {
  margin-top: 1rem;
  padding: 1rem;
  border: 1px solid var(--tv-border);
  border-radius: 0.3rem;
  background: #f8f9fa;
  text-align: center;
  font-weight: 700;
}

.transcript-viewer #no-results.is-error {
  border-color: var(--tv-error);
  background: #fff2f2;
  color: var(--tv-error);
}

@media (max-width: 760px) {
  .transcript-viewer .tv-controls {
    grid-template-columns: 1fr;
  }

  .transcript-viewer .tv-table {
    table-layout: auto;
  }

  .transcript-viewer .tv-table th:nth-child(1),
  .transcript-viewer .tv-table th:nth-child(2),
  .transcript-viewer .tv-table td:nth-child(1),
  .transcript-viewer .tv-table td:nth-child(2) {
    width: auto;
  }
}

@media (max-width: 540px) {
  .transcript-viewer .tv-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .transcript-viewer .tv-table,
  .transcript-viewer .tv-table tbody,
  .transcript-viewer .tv-table tr,
  .transcript-viewer .tv-table td {
    display: block;
    width: 100%;
  }

  .transcript-viewer .tv-table tr {
    margin-bottom: 0.75rem;
    border: 1px solid var(--tv-border);
  }

  .transcript-viewer .tv-table td {
    border: 0;
    border-bottom: 1px solid var(--tv-border);
  }

  .transcript-viewer .tv-table td:last-child {
    border-bottom: 0;
  }

  .transcript-viewer .tv-table td:nth-child(1)::before {
    content: "Start: ";
    font-weight: 700;
  }

  .transcript-viewer .tv-table td:nth-child(2)::before {
    content: "End: ";
    font-weight: 700;
  }
}

@media (prefers-reduced-motion: reduce) {
  .transcript-viewer .tv-table tbody tr {
    transition: none;
  }
}
