﻿:root {
  color-scheme: light;
  --bg: #eef1f5;
  --surface: #ffffff;
  --surface-2: #f7f9fc;
  --ink: #17202f;
  --muted: #6b7280;
  --line: #dce2ea;
  --line-strong: #c8d1de;
  --accent: #2563eb;
  --accent-2: #0f766e;
  --warn: #b45309;
  --danger: #dc2626;
  --shadow: 0 18px 50px rgba(21, 32, 49, .10);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, "Segoe UI", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button, input, textarea, select { font: inherit; }
button { border: 0; cursor: pointer; }
button:disabled { opacity: .55; cursor: wait; }
textarea, input, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 10px 12px;
  outline: none;
}
textarea { resize: vertical; min-height: 86px; line-height: 1.55; }
textarea:focus, input:focus, select:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(37, 99, 235, .12); }

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(520px, 1fr) 286px;
  height: 100vh;
  min-height: 680px;
}

.rail, .inspector {
  background: #f8fafc;
  border-color: var(--line);
  overflow: hidden;
}
.rail { border-right: 1px solid var(--line); display: flex; flex-direction: column; }
.inspector { border-left: 1px solid var(--line); padding: 18px; overflow-y: auto; }

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 18px;
  border-bottom: 1px solid var(--line);
}
.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
}
.brand h1 { margin: 0; font-size: 15px; line-height: 1.2; }
.brand p { margin: 3px 0 0; color: var(--muted); font-size: 12px; }

.tabs {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  padding: 12px;
  border-bottom: 1px solid var(--line);
}
.tab {
  height: 34px;
  border-radius: 7px;
  background: transparent;
  color: #586174;
  font-size: 13px;
}
.tab.active {
  background: #e8eef8;
  color: var(--accent);
  font-weight: 700;
}

.side-block { padding: 14px 12px; border-bottom: 1px solid var(--line); min-height: 0; }
.episode-block { flex: 1; display: flex; flex-direction: column; }
.side-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  color: #334155;
  font-size: 13px;
  font-weight: 800;
}
.icon-btn {
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: #e2e8f0;
  color: #1e293b;
}

