/* Design tokens ---------------------------------------------------------- */

:root {
  --bg: #ffffff;
  --bg-raised: #f7f7f8;
  --bg-raised-2: #eef0f2;
  --bg-sunken: #f2f3f5;

  --border: #e3e5e9;
  --border-soft: #ececef;

  --text: #16171c;
  --text-muted: #6b7280;
  --text-faint: #9aa1ac;

  --accent: oklch(68% 0.17 55);
  --accent-strong: oklch(62% 0.18 55);
  --accent-ink: oklch(99% 0.005 55);

  --danger: oklch(58% 0.19 25);
  --danger-strong: oklch(52% 0.19 25);
  --success: oklch(52% 0.14 145);

  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-pill: 999px;

  --ease-out-quint: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out-cubic: cubic-bezier(0.645, 0.045, 0.355, 1);

  --font-display: "Outfit", "Segoe UI", sans-serif;
  --shadow-raised: 0 1px 0 0 rgba(20, 20, 25, 0.03), 0 8px 24px -12px rgba(20, 20, 25, 0.12);
  --header-bg: rgba(255, 255, 255, 0.85);

  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: oklch(15% 0.012 55);
  --bg-raised: oklch(19% 0.014 55);
  --bg-raised-2: oklch(24% 0.016 55);
  --bg-sunken: oklch(12% 0.01 55);

  --border: oklch(30% 0.017 55);
  --border-soft: oklch(24% 0.015 55);

  --text: oklch(95% 0.006 60);
  --text-muted: oklch(68% 0.018 55);
  --text-faint: oklch(48% 0.016 55);

  --accent: oklch(74% 0.16 55);
  --accent-strong: oklch(80% 0.17 55);
  --accent-ink: oklch(18% 0.03 45);

  --danger: oklch(66% 0.17 25);
  --danger-strong: oklch(72% 0.18 25);
  --success: oklch(74% 0.15 145);

  --shadow-raised: 0 1px 0 0 oklch(0% 0 0 / 0.2), 0 8px 24px -12px oklch(0% 0 0 / 0.5);
  --header-bg: oklch(15% 0.012 55 / 0.9);

  color-scheme: dark;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  line-height: 1.5;
  padding-bottom: 72px;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 200ms var(--ease-out-quint), color 200ms var(--ease-out-quint);
}

.panel, .stage-card, .phone-frame, .clip-row, header {
  transition: background-color 200ms var(--ease-out-quint), border-color 200ms var(--ease-out-quint);
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* App shell (sidebar navigation) ------------------------------------------ */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex-shrink: 0;
  background: var(--bg-raised);
  border-right: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  padding: 18px 14px;
  position: fixed;
  top: 0; bottom: 0; left: 0;
  z-index: 30;
  transition: transform 220ms var(--ease-out-quint), background-color 200ms var(--ease-out-quint), border-color 200ms var(--ease-out-quint);
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 17px;
  letter-spacing: -0.01em;
  padding: 8px 10px 22px;
}
.sidebar__brand .dot { color: var(--accent); }

.sidebar__nav { display: flex; flex-direction: column; gap: 2px; flex: 1; }

.sidebar__link {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  text-decoration: none;
  font-size: 14.5px;
  font-weight: 500;
  transition: color 150ms var(--ease-out-quint), background-color 150ms var(--ease-out-quint);
}
.sidebar__link i { font-size: 18px; flex-shrink: 0; width: 18px; text-align: center; }
.sidebar__link.active { color: var(--text); background: var(--bg-raised-2); font-weight: 600; }
@media (hover: hover) and (pointer: fine) {
  .sidebar__link:not(.active):hover { color: var(--text); background: var(--bg-sunken); }
}

.sidebar__footer { border-top: 1px solid var(--border-soft); padding-top: 10px; margin-top: 10px; }

.sidebar__theme-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  background: transparent;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
}
.sidebar__theme-btn i { font-size: 17px; width: 18px; text-align: center; }
.sidebar__theme-btn:active { background: var(--bg-sunken); }

