:root {
  --bg: #f4f6f8;
  --panel: #fff;
  --soft: #f8fafc;
  --line: #d8e0e8;
  --text: #17202a;
  --muted: #647282;
  --accent: #2563eb;
  --accent-soft: #edf4ff;
  --ok: #13765f;
  --warn: #a15c07;
  --danger: #c62828;
  --shadow: 0 2px 12px rgba(15, 23, 42, .06);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  color: var(--text);
  background: var(--bg);
  font-family: "Segoe UI", "Microsoft YaHei", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  overflow: auto;
}

/* ====== APP SHELL ====== */
.app {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100vh;
  min-width: 1180px;
  overflow: hidden;
}

/* ====== TOP BAR ====== */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 20px;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.topbar-left { display: flex; align-items: center; gap: 12px; }
.topbar-left h1 { font-size: 18px; font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
.account-summary { font-size: 12px; color: var(--muted); white-space: nowrap; }

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 20, 28, .86);
  backdrop-filter: blur(8px);
}
.auth-gate[hidden] { display: none; }
.auth-card {
  width: min(420px, 100%);
  padding: 28px;
  border-radius: 14px;
  background: var(--panel);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .38);
  display: grid;
  gap: 14px;
}
.auth-card label { display: grid; gap: 6px; font-size: 13px; color: var(--muted); }
.auth-card input,
.admin-form-grid input,
.admin-form-grid select {
  width: 100%;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  color: var(--text);
}
.auth-error { min-height: 20px; color: var(--danger); font-size: 12px; white-space: pre-wrap; }
.account-dialog { width: min(920px, 94vw); max-height: 90vh; overflow: auto; border: 1px solid var(--line); border-radius: 10px; padding: 18px; background: var(--panel); color: var(--text); }
.account-dialog::backdrop { background: rgba(15, 23, 42, .45); }
.admin-dialog { width: min(1180px, 96vw); }
.account-kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 12px 0 18px; }
.account-kpi { border: 1px solid var(--line); border-radius: 9px; padding: 12px; background: var(--soft); }
.account-kpi span { display: block; color: var(--muted); font-size: 12px; }
.account-kpi strong { display: block; margin-top: 5px; font-size: 20px; }
.billing-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.billing-table th, .billing-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.billing-table th { color: var(--muted); font-weight: 600; }
.admin-section { padding: 14px 0; border-bottom: 1px solid var(--line); }
.admin-form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; align-items: end; }
.admin-form-grid label { display: grid; gap: 5px; font-size: 12px; color: var(--muted); }
.user-admin-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.status-reserved { color: var(--warn); }
.status-settled { color: var(--ok); }
.status-failed { color: var(--muted); }
.badge {
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}
.step-indicator {
  font-size: 12px;
  color: var(--muted);
}
.status-text {
  max-width: 360px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  font-size: 12px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ====== BUTTONS ====== */
button {
  min-height: 34px;
  padding: 6px 14px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
}
button:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
button:active:not(:disabled) { transform: scale(.96); background: var(--accent-soft); }
button:disabled { opacity: .4; cursor: not-allowed; pointer-events: none; }
.btn-primary { border-color: var(--accent); background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { background: #1d4ed8; color: #fff; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-sm { min-height: 28px; padding: 3px 10px; font-size: 12px; }

/* ====== INPUTS ====== */
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px 10px;
  background: #fff;
  font: inherit;
  font-size: 13px;
}
textarea { resize: vertical; line-height: 1.6; min-height: 100px; }
.board-prompt-editor {
  width: 100%;
  min-height: 220px;
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}

/* ====== TEXT2VIDEO VIDEO CARDS ====== */
.t2v-video-summary {
  display: grid;
  grid-template-columns: repeat(5, minmax(110px, 1fr));
  gap: 8px;
  margin: 12px 0;
}
.t2v-video-summary > div {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #fff;
  padding: 10px 12px;
}
.t2v-video-summary strong {
  display: block;
  font-size: 20px;
  line-height: 1.1;
}
.t2v-video-summary span {
  color: var(--muted);
  font-size: 12px;
}
.t2v-card-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.t2v-card {
  display: grid;
  grid-template-columns: 220px minmax(360px, 1fr) 260px;
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--muted);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
}
.t2v-card-left,
.t2v-card-mid,
.t2v-card-right {
  min-width: 0;
}
.t2v-card-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
  border-right: 1px solid var(--line);
  padding-right: 12px;
}
.t2v-card-index strong {
  display: block;
  font-size: 15px;
}
.t2v-card-index span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.t2v-ref-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.t2v-ref-title {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}
.t2v-ref-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}
.t2v-ref-item {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  overflow: hidden;
}
.t2v-ref-item img,
.t2v-ref-empty {
  width: 100%;
  aspect-ratio: 16 / 10;
  display: block;
  object-fit: cover;
  background: #eef2f6;
}
.t2v-ref-empty {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 11px;
}
.t2v-ref-name {
  padding: 4px 6px;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.t2v-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}
