* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background: #0e1014;
  color: #e8eaed;
  -webkit-font-smoothing: antialiased;
}

.page {
  max-width: 1320px;
  margin: 0 auto;
  padding: 28px 22px 64px;
}

.viewer-page {
  height: calc(100vh - 40px);
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

.header {
  padding-bottom: 18px;
  border-bottom: 1px solid #23262e;
}

.header h1 {
  margin: 0 0 6px;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
}

.header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.user-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.user-bar #userName {
  font-size: 14px;
}

.header p {
  margin: 6px 0 0;
  color: #8a92a0;
  font-size: 0.92rem;
}

.panel {
  margin-top: 20px;
  background: #16181e;
  padding: 18px;
  border: 1px solid #23262e;
  border-radius: 8px;
}

.panel h2 {
  margin: 0 0 4px;
  font-size: 1.02rem;
  font-weight: 600;
  color: #cfd4dc;
  letter-spacing: 0.01em;
}

.row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 12px 0;
  flex-wrap: wrap;
}

.input {
  flex: 1;
  padding: 9px 11px;
  border-radius: 6px;
  border: 1px solid #2c313c;
  background: #0f1116;
  color: #e8eaed;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.input::placeholder {
  color: #5f6673;
}

.input.compact {
  padding: 6px 8px;
  border-radius: 5px;
}

/* Inputs inside table cells must stay within their fixed column width. */
.file-table td .input {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  flex: none;
}

.input:focus {
  outline: none;
  border-color: #3d6fff;
  box-shadow: 0 0 0 2px rgba(61, 111, 255, 0.25);
}

.button {
  padding: 9px 14px;
  border-radius: 6px;
  border: 1px solid #2f3542;
  background: #21252e;
  color: #e8eaed;
  cursor: pointer;
  font-weight: 500;
  box-sizing: border-box;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.button:hover {
  background: #2a2f3a;
  border-color: #3a4152;
}

.button.primary {
  background: #3d6fff;
  border-color: #3d6fff;
  color: #fff;
}

.button.primary:hover {
  background: #4f7dff;
  border-color: #4f7dff;
}

.button.secondary {
  background: #2f4b7a;
  border-color: #2f4b7a;
}

.button.small {
  padding: 6px 10px;
  font-size: 0.9rem;
}

.button.small.danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
  border-color: rgba(239, 68, 68, 0.3);
}

.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.progress-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.supercut-job-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.progress-bar {
  height: 6px;
  background: #2a2f3a;
  border-radius: 4px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: #3d6fff;
  width: 0;
}

.table-wrap {
  border: 1px solid #23262e;
  border-radius: 8px;
  overflow: hidden;
}

.file-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.file-table th,
.file-table td {
  padding: 10px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid #20242c;
  overflow-wrap: anywhere;
}

.file-table thead th {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #8a92a0;
  background: #1b1e25;
}

.file-table tbody tr {
  background: #14161c;
  transition: background 0.12s ease;
}

.file-table tbody tr:hover {
  background: #1a1d25;
}

.file-table tbody tr:last-child td {
  border-bottom: none;
}

.empty-row {
  text-align: center;
  padding: 20px;
}

/* Fixed column widths keep the header cells and body cells perfectly aligned. */
.col-title { width: 30%; }
.col-type { width: 9%; }
.col-date { width: 9%; }
.col-length { width: 7%; }
.col-category { width: 12%; }
.col-status { width: 15%; }
.col-actions { width: 18%; }

/* Headers and short numeric/date cells should never wrap. */
.file-table thead th {
  white-space: nowrap;
}
.date-cell,
.length-cell {
  white-space: nowrap;
}

.sort-button {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  padding: 0;
  cursor: pointer;
  display: inline-flex;
  gap: 6px;
  align-items: center;
  width: 100%;
}

.sort-indicator {
  color: #8e97a6;
  font-size: 0.8rem;
}

.actions-inner {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}