.app-shell__main { flex: 1; min-width: 0; margin-left: 248px; }

.topbar {
  display: none;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-soft);
  position: sticky;
  top: 0;
  background: var(--header-bg);
  backdrop-filter: blur(10px);
  z-index: 20;
}
.topbar__title { font-weight: 700; font-size: 16px; }

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: oklch(0% 0 0 / 0.5);
  z-index: 25;
}

@media (max-width: 899px) {
  .sidebar { transform: translateX(-100%); width: 264px; box-shadow: var(--shadow-raised); }
  .sidebar.open { transform: translateX(0); }
  .app-shell__main { margin-left: 0; }
  .topbar { display: flex; }
  .sidebar-backdrop.open { display: block; }
}

main { max-width: 640px; margin: 0 auto; padding: 24px 16px 48px; }

.editor-grid {
  display: grid;
  grid-template-columns: 1fr;
  grid-template-areas: "preview" "editor";
  gap: 20px;
  align-items: start;
}

.editor-grid .preview-col { grid-area: preview; }
.editor-grid .editor-col { grid-area: editor; min-width: 0; }

@media (min-width: 900px) {
  main.wide { max-width: 980px; }
  .editor-grid { grid-template-columns: 1fr 360px; grid-template-areas: "editor preview"; }
  /* Sticky only makes sense once there's a separate column to scroll past it;
     on a single-column phone layout it just traps the viewport (see git log). */
  .editor-grid .preview-col { position: sticky; top: 68px; z-index: 5; }
}

section.block, details.block { margin-bottom: 28px; }

section.block h2, details.block > summary {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 13px;
  font-weight: 600;
  margin: 0 0 12px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

section.block h2 i, details.block > summary i { font-size: 14px; }

/* Collapsed-by-default "advanced" sections (style/general/music/sfx) - kept
   as native <details> so no JS is needed for the toggle. */
details.block > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
}
details.block > summary::-webkit-details-marker { display: none; }
details.block > summary .chevron {
  margin-left: auto;
  transition: transform 150ms var(--ease-out-quint);
}
details.block[open] > summary .chevron { transform: rotate(180deg); }
details.block:not([open]) { margin-bottom: 12px; }

/* A lighter nested toggle for advanced controls inside an otherwise
   always-visible section (e.g. font/size under the title text input). */
.style-details {
  margin-top: 10px;
}
.style-details > summary {
  cursor: pointer;
  list-style: none;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.style-details > summary::-webkit-details-marker { display: none; }
.style-details > summary i { font-size: 11px; transition: transform 150ms var(--ease-out-quint); }
.style-details[open] > summary i { transform: rotate(180deg); }
.style-details > .style-row:first-of-type { margin-top: 12px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.section-head h2 { margin: 0; }

.job-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 2px;
  border-bottom: 1px solid var(--border-soft);
}

.job-row:last-child { border-bottom: none; }
.job-row__main { min-width: 0; flex: 1; cursor: pointer; }
.job-row__main:active { background: var(--bg-raised-2); }
.job-row__title { font-size: 14px; font-weight: 500; overflow-wrap: anywhere; }

.panel {
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
}

/* Typography ---------------------------------------------------------- */

label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: 6px;
}

/* Form controls ------------------------------------------------------- */

.input, textarea, input[type=text], input[type=number], input[type=password], input[type=datetime-local] {
  width: 100%;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-family: inherit;
  margin-bottom: 12px;
  transition: border-color 150ms var(--ease-out-quint);
}

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

textarea { min-height: 70px; resize: vertical; }

select.input { appearance: none; background-image: linear-gradient(45deg, transparent 50%, var(--text-muted) 50%), linear-gradient(135deg, var(--text-muted) 50%, transparent 50%); background-position: calc(100% - 18px) center, calc(100% - 13px) center; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }

.style-row { display: flex; gap: 14px; align-items: center; margin-bottom: 12px; }
.style-row > div { flex: 1; }
.style-row label { margin-bottom: 4px; }

input[type=range] {
  width: 100%;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  margin: 10px 0 4px;
}

