/* ─────────────────────────────────────────────────────────
   video-agent · Claude-inspired design system
   Warm cream palette · serif headlines · sans body
   ───────────────────────────────────────────────────────── */

:root {
  /* Surfaces */
  --bg: #faf9f5;
  --bg-elevated: #ffffff;
  --bg-subtle: #f5f1e9;
  --bg-hover: #efe9dc;
  --bg-input: #ffffff;

  /* Text */
  --text: #1f1d1a;
  --text-muted: #6b6660;
  --text-subtle: #9b958d;
  --text-on-accent: #ffffff;

  /* Borders */
  --border: #e7e4dd;
  --border-strong: #d3cfc5;
  --border-focus: #d97757;

  /* Accent (Anthropic warm orange) */
  --accent: #c96442;
  --accent-hover: #b15535;
  --accent-soft: #f8efe7;
  --accent-soft-hover: #f1e3d4;

  /* Semantic */
  --success: #5b8a72;
  --success-soft: #e9f1ec;
  --warning: #c89856;
  --warning-soft: #faf2e3;
  --danger: #a04a3f;
  --danger-soft: #f5e6e2;

  /* Shadows (warm, not blue-tinted) */
  --shadow-xs: 0 1px 2px rgba(31, 29, 26, 0.04);
  --shadow-sm: 0 1px 3px rgba(31, 29, 26, 0.06), 0 1px 2px rgba(31, 29, 26, 0.04);
  --shadow-md: 0 4px 12px rgba(31, 29, 26, 0.06), 0 2px 4px rgba(31, 29, 26, 0.04);
  --shadow-lg: 0 12px 32px rgba(31, 29, 26, 0.08), 0 4px 8px rgba(31, 29, 26, 0.04);

  /* Radii */
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 20px;
  --r-pill: 999px;

  /* Spacing scale (4px base) */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  --s-20: 80px;

  /* Type */
  --font-serif: 'Tiempos Headline', 'Source Serif 4', ui-serif, 'Iowan Old Style', 'Georgia', serif;
  --font-sans: 'Söhne', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'Söhne Mono', 'JetBrains Mono', ui-monospace, 'SF Mono', 'Consolas', monospace;

  /* Motion */
  --ease: cubic-bezier(0.32, 0.72, 0.27, 1);
  --t-fast: 120ms var(--ease);
  --t-base: 200ms var(--ease);
  --t-slow: 360ms var(--ease);
}

/* ─────────────────────────── Dark theme ─────────────────────────── */
[data-theme="dark"] {
  /* Surfaces — warm dark espresso (matches Claude.ai dark) */
  --bg: #1c1a17;
  --bg-elevated: #262320;
  --bg-subtle: #221f1c;
  --bg-hover: #2e2a26;
  --bg-input: #221f1c;

  /* Text */
  --text: #f5f0ea;
  --text-muted: #b3aca3;
  --text-subtle: #6f6862;
  --text-on-accent: #1c1a17;

  /* Borders */
  --border: rgba(255, 245, 235, 0.07);
  --border-strong: rgba(255, 245, 235, 0.15);
  --border-focus: #e58869;

  /* Accent — slightly brighter for dark background */
  --accent: #e58869;
  --accent-hover: #d97757;
  --accent-soft: rgba(229, 136, 105, 0.12);
  --accent-soft-hover: rgba(229, 136, 105, 0.20);

  /* Semantic */
  --success: #7aa68a;
  --success-soft: rgba(122, 166, 138, 0.12);
  --warning: #d9a96a;
  --warning-soft: rgba(217, 169, 106, 0.12);
  --danger: #c9655a;
  --danger-soft: rgba(201, 101, 90, 0.14);

  /* Shadows */
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.4);
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.5), 0 1px 2px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.5), 0 2px 4px rgba(0,0,0,0.3);
  --shadow-lg: 0 12px 32px rgba(0,0,0,0.6), 0 4px 8px rgba(0,0,0,0.3);
}

/* Smooth theme transition (skip on initial paint via `.theme-ready`) */
.theme-ready,
.theme-ready * {
  transition:
    background-color 200ms ease,
    border-color 200ms ease,
    color 200ms ease,
    box-shadow 200ms ease;
}

/* Dark-specific tweaks */
[data-theme="dark"] .topbar {
  background: rgba(28, 26, 23, 0.85);
}
[data-theme="dark"] .select {
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23b3aca3' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
[data-theme="dark"] .ambient::before {
  opacity: 0.35;
  background: radial-gradient(circle, rgba(229, 136, 105, 0.25), transparent 70%);
}
[data-theme="dark"] .ambient::after {
  opacity: 0.2;
  background: radial-gradient(circle, rgba(86, 124, 168, 0.2), transparent 70%);
}
[data-theme="dark"] .toast { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border-strong); }
[data-theme="dark"] .btn-primary { background: var(--text); color: var(--bg); }
[data-theme="dark"] .btn-primary:hover:not(:disabled) { background: #e8e3dc; }
[data-theme="dark"] .screenplay-card {
  background: linear-gradient(135deg, var(--bg-elevated), rgba(229,136,105,0.04) 200%);
}

/* ─────────────────────────── Reset ─────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-feature-settings: 'ss01', 'cv11';
  font-size: 0.9375rem; /* 15px */
  line-height: 1.55;
  letter-spacing: -0.005em;
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { border: 0; background: transparent; cursor: pointer; }
a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }

::selection { background: var(--accent-soft); color: var(--accent); }

/* ─────────── Accessibility: focus rings ─────────── */
*:focus { outline: none; }
*:focus-visible {
  outline: 2px solid var(--border-focus);
  outline-offset: 2px;
  border-radius: var(--r-sm);
}
.btn:focus-visible,
.input:focus-visible,
.select:focus-visible,
.textarea:focus-visible,
.pill:focus-visible,
.aspect-card:focus-visible,
.preset-card:focus-visible,
.nav-item:focus-visible,
.lang-btn:focus-visible,
.theme-btn:focus-visible,
.shot-card:focus-visible {
  outline-offset: 3px;
  box-shadow: 0 0 0 3px var(--accent-soft);
}

/* Skip-to-content link (keyboard users) */
.skip-link {
  position: absolute;
  top: -100px;
  left: 16px;
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  z-index: 1000;
  transition: top var(--t-fast);
}
.skip-link:focus { top: 12px; }

/* ─────────────────────────── Ambient ─────────────────────────── */
.ambient {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden;
}
.ambient::before, .ambient::after {
  content: ''; position: absolute; border-radius: 50%;
  filter: blur(80px); opacity: 0.5;
}
.ambient::before {
  top: -10%; left: -10%; width: 50vw; height: 50vw;
  background: radial-gradient(circle, rgba(217, 119, 87, 0.18), transparent 70%);
  animation: drift 32s ease-in-out infinite;
}
.ambient::after {
  bottom: -20%; right: -15%; width: 60vw; height: 60vw;
  background: radial-gradient(circle, rgba(216, 178, 124, 0.12), transparent 70%);
  animation: drift 40s ease-in-out infinite reverse;
}
@keyframes drift {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(4%, 6%) scale(1.06); }
}

/* ─────────────────────────── Layout shell ─────────────────────────── */
.app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  background: var(--bg-subtle);
  border-right: 1px solid var(--border);
  padding: var(--s-6) var(--s-4);
  display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.sidebar-brand {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); margin-bottom: var(--s-8);
}
.sidebar-brand .mark {
  width: 30px; height: 30px;
  background: var(--accent);
  color: white;
  border-radius: var(--r-md);
  display: grid; place-items: center;
  position: relative;
  box-shadow: 0 4px 16px rgba(201, 100, 66, 0.25);
}
.sidebar-brand .mark::after {
  content: '';
  position: absolute; inset: -2px;
  border-radius: inherit;
  background: var(--accent);
  filter: blur(10px);
  opacity: 0.3;
  z-index: -1;
}
.sidebar-brand .mark svg {
  animation: shimmer 4s ease-in-out infinite;
}
@keyframes shimmer {
  0%, 100% { opacity: 1; transform: rotate(0deg) scale(1); }
  50% { opacity: 0.85; transform: rotate(45deg) scale(1.05); }
}
.sidebar-brand .name {
  font-family: var(--font-serif);
  font-size: 19px;
  letter-spacing: -0.02em;
  font-weight: 500;
}

.nav { display: flex; flex-direction: column; gap: 2px; }
.nav-item {
  display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-3) var(--s-3);
  border-radius: var(--r-md);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  transition: background var(--t-fast), color var(--t-fast);
  cursor: pointer; user-select: none;
}
.nav-item:hover { background: var(--bg-hover); color: var(--text); }
.nav-item.active { background: var(--bg-elevated); color: var(--text); box-shadow: var(--shadow-xs); }
.nav-item .icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.85; }

