/* ==========================================================================
   Image Studio — design system
   Dark-first, glass surfaces, one accent gradient used sparingly.
   ========================================================================== */

:root {
  --accent-1: #6366f1;
  --accent-2: #a855f7;
  --accent-3: #ec4899;
  --accent-grad: linear-gradient(120deg, var(--accent-1), var(--accent-2) 55%, var(--accent-3));
  --radius-sm: 10px;
  --radius: 16px;
  --radius-lg: 24px;
  --ring: 0 0 0 3px rgb(99 102 241 / 0.35);
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, monospace;
  --shadow-sm: 0 1px 2px rgb(0 0 0 / 0.16);
  --shadow: 0 12px 32px -12px rgb(0 0 0 / 0.5);
  --shadow-lg: 0 32px 64px -24px rgb(0 0 0 / 0.6);
  --transition: 180ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* --- Dark (default) ------------------------------------------------------ */
[data-bs-theme="dark"] {
  --bg: #0a0a0f;
  --bg-elevated: #12121a;
  --surface: rgb(255 255 255 / 0.035);
  --surface-hover: rgb(255 255 255 / 0.06);
  --surface-solid: #16161f;
  --border: rgb(255 255 255 / 0.08);
  --border-strong: rgb(255 255 255 / 0.16);
  --text: #eceef3;
  --text-muted: #9096a6;
  --text-dim: #656b7c;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --bs-secondary-color: var(--text-muted);
  --bs-emphasis-color: #fff;
}

/* --- Light --------------------------------------------------------------- */
[data-bs-theme="light"] {
  --bg: #f6f7fb;
  --bg-elevated: #ffffff;
  --surface: rgb(255 255 255 / 0.85);
  --surface-hover: #ffffff;
  --surface-solid: #ffffff;
  --border: rgb(15 23 42 / 0.09);
  --border-strong: rgb(15 23 42 / 0.18);
  --text: #16181d;
  --text-muted: #5b6272;
  --text-dim: #858c9c;
  --bs-body-bg: var(--bg);
  --bs-body-color: var(--text);
  --bs-border-color: var(--border);
  --shadow: 0 12px 32px -16px rgb(15 23 42 / 0.22);
  --shadow-lg: 0 32px 64px -28px rgb(15 23 42 / 0.28);
}

/* ==========================================================================
   Base
   ========================================================================== */

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  background-color: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.011em;
}

/* Two soft accent auroras behind everything. Fixed, non-interactive. */
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(60rem 40rem at 12% -8%, rgb(99 102 241 / 0.16), transparent 60%),
    radial-gradient(50rem 36rem at 92% 4%, rgb(236 72 153 / 0.11), transparent 60%);
}
[data-bs-theme="light"] body::before {
  background:
    radial-gradient(60rem 40rem at 12% -8%, rgb(99 102 241 / 0.10), transparent 60%),
    radial-gradient(50rem 36rem at 92% 4%, rgb(236 72 153 / 0.07), transparent 60%);
}

h1, h2, h3, h4, h5 { font-weight: 650; letter-spacing: -0.025em; }
a { color: var(--accent-2); text-decoration: none; transition: color var(--transition); }
a:hover { color: var(--accent-3); }
code, pre, .mono { font-family: var(--font-mono); font-size: 0.86em; }

::selection { background: rgb(168 85 247 / 0.35); }

:focus-visible {
  outline: none;
  box-shadow: var(--ring);
  border-radius: var(--radius-sm);
}

.text-muted, .text-secondary { color: var(--text-muted) !important; }
.text-dim { color: var(--text-dim); }

.gradient-text {
  background: var(--accent-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.eyebrow {
  font-size: 0.7rem;
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-dim);
}

/* ==========================================================================
   Navbar
   ========================================================================== */

.app-nav {
  position: sticky;
  top: 0;
  z-index: 1030;
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  background: color-mix(in srgb, var(--bg) 78%, transparent);
  border-bottom: 1px solid var(--border);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-weight: 700;
  font-size: 1.05rem;
  color: var(--text);
  letter-spacing: -0.03em;
}
.brand:hover { color: var(--text); }

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 15px;
  box-shadow: 0 4px 14px -4px rgb(139 92 246 / 0.7);
}