input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-raised);
}

input[type=range]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  cursor: pointer;
  border: 2px solid var(--bg-raised);
}

/* Buttons --------------------------------------------------------------- */

button, .btn {
  font-family: inherit;
  border: none;
  cursor: pointer;
  font-size: 14.5px;
  font-weight: 600;
  transition: transform 120ms var(--ease-out-quint), background-color 150ms var(--ease-out-quint), opacity 150ms;
}

button:active, .btn:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--accent);
  color: var(--accent-ink);
  border-radius: var(--radius-pill);
  padding: 13px 18px;
  width: 100%;
}

@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover { background: var(--accent-strong); }
}

.btn-secondary {
  background: var(--bg-raised-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  padding: 11px 16px;
}

.btn-danger { background: var(--danger); color: oklch(98% 0.01 25); border-radius: var(--radius-pill); padding: 11px 16px; }

.btn-row { display: flex; gap: 8px; }
.btn-row > * { flex: 1; }

.icon-btn {
  background: transparent;
  color: var(--text-muted);
  border: none;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  padding: 0;
}

.icon-btn:active { transform: scale(0.92); background: var(--bg-raised-2); }
.icon-btn.danger { color: var(--danger); }

/* Clip rows (lightweight; the video lives in the shared stage) ----------- */

.clip-row {
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  margin-bottom: 6px;
  transition: border-color 150ms var(--ease-out-quint), background-color 150ms var(--ease-out-quint);
}

.clip-row--active { border-color: var(--accent); background: oklch(74% 0.16 55 / 0.08); }

/* Collapsed by default once a clip loads, so a whole batch fits on screen
   without scrolling - tap the summary row to expand and edit. */
.clip-row__summary {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  cursor: pointer;
  list-style: none;
  user-select: none;
}
.clip-row__summary::-webkit-details-marker { display: none; }

.clip-row__summary-text {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  color: var(--text);
}

.clip-row__summary-sfx { color: var(--accent); font-size: 14px; flex-shrink: 0; }
.clip-row__summary-status { display: inline-flex; align-items: center; font-size: 15px; flex-shrink: 0; }
.clip-row__summary .chevron { color: var(--text-faint); font-size: 14px; flex-shrink: 0; transition: transform 150ms var(--ease-out-quint); }
.clip-row[open] .clip-row__summary .chevron { transform: rotate(180deg); }

.clip-row__body { padding: 0 12px 12px; }

.drag-handle {
  color: var(--text-faint);
  font-size: 19px;
  cursor: grab;
  touch-action: none;
  flex-shrink: 0;
  padding: 4px 2px;
}
.drag-handle:active { cursor: grabbing; }

.clip-row.dragging { opacity: 0.6; }

.clip-thumb-wrap {
  position: relative;
  width: 42px;
  height: 74px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: var(--bg-sunken);
  border: 1px solid var(--border-soft);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.clip-thumb-wrap.small { width: 26px; height: 40px; }
.clip-thumb-wrap.small .clip-thumb-placeholder { font-size: 12px; }
.clip-thumb-wrap.small .badge { width: 14px; height: 14px; font-size: 8px; }

.clip-thumb { width: 100%; height: 100%; object-fit: cover; display: block; }
.clip-thumb-placeholder { color: var(--text-faint); font-size: 16px; }

.clip-thumb-wrap .badge {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: var(--radius-pill);
  background: oklch(15% 0.01 55 / 0.75);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
}

.clip-row--active .badge { background: var(--accent); color: var(--accent-ink); }

.clip-row__actions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 10px; }
.clip-row__actions .icon-btn { width: 30px; height: 30px; font-size: 15px; }

.clip-row__url { display: flex; gap: 8px; align-items: center; padding-top: 10px; }
.clip-row__url .platform-icon { color: var(--text-faint); font-size: 18px; flex-shrink: 0; }
.clip-row__url .input { margin-bottom: 0; }
.clip-row__url .load-btn { width: auto; white-space: nowrap; flex-shrink: 0; }

.clip-row__status {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 2px 0;
}

.clip-row__status.error { color: var(--danger-strong); }

.clip-row__sfx { display: flex; gap: 8px; align-items: center; margin-top: 8px; }
.clip-row__sfx > i { color: var(--text-faint); font-size: 17px; flex-shrink: 0; }
.clip-row__sfx .sfx-select { margin-bottom: 0; flex: 1; }

.sfx-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 2px;
  border-bottom: 1px solid var(--border-soft);
}
.sfx-item:last-child { border-bottom: none; }
.sfx-item__name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.sfx-item__dur { color: var(--text-faint); font-size: 12px; flex-shrink: 0; }
.sfx-item .icon-btn { width: 30px; height: 30px; font-size: 15px; flex-shrink: 0; }
.sfx-item .icon-btn.playing { background: var(--accent); color: var(--accent-ink); }

