@import './tokens.css';

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
}

body {
  background-color: var(--color-bg);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  /* Pin the app to exactly the viewport height and let the body flex the
     header + app-body, so no whole-page vertical scroll can appear. */
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header ──────────────────────────────────────────── */

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) var(--space-8);
  border-bottom: 1px solid var(--color-border-subtle);
  background: var(--color-bg);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-header-left {
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.app-logo {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.02em;
  text-decoration: none;
}

.app-logo-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 4px;
  /* box-shadow: 0 0 10px 0 var(--color-accent); */
  background: var(--color-accent);
  color: #14101E;
  font-weight: 800;
  font-size: var(--text-base);
}

/* When the logo mark is the image asset, show it as-is (no accent bg). */
img.app-logo-mark {
  background: none;
  object-fit: contain;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.app-nav-link {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 500;
  text-decoration: none;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.app-nav-link:hover {
  background: var(--color-accent-dim);
  color: var(--color-accent);
}

.app-header-actions {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ── One-line status (navbar center) ─────────────────── */

.status-line {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  max-width: 40vw;
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-full);
  background: var(--color-card);
  border: 1px solid var(--color-border-subtle);
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  opacity: 0;
  transition: opacity var(--transition-base);
  pointer-events: none;
}

.status-line.has-text { opacity: 1; }

.status-line-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-text-disabled);
  flex-shrink: 0;
}

.status-line-text {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.status-line.active .status-line-dot {
  background: var(--color-accent);
  animation: status-pulse 1.2s ease-in-out infinite;
}
.status-line.active { color: var(--color-text-primary); border-color: var(--color-border); }

.status-line.done .status-line-dot { background: var(--color-success); }
.status-line.done { color: var(--color-success); }

.status-line.error .status-line-dot { background: var(--color-error); }
.status-line.error { color: var(--color-error); border-color: rgba(255, 123, 123, 0.3); }

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* Mobile status line: lives above the preview, in normal flow (not the
   absolutely-centered navbar variant). Hidden on desktop. */
.status-line-mobile {
  display: none;
  position: static;
  transform: none;
  max-width: 100%;
  width: 100%;
  justify-content: center;
  pointer-events: none;
}

@media (max-width: 768px) {
  .app-nav { display: none; }
  .status-line { display: none; }

  /* Show the mobile status line only when it carries text. */
  .status-line-mobile.has-text {
    display: inline-flex;
  }
}

/* ── Three-column app body: rail | options | preview ─── */

.app-body {
  display: flex;
  gap: var(--space-5);
  padding: var(--space-5);
  align-items: flex-start;
  flex: 1;          /* fill the space under the header, whatever its height */
  min-height: 0;    /* allow inner panels to size/scroll within this box */
  overflow: hidden;
}

/* ── Icon rail ───────────────────────────────────────── */

.sidebar-rail {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 72px;
  height: 100%;
  padding: var(--space-2);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
}

.rail-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: var(--space-3) var(--space-1);
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--color-text-secondary);
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.rail-btn:hover {
  background: var(--color-card);
  color: var(--color-text-primary);
}

.rail-btn.active {
  background: var(--color-accent-dim);
  color: var(--color-accent);
}

/* ── Options panel ───────────────────────────────────── */

.options-panel {
  flex: 0 0 340px;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  overflow-y: auto;
  overflow-x: hidden; /* tabs scroll vertically only — never sideways */
  height: 100%;
  padding: var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.options-panel::-webkit-scrollbar { width: 4px; }
.options-panel::-webkit-scrollbar-track { background: transparent; }
.options-panel::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}

/* Tab sections — only the active one is shown */
.tab-section { display: none; }
.tab-section.active {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.tab-section-title {
  font-size: var(--text-base);
  font-weight: 700;
  color: var(--color-text-primary);
  letter-spacing: -0.01em;
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--color-border-subtle);
}

.tab-section-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

/* ── Preview Panel ───────────────────────────────────── */

.right-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: center;
  justify-content: flex-start;
  height: 100%;
  overflow: hidden; /* preview panel never scrolls — video scales to fit */
}