.nav-link-app {
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 520;
  padding: 0.4rem 0.85rem;
  border-radius: 9px;
  transition: all var(--transition);
}
.nav-link-app:hover { color: var(--text); background: var(--surface-hover); }
.nav-link-app.active { color: var(--text); background: var(--surface-hover); }

/* ==========================================================================
   Surfaces
   ========================================================================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.panel-solid { background: var(--surface-solid); }

.panel-pad { padding: 1.5rem; }

.panel-hover { transition: transform var(--transition), border-color var(--transition), box-shadow var(--transition); }
.panel-hover:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow);
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--border);
}
.panel-header h2, .panel-header h3 { margin: 0; font-size: 1rem; font-weight: 650; }

.divider { height: 1px; background: var(--border); border: 0; margin: 1.5rem 0; }

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  border-radius: 10px;
  font-weight: 560;
  font-size: 0.875rem;
  padding: 0.5rem 1rem;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.btn-gradient {
  background: var(--accent-grad);
  background-size: 160% 160%;
  color: #fff;
  border: 0;
  box-shadow: 0 6px 18px -8px rgb(139 92 246 / 0.85);
}
.btn-gradient:hover {
  color: #fff;
  background-position: 100% 0;
  transform: translateY(-1px);
  box-shadow: 0 10px 26px -8px rgb(139 92 246 / 0.95);
}
.btn-gradient:disabled { opacity: 0.55; transform: none; box-shadow: none; }

.btn-ghost {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-ghost:hover { background: var(--surface-hover); border-color: var(--border-strong); color: var(--text); }

.btn-danger-ghost {
  background: transparent;
  border: 1px solid rgb(239 68 68 / 0.35);
  color: #f87171;
}
.btn-danger-ghost:hover { background: rgb(239 68 68 / 0.12); color: #fca5a5; }

.btn-icon {
  width: 34px;
  height: 34px;
  padding: 0;
  display: inline-grid;
  place-items: center;
  border-radius: 9px;
}

/* ==========================================================================
   Forms
   ========================================================================== */

.form-label {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.form-control, .form-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 0.6rem 0.85rem;
  font-size: 0.9rem;
  transition: all var(--transition);
}
.form-control:focus, .form-select:focus {
  background: var(--surface-hover);
  border-color: var(--accent-1);
  color: var(--text);
  box-shadow: var(--ring);
}
/* The open list of a native <select> can't be translucent: most browsers draw it
   on white, which made near-white option text unreadable in the dark theme. */
[data-bs-theme="dark"] { color-scheme: dark; }
[data-bs-theme="light"] { color-scheme: light; }
.form-select option,
.form-select optgroup { background-color: var(--bg-elevated); color: var(--text); }
.form-select optgroup { font-weight: 600; color: var(--text-muted); }
.form-select option:disabled { color: var(--text-dim); }
.form-select option:checked { background-color: var(--accent-1); color: #fff; }
.form-control::placeholder { color: var(--text-dim); }
.form-control:disabled { opacity: 0.6; }

.form-text { color: var(--text-dim); font-size: 0.78rem; }

.form-check-input { background-color: var(--surface); border-color: var(--border-strong); }
.form-check-input:checked { background-color: var(--accent-1); border-color: var(--accent-1); }
.form-check-label { font-size: 0.875rem; }

/* Segmented number/choice control */
.segmented {
  display: inline-flex;
  gap: 0.25rem;
  padding: 0.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  flex-wrap: wrap;
}
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label {
  padding: 0.35rem 0.75rem;
  border-radius: 9px;
  font-size: 0.83rem;
  font-weight: 560;
  color: var(--text-muted);
  cursor: pointer;
  transition: all var(--transition);
  user-select: none;
}
.segmented label:hover { color: var(--text); background: var(--surface-hover); }
.segmented input:checked + label {
  background: var(--accent-grad);
  color: #fff;
  box-shadow: 0 3px 10px -4px rgb(139 92 246 / 0.8);
}

/* ==========================================================================
   Dropzone
   ========================================================================== */

.dropzone {
  position: relative;
  border: 2px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  padding: 2.5rem 1.5rem;
  text-align: center;
  cursor: pointer;
  background: var(--surface);
  transition: all var(--transition);
  overflow: hidden;
}
.dropzone:hover, .dropzone.is-dragover {
  border-color: var(--accent-2);
  background: rgb(168 85 247 / 0.06);
}
.dropzone.is-dragover { transform: scale(1.01); }
.dropzone input[type="file"] { display: none; }

.dropzone-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--accent-grad);
  display: grid;
  place-items: center;
  margin: 0 auto 1rem;
  color: #fff;
  font-size: 24px;
  box-shadow: 0 10px 28px -10px rgb(139 92 246 / 0.9);
}