.action-primary,
.action-utility {
  display: flex;
  gap: 5px;
}

/* Give the action buttons a little more room than the default cell padding. */
.actions-cell {
  padding-left: 10px !important;
  padding-right: 10px !important;
}

.action-primary .button,
.action-utility .button {
  flex: 1 1 0;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
}

.action-utility .button {
  padding: 5px 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
}

.action-utility .button span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.btn-icon {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
}

/* The single top action always fills its row so it matches the 3 below. */
.action-block {
  width: 100%;
}

/* Download buttons are de-emphasized: smaller, muted text/icon. */
.download-btn {
  font-size: 0.66rem;
  color: #98a0af;
}
.download-btn .btn-icon {
  width: 10px;
  height: 10px;
  opacity: 0.85;
}
.download-btn.shared {
  color: #57c98a;
  border-color: rgba(87, 201, 138, 0.5);
}
.button.small.shared {
  color: #57c98a;
  border-color: rgba(87, 201, 138, 0.5);
}

/* Delete is an icon-only button so Video/Transcript get the remaining width. */
.action-utility .button.delete-icon {
  flex: 0 0 auto;
  width: 28px;
  padding: 5px;
}
.delete-icon .btn-icon {
  width: 13px;
  height: 13px;
}

.title-inner {
  display: flex;
  gap: 8px;
  align-items: center;
}

.file-thumb {
  width: 56px;
  height: 32px;
  border-radius: 4px;
  border: 1px solid #2c313c;
  object-fit: cover;
  background: #0b0d12;
  flex: 0 0 auto;
}

.title-text {
  font-weight: 600;
  white-space: normal;
  overflow-wrap: anywhere;
  flex: 1;
}

.type-inner {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 5px;
}

.file-type-badge {
  display: inline-block;
  padding: 3px 8px;
  border-radius: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(61, 111, 255, 0.15);
  color: #7ba4ff;
  border: 1px solid rgba(61, 111, 255, 0.25);
  white-space: nowrap;
}

.chunk-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 4px;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.chunk-badge.ready {
  background: rgba(34, 197, 94, 0.14);
  color: #6ee7a0;
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.chunk-badge.pending {
  background: rgba(148, 163, 184, 0.12);
  color: #94a3b8;
  border: 1px solid rgba(148, 163, 184, 0.22);
}

.button.tiny {
  padding: 4px 8px;
  font-size: 0.8rem;
}

.button.tiny.danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 14, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-card {
  width: min(520px, 100%);
  background: #16181e;
  border: 1px solid #2c313c;
  border-radius: 8px;
  padding: 18px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, 0.45);
}

.modal-card h3 {
  margin: 0 0 8px;
}

.modal-label {
  display: block;
  margin: 10px 0 8px;
  color: #dbe1ea;
}

.rename-input-wrap {
  display: flex;
  align-items: stretch;
  gap: 8px;
}

.rename-input-wrap .input {
  min-width: 0;
}

.rename-ext {
  display: inline-flex;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid #2c313c;
  border-radius: 10px;
  background: #111318;
  color: #b8bfc9;
  white-space: nowrap;
}

.modal-actions {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-actions .button.tiny {
  padding: 8px 12px;
  font-size: 0.9rem;
}

.viewer-shell {
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100%;
}

.viewer-top {
  display: grid;
  grid-template-columns: 1fr 2fr 1fr;
  gap: 18px;
  align-items: stretch;
  flex: 1;
  min-height: 0;
}

.info-panel {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #111318;
  border-radius: 12px;
  padding: 12px;
  height: 100%;
}

.info-panel h1 {
  margin: 2px 0 4px;
  font-size: 1.2rem;
  line-height: 1.2;
}

.video-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
}

.viewer-meta {
  font-size: 0.9rem;
  color: #8e97a6;
  margin-bottom: 4px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid #2c313c;
  color: #dbe1ea;
  text-decoration: none;
  background: #111318;
}