.t2v-card-head strong {
  display: block;
  font-size: 14px;
}
.t2v-card-head span {
  color: var(--muted);
  font-size: 12px;
}
.t2v-prompt-box {
  border: 1px solid var(--line);
  border-radius: 7px;
  background: var(--soft);
  padding: 8px;
}
.t2v-prompt-box summary,
.t2v-small-details summary {
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}
.t2v-prompt-box summary span {
  color: var(--muted);
  font-weight: 400;
  margin-left: 6px;
}
.t2v-prompt-box textarea {
  min-height: 170px;
  max-height: 360px;
  font-family: Consolas, "Microsoft YaHei", monospace;
}
.t2v-small-details {
  margin-top: 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 8px;
}
.t2v-small-details pre {
  white-space: pre-wrap;
  font-size: 12px;
  margin-top: 6px;
}
.t2v-card-right {
  display: flex;
  flex-direction: column;
  gap: 8px;
  border-left: 1px solid var(--line);
  padding-left: 12px;
}
.t2v-video-status {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  border-radius: 7px;
  padding: 8px 10px;
  background: var(--soft);
  color: var(--muted);
  font-size: 12px;
}
.t2v-video-status.done {
  background: #e8f6f1;
  color: var(--ok);
}
.t2v-video-status.running {
  background: var(--accent-soft);
  color: var(--accent);
}
.t2v-video-status.failed {
  background: #fff0f0;
  color: var(--danger);
}
.t2v-video-status strong {
  font-size: 12px;
}
.t2v-progress {
  height: 8px;
  border-radius: 999px;
  overflow: hidden;
  background: #e8edf3;
}
.t2v-task-id {
  color: var(--muted);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.t2v-video-preview,
.t2v-video-empty {
  width: 100%;
  aspect-ratio: 16 / 9;
  border-radius: 7px;
  background: #0b1220;
}
.t2v-video-preview {
  object-fit: cover;
}
.t2v-video-empty {
  display: grid;
  place-items: center;
  color: #9aa6b2;
  font-size: 12px;
  border: 1px dashed #b8c2cc;
}
.t2v-download {
  text-align: center;
}
.t2v-alert {
  border-radius: 7px;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.5;
}
.t2v-alert.warn {
  border: 1px solid #f1d19b;
  background: #fff8ea;
  color: var(--warn);
}
.t2v-alert.bad {
  border: 1px solid #f1b5b5;
  background: #fff3f3;
  color: var(--danger);
}
.t2v-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
@media (max-width: 1280px) {
  .t2v-card {
    grid-template-columns: 190px minmax(300px, 1fr) 220px;
  }
}
h2 { font-size: 17px; }
h3 { font-size: 14px; }
.desc { color: var(--muted); font-size: 12px; margin-top: 4px; }

/* ====== MAIN LAYOUT ====== */
.main-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  min-height: 0;
  overflow: hidden;
}

/* ====== STEPPER ====== */
.stepper {
  overflow-y: auto;
  border-right: 1px solid var(--line);
  background: #fff;
  padding: 10px 0;
}
.step-item {
  display: grid;
  grid-template-columns: 28px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  cursor: pointer;
  border: none;
  border-left: 3px solid transparent;
  background: none;
  width: 100%;
  text-align: left;
  font-size: 13px;
  border-radius: 0;
  min-height: auto;
}
.step-item:hover:not(.locked) { background: var(--soft); }
.step-item.active {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}
.step-item.completed { color: var(--ok); }
.step-item.locked { color: #c0c8d2; cursor: not-allowed; }
.step-item.processing { color: var(--accent); }
.step-num {
  width: 22px; height: 22px;
  display: grid; place-items: center;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid var(--line);
  color: var(--muted);
}
.step-item.completed .step-num { border-color: var(--ok); background: var(--ok); color: #fff; }
.step-item.active .step-num { border-color: var(--accent); background: var(--accent); color: #fff; }
.step-item.processing .step-num { border-color: var(--accent); background: var(--accent); color: #fff; animation: pulse 1.2s infinite; }
.step-item.locked .step-num { border-color: #e0e4ea; color: #c0c8d2; }
.step-badge {
  font-size: 10px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--ok);
  color: #fff;
  display: none;
}
.step-item.completed .step-badge { display: block; }

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

/* ====== CONTENT ====== */
.content {
  overflow-y: auto;
  overflow-x: auto;
  padding: 20px;
  min-width: 0;
}
.panel { display: none; }
.panel.active { display: block; }
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

/* ====== MODE CARDS ====== */
.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 16px;
}
.mode-card {
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 22px;
  border-radius: 10px;
  text-align: left;
  min-height: 150px;
}
.mode-card strong { font-size: 18px; }
.mode-card span { color: var(--muted); font-size: 12px; }

/* ====== IMPORT TYPE SELECTOR ====== */
.import-type {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.import-type-card {
  position: relative;
  display: block;
  padding: 12px 14px 12px 38px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--soft);
  cursor: pointer;
  transition: border-color .15s, background .15s, box-shadow .15s;
}
.import-type-card:hover { border-color: var(--accent); }
.import-type-card input { position: absolute; opacity: 0; pointer-events: none; }
.import-type-card .it-dot {
  position: absolute;
  left: 14px; top: 14px;
  width: 16px; height: 16px;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: #fff;
  transition: border-color .15s;
}
.import-type-card .it-title { font-weight: 600; font-size: 14px; color: var(--text); }
.import-type-card .it-desc { color: var(--muted); font-size: 12px; margin-top: 4px; line-height: 1.55; }
.import-type-card:has(input:checked) {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 1px var(--accent) inset;
}
.import-type-card:has(input:checked) .it-dot {
  border-color: var(--accent);
  background: radial-gradient(circle, var(--accent) 0 5px, #fff 6px);
}
.import-type-card:has(input:checked) .it-title { color: var(--accent); }
@media (max-width: 640px) { .import-type { grid-template-columns: 1fr; } }

.import-draft-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
  margin-bottom: 12px;
}
.import-draft-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 8px;
}
.import-draft-head h3 { font-size: 15px; margin: 0; }
.import-draft-warning {
  border: 1px solid rgba(245, 158, 11, .35);
  background: #fff7ed;
  color: #9a3412;
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.5;
  margin-bottom: 8px;
}
.import-draft-stats,
.import-draft-issues {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 6px;
}
.import-draft-stats span,
.import-draft-issues span {
  border: 1px solid var(--line);
  background: var(--panel);
  border-radius: 999px;
  padding: 3px 8px;
}
.import-draft-episode-list {
  display: grid;
  gap: 6px;
  max-height: 360px;
  overflow: auto;
  margin-top: 10px;
  padding-right: 4px;
}
.import-draft-episode {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 8px;
  align-items: flex-start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  padding: 8px;
  cursor: pointer;
}
.import-draft-episode b { font-size: 13px; }
.import-draft-episode small {
  display: block;
  color: var(--muted);
  margin-top: 2px;
  font-size: 11px;
}
.import-draft-episode p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
.import-replace-check {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--text);
}

/* ====== TILE GRID ====== */
.tile-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}
.project-card {
  display: grid;
  align-content: start;
  gap: 8px;
  padding: 18px;
  text-align: left;
  border-radius: 9px;
  min-height: 130px;
  border: 1px solid var(--line);
  background: #fff;
}
.project-card strong { font-size: 16px; }
.project-open {
  display: grid;
  gap: 6px;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
}
.project-open:hover { background: transparent; }
.meta-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
.pill {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  color: var(--muted);
  background: var(--soft);
}

