:root {
  color-scheme: dark;
  --bg: #090b0f;
  --surface: #101319;
  --surface-2: #161a21;
  --surface-3: #1d222b;
  --surface-hover: #242a34;
  --line: #2a303a;
  --line-strong: #3a424f;
  --text: #f5f7fa;
  --muted: #9ca6b5;
  --dim: #697586;
  --accent: #27d3c2;
  --accent-strong: #0da99c;
  --accent-soft: rgba(39, 211, 194, 0.12);
  --blue: #4da3ff;
  --purple: #8d7df2;
  --green: #36d184;
  --amber: #f4b942;
  --red: #f06b6b;
  --shadow: 0 16px 48px rgba(0, 0, 0, 0.36);
  --toolbar-height: 104px;
  --left-width: 292px;
  --right-width: 342px;
  --radius: 7px;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-width: 320px;
  min-height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "PingFang SC", "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

body { overflow-x: hidden; }
body.studio-open { overflow: hidden; }
body.studio-open #main-content { position: fixed; inset: 0; overflow: hidden; }
button,
input,
select,
textarea { font: inherit; letter-spacing: 0; }
button,
select { cursor: pointer; }
button:disabled,
.disabled { cursor: not-allowed; opacity: 0.45; }
button,
a,
input,
select,
textarea { -webkit-tap-highlight-color: transparent; }
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

[hidden] { display: none !important; }

.skip-link {
  position: fixed;
  left: 12px;
  top: -60px;
  z-index: 1000;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: var(--text);
  color: var(--bg);
  text-decoration: none;
}
.skip-link:focus { top: 12px; }

.button,
.icon-button {
  min-height: 34px;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text);
  background: transparent;
  font-weight: 700;
  transition: background-color 120ms ease, border-color 120ms ease, color 120ms ease;
}
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 0 13px;
  white-space: nowrap;
}
.button.primary { background: var(--accent); color: #061210; }
.button.primary:hover { background: #4be4d4; }
.button.secondary { border-color: var(--line-strong); background: var(--surface-2); }
.button.secondary:hover,
.button.ghost:hover,
.icon-button:hover { background: var(--surface-hover); border-color: var(--line-strong); }
.button.ghost { color: var(--muted); }
.button.compact { min-height: 30px; padding: 0 10px; font-size: 12px; }
.button.tiny { min-height: 28px; padding: 0 9px; font-size: 11px; }
.button.full { width: 100%; }
.icon-button {
  display: inline-grid;
  width: 34px;
  min-width: 34px;
  padding: 0;
  place-items: center;
  border-color: var(--line);
  background: var(--surface-2);
  text-decoration: none;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line-strong);
  border-radius: 6px;
  background: #0d1015;
  color: var(--text);
}
input,
select { min-height: 36px; padding: 0 10px; }
textarea { padding: 10px; line-height: 1.55; resize: vertical; }
input::placeholder,
textarea::placeholder { color: var(--dim); }
label { display: grid; gap: 7px; color: #cfd6df; font-size: 12px; font-weight: 650; }

.project-view { min-height: 100vh; background: #0b0e13; }
.project-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  min-height: 66px;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px max(24px, calc((100vw - 1360px) / 2));
  border-bottom: 1px solid var(--line);
  background: rgba(11, 14, 19, 0.94);
  backdrop-filter: blur(16px);
}
.brand { display: flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; }
.brand img { width: 38px; height: 38px; border-radius: 8px; }
.brand span { display: grid; line-height: 1.1; }
.brand strong { font-size: 17px; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 11px; font-weight: 600; }
.project-header-actions { display: flex; align-items: center; gap: 9px; }
.text-link { color: var(--muted); font-size: 13px; font-weight: 650; text-decoration: none; }
.text-link:hover { color: var(--text); }
.project-content { width: min(1360px, calc(100vw - 48px)); margin: 0 auto; padding: 54px 0 80px; }
.project-heading { display: flex; align-items: end; justify-content: space-between; gap: 24px; }
.eyebrow,
.panel-kicker { margin: 0 0 8px; color: var(--accent); font-size: 10px; font-weight: 800; letter-spacing: 0.12em; }
.project-heading h1 { margin: 0; font-size: 32px; line-height: 1.15; letter-spacing: 0; }
.project-summary { display: flex; gap: 18px; color: var(--muted); font-size: 13px; }
.project-summary strong { color: var(--text); }
.folder-nav { display: flex; gap: 6px; margin: 30px 0 20px; overflow-x: auto; scrollbar-width: thin; }
.folder-nav button {
  min-height: 34px;
  padding: 0 13px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
  white-space: nowrap;
}
.folder-nav button.active { border-color: rgba(39, 211, 194, 0.55); background: var(--accent-soft); color: var(--text); }
.folder-nav .folder-remove { width: 28px; min-height: 28px; padding: 0; margin-left: 3px; color: var(--dim); }
.project-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; }
.project-card {
  position: relative;
  display: grid;
  min-height: 210px;
  grid-template-rows: 110px auto;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  transition: border-color 140ms ease, transform 140ms ease;
}
.project-card:hover { border-color: var(--line-strong); transform: translateY(-2px); }
.project-thumb {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-bottom: 1px solid var(--line);
  background-color: #111720;
  background-image: linear-gradient(rgba(77, 163, 255, 0.06) 1px, transparent 1px), linear-gradient(90deg, rgba(77, 163, 255, 0.06) 1px, transparent 1px);
  background-size: 22px 22px;
}
.project-thumb::before { content: ""; width: 70px; height: 42px; border: 1px solid #4b5a6c; border-radius: 5px; background: #1a2330; box-shadow: 60px 18px 0 -4px #13292a, -58px 23px 0 -8px #202130; }
.project-thumb span { position: absolute; right: 10px; bottom: 8px; padding: 4px 7px; border-radius: 4px; background: rgba(5, 8, 12, 0.78); color: #dbe4ee; font-size: 10px; }
.project-card-body { display: grid; gap: 10px; padding: 14px; }
.project-card-title { display: flex; min-width: 0; align-items: start; justify-content: space-between; gap: 12px; }
.project-card-title h2 { min-width: 0; margin: 0; overflow-wrap: anywhere; font-size: 15px; line-height: 1.35; }
.project-menu { position: relative; }
.project-menu > button { width: 28px; min-width: 28px; min-height: 28px; }
.project-menu-list { position: absolute; top: 32px; right: 0; z-index: 4; width: 118px; padding: 5px; border: 1px solid var(--line); border-radius: 6px; background: #12161d; box-shadow: var(--shadow); }
.project-menu-list button { width: 100%; min-height: 31px; padding: 0 9px; border: 0; border-radius: 4px; background: transparent; color: var(--text); text-align: left; }
.project-menu-list button:hover { background: var(--surface-hover); }
.project-menu-list button.danger { color: #ff9999; }
.project-meta { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 11px; }
.project-meta span { min-width: 0; overflow-wrap: anywhere; }
.project-open { position: absolute; inset: 0; z-index: 1; border: 0; background: transparent; cursor: pointer; }
.project-card-body,
.project-menu { position: relative; z-index: 2; pointer-events: none; }
.project-menu { pointer-events: auto; }
.project-empty { padding: 90px 24px; border: 1px dashed var(--line-strong); border-radius: 8px; text-align: center; }
.project-empty .empty-mark { display: grid; width: 48px; height: 48px; margin: 0 auto 18px; place-items: center; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface-2); color: var(--accent); }
.project-empty h2 { margin: 0 0 8px; font-size: 18px; }
.project-empty p { margin: 0 0 20px; color: var(--muted); font-size: 13px; }

.studio-view { height: 100dvh; min-height: 650px; display: grid; grid-template-rows: auto auto minmax(240px, 1fr) auto; overflow: hidden; background: var(--bg); }
.studio-toolbar { position: relative; z-index: 30; border-bottom: 1px solid var(--line); background: #0c0f14; }
.toolbar-row { display: flex; min-width: 0; align-items: center; gap: 12px; padding: 7px 10px; }
.toolbar-row-main { min-height: 54px; border-bottom: 1px solid #1c222b; }
.toolbar-row-workflow { min-height: 48px; }
.toolbar-cluster { display: flex; min-width: 0; align-items: center; gap: 7px; }
.project-cluster { min-width: 250px; }
.toolbar-logo { width: 28px; height: 28px; border-radius: 6px; }
.project-name-input { width: 178px; min-width: 120px; border-color: transparent; background: transparent; font-size: 14px; font-weight: 750; }
.project-name-input:hover,
.project-name-input:focus { border-color: var(--line); background: var(--surface); }
.toolbar-label,
.toolbar-row label { color: var(--muted); font-size: 11px; font-weight: 650; white-space: nowrap; }
.segmented { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 7px; background: #090c10; }
.segmented button { min-height: 27px; padding: 0 9px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 11px; font-weight: 700; }
.segmented button.active { background: var(--surface-hover); color: var(--text); box-shadow: inset 0 0 0 1px var(--line-strong); }
.connection-cluster { margin-left: auto; }
.connection-status { display: inline-flex; align-items: center; gap: 7px; min-height: 30px; color: var(--muted); font-size: 11px; white-space: nowrap; }
.connection-status i { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); box-shadow: 0 0 0 3px rgba(244, 185, 66, 0.1); }
.connection-status.online i { background: var(--green); box-shadow: 0 0 0 3px rgba(54, 209, 132, 0.1); }
.connection-status.offline i { background: var(--red); box-shadow: 0 0 0 3px rgba(240, 107, 107, 0.1); }
.count-badge { display: inline-flex; min-height: 27px; align-items: center; padding: 0 8px; border: 1px solid var(--line); border-radius: 5px; color: #cbd4df; font-size: 10px; white-space: nowrap; }
.action-cluster { margin-left: auto; }
.stepper-label { color: var(--muted); font-size: 11px; }
.stepper { display: grid; width: 93px; grid-template-columns: 27px 38px 27px; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; }
.stepper button,
.stepper input { width: auto; min-width: 0; min-height: 30px; padding: 0; border: 0; border-radius: 0; background: var(--surface-2); color: var(--text); text-align: center; }
.stepper input { border-inline: 1px solid var(--line); appearance: textfield; }
.stepper input::-webkit-inner-spin-button { appearance: none; }
.workflow-cluster select { width: 134px; min-height: 32px; }
.canvas-settings { margin-left: auto; }
.canvas-settings select { width: auto; min-width: 84px; min-height: 32px; padding-right: 28px; }
.canvas-hint { margin: 0 0 0 auto; color: var(--dim); font-size: 10px; white-space: nowrap; }

.studio-body { min-width: 0; min-height: 0; display: grid; grid-template-columns: var(--left-width) minmax(420px, 1fr) var(--right-width); }
.studio-view.assets-collapsed { --left-width: 45px; }
.studio-view.preview-collapsed { --right-width: 45px; }
.side-panel { min-width: 0; min-height: 0; overflow: hidden; background: var(--surface); }
.asset-panel { display: flex; flex-direction: column; border-right: 1px solid var(--line); }
.preview-panel { border-left: 1px solid var(--line); overflow-y: auto; }
.panel-header { display: flex; min-height: 58px; align-items: center; justify-content: space-between; gap: 10px; padding: 11px 12px; border-bottom: 1px solid var(--line); }
.panel-header h2 { margin: 0; font-size: 14px; }
.panel-header .panel-kicker { margin-bottom: 4px; }
.preview-panel .panel-header { justify-content: flex-start; }
.asset-tools { display: flex; flex-wrap: wrap; gap: 5px; padding: 10px 10px 0; }
.asset-search-wrap { position: relative; margin: 9px 10px 6px; }
.asset-search-wrap span { position: absolute; left: 10px; top: 50%; color: var(--dim); transform: translateY(-50%); }
.asset-search-wrap input { height: 34px; padding-left: 30px; background: #0b0e12; font-size: 11px; }
.asset-categories { min-height: 0; flex: 1 1 auto; overflow-y: auto; padding: 5px 10px 10px; }
.asset-category { border-bottom: 1px solid #222831; }
.asset-category-header { display: flex; width: 100%; min-height: 38px; align-items: center; justify-content: space-between; padding: 0 2px; border: 0; background: transparent; color: var(--text); font-size: 12px; font-weight: 750; }
.asset-category-header span { display: flex; align-items: center; gap: 7px; }
.asset-category-header b { display: grid; min-width: 20px; height: 20px; place-items: center; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-size: 10px; }
.asset-list { display: grid; gap: 6px; padding-bottom: 9px; }
.asset-item { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 8px; align-items: center; min-height: 50px; padding: 6px; border: 1px solid transparent; border-radius: 6px; background: #0d1015; cursor: grab; }
.asset-item:hover { border-color: var(--line-strong); }
.asset-thumb { display: grid; width: 38px; height: 38px; place-items: center; overflow: hidden; border-radius: 5px; background: var(--surface-3); color: var(--muted); font-size: 15px; }
.asset-thumb img,
.asset-thumb video { width: 100%; height: 100%; object-fit: cover; }
.asset-copy { min-width: 0; }
.asset-copy strong { display: block; color: #e7ecf2; font-size: 11px; line-height: 1.35; overflow-wrap: anywhere; }
.asset-copy small { display: block; margin-top: 3px; color: var(--dim); font-size: 9px; line-height: 1.4; overflow-wrap: anywhere; }
.asset-item-actions { display: flex; }
.asset-item-actions button { width: 25px; min-width: 25px; min-height: 26px; border: 0; background: transparent; color: var(--muted); }
.asset-item-actions button:hover { color: var(--text); }
.asset-panel > .button.full { width: calc(100% - 20px); margin: 8px 10px 10px; }
.assets-collapsed .asset-panel > :not(.panel-header),
.preview-collapsed .preview-panel > :not(.panel-header) { display: none; }
.assets-collapsed .asset-panel .panel-header,
.preview-collapsed .preview-panel .panel-header { height: 100%; align-items: flex-start; justify-content: center; padding: 11px 5px; }
.assets-collapsed .asset-panel .panel-header > div,
.preview-collapsed .preview-panel .panel-header > div { display: none; }

.canvas-panel { position: relative; min-width: 0; min-height: 0; background: #0a0d12; }
.canvas-stage { position: absolute; inset: 0; overflow: hidden; background-color: #0a0d12; background-image: linear-gradient(rgba(121, 136, 156, 0.075) 1px, transparent 1px), linear-gradient(90deg, rgba(121, 136, 156, 0.075) 1px, transparent 1px), linear-gradient(rgba(121, 136, 156, 0.025) 1px, transparent 1px), linear-gradient(90deg, rgba(121, 136, 156, 0.025) 1px, transparent 1px); background-size: 64px 64px, 64px 64px, 16px 16px, 16px 16px; }
#cy { position: absolute; inset: 0; }
.canvas-empty { position: absolute; left: 50%; top: 50%; display: grid; place-items: center; pointer-events: none; color: var(--dim); transform: translate(-50%, -50%); }
.canvas-empty > span { display: grid; width: 40px; height: 40px; margin-bottom: 12px; place-items: center; border: 1px solid var(--line-strong); border-radius: 7px; background: rgba(18, 22, 29, 0.88); font-size: 24px; }
.canvas-empty strong { color: #abb5c2; font-size: 12px; }
.canvas-empty small { margin-top: 6px; font-size: 10px; }
.canvas-zoom-controls { position: absolute; right: 12px; bottom: 12px; display: flex; overflow: hidden; border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); }
.canvas-zoom-controls button { width: 34px; height: 32px; border: 0; border-right: 1px solid var(--line); background: rgba(18, 22, 29, 0.94); color: var(--text); }
.canvas-zoom-controls button:last-child { border-right: 0; }
.canvas-zoom-controls button:hover { background: var(--surface-hover); }
.canvas-status { position: absolute; left: 12px; bottom: 12px; min-height: 25px; padding: 6px 9px; border: 1px solid var(--line); border-radius: 5px; background: rgba(13, 16, 21, 0.9); color: var(--dim); font-size: 9px; }
.node-action-overlay { position: absolute; z-index: 8; width: 236px; min-height: 174px; padding: 10px; border: 1px solid rgba(39, 211, 194, 0.7); border-radius: 7px; background: rgba(16, 19, 25, 0.98); box-shadow: 0 12px 30px rgba(0, 0, 0, 0.42); pointer-events: none; }
.node-action-overlay .node-overlay-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 7px; }
.node-action-overlay .node-overlay-head strong { font-size: 11px; }
.node-action-overlay .node-overlay-status { color: var(--accent); font-size: 9px; }
.node-action-overlay textarea { min-height: 54px; max-height: 70px; padding: 7px; pointer-events: auto; font-size: 10px; }
.node-action-overlay .node-overlay-meta { display: grid; grid-template-columns: 1fr 1fr; gap: 4px 7px; margin: 7px 0; color: var(--muted); font-size: 9px; }
.node-action-overlay .node-overlay-actions { display: flex; gap: 5px; pointer-events: auto; }
.node-action-overlay .node-overlay-actions button { flex: 1; min-height: 27px; padding: 0 6px; font-size: 9px; }
.mobile-generation-dock { display: none; }

.preview-empty { display: grid; min-height: 240px; place-items: center; align-content: center; gap: 12px; color: var(--dim); }
.preview-empty > span { display: grid; width: 48px; height: 48px; place-items: center; border: 1px solid var(--line); border-radius: 50%; }
.preview-empty p { margin: 0; font-size: 11px; }
.preview-content { padding: 10px 11px 18px; }
.video-frame { position: relative; width: 100%; overflow: hidden; aspect-ratio: 16 / 9; border: 1px solid var(--line); border-radius: 7px; background: #050607; }
.video-frame video { width: 100%; height: 100%; object-fit: contain; }
.video-placeholder { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 10px; color: var(--dim); font-size: 11px; }
.video-play { position: absolute; left: 50%; top: 50%; display: grid; width: 42px; height: 42px; place-items: center; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 50%; background: rgba(8, 10, 13, 0.72); color: white; transform: translate(-50%, -50%); }
.task-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 13px 0 9px; }
.task-heading h3 { margin: 7px 0 0; font-size: 14px; }
.task-heading > strong { color: var(--muted); font-family: "SFMono-Regular", Consolas, monospace; font-size: 11px; }
.state-badge { display: inline-flex; min-height: 21px; align-items: center; padding: 0 7px; border: 1px solid var(--line); border-radius: 4px; color: var(--muted); font-size: 9px; font-weight: 750; }
.state-badge.queued { border-color: rgba(244, 185, 66, 0.45); color: var(--amber); }
.state-badge.processing { border-color: rgba(77, 163, 255, 0.45); color: #87bdff; }
.state-badge.completed { border-color: rgba(54, 209, 132, 0.45); color: var(--green); }
.state-badge.failed,
.state-badge.timeout { border-color: rgba(240, 107, 107, 0.45); color: #ff9696; }
.state-badge.stopped { border-color: rgba(156, 166, 181, 0.45); color: var(--muted); }
.task-meta { display: grid; gap: 0; margin: 0 0 10px; border-top: 1px solid var(--line); }
.task-meta div { display: grid; grid-template-columns: 70px minmax(0, 1fr); gap: 10px; padding: 7px 0; border-bottom: 1px solid #232932; }
.task-meta dt { color: var(--dim); font-size: 10px; }
.task-meta dd { min-width: 0; margin: 0; overflow-wrap: anywhere; color: #cbd3dd; font-size: 10px; text-align: right; }
.task-error { margin: -2px 0 10px; padding: 8px 9px; border: 1px solid rgba(240, 107, 107, 0.35); border-radius: 5px; background: rgba(240, 107, 107, 0.08); color: #ffadad; font-size: 10px; line-height: 1.5; overflow-wrap: anywhere; }
.preview-actions { display: flex; gap: 6px; margin-bottom: 14px; }
.preview-actions .button { margin-left: auto; }
.shot-inspector { padding: 12px 0; border-top: 1px solid var(--line); }
.shot-inspector h3,
.history-panel h3,
.template-section h3,
.developer-output h3 { margin: 0 0 10px; font-size: 12px; }
.field-grid { display: grid; gap: 10px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.shot-inspector textarea { min-height: 88px; font-size: 11px; }
.shot-inspector select { min-width: 0; font-size: 10px; }
.shot-reference-row { display: grid; grid-template-columns: 62px minmax(0, 1fr); gap: 8px; align-items: start; margin: 10px 0; padding: 8px 9px; border: 1px solid var(--line); border-radius: 5px; background: #0d1015; font-size: 10px; }
.shot-reference-row > span { color: var(--dim); }
.shot-reference-row > strong { min-width: 0; overflow-wrap: anywhere; color: #cbd3dd; font-weight: 600; text-align: right; }
.history-panel { padding-top: 12px; border-top: 1px solid var(--line); }
.section-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.section-title > span { display: grid; min-width: 21px; height: 21px; place-items: center; border-radius: 4px; background: var(--surface-3); color: var(--muted); font-size: 9px; }
.task-history { display: grid; gap: 6px; }
.history-item { display: grid; grid-template-columns: 8px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 8px; border: 1px solid var(--line); border-radius: 5px; background: #0d1015; }
.history-item > i { width: 7px; height: 7px; border-radius: 50%; background: var(--dim); }
.history-item.completed > i { background: var(--green); }
.history-item.failed > i,
.history-item.timeout > i { background: var(--red); }
.history-item.stopped > i { background: var(--muted); }
.history-item strong { display: block; font-size: 10px; }
.history-item small { display: block; margin-top: 3px; color: var(--dim); font-size: 8px; }
.history-item button { width: 25px; height: 25px; border: 0; background: transparent; color: var(--muted); }

.script-studio { position: relative; z-index: 20; display: grid; grid-template-rows: 43px minmax(0, 1fr); max-height: 306px; overflow: hidden; border-top: 1px solid var(--line); background: #0d1015; transition: max-height 180ms ease; }
.script-studio.collapsed { max-height: 43px; }
.script-toggle { display: flex; width: 100%; min-height: 43px; align-items: center; gap: 16px; padding: 0 13px; border: 0; border-bottom: 1px solid var(--line); background: #11151b; color: var(--text); text-align: left; }
.script-toggle > span:first-child { display: flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 750; }
.script-toggle i { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.script-toggle > span:nth-child(2) { color: var(--muted); font-size: 10px; }
.script-toggle b { margin-left: auto; font-size: 14px; transition: transform 150ms ease; }
.script-studio.collapsed .script-toggle b { transform: rotate(180deg); }
.script-content { height: auto; min-height: 0; display: grid; grid-template-columns: 210px 260px minmax(360px, 1fr); min-width: 0; overflow: hidden; }
.script-studio.collapsed .script-content { display: none; }
.script-options,
.script-presets { min-width: 0; overflow-y: auto; padding: 12px; border-right: 1px solid var(--line); }
.script-options { display: grid; align-content: start; gap: 8px; }
.script-options select { min-height: 31px; font-size: 10px; }
.script-command-group { display: flex; gap: 5px; margin-top: 4px; }
.script-presets { display: grid; align-content: start; gap: 10px; }
.script-presets fieldset { display: flex; flex-wrap: wrap; gap: 7px; margin: 0; padding: 8px; border: 1px solid var(--line); border-radius: 6px; }
.script-presets legend { padding: 0 5px; color: var(--muted); font-size: 9px; }
.script-presets fieldset label { display: flex; align-items: center; gap: 4px; font-size: 9px; }
.script-presets input[type="radio"] { width: 13px; min-height: 13px; accent-color: var(--accent); }
.script-presets .style-select select { min-height: 32px; font-size: 10px; }
.script-presets .style-select input { min-height: 32px; margin-top: 6px; font-size: 10px; }
.script-editor { display: grid; min-width: 0; min-height: 0; grid-template-rows: 34px minmax(0, 1fr) 41px; padding: 10px 12px; }
.script-tabs { display: flex; gap: 4px; }
.script-tabs button { min-height: 28px; padding: 0 10px; border: 0; border-radius: 4px; background: transparent; color: var(--muted); font-size: 10px; }
.script-tabs button[aria-selected="true"] { background: var(--surface-hover); color: var(--text); }
.script-editor textarea { min-height: 0; resize: none; font-size: 11px; }
.script-footer { display: flex; align-items: end; justify-content: space-between; gap: 12px; padding-top: 7px; }
.script-footer > span { color: var(--dim); font-size: 9px; }
.script-footer .button { min-height: 31px; font-size: 11px; }

.mobile-step-nav { display: none; }

.context-menu { position: fixed; z-index: 200; width: 174px; padding: 5px; border: 1px solid var(--line-strong); border-radius: 7px; background: #141820; box-shadow: var(--shadow); }
.context-menu button { display: flex; width: 100%; min-height: 32px; align-items: center; gap: 9px; padding: 0 9px; border: 0; border-radius: 4px; background: transparent; color: var(--text); font-size: 11px; text-align: left; }
.context-menu button:hover { background: var(--surface-hover); }
.context-menu button.danger { color: #ff9c9c; }
.context-menu hr { height: 1px; margin: 5px; border: 0; background: var(--line); }

.toast-region { position: fixed; right: 16px; bottom: 16px; z-index: 500; display: grid; width: min(360px, calc(100vw - 32px)); gap: 8px; pointer-events: none; }
.toast { padding: 11px 12px; border: 1px solid var(--line-strong); border-radius: 7px; background: #171c23; box-shadow: var(--shadow); color: #dce3ec; font-size: 11px; line-height: 1.5; animation: toast-in 160ms ease both; }
.toast.success { border-color: rgba(54, 209, 132, 0.45); }
.toast.error { border-color: rgba(240, 107, 107, 0.55); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

dialog { color: var(--text); }
dialog::backdrop { background: rgba(2, 4, 7, 0.72); backdrop-filter: blur(4px); }
.modal,
.drawer { border: 1px solid var(--line-strong); border-radius: 8px; background: #11151b; box-shadow: var(--shadow); }
.modal { width: min(520px, calc(100vw - 28px)); padding: 0; }
.modal form,
.drawer form { display: grid; gap: 15px; padding: 18px; }
.modal header,
.drawer header { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; }
.modal header h2,
.drawer header h2 { margin: 0; font-size: 18px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; padding-top: 3px; }
.field-note { color: var(--muted); font-size: 10px; line-height: 1.55; }
.reference-modal { width: min(640px, calc(100vw - 28px)); }
.reference-options { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.reference-options button { min-height: 130px; padding: 18px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface-2); color: var(--text); text-align: left; }
.reference-options button:hover { border-color: var(--accent); background: var(--accent-soft); }
.reference-options strong { display: block; margin-bottom: 10px; font-size: 15px; }
.reference-options span { display: block; color: var(--muted); font-size: 11px; line-height: 1.6; }
.drawer { position: fixed; width: min(500px, 100vw); max-width: 100%; height: 100dvh; max-height: 100dvh; margin: 0 0 0 auto; padding: 0; border-block: 0; border-right: 0; border-radius: 0; }
.drawer form { min-height: 100%; align-content: start; overflow-y: auto; }
.prompt-templates { display: flex; flex-wrap: wrap; gap: 6px; }
.prompt-templates button { min-height: 28px; padding: 0 9px; border: 1px solid var(--line); border-radius: 5px; background: var(--surface-2); color: #d5dce5; font-size: 10px; }
.developer-output { padding-top: 11px; border-top: 1px solid var(--line); }
.developer-output pre { max-height: 180px; margin: 0; overflow: auto; padding: 11px; border: 1px solid var(--line); border-radius: 6px; background: #080a0e; color: #b9e8df; font-family: "SFMono-Regular", Consolas, monospace; font-size: 9px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }
.script-history-list { display: grid; max-height: 50vh; gap: 7px; overflow-y: auto; }
.script-history-entry { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; padding: 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); }
.script-history-entry strong { display: block; font-size: 11px; }
.script-history-entry p { max-height: 7em; margin: 5px 0 0; overflow: auto; color: var(--muted); font-size: 9px; line-height: 1.4; overflow-wrap: anywhere; white-space: pre-wrap; }
.script-history-entry button { min-height: 28px; }

@media (max-width: 1420px) {
  :root { --left-width: 264px; --right-width: 316px; }
  .toolbar-row { gap: 8px; }
  .project-cluster { min-width: 220px; }
  .project-name-input { width: 145px; }
  .canvas-hint { display: none; }
  .button.compact { padding-inline: 8px; }
}

@media (max-width: 1180px) {
  :root { --left-width: 245px; --right-width: 292px; }
  .toolbar-row { overflow-x: auto; scrollbar-width: thin; }
  .toolbar-row-main,
  .toolbar-row-workflow { align-items: center; }
  .connection-cluster,
  .action-cluster,
  .canvas-settings { margin-left: 0; }
  .project-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .script-content { grid-template-columns: 190px 230px minmax(340px, 1fr); }
}

@media (min-width: 1001px) and (max-height: 720px) {
  .studio-view { min-height: 0; grid-template-rows: auto auto minmax(120px, 1fr) auto; }
  .script-studio { max-height: 170px; }
  .script-content { grid-template-columns: 180px 220px minmax(320px, 1fr); }
  .script-options,
  .script-presets { padding: 9px; }
}

@media (max-width: 1000px) {
  body { overflow: hidden; }
  .project-view { height: 100dvh; overflow-y: auto; }
  .project-header { position: sticky; min-height: 62px; padding: 10px 14px; }
  .brand img { width: 34px; height: 34px; }
  .brand small { display: none; }
  .project-header-actions { gap: 6px; }
  .project-header-actions .text-link,
  #new-folder-btn { display: none; }
  .project-header-actions .button { min-height: 34px; padding-inline: 10px; font-size: 12px; }
  .project-content { width: calc(100vw - 28px); padding: 28px 0 50px; }
  .project-heading { align-items: start; }
  .project-heading h1 { font-size: 26px; }
  .project-summary { display: grid; gap: 5px; text-align: right; font-size: 11px; }
  .folder-nav { margin: 22px 0 14px; }
  .project-grid { grid-template-columns: 1fr; }
  .project-card { min-height: 174px; grid-template-columns: 120px minmax(0, 1fr); grid-template-rows: 1fr; }
  .project-thumb { height: 100%; min-height: 174px; border-right: 1px solid var(--line); border-bottom: 0; }
  .project-thumb::before { width: 50px; height: 32px; box-shadow: 36px 18px 0 -4px #13292a, -33px 20px 0 -8px #202130; }

  .studio-view { min-height: 0; grid-template-rows: auto 54px minmax(0, 1fr); }
  .studio-toolbar { min-height: 58px; }
  .toolbar-row-main { min-height: 58px; padding: 8px 9px; overflow: visible; }
  .toolbar-row-workflow,
  .mode-cluster,
  .connection-cluster,
  .action-cluster { display: none; }
  .project-cluster { width: 100%; min-width: 0; }
  .toolbar-logo { display: none; }
  .project-name-input { flex: 1; width: auto; min-width: 0; }
  .project-cluster::after { content: "本地自动保存"; flex: 0 0 auto; color: var(--dim); font-size: 9px; }
  .mobile-step-nav { display: grid; grid-template-columns: repeat(4, 1fr); border-bottom: 1px solid var(--line); background: #0d1015; }
  .mobile-step-nav button { display: flex; min-width: 0; min-height: 53px; align-items: center; justify-content: center; gap: 6px; border: 0; border-bottom: 2px solid transparent; background: transparent; color: var(--muted); font-size: 11px; }
  .mobile-step-nav button span { display: grid; width: 20px; height: 20px; place-items: center; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 9px; }
  .mobile-step-nav button.active { border-bottom-color: var(--accent); color: var(--text); }
  .mobile-step-nav button.active span { border-color: var(--accent); background: var(--accent); color: #061210; }
  .studio-body { display: block; min-height: 0; }
  .side-panel,
  .canvas-panel { position: absolute; inset: 112px 0 0; width: 100%; border: 0; }
  .asset-panel,
  .preview-panel { overflow-y: auto; }
  [data-mobile-panel] { display: none; }
  .studio-view[data-mobile-step="assets"] [data-mobile-panel="assets"],
  .studio-view[data-mobile-step="generate"] [data-mobile-panel="generate"],
  .studio-view[data-mobile-step="results"] [data-mobile-panel="results"],
  .studio-view[data-mobile-step="script"] [data-mobile-panel="script"] { display: block; }
  .panel-header { min-height: 56px; }
  .panel-toggle { display: none; }
  .asset-categories { min-height: 180px; }
  .asset-item { min-height: 58px; grid-template-columns: 44px minmax(0, 1fr) auto; }
  .asset-thumb { width: 44px; height: 44px; }
  .canvas-panel { bottom: 0; }
  .canvas-stage { bottom: 58px; }
  .mobile-generation-dock { position: absolute; inset: auto 0 0; display: block; height: 58px; padding: 9px 12px; border-top: 1px solid var(--line); background: #101319; }
  .preview-panel { padding-bottom: 30px; }
  .preview-content { padding: 12px 14px 26px; }
  .video-frame { max-height: 42dvh; }
  .script-studio { position: absolute; inset: 112px 0 0; max-height: none; overflow-y: auto; border-top: 0; }
  .script-toggle { display: none; }
  .script-studio { grid-template-rows: minmax(0, 1fr); }
  .script-content { height: auto; min-height: 100%; display: grid; grid-template-columns: 1fr; overflow: visible; }
  .script-options,
  .script-presets { overflow: visible; border-right: 0; border-bottom: 1px solid var(--line); }
  .script-options { grid-template-columns: 1fr 1fr; }
  .script-command-group { align-items: end; }
  .script-presets fieldset { padding: 10px; }
  .script-editor { min-height: 300px; grid-template-rows: 40px minmax(210px, 1fr) 48px; padding: 12px; }
  .node-action-overlay { width: min(236px, calc(100vw - 24px)); }
  .context-menu { width: min(190px, calc(100vw - 24px)); }
  .drawer { width: 100%; }
  .field-grid.three { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .project-card { grid-template-columns: 102px minmax(0, 1fr); }
  .reference-options { grid-template-columns: 1fr; }
  .field-grid.two { grid-template-columns: 1fr; }
  .script-options { grid-template-columns: 1fr; }
  .project-cluster::after { display: none; }
}

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