.sidebar-footer {
  margin-top: auto;
  padding: var(--s-3);
  border-top: 1px solid var(--border);
}
.sidebar-footer .meta {
  font-size: 11px;
  color: var(--text-subtle);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
}

/* Main */
.main {
  min-width: 0;
  display: flex; flex-direction: column;
}
.topbar {
  height: 56px;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center;
  padding: 0 var(--s-8);
  gap: var(--s-4);
  background: rgba(250, 249, 245, 0.85);
  backdrop-filter: blur(12px);
  position: sticky; top: 0; z-index: 10;
}
.topbar-title { font-size: 14px; font-weight: 500; color: var(--text-muted); }
.topbar-spacer { flex: 1; }

/* Theme toggle button */
.theme-btn {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  cursor: pointer;
  transition: all var(--t-fast);
  color: var(--text-muted);
}
.theme-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
  color: var(--text);
}
.theme-btn svg {
  width: 14px; height: 14px;
  transition: transform 240ms var(--ease);
}
.theme-btn:hover svg { transform: rotate(15deg); }

/* Language switcher */
.lang-switcher {
  display: inline-flex;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-pill);
  padding: 2px;
  gap: 1px;
}
.lang-btn {
  padding: 5px 12px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--text-subtle);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: all var(--t-fast);
  font-family: inherit;
  min-width: 32px;
  text-align: center;
}
.lang-btn:hover {
  color: var(--text);
  background: var(--bg-hover);
}
.lang-btn.active {
  background: var(--bg-elevated);
  color: var(--accent);
  box-shadow: var(--shadow-xs);
}

.content {
  padding: var(--s-12) var(--s-8) var(--s-20);
  max-width: 920px;
  width: 100%;
  margin: 0 auto;
}

/* ─────────────────────────── Hero ─────────────────────────── */
.hero {
  margin-bottom: var(--s-12);
  text-align: center;
  padding: var(--s-8) 0 var(--s-6);
}
.hero-eyebrow {
  display: inline-flex; align-items: center; gap: var(--s-2);
  padding: 5px 12px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: 0.01em;
  margin-bottom: var(--s-5);
}
.hero-eyebrow .dot {
  width: 6px; height: 6px;
  background: var(--accent);
  border-radius: 50%;
  animation: breathe 2.4s var(--ease) infinite;
}
@keyframes breathe {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.7); }
}

.hero h1 {
  font-family: var(--font-serif);
  font-size: clamp(34px, 5vw, 48px);
  font-weight: 400;
  line-height: 1.08;
  letter-spacing: -0.025em;
  color: var(--text);
  margin-bottom: var(--s-4);
}
.hero h1 em {
  font-style: italic;
  color: var(--accent);
}
.hero p {
  font-size: 17px;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.55;
}

/* ─────────────────────────── Card ─────────────────────────── */
.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-8);
  margin-bottom: var(--s-5);
  box-shadow: var(--shadow-xs);
  transition: border-color var(--t-base), box-shadow var(--t-base);
}
.card:hover { border-color: var(--border-strong); }
.card-header {
  display: flex; align-items: baseline;
  gap: var(--s-3);
  margin-bottom: var(--s-6);
  padding-bottom: var(--s-4);
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: var(--font-serif);
  font-size: 19px; font-weight: 500;
  letter-spacing: -0.015em;
}
.card-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}
.card-step-num {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-subtle);
  letter-spacing: 0.02em;
  margin-right: auto;
}

/* ─────────────────────────── Form ─────────────────────────── */
.field { margin-bottom: var(--s-5); }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: var(--s-2);
  letter-spacing: -0.005em;
}
.field-label .req { color: var(--accent); margin-left: 2px; }
.field-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.5;
}
.field-error {
  font-size: 12px; color: var(--danger);
  margin-top: 6px;
}

.input, .select, .textarea {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text);
  transition: border-color var(--t-fast), box-shadow var(--t-fast), background var(--t-fast);
  outline: none;
}
.input:hover, .select:hover, .textarea:hover { border-color: var(--text-subtle); }
.input:focus, .select:focus, .textarea:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.input::placeholder, .textarea::placeholder { color: var(--text-subtle); }

.textarea { resize: vertical; min-height: 88px; line-height: 1.55; }

.select {
  appearance: none;
  cursor: pointer;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%236b6660' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
}

.row { display: grid; gap: var(--s-4); }
.row-2 { grid-template-columns: 1fr 1fr; }
.row-3 { grid-template-columns: repeat(3, 1fr); }
@media (max-width: 700px) {
  .row-2, .row-3 { grid-template-columns: 1fr; }
}

/* Pills (chip selectors) */
.pill-group {
  display: flex; flex-wrap: wrap; gap: var(--s-2);
}
.pill {
  padding: 7px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  border-radius: var(--r-pill);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: all var(--t-fast);
}
.pill:hover {
  border-color: var(--text-subtle);
  color: var(--text);
}
.pill.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

/* Aspect-ratio visual selector */
.aspect-grid { display: flex; flex-wrap: wrap; gap: var(--s-3); }
.aspect-card {
  display: flex; align-items: center; gap: var(--s-3);
  padding: 10px 16px;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  cursor: pointer;
  user-select: none;
  transition: all var(--t-fast);
}
.aspect-card:hover { border-color: var(--text-subtle); }
.aspect-card.active {
  background: var(--accent-soft);
  border-color: var(--accent);
}
.aspect-card .shape {
  border: 1.5px solid var(--text-subtle);
  border-radius: 2px;
  transition: border-color var(--t-fast);
}
.aspect-card.active .shape { border-color: var(--accent); }
.aspect-card[data-v="9:16"] .shape { width: 14px; height: 22px; }
.aspect-card[data-v="16:9"] .shape { width: 22px; height: 14px; }
.aspect-card[data-v="1:1"] .shape { width: 18px; height: 18px; }
.aspect-card[data-v="4:5"] .shape { width: 16px; height: 20px; }
.aspect-card .label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}
.aspect-card.active .label { color: var(--accent); }

/* Image upload zone */
.upload {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-lg);
  padding: var(--s-10) var(--s-6);
  text-align: center;
  background: var(--bg-input);
  cursor: pointer;
  transition: all var(--t-base);
  position: relative;
}
.upload:hover, .upload.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.upload-icon {
  width: 44px; height: 44px;
  margin: 0 auto var(--s-4);
  background: var(--bg-subtle);
  border-radius: var(--r-md);
  display: grid; place-items: center;
  color: var(--accent);
}
.upload:hover .upload-icon { background: var(--accent-soft-hover); }
.upload-text { font-size: 14px; font-weight: 500; }
.upload-text strong { color: var(--accent); }
.upload-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 4px;
}
.upload input[type="file"] { display: none; }

/* Advanced reference inputs (collapsed by default) */
.more-refs {
  border-top: 1px dashed var(--border);
  padding-top: 14px;
}
.more-refs-summary {
  cursor: pointer;
  font-weight: 500;
  font-size: 14px;
  color: var(--text-muted);
  user-select: none;
  list-style: none;
}
.more-refs-summary::-webkit-details-marker { display: none; }
.more-refs-summary:hover { color: var(--text); }
.more-refs[open] .more-refs-summary { color: var(--text); margin-bottom: 10px; }
.more-refs-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 14px;
  line-height: 1.5;
}