.sfx-upload {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-top: 8px;
}
.sfx-upload .input { margin-bottom: 0; flex: 1; }
.sfx-upload label.btn-secondary { width: auto; white-space: nowrap; flex-shrink: 0; padding: 10px 14px; }
.clip-row__label { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.clip-row__label .label-input { margin-bottom: 0; flex: 1; }
.clip-row__label .label-color-input {
  width: 34px; height: 34px; padding: 2px; border-radius: 8px;
  border: 1px solid var(--border); background: transparent; flex-shrink: 0;
}
.clip-row__label .label-color-reset { width: 30px; height: 30px; font-size: 14px; flex-shrink: 0; }

.spinner {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  animation: spin 700ms linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* Live preview stage ------------------------------------------------------ */

.stage-card {
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 14px;
}

.stage-card__head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.phone-frame {
  border-radius: var(--radius-lg);
  padding: 6px;
  background: var(--bg-sunken);
  border: 1px solid var(--border);
}

.stage {
  position: relative;
  border-radius: calc(var(--radius-lg) - 4px);
  overflow: hidden;
  background: black;
  aspect-ratio: 9 / 16;
  max-height: 62vh;
  margin: 0 auto;
}

.stage__video { position: absolute; top: 0; left: 0; right: 0; width: 100%; height: 100%; object-fit: cover; background: transparent; }

.stage__empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--text-faint);
  font-size: 13px;
  text-align: center;
  padding: 20px;
}

.stage__empty i { font-size: 32px; }

.stage__bar {
  position: absolute;
  top: 0; left: 0; right: 0;
  background: black;
  display: flex;
  /* Vertical position is set per-render in JS (padding-top), not centered -
     mirrors app/video.py's TITLE_SAFE_TOP clamp so the title never sits
     where YouTube Shorts/TikTok/Reels draw their own top UI chrome. */
  align-items: flex-start;
  justify-content: center;
  padding: 0 10px;
  text-align: center;
}

/* Mirrors build_overlay_filter: wraps to a second line before shrinking
   too far, rather than shrinking indefinitely to fit one line. */
.stage__title {
  font-weight: 700;
  line-height: 1.15;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 100%;
}
.stage__title-line { white-space: nowrap; }
.stage__title span { padding: 0 1px; }

.stage__list { position: absolute; inset: 0; pointer-events: none; }

.stage-list-row {
  position: absolute;
  display: flex;
  align-items: baseline;
  color: white;
  font-weight: 700;
  font-family: 'Liberation Sans', Arial, sans-serif;
  text-shadow: 0 0 3px black, 0 0 6px black;
}

.stage__play-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: oklch(0% 0 0 / 0);
  transition: background-color 150ms var(--ease-out-quint);
}

.stage__play-overlay .icon-btn {
  width: 52px;
  height: 52px;
  font-size: 24px;
  background: oklch(15% 0.01 55 / 0.55);
  color: white;
  backdrop-filter: blur(4px);
}

.stage__scrub { padding-top: 10px; }

.trimmer__meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
  font-variant-numeric: tabular-nums;
}

.trimmer__meta .trim-len { color: var(--accent); font-weight: 600; }

