:root {
  color-scheme: dark;
  --canvas: #0a0a0a;
  --chrome: #0a0a0a;
  --panel: #1c1d22;
  --panel-2: #141519;
  --panel-3: #26272d;
  --line: #2a2b31;
  --line-soft: #1f2026;
  --text: #f2f3f5;
  --text-dim: #9b9da4;
  --text-faint: #6b6d75;
  --accent: #78fb60;
  --accent-rgb: 120, 251, 96;
  --accent-dim: #5c7b5f;
  --accent-ink: #08130a;
  --accent-hover: #8bff76;
  --canvas-dot: #1a1b1f;
  --edge: #6a6d78;
  --panel-hover: #313239;
  --danger: #ff6b5e;
  --radius: 10px;
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.55);
  font-family: "Microsoft YaHei", "PingFang SC", "Segoe UI", system-ui, sans-serif;
  font-size: 14px;
}

:root[data-theme="white"] {
  color-scheme: light;
  --canvas: #f7f8f9;
  --chrome: #ffffff;
  --panel: #ffffff;
  --panel-2: #f1f3f5;
  --panel-3: #e6e9ed;
  --line: #d6dae0;
  --line-soft: #e7eaee;
  --text: #17191c;
  --text-dim: #5d6269;
  --text-faint: #8a9098;
  --accent: #347a3c;
  --accent-rgb: 52, 122, 60;
  --accent-dim: #7da382;
  --accent-ink: #ffffff;
  --accent-hover: #3f8f48;
  --canvas-dot: #dfe3e8;
  --edge: #9299a3;
  --panel-hover: #dce1e7;
  --danger: #c63f34;
  --shadow: 0 18px 44px rgba(35, 42, 52, 0.18);
}

:root[data-theme="warm"] {
  color-scheme: dark;
  --canvas: #26211b;
  --chrome: #201c17;
  --panel: #342d25;
  --panel-2: #2b251f;
  --panel-3: #443a30;
  --line: #514438;
  --line-soft: #3d342b;
  --text: #f4ecdf;
  --text-dim: #c7b9a7;
  --text-faint: #958675;
  --accent: #e8a35c;
  --accent-rgb: 232, 163, 92;
  --accent-dim: #9a7044;
  --accent-ink: #281b0e;
  --accent-hover: #f2b06c;
  --canvas-dot: #3b332a;
  --edge: #948372;
  --panel-hover: #504338;
  --danger: #ff7a67;
  --shadow: 0 18px 44px rgba(15, 11, 8, 0.5);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--canvas);
  color: var(--text);
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  background: none;
  border: 0;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.app {
  display: grid;
  grid-template-rows: 64px 1fr;
  height: 100vh;
}

/* ---------- top bar ---------- */

.topbar {
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(200px, 1fr) auto minmax(200px, 1fr);
  align-items: center;
  gap: 16px;
  padding: 0 16px;
  background: var(--chrome);
  border-bottom: 1px solid var(--line-soft);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}

.brand-mark {
  align-self: center;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--accent);
}

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

.brand strong {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}

.brand-en {
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
}

.build-tag {
  padding: 1px 6px;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  white-space: nowrap;
}

.topbar-center {
  display: flex;
  align-items: center;
  gap: 8px;
}

.workflow-name {
  width: 200px;
  padding: 5px 8px;
  text-align: center;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  outline: none;
}

.workflow-name:hover {
  background: var(--panel-2);
}

.workflow-name:focus {
  background: var(--panel-2);
  border-color: var(--line);
}

.save-state {
  color: var(--text-faint);
  font-size: 11px;
  white-space: nowrap;
}

.save-state.dirty {
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.config-status {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 28px;
  padding: 0 10px;
  color: var(--text-dim);
  background: var(--panel-2);
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}

.config-status[hidden] {
  display: none;
}

.config-status .dot {
  width: 6px;
  height: 6px;
  background: var(--text-faint);
  border-radius: 50%;
}

.config-status.ok .dot {
  background: var(--accent);
  box-shadow: 0 0 8px rgba(var(--accent-rgb), 0.65);
}

.config-status.error .dot {
  background: var(--danger);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 30px;
  padding: 0 13px;
  color: var(--text-dim);
  border-radius: 7px;
  font-size: 13px;
  transition: color 120ms ease, background 120ms ease;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.btn:hover {
  color: var(--text);
  background: var(--panel-2);
}

.btn.primary {
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 700;
}

.btn.primary:hover {
  background: var(--accent-hover);
}

.assistant-action {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  height: 52px;
  padding: 0 22px 0 15px;
  color: var(--text);
  background: linear-gradient(135deg, rgba(var(--accent-rgb), 0.16), rgba(var(--accent-rgb), 0.04));
  border: 1px solid rgba(var(--accent-rgb), 0.35);
  border-radius: 999px;
  font-size: 21px;
  font-weight: 700;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}

.assistant-action:hover,
.assistant-action[aria-expanded="true"] {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.2);
  border-color: rgba(var(--accent-rgb), 0.6);
}

.assistant-action-icon {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
  border-radius: 50%;
}

.assistant-action-icon svg {
  width: 31px;
  height: 31px;
}

.assistant-action-label {
  white-space: nowrap;
}

/* ---------- language assistant ---------- */

.language-panel {
  position: fixed;
  top: 76px;
  right: 16px;
  z-index: 55;
  display: flex;
  flex-direction: column;
  width: min(500px, calc(100vw - 24px));
  height: min(680px, calc(100vh - 96px));
  min-width: min(360px, calc(100vw - 24px));
  min-height: min(420px, calc(100vh - 96px));
  max-width: calc(100vw - 16px);
  max-height: calc(100vh - 72px);
  resize: none;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.language-resize {
  position: absolute;
  left: 3px;
  right: auto;
  bottom: 3px;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  color: var(--text-faint);
  cursor: nesw-resize;
  touch-action: none;
}

.language-resize:hover {
  color: var(--accent);
}

.language-resize svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.5;
  stroke-linecap: round;
  transform: rotate(90deg);
  transform-origin: center;
}

body.resizing-language,
body.resizing-language *,
body.dragging-language,
body.dragging-language * {
  user-select: none !important;
}

.language-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 10px;
  border-bottom: 1px solid var(--line-soft);
  cursor: move;
  user-select: none;
  touch-action: none;
}

.language-head strong {
  display: block;
  font-size: 22px;
}

.language-head span {
  display: block;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 17px;
}

.language-head-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 4px;
}

.language-clear-history {
  height: 30px;
  padding: 0 5px;
  color: var(--text-faint);
  border-radius: 5px;
  font-size: 13px;
}