.ref-group {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
  margin-bottom: 10px;
  background: var(--bg-elevated);
  transition: border-color 0.15s;
}
/* Required = highlighted with accent border */
.ref-group.ref-required {
  border-color: var(--accent, #c25b3b);
  background: rgba(194, 91, 59, 0.06);
}
.ref-group.ref-recommended {
  border-color: rgba(218, 165, 32, 0.5);
}
.ref-required-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 7px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  background: var(--accent, #c25b3b);
  color: white;
}
.ref-recommended-badge {
  background: #d4a23c;
}

/* Custom-style preset card — accented, dashed to signal "create" */
.preset-card-custom {
  border-style: dashed;
  border-color: var(--accent, #c25b3b);
}
.preset-card-custom .preset-card-name { color: var(--accent, #c25b3b); }

/* Custom-style modal layout */
.cs-row { display: flex; gap: var(--s-3); }
.cs-col { flex: 1; }
.cs-refs-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px 12px;
  margin-top: 4px;
}
.cs-ref-row {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px;
}
.cs-ref-label { flex: 1; color: var(--text-muted); }
.cs-ref-level {
  padding: 2px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 11.5px;
}
.ref-group-head {
  display: flex; align-items: baseline; gap: 8px;
  font-size: 13px;
  margin-bottom: 8px;
}
.ref-group-head strong { font-size: 13px; }
.ref-group-head span {
  font-size: 11.5px;
  color: var(--text-muted);
}
/* Compact dashed drop zone for secondary reference uploads — same visual
   language as the main `.upload` zone above (dashed border, accent on
   hover, accent-soft fill) but smaller padding because it lives inside an
   already-bordered .ref-group card. The native file input is hidden;
   the wrapping <label> forwards clicks to it automatically. */
.ref-dropzone {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 14px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--r-md);
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: 12.5px;
  cursor: pointer;
  transition: all var(--t-fast);
  user-select: none;
  position: relative; /* contain the visually-hidden input below */
}
.ref-dropzone:hover,
.ref-dropzone.drag {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--text);
}
.ref-dropzone-icon {
  color: var(--accent);
  flex-shrink: 0;
}
.ref-dropzone-text strong {
  color: var(--accent);
  font-weight: 600;
}
.ref-group-input {
  /* Visually hidden — the wrapping <label class="ref-dropzone"> handles
     clicks and the change event still fires for app.js. We use this
     pattern (not display:none) so keyboard users still tab to the input
     and trigger it with space/enter via the label. */
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}
.ref-group-list {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 8px;
}
.ref-group-item {
  position: relative;
  width: 64px; height: 64px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg);
  border: 1px solid var(--border);
}
.ref-group-item img { width: 100%; height: 100%; object-fit: cover; }
.ref-group-item-status {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  font-size: 9px;
  text-align: center;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 1px 0;
}
.ref-group-item.failed { border-color: var(--warning, #d65555); }
.ref-group-item-label {
  width: 100%;
  font-size: 11px;
  padding: 2px 4px;
  border: 1px solid var(--border);
  border-radius: 3px;
  margin-top: 2px;
  background: var(--bg);
}
.ref-group-item-remove {
  position: absolute;
  top: 2px; right: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: rgba(0,0,0,0.7);
  color: white;
  border: 0;
  font-size: 11px;
  line-height: 14px;
  cursor: pointer;
  padding: 0;
}

.upload-preview {
  display: none;
  align-items: center;
  gap: var(--s-3);
  background: var(--success-soft);
  border-radius: var(--r-md);
  padding: 10px 14px;
  margin-top: var(--s-4);
  font-size: 13px;
  color: var(--success);
}
.upload-preview.show { display: flex; }
.upload-preview img {
  width: 48px; height: 48px;
  object-fit: cover;
  border-radius: var(--r-sm);
}

/* ─────────────────────────── Buttons ─────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: var(--s-2);
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: 14px;
  font-weight: 500;
  letter-spacing: -0.005em;
  cursor: pointer;
  transition: all var(--t-fast);
  border: 1px solid transparent;
  white-space: nowrap;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: var(--text);
  color: var(--bg);
}
.btn-primary:hover:not(:disabled) {
  background: #2c2925;
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}
.btn-primary:active:not(:disabled) { transform: translateY(0); }

.btn-accent {
  background: var(--accent);
  color: var(--text-on-accent);
  position: relative;
}
.btn-accent::after {
  content: '';
  position: absolute; inset: -1px;
  border-radius: inherit;
  background: var(--accent);
  filter: blur(20px);
  opacity: 0.25;
  z-index: -1;
  transition: opacity var(--t-base);
}
.btn-accent:hover:not(:disabled) {
  background: var(--accent-hover);
  transform: translateY(-1px);
}
.btn-accent:hover:not(:disabled)::after { opacity: 0.45; }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border-color: var(--border-strong);
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg-hover);
  color: var(--text);
}

.btn-lg { padding: 14px 26px; font-size: 15px; }

.actions {
  display: flex;
  gap: var(--s-3);
  align-items: center;
  margin-top: var(--s-8);
}
.actions .spacer { flex: 1; }

/* ─────────────────────────── Catalog list ─────────────────────────── */
.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--s-4);
}
.skill-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  transition: all var(--t-base);
}
.skill-card:hover {
  border-color: var(--border-strong);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.skill-card-head {
  display: flex; align-items: center; gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.skill-card-name {
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 500;
}
.skill-card-status {
  margin-left: auto;
  font-size: 11px;
  padding: 3px 8px;
  border-radius: var(--r-pill);
  font-weight: 500;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.skill-card-status.active { background: var(--success-soft); color: var(--success); }
.skill-card-status.experimental { background: var(--warning-soft); color: var(--warning); }
.skill-card-status.deprecated { background: var(--danger-soft); color: var(--danger); }

.skill-card-type {
  display: inline-block;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-subtle);
  padding: 3px 10px;
  border-radius: var(--r-pill);
  margin-bottom: var(--s-3);
}
.skill-card-notes {
  font-size: 13px;
  color: var(--text-muted);
  line-height: 1.55;
  margin-bottom: var(--s-4);
  min-height: 40px;
}
.skill-card-meta {
  display: flex; gap: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-muted);
}
.skill-card-meta strong {
  color: var(--text);
  font-weight: 500;
}

/* ─────────────────────────── Toast ─────────────────────────── */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: var(--r-md);
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  transition: all var(--t-base);
  z-index: 1000;
  pointer-events: none;
}
.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
.toast.error { background: var(--danger); color: white; }
.toast.success { background: var(--success); color: white; }

/* ─────────────────────────── Pages ─────────────────────────── */
.page { display: none; animation: fadeIn 240ms var(--ease); }
.page.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.empty {
  text-align: center;
  padding: var(--s-16) var(--s-6);
  color: var(--text-muted);
}
.empty-icon {
  width: 56px; height: 56px;
  margin: 0 auto var(--s-4);
  background: var(--bg-subtle);
  border-radius: var(--r-lg);
  display: grid; place-items: center;
  color: var(--text-subtle);
}
.empty-title {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text);
  margin-bottom: var(--s-2);
}
.empty-body { font-size: 14px; max-width: 420px; margin: 0 auto; }

/* ─────────────────────────── Skeleton loaders ─────────────────────────── */
.skel {
  background: linear-gradient(
    90deg,
    var(--bg-subtle) 0%,
    var(--bg-hover) 50%,
    var(--bg-subtle) 100%
  );
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.4s ease-in-out infinite;
  border-radius: var(--r-sm);
}
@keyframes skeleton-shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}
.skel-line {
  height: 14px;
  margin-bottom: 8px;
  border-radius: 4px;
}
.skel-line.short { width: 40%; }
.skel-line.medium { width: 70%; }
.skel-line.long { width: 100%; }
.skel-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  margin-bottom: var(--s-3);
}
.skel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: var(--s-4);
}

/* ─────────────────────────── Error states ─────────────────────────── */
.error-block {
  background: var(--danger-soft);
  border: 1px solid rgba(160, 74, 63, 0.2);
  border-radius: var(--r-md);
  padding: var(--s-5) var(--s-6);
  display: flex;
  align-items: flex-start;
  gap: var(--s-4);
}
.error-icon {
  width: 32px; height: 32px;
  background: var(--danger);
  color: white;
  border-radius: 50%;
  display: grid; place-items: center;
  flex-shrink: 0;
}
.error-content { flex: 1; min-width: 0; }
.error-title {
  font-weight: 600;
  color: var(--danger);
  margin-bottom: 4px;
  font-size: 14px;
}
.error-detail {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  word-break: break-all;
  line-height: 1.5;
}
.error-actions {
  margin-top: var(--s-3);
  display: flex;
  gap: var(--s-2);
}

/* Inline field error */
.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px var(--danger-soft);
}

/* ─────────────────────────── Network status ─────────────────────────── */
.net-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
  padding: 4px 10px;
  border-radius: var(--r-pill);
  transition: all var(--t-base);
}
.net-status .net-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
}
.net-status.offline {
  background: var(--danger-soft);
  color: var(--danger);
}
.net-status.offline .net-dot {
  background: var(--danger);
  animation: breathe 1.4s var(--ease) infinite;
}
.net-status.reconnecting {
  background: var(--warning-soft);
  color: var(--warning);
}
.net-status.reconnecting .net-dot {
  background: var(--warning);
  animation: breathe 1.2s var(--ease) infinite;
}

/* Top-of-app offline banner */
.offline-banner {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0;
  background: var(--danger);
  color: white;
  padding: 8px 16px;
  font-size: 13px;
  font-weight: 500;
  text-align: center;
  z-index: 100;
  box-shadow: var(--shadow-md);
}
.offline-banner.show { display: block; }