/* Mobile-only download button under the preview controls; hidden on desktop
   (the navbar Download is used there). Shown via the 768px media query.
   Uses `.btn.download-btn-mobile` so it out-specifies `.btn { display:inline-flex }`
   in buttons.css (which loads after app.css). */
.btn.download-btn-mobile {
  display: none;
}

/* ── Preview ─────────────────────────────────────────── */

/* Preview fills the panel above the player bar; the video is centered and
   scaled to fit the available space so nothing overflows/scrolls. */
.preview-wrapper {
  flex: 1;
  min-height: 0;
  width: 100%;
  max-width: 720px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.video-container {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  box-shadow: var(--shadow-card);
  /* Fit within the wrapper on both axes; aspect-ratio decides the shape and
     max-width/height keep it inside the panel (no scroll). Default derives the
     ratio from the real video via the --preview-ar variable set in JS. */
  aspect-ratio: var(--preview-ar, 16 / 9);
  max-width: 100%;
  max-height: 100%;
  height: 100%;
  width: auto;
  margin: 0 auto;
}

/* Explicit aspect overrides (from the Aspect Ratio pills) */
.video-container.aspect-landscape { aspect-ratio: 16 / 9; }
.video-container.aspect-portrait  { aspect-ratio: 9 / 16; }

.video-container video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.caption-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ── Custom timeline player ──────────────────────────── */

.player-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 720px;
}

.player-bar[hidden] { display: none; }

.player-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--color-accent);
  color: #14101E;
  border: none;
  cursor: pointer;
  transition: background var(--transition-fast), transform var(--transition-fast);
}

.player-btn:hover { background: var(--color-accent-hover); }
.player-btn:active { transform: scale(0.94); }

.player-btn-sm {
  width: 32px;
  height: 32px;
  background: transparent;
  color: var(--color-text-secondary);
}

.player-btn-sm:hover {
  background: var(--color-accent-dim);
  color: var(--color-accent);
}

.player-time {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: center;
  flex-shrink: 0;
}

.player-scrub {
  flex: 1;
  min-width: 0;
  padding: var(--space-3) 0;
  cursor: pointer;
  touch-action: none;
}

.player-scrub-track {
  position: relative;
  height: 5px;
  border-radius: var(--radius-full);
  background: var(--color-card-raised);
}

.player-scrub-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  border-radius: var(--radius-full);
  background: var(--color-accent);
}

.player-scrub-thumb {
  position: absolute;
  top: 50%;
  left: 0%;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(184, 164, 255, 0.25);
  transform: translate(-50%, -50%);
  transition: transform var(--transition-fast);
}

.player-scrub:hover .player-scrub-thumb { transform: translate(-50%, -50%) scale(1.15); }

.player-volume {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex-shrink: 0;
}

.player-volume-slider {
  width: 72px;
  height: 4px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

@media (max-width: 768px) {
  .player-volume-slider { width: 52px; }
}

/* ── Full-width button variant ───────────────────────── */

.btn-full {
  width: 100%;
  justify-content: center;
}

.btn-outline {
  background: transparent;
  border: 1.5px solid var(--color-border);
  color: var(--color-text-secondary);
  transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}

.btn-outline:not(:disabled):hover {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-dim);
}

.btn-outline.ready {
  border-color: var(--color-accent);
  color: var(--color-accent);
  background: var(--color-accent-dim);
}

/* ── Sub-sections ────────────────────────────────────── */

.sub-section {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding-top: var(--space-3);
  border-top: 1px solid var(--color-border-subtle);
}

.sub-section:first-child {
  padding-top: 0;
  border-top: none;
}

.sub-section-label {
  font-size: var(--text-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-secondary);
}

.sub-section-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* ── Control primitives ──────────────────────────────── */

.control-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.control-group.half {
  flex: 1;
  min-width: 0;
}

/* One control per row — stacking vertically prevents the cramped two-up layout
   in the narrow 340px options panel and removes horizontal overflow. */
.control-row {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  align-items: stretch;
}

.control-label {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-secondary);
}

.control-hint {
  margin-top: 6px;
  font-size: var(--text-xs);
  color: var(--color-text-tertiary, var(--color-text-secondary));
  font-style: italic;
}

