/* ==========================================================================
   FrameSync Studio — Design System
   Midnight-navy theme, glass panels, teal + violet accents.
   ========================================================================== */

/* The `hidden` attribute must always win, even on elements whose own
   rules set a display value (e.g. .modal-backdrop uses display:flex).
   Without this, a hidden modal/backdrop renders on top of the page
   and can never be dismissed. Regression: Nov 2026 stuck Relink modal. */
[hidden] {
  display: none !important;
}

/* --------------------------------------------------------------------------
   1. CSS Variables
   -------------------------------------------------------------------------- */
:root {
  /* Backgrounds */
  --bg-0: #070d1a;
  --bg-1: #0a1428;
  --bg-2: #0d1b36;
  --bg-3: #122242;
  --bg-elevated: #101f3d;
  --bg-sunken: #050a14;

  /* Glass */
  --glass-bg: rgba(16, 31, 61, 0.62);
  --glass-bg-strong: rgba(18, 34, 66, 0.82);
  --glass-border: rgba(148, 178, 255, 0.16);
  --glass-border-bright: rgba(148, 178, 255, 0.28);
  --glass-highlight: rgba(255, 255, 255, 0.07);

  /* Accents */
  --teal: #2dd4bf;
  --teal-soft: #5eead4;
  --teal-deep: #0d9488;
  --teal-dim: rgba(45, 212, 191, 0.14);
  --violet: #8b7cff;
  --violet-soft: #a5a0ff;
  --violet-deep: #6d5ef0;
  --violet-dim: rgba(139, 124, 255, 0.16);
  --amber: #fbbf24;
  --rose: #fb7185;
  --green: #34d399;
  --blue: #60a5fa;

  /* Text */
  --text-0: #f4f7fe;
  --text-1: #dbe4f5;
  --text-2: #a8b8d8;
  --text-3: #7d90b5;
  --text-muted: #8fa3c4;

  /* Borders & radii */
  --border: rgba(148, 178, 255, 0.14);
  --border-strong: rgba(148, 178, 255, 0.24);
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;
  --radius-pill: 999px;

  /* Shadows — layered depth */
  --shadow-xs: 0 1px 2px rgba(2, 6, 18, 0.5);
  --shadow-sm: 0 2px 6px rgba(2, 6, 18, 0.55), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-md: 0 8px 24px rgba(2, 6, 18, 0.55), 0 2px 8px rgba(2, 6, 18, 0.4);
  --shadow-lg: 0 18px 48px rgba(2, 6, 18, 0.6), 0 4px 16px rgba(2, 6, 18, 0.45);
  --shadow-xl: 0 28px 72px rgba(2, 6, 18, 0.7), 0 8px 24px rgba(2, 6, 18, 0.5);
  --shadow-glow-teal: 0 0 0 1px rgba(45, 212, 191, 0.25), 0 8px 28px rgba(45, 212, 191, 0.18);
  --shadow-glow-violet: 0 0 0 1px rgba(139, 124, 255, 0.28), 0 8px 28px rgba(139, 124, 255, 0.2);

  /* Typography */
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  --font-size-xs: 0.75rem;
  --font-size-sm: 0.875rem;
  --font-size-base: 1rem;
  --font-size-lg: 1.125rem;
  --font-size-xl: 1.25rem;
  --font-size-2xl: 1.5rem;
  --font-size-3xl: 2rem;
  --font-size-4xl: 2.75rem;
  --line-height-tight: 1.2;
  --line-height-normal: 1.5;
  --line-height-relaxed: 1.7;

  /* Spacing scale */
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --space-10: 2.5rem;
  --space-12: 3rem;
  --space-16: 4rem;

  /* Layout */
  --header-height: 64px;
  --max-width: 1280px;
  --max-width-wide: 1440px;
  --sidebar-width: 300px;

  /* Motion */
  --duration-fast: 140ms;
  --duration-normal: 220ms;
  --duration-slow: 360ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);

  /* Focus */
  --focus-ring: 0 0 0 3px rgba(45, 212, 191, 0.45), 0 0 0 1px #2dd4bf;
}

/* --------------------------------------------------------------------------
   2. Reset
   -------------------------------------------------------------------------- */
*,
*::before,
*::after {
  box-sizing: border-box;
}

* {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: var(--font-sans);
  font-size: var(--font-size-base);
  line-height: var(--line-height-normal);
  color: var(--text-1);
  background-color: var(--bg-0);
  background-image:
    radial-gradient(900px 500px at 12% -10%, rgba(139, 124, 255, 0.14), transparent 60%),
    radial-gradient(800px 480px at 92% 0%, rgba(45, 212, 191, 0.1), transparent 60%),
    radial-gradient(700px 500px at 50% 115%, rgba(13, 148, 136, 0.08), transparent 60%),
    linear-gradient(180deg, var(--bg-1) 0%, var(--bg-0) 100%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  overflow-x: hidden;
}

img,
picture,
video,
canvas,
svg {
  display: block;
  max-width: 100%;
}

canvas {
  max-width: none;
}

input,
button,
textarea,
select {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

a {
  color: var(--teal-soft);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

ul,
ol {
  list-style: none;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-0);
  line-height: var(--line-height-tight);
  font-weight: 700;
  letter-spacing: -0.02em;
}

p {
  color: var(--text-2);
}

::selection {
  background: rgba(45, 212, 191, 0.32);
  color: #ffffff;
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--bg-0);
}

::-webkit-scrollbar-thumb {
  background: #1e3258;
  border-radius: var(--radius-pill);
  border: 2px solid var(--bg-0);
}

::-webkit-scrollbar-thumb:hover {
  background: #2a4470;
}

/* --------------------------------------------------------------------------
   3. Accessibility — focus & reduced motion
   -------------------------------------------------------------------------- */
:focus {
  outline: none;
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 3px;
  border-radius: 4px;
  box-shadow: var(--focus-ring);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  top: -48px;
  left: var(--space-4);
  z-index: 200;
  padding: var(--space-2) var(--space-4);
  background: var(--teal);
  color: #04211d;
  font-weight: 700;
  border-radius: var(--radius-md);
  transition: top var(--duration-fast) var(--ease-out);
}

.skip-link:focus-visible {
  top: var(--space-3);
  text-decoration: none;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
}

/* --------------------------------------------------------------------------
   4. Utilities
   -------------------------------------------------------------------------- */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin-inline: auto;
  padding-inline: var(--space-6);
}