/* ─────────────────────────── 404 ─────────────────────────── */
.notfound {
  text-align: center;
  padding: var(--s-20) var(--s-6);
}
.notfound-glyph {
  font-family: var(--font-serif);
  font-size: 96px;
  font-weight: 400;
  color: var(--accent);
  letter-spacing: -0.04em;
  line-height: 1;
  margin-bottom: var(--s-5);
  font-style: italic;
}
.notfound-title {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 500;
  margin-bottom: var(--s-3);
  letter-spacing: -0.02em;
}
.notfound-body {
  font-size: 15px;
  color: var(--text-muted);
  margin-bottom: var(--s-6);
  max-width: 460px;
  margin-left: auto;
  margin-right: auto;
}
.notfound-actions {
  display: flex;
  gap: var(--s-3);
  justify-content: center;
}

/* ─────────────────────────── Loading ─────────────────────────── */
.dots { display: inline-flex; gap: 4px; }
.dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: currentColor;
  animation: dot 1.2s var(--ease) infinite;
}
.dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes dot {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.85); }
  40% { opacity: 1; transform: scale(1); }
}

/* ─────────────────────────── Preset selector ─────────────────────────── */
.preset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: var(--s-3);
}
.preset-card {
  position: relative;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 14px 16px;
  cursor: pointer;
  user-select: none;
  transition: all var(--t-fast);
  overflow: hidden;
}
.preset-card:hover {
  border-color: var(--text-subtle);
  background: var(--bg-hover);
}
.preset-card.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.preset-card.active::before {
  content: '';
  position: absolute; inset: 0;
  background: linear-gradient(135deg, transparent 70%, rgba(201, 100, 66, 0.08));
  pointer-events: none;
}
.preset-card-name {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}
.preset-card.active .preset-card-name { color: var(--accent); }
.preset-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.preset-card-aside {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 8px;
  display: flex;
  gap: 8px;
}
.preset-card-aside span {
  background: var(--bg-subtle);
  padding: 2px 8px;
  border-radius: var(--r-pill);
}

/* ─────────────────────────── Plan preview ─────────────────────────── */
.plan-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: var(--s-3);
  margin-bottom: var(--s-6);
}
.plan-meta-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 14px 16px;
}
.plan-meta-label {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 500;
  margin-bottom: 4px;
}
.plan-meta-value {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
}
.plan-meta-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

/* Execution counter + ETA */
.exec-counter {
  margin-left: auto;
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-size: 12px;
  color: var(--text-muted);
}
.exec-eta {
  font-family: var(--font-mono, monospace);
  font-size: 11.5px;
}
.exec-eta-sep {
  transition: opacity 0.25s;
  color: var(--text-muted);
}

