/* ============================================================================
   YouTube Creation Dashboard — design system
   Hand-written so the app has no runtime CSS dependency and works offline.
   ========================================================================= */

:root {
  --bg: #0b0d12;
  --surface: #12151e;
  --surface-2: #181c28;
  --surface-3: #1f2432;
  --border: #262c3a;
  --border-strong: #333a4d;

  --text: #e8ebf2;
  --text-dim: #a2aabd;
  --text-mute: #6f7789;

  --accent: #f43f5e;
  --accent-hover: #fb5570;
  --accent-soft: rgba(244, 63, 94, 0.14);
  --accent-2: #8b5cf6;

  --ok: #22c55e;
  --ok-soft: rgba(34, 197, 94, 0.14);
  --warn: #f59e0b;
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger: #ef4444;
  --danger-soft: rgba(239, 68, 68, 0.14);
  --info: #38bdf8;
  --info-soft: rgba(56, 189, 248, 0.14);

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px -8px rgba(0, 0, 0, 0.5);
  --shadow-lg: 0 24px 60px -12px rgba(0, 0, 0, 0.7);

  --sidebar-w: 248px;
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

:root[data-theme="light"] {
  --bg: #f6f7fb;
  --surface: #ffffff;
  --surface-2: #f2f4f9;
  --surface-3: #e9ecf4;
  --border: #e2e6ef;
  --border-strong: #cdd4e2;

  --text: #131722;
  --text-dim: #545c70;
  --text-mute: #858da1;

  --accent-soft: rgba(244, 63, 94, 0.1);
  --ok-soft: rgba(34, 197, 94, 0.12);
  --warn-soft: rgba(245, 158, 11, 0.14);
  --danger-soft: rgba(239, 68, 68, 0.1);
  --info-soft: rgba(56, 189, 248, 0.14);

  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px -12px rgba(16, 24, 40, 0.12);
  --shadow-lg: 0 24px 60px -16px rgba(16, 24, 40, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

h1,
h2,
h3,
h4 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.25;
}

h1 { font-size: 22px; }
h2 { font-size: 17px; }
h3 { font-size: 15px; }

p { margin: 0 0 10px; }
p:last-child { margin-bottom: 0; }

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

/* --- Layout -------------------------------------------------------------- */

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

.sidebar {
  width: var(--sidebar-w);
  flex: 0 0 var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 20px 18px 18px;
}

.brand-mark {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  display: grid;
  place-items: center;
  color: #fff;
  flex: none;
}

.brand-mark svg { width: 17px; height: 17px; }

.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 680; font-size: 14px; letter-spacing: -0.01em; }
.brand-sub { font-size: 11px; color: var(--text-mute); }

.nav {
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.nav-label {
  font-size: 10.5px;
  font-weight: 640;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 16px 8px 6px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-weight: 500;
  font-size: 13.5px;
  transition: background 0.14s, color 0.14s;
}

.nav-item:hover { background: var(--surface-2); color: var(--text); }

.nav-item.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.nav-item svg { width: 16px; height: 16px; flex: none; }

.nav-count {
  margin-left: auto;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  color: var(--text-mute);
  background: var(--surface-2);
  padding: 1px 7px;
  border-radius: 20px;
}

.sidebar-foot {
  margin-top: auto;
  padding: 14px;
  border-top: 1px solid var(--border);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 60px;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 26px;
  position: sticky;
  top: 0;
  z-index: 20;
}

.topbar-title { font-size: 15px; font-weight: 640; letter-spacing: -0.01em; }
.topbar-sub { font-size: 12.5px; color: var(--text-mute); }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }

.content { padding: 26px; max-width: 1240px; width: 100%; }
.content.wide { max-width: none; }

.page-head {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  margin-bottom: 22px;
}

.page-head .grow { flex: 1; min-width: 0; }
.page-desc { color: var(--text-dim); font-size: 13.5px; margin-top: 4px; }

/* --- Cards --------------------------------------------------------------- */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-head {
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.card-head .grow { flex: 1; min-width: 0; }
.card-body { padding: 18px; }
.card-foot {
  padding: 13px 18px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
}

.grid { display: grid; gap: 14px; }
.grid.cols-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid.cols-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid.cols-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

@media (max-width: 1080px) {
  .grid.cols-3, .grid.cols-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 720px) {
  .grid.cols-2, .grid.cols-3, .grid.cols-4 { grid-template-columns: minmax(0, 1fr); }
}

.row { display: flex; align-items: center; gap: 10px; }
.row.wrap { flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.stack.tight { gap: 8px; }

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

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  font-weight: 560;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.14s, border-color 0.14s, opacity 0.14s, transform 0.06s;
}

.btn:hover { background: var(--surface-3); border-color: var(--border-strong); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--text-dim); }
.btn-ghost:hover { background: var(--surface-2); color: var(--text); }

.btn-danger { background: transparent; border-color: var(--border-strong); color: var(--danger); }
.btn-danger:hover { background: var(--danger-soft); border-color: var(--danger); }

.btn-sm { height: 30px; padding: 0 10px; font-size: 12.5px; border-radius: 7px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 42px; padding: 0 20px; font-size: 14.5px; }
.btn-icon { width: 34px; padding: 0; }
.btn-icon.btn-sm { width: 28px; }
.btn-block { width: 100%; }

/* --- Forms --------------------------------------------------------------- */

.field { display: flex; flex-direction: column; gap: 6px; }

.label {
  font-size: 12.5px;
  font-weight: 580;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}

.hint { font-size: 12px; color: var(--text-mute); line-height: 1.45; }

.input,
.select,
.textarea {
  width: 100%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: 13.5px;
  padding: 9px 11px;
  transition: border-color 0.14s, box-shadow 0.14s;
}

.input:focus,
.select:focus,
.textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

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

.textarea { resize: vertical; min-height: 92px; line-height: 1.6; }
.textarea.script { min-height: 320px; font-size: 14px; line-height: 1.75; }

.select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%238b93a7' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
  padding-right: 30px;
  cursor: pointer;
}