.container--wide {
  max-width: var(--max-width-wide);
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.text-muted {
  color: var(--text-3);
}

.text-teal {
  color: var(--teal);
}

.text-violet {
  color: var(--violet-soft);
}

.text-sm {
  font-size: var(--font-size-sm);
}

.text-xs {
  font-size: var(--font-size-xs);
}

.text-center {
  text-align: center;
}

.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-pill);
  font-size: var(--font-size-xs);
  font-weight: 600;
  letter-spacing: 0.02em;
  line-height: 1.4;
  white-space: nowrap;
}

.badge--teal {
  background: var(--teal-dim);
  color: var(--teal-soft);
  border: 1px solid rgba(45, 212, 191, 0.3);
}

.badge--violet {
  background: var(--violet-dim);
  color: var(--violet-soft);
  border: 1px solid rgba(139, 124, 255, 0.32);
}

.badge--amber {
  background: rgba(251, 191, 36, 0.12);
  color: #fcd34d;
  border: 1px solid rgba(251, 191, 36, 0.32);
}

.badge--muted {
  background: rgba(148, 178, 255, 0.08);
  color: var(--text-2);
  border: 1px solid var(--border);
}

.kbd {
  font-family: var(--font-mono);
  font-size: 0.8em;
  padding: 0.1rem 0.4rem;
  border-radius: 6px;
  background: rgba(148, 178, 255, 0.1);
  border: 1px solid var(--border);
  border-bottom-width: 2px;
}

/* --------------------------------------------------------------------------
   5. Glass panels & cards
   -------------------------------------------------------------------------- */
.panel,
.glass-panel {
  background: var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 1px 0 var(--glass-highlight);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.panel--strong {
  background: var(--glass-bg-strong);
}

.panel--flat {
  box-shadow: var(--shadow-sm);
}

.panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border);
}

.panel__title {
  font-size: var(--font-size-base);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.panel__body {
  padding: var(--space-5);
}

.panel__footer {
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.card {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.015)),
    var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-md), inset 0 1px 0 var(--glass-highlight);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  transition: transform var(--duration-normal) var(--ease-out),
    box-shadow var(--duration-normal) var(--ease-out),
    border-color var(--duration-normal) var(--ease-out);
}

.card:hover {
  transform: translateY(-3px);
  border-color: var(--glass-border-bright);
  box-shadow: var(--shadow-lg), inset 0 1px 0 rgba(255, 255, 255, 0.09);
}

.card:active {
  transform: translateY(-1px);
  box-shadow: var(--shadow-sm);
}

/* Upload cards — extra depth */
.upload-card {
  position: relative;
  overflow: hidden;
  padding: var(--space-6);
  text-align: center;
  cursor: pointer;
  background:
    radial-gradient(220px 120px at 50% 0%, rgba(45, 212, 191, 0.08), transparent 70%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015)),
    var(--glass-bg);
}

.upload-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.09), transparent 32%);
  pointer-events: none;
}

.upload-card:hover {
  transform: translateY(-4px);
  border-color: rgba(45, 212, 191, 0.42);
  box-shadow: var(--shadow-lg), var(--shadow-glow-teal);
}

.upload-card--violet:hover {
  border-color: rgba(139, 124, 255, 0.48);
  box-shadow: var(--shadow-lg), var(--shadow-glow-violet);
}

.upload-card--dragging,
.upload-card.drag-over {
  border-color: var(--teal);
  border-style: dashed;
  background: var(--teal-dim);
  transform: translateY(-2px) scale(1.01);
}

.upload-card__icon {
  width: 52px;
  height: 52px;
  margin: 0 auto var(--space-3);
  display: grid;
  place-items: center;
  border-radius: var(--radius-xl);
  background: var(--teal-dim);
  color: var(--teal);
  border: 1px solid rgba(45, 212, 191, 0.3);
  box-shadow: var(--shadow-sm);
}

.upload-card--violet .upload-card__icon {
  background: var(--violet-dim);
  color: var(--violet-soft);
  border-color: rgba(139, 124, 255, 0.32);
}

.upload-card h3 {
  font-size: var(--font-size-base);
  margin-bottom: var(--space-1);
}

.upload-card p {
  font-size: var(--font-size-sm);
}

/* --------------------------------------------------------------------------
   6. Buttons — 3D, polished hover / pressed
   -------------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: 0.65rem 1.15rem;
  border-radius: var(--radius-md);
  font-size: var(--font-size-sm);
  font-weight: 650;
  line-height: 1.2;
  letter-spacing: 0.01em;
  color: var(--text-0);
  background: linear-gradient(180deg, #1a2c52, #13233f);
  border: 1px solid var(--border-strong);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 -1px 0 rgba(0, 0, 0, 0.35) inset,
    0 4px 14px rgba(2, 6, 18, 0.5);
  text-decoration: none;
  white-space: nowrap;
  transition: transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    background var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast) var(--ease-out),
    filter var(--duration-fast) var(--ease-out);
  user-select: none;
}

.btn:hover {
  transform: translateY(-2px);
  border-color: var(--glass-border-bright);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.1) inset,
    0 -1px 0 rgba(0, 0, 0, 0.3) inset,
    0 8px 22px rgba(2, 6, 18, 0.6);
  filter: brightness(1.06);
  text-decoration: none;
}

.btn:active,
.btn--pressed {
  transform: translateY(1px) scale(0.99);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.05) inset,
    0 2px 6px rgba(2, 6, 18, 0.55);
}

.btn:disabled,
.btn[aria-disabled="true"] {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: var(--shadow-xs);
}

.btn--primary {
  color: #03211d;
  background: linear-gradient(180deg, #5eead4 0%, #2dd4bf 55%, #14b8a6 100%);
  border-color: rgba(94, 234, 212, 0.6);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.55) inset,
    0 -2px 0 rgba(13, 148, 136, 0.55) inset,
    0 6px 18px rgba(45, 212, 191, 0.28),
    0 2px 6px rgba(2, 6, 18, 0.5);
}

.btn--primary:hover {
  filter: brightness(1.07);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.6) inset,
    0 -2px 0 rgba(13, 148, 136, 0.5) inset,
    0 10px 28px rgba(45, 212, 191, 0.36),
    0 4px 10px rgba(2, 6, 18, 0.55);
}

.btn--primary:active {
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.4) inset,
    0 2px 8px rgba(2, 6, 18, 0.6);
}

.btn--violet {
  color: #ffffff;
  background: linear-gradient(180deg, #a5a0ff 0%, #8b7cff 55%, #6d5ef0 100%);
  border-color: rgba(165, 160, 255, 0.55);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.45) inset,
    0 -2px 0 rgba(80, 64, 220, 0.55) inset,
    0 6px 18px rgba(139, 124, 255, 0.3),
    0 2px 6px rgba(2, 6, 18, 0.5);
}

.btn--violet:hover {
  filter: brightness(1.07);
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.5) inset,
    0 -2px 0 rgba(80, 64, 220, 0.5) inset,
    0 10px 28px rgba(139, 124, 255, 0.38),
    0 4px 10px rgba(2, 6, 18, 0.55);
}

.btn--ghost {
  background: rgba(148, 178, 255, 0.06);
  border-color: var(--border);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset, var(--shadow-xs);
}

.btn--ghost:hover {
  background: rgba(148, 178, 255, 0.11);
}

.btn--danger {
  color: #ffe4e6;
  background: linear-gradient(180deg, #fb7185, #e11d48);
  border-color: rgba(251, 113, 133, 0.5);
}

.btn--sm {
  padding: 0.45rem 0.8rem;
  font-size: var(--font-size-xs);
  border-radius: var(--radius-sm);
}

.btn--lg {
  padding: 0.85rem 1.5rem;
  font-size: var(--font-size-base);
  border-radius: var(--radius-lg);
}

.btn--block {
  width: 100%;
}

.btn--icon {
  padding: 0.55rem;
  aspect-ratio: 1;
}

.btn svg {
  flex-shrink: 0;
}

/* Icon buttons in transport bar */
.transport-btn {
  width: 40px;
  height: 40px;
  display: inline-grid;
  place-items: center;
  border-radius: 50%;
  color: var(--text-1);
  background: linear-gradient(180deg, #1a2c52, #13233f);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-sm), 0 1px 0 rgba(255, 255, 255, 0.08) inset;
  transition: transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out), color var(--duration-fast);
}