/* Plan-generation overlay (~2 min phased progress) */
.gen-overlay {
  position: fixed; inset: 0;
  background: rgba(20, 14, 9, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex; align-items: center; justify-content: center;
  z-index: 9500;
  animation: gen-fade-in 0.25s ease-out;
}
@keyframes gen-fade-in { from { opacity: 0; } to { opacity: 1; } }
.gen-card {
  width: min(440px, calc(100vw - 32px));
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-7) var(--s-6);
  box-shadow: var(--shadow-lg);
  text-align: center;
}
.gen-spinner {
  width: 40px; height: 40px;
  margin: 0 auto var(--s-4);
  border: 3px solid var(--border);
  border-top-color: var(--accent, #c25b3b);
  border-radius: 50%;
  animation: gen-spin 0.9s linear infinite;
}
@keyframes gen-spin { to { transform: rotate(360deg); } }
.gen-overlay.failed .gen-spinner {
  border-top-color: #d65555;
  animation: none;
}
.gen-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  margin-bottom: var(--s-2);
}
.gen-phase {
  font-size: 14px;
  color: var(--text-muted);
  min-height: 1.5em;
  margin-bottom: var(--s-4);
  transition: opacity 0.2s;
}
.gen-progress {
  width: 100%;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: var(--s-2);
}
.gen-progress-bar {
  height: 100%;
  background: var(--accent, #c25b3b);
  transition: width 0.4s ease-out;
}
.gen-meta {
  display: flex; justify-content: space-between;
  font-size: 11px; font-family: var(--font-mono, monospace);
  color: var(--text-muted);
  letter-spacing: 0.04em;
  margin-bottom: var(--s-4);
}
.gen-tip {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.55;
  font-style: italic;
}

/* Director's Treatment — the professional pre-pro doc */
.treatment-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-left: 4px solid var(--accent, #c25b3b);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  margin-bottom: var(--s-5);
}
.treatment-eyebrow {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
  color: var(--accent, #c25b3b);
  margin-bottom: var(--s-2);
}
.treatment-controlling-idea {
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.35;
  font-weight: 500;
  margin-bottom: var(--s-3);
  font-style: italic;
}
.treatment-meta {
  display: flex; flex-wrap: wrap; gap: var(--s-2);
  margin-bottom: var(--s-4);
}
.treatment-tag {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
}
.treatment-tag-archetype {
  background: rgba(194, 91, 59, 0.10);
  border-color: rgba(194, 91, 59, 0.3);
  color: var(--accent, #c25b3b);
}
.treatment-tag-emotion {
  background: rgba(218, 165, 32, 0.10);
  border-color: rgba(218, 165, 32, 0.3);
  color: #8a6a18;
}
.treatment-tag-theme {
  background: var(--bg);
  color: var(--text-muted);
}
.treatment-row {
  display: grid;
  grid-template-columns: 130px 1fr;
  gap: var(--s-3);
  padding: var(--s-2) 0;
  border-top: 1px dashed var(--border);
}
.treatment-row-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding-top: 2px;
}
.treatment-row-value {
  font-size: 13.5px;
  line-height: 1.55;
  color: var(--text);
}
.treatment-row-value.mono { font-family: var(--font-mono, monospace); font-size: 12px; }

/* Editable treatment fields */
.treatment-eyebrow {
  display: flex; align-items: baseline; gap: 12px;
}
.treatment-edit-hint {
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  text-transform: none;
  font-style: italic;
  opacity: 0.7;
}
.tr-editable {
  outline: none;
  cursor: text;
  border-bottom: 1px dashed transparent;
  transition: border-color 0.15s, background 0.15s;
  padding: 0 2px;
  border-radius: 2px;
}
.tr-editable:hover {
  border-bottom-color: var(--border);
}
.tr-editable:focus {
  border-bottom-color: var(--accent, #c25b3b);
  background: rgba(194, 91, 59, 0.05);
}
/* Tag-shaped editables (archetype/emotion/theme) — keep them inline-flex */
.tr-tag-edit {
  display: inline-block;
  min-width: 30px;
}

.treatment-replan-banner {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: rgba(194, 91, 59, 0.08);
  border: 1px solid rgba(194, 91, 59, 0.3);
  border-radius: var(--r-md);
  font-size: 13px;
}
.treatment-replan-banner > span:first-child { flex: 1; color: var(--accent, #c25b3b); font-weight: 500; }
.btn-sm { font-size: 12px; padding: 5px 10px; }

/* Shot card edit pencil */
.shot-info-title {
  display: flex;
  align-items: baseline;
  gap: 8px;
}
.shot-edit-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 2px 6px;
  border-radius: var(--r-sm);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.shot-card:hover .shot-edit-btn { opacity: 1; }
.shot-edit-btn:hover {
  background: var(--bg-elevated);
  color: var(--accent, #c25b3b);
  border-color: var(--accent, #c25b3b);
}

/* Shot edit modal — bigger textarea for Chinese prompts (~400 chars) */
.shot-edit-prompt {
  font-family: var(--font-mono, monospace);
  font-size: 13px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.shot-edit-meta {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
  margin-top: 6px;
}
.shot-edit-charcount {
  font-family: var(--font-mono, monospace);
  font-weight: 500;
  color: var(--text);
}
.shot-edit-charcount-sep { opacity: 0.4; }
.shot-edit-duration {
  width: 60px;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
}

/* Inline "Retry this shot" button on failed step rows in live exec view */
.step-retry-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-top: 6px;
  font-size: 11.5px;
  padding: 4px 9px;
  border: 1px solid var(--accent, #c25b3b);
  color: var(--accent, #c25b3b);
  background: rgba(194, 91, 59, 0.06);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: background 0.15s;
}
.step-retry-btn:hover:not(:disabled) { background: rgba(194, 91, 59, 0.14); }
.step-retry-btn:disabled { opacity: 0.6; cursor: wait; }
.step-retry-btn svg { flex-shrink: 0; }

/* First-time onboarding modal */
.onboarding-card { padding: var(--s-6); }
.onboarding-header {
  display: flex; align-items: center; gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.onboarding-mark {
  width: 44px; height: 44px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(194, 91, 59, 0.18), rgba(218, 165, 32, 0.18));
  font-size: 22px;
}
.onboarding-title {
  font-family: var(--font-serif);
  font-size: 22px; font-weight: 500;
  letter-spacing: -0.01em;
}
.onboarding-subtitle {
  font-size: 13px; color: var(--text-muted);
  margin-top: 2px;
}
.onboarding-steps {
  list-style: none;
  counter-reset: ob;
  padding: 0;
  margin: 0;
}
.onboarding-steps li {
  counter-increment: ob;
  display: flex; align-items: baseline; gap: var(--s-3);
  padding: var(--s-2) 0;
  border-bottom: 1px dashed var(--border);
}
.onboarding-steps li:last-child { border-bottom: none; }
.onboarding-steps li::before {
  content: counter(ob);
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  font-size: 11px; font-weight: 600;
  color: var(--accent, #c25b3b);
}
.onboarding-steps li strong {
  font-size: 13px; font-weight: 600; flex-shrink: 0;
}
.onboarding-steps li span {
  font-size: 13px; color: var(--text-muted);
  line-height: 1.5;
}
.onboarding-tip {
  margin-top: var(--s-3);
  padding: var(--s-3);
  background: var(--bg-elevated);
  border-radius: var(--r-sm);
  font-size: 12px;
  color: var(--text-muted);
  font-style: italic;
}

/* Screenplay summary card */
.screenplay-card {
  background: linear-gradient(135deg, var(--bg-elevated), var(--accent-soft) 200%);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6) var(--s-8);
  margin-bottom: var(--s-5);
  position: relative;
  overflow: hidden;
}
.screenplay-card::before {
  content: '';
  position: absolute;
  top: -50%; right: -10%;
  width: 60%; height: 200%;
  background: radial-gradient(ellipse, var(--accent-soft) 0%, transparent 60%);
  opacity: 0.5;
  pointer-events: none;
}
.screenplay-eyebrow {
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 8px;
}
.screenplay-logline {
  font-family: var(--font-serif);
  font-size: 22px;
  line-height: 1.35;
  letter-spacing: -0.015em;
  color: var(--text);
  margin-bottom: 14px;
  position: relative;
}
.screenplay-meta {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--text-muted);
  position: relative;
}
.screenplay-meta-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.screenplay-meta-item strong {
  font-weight: 500;
  color: var(--text);
}
.screenplay-meta-divider {
  color: var(--text-subtle);
  opacity: 0.5;
}

/* Beats timeline */
.beats-timeline {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 8px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  margin-bottom: var(--s-6);
  min-height: 80px;
}
.beat-bar {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  position: relative;
  transition: all var(--t-fast);
}
.beat-bar:hover {
  border-color: var(--text-subtle);
  transform: translateY(-1px);
}
.beat-bar.beat-hook { border-top: 3px solid #d97757; }
.beat-bar.beat-setup { border-top: 3px solid #c89856; }
.beat-bar.beat-build { border-top: 3px solid #5b8a72; }
.beat-bar.beat-climax { border-top: 3px solid #a04a3f; }
.beat-bar.beat-resolution { border-top: 3px solid #5a7e9a; }

.beat-bar-name {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.beat-bar.beat-hook .beat-bar-name { color: #d97757; }
.beat-bar.beat-setup .beat-bar-name { color: #c89856; }
.beat-bar.beat-build .beat-bar-name { color: #5b8a72; }
.beat-bar.beat-climax .beat-bar-name { color: #a04a3f; }
.beat-bar.beat-resolution .beat-bar-name { color: #5a7e9a; }

.beat-bar-duration {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
  margin-top: 2px;
}
.beat-bar-intent {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.4;
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.beat-bar-shotcount {
  font-size: 10px;
  color: var(--text-subtle);
  margin-top: 4px;
  font-family: var(--font-mono);
}

/* Cinematography badges (on shot cards) */
.cine-badges {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 8px;
}
.cine-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 9px;
  background: var(--bg-subtle);
  border-radius: var(--r-pill);
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  letter-spacing: 0.01em;
}
.cine-badge svg {
  width: 11px; height: 11px;
  color: var(--text-subtle);
}
.cine-badge.beat {
  background: var(--accent-soft);
  color: var(--accent);
}
.cine-badge.beat svg { color: var(--accent); }
.cine-badge.emotion {
  background: rgba(91, 138, 114, 0.08);
  color: var(--success);
}

/* Shot prompt expansion */
.shot-prompt-expand {
  cursor: pointer;
  color: var(--accent);
  font-size: 11px;
  margin-top: 6px;
  font-weight: 500;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.shot-prompt-expand:hover { text-decoration: underline; }
.shot-prompt-full {
  display: none;
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--bg-subtle);
  border-radius: var(--r-sm);
  font-size: 12px;
  line-height: 1.6;
  color: var(--text-muted);
  white-space: pre-wrap;
}
.shot-prompt-full.show { display: block; }

/* Inline video preview (in execution step) */
.step-thumb {
  width: 56px; height: 56px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-subtle);
  position: relative;
  flex-shrink: 0;
}
.step-thumb video,
.step-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
}
.step-thumb::after {
  content: '';
  position: absolute; inset: 0;
  background: radial-gradient(circle at center, rgba(0,0,0,0) 60%, rgba(0,0,0,0.15));
  pointer-events: none;
}
.step-item-with-thumb {
  grid-template-columns: 28px 1fr 56px auto;
}

/* Final video player */
.video-player-wrap {
  width: 100%;
  background: #000;
  border-radius: var(--r-md);
  overflow: hidden;
  margin-bottom: var(--s-4);
  aspect-ratio: 9 / 16;
  max-width: 360px;
  margin-left: auto;
  margin-right: auto;
}
.video-player-wrap video {
  width: 100%; height: 100%;
  display: block;
}
.video-player-wrap.aspect-16-9 { aspect-ratio: 16 / 9; max-width: 640px; }
.video-player-wrap.aspect-1-1 { aspect-ratio: 1 / 1; max-width: 480px; }
.video-player-wrap.aspect-4-5 { aspect-ratio: 4 / 5; max-width: 400px; }

/* Thumbnail strip below player (the individual shot clips) */
.shot-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 8px 0;
  scrollbar-width: thin;
}
.shot-strip-item {
  flex-shrink: 0;
  width: 80px;
  height: 80px;
  border-radius: var(--r-sm);
  overflow: hidden;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all var(--t-fast);
  position: relative;
}
.shot-strip-item:hover {
  border-color: var(--accent);
  transform: scale(1.05);
}
.shot-strip-item video {
  width: 100%; height: 100%;
  object-fit: cover;
}
.shot-strip-item::before {
  content: attr(data-num);
  position: absolute;
  top: 4px; left: 4px;
  background: rgba(0,0,0,0.6);
  color: white;
  font-size: 10px;
  font-family: var(--font-mono);
  padding: 1px 6px;
  border-radius: var(--r-pill);
  z-index: 1;
}

/* Shot cards */
.shot-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 16px 20px;
  margin-bottom: var(--s-2);
  display: grid;
  grid-template-columns: 60px 1fr auto;
  gap: var(--s-4);
  align-items: center;
}
.shot-num {
  font-family: var(--font-mono);
  font-size: 13px;
  color: var(--text-subtle);
  font-weight: 500;
}
.shot-num strong {
  display: block;
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--text);
}
.shot-info-title {
  font-weight: 500;
  margin-bottom: 4px;
  font-size: 14px;
}
.shot-info-purpose {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}
.shot-tags {
  display: flex;
  gap: 6px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.shot-tag {
  font-size: 10px;
  font-family: var(--font-mono);
  background: var(--bg-subtle);
  color: var(--text-muted);
  padding: 2px 8px;
  border-radius: var(--r-pill);
}
.shot-duration {
  font-family: var(--font-serif);
  font-size: 18px;
  color: var(--text-muted);
}

/* ─────────────────────────── Execution / progress ─────────────────────────── */
.exec-progress {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-6);
  margin-bottom: var(--s-5);
}
.exec-summary {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.exec-status-dot {
  width: 10px; height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}
.exec-status-dot.running { background: var(--accent); animation: breathe 2s var(--ease) infinite; }
.exec-status-dot.completed { background: var(--success); }
.exec-status-dot.failed { background: var(--danger); }
.exec-status-dot.pending { background: var(--text-subtle); }

.exec-bar-track {
  height: 4px;
  background: rgba(0,0,0,0.05);
  border-radius: 100px;
  overflow: hidden;
  margin-top: var(--s-3);
}
.exec-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #e58869);
  width: 0%;
  border-radius: 100px;
  transition: width 0.5s ease;
}

/* Step item */
.step-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.step-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  gap: var(--s-3);
  padding: 12px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  align-items: center;
  transition: all var(--t-fast);
}
.step-item.running {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.step-item.done {
  border-color: rgba(91, 138, 114, 0.25);
}
.step-item.failed {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.step-icon {
  width: 22px; height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--bg-subtle);
  color: var(--text-subtle);
  flex-shrink: 0;
}
.step-icon.pending { background: var(--bg-subtle); color: var(--text-subtle); }
.step-icon.running {
  background: var(--accent);
  color: white;
}
.step-icon.running .spin {
  width: 12px; height: 12px;
  border: 2px solid rgba(255,255,255,0.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.step-icon.done { background: var(--success); color: white; }
.step-icon.failed { background: var(--danger); color: white; }

.step-body { min-width: 0; }
.step-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-title-id {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
}
.step-msg {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.step-skill {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-subtle);
  padding: 2px 8px;
  background: var(--bg-subtle);
  border-radius: var(--r-pill);
}

/* Live log */
.exec-log {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 16px;
  margin-top: var(--s-4);
  max-height: 200px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--text-muted);
}
.exec-log .log-line { white-space: pre-wrap; word-break: break-all; }
.exec-log .log-line.success { color: var(--success); }
.exec-log .log-line.error { color: var(--danger); }
.exec-log .log-line.accent { color: var(--accent); }

/* Result panel */
.result-panel {
  background: var(--bg-elevated);
  border: 1px solid rgba(91, 138, 114, 0.25);
  border-radius: var(--r-lg);
  padding: var(--s-8);
  margin-top: var(--s-5);
}
.result-header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-5);
}
.result-icon {
  width: 36px; height: 36px;
  background: var(--success-soft);
  color: var(--success);
  border-radius: var(--r-md);
  display: grid; place-items: center;
}
.result-title {
  font-family: var(--font-serif);
  font-size: 19px;
  font-weight: 500;
}
.result-row {
  padding: 10px 14px;
  background: var(--bg-subtle);
  border-radius: var(--r-md);
  font-size: 13px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: var(--s-3);
}
.result-row code {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-muted);
  flex: 1;
  overflow-wrap: anywhere;
}

/* ─────────────────────────── Preflight panel ─────────────────────────── */
.preflight-panel {
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: var(--s-3) var(--s-4);
  margin-top: var(--s-4);
  background: var(--bg-elevated);
  font-size: 13px;
}
.preflight-panel-loading { color: var(--text-muted); font-style: italic; }
.preflight-panel-pass { border-color: rgba(40, 180, 120, 0.4); background: rgba(40, 180, 120, 0.06); }
.preflight-panel-info { border-color: rgba(120, 160, 220, 0.4); background: rgba(120, 160, 220, 0.06); }
.preflight-panel-warn { border-color: rgba(220, 170, 60, 0.5); background: rgba(220, 170, 60, 0.07); }
.preflight-panel-block { border-color: rgba(220, 80, 80, 0.5); background: rgba(220, 80, 80, 0.07); }
.preflight-error { color: var(--text-muted); font-style: italic; }

.preflight-summary {
  display: flex; align-items: center; gap: var(--s-2);
  font-weight: 500;
}
.preflight-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 50%;
  font-size: 11px; font-weight: 700; color: white;
}
.preflight-icon-pass  { background: #28b478; }
.preflight-icon-info  { background: #6f9adc; }
.preflight-icon-warn  { background: #d4a23c; }
.preflight-icon-block { background: #d65555; }

.preflight-list {
  list-style: none;
  margin: var(--s-3) 0 0 0;
  padding: 0;
  display: flex; flex-direction: column; gap: var(--s-2);
}
.preflight-item {
  display: flex; align-items: center; gap: var(--s-2);
  padding: var(--s-2) var(--s-3);
  background: var(--bg);
  border-radius: var(--r-sm);
  font-size: 12.5px;
  line-height: 1.5;
}
.preflight-item-tag {
  text-transform: uppercase;
  font-size: 10px;
  letter-spacing: 0.06em;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}
.preflight-item-blocker .preflight-item-tag { background: rgba(220, 80, 80, 0.18); color: #b03030; }
.preflight-item-warning .preflight-item-tag { background: rgba(220, 170, 60, 0.22); color: #8a6a18; }
.preflight-item-info    .preflight-item-tag { background: rgba(120, 160, 220, 0.20); color: #3a5a8a; }
.preflight-item-msg { flex: 1; }
.preflight-item-target {
  font-family: var(--font-mono, monospace);
  font-size: 11px;
  color: var(--text-muted);
  background: var(--bg-elevated);
  padding: 2px 5px;
  border-radius: 3px;
  flex-shrink: 0;
}

.btn-disabled, .btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  pointer-events: none;
}

/* ─────────────────────────── Cost preview ─────────────────────────── */
.cost-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4) var(--s-6);
  margin-top: var(--s-8);
  display: flex;
  align-items: center;
  gap: var(--s-6);
  box-shadow: var(--shadow-md);
}
.cost-bar-stat {
  display: flex; flex-direction: column;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.cost-bar-stat strong {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: -0.01em;
  text-transform: none;
  margin-top: 2px;
}
.cost-bar .actions {
  margin-top: 0;
  margin-left: auto;
}

/* ─────────────────────────── PCE consistency display ─────────────────────────── */
.pce-panel {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  margin-top: var(--s-5);
  position: relative;
  overflow: hidden;
}
.pce-panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; bottom: 0;
  width: 3px;
  background: var(--accent);
}
.pce-panel.pass::before { background: var(--success); }
.pce-panel.warn::before { background: var(--warning); }
.pce-panel.fail::before { background: var(--danger); }

.pce-header {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  margin-bottom: var(--s-4);
}
.pce-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.pce-overall-badge {
  margin-left: auto;
  padding: 4px 12px;
  border-radius: var(--r-pill);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-family: var(--font-mono);
}
.pce-overall-badge.pass { background: var(--success-soft); color: var(--success); }
.pce-overall-badge.warn { background: var(--warning-soft); color: var(--warning); }
.pce-overall-badge.fail { background: var(--danger-soft); color: var(--danger); }

/* Quality tier badge — Gold / Silver / Bronze / Failed */
.pce-tier {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--r-pill);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-right: 8px;
  border: 1px solid currentColor;
}
.pce-tier-medal { display: inline-flex; align-items: center; }
.pce-tier-label { white-space: nowrap; }
.pce-tier-gold {
  background: rgba(212, 175, 55, 0.12);
  color: #b08838;     /* burnished gold — readable on cream */
}
.pce-tier-silver {
  background: rgba(140, 145, 155, 0.12);
  color: #6a6f7a;
}
.pce-tier-bronze {
  background: rgba(178, 102, 60, 0.12);
  color: #8a4f2c;
}
.pce-tier-failed {
  background: var(--danger-soft);
  color: var(--danger);
}

/* Cost panel — estimated vs actual vs regen breakdown */
.cost-panel {
  margin-top: var(--s-4);
  padding: var(--s-3) var(--s-4);
  background: var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
}
.cost-title {
  font-size: 13px;
  font-weight: 500;
  margin-bottom: var(--s-2);
  color: var(--text-muted);
  letter-spacing: 0.02em;
}
.cost-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-size: 13px;
  padding: 4px 0;
}
.cost-label { color: var(--text-muted); }
.cost-value { font-family: var(--font-mono); }
.cost-total {
  border-top: 1px solid var(--border);
  margin-top: 4px;
  padding-top: 6px;
  font-weight: 600;
}
.cost-total .cost-label { color: var(--text); }
.cost-total.overshot .cost-value { color: var(--warning); }

/* Per-shot manual regen button — overlays each shot in the strip */
.shot-strip-item { position: relative; }
.shot-regen-group {
  position: absolute;
  bottom: 4px;
  right: 4px;
  display: inline-flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s;
}
.shot-strip-item:hover .shot-regen-group { opacity: 1; }
.shot-regen-btn,
.shot-regen-edit-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 7px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: var(--r-pill);
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s;
}
.shot-regen-edit-btn { padding: 3px 6px; }
.shot-regen-btn:hover:not(:disabled),
.shot-regen-edit-btn:hover:not(:disabled) { background: rgba(0, 0, 0, 0.8); }
.shot-regen-btn:disabled { cursor: wait; opacity: 0.6; }
.shot-regen-btn.busy {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

/* Regen recipe editor modal */
.regen-editor-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 9000;
}
.regen-editor-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-5) var(--s-6);
  width: min(520px, calc(100vw - 32px));
  max-height: 80vh; overflow-y: auto;
  box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column; gap: var(--s-3);
}
.regen-editor-title { font-size: 16px; font-weight: 600; }
.regen-editor-subtitle { font-size: 12px; color: var(--text-muted); margin-bottom: var(--s-2); }
.regen-editor-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-muted); margin-top: var(--s-2);
}
.regen-editor-prompt {
  width: 100%; box-sizing: border-box;
  padding: var(--s-3); border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg); color: var(--text);
  font-family: inherit; font-size: 13px; line-height: 1.5;
  resize: vertical;
}
.regen-editor-skill {
  width: 100%; box-sizing: border-box;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--bg); color: var(--text);
  font-size: 13px;
}
.regen-editor-hint {
  font-size: 11.5px; color: var(--text-muted); font-style: italic;
}
.regen-editor-actions {
  display: flex; justify-content: flex-end; gap: var(--s-3);
  margin-top: var(--s-3);
}

.pce-axes {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--s-3);
}
.pce-axis {
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  padding: 12px 14px;
}
.pce-axis-label {
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 6px;
}
.pce-axis-value {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.pce-axis-value.pass { color: var(--success); }
.pce-axis-value.warn { color: var(--warning); }
.pce-axis-value.fail { color: var(--danger); }
.pce-axis-detail {
  font-size: 11px;
  color: var(--text-subtle);
  margin-top: 4px;
  font-family: var(--font-mono);
}

.pce-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(0,0,0,0.05);
  border-radius: 100px;
  overflow: hidden;
  margin-top: 8px;
}
.pce-bar-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.5s ease;
}
.pce-bar-fill.pass { background: var(--success); }
.pce-bar-fill.warn { background: var(--warning); }
.pce-bar-fill.fail { background: var(--danger); }

/* Per-shot inline PCE indicator (small) */
.pce-shot-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: var(--r-pill);
  font-size: 10px;
  font-family: var(--font-mono);
  font-weight: 600;
  letter-spacing: 0.04em;
}
.pce-shot-pill.pass { background: var(--success-soft); color: var(--success); }
.pce-shot-pill.warn { background: var(--warning-soft); color: var(--warning); }
.pce-shot-pill.fail { background: var(--danger-soft); color: var(--danger); }

/* ── PCE customer-facing verdict + outliers + regen ─────────── */
.pce-verdict {
  font-size: 14px;
  margin: var(--s-2) 0 var(--s-4);
  color: var(--text);
  line-height: 1.5;
}
.pce-panel.pass .pce-verdict { color: var(--text); }
.pce-panel.warn .pce-verdict { color: var(--text); }
.pce-panel.fail .pce-verdict { color: var(--danger); }

.pce-outliers {
  margin-top: var(--s-4);
  padding-top: var(--s-4);
  border-top: 1px solid var(--border);
}
.pce-outliers-title {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  margin-bottom: var(--s-3);
  letter-spacing: 0.02em;
}
.pce-outlier-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: var(--s-3);
}
.pce-outlier-tile {
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border);
}
.pce-outlier-tile video,
.pce-outlier-tile img {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  background: #000;
}
.pce-outlier-placeholder {
  width: 100%;
  aspect-ratio: 9 / 16;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-subtle);
}
.pce-outlier-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  font-size: 11px;
}
.pce-outlier-num {
  font-weight: 500;
  color: var(--text);
}