/* ====== STEP CONTENT ====== */
.step-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.nav-buttons {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.nav-buttons > div {
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-header { margin-bottom: 14px; }
.step-header h2 { margin-bottom: 4px; }
.source-text { min-height: 320px; }

/* ====== ASSET CARD GRID ====== */
.asset-section { margin-bottom: 20px; }
.asset-section h3 {
  font-size: 14px; font-weight: 600; margin-bottom: 10px;
  padding-bottom: 6px; border-bottom: 2px solid var(--accent);
  display: flex; align-items: center; gap: 8px;
}
.asset-card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.asset-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fff;
  cursor: pointer;
  overflow: hidden;
  transition: box-shadow .15s, border-color .15s;
  display: grid;
  grid-template-rows: 120px auto;
}
.asset-card:hover { border-color: var(--accent); box-shadow: 0 4px 16px rgba(37,99,235,.1); }
.asset-card.expanded { grid-column: 1 / -1; grid-template-rows: auto; cursor: default; border-color: var(--accent); box-shadow: var(--shadow); }
.asset-card-thumb {
  width: 100%; height: 120px;
  object-fit: cover;
  background: #e8eef5;
  border-bottom: 1px solid var(--line);
  cursor: zoom-in;
  position: relative;
}
.asset-card-thumb.no-image {
  display: grid; place-items: center;
  color: var(--muted); font-size: 12px;
}
.asset-card-info {
  padding: 8px 10px;
  display: grid; gap: 4px;
}
.asset-card-info .name { font-weight: 600; font-size: 13px; }
.asset-card-info .meta {
  display: flex; flex-wrap: wrap; gap: 4px; font-size: 10px;
}
.asset-card-badge {
  padding: 1px 6px; border-radius: 999px;
  font-size: 10px; font-weight: 600;
}
.asset-card-badge.ok { background: #d4edda; color: var(--ok); }
.asset-card-badge.warn { background: #fff3cd; color: var(--warn); }
.asset-card-badge.info { background: var(--accent-soft); color: var(--accent); }
.asset-candidate-panel {
  margin: 12px 0 18px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}
.asset-candidate-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.asset-candidate-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
}
.asset-candidate-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px;
}
.asset-candidate-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
}
.asset-candidate-title span {
  color: var(--accent);
  font-weight: 700;
}
.asset-candidate-title em {
  margin-left: auto;
  color: var(--muted);
  font-style: normal;
  font-size: 11px;
}
.asset-candidate-card p {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
.asset-candidate-remove {
  border: 1px solid rgba(239, 68, 68, .35);
  background: rgba(239, 68, 68, .08);
  color: var(--danger, #ef4444);
  border-radius: 6px;
  padding: 4px 8px;
  cursor: pointer;
}

/* Image zoom overlay */
.img-zoom-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.75);
  display: grid; place-items: center;
  z-index: 9999; cursor: zoom-out;
}
.img-zoom-overlay img {
  max-width: 90vw; max-height: 90vh;
  border-radius: 10px; box-shadow: 0 8px 40px rgba(0,0,0,.5);
  object-fit: contain;
}

/* Asset modal overlay */
.asset-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(15,23,42,.55);
  display: grid; place-items: center;
  z-index: 9998; padding: 40px;
}
.asset-modal {
  background: #fff; border-radius: 12px;
  max-width: min(900px, calc(100vw - 40px));
  max-height: 90vh;
  display: grid; grid-template-rows: auto 1fr;
  overflow: hidden; box-shadow: 0 8px 48px rgba(0,0,0,.2);
}
.asset-modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--line);
}
.asset-modal-head h3 { font-size: 15px; }
.asset-modal-close { min-height: auto; padding: 4px 10px; font-size: 14px; }
.asset-modal-body { overflow-y: auto; padding: 20px; }