.language-clear-history:hover {
  color: var(--text);
  background: var(--panel-2);
}

.language-model-row {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.language-model-row label {
  flex: none;
  color: var(--text-faint);
  font-size: 15px;
  font-weight: 600;
}

.language-model-row select {
  flex: 1;
  min-width: 0;
  height: 34px;
  padding: 0 8px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 15px;
  outline: none;
}

.language-model-row select#language-effort {
  flex: 0 0 78px;
  width: 78px;
  height: 34px;
  padding: 0 6px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 6px;
  outline: none;
  font-size: 15px;
}

.language-balance {
  flex: none;
  min-width: 86px;
  height: 34px;
  padding: 0 9px;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  border-radius: 999px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease;
}

.language-balance:hover:not(:disabled) {
  background: rgba(var(--accent-rgb), 0.18);
  border-color: rgba(var(--accent-rgb), 0.5);
}

.language-balance.loading {
  color: var(--text-dim);
}

.language-balance.error {
  color: var(--text-faint);
  background: var(--panel-2);
  border-color: var(--line);
}

.language-balance:disabled {
  cursor: wait;
  opacity: 0.75;
}

.language-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 9px 12px 0;
}

.language-thumb {
  position: relative;
  width: 84px;
  height: 84px;
  overflow: hidden;
  background: #000;
  border-radius: 8px;
}

.language-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.language-thumb button {
  position: absolute;
  top: 2px;
  right: 2px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: #fff;
  background: rgba(0, 0, 0, 0.72);
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
}

.language-log {
  flex: 1;
  min-height: 150px;
  overflow-y: auto;
  padding: 10px 12px;
}

.language-empty {
  display: grid;
  place-items: center;
  height: 100%;
  min-height: 130px;
  color: var(--text-faint);
  font-size: 16px;
  text-align: center;
  line-height: 1.6;
}

.language-message {
  margin-bottom: 9px;
  padding: 10px 12px;
  border-radius: 9px;
  font-size: 18px;
  line-height: 1.65;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.language-message.user {
  margin-left: 28px;
  color: var(--text);
  background: var(--panel-3);
}

.language-message.assistant {
  margin-right: 28px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid var(--line-soft);
}

.language-message .language-message-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px solid var(--line-soft);
}

.language-message .language-message-actions button {
  color: var(--accent);
  font-size: 14px;
}

.language-message .language-message-actions button:hover {
  text-decoration: underline;
}

.language-message-thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 8px;
}

.language-message-thumb {
  width: 72px;
  height: 72px;
  overflow: hidden;
  padding: 0;
  background: #000;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
}

.language-message-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.language-compose {
  padding: 10px 12px 12px;
  border-top: 1px solid var(--line-soft);
}

.language-prompt-wrap {
  position: relative;
}

.language-compose textarea {
  display: block;
  width: 100%;
  min-height: 76px;
  max-height: none;
  padding: 8px 9px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
  resize: none;
  font-size: 18px;
  line-height: 1.55;
}

.language-prompt-resize {
  position: absolute;
  left: 50%;
  top: -6px;
  bottom: auto;
  z-index: 2;
  width: 48px;
  height: 12px;
  transform: translateX(-50%);
  cursor: ns-resize;
  touch-action: none;
}

.language-prompt-resize::before {
  position: absolute;
  top: 5px;
  left: 9px;
  right: 9px;
  height: 2px;
  background: var(--line);
  border-radius: 999px;
  content: '';
}

.language-prompt-resize:hover::before {
  background: var(--accent);
}

.language-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 12px;
  padding-left: 24px;
}

.language-actions #language-clear-images {
  flex: none;
}

.language-actions #language-send {
  flex: none;
  margin-left: 2px;
}

/* ---------- layout ---------- */

.workspace {
  position: relative;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  min-height: 0;
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-column: 2;
  order: 2;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

/* ---------- left rail ---------- */

.project-panel,
.prompt-panel {
  position: fixed;
  top: 76px;
  left: 88px;
  z-index: 72;
  display: flex;
  flex-direction: column;
  width: 360px;
  height: min(560px, calc(100vh - 96px));
  min-width: 280px;
  min-height: 260px;
  max-width: calc(100vw - 104px);
  max-height: calc(100vh - 92px);
  overflow: hidden;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 20px 54px rgba(0, 0, 0, 0.38);
}

.project-panel.collapsed,
.prompt-panel.collapsed {
  display: none;
}

.project-head {
  cursor: move;
  user-select: none;
  touch-action: none;
}

.project-head button {
  cursor: pointer;
}

body.dragging-floating-panel,
body.dragging-floating-panel *,
body.resizing-floating-panel,
body.resizing-floating-panel * {
  user-select: none !important;
}

.floating-panel-resize {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 5;
  width: 20px;
  height: 20px;
  cursor: nwse-resize;
  touch-action: none;
}

.floating-panel-resize::before,
.floating-panel-resize::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 8px;
  height: 8px;
  border-right: 2px solid var(--text-faint);
  border-bottom: 2px solid var(--text-faint);
  content: '';
  transition: border-color 120ms ease;
}

.floating-panel-resize::after {
  right: 9px;
  bottom: 9px;
  width: 4px;
  height: 4px;
}

.floating-panel-resize:hover::before,
.floating-panel-resize:hover::after {
  border-color: var(--accent);
}

.prompt-search-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px 4px;
}

.prompt-search {
  flex: 1;
  min-width: 0;
  height: 36px;
  padding: 0 10px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  font-size: 15px;
  outline: none;
}

.prompt-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 36px;
  padding: 0 10px;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 7px;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}

.prompt-add svg {
  width: 15px;
  height: 15px;
}

.prompt-folders {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--line-soft);
}

.prompt-folder {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  height: 30px;
  padding: 0 8px;
  color: var(--text-dim);
  background: var(--panel);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 13px;
}

.prompt-folder > span:first-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-folder small {
  color: var(--text-faint);
  font-size: 11px;
}

.prompt-folder:hover,
.prompt-folder.active {
  color: var(--text);
  border-color: var(--accent);
}

.prompt-folder-actions {
  display: none;
  gap: 3px;
  margin-left: 2px;
}

.prompt-folder:hover .prompt-folder-actions {
  display: inline-flex;
}

.prompt-folder-actions span {
  color: var(--text-faint);
  font-size: 11px;
}

.prompt-folder-actions span:hover {
  color: var(--accent);
}

.prompt-list {
  flex: 1;
  min-height: 0;
  padding: 10px;
  overflow-y: auto;
}

.prompt-card {
  position: relative;
  display: flex;
  align-items: stretch;
  margin-bottom: 7px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line-soft);
  border-radius: 9px;
}