.pce-expert {
  margin-top: var(--s-4);
  padding-top: var(--s-3);
  border-top: 1px dashed var(--border);
  font-size: 11px;
}
.pce-expert summary {
  cursor: pointer;
  color: var(--text-muted);
  user-select: none;
  margin-bottom: var(--s-2);
}
.pce-expert-axes { margin-top: var(--s-2); }
.pce-expert-tech {
  margin-top: var(--s-2);
  font-family: var(--font-mono);
  color: var(--text-subtle);
  font-size: 10px;
}

/* Regen progress note (on each step row) */
.regen-note {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: 12px;
  color: var(--accent);
  flex-wrap: wrap;
}
.regen-note.success { color: var(--success); }
.regen-note .regen-detail {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-subtle);
  margin-left: 6px;
}
.regen-spinner {
  display: inline-block;
  width: 10px;
  height: 10px;
  border: 1.5px solid var(--accent);
  border-top-color: transparent;
  border-radius: 50%;
  animation: regen-spin 0.7s linear infinite;
}
.regen-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success-soft);
  color: var(--success);
  font-size: 10px;
  font-weight: 700;
}
@keyframes regen-spin {
  to { transform: rotate(360deg); }
}

/* ─────────────────────────── PCE demo page ─────────────────────────── */
.demo-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--s-5);
  margin-top: var(--s-4);
}
@media (max-width: 900px) {
  .demo-grid { grid-template-columns: 1fr; }
}
.demo-col {
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-4);
  background: var(--bg);
  position: relative;
}
.demo-col.pass { border-color: rgba(34, 139, 80, 0.4); }
.demo-col.fail { border-color: rgba(180, 50, 50, 0.4); }
.demo-col::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 3px;
  border-radius: var(--r-lg) var(--r-lg) 0 0;
}
.demo-col.pass::before { background: var(--success); }
.demo-col.fail::before { background: var(--danger); }