input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 4px;
  background: var(--surface-3);
  outline: none;
  cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}

input[type="range"]::-moz-range-thumb {
  width: 15px;
  height: 15px;
  border: 2px solid var(--surface);
  border-radius: 50%;
  background: var(--accent);
}

.slider-row { display: flex; flex-direction: column; gap: 7px; }
.slider-head { display: flex; justify-content: space-between; align-items: baseline; }
.slider-val {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text);
  background: var(--surface-3);
  padding: 1px 7px;
  border-radius: 5px;
}

.switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; }
.switch input { display: none; }

.switch-track {
  width: 36px;
  height: 20px;
  border-radius: 20px;
  background: var(--surface-3);
  border: 1px solid var(--border-strong);
  position: relative;
  transition: background 0.16s, border-color 0.16s;
  flex: none;
}

.switch-track::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform 0.16s, background 0.16s;
}

.switch input:checked + .switch-track { background: var(--accent); border-color: var(--accent); }
.switch input:checked + .switch-track::after { transform: translateX(16px); background: #fff; }

.dropzone {
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  padding: 22px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.16s, background 0.16s;
  background: var(--surface-2);
}

.dropzone:hover,
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone input { display: none; }
.dropzone-icon { color: var(--text-mute); margin-bottom: 6px; }
.dropzone-icon svg { width: 22px; height: 22px; }

/* --- Badges & chips ------------------------------------------------------ */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 580;
  padding: 2px 8px;
  border-radius: 20px;
  background: var(--surface-3);
  color: var(--text-dim);
  white-space: nowrap;
}

.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.danger { background: var(--danger-soft); color: var(--danger); }
.badge.info { background: var(--info-soft); color: var(--info); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }

.dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  padding: 2px 8px;
  border-radius: 6px;
  background: var(--surface-3);
  color: var(--text-dim);
}

.kbd {
  font-family: var(--mono);
  font-size: 11px;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text-dim);
}

/* --- Stat tiles ---------------------------------------------------------- */

.stat {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
}