/* Asset detail (inside modal) */
.asset-detail {
  display: grid;
  grid-template-columns: minmax(220px, 2fr) minmax(0, 3fr);
  gap: 24px;
}
.asset-detail-base {
  display: grid; gap: 8px; align-content: start;
}
.asset-detail-base img {
  width: 100%; border: 1px solid var(--line);
  border-radius: 9px; object-fit: cover;
  cursor: zoom-in;
}
.asset-detail-base img:hover { transform: scale(1.02); }
.asset-detail-placeholder {
  width: 100%; aspect-ratio: 16/9;
  display: grid; place-items: center;
  background: #e8eef5; border: 1px solid var(--line);
  border-radius: 9px; color: var(--muted); font-size: 13px;
}
.asset-detail-name { font-weight: 700; font-size: 14px; }
.asset-detail-meta { display: flex; flex-wrap: wrap; gap: 6px; font-size: 11px; color: var(--muted); }
.asset-detail-desc { font-size: 12px; color: var(--text); line-height: 1.6; }
.asset-detail-base pre {
  max-height: 100px; overflow: auto;
  white-space: pre-wrap; word-break: break-word;
  padding: 8px; border: 1px solid var(--line);
  border-radius: 6px; background: var(--soft);
  font-size: 11px; margin: 0;
}
.asset-prompt-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text);
}
.asset-prompt-editor {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px;
  font-size: 12px;
  line-height: 1.55;
  background: #fff;
}
.asset-prompt-editor.small { min-height: 86px; margin: 8px 10px 0; width: calc(100% - 20px); }
.asset-prompt-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.asset-source-title {
  font-size: 12px;
  font-weight: 800;
  color: var(--text);
  padding: 8px 10px 0;
}
.asset-source-desc {
  font-size: 11px;
  line-height: 1.5;
  color: var(--muted);
  padding: 2px 10px 6px;
}
.asset-style-control {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.asset-style-control label { font-size: 13px; font-weight: 700; }
.asset-style-control select { min-width: 220px; }
.asset-style-control span { color: var(--muted); font-size: 12px; }
.character-look-control { flex-wrap: wrap; }
.character-look-control input { min-width: min(420px, 100%); flex: 1; }
.asset-scope-tabs {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 10px 0 14px;
}
.asset-scope-tab {
  border: 1px solid var(--line);
  background: #fff;
  color: var(--text);
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
}
.asset-scope-tab.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 700;
}
.voice-lock {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
  max-height: 32px;
  overflow: hidden;
}
.asset-voice-lock {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  font-size: 12px;
  line-height: 1.5;
}
.asset-voice-lock b { display: block; margin-bottom: 4px; }
.asset-voice-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.asset-voice-mode {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 10px 0;
}
.asset-voice-mode label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 4px 8px;
  background: #fff;
  cursor: pointer;
}
.asset-voice-mode label.active {
  border-color: var(--accent);
  color: var(--accent);
  font-weight: 700;
}
.asset-voice-mode label:has(input:disabled) {
  opacity: .55;
  cursor: not-allowed;
}
.asset-voice-audio {
  padding: 8px 10px 0;
}
.asset-voice-audio-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 6px;
}
.asset-voice-player {
  width: 100%;
  height: 34px;
}
.asset-voice-file {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
  word-break: break-all;
}
.asset-voice-file.muted { color: var(--muted); }

/* Variant tree */
.asset-variant-tree {
  border-left: 2px solid var(--line);
  padding-left: 16px;
}
.variant-tree-title {
  font-size: 13px; font-weight: 600;
  color: var(--accent); margin-bottom: 12px;
}
.variant-tree-node {
  display: grid; grid-template-columns: 24px 1fr;
  margin-bottom: 12px;
}
.variant-tree-connector {
  font-family: monospace; font-size: 14px;
  color: var(--muted); padding-top: 12px;
}
.variant-tree-content {
  border: 1px solid var(--line);
  border-radius: 8px; background: var(--soft);
  overflow: hidden;
}
.variant-tree-row {
  display: grid;
  grid-template-columns: 120px 1fr auto;
  gap: 12px; align-items: center;
  padding: 10px;
}
.variant-tree-row img {
  width: 120px; height: 68px;
  object-fit: cover; border-radius: 6px;
  border: 1px solid var(--line);
  cursor: zoom-in;
}
.variant-placeholder-sm {
  width: 120px; height: 68px;
  display: grid; place-items: center;
  background: #e8eef5; border: 1px solid var(--line);
  border-radius: 6px; font-size: 10px; color: var(--muted);
}
.variant-tree-info { font-size: 12px; display: grid; gap: 3px; }
.variant-tree-info b { font-size: 13px; }
.variant-tree-visual { color: var(--muted); font-size: 11px; }
.variant-tree-episode {
  color: var(--accent); font-size: 11px;
  background: var(--accent-soft);
  padding: 2px 8px; border-radius: 4px;
  display: inline-block; margin-top: 2px;
}
.variant-tree-actions {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}

@media (max-width:1100px) {
  .asset-detail { grid-template-columns: 1fr; }
  .asset-card-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
  .asset-variant-tree { border-left: none; padding-left: 0; border-top: 2px solid var(--line); padding-top: 16px; }
  .variant-tree-row { grid-template-columns: 80px 1fr auto; }
  .variant-tree-row img { width: 80px; height: 45px; }
}

/* ====== RESULT CARDS ====== */
.result-list { display: grid; gap: 10px; margin-top: 12px; }
.result-card, .final-board {
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 14px;
  background: #fff;
  display: grid;
  gap: 8px;
}
.result-card header {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 600;
}
.result-card img, .final-board img {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 7px;
  object-fit: cover;
}
.result-card pre, .final-board pre {
  max-height: 200px;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  font-size: 11px;
}
.board-segment-card {
  display: grid;
  grid-template-columns: minmax(520px, 1.15fr) minmax(360px, .85fr);
  gap: 16px;
  align-items: start;
}
.board-image-pane {
  display: grid;
  gap: 10px;
  min-width: 0;
}
.board-image-pane header {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.board-preview-img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #0f172a;
  cursor: zoom-in;
}
.board-preview-wrap {
  position: relative;
}
.board-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
  width: 28px;
  height: 28px;
  border: 1px solid rgba(15, 23, 42, .25);
  border-radius: 999px;
  background: rgba(255, 255, 255, .92);
  color: #991b1b;
  font-size: 20px;
  line-height: 24px;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(15, 23, 42, .18);
}
.board-delete-btn:hover {
  background: #fee2e2;
}
.board-image-placeholder {
  width: 100%;
  aspect-ratio: 16 / 9;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
}
.board-image-placeholder span { font-size: 12px; }
.board-history-panel { margin-top: 8px; }
.board-history-panel .history-label { font-size: 11px; color: var(--muted); margin-bottom: 4px; }
.history-thumbnails { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.history-thumb {
  position: relative; flex-shrink: 0; width: 80px; aspect-ratio: 16/9;
  border: 1px solid var(--line); border-radius: 4px; overflow: hidden; cursor: pointer;
}
.history-thumb img { width: 100%; height: 100%; object-fit: cover; }
.history-thumb:hover { border-color: var(--accent); }
.history-version-badge {
  position: absolute; top: 2px; left: 2px; background: rgba(0,0,0,.6); color: #fff;
  font-size: 10px; padding: 0 3px; border-radius: 2px;
}
.history-swap-btn {
  position: absolute; bottom: 2px; left: 2px; background: rgba(255,255,255,.85);
  border: none; border-radius: 2px; font-size: 12px; padding: 0 3px; cursor: pointer;
}
.history-del-btn {
  position: absolute; top: 2px; right: 2px; background: rgba(255,0,0,.7); color: #fff;
  border: none; border-radius: 2px; font-size: 12px; padding: 0 3px; cursor: pointer;
}

.spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: taskDockSpin 0.8s linear infinite;
  vertical-align: middle;
  margin-right: 4px;
}
.board-image-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}
.inline-log {
  margin: 10px 0 14px;
  padding: 10px 12px;
  max-height: 180px;
  overflow: auto;
  white-space: pre-wrap;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
}