.dropzone-preview {
  display: none;
  max-height: 320px;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.dropzone.has-file .dropzone-preview { display: block; margin: 0 auto; }
.dropzone.has-file .dropzone-idle { display: none; }

/* ==========================================================================
   Status badges
   ========================================================================== */

.badge-status {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 620;
  letter-spacing: 0.02em;
  text-transform: capitalize;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-status::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex: none;
}
.badge-status.is-complete { color: #34d399; background: rgb(52 211 153 / 0.12); border-color: rgb(52 211 153 / 0.28); }
.badge-status.is-generating,
.badge-status.is-prompting,
.badge-status.is-running,
.badge-status.is-pending { color: #60a5fa; background: rgb(96 165 250 / 0.12); border-color: rgb(96 165 250 / 0.28); }
.badge-status.is-generating::before,
.badge-status.is-prompting::before,
.badge-status.is-running::before { animation: pulse 1.4s ease-in-out infinite; }
.badge-status.is-partial { color: #fbbf24; background: rgb(251 191 36 / 0.12); border-color: rgb(251 191 36 / 0.28); }
.badge-status.is-failed { color: #f87171; background: rgb(248 113 113 / 0.12); border-color: rgb(248 113 113 / 0.28); }
.badge-status.is-cancelled,
.badge-status.is-prompts_ready { color: var(--text-muted); background: var(--surface); border-color: var(--border); }

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.35; transform: scale(0.75); }
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 560;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-muted);
}

/* ==========================================================================
   Progress
   ========================================================================== */

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--accent-grad);
  background-size: 200% 100%;
  transition: width 400ms cubic-bezier(0.4, 0, 0.2, 1);
  animation: shift 2.5s linear infinite;
}
@keyframes shift {
  to { background-position: 200% 0; }
}

/* ==========================================================================
   Image grid
   ========================================================================== */

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1.1rem;
}

.tile {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: all var(--transition);
  animation: rise 320ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.tile:hover {
  border-color: var(--border-strong);
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}
.tile.is-selected {
  border-color: var(--accent-2);
  box-shadow: 0 0 0 2px rgb(168 85 247 / 0.5), var(--shadow);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: none; }
}

.tile-media {
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--bg-elevated);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.tile-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  transition: transform 450ms cubic-bezier(0.2, 0.8, 0.2, 1);
}
.tile:hover .tile-media img { transform: scale(1.045); }

.tile-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 0.7rem;
  gap: 0.4rem;
  background: linear-gradient(to top, rgb(0 0 0 / 0.82), rgb(0 0 0 / 0.15) 45%, transparent 70%);
  opacity: 0;
  transition: opacity var(--transition);
}
.tile:hover .tile-overlay, .tile:focus-within .tile-overlay { opacity: 1; }