.trimmer__track {
  position: relative;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--bg-sunken);
  border: 1px solid var(--border);
  touch-action: none;
}

.trimmer__range {
  position: absolute;
  top: 0;
  bottom: 0;
  background: oklch(74% 0.16 55 / 0.22);
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  will-change: transform, width;
}

.trimmer__handle {
  position: absolute;
  top: -1px;
  bottom: -1px;
  width: 18px;
  margin-left: -9px;
  background: var(--accent);
  border-radius: 6px;
  cursor: grab;
  display: flex;
  align-items: center;
  justify-content: center;
  will-change: transform;
}

.trimmer__handle::after {
  content: "";
  width: 3px;
  height: 14px;
  border-radius: 2px;
  background: var(--accent-ink);
  opacity: 0.6;
}

.trimmer__handle:active { cursor: grabbing; }

.trimmer__playhead {
  position: absolute;
  top: -4px;
  bottom: -4px;
  width: 2px;
  background: white;
  border-radius: 1px;
  pointer-events: none;
  will-change: transform;
}

/* Title bar word chips ---------------------------------------------------- */

.title-words {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 14px;
}

.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 13px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border);
  background: var(--bg-sunken);
  cursor: pointer;
  font-weight: 600;
  font-size: 14px;
  transition: transform 120ms var(--ease-out-quint), border-color 150ms, background 150ms;
}

.word-chip__swatch {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid oklch(0% 0 0 / 0.25);
  flex-shrink: 0;
}

.word-chip:active { transform: scale(0.95); }

/* No free color choice - a word is either default or locked to the one
   highlight red (renderTitleWords toggles this class on tap). */
.word-chip--highlighted {
  border-color: #ff2b2b;
  background: color-mix(in oklch, #ff2b2b 12%, var(--bg-sunken));
}

/* Status pill --------------------------------------------------------- */

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 12px;
  border-radius: var(--radius-pill);
  font-size: 12.5px;
  font-weight: 600;
  background: var(--bg-raised-2);
  color: var(--text-muted);
  text-transform: capitalize;
}

.status-pill.success { background: oklch(74% 0.15 145 / 0.16); color: var(--success); }
.status-pill.failed { background: oklch(66% 0.17 25 / 0.16); color: var(--danger-strong); }
.status-pill.busy { background: oklch(74% 0.16 55 / 0.16); color: var(--accent); }
.status-pill.review { background: oklch(74% 0.16 55 / 0.22); color: var(--accent-strong); }
.status-pill.busy .dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; animation: pulse 1.2s ease-in-out infinite; }

@keyframes pulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

/* Media ------------------------------------------------------------------ */

video.preview-video, img.preview {
  width: 100%;
  max-height: 460px;
  border-radius: var(--radius-md);
  background: black;
  margin-bottom: 12px;
  object-fit: contain;
}

.thumb-row { display: flex; gap: 12px; align-items: center; margin-bottom: 4px; }
.thumb-row img { width: 96px; height: 171px; object-fit: cover; border-radius: var(--radius-sm); background: black; flex-shrink: 0; }
.thumb-row .thumb-actions { flex: 1; }

/* Misc --------------------------------------------------------------- */

.muted { color: var(--text-muted); font-size: 13px; }
.error-box {
  background: oklch(66% 0.17 25 / 0.12);
  border: 1px solid oklch(66% 0.17 25 / 0.4);
  color: var(--danger-strong);
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  margin-bottom: 12px;
  font-size: 13.5px;
}
.hidden { display: none !important; }

.empty-state {
  text-align: center;
  padding: 32px 16px;
  color: var(--text-faint);
  font-size: 14px;
}

a { color: var(--accent); }

/* Dashboard --------------------------------------------------------------- */

.stat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 20px; }

.stat-box {
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  transition: border-color 150ms var(--ease-out-quint), box-shadow 150ms var(--ease-out-quint);
}

@media (hover: hover) and (pointer: fine) {
  .stat-box:hover { border-color: var(--border); box-shadow: var(--shadow-raised); }
}