.select-input {
  width: 100%;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: var(--space-2) var(--space-3);
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23A89FC4' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 30px;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.select-input:focus {
  outline: none;
  border-color: var(--color-accent);
}

/* ── Stepper ─────────────────────────────────────────── */

.stepper {
  display: flex;
  align-items: center;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.stepper-btn {
  flex-shrink: 0;
  width: 32px;
  height: 34px;
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: var(--text-base);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.stepper-btn:hover {
  background: var(--color-card-raised);
  color: var(--color-text-primary);
}

.stepper-input {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  border-left: 1px solid var(--color-border-subtle);
  border-right: 1px solid var(--color-border-subtle);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  text-align: center;
  padding: var(--space-2) 0;
  height: 34px;
}

.stepper-input:focus { outline: none; }
.stepper-input::-webkit-inner-spin-button,
.stepper-input::-webkit-outer-spin-button { -webkit-appearance: none; }

/* Stepper + drag slider stacked together (slider injected by JS). */
.stepper-with-slider {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}
.stepper-with-slider .stepper-slider {
  width: 100%;
}

/* ── Range slider ────────────────────────────────────── */

.slider-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.range-input {
  flex: 1;
  height: 4px;
  accent-color: var(--color-accent);
  cursor: pointer;
}

.range-value {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
  min-width: 36px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

/* ── Color picker ────────────────────────────────────── */

.color-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.color-input {
  width: 32px;
  height: 32px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 2px;
  background: var(--color-card);
  cursor: pointer;
  flex-shrink: 0;
}

.color-input::-webkit-color-swatch-wrapper { padding: 0; }
.color-input::-webkit-color-swatch { border: none; border-radius: 4px; }

.color-value {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
}

/* ── Toggle switch ───────────────────────────────────── */

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.toggle {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  cursor: pointer;
  flex-shrink: 0;
}

.toggle input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
}

.toggle-track {
  position: absolute;
  inset: 0;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-full);
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.toggle-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 14px;
  height: 14px;
  background: var(--color-text-disabled);
  border-radius: 50%;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.toggle input:checked + .toggle-track {
  background: var(--color-accent-dim);
  border-color: var(--color-accent);
}

.toggle input:checked + .toggle-track::after {
  transform: translateX(18px);
  background: var(--color-accent);
}

/* ── Pill group ──────────────────────────────────────── */

.pill-group {
  display: flex;
  gap: var(--space-2);
}

.pill {
  flex: 1;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.pill:hover {
  border-color: var(--color-accent);
  color: var(--color-text-primary);
}

.pill.active {
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
  color: var(--color-accent);
}

.pill.is-locked {
  cursor: default;
  pointer-events: none;
}

/* ── Per-style size controls (dynamic) ───────────────── */

.size-controls {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.size-controls .control-row {
  gap: var(--space-2);
}

/* ── Position preset grid ────────────────────────────── */

.pos-preset-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-2);
}

.pos-preset {
  padding: var(--space-2) var(--space-1);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border);
  background: var(--color-card);
  color: var(--color-text-secondary);
  font-size: var(--text-xs);
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: border-color var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.pos-preset:hover {
  border-color: var(--color-accent);
  color: var(--color-text-primary);
}

.pos-preset.active {
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
  color: var(--color-accent);
}

/* ── Style preset cards ──────────────────────────────── */

.style-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--space-2);
}

.style-option {
  padding: var(--space-3);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
  background: var(--color-card);
  cursor: pointer;
  text-align: center;
  transition: border-color var(--transition-fast), background var(--transition-fast), box-shadow var(--transition-fast);
  color: var(--color-text-primary);
}

.style-option:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.style-option.active {
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
}

/* Loading state while Impact emphasis classification runs */
.style-option-loading {
  position: relative;
  pointer-events: none;
}

.style-option-loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 20px;
  margin: -10px 0 0 -10px;
  border: 2px solid var(--color-border);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

.style-option-preview {
  height: 44px;
  border-radius: var(--radius-sm);
  background: #111;
  margin-bottom: var(--space-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.02em;
}

.style-option-name {
  display: block;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--color-text-primary);
}