.projlist, .episodes { overflow-y: auto; }
.projitem, .epitem {
  position: relative;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 10px;
  margin-bottom: 6px;
  background: transparent;
  cursor: pointer;
}
.projitem:hover, .epitem:hover { background: #fff; border-color: var(--line); }
.projitem.active, .epitem.active { background: #eff6ff; border-color: #bfdbfe; }
.projitem h4 { margin: 0 24px 4px 0; font-size: 13px; line-height: 1.35; }
.projitem .meta { color: var(--muted); font-size: 11px; }
.projdelete {
  position: absolute;
  top: 9px;
  right: 8px;
  width: 20px;
  height: 20px;
  border-radius: 5px;
  background: transparent;
  color: #94a3b8;
}
.projdelete:hover { background: #fee2e2; color: var(--danger); }
.epitem { font-size: 13px; color: #334155; }

.workspace {
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 18px;
  gap: 14px;
  overflow: hidden;
}
.topbar {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 18px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}
.topbar h2, .section-head h3, .canvasheader h3, .episode-head h3, .inspector-card h3 {
  margin: 0;
  line-height: 1.2;
}
.topbar h2 { font-size: 20px; }
.eyebrow {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.status {
  max-width: 48%;
  color: var(--muted);
  font-size: 12px;
  text-align: right;
}

.panel {
  display: none;
  min-height: 0;
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.panel.active { display: flex; flex-direction: column; }

.empty-state {
  flex: 1;
  display: grid;
  place-content: center;
  justify-items: center;
  text-align: center;
  padding: 40px;
}
.empty-state h3 { margin: 0 0 8px; font-size: 22px; }
.empty-state p { max-width: 480px; margin: 0 0 18px; color: var(--muted); line-height: 1.6; }

.episode-workbench { min-height: 0; flex: 1; display: flex; flex-direction: column; }
.episode-head, .section-head, .canvasheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #fbfcfe;
}
.action-row, .canvastools { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.ratio-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.ratio-control select {
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #0f172a;
  padding: 0 8px;
  font-weight: 800;
}

.episode-grid {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: minmax(250px, .75fr) minmax(360px, 1.05fr) minmax(220px, .42fr);
}
.script-pane, .shots-pane, .video-side-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.script-pane { border-right: 1px solid var(--line); background: #fbfcfe; }
.video-side-pane { border-left: 1px solid var(--line); background: #f8fafc; }
.pane-head {
  height: 42px;
  display: flex;
  align-items: center;
  padding: 0 14px;
  border-bottom: 1px solid var(--line);
  color: #334155;
  font-size: 12px;
  font-weight: 800;
}
#epscript {
  flex: 1;
  border: 0;
  border-radius: 0;
  background: transparent;
  padding: 16px;
  min-height: 0;
}
.epshots {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

.shotcard {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  margin-bottom: 12px;
}
.shot-topline { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.pill {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: #e0f2fe;
  color: #0369a1;
  font-size: 12px;
  font-weight: 800;
}
.meta, .hint { color: var(--muted); font-size: 12px; }
.shot-desc { line-height: 1.55; margin: 8px 0; }
.shot-cutline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 8px 0;
}
.shot-cutline span,
.shot-cutline em {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  border-radius: 7px;
  padding: 4px 8px;
  font-size: 12px;
  font-style: normal;
}
.shot-cutline span {
  background: #eef2ff;
  color: #4338ca;
  font-weight: 800;
}
.shot-cutline em {
  background: #f8fafc;
  border: 1px solid var(--line);
  color: #64748b;
}
.shot-dialogue { color: #475569; font-size: 12px; margin: 5px 0; }
.shot-continuity {
  margin: 8px 0;
  border: 1px solid #bfdbfe;
  border-radius: 7px;
  background: #eff6ff;
  color: #1e3a8a;
  padding: 7px 9px;
  font-size: 12px;
  line-height: 1.45;
}
.shot-prompt {
  min-height: 74px;
  background: #f8fafc;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
}
.pipeline-steps {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 10px 0;
}
.pipeline-steps span {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 5px;
  text-align: center;
  color: #94a3b8;
  font-size: 12px;
  background: #f8fafc;
}
.pipeline-steps span.on {
  background: #ecfdf5;
  border-color: #a7f3d0;
  color: #047857;
}
.acts { display: flex; gap: 8px; flex-wrap: wrap; }
.acts button { padding: 7px 10px; border-radius: 7px; background: #eef2f7; color: #334155; font-size: 12px; }
.shot-result { margin-top: 10px; }
.shot-result img { max-width: 180px; border-radius: 7px; border: 1px solid var(--line); }
.shot-result video, .output video { width: 100%; border-radius: 8px; background: #000; }
.shot-ref-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}
.shot-ref-item {
  position: relative;
}
.shot-ref-grid img {
  width: 82px;
  height: 62px;
  object-fit: cover;
}
.storyboard-preview,
.shot-reference-preview,
.shot-video-preview {
  margin-bottom: 10px;
}
.video-actions,
.generated-video-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 7px;
}
.media-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  color: #475569;
  font-size: 12px;
}

.storyboard-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.storyboard-actions button.mini {
  min-height: 28px;
  padding: 4px 9px;
  font-size: 12px;
}

.storyboard-actions .danger {
  color: #b42318;
  border-color: #f1b5ad;
  background: #fff7f6;
}
.storyboard-preview > a {
  display: block;
  width: min(100%, 360px);
}
.storyboard-preview img {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  object-fit: contain;
}
.shot-image-delete,
.asset-plan-delete-image {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 1px solid rgba(15, 23, 42, .08);
  border-radius: 999px;
  background: rgba(15, 23, 42, .78);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  padding: 0;
  display: grid;
  place-items: center;
}
.shot-image-delete:hover,
.asset-plan-delete-image:hover {
  background: #dc2626;
}
.history { margin-top: 8px; color: var(--muted); font-size: 12px; }
.generated-video-summary {
  padding: 12px;
}
.generated-videos-side {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px;
}
.generated-video-episode {
  margin-bottom: 12px;
}
.generated-video-episode h4 {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 13px;
}
.generated-video-item {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid #dbeafe;
  border-radius: 8px;
  background: #fff;
  font-size: 12px;
}
.generated-video-item video {
  display: block;
  width: 100%;
  max-height: 220px;
  aspect-ratio: 16 / 9;
  object-fit: contain;
  border-radius: 6px;
  background: #000;
}
.generated-video-item span {
  min-width: 0;
  line-height: 1.35;
  color: #334155;
}

.canvascontainer {
  flex: 1;
  min-height: 0;
  border: 0;
  background: #f7f9fc;
  position: relative;
  overflow: hidden;
}

.tool-panel {
  margin: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: end;
  margin-bottom: 12px;
}
.form-grid.compact { grid-template-columns: 160px 160px auto; }
label { display: grid; gap: 6px; color: #475569; font-size: 12px; font-weight: 700; }
.output { margin: 16px; }
.gallery {
  display: block;
  overflow-y: auto;
}
.asset-group {
  margin-bottom: 18px;
}
.asset-group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 10px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}
.asset-group-head h4 {
  margin: 0;
  color: #1f2937;
  font-size: 14px;
}
.asset-group-head span,
.asset-meta {
  color: var(--muted);
  font-size: 12px;
}
.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}
.imgcard {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
}
.imgcard img {
  width: 100%;
  aspect-ratio: 1.35;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
}
.imgcard p {
  margin: 7px 2px 0;
  color: #475569;
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-meta {
  margin: 4px 2px 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.asset-plan-panel {
  overflow-y: auto;
  padding: 14px 16px 0;
}
.face-library-panel { margin: 14px 16px 0; border: 1px solid #c7d7f4; border-radius: 8px; background: #f8fbff; padding: 14px; }
.face-library-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.face-library-head h3 { margin: 0; }
.face-library-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.face-library-stage { display: grid; gap: 8px; align-content: start; border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 12px; }
.face-library-stage strong { color: #0f172a; }
.face-library-stage label { margin: 0; }
.face-library-stage input, .face-library-stage select { margin-top: 5px; width: 100%; }
.face-state { min-height: 32px; color: #475569; font-size: 12px; white-space: pre-wrap; word-break: break-word; }
.face-assets { display: grid; gap: 8px; margin-top: 12px; }
.face-asset-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; border-top: 1px solid var(--line); padding-top: 9px; font-size: 12px; }
.face-asset-row span { color: #475569; }
.asset-plan-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
  margin-bottom: 12px;
}
.asset-plan-head h3,
.asset-plan-group h4 {
  margin: 0;
}
.asset-plan-group {
  margin-bottom: 16px;
}
.asset-plan-group h4 {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #334155;
  font-size: 13px;
  margin-bottom: 8px;
}
.asset-plan-group h4 span {
  color: var(--muted);
  font-weight: 700;
}
.asset-character-bundle {
  border: 1px solid #dbe5f3;
  border-radius: 8px;
  background: #f8fafc;
  padding: 10px;
  margin-bottom: 12px;
}
.asset-character-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #0f172a;
}
.asset-character-head span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.asset-plan-card {
  display: grid;
  grid-template-columns: 116px minmax(0, 1fr);
  gap: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  margin-bottom: 10px;
}
.asset-plan-card.ready {
  border-color: #a7f3d0;
  background: #fbfffd;
}
.asset-plan-preview {
  position: relative;
  min-height: 96px;
  border: 1px dashed var(--line-strong);
  border-radius: 7px;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #f8fafc;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}
.asset-plan-preview img {
  width: 100%;
  height: 100%;
  min-height: 96px;
  object-fit: cover;
}
.asset-safety-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  z-index: 2;
  max-width: calc(100% - 12px);
  border: 1px solid #fed7aa;
  border-radius: 6px;
  background: rgba(255, 247, 237, 0.94);
  color: #9a3412;
  padding: 3px 6px;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.2;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.asset-safety-badge.safe {
  border-color: #bbf7d0;
  background: rgba(240, 253, 244, 0.94);
  color: #166534;
}
.asset-plan-preview-grid {
  width: 100%;
  height: 100%;
  min-height: 96px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 3px;
}
.asset-plan-preview-grid img {
  min-height: 0;
  height: 46px;
  border-radius: 4px;
}
.asset-plan-body {
  min-width: 0;
  display: grid;
  gap: 8px;
}
.asset-plan-row {
  display: grid;
  grid-template-columns: minmax(120px, 1fr) auto;
  gap: 8px;
  align-items: center;
}
.asset-plan-row.character-detail-row {
  grid-template-columns: minmax(160px, 1fr) minmax(160px, 1fr);
}
.asset-name-input {
  height: 34px;
  padding: 7px 9px;
  font-weight: 800;
}
.asset-shotrefs-open {
  min-width: 220px;
  max-width: 360px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: #64748b;
  padding: 7px 9px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: left;
  font-size: 12px;
}
.asset-shotrefs-open:hover {
  border-color: #93c5fd;
  background: #eff6ff;
  color: #1d4ed8;
}
.asset-plan-tag {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 12px;
}
.asset-plan-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.asset-plan-merge {
  min-height: 34px;
  max-width: 180px;
  border: 1px solid #c7d7f4;
  border-radius: 8px;
  background: #f8fbff;
  color: #1d4ed8;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 800;
}
.asset-plan-actions .dl.mini {
  width: auto;
  margin-top: 0;
}

.primary, .secondary, .ghost, .dl {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border-radius: 8px;
  padding: 8px 13px;
  text-decoration: none;
  font-size: 13px;
  font-weight: 800;
}
.primary { background: var(--accent); color: #fff; }
.secondary { background: #e8eef8; color: #1d4ed8; border: 1px solid #c7d7f4; }
.ghost { background: #f1f5f9; color: #475569; }
.dl { background: var(--accent-2); color: #fff; margin-top: 10px; }
.dl.mini {
  min-height: 28px;
  width: 100%;
  margin-top: 8px;
  padding: 5px 9px;
  font-size: 12px;
}

.progress-bar { height: 3px; background: #e5e7eb; overflow: hidden; }
.progress-bar-inner { height: 100%; background: var(--accent); animation: progress 1.8s ease-in-out infinite; }
@keyframes progress { 0% { width: 0; } 50% { width: 72%; } 100% { width: 100%; } }
.gen-progress {
  width: 100%;
  min-width: 180px;
  border: 1px solid #bfdbfe;
  border-radius: 8px;
  background: #eff6ff;
  padding: 10px;
}
.gen-progress-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #1e3a8a;
  font-size: 12px;
}
.gen-progress-head span {
  color: #2563eb;
  font-variant-numeric: tabular-nums;
}
.gen-progress-track {
  height: 7px;
  border-radius: 999px;
  overflow: hidden;
  background: #dbeafe;
}
.gen-progress-track div {
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #2563eb, #14b8a6);
  transition: width .45s ease;
}

.inspector-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  margin-bottom: 12px;
}
.metric-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 10px 0;
  color: var(--muted);
  font-size: 13px;
}
.metric-row:first-of-type { margin-top: 10px; }
.metric-row strong { color: var(--ink); }
.detail-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  margin-top: 12px;
  color: #475569;
  font-size: 13px;
}
.note {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  color: #9a3412;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 12px;
}

dialog {
  width: min(520px, calc(100vw - 32px));
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 22px;
  box-shadow: 0 24px 80px rgba(15, 23, 42, .24);
}
dialog::backdrop { background: rgba(15, 23, 42, .38); }
dialog h3 { margin: 0 0 8px; }
dialog label { margin-top: 14px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 18px; }

.settings-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 30;
  min-width: 72px;
  height: 42px;
  border-radius: 999px;
  background: #0f172a;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  box-shadow: 0 16px 36px rgba(15, 23, 42, .26);
}
.settings-fab:hover { background: #2563eb; }
.settings-dialog {
  width: min(900px, calc(100vw - 36px));
  max-height: min(760px, calc(100vh - 36px));
  overflow: hidden;
}
.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.settings-head h3 { margin: 0; }
.settings-form {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 220px);
  overflow-y: auto;
  padding-right: 4px;
}
.settings-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 12px;
}
.settings-card-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.settings-card-title strong {
  color: #0f172a;
  font-size: 14px;
}
.settings-card-title span {
  color: var(--muted);
  font-size: 12px;
}
.settings-grid {
  display: grid;
  grid-template-columns: 160px minmax(180px, 1fr);
  gap: 10px;
}
.settings-grid .wide {
  grid-column: 1 / -1;
}
.shot-image-dialog {
  width: min(920px, calc(100vw - 36px));
  max-height: min(760px, calc(100vh - 36px));
  overflow: hidden;
}
.character-dialog {
  width: min(620px, calc(100vw - 36px));
}
.shotrefs-dialog {
  width: min(980px, calc(100vw - 36px));
  max-height: min(780px, calc(100vh - 36px));
  overflow: hidden;
}
.character-form {
  display: grid;
  gap: 12px;
}
.character-form label {
  margin-top: 0;
}
.shot-image-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}
.shotrefs-list {
  display: grid;
  gap: 12px;
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  padding-right: 4px;
}
.shotrefs-episode {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfe;
  padding: 10px;
}
.shotrefs-episode h4 {
  margin: 0 0 8px;
  color: #0f172a;
  font-size: 13px;
}
.shotrefs-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 8px;
}
.shotrefs-option {
  display: grid;
  grid-template-columns: auto minmax(58px, auto) minmax(0, 1fr);
  gap: 7px;
  align-items: center;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 7px 8px;
}
.shotrefs-option input {
  width: 16px;
  height: 16px;
}
.shotrefs-option span {
  color: #1e293b;
  font-size: 12px;
  font-weight: 800;
}
.shotrefs-option em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}
.shot-image-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  max-height: calc(100vh - 250px);
  overflow-y: auto;
  padding-right: 4px;
}
.shot-image-choice {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 8px;
  text-align: left;
}
.shot-image-choice:hover {
  border-color: #93c5fd;
  background: #eff6ff;
}
.shot-image-choice img {
  width: 100%;
  aspect-ratio: 1.2;
  object-fit: cover;
  border-radius: 6px;
  border: 1px solid var(--line);
  margin-bottom: 7px;
}
.shot-image-choice span,
.shot-image-choice em {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.shot-image-choice span {
  color: #0f172a;
  font-size: 12px;
  font-weight: 800;
}
.shot-image-choice em {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
}

@media (max-width: 1120px) {
  .app-shell { grid-template-columns: 260px 1fr; }
  .inspector { display: none; }
}
@media (max-width: 820px) {
  body { overflow: auto; }
  .app-shell { display: block; height: auto; min-height: 100vh; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); }
  .workspace { min-height: 760px; padding: 12px; }
  .episode-grid, .form-grid, .form-grid.compact { grid-template-columns: 1fr; }
  .script-pane { border-right: 0; border-bottom: 1px solid var(--line); min-height: 280px; }
  .video-side-pane { border-left: 0; border-top: 1px solid var(--line); min-height: 220px; }
  .topbar { align-items: flex-start; flex-direction: column; }
  .status { max-width: none; text-align: left; }
  .settings-grid, .face-library-grid { grid-template-columns: 1fr; }
  .settings-fab { right: 14px; bottom: 14px; }
}

/* Canvas beautify mode */
#i2v.panel {
  position: relative;
  background: #080b12;
}

#i2v .canvasheader {
  position: absolute;
  top: 18px;
  left: 18px;
  right: 18px;
  z-index: 5;
  border: 1px solid rgba(148, 163, 184, .25);
  border-radius: 12px;
  background: rgba(15, 23, 42, .72);
  color: #e5edf7;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .28);
  backdrop-filter: blur(18px);
}

#i2v .canvasheader .eyebrow,
#i2v .canvasheader h3 {
  color: #e5edf7;
}

#i2v .canvastools {
  padding: 4px;
  border: 1px solid rgba(148, 163, 184, .22);
  border-radius: 10px;
  background: rgba(2, 6, 23, .38);
}

#i2v .canvastools button {
  min-width: 56px;
  border-color: rgba(148, 163, 184, .28);
  background: rgba(255, 255, 255, .08);
  color: #e2e8f0;
}

#i2v .canvastools .primary {
  background: #2563eb;
  color: #fff;
  box-shadow: 0 0 0 1px rgba(147, 197, 253, .3), 0 10px 26px rgba(37, 99, 235, .34);
}