.transport-btn:hover {
  transform: translateY(-2px);
  color: var(--text-0);
  box-shadow: var(--shadow-md);
}

.transport-btn:active {
  transform: translateY(1px);
}

.transport-btn--play {
  width: 48px;
  height: 48px;
  color: #03211d;
  background: linear-gradient(180deg, #5eead4, #14b8a6);
  border-color: rgba(94, 234, 212, 0.6);
  box-shadow: 0 6px 18px rgba(45, 212, 191, 0.3);
}

.transport-btn--play:hover {
  color: #03211d;
}

/* --------------------------------------------------------------------------
   7. Header & navigation
   -------------------------------------------------------------------------- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--header-height);
  background: rgba(7, 13, 26, 0.78);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.site-header__inner {
  height: 100%;
  display: flex;
  align-items: center;
  gap: var(--space-6);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-0);
  font-weight: 800;
  font-size: var(--font-size-lg);
  letter-spacing: -0.02em;
  text-decoration: none;
  flex-shrink: 0;
}

.brand:hover {
  text-decoration: none;
  color: var(--text-0);
}

.brand__logo {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  filter: drop-shadow(0 4px 10px rgba(45, 212, 191, 0.35));
}

.brand__mark {
  display: inline-flex;
  flex-direction: column;
  line-height: 1.05;
}

/* "House of Mehanga" above the tool name — 3D extruded gold, clearly
 * visible on the midnight-navy header (added Nov 2026 at the user's
 * request; it supersedes the earlier "FrameSync Studio only" rule). */
.brand__house {
  display: block;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.15;
  color: #FFD166;
  text-shadow:
    0 1px 0 #B97F16,
    0 2px 0 #9A6A10,
    0 3px 0 #7A5408,
    0 4px 0 #5C3F06,
    0 6px 12px rgba(0, 0, 0, 0.55);
}

.brand__mark small {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
}

.main-nav {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-left: var(--space-2);
}

.main-nav a,
.main-nav button {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: 0.5rem 0.85rem;
  border-radius: var(--radius-md);
  color: var(--text-2);
  font-size: var(--font-size-sm);
  font-weight: 600;
  text-decoration: none;
  border: 1px solid transparent;
  transition: color var(--duration-fast), background var(--duration-fast),
    border-color var(--duration-fast);
}

.main-nav a:hover,
.main-nav button:hover {
  color: var(--text-0);
  background: rgba(148, 178, 255, 0.08);
  text-decoration: none;
}

.main-nav a[aria-current="page"],
.main-nav a.is-active {
  color: var(--text-0);
  background: rgba(45, 212, 191, 0.12);
  border-color: rgba(45, 212, 191, 0.28);
}

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

.auth-status {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-2);
  padding: 0.4rem 0.75rem;
  border-radius: var(--radius-pill);
  background: rgba(148, 178, 255, 0.06);
  border: 1px solid var(--border);
}

.auth-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(251, 191, 36, 0.18);
  flex-shrink: 0;
}

.auth-status--signed-in .auth-status__dot {
  background: var(--green);
  box-shadow: 0 0 0 3px rgba(52, 211, 153, 0.18);
}

.auth-status--local .auth-status__dot {
  background: var(--amber);
}

/* --------------------------------------------------------------------------
   8. Layout — app shell, views, dashboard grid
   -------------------------------------------------------------------------- */
.app {
  min-height: calc(100vh - var(--header-height));
  display: flex;
  flex-direction: column;
}

.app-main {
  flex: 1;
  width: 100%;
  max-width: var(--max-width-wide);
  margin-inline: auto;
  padding: var(--space-8) var(--space-6) var(--space-16);
}

.view {
  animation: view-in var(--duration-slow) var(--ease-out);
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-6);
}

.page-head h1 {
  font-size: var(--font-size-3xl);
}

.page-head p {
  margin-top: var(--space-2);
  max-width: 62ch;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: var(--space-5);
}

.dashboard-grid__main {
  grid-column: span 8;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

.dashboard-grid__side {
  grid-column: span 4;
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

.project-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: var(--space-4);
}

.project-card {
  padding: var(--space-5);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  cursor: pointer;
  text-align: left;
  color: inherit;
}

.project-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--font-size-xs);
  color: var(--text-3);
}

.project-card h3 {
  font-size: var(--font-size-base);
}

.project-card p {
  font-size: var(--font-size-sm);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  padding: var(--space-12) var(--space-6);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
}

.empty-state__icon {
  width: 64px;
  height: 64px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-xl);
  background: var(--teal-dim);
  color: var(--teal);
  border: 1px solid rgba(45, 212, 191, 0.28);
}