.stat-label {
  font-size: 11.5px;
  font-weight: 580;
  color: var(--text-mute);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.stat-value {
  font-size: 24px;
  font-weight: 660;
  letter-spacing: -0.02em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}

.stat-sub { font-size: 12px; color: var(--text-mute); margin-top: 2px; }

/* --- Progress ------------------------------------------------------------ */

.progress {
  height: 6px;
  border-radius: 6px;
  background: var(--surface-3);
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s ease;
}

.progress.thin { height: 4px; }
.progress-bar.ok { background: var(--ok); }
.progress-bar.warn { background: var(--warn); }

.score-bar {
  height: 5px;
  border-radius: 5px;
  background: var(--surface-3);
  overflow: hidden;
  width: 100%;
}

.score-fill { height: 100%; border-radius: 5px; transition: width 0.4s ease; }

/* --- Stepper ------------------------------------------------------------- */

.stepper {
  display: flex;
  align-items: stretch;
  gap: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-bottom: 20px;
}

.step {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.14s;
  min-width: 0;
}

.step:last-child { border-right: none; }
.step:hover { background: var(--surface-2); }
.step.active { background: var(--accent-soft); }
.step[aria-disabled="true"] { cursor: not-allowed; opacity: 0.5; }

.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 12px;
  font-weight: 640;
  background: var(--surface-3);
  color: var(--text-dim);
  flex: none;
}

.step.active .step-num { background: var(--accent); color: #fff; }
.step.done .step-num { background: var(--ok-soft); color: var(--ok); }
.step-text { min-width: 0; }
.step-name { font-size: 13px; font-weight: 580; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.step.active .step-name { color: var(--accent); }
.step-meta { font-size: 11px; color: var(--text-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

@media (max-width: 900px) {
  .stepper { flex-wrap: wrap; }
  .step { flex: 1 1 50%; border-bottom: 1px solid var(--border); }
}

/* --- Tables -------------------------------------------------------------- */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}

table { width: 100%; border-collapse: collapse; font-size: 13px; }

th {
  text-align: left;
  font-size: 11.5px;
  font-weight: 620;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-mute);
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--surface-2);
  white-space: nowrap;
  position: sticky;
  top: 0;
}

td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: var(--surface-2); }
.num { font-variant-numeric: tabular-nums; }

/* --- Lists --------------------------------------------------------------- */

.list-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.14s;
}

.list-item:last-child { border-bottom: none; }
.list-item:hover { background: var(--surface-2); }

.title-card {
  display: flex;
  gap: 14px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  cursor: pointer;
  transition: border-color 0.14s, background 0.14s;
}

.title-card:hover { border-color: var(--border-strong); }
.title-card.selected { border-color: var(--accent); background: var(--accent-soft); }
.title-card .rank {
  font-family: var(--mono);
  font-size: 12px;
  color: var(--text-mute);
  width: 20px;
  flex: none;
  padding-top: 2px;
}
.title-card .text { font-size: 14.5px; font-weight: 580; line-height: 1.4; }
.title-card .meta { font-size: 12px; color: var(--text-mute); margin-top: 5px; }
.title-card .score {
  flex: none;
  width: 78px;
  text-align: right;
}
.title-card .score-num {
  font-size: 19px;
  font-weight: 660;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}

.scene-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.scene-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}

.scene-idx {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 620;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 1px 7px;
  border-radius: 5px;
}

.scene-body { padding: 14px; display: flex; flex-direction: column; gap: 12px; }

.prompt-block { display: flex; flex-direction: column; gap: 5px; }
.prompt-label {
  font-size: 11px;
  font-weight: 620;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-mute);
  display: flex;
  align-items: center;
  gap: 6px;
}

.prompt-text {
  font-size: 12.5px;
  line-height: 1.6;
  color: var(--text-dim);
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  white-space: pre-wrap;
  word-break: break-word;
}

.narration-text {
  font-size: 13.5px;
  line-height: 1.6;
  padding: 9px 11px;
  border-left: 2px solid var(--accent);
  background: var(--surface-2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* --- Empty & loading ----------------------------------------------------- */

.empty {
  text-align: center;
  padding: 52px 24px;
  color: var(--text-mute);
}

.empty-icon {
  width: 44px;
  height: 44px;
  margin: 0 auto 14px;
  border-radius: 12px;
  background: var(--surface-2);
  display: grid;
  place-items: center;
  color: var(--text-mute);
}

.empty-icon svg { width: 21px; height: 21px; }
.empty h3 { color: var(--text); margin-bottom: 5px; }
.empty p { font-size: 13px; max-width: 380px; margin: 0 auto 16px; }

.spinner {
  width: 15px;
  height: 15px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
  flex: none;
  display: inline-block;
}

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

.skeleton {
  background: linear-gradient(
    90deg,
    var(--surface-2) 25%,
    var(--surface-3) 50%,
    var(--surface-2) 75%
  );
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
  border-radius: var(--radius-sm);
}

@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.busy {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  color: var(--text-dim);
  font-size: 13px;
}

/* --- Callouts ------------------------------------------------------------ */

.callout {
  display: flex;
  gap: 10px;
  padding: 11px 13px;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.55;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-dim);
}

.callout svg { width: 15px; height: 15px; flex: none; margin-top: 1px; }
.callout.warn { background: var(--warn-soft); border-color: transparent; color: var(--warn); }
.callout.danger { background: var(--danger-soft); border-color: transparent; color: var(--danger); }
.callout.info { background: var(--info-soft); border-color: transparent; color: var(--info); }
.callout strong { color: inherit; }

/* --- Toasts -------------------------------------------------------------- */

.toasts {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: 380px;
}

.toast {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--surface);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-lg);
  font-size: 13px;
  animation: toast-in 0.22s cubic-bezier(0.2, 0.9, 0.3, 1);
}