.prompt-card:hover {
  border-color: var(--line);
}

.prompt-card-main {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  min-width: 0;
  padding: 10px 42px 10px 11px;
  text-align: left;
  flex: 1;
}

.prompt-card-main b {
  width: 100%;
  overflow: hidden;
  color: var(--text);
  font-size: 15px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.prompt-card-main > span {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-dim);
  font-size: 13px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.prompt-card-main small {
  color: var(--text-faint);
  font-size: 11px;
}

.prompt-card-edit {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--text-faint);
  border-radius: 6px;
  opacity: 0;
}

.prompt-card:hover .prompt-card-edit {
  opacity: 1;
}

.prompt-card-edit:hover {
  color: var(--text);
  background: var(--panel-3);
}

.prompt-card-edit svg {
  width: 15px;
  height: 15px;
}

.prompt-empty {
  padding: 14px 12px;
}

.project-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 70px;
  padding: 0 14px 0 20px;
  border-bottom: 1px solid var(--line-soft);
  font-size: 21px;
  font-weight: 700;
  white-space: nowrap;
}

.project-add {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  color: var(--text-faint);
  border-radius: 6px;
}

.project-add:hover {
  color: var(--accent);
  background: var(--panel-3);
}

.project-add svg {
  width: 28px;
  height: 28px;
}

.project-list {
  flex: 1;
  min-height: 0;
  padding: 10px;
  overflow-y: auto;
}

.project-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 16px 102px 16px 16px;
  margin-bottom: 6px;
  color: var(--text-dim);
  text-align: left;
  border-radius: 8px;
}

.project-item:hover {
  color: var(--text);
  background: var(--panel-3);
}

.project-item.active {
  color: var(--text);
  background: rgba(var(--accent-rgb), 0.1);
  box-shadow: inset 2px 0 0 var(--accent);
}

.project-item-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.project-item-name {
  overflow: hidden;
  font-size: 20px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.project-item-meta {
  color: var(--text-faint);
  font-size: 16px;
}

.project-item-edit,
.project-item-remove {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  flex: none;
  color: var(--text-faint);
  border-radius: 5px;
  opacity: 0;
}

.project-item:hover .project-item-edit,
.project-item.active .project-item-edit,
.project-item:hover .project-item-remove,
.project-item.active .project-item-remove {
  opacity: 1;
}

@media (hover: none) {
  .project-item-edit,
  .project-item-remove {
    opacity: 1;
  }
}

.project-item-edit:hover {
  color: var(--text);
  background: var(--panel);
}

.project-item-remove:hover {
  color: var(--danger);
  background: var(--panel);
}

.project-item-edit svg,
.project-item-remove svg {
  width: 21px;
  height: 21px;
}

.project-item-input {
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--accent);
  border-radius: 5px;
  font-size: 20px;
  outline: none;
}

.project-collapse {
  position: absolute;
  top: 12px;
  right: 48px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  color: var(--text-faint);
  border-radius: 6px;
}

.project-collapse:hover {
  color: var(--text);
  background: var(--panel);
}

.project-collapse svg {
  width: 18px;
  height: 18px;
}

.rail {
  z-index: 50;
  display: flex;
  flex-direction: column;
  align-items: center;
  grid-column: 1;
  order: 1;
  gap: 7px;
  padding: 16px 0;
  background: var(--chrome);
  border-right: 1px solid var(--line-soft);
}

.rail-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  color: var(--text-faint);
  border-radius: 8px;
  transition: color 120ms ease, background 120ms ease;
}

.rail-btn svg {
  width: 27px;
  height: 27px;
}

.rail-btn:hover {
  color: var(--text);
  background: var(--panel-2);
}

.rail-btn.active {
  color: var(--accent);
  background: var(--panel-2);
}

.rail-sep {
  width: 34px;
  height: 1px;
  margin: 6px 0;
  background: var(--line);
}

.visionary-balance {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 68px;
  min-height: 74px;
  padding: 7px 4px;
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.09);
  border: 1px solid rgba(var(--accent-rgb), 0.3);
  border-radius: 10px;
  text-align: center;
  transition: color 120ms ease, background 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.balance-wrap {
  position: relative;
}

.balance-panel {
  position: absolute;
  top: 0;
  left: 78px;
  z-index: 70;
  width: 322px;
  max-height: min(70vh, 620px);
  overflow-y: auto;
  padding: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

@media (max-width: 760px) {
  .balance-panel {
    left: 74px;
    width: min(322px, calc(100vw - 86px));
    max-width: calc(100vw - 86px);
    max-height: calc(100vh - 96px);
  }
}

.balance-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 8px 10px;
  border-bottom: 1px solid var(--line-soft);
}

.balance-panel-head > div {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.balance-panel-head strong {
  color: var(--text);
  font-size: 15px;
}

.balance-panel-head small {
  color: var(--text-faint);
  font-size: 11px;
}

.balance-panel-head button {
  height: 30px;
  padding: 0 10px;
  color: var(--text-dim);
  background: var(--panel-2);
  border-radius: 7px;
  font-size: 12px;
}

.balance-panel-head button:hover:not(:disabled) {
  color: var(--text);
  background: var(--panel-3);
}

.balance-panel-head button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.balance-panel-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
}

.balance-item {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 9px;
  padding: 9px;
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 9px;
}

.balance-item.ready {
  border-color: rgba(var(--accent-rgb), 0.28);
}

.balance-item.error {
  border-color: color-mix(in srgb, var(--danger) 35%, transparent);
}

.balance-kind {
  display: grid;
  place-items: center;
  align-self: start;
  height: 26px;
  color: var(--text-dim);
  background: var(--panel-3);
  border-radius: 6px;
  font-size: 10px;
  font-weight: 700;
}