.empty-state h2 {
  font-size: var(--font-size-xl);
}

.empty-state p {
  max-width: 48ch;
  font-size: var(--font-size-sm);
}

.stat-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-3);
}

.stat {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  background: rgba(148, 178, 255, 0.05);
  border: 1px solid var(--border);
}

.stat__value {
  font-size: var(--font-size-2xl);
  font-weight: 800;
  color: var(--text-0);
  letter-spacing: -0.02em;
}

.stat__label {
  font-size: var(--font-size-xs);
  color: var(--text-3);
  margin-top: 2px;
}

/* --------------------------------------------------------------------------
   9. Studio — 3-column layout
   -------------------------------------------------------------------------- */
.studio-layout {
  display: grid;
  grid-template-columns: 300px minmax(0, 1fr) 320px;
  gap: var(--space-5);
  align-items: start;
}

.studio-layout__media,
.studio-layout__side {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

.studio-layout__center {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
  min-width: 0;
}

.studio-section-title {
  font-size: var(--font-size-sm);
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-3);
  margin-bottom: var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.studio-section-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Preview */
.preview-wrap {
  position: relative;
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  aspect-ratio: 16 / 9;
}

.preview-wrap canvas,
#preview-canvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
}

.preview-wrap--fit #preview-canvas {
  object-fit: contain;
}

.preview-wrap--fill #preview-canvas {
  object-fit: cover;
}

.preview-overlay {
  position: absolute;
  inset: auto 0 0 0;
  padding: var(--space-3) var(--space-4);
  background: linear-gradient(180deg, transparent, rgba(2, 6, 18, 0.82));
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  font-size: var(--font-size-sm);
  color: var(--text-1);
  pointer-events: none;
}

.preview-overlay strong {
  color: var(--text-0);
}

.transport-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
}

.transport-bar__seek {
  flex: 1;
  min-width: 140px;
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.transport-time {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-2);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

/* --------------------------------------------------------------------------
   10. Timeline, clips & waveform
   -------------------------------------------------------------------------- */
.timeline-panel {
  overflow: hidden;
}

.timeline-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  padding: var(--space-3) var(--space-5);
  border-bottom: 1px solid var(--border);
}

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

.timeline-toolbar__spacer {
  flex: 1;
}

.timeline-scroll {
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--bg-sunken);
}

.timeline-inner {
  min-width: 640px;
  position: relative;
}

#timeline {
  position: relative;
}

.waveform-wrap {
  position: relative;
  height: 72px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.05), transparent);
}

#waveform-canvas {
  width: 100%;
  height: 100%;
}

.playhead {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--teal);
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.7);
  pointer-events: none;
  z-index: 5;
}

.playhead::before {
  content: "";
  position: absolute;
  top: 0;
  left: -5px;
  border: 6px solid transparent;
  border-top: 8px solid var(--teal);
}

.clips-track {
  position: relative;
  min-height: 96px;
  padding: var(--space-3);
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
}

#clips {
  display: flex;
  gap: var(--space-2);
  align-items: stretch;
  width: 100%;
  min-height: 72px;
}

.clip {
  position: relative;
  flex-shrink: 0;
  min-width: 72px;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: grab;
  border: 1px solid rgba(139, 124, 255, 0.42);
  background: linear-gradient(180deg, rgba(139, 124, 255, 0.22), rgba(139, 124, 255, 0.08));
  box-shadow: var(--shadow-sm);
  transition: transform var(--duration-fast) var(--ease-out),
    box-shadow var(--duration-fast) var(--ease-out),
    border-color var(--duration-fast);
}

.clip:hover {
  transform: translateY(-2px);
  border-color: var(--violet-soft);
  box-shadow: var(--shadow-md), var(--shadow-glow-violet);
}

.clip:active {
  cursor: grabbing;
  transform: translateY(0);
}

.clip--active {
  border-color: var(--teal);
  background: linear-gradient(180deg, rgba(45, 212, 191, 0.26), rgba(45, 212, 191, 0.08));
  box-shadow: var(--shadow-md), var(--shadow-glow-teal);
}

.clip--unmapped {
  border-style: dashed;
  border-color: rgba(251, 191, 36, 0.55);
  background: rgba(251, 191, 36, 0.07);
}

.clip img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  aspect-ratio: 16 / 9;
}

.clip__label {
  position: absolute;
  inset: auto 0 0 0;
  padding: 0.3rem 0.45rem;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.3;
  color: #fff;
  background: linear-gradient(180deg, transparent, rgba(2, 6, 18, 0.88));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.clip__duration {
  position: absolute;
  top: 0.35rem;
  right: 0.35rem;
  padding: 0.1rem 0.35rem;
  border-radius: var(--radius-pill);
  background: rgba(2, 6, 18, 0.78);
  color: var(--text-1);
  font-family: var(--font-mono);
  font-size: 0.65rem;
}

.clip__handle {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 8px;
  cursor: ew-resize;
  background: transparent;
}

.clip__handle--left { left: 0; }
.clip__handle--right { right: 0; }

.timeline-ruler {
  display: flex;
  justify-content: space-between;
  padding: var(--space-2) var(--space-4);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-2);
  border-top: 1px solid var(--border);
}

.timeline-empty {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-3);
  font-size: var(--font-size-sm);
}

/* Zoom slider */
.zoom-control {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-xs);
  color: var(--text-3);
}