.demo-col-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--s-3);
}
.demo-col-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  letter-spacing: -0.01em;
}
.demo-shot-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--s-2);
  margin-bottom: var(--s-3);
}
.demo-shot {
  border-radius: var(--r-md);
  overflow: hidden;
  background: var(--bg-soft);
  border: 1px solid var(--border);
  position: relative;
}
.demo-shot.outlier {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px rgba(180, 50, 50, 0.15);
}
.demo-shot video {
  display: block;
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  background: #000;
}
.demo-shot-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px;
  font-size: 11px;
  color: var(--text-muted);
}
.demo-verdict {
  font-size: 14px;
  margin-top: var(--s-3);
  font-weight: 500;
}
.demo-verdict.pass { color: var(--success); }
.demo-verdict.fail { color: var(--danger); }
.demo-caption {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: var(--s-2);
  line-height: 1.5;
}
.demo-cta {
  display: flex;
  justify-content: center;
  margin-top: var(--s-5);
}

/* ─────────────────────────── Rating UI ─────────────────────────── */
.rating-panel {
  margin-top: var(--s-6);
  padding-top: var(--s-5);
  border-top: 1px solid var(--border);
}
.rating-title {
  font-family: var(--font-serif);
  font-size: 17px;
  font-weight: 500;
  margin-bottom: var(--s-2);
  letter-spacing: -0.01em;
}
.rating-subtitle {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: var(--s-5);
}

.rating-axes { display: grid; gap: var(--s-3); margin-bottom: var(--s-4); }
.rating-axis {
  display: grid;
  grid-template-columns: 130px 1fr;
  align-items: center;
  gap: var(--s-3);
}
.rating-axis-label {
  font-size: 13px;
  color: var(--text-muted);
}
.rating-stars {
  display: inline-flex;
  gap: 4px;
}
.rating-star {
  cursor: pointer;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  color: var(--text-subtle);
  transition: color var(--t-fast), transform var(--t-fast);
  background: transparent; border: none;
}
.rating-star:hover, .rating-star.hot {
  color: var(--accent);
  transform: scale(1.1);
}
.rating-star.active { color: var(--accent); }
.rating-star svg { width: 18px; height: 18px; }