.balance-item-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.balance-item-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.balance-item-title b {
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-item-title em {
  flex: none;
  color: var(--text-faint);
  font-size: 10px;
  font-style: normal;
}

.balance-item-main > strong {
  color: var(--accent);
  font-size: 16px;
  line-height: 1.2;
}

.balance-item-main > small {
  overflow: hidden;
  color: var(--text-faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.balance-item-actions {
  display: flex;
  gap: 6px;
  margin-top: 4px;
}

.balance-item-actions button {
  min-height: 26px;
  padding: 0 8px;
  color: var(--text-dim);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 6px;
  font-size: 11px;
}

.balance-item-actions button:hover {
  color: var(--text);
  border-color: var(--accent);
}

.balance-item-actions button[data-platform-action] {
  color: var(--accent);
  border-color: rgba(var(--accent-rgb), 0.35);
}

.balance-empty {
  margin: 0;
  padding: 18px 10px;
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
}

.visionary-balance:hover:not(:disabled) {
  background: rgba(var(--accent-rgb), 0.17);
  border-color: rgba(var(--accent-rgb), 0.58);
}

.visionary-balance.login-needed {
  color: var(--text-dim);
  background: var(--panel-2);
  border-color: var(--line);
}

.visionary-balance.error {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, transparent);
}

.visionary-balance.loading {
  cursor: wait;
  opacity: 0.72;
}

.visionary-balance-icon svg {
  width: 18px;
  height: 18px;
}

.visionary-balance-label {
  font-size: 10px;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.visionary-balance strong {
  max-width: 62px;
  overflow: hidden;
  color: inherit;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.theme-wrap {
  position: relative;
}

.theme-menu {
  position: absolute;
  top: 0;
  left: 48px;
  z-index: 65;
  width: 184px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.theme-menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 9px;
  color: var(--text-dim);
  text-align: left;
  border-radius: 7px;
}

.theme-menu button:hover,
.theme-menu button.active {
  color: var(--text);
  background: var(--panel-3);
}

.theme-menu button > span:last-child {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.theme-menu b {
  font-size: 13px;
  font-weight: 700;
}

.theme-menu small {
  color: var(--text-faint);
  font-size: 10px;
}

.theme-swatch {
  width: 20px;
  height: 20px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 50%;
}

.theme-swatch.black {
  background: #111216;
}

.theme-swatch.white {
  background: #fbfcfd;
}

.theme-swatch.warm {
  background: #d99a54;
}

.add-wrap {
  position: relative;
}

.add-menu {
  position: absolute;
  top: 0;
  left: 48px;
  z-index: 60;
  width: 224px;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.add-menu button {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 9px 10px;
  text-align: left;
  border-radius: 7px;
}

.add-menu button:hover {
  background: var(--panel-3);
}

.add-menu button b {
  font-size: 13px;
  font-weight: 600;
}

.add-menu button small {
  color: var(--text-faint);
  font-size: 11px;
}

.add-menu button.pending {
  opacity: 0.5;
}

.add-menu button.pending::after {
  content: "待接入";
  position: absolute;
  right: 16px;
  color: var(--accent);
  font-size: 10px;
}

/* ---------- canvas ---------- */

.viewport {
  position: relative;
  grid-column: 1;
  min-width: 0;
  overflow: hidden;
  background-color: var(--canvas);
  background-image: radial-gradient(circle at 1px 1px, var(--canvas-dot) 1px, transparent 0);
  background-size: 26px 26px;
  cursor: default;
  touch-action: none;
}

.viewport[data-tool="pan"] {
  cursor: grab;
}

.viewport.panning {
  cursor: grabbing;
}

.viewport.dragover {
  outline: 2px dashed var(--accent);
  outline-offset: -8px;
}

.world {
  position: absolute;
  inset: 0;
  transform-origin: 0 0;
}

.edges {
  position: absolute;
  top: -10000px;
  left: -10000px;
  width: 20000px;
  height: 20000px;
  overflow: visible;
  pointer-events: none;
}

.edge {
  fill: none;
  stroke: var(--edge);
  stroke-width: 1;
  marker-end: url(#edge-arrow);
  transition: stroke 120ms ease, stroke-width 120ms ease;
}

.edge.active {
  stroke: var(--accent);
  stroke-width: 1.4;
  marker-end: url(#edge-arrow-active);
  filter: url(#edge-glow);
}

.pending-edge {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.2;
  stroke-dasharray: 6 5;
}

.node-layer {
  position: absolute;
  inset: 0;
}

/* ---------- nodes ---------- */

.node {
  position: absolute;
  width: 280px;
  min-height: 120px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.45);
  user-select: none;
}

.node.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), 0 12px 30px rgba(0, 0, 0, 0.5);
}

.node.running {
  border-color: var(--accent);
}

.node.failed {
  border-color: var(--danger);
}

/* Reference and output read as pictures pinned to the canvas, like Dabby:
   the chrome only shows up for hover, selection, and the node menu. */
.node.node-media {
  background: transparent;
  border-color: transparent;
  box-shadow: none;
}

.node.node-media .node-head {
  height: 26px;
  padding: 0 6px 0 8px;
  background: rgba(16, 17, 20, 0.78);
  border-bottom: 0;
  border-radius: 9px 9px 0 0;
  opacity: 0;
  transition: opacity 120ms ease;
}

.node.node-media .node-body {
  padding: 0;
}

.node.node-media:hover .node-head,
.node.node-media.selected .node-head,
.node.node-media.running .node-head,
.node.node-media.failed .node-head,
.node.node-media:focus-within .node-head {
  opacity: 1;
}

.node.node-media.selected {
  border-color: transparent;
  box-shadow: none;
}

.node.node-media.selected .node-body {
  box-shadow: 0 0 0 2px var(--accent);
  border-radius: 9px;
}

.node.node-media .node-icon svg {
  width: 12px;
  height: 12px;
}

.node.node-media .node-title {
  font-size: 12px;
}

.node.node-media .node-badge {
  padding: 0 5px;
}

.node.marked .node-body {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}

.node.cover .node-head {
  background: rgba(var(--accent-rgb), 0.1);
}

.node.cover .node-badge::before {
  content: '封面 · ';
}

.node.node-media .node-menu {
  width: 18px;
  height: 18px;
}

@media (hover: none) {
  .node.node-media .node-head {
    opacity: 1;
  }
}

.node-head {
  display: flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 8px 0 10px;
  border-bottom: 1px solid var(--line-soft);
  cursor: move;
}

.node-icon {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  color: var(--accent);
}

.node-icon svg {
  width: 14px;
  height: 14px;
}

.node-title {
  flex: 1;
  overflow: hidden;
  font-size: 13px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.node-badge {
  padding: 1px 7px;
  color: var(--text-faint);
  background: var(--panel-2);
  border-radius: 999px;
  font-size: 10px;
  white-space: nowrap;
}

.node-badge.ready {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}

.node-badge.running {
  color: var(--accent);
  background: rgba(var(--accent-rgb), 0.12);
}

.node-badge.failed {
  color: var(--danger);
  background: rgba(255, 107, 94, 0.12);
}

.node-menu {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  color: var(--text-faint);
  border-radius: 5px;
}

.node-menu:hover {
  color: var(--danger);
  background: rgba(255, 107, 94, 0.1);
}

.node-menu svg {
  width: 13px;
  height: 13px;
}

.node-body {
  padding: 10px;
  font-size: 12px;
}

.node-ports {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.port {
  position: absolute;
  display: flex;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  color: var(--text-faint);
  font-size: 10px;
  white-space: nowrap;
}

.port.in {
  top: 32px;
  left: -7px;
  flex-direction: row;
}

.port.out {
  top: 32px;
  right: -7px;
  flex-direction: row-reverse;
}

.port-dot {
  width: 13px;
  height: 13px;
  background: #14151a;
  border: 2px solid #4d4f58;
  border-radius: 50%;
  cursor: crosshair;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
}

.port:hover .port-dot,
.port.active .port-dot {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.12);
}

.port-label {
  opacity: 0;
  transition: opacity 120ms ease;
}

.port:hover .port-label {
  opacity: 1;
}

.node-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.node-preview img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #000;
  border-radius: 7px;
}

.node-placeholder {
  display: grid;
  place-items: center;
  min-height: 74px;
  color: var(--text-faint);
  background: var(--panel-2);
  border: 1px dashed var(--line);
  border-radius: 7px;
  text-align: center;
  line-height: 1.5;
}

.node-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 9px;
}

.node-field:last-child {
  margin-bottom: 0;
}

.node-field > span {
  color: var(--text-faint);
  font-size: 10px;
}

.node-field textarea,
.node-field select,
.node-field input {
  width: 100%;
  padding: 7px 8px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
  resize: vertical;
}

.node-field textarea {
  min-height: 74px;
  line-height: 1.5;
}

.node-field textarea:focus,
.node-field select:focus,
.node-field input:focus {
  border-color: var(--accent);
}

.node-hint {
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.5;
}

.node-status {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  padding: 7px 8px;
  color: var(--text-dim);
  background: var(--panel-2);
  border-radius: 7px;
  font-size: 11px;
}

.node-status .spinner {
  width: 11px;
  height: 11px;
  border: 2px solid rgba(var(--accent-rgb), 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.node-status.failed {
  color: #ffaaa2;
  background: rgba(255, 107, 94, 0.1);
}

.node-actions {
  display: flex;
  gap: 6px;
  margin-top: 9px;
}

.mini-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 29px;
  padding: 0 10px;
  color: var(--text);
  background: var(--panel-3);
  border-radius: 7px;
  font-size: 11px;
}

.mini-btn:hover {
  background: var(--panel-hover);
}

.mini-btn.primary {
  flex: 1;
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 700;
}

.mini-btn.danger {
  color: #ffaaa2;
  background: rgba(255, 107, 94, 0.1);
}

/* ---------- reference upload ---------- */

.ref-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.ref-chain {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.ref-chain-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 9px;
}

.ref-chain-item .ref-thumb {
  width: 62px;
  flex: none;
}

.ref-chain-number {
  color: var(--text-dim);
  font-size: 11px;
}

.ref-chain-link {
  position: relative;
  display: block;
  width: 2px;
  height: 15px;
  margin-left: 30px;
  background: #4a4d57;
}

.ref-chain-link::before,
.ref-chain-link::after {
  content: "";
  position: absolute;
  left: 50%;
  width: 7px;
  height: 7px;
  background: var(--panel-2);
  border: 2px solid #5f636e;
  border-radius: 50%;
  transform: translateX(-50%);
}

.ref-chain-link::before {
  top: -4px;
}

.ref-chain-link::after {
  bottom: -4px;
}

.ref-single {
  position: relative;
  overflow: hidden;
  background: #000;
  border-radius: 8px;
}

/* On the canvas a reference picture is only a picture: numbering and the
   remove control stay hidden until the pointer is over it. */
.ref-stack {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ref-item {
  position: relative;
  overflow: hidden;
  background: #000;
  border-radius: 8px;
}

.ref-item img {
  display: block;
  width: 100%;
  object-fit: contain;
}

.ref-item .ref-index,
.ref-item button {
  opacity: 0;
  transition: opacity 120ms ease;
}

.ref-item:hover .ref-index,
.ref-item:hover button,
.ref-item:focus-within .ref-index,
.ref-item:focus-within button {
  opacity: 1;
}

.ref-item button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #fff;
  background: rgba(0, 0, 0, 0.68);
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
}

.ref-index {
  position: absolute;
  left: 5px;
  bottom: 5px;
  padding: 1px 6px;
  color: #0a0a0a;
  background: rgba(242, 243, 245, 0.92);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
  pointer-events: none;
}

.result-index {
  color: var(--accent-ink);
  background: rgba(var(--accent-rgb), 0.92);
}

.ref-chain-item .ref-index {
  position: absolute;
  left: 5px;
  bottom: 5px;
}

.ref-single img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
}

.ref-single button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #fff;
  background: rgba(0, 0, 0, 0.68);
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
}

.node-preview.single {
  grid-template-columns: minmax(0, 1fr);
}

.node-preview.single img {
  object-fit: contain;
}

.preview-extra {
  margin-top: 7px;
  color: var(--text-faint);
  font-size: 11px;
}

/* ---------- generated picture with its own caption ---------- */
.gen-figure {
  display: flex;
  flex-direction: column;
  margin: 0;
  overflow: hidden;
  background: var(--panel);
  border-radius: 9px;
}

.gen-image {
  position: relative;
  overflow: hidden;
  background: #000;
  border-radius: 9px;
}

.gen-stack {
  display: flex;
  flex-direction: column;
}

.gen-stack .gen-image + .gen-image {
  margin-top: 2px;
}

.gen-image img {
  display: block;
  width: 100%;
  object-fit: contain;
}

.ref-thumb {
  position: relative;
  overflow: hidden;
  aspect-ratio: 1 / 1;
  background: #000;
  border-radius: 7px;
}

.ref-chain-item .ref-thumb {
  position: relative;
}

.ref-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.ref-thumb button {
  position: absolute;
  top: 4px;
  right: 4px;
  display: grid;
  place-items: center;
  width: 18px;
  height: 18px;
  color: #fff;
  background: rgba(0, 0, 0, 0.68);
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
}

.upload-zone {
  display: grid;
  place-items: center;
  gap: 4px;
  min-height: 82px;
  padding: 10px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px dashed var(--line);
  border-radius: 7px;
  cursor: pointer;
  text-align: center;
}

.upload-zone:hover,
.upload-zone.dragover {
  color: var(--accent);
  border-color: var(--accent);
}

.upload-zone svg {
  width: 18px;
  height: 18px;
}

.upload-zone small {
  color: var(--text-faint);
  font-size: 10px;
}

.marquee {
  position: absolute;
  background: rgba(var(--accent-rgb), 0.08);
  border: 1px solid var(--accent);
  pointer-events: none;
}

/* ---------- canvas controls ---------- */

.zoom-control {
  position: absolute;
  right: 14px;
  bottom: 14px;
  display: flex;
  align-items: center;
  overflow: hidden;
  background: var(--panel);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.zoom-control button {
  display: grid;
  place-items: center;
  min-width: 34px;
  height: 32px;
  color: var(--text-dim);
  border-right: 1px solid var(--line-soft);
  font-size: 12px;
}

.zoom-control button:last-child {
  border-right: 0;
}

.zoom-control button:hover {
  color: var(--text);
  background: var(--panel-3);
}

.zoom-control svg {
  width: 14px;
  height: 14px;
}

.drop-hint {
  position: absolute;
  inset: 24px;
  display: grid;
  place-items: center;
  color: var(--accent);
  background: rgba(10, 10, 10, 0.72);
  border: 2px dashed var(--accent);
  border-radius: 14px;
  font-size: 15px;
  pointer-events: none;
}

/* ---------- lightbox / context menu ---------- */

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 4, 5, 0.92);
}

.lightbox img {
  /* Size is set after load to fit the window; hide the jump until then. */
  max-width: calc(100vw - 48px);
  max-height: calc(100vh - 48px);
  object-fit: contain;
  border-radius: 10px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.7);
  opacity: 0;
  transition: opacity 120ms ease;
}

.lightbox img.ready {
  opacity: 1;
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  color: var(--text-dim);
  background: var(--panel);
  border-radius: 9px;
}

.lightbox-close:hover {
  color: var(--text);
  background: var(--panel-3);
}

.lightbox-close svg {
  width: 17px;
  height: 17px;
}

.context-menu {
  position: fixed;
  z-index: 210;
  min-width: 168px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  box-shadow: var(--shadow);
}

.context-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 8px 9px;
  text-align: left;
  color: var(--text-dim);
  border-radius: 6px;
  font-size: 12px;
}

.context-menu button:hover {
  color: var(--text);
  background: var(--panel-3);
}

.context-menu button.danger {
  color: var(--danger);
}

.context-menu button.danger:hover {
  background: rgba(255, 107, 94, 0.12);
}

.context-menu button small {
  color: var(--text-faint);
  font-size: 10px;
}

.context-menu-sep {
  height: 1px;
  margin: 5px 4px;
  background: var(--line-soft);
}

.context-menu button svg {
  width: 14px;
  height: 14px;
  flex: none;
}

/* ---------- generation info dialog ---------- */

.info-dialog {
  position: fixed;
  inset: 0;
  z-index: 215;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 4, 5, 0.7);
}