/* --------------------------------------------------------------------------
   11. Forms, inputs, selects, range
   -------------------------------------------------------------------------- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.form-group:last-child {
  margin-bottom: 0;
}

label,
.form-label {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-1);
}

.form-label--required::after {
  content: " *";
  color: var(--rose);
}

.form-hint {
  font-size: var(--font-size-xs);
  color: var(--text-3);
  line-height: 1.5;
}

.form-error {
  font-size: var(--font-size-xs);
  color: #fda4af;
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="search"],
input[type="url"],
textarea,
select,
.input {
  width: 100%;
  padding: 0.65rem 0.85rem;
  border-radius: var(--radius-md);
  background: rgba(5, 10, 20, 0.62);
  border: 1px solid var(--border-strong);
  color: var(--text-0);
  font-size: var(--font-size-sm);
  line-height: 1.5;
  box-shadow: inset 0 2px 6px rgba(2, 6, 18, 0.45);
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast),
    background var(--duration-fast);
}

input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
}

input:hover,
textarea:hover,
select:hover {
  border-color: var(--glass-border-bright);
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: inset 0 2px 6px rgba(2, 6, 18, 0.45), 0 0 0 3px rgba(45, 212, 191, 0.28);
  outline: none;
}

input:disabled,
textarea:disabled,
select:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"],
select[aria-invalid="true"] {
  border-color: var(--rose);
  box-shadow: 0 0 0 3px rgba(251, 113, 133, 0.2);
}

textarea {
  min-height: 140px;
  resize: vertical;
  line-height: var(--line-height-relaxed);
}

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 2.25rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%23a8b8d8' stroke-width='2'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  cursor: pointer;
}

select option {
  background: var(--bg-2);
  color: var(--text-1);
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: linear-gradient(90deg, var(--teal) var(--range-fill, 50%), #1e3258 var(--range-fill, 50%));
  box-shadow: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--teal-deep);
  box-shadow: 0 2px 8px rgba(2, 6, 18, 0.6);
  transition: transform var(--duration-fast) var(--ease-out);
}

input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

input[type="range"]::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  border: 3px solid var(--teal-deep);
  box-shadow: 0 2px 8px rgba(2, 6, 18, 0.6);
}

input[type="checkbox"],
input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--teal);
  flex-shrink: 0;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  color: var(--text-2);
  cursor: pointer;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.drop-hint {
  font-size: var(--font-size-xs);
  color: var(--text-3);
}

/* Progress */
.progress {
  width: 100%;
  height: 8px;
  border-radius: var(--radius-pill);
  background: #16294e;
  overflow: hidden;
  border: 1px solid var(--border);
}

.progress__bar {
  height: 100%;
  width: 0%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal-deep), var(--teal), var(--violet));
  transition: width var(--duration-slow) var(--ease-out);
}

.progress--indeterminate .progress__bar {
  width: 38% !important;
  animation: progress-slide 1.3s var(--ease-in-out) infinite;
}

@keyframes progress-slide {
  0% { transform: translateX(-110%); }
  100% { transform: translateX(280%); }
}

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

.progress-row .progress {
  flex: 1;
}

.progress-label {
  font-size: var(--font-size-xs);
  color: var(--text-2);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* --------------------------------------------------------------------------
   12. Sentence review & mapping
   -------------------------------------------------------------------------- */
.sentence-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-height: 420px;
  overflow-y: auto;
  padding-right: var(--space-1);
}

#sentence-review {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.sentence-row {
  display: grid;
  grid-template-columns: 2.25rem minmax(0, 1fr);
  gap: var(--space-3);
  align-items: start;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(148, 178, 255, 0.04);
  border: 1px solid var(--border);
  transition: border-color var(--duration-fast), background var(--duration-fast);
}

.sentence-row:hover {
  border-color: var(--glass-border-bright);
  background: rgba(148, 178, 255, 0.07);
}

.sentence-row--active {
  border-color: rgba(45, 212, 191, 0.45);
  background: var(--teal-dim);
}

.sentence-row--unmapped {
  border-style: dashed;
  border-color: rgba(251, 191, 36, 0.45);
}

.sentence-row__num {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-3);
  padding-top: 0.15rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.sentence-row__text {
  font-size: var(--font-size-sm);
  color: var(--text-1);
  line-height: 1.6;
  min-width: 0;
}

.sentence-row__meta {
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  font-size: var(--font-size-xs);
  color: var(--text-3);
}

.sentence-row__text {
  overflow-wrap: break-word;
}

.sentence-row--needs-review {
  border-color: rgba(251, 191, 36, 0.6);
}

.sentence-row__flag {
  grid-column: 2;
  font-size: var(--font-size-xs);
  color: #fbbf24;
}

/* Close match: real timing, a word or two differ. Blue, distinct from
   the amber needs-review flag — it is not a failure, and it is never
   presented as an exact match. */
.sentence-row--close-match {
  border-color: rgba(125, 211, 252, 0.45);
}

.sentence-row__flag--close {
  color: #7dd3fc;
}

/* Exact match: every script word was heard, with real timing. Green,
   distinct from blue close and amber needs-review — so the row shows
   the same verdict the banner counts. */
.sentence-row--exact-match {
  border-color: rgba(52, 211, 153, 0.45);
}

.sentence-row__flag--exact {
  color: var(--green);
}

/* Dashboard project list: each project is one obvious, tappable row.
   (Nov 2026: the list had NO styling at all — names rendered as plain
   text jammed against "Updated …", only Delete looked like a button,
   and only the tiny name was clickable, so users reported that no
   project would open.) */
#project-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.project-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg-1);
  cursor: pointer;
}

.project-item:hover,
.project-item:focus-visible {
  border-color: var(--teal);
  background: var(--teal-dim);
  outline: none;
}

.project-item-name {
  font-weight: 600;
  color: var(--text-0);
}

.project-item-meta {
  font-size: var(--font-size-sm);
  color: var(--text-2);
}

.project-item-delete {
  margin-left: auto;
  flex: none;
  padding: var(--space-1) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: var(--font-size-sm);
}

.project-item-delete:hover {
  border-color: var(--rose);
  color: var(--rose);
}

/* Alignment warning banner above the preview: shown when sentences
   have no timing, so the user learns the preview will hold the
   previous scene's image during those parts — before pressing Play. */
.alignment-warning {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  border: 1px solid rgba(251, 191, 36, 0.6);
  background: rgba(251, 191, 36, 0.08);
  color: #fcd34d;
  font-size: var(--font-size-sm);
  line-height: 1.6;
}

.alignment-warning .btn {
  flex-shrink: 0;
}

.alignment-warning__actions {
  display: flex;
  gap: var(--space-2);
  align-items: center;
  flex-shrink: 0;
}

.sentence-row__time {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--teal-soft);
  white-space: nowrap;
}

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

#mapping-ui {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.mapping-row {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr) auto;
  gap: var(--space-3);
  align-items: center;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: rgba(148, 178, 255, 0.04);
  border: 1px solid var(--border);
  font-size: var(--font-size-sm);
}

.mapping-num {
  font-family: var(--font-mono);
  font-size: var(--font-size-xs);
  color: var(--text-3);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.mapping-sentence-text {
  line-height: 1.6;
  min-width: 0;
  overflow-wrap: break-word;
}

.mapping-thumb--empty {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-3);
  border-style: dashed;
  background: transparent;
}

.mapping-row__arrow {
  color: var(--teal);
  flex-shrink: 0;
}

.mapping-row__thumb {
  width: 64px;
  height: 36px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid var(--border-strong);
  flex-shrink: 0;
}