.toast.error { border-left: 3px solid var(--danger); }
.toast.success { border-left: 3px solid var(--ok); }
.toast.info { border-left: 3px solid var(--info); }
.toast-body { flex: 1; min-width: 0; word-break: break-word; }
.toast-title { font-weight: 620; margin-bottom: 2px; }
.toast-msg { color: var(--text-dim); font-size: 12.5px; }

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

/* --- Modal --------------------------------------------------------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4, 6, 10, 0.6);
  backdrop-filter: blur(3px);
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 24px;
  animation: fade-in 0.16s;
}

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

.modal {
  width: 100%;
  max-width: 620px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  animation: modal-in 0.2s cubic-bezier(0.2, 0.9, 0.3, 1);
}

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

.modal-head {
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
}

.modal-body { padding: 20px; }
.modal-foot {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

/* --- Utilities ----------------------------------------------------------- */

.muted { color: var(--text-mute); }
.dim { color: var(--text-dim); }
.small { font-size: 12px; }
.mono { font-family: var(--mono); }
.tabnum { font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.center { text-align: center; }
.right { text-align: right; }
.mt-0 { margin-top: 0; }
.mt-8 { margin-top: 8px; }
.mt-14 { margin-top: 14px; }
.mt-20 { margin-top: 20px; }
.mb-8 { margin-bottom: 8px; }
.mb-14 { margin-bottom: 14px; }
.gap-6 { gap: 6px; }
.divider { height: 1px; background: var(--border); border: 0; margin: 0; }

audio {
  width: 100%;
  height: 34px;
  filter: var(--audio-filter, none);
}

:root:not([data-theme="light"]) audio {
  --audio-filter: invert(0.92) hue-rotate(180deg) saturate(0.7);
}

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 9px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-mute); }

/* ── Niche bank ──────────────────────────────────────────────────────────── */

.niche-card { padding: 16px; cursor: pointer; transition: border-color .15s, transform .15s; }
.niche-card:hover { border-color: var(--border-strong); transform: translateY(-1px); }
.niche-card h3 { font-size: 15px; margin: 0; }
.niche-card .row { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.niche-card p { margin: 2px 0 0; }

.pill {
  flex: none;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .02em;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--text-dim);
  text-transform: lowercase;
}
.pill[data-status="done"] { background: var(--ok-soft); color: var(--ok); }
.pill[data-status="partial"] { background: var(--warn-soft); color: var(--warn); }
.pill[data-status="failed"],
.pill[data-status="interrupted"] { background: var(--danger-soft); color: var(--danger); }
.pill[data-status="running"] { background: var(--info-soft); color: var(--info); }

/* A strip rather than a grid: screenshots are read in the order they were
   pasted, and a wrapping grid loses that. */
.shot-strip { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.shot {
  position: relative;
  width: 96px;
  height: 62px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.shot img { width: 100%; height: 100%; object-fit: cover; display: block; }
.shot-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 20px;
  height: 20px;
  padding: 0;
  line-height: 1;
  font-size: 15px;
  background: rgba(0, 0, 0, .6);
  color: #fff;
  border-radius: 999px;
}

.profile-row { display: grid; grid-template-columns: 180px 1fr; gap: 10px; align-items: start; }
.profile-row .label { margin: 0; }
@media (max-width: 640px) {
  .profile-row { grid-template-columns: 1fr; gap: 2px; }
}