.back-link:hover {
  background: #1a1f2a;
}

.back-link:visited {
  color: #dbe1ea;
}

.viewer-bottom {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 2;
}

.video {
  width: 100%;
  border-radius: 12px;
  background: #000;
  flex: 1;
  min-height: 0;
  height: auto;
  object-fit: contain;
}

.search-box {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.search-meta {
  display: flex;
  gap: 10px;
  align-items: center;
  color: #b8bfc9;
  flex-wrap: wrap;
}

.search-meta #searchCount {
  padding-left: 6px;
}

.search-actions {
  display: flex;
  gap: 6px;
  align-items: center;
}

.button.icon {
  width: 32px;
  height: 32px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.button.icon:hover {
  background: #3a4152;
  transform: translateY(-1px);
}

.button.icon.danger {
  background: rgba(239, 68, 68, 0.2);
  color: #f87171;
}

.button.icon.danger:hover {
  background: rgba(239, 68, 68, 0.35);
}

.search-toggle {
  display: flex;
  gap: 6px;
  align-items: center;
  font-size: 0.9rem;
  color: #b8bfc9;
}

.speaker-panel {
  display: flex;
  flex-direction: column;
  background: #111318;
  border-radius: 12px;
  padding: 12px;
  height: 100%;
  overflow: hidden;
}

.speaker-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.speaker-panel h3 {
  margin: 0;
}

.speaker-filters {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 12px 0;
  flex: 1;
  overflow-y: auto;
  padding-right: 6px;
}

.speaker-controls {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.speaker-item {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 8px;
  align-items: center;
  padding: 6px 10px;
  background: #151922;
  border-radius: 10px;
  font-size: 0.9rem;
  border: 1px solid transparent;
}

.transcript-list {
  padding-top: 12px;
  padding-bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 100%;
  overflow-y: auto;
  padding-right: 6px;
}

.sticky-search {
  position: sticky;
  top: 0;
  background: #181b22;
  padding-bottom: 10px;
  z-index: 2;
}

.segment {
  display: grid;
  grid-template-columns: 70px 110px 1fr;
  gap: 10px;
  padding: 10px 12px;
  background: #111318;
  border-radius: 10px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.2s ease, transform 0.2s ease, border-color 0.2s ease;
  position: relative;
}

.segment::before {
  content: "";
  position: absolute;
  inset: 0;
  background: var(--speaker-color, #6f7a8a);
  opacity: 0.08;
  pointer-events: none;
}

.segment:hover {
  background: #1a1f2a;
  transform: translateY(-1px);
}

.segment.match {
  border-color: #3d6fff;
}

.segment.active {
  background: #24305b;
}

.segment.playing {
  border-color: #6fd3ff;
  box-shadow: 0 0 0 1px rgba(111, 211, 255, 0.3);
}

.speaker-dot {
  display: inline-flex;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  margin-right: 6px;
  background: var(--speaker-color, #6f7a8a);
}

.speaker-item.active {
  border-color: #c9ced6;
}

.term-hit {
  background: rgba(111, 211, 255, 0.35);
  color: #f5f6f8;
  padding: 0 2px;
  border-radius: 4px;
}

.segment .time {
  color: #8fa3c7;
  font-size: 0.85rem;
}

.segment .speaker {
  color: #d4d7dd;
  font-size: 0.9rem;
}

.segment .text {
  color: #f5f6f8;
}

.hidden {
  display: none;
}

.muted {
  color: #8e97a6;
}

.warning-text {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(239, 68, 68, 0.5);
  background: rgba(239, 68, 68, 0.12);
  color: #ffb4b4;
  border-radius: 10px;
  font-size: 0.92rem;
}

.info-text-green {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(34, 197, 94, 0.5);
  background: rgba(34, 197, 94, 0.12);
  color: #86efac;
  border-radius: 10px;
  font-size: 0.92rem;
}

.info-text-amber {
  margin-top: 10px;
  padding: 10px 12px;
  border: 1px solid rgba(234, 179, 8, 0.45);
  background: rgba(234, 179, 8, 0.1);
  color: #fde68a;
  border-radius: 10px;
  font-size: 0.92rem;
}

.supercut-modal-card {
  width: min(700px, 100%);
}

.supercut-speakers-list {
  max-height: 190px;
  overflow-y: auto;
  border: 1px solid #2c313c;
  border-radius: 10px;
  background: #111318;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.supercut-speaker-item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 8px;
  align-items: center;
  font-size: 0.9rem;
  color: #dbe1ea;
  padding: 8px 10px;
  border: 1px solid #2c313c;
  border-radius: 10px;
  background: #151922;
  cursor: pointer;
}

.supercut-speaker-item.active {
  border-color: #4e7bff;
  background: rgba(61, 111, 255, 0.16);
}

.supercut-speaker-item input {
  transform: translateY(1px);
}

.supercut-match-note {
  margin: -2px 0 4px;
  font-size: 0.82rem;
}

.supercut-words-chips {
  margin-top: 8px;
  min-height: 34px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.supercut-word-chip {
  border: 1px solid #3d6fff;
  background: rgba(61, 111, 255, 0.18);
  color: #dce6ff;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 0.85rem;
  cursor: pointer;
}

.supercut-word-chip:hover {
  background: rgba(61, 111, 255, 0.28);
}

.supercut-buffer-group {
  display: flex;
  flex-direction: column;
  min-width: 130px;
}

.supercut-counter-toggle {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
  color: #dbe1ea;
}

.supercut-count-summary {
  margin-top: 8px;
}

.supercuts-panel {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid #2c313c;
}

.supercuts-panel h3,
.supercuts-panel h4 {
  margin: 8px 0;
}

.supercuts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 14px;
  max-height: 200px;
  overflow-y: auto;
  padding-right: 4px;
}

.supercuts-list-item {
  background: #151922;
  border: 1px solid #2c313c;
  border-radius: 10px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.supercuts-item-title {
  font-size: 0.85rem;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.supercuts-preview {
  margin: 8px 0 10px;
  width: 100%;
  max-height: 240px;
  border-radius: 10px;
}

.status-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 3px;
}

.status-title {
  font-size: 0.86rem;
  font-weight: 600;
  line-height: 1.2;
}

.status-title.done {
  color: #c7f0d5;
}

.status-title.error {
  color: #fca5a5;
}

.status-sub {
  font-size: 0.76rem;
  color: #9ea8b8;
  line-height: 1.15;
}

.status-sub.error-detail {
  color: #fca5a5;
  cursor: help;
  word-break: break-word;
}

.status-delete-link {
  color: #d98989;
  font-size: 0.66rem;
  font-weight: 500;
  line-height: 1;
  padding: 0;
  cursor: pointer;
  user-select: none;
  letter-spacing: 0.01em;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 1px;
  opacity: 0.92;
}

.status-delete-link:hover {
  color: #e8a1a1;
  opacity: 1;
}

.status-delete-link:focus-visible {
  outline: none;
  text-decoration: underline;
  text-decoration-thickness: 1px;
}

/* Sleeker scrollbars */
* {
  scrollbar-width: thin;
  scrollbar-color: #2b3240 #0f1115;
}

*::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

*::-webkit-scrollbar-track {
  background: #0f1115;
}

*::-webkit-scrollbar-thumb {
  background-color: #2b3240;
  border-radius: 999px;
  border: 2px solid #0f1115;
}

@media (max-width: 900px) {
  .viewer-top {
    grid-template-columns: 1fr;
  }
  .viewer-shell {
    flex-direction: column;
  }
  .video-panel {
    height: auto;
  }
  .video {
    max-height: 30vh;
  }
  .table-wrap {
    overflow-x: auto;
  }
  .file-table {
    min-width: 820px;
  }
  .supercut-speakers-list {
    grid-template-columns: 1fr;
  }
}