.mapping-row select {
  grid-column: 1 / -1;
  padding: 0.45rem 2rem 0.45rem 0.65rem;
  font-size: var(--font-size-xs);
}

/* Timeline clips rendered by timeline.js (framesync-* classes, not the
   .clip classes above): clamp the sentence label to two lines and keep
   the time inputs inside the clip, or long sentences spill over the
   clip boundaries. Labels and times are deliberately large enough to
   read at a glance (Nov 2026: "timeline saaf honi chahiye"). */
.framesync-clip-thumb {
  display: block;
  width: 100%;
  height: 54px;
  object-fit: cover;
  flex: none;
}

.framesync-clip-label {
  padding: 0.35rem 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.35;
  color: #fff;
  background: linear-gradient(180deg, transparent, rgba(2, 6, 18, 0.88));
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: break-word;
}

.framesync-clip-times {
  display: flex;
  gap: 0.25rem;
  padding: 0.3rem 0.4rem;
  align-items: center;
}

.framesync-clip-times input {
  width: 4.8rem;
  min-width: 0;
  padding: 0.2rem 0.3rem;
  font-size: 0.75rem;
}

/* Selected clip: unmistakable teal border + glow, so the scene being
   previewed is obvious in the strip. */
.framesync-clip.is-active {
  border-color: var(--teal) !important;
  box-shadow: 0 0 0 1px var(--teal), var(--shadow-glow-teal);
}

/* Drag handles: faintly visible at rest, solid on hover, so trimming
   is discoverable without hunting for the clip edge. */
.framesync-clip-handle {
  background: rgba(139, 124, 255, 0.18);
}
.framesync-clip:hover .framesync-clip-handle {
  background: rgba(139, 124, 255, 0.55);
}

/* Clip action buttons: compact, contained — they used to spill below
   the clip rectangles on narrow clips. */
.framesync-clip {
  display: flex;
  flex-direction: column;
}

/* Narrow clips show only the scene number: even "Scene 1" wraps
   mid-word ("Scen / e 1") at 49px, and the time inputs are unreadable
   there anyway. Full sentence + times stay in the clip's title. */
.framesync-clip--narrow .framesync-clip-label {
  white-space: nowrap;
  text-align: center;
  padding: 0.3rem 0.1rem;
}

.framesync-clip--narrow .framesync-clip-times {
  display: none;
}

.framesync-clip-lock,
.framesync-clip-replace {
  display: block;
  width: 100%;
  min-width: 0;
  padding: 0.2rem 0.4rem;
  font-size: 0.72rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
  background: rgba(2, 6, 18, 0.55);
  color: var(--text-2);
  border: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  cursor: pointer;
}

/* --------------------------------------------------------------------------
   13. Export bar, banners & status
   -------------------------------------------------------------------------- */
.export-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  padding: var(--space-4) var(--space-5);
  border-top: 1px solid var(--border);
  background: rgba(5, 10, 20, 0.35);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.export-bar__group {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.export-bar__divider {
  width: 1px;
  height: 28px;
  background: var(--border);
  margin-inline: var(--space-2);
}

/* Persistent export status: toasts vanish after 4s, so a 30s+ render
   needs a status line that stays readable until the next export. */
.export-status {
  flex-basis: 100%;
  margin: 0;
  min-height: 1.2em;
}

/* Export options row (Nov 2026): quality 720p-4K + auto captions. */
.export-options {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  flex-basis: 100%;
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.export-option {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--text-1);
}

.export-option select {
  padding: 0.35rem 0.5rem;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
  color: var(--text-0);
  font-size: var(--font-size-sm);
}

/* The caption-size slider sits inside its export-option label: keep
   it short so the export row stays on one line. */
.export-option input[type="range"] {
  width: 9rem;
}

.export-option--check {
  cursor: pointer;
}

.export-option--check input {
  width: 1rem;
  height: 1rem;
  accent-color: var(--teal);
}

/* Caption style preview: a live demo of the selected template, drawn
 * on a canvas so the user can see how it looks before rendering. */
.caption-preview {
  flex-basis: 100%;
  padding-top: var(--space-3);
}

.caption-preview canvas {
  display: block;
  width: 100%;
  max-width: 480px;
  aspect-ratio: 16 / 9;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0a1128;
}

.caption-preview__label {
  margin-top: var(--space-2);
}

.caption-preview__nav {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin-top: var(--space-2);
}

/* Video captions: generate captions from a video's own audio. */
.video-captions__row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  margin-top: var(--space-3);
}

#video-preview {
  display: block;
  width: 100%;
  max-width: 480px;
  margin-top: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #0a1128;
}

/* Captions playing ON the video preview: the overlay sits over the
 * video and shows the caption spoken at the current playhead, styled
 * from the panel's chosen template (font, colour, background) so
 * changing the style changes the captions on the video live. */
.video-preview-wrap {
  position: relative;
  width: 100%;
  max-width: 480px;
  margin-top: var(--space-3);
}

.video-preview-wrap #video-preview {
  margin-top: 0;
  max-width: 100%;
}

.video-caption-overlay {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 7%;
  text-align: center;
  pointer-events: none;
  font-weight: 800;
  line-height: 1.25;
  padding: 0.15em 0.5em;
  border-radius: 0.35em;
  white-space: pre-wrap;
}

/* Generated-captions list inside the captions modal. */
.captions-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

.caption-row {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-2);
}

.caption-row__num {
  font-weight: 700;
  color: var(--text-3);
  min-width: 1.5rem;
}

.caption-row__time {
  font-size: var(--font-size-sm);
  color: var(--text-3);
  white-space: nowrap;
}

.caption-row__text {
  font-size: var(--font-size-sm);
  color: var(--text-0);
}

.helper-status {
  font-size: var(--font-size-xs);
  color: var(--text-3);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-left: auto;
}

.helper-status__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

.helper-status--ok .helper-status__dot {
  background: var(--green);
}

.helper-status--error .helper-status__dot {
  background: var(--rose);
}

.helper-status--busy .helper-status__dot {
  background: var(--amber);
  animation: pulse-dot 1.1s ease-in-out infinite;
}

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

.banner {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-5);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border-strong);
  background: rgba(148, 178, 255, 0.06);
  font-size: var(--font-size-sm);
  line-height: 1.6;
}

.banner--local {
  background: rgba(251, 191, 36, 0.08);
  border-color: rgba(251, 191, 36, 0.35);
}

.banner--info {
  background: rgba(96, 165, 250, 0.08);
  border-color: rgba(96, 165, 250, 0.35);
}