.tile-action {
  background: rgb(255 255 255 / 0.14);
  backdrop-filter: blur(10px);
  border: 1px solid rgb(255 255 255 / 0.18);
  color: #fff;
  border-radius: 9px;
  padding: 0.3rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 560;
  transition: all var(--transition);
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}
.tile-action:hover { background: rgb(255 255 255 / 0.28); color: #fff; }

.tile-check {
  position: absolute;
  top: 0.6rem;
  left: 0.6rem;
  z-index: 3;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  background: rgb(0 0 0 / 0.45);
  border: 1px solid rgb(255 255 255 / 0.35);
  /* Visible at rest: a hover-only checkbox is undiscoverable, and it is the
     only way into the multi-select download. */
  opacity: 0.65;
  transition: opacity var(--transition);
}
.tile:hover .tile-check, .tile-check:checked, .tile-check:focus-visible { opacity: 1; }
.image-grid:hover .tile-check { opacity: 0.85; }
.tile-check:checked { background-color: var(--accent-2); border-color: var(--accent-2); }

.tile-badge {
  position: absolute;
  top: 0.6rem;
  right: 0.6rem;
  z-index: 2;
}

.tile-body { padding: 0.75rem 0.85rem 0.85rem; }
.tile-prompt {
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.tile-meta {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-top: 0.55rem;
  font-size: 0.7rem;
  color: var(--text-dim);
  flex-wrap: wrap;
}

/* Skeleton shimmer while an image is pending or running */
.skeleton {
  position: relative;
  width: 100%;
  height: 100%;
  background: linear-gradient(100deg, var(--surface) 30%, var(--surface-hover) 50%, var(--surface) 70%);
  background-size: 240% 100%;
  animation: shimmer 1.6s ease-in-out infinite;
  display: grid;
  place-items: center;
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to { background-position: -60% 0; }
}

.tile-error {
  padding: 1rem;
  font-size: 0.75rem;
  color: #fca5a5;
  text-align: center;
  line-height: 1.5;
  max-height: 100%;
  overflow: auto;
}

/* ==========================================================================
   Prompt editor
   ========================================================================== */

.prompt-row {
  display: flex;
  gap: 0.85rem;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  transition: all var(--transition);
  animation: rise 280ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}
.prompt-row:hover { border-color: var(--border-strong); }
.prompt-row.is-removing { opacity: 0; transform: translateX(-16px); }

.prompt-index {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--accent-grad);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.prompt-text {
  flex: 1;
  background: transparent;
  border: 0;
  color: var(--text);
  font-size: 0.875rem;
  line-height: 1.6;
  resize: none;
  padding: 0.15rem 0;
  min-height: 3.5rem;
}
.prompt-text:focus { outline: none; box-shadow: none; }

.prompt-tools { display: flex; flex-direction: column; gap: 0.3rem; flex: none; }

/* ==========================================================================
   Lineage
   ========================================================================== */

.lineage {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.lineage-node {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.6rem 0.35rem 0.35rem;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  transition: all var(--transition);
}
.lineage-node:hover { border-color: var(--accent-2); }
.lineage-node.is-current { border-color: var(--accent-2); background: rgb(168 85 247 / 0.1); }
.lineage-node img { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; }
.lineage-node span { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); }
.lineage-arrow { color: var(--text-dim); font-size: 0.9rem; }

/* ==========================================================================
   Log console
   ========================================================================== */

.log-console {
  font-family: var(--font-mono);
  font-size: 0.74rem;
  line-height: 1.7;
  max-height: 280px;
  overflow-y: auto;
  padding: 0.9rem 1.1rem;
  background: var(--bg-elevated);
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.log-line { display: flex; gap: 0.7rem; }
.log-time { color: var(--text-dim); flex: none; }
.log-line.level-error .log-msg { color: #f87171; }
.log-line.level-warning .log-msg { color: #fbbf24; }
.log-msg { color: var(--text-muted); word-break: break-word; }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-app {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 0.875rem;
}
.table-app th {
  text-align: left;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--text-dim);
  font-weight: 640;
  padding: 0.7rem 1rem;
  border-bottom: 1px solid var(--border);
}
.table-app td {
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text);
}
.table-app tbody tr { transition: background var(--transition); }
.table-app tbody tr:hover { background: var(--surface-hover); }
.table-app tbody tr:last-child td { border-bottom: 0; }

/* ==========================================================================
   Run history cards
   ========================================================================== */

.run-card { display: block; color: inherit; overflow: hidden; }
.run-card:hover { color: inherit; }

.run-strip {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  aspect-ratio: 5 / 1.6;
  background: var(--bg-elevated);
}
.run-strip img { width: 100%; height: 100%; object-fit: cover; display: block; }
.run-strip .empty { background: var(--surface); }

/* ==========================================================================
   Toasts / misc
   ========================================================================== */

.toast-stack {
  position: fixed;
  bottom: 1.25rem;
  right: 1.25rem;
  z-index: 1080;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-width: min(28rem, calc(100vw - 2.5rem));
}
.toast-app {
  padding: 0.8rem 1.1rem;
  border-radius: 12px;
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 0.85rem;
  animation: rise 260ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
  display: flex;
  gap: 0.6rem;
  align-items: flex-start;
}
.toast-app.is-success { border-left: 3px solid #34d399; }
.toast-app.is-danger { border-left: 3px solid #f87171; }
.toast-app.is-warning { border-left: 3px solid #fbbf24; }
.toast-app.is-info { border-left: 3px solid var(--accent-2); }

.modal-content {
  background: var(--surface-solid);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  color: var(--text);
}
.modal-header, .modal-footer { border-color: var(--border); }

.empty-state {
  text-align: center;
  padding: 4rem 1.5rem;
  color: var(--text-muted);
}
.empty-state .icon {
  width: 64px;
  height: 64px;
  border-radius: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  display: grid;
  place-items: center;
  margin: 0 auto 1.25rem;
  font-size: 26px;
  color: var(--text-dim);
}

.stat {
  padding: 0.9rem 1.1rem;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
}
.stat .value { font-size: 1.35rem; font-weight: 680; letter-spacing: -0.03em; }
.stat .label { font-size: 0.7rem; text-transform: uppercase; letter-spacing: 0.09em; color: var(--text-dim); }

.sticky-actions {
  position: sticky;
  bottom: 0;
  z-index: 20;
  padding: 1rem 1.25rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  margin-top: 1.5rem;
  border-radius: var(--radius) var(--radius) 0 0;
}

.scroll-thin::-webkit-scrollbar { width: 8px; height: 8px; }
.scroll-thin::-webkit-scrollbar-track { background: transparent; }
.scroll-thin::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 999px; }
.scroll-thin::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

.spinner-app {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border-strong);
  border-top-color: var(--accent-2);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
  display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 576px) {
  .panel-pad { padding: 1.15rem; }
  .image-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 0.75rem; }
}

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

/* ---------------------------------------------------------------- Animations */
.film-thumb { position: relative; aspect-ratio: 16 / 9; background: var(--bg-elevated); overflow: hidden; }
.film-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform var(--transition); }
.run-card:hover .film-thumb img { transform: scale(1.03); }
.film-thumb-empty { position: absolute; inset: 0; display: grid; place-items: center; font-size: 2rem; color: var(--text-dim, #888); }
.film-duration { position: absolute; right: .5rem; bottom: .5rem; background: rgb(0 0 0 / .65); color: #fff; font-size: .72rem;
  padding: .1rem .45rem; border-radius: 6px; font-variant-numeric: tabular-nums; }
.film-stage { container-type: inline-size; overflow: hidden; padding: 0; background: #17130f; }
.film-stage iframe { width: 100%; height: calc(100cqw * 9 / 16 + 54px); border: 0; display: block; }
.film-stage-empty { aspect-ratio: 16 / 9; }
.film-stage-empty { display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; padding: 1rem; }
.film-steps { display: flex; flex-wrap: wrap; gap: .4rem; }
.film-steps .pill { opacity: .55; }
.film-steps .pill.is-done { opacity: 1; color: #34d399; border-color: rgb(52 211 153 / .35); }
.film-steps .pill.is-now { opacity: 1; color: #60a5fa; border-color: rgb(96 165 250 / .45); }
.film-downloads { display: flex; flex-direction: column; gap: .15rem; }
.film-dl { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .55rem 0; border-bottom: 1px solid var(--border); }
.film-dl:last-child { border-bottom: 0; }
.film-dl-action { flex: none; }
.film-script { padding-left: 1.3rem; display: grid; gap: .35rem; font-size: .92rem; }
.film-script li::marker { color: var(--text-dim, #888); font-size: .8em; }
.spinner-app.spinner-sm { width: 12px; height: 12px; border-width: 2px; display: inline-block; vertical-align: -1px; }
.badge-status.is-queued,
.badge-status.is-writing,
.badge-status.is-producing { color: #60a5fa; background: rgb(96 165 250 / 0.12); border-color: rgb(96 165 250 / 0.28); }
.badge-status.is-writing::before,
.badge-status.is-producing::before { animation: pulse 1.4s ease-in-out infinite; }

/* ---------------------------------------------------------------- Names
   Run and film names: wrap to at most two lines, then "…". The full name is
   in the title attribute, and the text itself is tidied by the display_name /
   short template filters (app/naming.py). */
.name-clamp {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  overflow: hidden;
  overflow-wrap: anywhere;
  min-width: 0;
}
.name-inline {
  display: inline-block;
  max-width: min(32ch, 60vw);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
}