.style-option-desc {
  display: block;
  font-size: 10px;
  color: var(--color-text-secondary);
  margin-top: 2px;
}

/* ── Caption editor (in captions accordion) ─────────── */

.translate-row {
  display: flex;
  gap: var(--space-2);
  align-items: center;
}

.translate-row[hidden] {
  display: none;
}

.select-compact {
  flex: 1;
}

/* Captions tab fills the whole panel height, then the list scrolls internally
   instead of stopping at ~60% and leaving the bottom empty. */
#accordion-captions-panel.tab-section.active {
  flex: 1;
  min-height: 0;
}
#accordion-captions-panel .tab-section-body {
  flex: 1;
  min-height: 0;
}

.editor-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

.caption-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-2);
  border-bottom: 1px solid var(--color-border-subtle);
  align-items: start;
}

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

.caption-time {
  font-size: var(--text-xs);
  font-family: var(--font-mono);
  color: var(--color-text-secondary);
  padding-top: 6px;
  white-space: nowrap;
}

.caption-text-input {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--color-text-primary);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  padding: var(--space-1) var(--space-2);
  width: 100%;
  resize: none;
  transition: border-color var(--transition-fast), background var(--transition-fast);
  line-height: 1.5;
}

.caption-text-input:hover {
  border-color: var(--color-border);
  background: var(--color-accent-dim);
}

.caption-text-input:focus {
  outline: none;
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
}

/* ── Upload zone ─────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-card);
  padding: var(--space-8) var(--space-4);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  cursor: pointer;
  transition: border-color var(--transition-base), background var(--transition-base);
  text-align: center;
  min-height: 150px;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--color-accent);
  background: var(--color-accent-dim);
}

.upload-icon-wrap {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: var(--space-1);
}

.upload-zone-title {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--color-text-primary);
}

.upload-zone-subtitle {
  font-size: var(--text-xs);
  color: var(--color-text-secondary);
}

.upload-zone-limit {
  font-size: var(--text-xs);
  color: var(--color-text-disabled);
}

.upload-error {
  display: none;
  background: var(--color-error-bg);
  border: 1px solid rgba(255, 123, 123, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--color-error);
  font-size: var(--text-sm);
}

.upload-error.visible { display: block; }

/* ── File info ───────────────────────────────────────── */

.file-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  background: var(--color-card);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-3);
}

.file-info.hidden { display: none; }

.file-info-inner {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  flex: 1;
  color: var(--color-text-secondary);
}

.file-info-name {
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-info-size {
  font-size: var(--text-xs);
  color: var(--color-text-disabled);
  white-space: nowrap;
  flex-shrink: 0;
}

.file-remove-btn {
  flex-shrink: 0;
  background: transparent;
  border: none;
  color: var(--color-text-disabled);
  cursor: pointer;
  padding: var(--space-1);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  transition: color var(--transition-fast);
}

.file-remove-btn:hover { color: var(--color-error); }

/* ── Progress panel ──────────────────────────────────── */

.progress-panel {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-4);
  border: 1px solid var(--color-border-subtle);
  display: none;
}

.progress-panel.visible { display: block; }

/* ── Inline messages ─────────────────────────────────── */

.inline-error {
  display: none;
  background: var(--color-error-bg);
  border: 1px solid rgba(255, 123, 123, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--color-error);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.inline-error.visible { display: block; }

.inline-info {
  display: none;
  background: var(--color-accent-dim);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
  color: var(--color-text-primary);
  font-size: var(--text-sm);
  line-height: 1.5;
}

.inline-info.visible { display: block; }
.inline-info a {
  color: var(--color-accent);
  cursor: pointer;
  text-decoration: underline;
}

/* ── Key status badge ────────────────────────────────── */

.key-status-badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-xs);
  padding: 2px 8px;
  border-radius: var(--radius-full);
  background: var(--color-error-bg);
  color: var(--color-error);
  font-weight: 500;
}

.key-status-badge.has-key {
  background: var(--color-success-bg);
  color: var(--color-success);
}

/* ── Responsive ──────────────────────────────────────── */