.banner--success {
  background: rgba(52, 211, 153, 0.08);
  border-color: rgba(52, 211, 153, 0.35);
}

.banner strong {
  color: var(--text-0);
}

.banner__icon {
  flex-shrink: 0;
  margin-top: 2px;
}

#local-mode-banner {
  margin-bottom: var(--space-5);
}

/* --------------------------------------------------------------------------
   14. Modal
   -------------------------------------------------------------------------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 150;
  background: rgba(2, 6, 18, 0.72);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-4);
  animation: fade-in var(--duration-normal) var(--ease-out);
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: 100%;
  max-width: 520px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border-bright);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xl);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  animation: modal-in var(--duration-normal) var(--ease-out);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: var(--space-5) var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.modal__header h2 {
  font-size: var(--font-size-lg);
}

.modal__body {
  padding: var(--space-5) var(--space-6);
}

.modal__footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-6);
  border-top: 1px solid var(--border);
}

.modal__close {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-md);
  color: var(--text-2);
  border: 1px solid transparent;
  transition: background var(--duration-fast), color var(--duration-fast);
}

.modal__close:hover {
  background: rgba(148, 178, 255, 0.1);
  color: var(--text-0);
}

/* --------------------------------------------------------------------------
   15. Toast
   -------------------------------------------------------------------------- */
#toast-root {
  position: fixed;
  bottom: var(--space-6);
  right: var(--space-6);
  z-index: 180;
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: min(92vw, 380px);
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--glass-bg-strong);
  border: 1px solid var(--glass-border-bright);
  box-shadow: var(--shadow-lg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  font-size: var(--font-size-sm);
  color: var(--text-1);
  animation: toast-in var(--duration-normal) var(--ease-out);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.toast--leaving {
  opacity: 0;
  transform: translateY(6px);
  transition: opacity var(--duration-normal), transform var(--duration-normal);
}

.toast--success {
  border-color: rgba(52, 211, 153, 0.45);
}

.toast--error {
  border-color: rgba(251, 113, 133, 0.5);
}

.toast--info {
  border-color: rgba(96, 165, 250, 0.45);
}

.toast strong {
  color: var(--text-0);
}

.toast__icon {
  flex-shrink: 0;
  margin-top: 1px;
}

.toast--success .toast__icon { color: var(--green); }
.toast--error .toast__icon { color: var(--rose); }
.toast--info .toast__icon { color: var(--blue); }

/* --------------------------------------------------------------------------
   16. Login view
   -------------------------------------------------------------------------- */
.auth-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: var(--space-8);
  align-items: start;
  max-width: 1020px;
  margin-inline: auto;
}

.auth-card {
  padding: var(--space-8);
}

.auth-card h1 {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-2);
}

.auth-card > p {
  margin-bottom: var(--space-6);
}

.auth-tabs {
  display: flex;
  gap: var(--space-2);
  margin-bottom: var(--space-6);
}

.auth-tabs .btn {
  flex: 1;
}

.auth-tabs .btn.is-active {
  border-color: var(--teal);
  color: var(--text-0);
  background: var(--teal-dim);
}

.auth-notice {
  font-size: var(--font-size-sm);
  color: var(--green);
  background: rgba(52, 211, 153, 0.08);
  border: 1px solid rgba(52, 211, 153, 0.3);
  border-radius: var(--radius-md);
  padding: var(--space-3) var(--space-4);
}

/* "or" divider between password sign-in and Google sign-in. */
.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-5) 0;
  color: var(--text-3);
  font-size: var(--font-size-sm);
}
.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* Google sign-in: white button, dark text — recognisably Google. */
.btn--google {
  background: #fff;
  color: #1f1f1f;
  border: 1px solid #dadce0;
}
.btn--google:hover {
  background: #f8f9fa;
  border-color: #c6c9ce;
}
.btn--google:disabled {
  opacity: 0.6;
  cursor: wait;
}

.auth-side h2 {
  font-size: var(--font-size-xl);
  margin-bottom: var(--space-3);
}

.auth-side ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin-top: var(--space-4);
}

.auth-side li {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
  font-size: var(--font-size-sm);
  color: var(--text-2);
  line-height: 1.6;
}

.auth-side li svg {
  flex-shrink: 0;
  margin-top: 2px;
  color: var(--teal);
}

/* --------------------------------------------------------------------------
   17. Landing page
   -------------------------------------------------------------------------- */
.landing-hero {
  padding: var(--space-16) 0 var(--space-12);
  text-align: center;
}

.landing-hero__eyebrow {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-5);
}

.landing-hero h1 {
  font-size: clamp(2.25rem, 5.5vw, 3.75rem);
  max-width: 18ch;
  margin-inline: auto;
  line-height: 1.08;
}

.landing-hero h1 .gradient-text {
  background: linear-gradient(92deg, var(--teal-soft), var(--teal) 38%, var(--violet-soft));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.landing-hero p {
  max-width: 62ch;
  margin: var(--space-5) auto 0;
  font-size: var(--font-size-lg);
  line-height: 1.65;
}

.landing-hero__actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  flex-wrap: wrap;
  margin-top: var(--space-8);
}

.landing-hero__note {
  margin-top: var(--space-4);
  font-size: var(--font-size-sm);
}

.feature-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-8);
}

.feature-card {
  padding: var(--space-6);
}

.feature-card__icon {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border-radius: var(--radius-lg);
  background: var(--teal-dim);
  color: var(--teal);
  border: 1px solid rgba(45, 212, 191, 0.28);
  margin-bottom: var(--space-4);
}

.feature-card:nth-child(2) .feature-card__icon {
  background: var(--violet-dim);
  color: var(--violet-soft);
  border-color: rgba(139, 124, 255, 0.3);
}

.feature-card h3 {
  font-size: var(--font-size-lg);
  margin-bottom: var(--space-2);
}

.feature-card p {
  font-size: var(--font-size-sm);
  line-height: 1.65;
}

.landing-section {
  padding: var(--space-10) 0;
}

.landing-section h2 {
  font-size: var(--font-size-2xl);
  text-align: center;
  margin-bottom: var(--space-2);
}

.landing-section > p {
  text-align: center;
  max-width: 58ch;
  margin-inline: auto;
}

.how-it-works {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-5);
  margin-top: var(--space-8);
  counter-reset: step;
}

.how-step {
  padding: var(--space-6);
  position: relative;
}

.how-step::before {
  counter-increment: step;
  content: counter(step, decimal-leading-zero);
  display: block;
  font-family: var(--font-mono);
  font-size: var(--font-size-sm);
  font-weight: 700;
  color: var(--teal);
  margin-bottom: var(--space-3);
}