.rating-comment {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: var(--r-md);
  padding: 10px 14px;
  font-size: 13px;
  color: var(--text);
  font-family: inherit;
  resize: vertical;
  min-height: 64px;
  margin-bottom: var(--s-3);
}
.rating-comment:focus {
  outline: none;
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.rating-actions { display: flex; gap: var(--s-2); align-items: center; }
.rating-thanks {
  font-size: 12px;
  color: var(--success);
  display: none;
}
.rating-thanks.show { display: inline-flex; align-items: center; gap: 6px; }

/* Per-shot thumb buttons */
.shot-thumb-row {
  display: flex; gap: 6px;
  margin-top: 8px;
  align-items: center;
}
.thumb-btn {
  width: 28px; height: 28px;
  display: grid; place-items: center;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  border-radius: var(--r-sm);
  cursor: pointer;
  color: var(--text-subtle);
  transition: all var(--t-fast);
}
.thumb-btn:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.thumb-btn.up.active {
  background: var(--success-soft);
  border-color: var(--success);
  color: var(--success);
}
.thumb-btn.down.active {
  background: var(--danger-soft);
  border-color: var(--danger);
  color: var(--danger);
}
.thumb-btn svg { width: 14px; height: 14px; }

/* ─────────────────────────── Modal (shortcuts help) ─────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 26, 23, 0.55);
  backdrop-filter: blur(6px);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: var(--s-6);
  animation: modal-fade 160ms ease;
}
.modal-overlay.show { display: flex; }
@keyframes modal-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}
.modal {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  padding: var(--s-8);
  max-width: 520px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
  animation: modal-pop 200ms var(--ease);
}
@keyframes modal-pop {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.modal-header {
  display: flex;
  align-items: baseline;
  margin-bottom: var(--s-5);
}
.modal-title {
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.02em;
  flex: 1;
}
.modal-close {
  width: 28px; height: 28px;
  background: transparent;
  border: none;
  border-radius: var(--r-sm);
  color: var(--text-muted);
  cursor: pointer;
  display: grid; place-items: center;
}
.modal-close:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.shortcut-row {
  display: flex;
  align-items: center;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: var(--s-4);
}
.shortcut-row:last-child { border-bottom: none; }
.shortcut-keys {
  display: inline-flex;
  gap: 4px;
  flex-shrink: 0;
}
kbd {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-subtle);
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  padding: 2px 8px;
  color: var(--text);
  letter-spacing: 0.02em;
  font-weight: 500;
  min-width: 22px;
  text-align: center;
}
.shortcut-desc {
  font-size: 13px;
  color: var(--text-muted);
}

.shortcut-section-title {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-subtle);
  margin: var(--s-5) 0 var(--s-2);
}
.shortcut-section-title:first-child { margin-top: 0; }


/* ─────────────────────────── Mobile responsive ─────────────────────────── */
/*
 * Single comprehensive breakpoint at 768px. We don't add a hamburger
 * (would require HTML changes) — instead the sidebar becomes a
 * top-stuck horizontal scrolling navbar so nav + brand stay visible.
 *
 * Modals (regen-editor / shot-edit / custom-style) already use
 * `width: min(Npx, calc(100vw - 32px))` — they're fine on mobile.
 */
@media (max-width: 768px) {
  /* App grid → single column */
  .app {
    grid-template-columns: 1fr;
  }

  /* Sidebar → horizontal top bar */
  .sidebar {
    position: sticky;
    top: 0;
    height: auto;
    flex-direction: row;
    align-items: center;
    overflow-x: auto;
    overflow-y: hidden;
    padding: var(--s-2) var(--s-3);
    gap: var(--s-2);
    border-right: none;
    border-bottom: 1px solid var(--border);
    z-index: 10;
  }
  .sidebar-brand {
    margin-bottom: 0;
    flex-shrink: 0;
    padding: 0 var(--s-2);
  }
  .sidebar-brand .name { font-size: 16px; }
  .sidebar-brand .mark { width: 26px; height: 26px; }
  .nav {
    flex-direction: row;
    gap: 4px;
    flex: 1;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .nav-item {
    padding: 6px 10px;
    font-size: 12.5px;
    white-space: nowrap;
    flex-shrink: 0;
  }
  .nav-item .icon { width: 14px; height: 14px; }
  .sidebar-footer { display: none; }   /* version meta — not worth screen real estate */

  /* Topbar — drop "Browse skills" label, keep just the icon + lang/theme */
  .topbar {
    height: 48px;
    padding: 0 var(--s-3);
    gap: var(--s-2);
  }
  .topbar-title { font-size: 14px; }
  .topbar .btn-ghost span { display: none; }   /* hide button labels */
  .topbar .btn-ghost { padding: 6px 8px; }
  .net-status { display: none; }                /* online dot — too noisy on tight bar */

  /* Content padding tightens */
  .content {
    padding: var(--s-4) var(--s-3);
  }

  /* Hero — smaller, less margin */
  .hero h1 { font-size: 32px; }
  .hero p { font-size: 14px; }

  /* Cards — tighter padding */
  .card {
    padding: var(--s-4);
    margin-bottom: var(--s-4);
  }
  .card-header { gap: var(--s-2); }
  .card-step-num { font-size: 28px; }
  .card-title { font-size: 16px; }
  .card-subtitle { font-size: 12px; }

  /* Aspect grid 4-col → 2-col */
  .aspect-grid { grid-template-columns: repeat(2, 1fr); }

  /* Preset grid: any wider auto-fill rule degrades — force single column */
  .preset-grid {
    grid-template-columns: 1fr !important;
  }

  /* Cost bar at form bottom — stack stats above actions */
  .cost-bar {
    flex-direction: column;
    align-items: stretch;
    gap: var(--s-3);
    padding: var(--s-3);
  }
  .cost-bar-stat { font-size: 11px; }
  .cost-bar-stat strong { font-size: 18px; }
  .cost-bar .actions {
    width: 100%;
    justify-content: space-between;
  }
  .cost-bar .actions .btn { flex: 1; }

  /* Plan view */
  .screenplay-card { padding: var(--s-4); }
  .screenplay-logline { font-size: 18px; }
  .treatment-card { padding: var(--s-3); }
  .treatment-controlling-idea { font-size: 17px; }
  .treatment-row {
    grid-template-columns: 1fr;        /* label above value, not beside */
    gap: 4px;
    padding: var(--s-2) 0;
  }
  .treatment-row-label {
    font-size: 10px;
  }
  .plan-meta {
    grid-template-columns: 1fr 1fr;    /* 2-col on mobile, was wider */
  }

  /* Beats timeline — keep row but smaller */
  .beats-timeline { font-size: 11px; }
  .beat-bar { padding: 8px 6px; }
  .beat-bar-name { font-size: 11px; }
  .beat-bar-duration { font-size: 10px; }
  .beat-bar-intent { font-size: 10px; }

  /* Shot card 3-col → stack */
  .shot-card {
    grid-template-columns: auto 1fr;    /* num beside body */
  }
  .shot-card .shot-duration {
    grid-column: 1 / -1;
    text-align: right;
    font-size: 12px;
  }
  .shot-card .shot-edit-btn { opacity: 1; }   /* always visible — no hover on touch */

  /* Run/exec page */
  .exec-progress { padding: var(--s-3); }
  .exec-summary { font-size: 12px; flex-wrap: wrap; }
  .exec-counter { width: 100%; margin-left: 0; margin-top: 4px; }
  .step-item-with-thumb {
    grid-template-columns: auto 1fr;
  }
  .step-thumb {
    grid-column: 1 / -1;
    margin-top: var(--s-2);
  }
  .step-skill { display: none; }    /* save space — visible elsewhere if needed */

  /* History / briefs list */
  .empty { padding: var(--s-6) var(--s-3); }

  /* Reference upload "more refs" panel — full width inputs */
  .more-refs { padding-top: var(--s-3); }
  .ref-group { padding: var(--s-2) var(--s-3); }
  .ref-group-input { font-size: 11px; }
  .ref-group-item { width: 56px; height: 56px; }

  /* Custom-style modal — single col instead of 2-col grid */
  .cs-row { flex-direction: column; gap: var(--s-2); }
  .cs-refs-grid { grid-template-columns: 1fr; }

  /* Treatment edit banner — stack buttons under message */
  .treatment-replan-banner {
    flex-direction: column;
    align-items: stretch;
  }
  .treatment-replan-banner > span:first-child { margin-bottom: var(--s-2); }

  /* Generation overlay — full-screen on mobile (already centered, just sized) */
  .gen-card {
    width: calc(100vw - 24px);
    padding: var(--s-5) var(--s-4);
  }
  .gen-title { font-size: 18px; }

  /* Preflight panel */
  .preflight-list { gap: 6px; }
  .preflight-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }
  .preflight-item-target { align-self: flex-end; }

  /* Touch-friendly tap targets */
  .pill, .aspect-card, .preset-card, .nav-item {
    min-height: 36px;
  }

  /* Hide intricate cinematography badges that don't fit */
  .cine-badges { gap: 4px; }
  .cine-badge { font-size: 10px; padding: 2px 5px; }
}

/* Even tighter for very small screens */
@media (max-width: 380px) {
  .hero h1 { font-size: 26px; }
  .aspect-grid { grid-template-columns: 1fr; }
  .topbar .lang-btn { padding: 4px 6px; font-size: 10px; }
}