#i2v .canvastools button:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, .14);
}

#i2v .canvascontainer {
  flex: 1;
  min-height: 0;
  height: 100%;
  border: 0;
  border-radius: 0;
  background:
    radial-gradient(circle at 18% 12%, rgba(37, 99, 235, .20), transparent 28%),
    radial-gradient(circle at 86% 22%, rgba(20, 184, 166, .14), transparent 26%),
    #070a11;
}

.canvas-vignette {
  pointer-events: none;
  position: absolute;
  inset: 0;
  z-index: 2;
  box-shadow: inset 0 0 120px rgba(0, 0, 0, .48);
}

.canvas-menu {
  position: fixed;
  z-index: 1000;
  min-width: 176px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, .25);
  border-radius: 12px;
  background: rgba(15, 23, 42, .92);
  box-shadow: 0 22px 60px rgba(0, 0, 0, .36);
  backdrop-filter: blur(18px);
}

.canvas-menu button {
  display: block;
  width: 100%;
  height: 34px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #dbeafe;
  text-align: left;
  padding: 0 10px;
}

.canvas-menu button:hover {
  background: rgba(59, 130, 246, .22);
  color: #fff;
}

body.canvas-focus {
  overflow: hidden;
}

body.canvas-focus .app-shell {
  display: block;
}

body.canvas-focus .rail,
body.canvas-focus .inspector,
body.canvas-focus .topbar,
body.canvas-focus .panel:not(#i2v) {
  display: none !important;
}

body.canvas-focus .workspace {
  height: 100vh;
  padding: 0;
}

body.canvas-focus #i2v.panel {
  display: flex !important;
  height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

body.canvas-focus #i2v .canvasheader {
  top: 20px;
  left: 50%;
  right: auto;
  width: min(920px, calc(100vw - 40px));
  transform: translateX(-50%);
}

body.canvas-focus #i2v .canvascontainer {
  height: 100vh;
}

body.canvas-focus #i2v .canvasheader h3::after {
  content: " 路 涓撴敞妯″紡";
  color: #93c5fd;
  font-weight: 700;
}