.stat-box .num { font-size: 30px; font-weight: 700; letter-spacing: -0.02em; }
.stat-box .label { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; }

.stat-box .stat-icon {
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  background: oklch(74% 0.16 55 / 0.14);
  color: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}

.day-bar-row { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; font-size: 12.5px; }
.day-bar-row .day { width: 78px; color: var(--text-muted); font-variant-numeric: tabular-nums; }
.day-bar-track { flex: 1; background: var(--bg-sunken); border-radius: 4px; overflow: hidden; height: 12px; }
.day-bar-fill { background: var(--accent); height: 100%; border-radius: 4px; transition: width 300ms var(--ease-out-quint); }
.day-bar-row .count { width: 20px; text-align: right; color: var(--text-muted); font-variant-numeric: tabular-nums; }

table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border-soft); }
th { color: var(--text-faint); font-weight: 500; font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; }

/* Jobs & Drafts page -------------------------------------------------------- */

.list-toolbar { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.list-toolbar .input { margin-bottom: 0; flex: 1; min-width: 160px; }

.filter-tabs { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 2px; margin-bottom: 14px; -ms-overflow-style: none; scrollbar-width: none; }
.filter-tabs::-webkit-scrollbar { display: none; }

.filter-tab {
  flex-shrink: 0;
  padding: 8px 14px;
  border-radius: var(--radius-pill);
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  color: var(--text-muted);
  font-size: 13.5px;
  font-weight: 500;
  white-space: nowrap;
}
.filter-tab.active { background: var(--text); color: var(--bg); border-color: var(--text); }
:root[data-theme="dark"] .filter-tab.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.data-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 4px;
  border-bottom: 1px solid var(--border-soft);
}
.data-row:last-child { border-bottom: none; }

.data-row__main { min-width: 0; flex: 1; cursor: pointer; display: flex; align-items: center; gap: 10px; }
.data-row__thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; flex-shrink: 0; background: var(--bg-raised-2); }
.data-row__body { min-width: 0; }
.data-row__title { font-size: 14.5px; font-weight: 500; overflow-wrap: anywhere; }
.data-row__meta { font-size: 12.5px; color: var(--text-muted); margin-top: 2px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.data-row__error { font-size: 12.5px; color: var(--danger); margin-top: 3px; overflow-wrap: anywhere; }
.data-row__actions { display: flex; gap: 2px; flex-shrink: 0; align-items: center; }
.data-row__reschedule { display: flex; gap: 6px; align-items: center; margin-top: 8px; }
.data-row__reschedule input { margin: 0; }
.data-row__edit-meta { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.data-row__edit-meta input, .data-row__edit-meta textarea { margin: 0; }
.data-row__edit-meta textarea { min-height: 60px; resize: vertical; }

.source-tag {
  display: inline-flex;
  align-items: center;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  background: var(--bg-raised-2);
  color: var(--text-muted);
}

.pagination { display: flex; align-items: center; justify-content: center; gap: 14px; margin-top: 16px; }
.pagination__pos { font-size: 13px; color: var(--text-muted); font-variant-numeric: tabular-nums; }

/* Batch upload modal ------------------------------------------------------- */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: flex-end;
  justify-content: center;
}

.modal__backdrop { position: absolute; inset: 0; background: oklch(0% 0 0 / 0.6); }

.modal__panel {
  position: relative;
  background: var(--bg-raised);
  border: 1px solid var(--border-soft);
  border-bottom: none;
  border-top-left-radius: var(--radius-lg);
  border-top-right-radius: var(--radius-lg);
  padding: 18px 16px calc(18px + env(safe-area-inset-bottom, 0px));
  width: 100%;
  max-width: 640px;
  max-height: 85vh;
  overflow-y: auto;
}

.modal__head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }

@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal__panel { border-radius: var(--radius-lg); border-bottom: 1px solid var(--border-soft); max-height: 80vh; }
}

.batch-video-box { margin-bottom: 12px; }
.batch-video-box textarea { margin-bottom: 0; min-height: 90px; }