@media (max-width: 768px) {
  /* On small screens the layout stacks and needs normal page scrolling, so
     undo the fixed-viewport / no-scroll setup used on desktop. */
  body {
    height: auto;
    overflow: visible;
  }

  .app-body {
    flex-direction: column;
    padding: var(--space-4);
    gap: var(--space-4);
    height: auto;
    flex: none;
    overflow: visible;
  }

  /* Mobile stacking order: preview first, then the rail, then the panels. */
  .right-panel   { order: 1; }
  .sidebar-rail  { order: 2; }
  .options-panel { order: 3; }

  .sidebar-rail {
    flex-direction: row;
    width: 100%;
    height: auto;
  }

  .rail-btn { flex: 1; }

  .options-panel {
    flex: 1 1 auto;
    width: 100%;
    height: auto;
    overflow-y: visible;
  }

  .right-panel {
    position: static;
    height: auto;
    overflow-y: visible;
    width: 100%;
  }

  .video-container.aspect-portrait {
    height: min(50vh, 360px);
  }

  /* Hide the navbar Download on phones — it's surfaced under the preview via
     #download-btn-mobile instead. */
  #download-btn {
    display: none;
  }

  .btn.download-btn-mobile {
    display: inline-flex;
    width: 100%;
    max-width: 720px;
  }
}

/* ── Timeline (waveform + draggable caption segments) ──── */

.timeline-panel {
  /* Hidden for now — the simple play/pause + slider + volume player bar is the
     active preview control. Kept in the DOM/CSS so it can be re-enabled later
     by removing this display:none. */
  display: none;
  width: 100%;
  max-width: 720px;
  background: var(--color-surface);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  flex-direction: column;
  gap: var(--space-3);
}

.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.timeline-toolbar-spacer { flex: 1; }

.timeline-time {
  font-size: 12px;
  color: var(--color-text-secondary);
  font-variant-numeric: tabular-nums;
  min-width: 96px;
}

.timeline-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg);
  color: var(--color-text-primary);
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.timeline-btn:hover {
  border-color: var(--color-border);
  background: var(--color-accent-dim);
}

.timeline-btn-sm { width: 26px; height: 26px; }

.timeline-view-toggle {
  display: inline-flex;
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.timeline-toggle-btn {
  padding: 5px 10px;
  font-size: 12px;
  border: none;
  background: var(--color-bg);
  color: var(--color-text-secondary);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.timeline-toggle-btn.active {
  background: var(--color-accent-dim);
  color: var(--color-accent);
}

.timeline-zoom { display: inline-flex; gap: 4px; }

.timeline-track-container {
  position: relative;
  width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--color-bg);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: var(--space-2) 0;
}

.timeline-segments-area {
  position: relative;
  width: 100%;
  height: 96px;
}

.timeline-waveform {
  position: absolute;
  top: 50%;
  left: 0;
  transform: translateY(-50%);
  width: 100%;
  height: 48px;
  pointer-events: none;
}

.timeline-playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--color-accent);
  box-shadow: 0 0 6px rgba(184, 164, 255, 0.7);
  pointer-events: none;
  z-index: 3;
}

.timeline-segment-box {
  position: absolute;
  top: 8px;
  height: 26px;
  background: var(--color-accent-dim);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  cursor: grab;
  overflow: hidden;
  z-index: 2;
  transition: background 0.12s ease, border-color 0.12s ease;
}

.timeline-segment-box:hover { background: rgba(184, 164, 255, 0.22); }
.timeline-segment-box:active { cursor: grabbing; }

.timeline-segment-box.active {
  background: rgba(184, 164, 255, 0.32);
  border-color: var(--color-accent);
}

.timeline-segment-text {
  flex: 1;
  padding: 0 8px;
  font-size: 11px;
  color: var(--color-text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  user-select: none;
}

.timeline-handle {
  width: 6px;
  align-self: stretch;
  cursor: ew-resize;
  flex-shrink: 0;
  background: transparent;
}

.timeline-handle:hover { background: var(--color-accent); }

/* ── Global scrollbar ────────────────────────────────── */

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: var(--radius-full);
}