.how-step h3 {
  font-size: var(--font-size-base);
  margin-bottom: var(--space-2);
}

.how-step p {
  font-size: var(--font-size-sm);
  line-height: 1.65;
}

.cta-band {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  background:
    radial-gradient(420px 200px at 50% 0%, rgba(45, 212, 191, 0.14), transparent 70%),
    var(--glass-bg);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

.cta-band h2 {
  font-size: var(--font-size-2xl);
  margin-bottom: var(--space-3);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: var(--space-8) 0 var(--space-10);
  margin-top: var(--space-12);
  color: var(--text-3);
  font-size: var(--font-size-sm);
}

.site-footer__inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.site-footer__build {
  opacity: 0.6;
  font-size: 0.8rem;
}

.site-footer nav {
  display: flex;
  gap: var(--space-5);
  flex-wrap: wrap;
}

.site-footer a {
  color: var(--text-2);
}

/* --------------------------------------------------------------------------
   18. Misc components
   -------------------------------------------------------------------------- */
.divider {
  height: 1px;
  background: var(--border);
  margin: var(--space-6) 0;
}

.tag-list {
  display: flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.spinner {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.25);
  border-top-color: currentColor;
  animation: spin 0.8s linear infinite;
  flex-shrink: 0;
}

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

.spinner--lg {
  width: 28px;
  height: 28px;
  border-width: 3px;
}

.inline-icon {
  display: inline-block;
  vertical-align: -3px;
  flex-shrink: 0;
}

.audio-player {
  width: 100%;
}

audio {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-md);
}

audio::-webkit-media-controls-panel {
  background: #122242;
}

/* --------------------------------------------------------------------------
   19. Breakpoints — 1100px
   -------------------------------------------------------------------------- */
@media (max-width: 1100px) {
  .studio-layout {
    grid-template-columns: 260px minmax(0, 1fr);
  }

  .studio-layout__side {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: start;
  }

  .dashboard-grid__main,
  .dashboard-grid__side {
    grid-column: span 12;
  }

  .feature-grid,
  .how-it-works {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .feature-grid .feature-card:last-child,
  .how-it-works .how-step:last-child {
    grid-column: span 2;
  }

  .auth-layout {
    grid-template-columns: 1fr;
    gap: var(--space-6);
  }

  .app-main {
    padding: var(--space-6) var(--space-5) var(--space-12);
  }
}

/* --------------------------------------------------------------------------
   20. Breakpoints — 720px
   -------------------------------------------------------------------------- */
@media (max-width: 720px) {
  :root {
    --header-height: 60px;
  }

  .container {
    padding-inline: var(--space-4);
  }

  .site-header__inner {
    gap: var(--space-3);
  }

  .brand {
    font-size: var(--font-size-base);
  }

  .brand__mark small {
    display: none;
  }

  .brand__house {
    font-size: 0.95rem;
  }

  .main-nav {
    margin-left: 0;
    gap: 0;
  }

  .main-nav a,
  .main-nav button {
    padding: 0.45rem 0.6rem;
    font-size: var(--font-size-xs);
  }

  .main-nav .nav-label {
    display: none;
  }

  .auth-status__text {
    display: none;
  }

  .app-main {
    padding: var(--space-5) var(--space-4) var(--space-10);
  }

  .page-head h1 {
    font-size: var(--font-size-2xl);
  }

  .studio-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .studio-layout__side {
    grid-template-columns: minmax(0, 1fr);
  }

  .feature-grid,
  .how-it-works {
    grid-template-columns: minmax(0, 1fr);
  }

  .feature-grid .feature-card:last-child,
  .how-it-works .how-step:last-child {
    grid-column: auto;
  }

  .stat-row {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .panel__body,
  .auth-card {
    padding: var(--space-5);
  }

  .transport-bar {
    padding: var(--space-3) var(--space-4);
  }

  .transport-bar__seek {
    order: 10;
    flex-basis: 100%;
  }

  .export-bar {
    padding: var(--space-3) var(--space-4);
  }

  .helper-status {
    margin-left: 0;
    flex-basis: 100%;
  }

  .mapping-row {
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-2);
  }

  .mapping-row__arrow {
    transform: rotate(90deg);
    justify-self: center;
  }

  .sentence-row {
    grid-template-columns: 1.75rem minmax(0, 1fr);
  }

  .sentence-row__meta {
    grid-column: 2;
  }

  .modal {
    max-height: 92vh;
  }

  #toast-root {
    left: var(--space-4);
    right: var(--space-4);
    bottom: var(--space-4);
    max-width: none;
  }

  .landing-hero {
    padding: var(--space-10) 0 var(--space-8);
  }

  .landing-hero p {
    font-size: var(--font-size-base);
  }

  .site-footer__inner {
    flex-direction: column;
    align-items: flex-start;
  }
}

/* --------------------------------------------------------------------------
   20. Silence Cut panel
   -------------------------------------------------------------------------- */
.silence-cut-panel {
  margin-top: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: rgba(10, 20, 40, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.silence-cut-panel__toggle {
  font-size: var(--font-size-sm);
  color: var(--text-1);
}

.silence-cut-panel__controls {
  margin-top: var(--space-3);
  display: none;
  flex-direction: column;
  gap: var(--space-3);
}

.silence-cut-panel.is-enabled .silence-cut-panel__controls {
  display: flex;
}

.silence-cut-panel__controls .form-group {
  margin-bottom: 0;
}

.silence-cut-summary {
  font-size: var(--font-size-sm);
  font-weight: 600;
  color: var(--teal);
  margin: 0;
}

.silence-cut-summary:empty,
.silence-cut-summary--muted {
  color: var(--text-3);
  font-weight: 400;
}

.silence-regions-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: var(--font-size-xs);
  color: var(--text-3);
  max-height: 7.5rem;
  overflow-y: auto;
}

.silence-regions-list li {
  display: flex;
  justify-content: space-between;
  gap: var(--space-2);
  padding: 0.2rem 0;
  border-bottom: 1px solid var(--border);
}

.silence-regions-list li:last-child {
  border-bottom: 0;
}

/* --------------------------------------------------------------------------
   21. Print
   -------------------------------------------------------------------------- */
@media print {
  body {
    background: #fff;
    color: #111;
  }

  .site-header,
  .transport-bar,
  .export-bar,
  #toast-root,
  .btn {
    display: none !important;
  }
}