/* ====== TASK DOCK TRIGGER (header button) ====== */
.task-dock-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  position: relative;
}
.task-dock-trigger .task-dock-caret {
  font-size: 10px;
  opacity: .6;
  transition: transform .15s;
}
.task-dock-trigger[aria-expanded="true"] .task-dock-caret {
  transform: rotate(180deg);
}
.task-dock-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  background: var(--accent, #4f46e5);
  color: #fff;
  border-radius: 9px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
}
.task-dock-badge[hidden] { display: none !important; }
.task-dock-badge[data-state="idle"] { background: var(--muted, #64748b); }
.task-dock-badge[data-state="running"] { background: var(--accent, #4f46e5); }
.task-dock-badge[data-state="done"] { background: var(--ok, #10b981); }
.task-dock-badge[data-state="failed"] { background: var(--danger, #ef4444); }
.task-dock-badge.flash {
  animation: taskDockBadgeFlash .9s ease-out 2;
}
@keyframes taskDockBadgeFlash {
  0%, 100% { transform: scale(1); box-shadow: 0 0 0 0 currentColor; }
  50% { transform: scale(1.35); box-shadow: 0 0 0 8px transparent; }
}

/* ====== TASK DOCK PANEL (drawer) ====== */
#taskDock {
  position: fixed;
  top: 56px;
  right: 14px;
  width: 380px;
  min-width: 280px;
  max-width: calc(100vw - 28px);
  height: 460px;
  min-height: 200px;
  max-height: calc(100vh - 80px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: 0 14px 40px rgba(15, 23, 42, .22);
  z-index: 60;
  font-size: 12px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  resize: none;
}
#taskDock.open { display: flex; }
#taskDock.dragging { transition: none; user-select: none; }
.task-dock-headbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--soft);
  border-bottom: 1px solid var(--line);
  cursor: move;
  user-select: none;
}
.task-dock-headbar .grip {
  color: var(--muted);
  font-size: 14px;
  letter-spacing: -2px;
}
.task-dock-headbar .title {
  flex: 1;
  font-weight: 600;
  color: var(--text);
}
.task-dock-headbar .title small {
  font-weight: 400;
  color: var(--muted);
  margin-left: 6px;
}
.task-dock-headbar button {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 13px;
  line-height: 1;
}
.task-dock-headbar button:hover {
  background: var(--line);
  color: var(--text);
}
.task-dock-body {
  flex: 1;
  overflow: auto;
  padding: 10px;
  display: grid;
  gap: 10px;
  align-content: start;
}
.task-dock-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .5px;
  margin: 0 0 4px;
}
#taskDockRunning {
  display: grid;
  gap: 6px;
}
.task-dock-job {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border-radius: 6px;
  background: var(--soft);
  border-left: 3px solid var(--accent, #4f46e5);
}
.task-dock-job.running { border-left-color: var(--accent, #4f46e5); }
.task-dock-job.done { border-left-color: var(--ok, #10b981); }
.task-dock-job.failed { border-left-color: var(--danger, #ef4444); }
.task-dock-job-line {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}
.task-dock-job-icon {
  font-size: 13px;
  width: 16px;
  text-align: center;
  flex: 0 0 16px;
}
.task-dock-job.running .task-dock-job-icon { color: var(--accent, #4f46e5); animation: taskDockSpin 1.2s linear infinite; }
.task-dock-job.done .task-dock-job-icon { color: var(--ok, #10b981); }
.task-dock-job.failed .task-dock-job-icon { color: var(--danger, #ef4444); }
@keyframes taskDockSpin {
  0% { transform: rotate(0); }
  100% { transform: rotate(360deg); }
}
.task-dock-job-label {
  flex: 1;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.task-dock-job-elapsed {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-size: 11px;
  flex: 0 0 auto;
}
.task-dock-cancel {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(239, 68, 68, 0.38);
  border-radius: 50%;
  background: rgba(239, 68, 68, 0.1);
  color: var(--danger, #ef4444);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
}
.task-dock-cancel:hover {
  background: rgba(239, 68, 68, 0.18);
  border-color: rgba(239, 68, 68, 0.7);
}
.task-dock-progress {
  height: 3px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(148, 163, 184, 0.22);
  margin-left: 24px;
}
.task-dock-progress span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--accent, #4f46e5);
  transition: width .2s ease;
}
.task-dock-job-detail {
  font-size: 11px;
  color: var(--muted);
  margin-left: 24px;
  line-height: 1.4;
}
.task-dock-empty {
  color: var(--muted);
  padding: 12px;
  text-align: center;
  background: var(--soft);
  border-radius: 6px;
  line-height: 1.5;
}
.task-dock-history {
  display: grid;
  gap: 4px;
}
.task-dock-history .task-dock-job {
  padding: 6px 10px;
  background: transparent;
  border-left-width: 2px;
}
.task-dock-history .task-dock-job-line { font-size: 11px; }
#taskLogPanel {
  max-height: 200px;
  overflow: auto;
  display: grid;
  gap: 4px;
  padding-top: 6px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
#taskLogPanel span { color: var(--text); }
.task-dock-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 14px;
  height: 14px;
  cursor: nwse-resize;
  background:
    linear-gradient(135deg, transparent 0 6px, var(--muted) 6px 7px, transparent 7px 9px, var(--muted) 9px 10px, transparent 10px);
  opacity: .55;
  border-bottom-right-radius: 10px;
}
.task-dock-resize:hover { opacity: 1; }

/* ====== TASK TOAST STACK ====== */
#taskToastStack {
  position: fixed;
  top: 56px;
  right: 14px;
  display: grid;
  gap: 8px;
  z-index: 80;
  pointer-events: none;
  max-width: 380px;
  transition: right .15s ease;
}
body.task-dock-is-open #taskToastStack {
  right: 408px;
}
.task-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent, #4f46e5);
  border-radius: 8px;
  box-shadow: 0 10px 28px rgba(15, 23, 42, .18);
  font-size: 12px;
  animation: taskToastIn .2s ease-out;
  min-width: 240px;
}
.task-toast.done { border-left-color: var(--ok, #10b981); }
.task-toast.failed { border-left-color: var(--danger, #ef4444); }
.task-toast.dismissing { animation: taskToastOut .25s ease-out forwards; }
.task-toast-icon { font-size: 16px; flex: 0 0 18px; }
.task-toast.done .task-toast-icon { color: var(--ok, #10b981); }
.task-toast.failed .task-toast-icon { color: var(--danger, #ef4444); }
.task-toast-body { flex: 1; line-height: 1.4; }
.task-toast-body b { color: var(--text); }
.task-toast-body .task-toast-detail { color: var(--muted); display: block; margin-top: 2px; }
.task-toast button.task-toast-close {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  padding: 0 4px;
  font-size: 14px;
  line-height: 1;
}
@keyframes taskToastIn {
  from { transform: translateX(20px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
@keyframes taskToastOut {
  to { transform: translateX(20px); opacity: 0; }
}
/* ====== VARIANT TIMELINE PANEL ====== */
.variant-timeline-panel {
  margin: 12px 0 16px;
  padding: 10px 12px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}
.variant-timeline-panel summary {
  cursor: pointer;
  font-size: 13px;
  user-select: none;
}
.variant-timeline-panel summary:hover { color: var(--accent); }
.variant-timeline-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 8px;
  font-size: 12px;
}
.variant-timeline-table th,
.variant-timeline-table td {
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}
.variant-timeline-table th {
  font-weight: 600;
  color: var(--muted);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.variant-timeline-table tr:last-child td { border-bottom: none; }
.variant-range-chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  font-family: ui-monospace, monospace;
  font-size: 11px;
}
.variant-name-chip {
  display: inline-block;
  padding: 2px 8px;
  background: var(--accent, #4f46e5);
  color: #fff;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
}

.board-info-pane {
  display: grid;
  gap: 8px;
  min-width: 0;
}
.final-board { background: var(--accent-soft); }
.field-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 6px;
  font-size: 12px;
}
.field-row .label { color: var(--text); font-weight: 600; }
.field-row .value { color: var(--muted); }

/* ====== STATUS BAR ====== */
.statusbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 20px;
  border-top: 1px solid var(--line);
  background: #fff;
  flex-shrink: 0;
  font-size: 12px;
}
.statusbar .progress-track {
  flex: 1;
  max-width: 260px;
  height: 6px;
  border-radius: 999px;
  background: #e7edf5;
  overflow: hidden;
}
#progressFill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #13a085);
  transition: width .3s ease;
}
.log-line {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 420px;
}

/* ====== DIALOG ====== */
.config-dialog {
  width: min(960px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 18px;
}
.config-dialog::backdrop { background: rgba(15, 23, 42, .45); }
.dialog-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}
.config-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.config-grid section {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
}
.config-grid section h3 { font-size: 13px; margin-bottom: 2px; }

/* ====== CONFIG TABS ====== */
.config-tabs {
  display: flex;
  gap: 4px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}
.config-tab {
  padding: 8px 16px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.config-tab:hover { color: var(--text); }
.config-tab.active { color: var(--accent, #2563eb); border-bottom-color: var(--accent, #2563eb); }
.config-pane { display: none; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-bottom: 14px; }
.config-pane.active { display: grid; }
#pipelineConfigPane section { grid-column: 1 / -1; }
#pipelineCards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 10px;
}
.config-pane section {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  align-content: start;
}
.config-pane section h3 { font-size: 13px; margin-bottom: 2px; }
.cfg-channel-row { display: flex; gap: 4px; align-items: center; }
.cfg-channel-row .cfg-grow { flex: 1; min-width: 0; }
.cfg-label { font-size: 11px; color: var(--muted); margin-top: 4px; font-weight: 600; }
.cfg-hint { font-size: 11px; color: var(--muted); margin: 0; line-height: 1.4; }
.cfg-advanced { margin-top: 4px; border-top: 1px dashed var(--line); padding-top: 6px; }
.cfg-advanced summary { font-size: 11px; color: var(--muted); cursor: pointer; }
.cfg-advanced > input, .cfg-advanced > select, .cfg-advanced > label { margin-top: 6px; display: block; width: 100%; }
.cfg-test-result {
  font-size: 12px;
  padding: 8px 10px;
  border-radius: 6px;
  margin-bottom: 10px;
  white-space: pre-wrap;
  word-break: break-all;
  border: 1px solid var(--line);
  background: var(--soft);
}
.cfg-test-result.ok { border-color: var(--ok); color: var(--ok); }
.cfg-test-result.err { border-color: var(--err); color: var(--err); }
.btn-sm { font-size: 12px; padding: 4px 8px; }

/* ====== INLINE TIER SELECTOR (generation steps) ====== */
.tier-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-right: 8px;
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--soft);
  vertical-align: middle;
}
.tier-inline-label { font-size: 11px; color: var(--muted); font-weight: 600; }
.tier-inline-select { font-size: 12px; padding: 2px 4px; border: none; background: transparent; cursor: pointer; }

/* ====== EMPTY / LOADING ====== */
.empty {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  text-align: center;
  font-size: 13px;
}
.spin { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.task-status { font-size: 11px; }
.task-status.queued { color: var(--warn); }
.task-status.in_progress { color: var(--accent); }
.task-status.completed { color: var(--ok); }
.task-status.failed { color: var(--danger); }
.grok-mode .tile-grid, .storyboard-mode .tile-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

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

.shot-table-wrap {
  margin-top: 10px;
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.shot-table {
  width: 100%;
  min-width: 980px;
  border-collapse: collapse;
  font-size: 12px;
  line-height: 1.45;
}

.shot-table th,
.shot-table td {
  padding: 8px;
  border-bottom: 1px solid var(--line);
  border-right: 1px solid var(--line);
  vertical-align: top;
}

.shot-table th {
  background: var(--bg);
  color: var(--muted);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}

.shot-table tr:last-child td { border-bottom: 0; }
.shot-table th:last-child,
.shot-table td:last-child { border-right: 0; }

.reference-picker {
  margin: 8px 0;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.reference-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 8px;
  margin: 8px 0;
}

.reference-picker-row {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  font-size: 12px;
}

.reference-picker-row select {
  min-width: 0;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--bg);
  color: var(--text);
}
.ref-thumb-card {
  position: relative;
  text-align: center;
  font-size: 10px;
}
.ref-thumb-card.interactive {
  width: 72px;
  padding: 4px 4px 5px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  transition: border-color .15s, transform .15s;
}
.ref-thumb-card.interactive:hover {
  border-color: var(--accent, #4f46e5);
}
.ref-thumb-img {
  width: 60px;
  height: 34px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--line);
}
.ref-thumb-card.interactive .ref-thumb-img {
  width: 64px;
  height: 40px;
}
.ref-thumb-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  height: 18px;
  border: 1px solid rgba(220, 38, 38, .25);
  border-radius: 4px;
  background: rgba(255, 255, 255, .92);
  color: var(--danger, #dc2626);
  cursor: pointer;
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  box-shadow: 0 1px 4px rgba(0,0,0,.16);
  opacity: 0;
  transition: opacity .12s, background .12s, color .12s, border-color .12s;
  z-index: 5;
}
.ref-thumb-card.interactive:hover .ref-thumb-remove,
.ref-thumb-card.interactive:focus-within .ref-thumb-remove {
  opacity: 1;
}
.ref-thumb-remove:hover {
  background: var(--danger, #dc2626);
  border-color: var(--danger, #dc2626);
  color: #fff;
}
.ref-thumb-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  margin-top: 3px;
  line-height: 1.2;
}
.ref-thumb-typetag {
  display: inline-block;
  padding: 0 4px;
  font-size: 9px;
  color: var(--muted);
  background: var(--panel);
  border-radius: 6px;
  border: 1px solid var(--line);
}
.ref-thumb-name {
  font-size: 10px;
  color: var(--text);
  font-weight: 600;
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ref-thumb-label small {
  font-size: 9px;
  color: var(--muted);
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ref-thumb-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  align-items: flex-start;
}
.ref-thumb-add {
  width: 72px;
  min-height: 70px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  transition: border-color .15s, color .15s, background .15s;
}
.ref-thumb-add:hover {
  border-color: var(--accent, #4f46e5);
  color: var(--accent, #4f46e5);
  background: var(--soft);
}
.ref-thumb-add-icon {
  font-size: 22px;
  font-weight: 300;
  line-height: 1;
}
.ref-thumb-add-label {
  font-size: 11px;
}
.ref-bar-empty {
  font-size: 11px;
  padding: 12px;
}

.ref-picker-panel {
  margin-top: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  box-shadow: 0 6px 18px rgba(15,23,42,.1);
}
.ref-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 11px;
  color: var(--muted);
}
.ref-picker-close {
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 4px;
}
.ref-picker-close:hover { color: var(--danger, #ef4444); }
.ref-picker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 6px;
  max-height: 280px;
  overflow-y: auto;
}
.ref-picker-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 4px;
  background: var(--soft);
  border: 1px solid var(--line);
  border-radius: 6px;
  cursor: pointer;
  font-size: 10px;
  text-align: center;
  transition: border-color .12s, transform .12s;
}
.ref-picker-item:hover {
  border-color: var(--accent, #4f46e5);
  transform: translateY(-1px);
}
.ref-picker-item img {
  width: 86px;
  height: 50px;
  object-fit: cover;
  border-radius: 3px;
  border: 1px solid var(--line);
}
.ref-picker-item-label {
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
  gap: 1px;
}
.ref-picker-item-label small {
  color: var(--muted);
  font-size: 9px;
}
.ref-picker-item-label b {
  font-size: 11px;
  color: var(--text);
  max-width: 86px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ref-thumb-pop {
  display: none;
  position: absolute;
  left: 0;
  bottom: calc(100% + 8px);
  z-index: 30;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, .24);
}
.ref-thumb-pop img {
  width: 320px;
  max-width: 42vw;
  max-height: 240px;
  object-fit: contain;
  display: block;
}
.ref-thumb-card:hover .ref-thumb-pop {
  display: block;
}

/* Type color coding for reference cards */
.ref-char { --ref-type-color: #6366f1; }  /* character = indigo */
.ref-loc  { --ref-type-color: #10b981; }  /* location = emerald */
.ref-prop { --ref-type-color: #f59e0b; }  /* prop = amber */

.ref-thumb-card.ref-char { border-left: 3px solid var(--ref-type-color, var(--line)); }
.ref-thumb-card.ref-loc  { border-left: 3px solid var(--ref-type-color, var(--line)); }
.ref-thumb-card.ref-prop { border-left: 3px solid var(--ref-type-color, var(--line)); }

.ref-thumb-typetag.ref-char { background: rgba(99,102,241,.1); color: #6366f1; border-color: rgba(99,102,241,.2); }
.ref-thumb-typetag.ref-loc  { background: rgba(16,185,129,.1); color: #10b981; border-color: rgba(16,185,129,.2); }
.ref-thumb-typetag.ref-prop { background: rgba(245,158,11,.1); color: #f59e0b; border-color: rgba(245,158,11,.2); }

.ref-picker-item.ref-char { border-left: 3px solid #6366f1; }
.ref-picker-item.ref-loc  { border-left: 3px solid #10b981; }
.ref-picker-item.ref-prop { border-left: 3px solid #f59e0b; }

.ref-picker-item-label small.ref-char { color: #6366f1; }
.ref-picker-item-label small.ref-loc  { color: #10b981; }
.ref-picker-item-label small.ref-prop { color: #f59e0b; }

/* Reference row type tags */
.ref-row-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
}
.ref-row-typetag {
  display: inline-block;
  padding: 1px 5px;
  font-size: 9px;
  border-radius: 4px;
  font-weight: 600;
  line-height: 1.3;
}
.ref-row-typetag.ref-character { background: rgba(99,102,241,.12); color: #6366f1; }
.ref-row-typetag.ref-location  { background: rgba(16,185,129,.12); color: #10b981; }
.ref-row-typetag.ref-prop      { background: rgba(245,158,11,.12); color: #f59e0b; }

/* Always show remove button with slight transparency */
.ref-thumb-remove {
  opacity: 0.55;
}
.ref-thumb-card.interactive:hover .ref-thumb-remove,
.ref-thumb-card.interactive:focus-within .ref-thumb-remove {
  opacity: 1;
}
.grok-mode .result-card { border-left: 3px solid var(--accent); }

/* ====== SCRIPT DISPLAY ====== */
.script-scene {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 8px;
  background: var(--soft);
}
.script-scene h4 { font-size: 13px; margin-bottom: 6px; }
.dialogue-line { padding: 3px 0 3px 12px; border-left: 2px solid var(--accent-soft); margin: 3px 0; font-size: 12px; }

/* ====== VERIFY DIALOG ====== */
.verify-dialog { border: none; border-radius: 10px; padding: 0; max-width: 560px; width: 90vw; box-shadow: 0 8px 32px rgba(0,0,0,.18); }
.verify-dialog::backdrop { background: rgba(0,0,0,.4); }
.verify-dialog-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.verify-dialog-head h2 { font-size: 16px; margin: 0; color: var(--warn); }
.verify-close-btn { font-size: 18px; padding: 2px 8px; }
.verify-summary { padding: 10px 18px; background: #fff8e1; font-size: 13px; }
.verify-summary p { margin: 2px 0; }
.verify-issues-list { padding: 8px 18px; max-height: 260px; overflow-y: auto; }
.verify-issue { font-size: 12px; padding: 6px 0; border-bottom: 1px solid var(--line); }
.verify-issue.severity-high { color: var(--err); }
.verify-issue.severity-medium { color: #e67e22; }
.verify-issue.severity-low { color: var(--muted); }
.verify-expected { color: var(--ok); }
.verify-found { color: var(--err); }
.verify-actions { padding: 10px 18px; border-top: 1px solid var(--line); }

/* ====== RESPONSIVE ====== */
@media (max-width: 1100px) {
  .mode-grid, .tile-grid, .config-grid { grid-template-columns: 1fr; }
  .asset-body { grid-template-columns: 1fr; }
}

@media (max-width: 700px) {
  .app {
    min-width: 0;
    width: 100%;
  }
  .topbar {
    align-items: flex-start;
    padding: 8px 10px;
  }
  .topbar-left,
  .topbar-right {
    min-width: 0;
    gap: 6px;
    flex-wrap: wrap;
  }
  .topbar-left h1 {
    max-width: 190px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .topbar-right .status-text {
    display: none;
  }
  .main-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto minmax(0, 1fr);
  }
  .stepper {
    display: flex;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: 0;
    border-bottom: 1px solid var(--line);
    padding: 0;
    scrollbar-width: thin;
  }
  .step-item {
    flex: 0 0 auto;
    width: auto;
    grid-template-columns: 22px auto auto;
    padding: 9px 10px;
    border-left: 0;
    border-bottom: 3px solid transparent;
  }
  .step-item.active {
    border-left-color: transparent;
    border-bottom-color: var(--accent);
  }
  .step-item .step-badge {
    display: none;
  }
  .content {
    overflow-x: hidden;
    padding: 14px 10px 22px;
  }
  .result-card {
    min-width: 0;
    padding: 12px;
  }
  .result-card header {
    flex-wrap: wrap;
    justify-content: flex-start;
  }
  .field-row {
    grid-template-columns: 72px minmax(0, 1fr);
  }
  .field-row .value {
    min-width: 0;
    overflow-wrap: anywhere;
  }
  .nav-buttons,
  .nav-buttons > div {
    align-items: stretch;
    flex-direction: column;
    width: 100%;
  }
  .nav-buttons button {
    width: 100%;
    white-space: normal;
  }
  .statusbar {
    padding: 6px 10px;
  }
}