.info-card {
  display: flex;
  flex-direction: column;
  width: min(460px, 100%);
  max-height: min(78vh, 640px);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.info-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 12px 12px 16px;
  border-bottom: 1px solid var(--line-soft);
}

.info-head h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 700;
}

.info-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  overflow-y: auto;
}

.info-row > span,
.info-grid span {
  display: block;
  margin-bottom: 5px;
  color: var(--text-faint);
  font-size: 10px;
}

.info-row p {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  user-select: text;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.info-grid > div {
  padding: 9px 10px;
  background: var(--panel-2);
  border-radius: 8px;
}

.info-grid strong {
  font-size: 12px;
  font-weight: 600;
}

.info-actions {
  display: flex;
  justify-content: flex-end;
  gap: 7px;
  padding: 12px 16px;
  border-top: 1px solid var(--line-soft);
}

/* ---------- composer ---------- */

.composer {
  position: absolute;
  left: 10.5%;
  right: 10.5%;
  bottom: 18px;
  z-index: 25;
  width: min(1840px, 79%);
  margin: 0 auto;
  padding: 16px 18px 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  transition: left 160ms ease, right 160ms ease, width 160ms ease;
}

.composer-input {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.mention-menu {
  position: absolute;
  left: 18px;
  bottom: calc(100% - 6px);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 232px;
  max-height: 268px;
  overflow-y: auto;
  padding: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.mention-menu button {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 6px 7px;
  text-align: left;
  border-radius: 7px;
}

.mention-menu button:hover,
.mention-menu button.active {
  background: var(--panel-3);
}

.mention-menu img {
  width: 34px;
  height: 34px;
  flex: none;
  object-fit: cover;
  background: #000;
  border-radius: 6px;
}

.mention-menu b {
  display: block;
  font-size: 12px;
  font-weight: 600;
}

.mention-menu small {
  display: block;
  overflow: hidden;
  color: var(--text-faint);
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer-prompt {
  flex: 1;
  max-height: 200px;
  min-height: 88px;
  overflow-y: auto;
  padding: 6px 2px;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: none;
  line-height: 1.55;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.composer-prompt:empty::before {
  content: attr(data-placeholder);
  color: var(--text-faint);
  pointer-events: none;
}

.composer-inline-token {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 23px;
  margin: 0 2px;
  padding: 1px 5px 1px 2px;
  color: var(--text);
  background: var(--panel-3);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  vertical-align: middle;
  user-select: none;
  white-space: nowrap;
}

.composer-inline-token img {
  width: 19px;
  height: 19px;
  flex: none;
  object-fit: cover;
  background: #000;
  border-radius: 50%;
}

.composer-inline-token button {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
  margin-left: 1px;
  color: var(--text-faint);
  border-radius: 50%;
  font-size: 13px;
  line-height: 1;
}

.composer-inline-token button:hover {
  color: var(--text);
  background: var(--panel-hover);
}

.composer-send {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex: none;
  color: var(--accent-ink);
  background: var(--accent);
  border-radius: 9px;
  transition: background 120ms ease;
}

.composer-send:hover {
  background: var(--accent-hover);
}

.composer-send:disabled {
  color: var(--text-faint);
  background: var(--panel-3);
  cursor: default;
}

.composer-send svg {
  width: 17px;
  height: 17px;
}

.composer-controls {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-top: 12px;
}

.composer-left,
.composer-right {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 30px;
  padding: 0 10px;
  color: var(--text-dim);
  background: var(--panel-2);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}

.chip svg {
  width: 13px;
  height: 13px;
}

/* Image / video mode switch. Video stays visible so the seat is ready for the
   API that is coming later, instead of appearing as a missing feature. */
.kind-switch {
  display: inline-flex;
  align-items: center;
  height: 30px;
  padding: 2px;
  background: var(--panel-2);
  border-radius: 999px;
}

.kind-switch button {
  height: 26px;
  padding: 0 11px;
  color: var(--text-faint);
  border-radius: 999px;
  font-size: 11px;
  white-space: nowrap;
}

.kind-switch button[aria-selected="true"] {
  color: var(--accent-ink);
  background: var(--accent);
  font-weight: 600;
}

/* Audio mode keeps model + voice, and hides the picture-only controls so the
   row never shows meaningless 比例 / 张数 choices. */
.composer.audio-mode .select-chip[data-chip="stage"],
.composer.audio-mode .select-chip[data-chip="size"],
.composer.audio-mode .select-chip[data-chip="count"] {
  display: none;
}

.composer:not(.audio-mode) .select-chip[data-chip="voice"] {
  display: none;
}

/* Video keeps only the model picker; audio adds the voice picker. */
.composer.video-mode:not(.audio-mode) .select-chip[data-chip="stage"],
.composer.video-mode:not(.audio-mode) .select-chip[data-chip="size"],
.composer.video-mode:not(.audio-mode) .select-chip[data-chip="count"] {
  display: none;
}

button.chip:hover {
  color: var(--text);
  background: var(--panel-3);
}

.chip.static {
  cursor: default;
}

.select-chip {
  position: relative;
  padding: 0;
}

.chip-label {
  color: var(--text-faint);
  font-size: 10px;
}

.chip-value {
  color: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.chip-trigger {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  color: var(--text-dim);
  border-radius: 999px;
  white-space: nowrap;
}

.chip-trigger:hover,
.select-chip.open .chip-trigger {
  color: var(--text);
  background: var(--panel-3);
}

.chip-trigger > svg {
  width: 13px;
  height: 13px;
  color: var(--text-faint);
  transition: transform 120ms ease;
}

.select-chip.open .chip-trigger > svg {
  transform: rotate(180deg);
}

/* The composer sits at the bottom, so the list opens upward. */
.chip-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 60;
  min-width: 184px;
  padding: 5px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.chip-menu button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 9px;
  color: var(--text-dim);
  border-radius: 7px;
  font-size: 12px;
  text-align: left;
}

.chip-menu button:hover {
  color: var(--text);
  background: var(--panel-3);
}

.chip-menu button[aria-selected="true"] {
  color: var(--text);
  background: rgba(var(--accent-rgb), 0.1);
}

.chip-menu button[aria-selected="true"]::after {
  content: '';
  width: 6px;
  height: 6px;
  margin-left: auto;
  background: var(--accent);
  border-radius: 50%;
}

.chip-menu-label {
  flex: 1;
  white-space: nowrap;
}

.chip-menu small {
  color: var(--text-faint);
  font-size: 10px;
}

/* Audio card keeps model + voice on one compact row. */
.audio-node-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.audio-node-fields select {
  min-width: 0;
}

/* Little proportional box next to a ratio, so 1:1 / 9:16 / 16:9 read at a
   glance instead of as bare numbers. */
.ratio-shape {
  display: inline-block;
  flex: none;
  width: 12px;
  height: 12px;
  border: 1.5px solid currentColor;
  border-radius: 2px;
  opacity: 0.85;
}

/* ---------- inspector ---------- */

.inspector {
  position: relative;
  z-index: 20;
  display: flex;
  flex-direction: column;
  width: 300px;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  background: var(--panel-2);
  border-left: 1px solid var(--line-soft);
  transition: width 160ms ease;
}

.inspector.collapsed {
  width: 0;
  border-left: 0;
}

.inspector-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding: 16px 14px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.inspector-head h2 {
  margin: 0 0 3px;
  font-size: 14px;
}

.inspector-head p {
  margin: 0;
  color: var(--text-faint);
  font-size: 11px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  color: var(--text-dim);
  border-radius: 6px;
}

.icon-btn:hover {
  color: var(--text);
  background: var(--panel-3);
}

.icon-btn svg {
  width: 14px;
  height: 14px;
}

.inspector-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
}

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

.field > label {
  color: var(--text-dim);
  font-size: 11px;
}

.field textarea,
.field select,
.field input {
  width: 100%;
  padding: 8px 9px;
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}

.field textarea {
  min-height: 128px;
  line-height: 1.55;
  resize: vertical;
}

.field textarea:focus,
.field select:focus,
.field input:focus {
  border-color: var(--accent);
}

.field-note {
  color: var(--text-faint);
  font-size: 11px;
  line-height: 1.55;
}

.empty-state {
  display: grid;
  place-items: center;
  gap: 8px;
  min-height: 220px;
  color: var(--text-faint);
  text-align: center;
  line-height: 1.6;
}

.empty-state svg {
  width: 28px;
  height: 28px;
  opacity: 0.5;
}

.job-list {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.job-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 9px;
  background: var(--panel);
  border-radius: 7px;
  font-size: 11px;
}

.job-row .status {
  width: 7px;
  height: 7px;
  flex: none;
  background: var(--text-faint);
  border-radius: 50%;
}

.job-row.running .status {
  background: var(--accent);
}

.job-row.completed .status {
  background: var(--accent);
}

.job-row.failed .status {
  background: var(--danger);
}

.job-row span {
  overflow: hidden;
  color: var(--text-dim);
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- toasts ---------- */

.toast-stack {
  position: fixed;
  right: 18px;
  top: 64px;
  z-index: 100;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(340px, calc(100vw - 36px));
}

.toast {
  padding: 10px 12px;
  color: var(--text);
  background: var(--panel);
  border-left: 3px solid var(--accent-dim);
  border-radius: 8px;
  box-shadow: var(--shadow);
  font-size: 12px;
  line-height: 1.5;
  animation: toast-in 160ms ease;
}

.toast.error {
  border-left-color: var(--danger);
}

.toast.success {
  border-left-color: var(--accent);
}

/* ---------- prompt editor ---------- */

.prompt-editor {
  position: fixed;
  inset: 0;
  z-index: 220;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 4, 5, 0.7);
}

.prompt-editor-head,
.prompt-editor-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 16px;
}

.prompt-editor-head {
  border-bottom: 1px solid var(--line-soft);
}

.prompt-editor-head strong {
  display: block;
  font-size: 17px;
}

.prompt-editor-head small {
  display: block;
  margin-top: 2px;
  color: var(--text-faint);
  font-size: 12px;
}

.prompt-editor-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: min(620px, calc(100vw - 32px));
  max-height: min(78vh, 720px);
  padding: 16px;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px 12px 0 0;
  box-shadow: var(--shadow);
}

.prompt-editor {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.prompt-editor-head {
  width: min(620px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
}

.prompt-editor-body {
  border-radius: 0;
}

.prompt-editor-actions {
  width: min(620px, calc(100vw - 32px));
  background: var(--panel);
  border: 1px solid var(--line);
  border-top: 1px solid var(--line-soft);
  border-radius: 0 0 12px 12px;
}

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

.prompt-editor-field > span {
  color: var(--text-dim);
  font-size: 13px;
}

.prompt-editor-field input,
.prompt-editor-field select,
.prompt-editor-field textarea {
  width: 100%;
  padding: 9px 10px;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 7px;
  outline: none;
}

.prompt-editor-field textarea {
  min-height: 210px;
  line-height: 1.6;
  resize: vertical;
}

.prompt-editor-field input:focus,
.prompt-editor-field select:focus,
.prompt-editor-field textarea:focus {
  border-color: var(--accent);
}

.prompt-editor-actions .danger {
  color: var(--danger);
}

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

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* ---------- responsive ---------- */

@media (max-width: 1200px) {
  .workspace {
    grid-template-columns: 70px auto minmax(0, 1fr);
  }

  .composer {
    left: 8%;
    right: 8%;
    width: min(1840px, 82%);
  }


  .brand-en {
    display: none;
  }
}

@media (max-width: 760px) {
  .assistant-action {
    gap: 0;
    width: 52px;
    padding: 0;
    justify-content: center;
  }

  .assistant-action-label {
    display: none;
  }

  .language-panel {
    top: 70px;
    right: 8px;
    width: calc(100vw - 16px);
    height: min(620px, calc(100vh - 86px));
    min-width: 0;
    min-height: min(380px, calc(100vh - 86px));
    max-width: calc(100vw - 16px);
    max-height: calc(100vh - 86px);
    resize: none;
  }

  .workspace {
    grid-template-columns: 70px minmax(0, 1fr);
  }

  .project-panel,
  .prompt-panel {
    top: 72px;
    left: 78px;
    width: min(420px, calc(100vw - 88px));
    height: min(560px, calc(100vh - 84px));
    max-width: calc(100vw - 86px);
    max-height: calc(100vh - 82px);
  }

  .stage {
    grid-template-columns: minmax(0, 1fr);
    grid-column: 2;
    order: 2;
  }

  .inspector {
    position: absolute;
    inset: 0 0 0 auto;
    z-index: 40;
    width: min(300px, 86vw);
    box-shadow: -14px 0 34px rgba(0, 0, 0, 0.45);
    transition: transform 160ms ease;
  }

  .inspector.collapsed {
    width: min(300px, 86vw);
    border-left: 1px solid var(--line-soft);
    transform: translateX(100%);
    pointer-events: none;
  }

  .topbar {
    grid-template-columns: auto 1fr auto;
    gap: 8px;
    padding: 0 10px;
  }

  .brand strong {
    font-size: 13px;
  }

  .workflow-name {
    width: 120px;
  }

  .config-status,
  #btn-new,
  #btn-import {
    display: none;
  }

  .composer {
    left: 10px;
    right: 10px;
    bottom: 10px;
    width: auto;
    padding: 10px 11px 9px;
  }

  .composer-prompt {
    min-height: 56px;
  }

  .composer-controls {
    flex-direction: column;
    align-items: stretch;
    gap: 7px;
  }

  .composer-left,
  .composer-right {
    justify-content: space-between;
  }

  .zoom-control {
    bottom: auto;
    top: 12px;
    right: 12px;
  }
}

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

/* ---------- auth gate ---------- */

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--canvas, #0a0a0a);
}

.auth-gate[hidden] {
  display: none;
}

.auth-card {
  width: min(420px, 100%);
  padding: 26px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.12));
  border-radius: 14px;
  background: var(--panel, #121212);
  color: var(--text, #f3f3f3);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.45);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.auth-brand .brand-mark {
  display: inline-flex;
  width: 38px;
  height: 38px;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(232, 163, 61, 0.14);
  color: #e8a33d;
}

.auth-brand strong {
  display: block;
  font-size: 17px;
}

.auth-brand span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  opacity: 0.62;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 13px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 12px;
  opacity: 0.9;
}

.auth-field input {
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.16));
  border-radius: 8px;
  background: var(--field, rgba(255, 255, 255, 0.05));
  color: inherit;
  font-size: 14px;
}

.auth-field input:focus {
  border-color: #e8a33d;
  outline: none;
}

.auth-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.auth-actions .btn {
  flex: 1;
  height: 40px;
}

.auth-hint {
  margin: 16px 0 0;
  font-size: 12px;
  line-height: 1.7;
  opacity: 0.6;
}

.auth-message {
  margin-bottom: 14px;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.6;
  background: rgba(232, 163, 61, 0.12);
  color: #e8a33d;
}

.auth-message.error {
  background: rgba(224, 96, 96, 0.14);
  color: #e88a8a;
}

.auth-message.success {
  background: rgba(79, 194, 176, 0.14);
  color: #4fc2b0;
}

/* ---------- account + admin ---------- */

.account-button {
  display: inline-flex;
  height: 32px;
  align-items: center;
  gap: 7px;
  padding: 0 11px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.14));
  border-radius: 8px;
  background: transparent;
  color: inherit;
  font-size: 12px;
  cursor: pointer;
}

.account-button:hover {
  border-color: #e8a33d;
}

.account-timer {
  font-variant-numeric: tabular-nums;
  color: #e8a33d;
}

.account-badge {
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 9px;
  background: #e06060;
  color: #fff;
  font-size: 11px;
  line-height: 17px;
  text-align: center;
}

.admin-panel {
  position: fixed;
  top: 62px;
  right: 18px;
  z-index: 1500;
  width: min(420px, calc(100vw - 36px));
  max-height: min(560px, calc(100vh - 90px));
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.14));
  border-radius: 12px;
  background: var(--panel, #131313);
  color: var(--text, #f3f3f3);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.5);
}

.admin-panel[hidden] {
  display: none;
}

.admin-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line, rgba(255, 255, 255, 0.1));
}

.admin-head strong {
  display: block;
  font-size: 14px;
}

.admin-head span {
  display: block;
  margin-top: 3px;
  font-size: 12px;
  opacity: 0.6;
}

.admin-head-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.admin-body {
  min-height: 0;
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px 16px;
}

.admin-item {
  padding: 12px;
  border: 1px solid var(--line, rgba(255, 255, 255, 0.1));
  border-radius: 10px;
  margin-bottom: 10px;
}

.admin-item-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
}

.admin-item-title b {
  font-size: 14px;
}

.admin-item-meta {
  margin-top: 5px;
  font-size: 12px;
  line-height: 1.7;
  opacity: 0.68;
  word-break: break-word;
}

.admin-item-actions {
  display: flex;
  gap: 8px;
  margin-top: 11px;
}

.admin-item-actions .btn {
  height: 30px;
  padding: 0 12px;
  font-size: 12px;
}

.admin-empty {
  padding: 26px 10px;
  font-size: 13px;
  text-align: center;
  opacity: 0.55;
}

@media (max-width: 640px) {
  .admin-panel {
    top: auto;
    right: 10px;
    bottom: 10px;
    left: 10px;
    width: auto;
    max-height: 70vh;
  }
}

