:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --panel-soft: #f8fafc;
  --text: #172033;
  --muted: #69748a;
  --line: #d8dee9;
  --line-strong: #aab4c5;
  --accent: #2563eb;
  --accent-strong: #1d4ed8;
  --accent-soft: #dbeafe;
  --danger: #dc2626;
  --shadow: 0 18px 42px rgba(24, 35, 52, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  color: var(--text);
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.shell-page {
  display: grid;
  grid-template-columns: 232px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background: #fff;
}

.app-sidebar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 38px;
  padding: 34px 26px;
  background: #fff;
  border-right: 1px solid #eef1f6;
}

.app-mark {
  display: block;
  width: 100%;
  color: #111827;
  font-size: 17px;
  font-weight: 900;
  line-height: 1.2;
  text-align: center;
  white-space: normal;
  border: 0;
  border-radius: 0;
}

.api-settings-page .app-sidebar > .app-mark {
  display: flex !important;
  width: 100%;
  height: auto !important;
  align-items: center;
  justify-content: center;
  color: #111827 !important;
  background: transparent !important;
  border: 0 !important;
  border-radius: 0 !important;
  font-size: 18px;
  font-weight: 900;
  text-indent: 0 !important;
}

.api-settings-page .app-sidebar > .app-mark::before,
.api-settings-page .app-sidebar > .app-mark::after {
  display: none !important;
  content: none !important;
}

.api-settings-page .app-sidebar > .app-mark span {
  display: block;
}

.app-nav {
  display: grid;
  width: 100%;
  gap: 10px;
}

.app-nav-item {
  display: flex;
  align-items: center;
  gap: 13px;
  min-height: 44px;
  padding: 0 14px;
  color: #8a8f98;
  border-radius: 16px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.app-nav-item span {
  min-width: 0;
  line-height: 1.25;
}

.app-nav-item svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.app-nav-item:hover {
  color: #111827;
  background: #f5f7fa;
}

.app-nav-item.active {
  color: #fff;
  background: #000;
}

.workspace {
  position: relative;
  overflow: auto;
  background-color: #fbfdff;
  background-image: radial-gradient(circle, #d8e7f6 1.15px, transparent 1.2px);
  background-position: 0 0;
  background-size: 24px 24px;
  border-top-left-radius: 24px;
}

.canvas-picker-panel {
  position: absolute;
  left: 50%;
  top: 58%;
  width: min(612px, calc(100% - 64px));
  padding: 26px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5ebf3;
  border-radius: 24px;
  box-shadow: 0 22px 54px rgba(31, 41, 55, 0.12);
  transform: translate(-50%, -50%);
}

.picker-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 20px;
}

.picker-title-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.picker-title-row h1,
.settings-header h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.1;
  letter-spacing: 0;
}

.count-badge {
  display: inline-flex;
  align-items: center;
  height: 22px;
  padding: 0 10px;
  color: #5b6b82;
  background: #eef4fb;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.picker-header p,
.settings-header p {
  margin: 8px 0 0;
  color: #8a96a8;
  font-size: 13px;
  font-weight: 700;
}

.picker-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.primary-button,
.dark-button,
.tool-button,
.icon-button,
.canvas-card,
.context-menu button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  border-radius: 8px;
  transition:
    background 160ms ease,
    border-color 160ms ease,
    transform 160ms ease,
    box-shadow 160ms ease;
}

.primary-button {
  flex: 0 0 auto;
  min-height: 46px;
  padding: 0 18px;
  color: #fff;
  background: var(--accent);
  box-shadow: 0 14px 28px rgba(37, 99, 235, 0.24);
}

.primary-button:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
}

.dark-button {
  min-height: 36px;
  padding: 0 15px;
  color: #fff;
  background: #111827;
  border-color: #111827;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}

.dark-button:hover {
  background: #000;
}

.smart-button {
  min-height: 36px;
  padding: 0 15px;
  color: #111827;
  background:
    linear-gradient(#fff, #fff) padding-box,
    linear-gradient(135deg, #10b981, #2563eb, #ef4444) border-box;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}

.icon-button {
  width: 38px;
  height: 38px;
  color: var(--text);
  background: #fff;
  border-color: var(--line);
  text-decoration: none;
}

.icon-button:hover {
  border-color: var(--line-strong);
  background: var(--panel-soft);
}

.primary-button svg,
.tool-button svg,
.icon-button svg,
.context-menu svg,
.empty-state svg,
.drop-overlay svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.2;
}

.canvas-list-shell {
  min-height: 138px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e5ebf3;
  border-radius: 16px;
}

.create-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px 42px;
  gap: 8px;
  margin: 0 0 14px;
}

.create-inline.hidden {
  display: none;
}

.create-inline input {
  height: 42px;
  padding: 0 14px;
  color: #111827;
  background: #fff;
  border: 1px solid #cbd8e8;
  border-radius: 12px;
  outline: none;
  font-weight: 800;
}

.create-inline input:focus {
  border-color: #9bb7f5;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.dark-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  color: #fff;
  background: #111827;
  border: 1px solid #111827;
  border-radius: 12px;
}

.canvas-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(126px, 1fr));
  gap: 10px;
}

.canvas-card {
  position: relative;
  min-height: 126px;
  align-items: stretch;
  justify-content: space-between;
  flex-direction: column;
  padding: 14px;
  color: inherit;
  background: #fff;
  border-color: var(--line);
  text-align: left;
  text-decoration: none;
}

.canvas-card.selected {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.card-select {
  position: absolute;
  right: 10px;
  top: 10px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #94a3b8;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
}

.canvas-card.selected .card-select {
  color: #fff;
  background: #2563eb;
  border-color: #2563eb;
}

.card-select svg {
  width: 14px;
  height: 14px;
}

.canvas-card:hover {
  border-color: #9bb7f5;
  box-shadow: 0 12px 26px rgba(37, 99, 235, 0.1);
  transform: translateY(-1px);
}

.canvas-card::before {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #52657d;
  background: #f5f8fc;
  border: 1px solid #e2e9f2;
  border-radius: 10px;
  content: "▦";
  font-size: 16px;
}

.canvas-card.smart-card::before {
  content: "✦";
  color: #2563eb;
}

.canvas-card em {
  justify-self: start;
  padding: 3px 8px;
  color: #7c3aed;
  background: #ede9fe;
  border-radius: 999px;
  font-size: 11px;
  font-style: normal;
  font-weight: 900;
}

.canvas-card strong {
  display: block;
  overflow: hidden;
  font-size: 14px;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.canvas-card span {
  color: var(--muted);
  font-size: 12px;
}

.empty-state {
  display: none;
  min-height: 150px;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: 8px;
  background: rgba(248, 250, 252, 0.82);
}

.empty-state.visible {
  display: grid;
}

.empty-state p {
  margin: 6px 0 0;
}

.settings-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(560px, calc(100% - 64px));
  padding: 28px;
  background: rgba(255, 255, 255, 0.95);
  border: 1px solid #e5ebf3;
  border-radius: 24px;
  box-shadow: 0 22px 54px rgba(31, 41, 55, 0.12);
  transform: translate(-50%, -50%);
}

.settings-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 150px;
  margin-top: 22px;
  color: #8793a6;
  background: #f8fafc;
  border: 1px dashed #ccd6e4;
  border-radius: 16px;
  font-weight: 800;
}

.settings-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.settings-form label {
  display: grid;
  gap: 7px;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.settings-form input,
.settings-form select {
  width: 100%;
  height: 42px;
  padding: 0 10px;
  color: #111827;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 10px;
  outline: none;
  font-size: 13px;
  font-weight: 700;
}

.settings-form input:focus,
.settings-form select:focus {
  border-color: #9bb7f5;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.settings-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 12px;
}

.settings-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 4px;
}

.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px;
  color: #52657d;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}

.settings-status {
  min-height: 18px;
  margin: 2px 0 0;
  color: #6b778a;
  font-size: 12px;
  font-weight: 700;
}

.settings-status[data-tone="error"] {
  color: #dc2626;
}

.settings-status[data-tone="ok"] {
  color: #15803d;
}

.provider-settings-panel {
  width: min(1180px, calc(100vw - 270px));
  max-height: calc(100vh - 56px);
  overflow: hidden;
}

.api-settings-page .provider-settings-panel {
  position: static;
  display: grid;
  width: min(1220px, calc(100% - 64px));
  min-height: calc(100vh - 56px);
  max-height: none;
  gap: 16px;
  margin: 28px auto;
  overflow: visible;
  padding: 24px;
  border-radius: 8px;
  transform: none;
}

.provider-settings-layout {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
}

.provider-sidebar,
.provider-editor {
  min-height: 0;
}

.provider-sidebar {
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.provider-sidebar-head,
.provider-editor-head,
.model-editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.provider-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  max-height: calc(100vh - 240px);
  overflow: auto;
}

.provider-list-item {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  background: #fff;
  padding: 10px;
  text-align: left;
  cursor: pointer;
}

.provider-list-item.active {
  border-color: #0f172a;
  box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.08);
}

.provider-list-item strong,
.provider-list-item span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.provider-list-item span {
  color: #6b778a;
  font-size: 12px;
}

.provider-pill {
  border-radius: 999px;
  background: #eef2f7;
  color: #6b778a;
  font-size: 11px;
  font-weight: 800;
  padding: 4px 7px;
}

.provider-editor {
  overflow: auto;
  padding-right: 4px;
}

.api-settings-page .provider-editor {
  overflow: visible;
  padding-right: 0;
}

.provider-editor-head h2 {
  margin: 0;
  font-size: 22px;
}

.provider-editor-head p {
  margin: 6px 0 0;
  color: #6b778a;
  font-size: 13px;
}

.provider-editor-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.provider-basic-grid {
  grid-template-columns: 1.2fr 0.9fr 0.8fr;
}

.provider-key-grid {
  grid-template-columns: minmax(0, 1fr) 170px 140px;
  align-items: end;
}

.provider-default-grid {
  grid-template-columns: 1fr 1fr;
}

.checkbox-field {
  display: flex !important;
  flex-direction: row;
  align-items: center;
  gap: 9px;
  min-height: 42px;
}

.checkbox-field input {
  width: 16px !important;
  height: 16px;
  padding: 0 !important;
}

.danger-button {
  color: #dc2626;
}

.compact-button {
  min-height: 34px;
  padding: 8px 10px;
}

.model-editor-section {
  display: grid;
  gap: 10px;
  border: 1px solid #dbe3ef;
  border-radius: 8px;
  padding: 12px;
  background: #fff;
}

.model-list-editor {
  display: grid;
  gap: 8px;
}

.model-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 8px;
  align-items: center;
}

.model-row input {
  width: 100%;
}

.model-row .icon-button {
  width: 34px;
  height: 34px;
}

@media (max-width: 980px) {
  .provider-settings-panel {
    width: min(720px, calc(100vw - 28px));
    max-height: none;
  }

  .api-settings-page .provider-settings-panel {
    width: calc(100% - 28px);
    min-height: auto;
    margin: 14px auto;
    padding: 18px;
  }

  .provider-settings-layout {
    grid-template-columns: 1fr;
  }

  .provider-basic-grid,
  .provider-key-grid,
  .provider-default-grid {
    grid-template-columns: 1fr;
  }
}

.canvas-page {
  overflow: hidden;
}

.canvas-app {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr);
  width: 100vw;
  height: 100vh;
}

.canvas-app-full {
  display: block;
}

.canvas-app-full .board {
  width: 100vw;
  height: 100vh;
}

.sidebar {
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 18px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.96);
  border-right: 1px solid var(--line);
  box-shadow: 8px 0 28px rgba(24, 35, 52, 0.06);
}

.brand-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.title-input {
  min-width: 0;
  height: 38px;
  padding: 0 10px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

.title-input:focus {
  border-color: #8bb0f6;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.14);
}

.tool-group {
  display: grid;
  gap: 10px;
}

.tool-button {
  width: 100%;
  min-height: 40px;
  justify-content: flex-start;
  padding: 0 12px;
  color: var(--text);
  background: var(--panel-soft);
  border-color: var(--line);
}

.tool-button:hover {
  background: #eef4ff;
  border-color: #aac1f5;
}

.status-panel,
.selection-panel {
  padding: 12px;
  background: var(--panel-soft);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.status-panel {
  display: grid;
  gap: 10px;
}

.status-panel div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.status-panel strong {
  color: var(--text);
  font-size: 13px;
}

.selection-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13px;
}

.selection-panel strong {
  color: var(--text);
}

.board {
  position: relative;
  overflow: hidden;
  outline: none;
  background-color: #fbfdff;
  background-image: radial-gradient(circle, #d8e7f6 1.15px, transparent 1.2px);
  background-size: 24px 24px;
}

.smart-rail,
.smart-top-actions {
  display: none;
}

.smart-mode .canvas-toolbar {
  display: none;
}

.smart-mode .board {
  background-color: #0c1220;
  background-image: radial-gradient(circle, rgba(91, 112, 145, 0.42) 1.1px, transparent 1.2px);
  background-size: 26px 26px;
}

.smart-mode .canvas-topbar {
  left: 22px;
  right: auto;
}

.smart-mode .smart-rail {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 28px;
  width: 58px;
  padding: 28px 0;
  background: rgba(15, 23, 42, 0.72);
  border-right: 1px solid rgba(148, 163, 184, 0.14);
  backdrop-filter: blur(16px);
}

.smart-mode .canvas-title-chip {
  color: #e5edf8;
  background: rgba(15, 23, 42, 0.84);
  border-color: rgba(148, 163, 184, 0.24);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.22);
}

.smart-mode .canvas-title-chip .icon-button {
  color: #e5edf8;
  background: rgba(255, 255, 255, 0.05);
}

.smart-mode .ghost-title {
  color: #f8fafc;
}

.smart-mode .canvas-title-chip span {
  color: #93a4bb;
}

.smart-dot {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1.5px solid #111;
  border-radius: 50%;
}

.smart-dot span {
  width: 4px;
  height: 4px;
  background: #111;
  border-radius: 50%;
}

.rail-button {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  color: #92a3ba;
  background: transparent;
  border: 0;
  border-radius: 12px;
}

.rail-button.active,
.rail-button:hover {
  color: #0f172a;
  background: #eef2f7;
}

.rail-button svg {
  width: 17px;
  height: 17px;
}

.smart-mode .smart-top-actions {
  position: absolute;
  right: 22px;
  top: 22px;
  z-index: 70;
  display: flex;
  gap: 8px;
}

.smart-mode .canvas-status-strip {
  left: 26px;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.82);
  border-color: rgba(148, 163, 184, 0.22);
}

.canvas-topbar {
  position: absolute;
  left: 24px;
  right: 24px;
  top: 24px;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  pointer-events: none;
}

.canvas-title-chip,
.canvas-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  pointer-events: auto;
}

.canvas-title-chip {
  min-width: 118px;
  padding: 7px;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #e5ebf3;
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.08);
}

.canvas-title-chip .icon-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
}

.ghost-title {
  width: 120px;
  height: 22px;
  padding: 0;
  font-size: 13px;
  font-weight: 800;
  background: transparent;
  border: 0;
  border-radius: 0;
}

.canvas-title-chip span {
  display: block;
  color: #8a96a8;
  font-size: 11px;
  font-weight: 700;
}

.canvas-title-chip b,
.canvas-title-chip em {
  font-style: normal;
}

.canvas-toolbar {
  flex-wrap: wrap;
  justify-content: flex-end;
}

.pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 36px;
  padding: 0 13px;
  color: #52657d;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #dfe8f3;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(31, 41, 55, 0.06);
  font-size: 13px;
  font-weight: 800;
  text-decoration: none;
}

.pill-button:hover {
  color: #111827;
  border-color: #b8c7dc;
}

.smart-mode .pill-button {
  color: #e5edf8;
  background: rgba(15, 23, 42, 0.82);
  border-color: rgba(148, 163, 184, 0.22);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.2);
}

.smart-mode .pill-button:hover {
  color: #fff;
  border-color: rgba(226, 232, 240, 0.48);
}

.pill-button svg {
  width: 16px;
  height: 16px;
}

.world {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
  transform-origin: 0 0;
}

.links,
.temp-link-layer,
.nodes-layer {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 1px;
}

.temp-link-layer {
  overflow: visible;
  pointer-events: none;
}

.links {
  overflow: visible;
  pointer-events: auto;
}

.connection-path {
  fill: none;
  stroke: #64748b;
  stroke-width: 2;
  pointer-events: none;
}

.connection-hit {
  fill: none;
  stroke: transparent;
  stroke-width: 14;
  pointer-events: stroke;
  cursor: pointer;
}

.connection-group.selected .connection-path {
  stroke: var(--accent);
  stroke-width: 3;
}

.temp-path {
  fill: none;
  stroke: var(--accent);
  stroke-dasharray: 8 6;
  stroke-width: 2.5;
}

.node {
  position: absolute;
  width: 260px;
  min-height: 160px;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 22px;
  box-shadow: 0 10px 28px rgba(24, 35, 52, 0.12);
  user-select: none;
}

.node.selected {
  border-color: var(--accent);
  box-shadow:
    0 0 0 3px rgba(37, 99, 235, 0.16),
    0 12px 32px rgba(24, 35, 52, 0.14);
}

.smart-mode .smart-node {
  overflow: visible;
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.42);
  border-radius: 16px;
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.34);
}

.smart-mode .smart-node.selected {
  border-color: rgba(226, 232, 240, 0.88);
  box-shadow:
    0 0 0 2px rgba(226, 232, 240, 0.32),
    0 18px 60px rgba(0, 0, 0, 0.42);
}

.smart-mode .node-smart-image {
  background: transparent;
}

.smart-mode .node-smart-image .node-header {
  position: absolute;
  inset: 0 0 auto 0;
  z-index: 3;
  height: 34px;
  padding: 8px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.66), transparent);
  border: 0;
  border-radius: 16px 16px 0 0;
}

.smart-mode .node-smart-image .node-title {
  width: 0;
  opacity: 0;
}

.smart-mode .node-smart-image .node-actions {
  width: 100%;
  justify-content: space-between;
}

.smart-mode .node-smart-image .node-body {
  height: 100%;
  min-height: 0;
  padding: 0;
}

.smart-mode .node-smart-prompt,
.smart-mode .node-smart-loop {
  color: #e5edf8;
  background: rgba(15, 23, 42, 0.9);
  border-color: rgba(148, 163, 184, 0.24);
}

.smart-mode .node-smart-prompt .node-header,
.smart-mode .node-smart-loop .node-header {
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.86);
  border-color: rgba(148, 163, 184, 0.18);
}

.node-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: 34px;
  padding: 0 14px 0 18px;
  color: #64748b;
  background: #fff;
  border-bottom: 1px solid var(--line);
  border-radius: 22px 22px 0 0;
  cursor: move;
}

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

.node-actions {
  display: inline-flex;
  gap: 4px;
}

.node-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
}

.node-icon-button:hover {
  color: var(--danger);
  background: #fee2e2;
}

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

.node-body {
  position: relative;
  height: calc(100% - 34px);
  min-height: 124px;
  padding: 18px;
}

.node-image .node-body {
  padding: 16px;
}

.node-output .node-body {
  padding: 14px;
}

.node-prompt .node-body,
.node-text .node-body {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
}

.text-editor {
  width: 100%;
  height: 100%;
  min-height: 104px;
  resize: none;
  color: var(--text);
  background: #fff;
  border: 1px solid transparent;
  border-radius: 6px;
  outline: none;
  line-height: 1.55;
}

.text-editor:focus {
  border-color: var(--line);
}

.image-drop-zone {
  display: grid;
  width: 100%;
  height: 100%;
  min-height: 104px;
  place-items: center;
  overflow: hidden;
  color: var(--muted);
  background: #f8fafc;
  border: 1px dashed #cbd8e8;
  border-radius: 18px;
}

.image-drop-zone img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.output-node-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.output-summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.output-summary strong,
.output-summary span {
  display: block;
}

.output-summary strong {
  color: #172033;
  font-size: 13px;
  font-weight: 900;
}

.output-summary span {
  color: #7c8798;
  font-size: 12px;
  font-weight: 800;
}

.output-state {
  display: inline-flex !important;
  max-width: 220px;
  align-items: center;
  gap: 7px;
  overflow: hidden;
  padding: 5px 8px;
  border-radius: 999px;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.output-state .spinner {
  width: 15px;
  height: 15px;
  border-width: 2px;
}

.output-state.is-pending {
  color: #1d4ed8;
  background: #dbeafe;
}

.output-state.is-error {
  color: #dc2626;
  background: #fee2e2;
}

.output-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  grid-auto-rows: 112px;
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
}

.output-empty {
  grid-column: 1 / -1;
  display: grid;
  min-height: 180px;
  place-items: center;
  gap: 8px;
  color: #94a3b8;
  background: #f8fafc;
  border: 1px dashed #cbd8e8;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.output-empty svg {
  width: 24px;
  height: 24px;
}

.output-image-card {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
}

.output-image-card:hover {
  border-color: #9bb7f5;
}

.output-thumb {
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  background: #f8fafc;
  border: 0;
}

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

.output-remove {
  position: absolute;
  right: 5px;
  top: 5px;
  display: grid;
  width: 24px;
  height: 24px;
  place-items: center;
  color: #fff;
  background: rgba(17, 24, 39, 0.76);
  border: 0;
  border-radius: 8px;
  opacity: 0;
}

.output-image-card:hover .output-remove {
  opacity: 1;
}

.output-remove:hover {
  background: #dc2626;
}

.output-remove svg {
  width: 14px;
  height: 14px;
}

.group-node-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 10px;
  height: 100%;
  min-height: 0;
}

.group-summary {
  display: flex;
  min-height: 42px;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.group-summary strong {
  color: #172033;
  font-size: 13px;
  font-weight: 900;
}

.group-summary span {
  color: #7c8798;
  font-size: 12px;
  font-weight: 800;
}

.group-image-grid {
  display: grid;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.group-image-grid-1 {
  grid-template-columns: 1fr;
}

.group-image-grid-2,
.group-image-grid-3,
.group-image-grid-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.group-image-grid-5,
.group-image-grid-6 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.group-thumb {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  background: #f8fafc;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
}

.group-thumb:hover {
  border-color: #9bb7f5;
}

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

.group-thumb span {
  position: absolute;
  left: 6px;
  top: 6px;
  min-width: 18px;
  height: 18px;
  color: #fff;
  background: rgba(17, 24, 39, 0.72);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  line-height: 18px;
}

.group-empty {
  grid-column: 1 / -1;
  display: grid;
  min-height: 160px;
  place-items: center;
  gap: 8px;
  color: #94a3b8;
  background: #f8fafc;
  border: 1px dashed #cbd8e8;
  border-radius: 8px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
}

.group-empty svg {
  width: 24px;
  height: 24px;
}

.smart-image-zone {
  position: relative;
}

.smart-mode .smart-image-zone {
  min-height: 100%;
  background: rgba(15, 23, 42, 0.88);
  border: 0;
  border-radius: 16px;
}

.smart-mode .smart-image-zone img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #0f172a;
  border-radius: 14px;
}

.smart-image-zone.drag-over {
  background: #eef6ff;
  border-color: #2563eb;
  box-shadow: inset 0 0 0 2px rgba(37, 99, 235, 0.16);
}

.smart-mode .smart-image-zone.drag-over {
  background: rgba(37, 99, 235, 0.22);
  outline: 2px dashed rgba(147, 197, 253, 0.8);
  outline-offset: -10px;
}

.smart-image-count {
  position: absolute;
  right: 10px;
  bottom: 10px;
  min-width: 26px;
  height: 26px;
  padding: 0 8px;
  color: #fff;
  background: rgba(17, 24, 39, 0.86);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  line-height: 26px;
  text-align: center;
}

.smart-image-node-actions {
  display: inline-flex;
  gap: 4px;
}

.smart-mode .smart-image-node-actions {
  align-items: flex-start;
}

.smart-image-size-label {
  display: inline-flex;
  min-height: 24px;
  align-items: center;
  padding: 0 8px;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.68);
  border: 1px solid rgba(226, 232, 240, 0.16);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.smart-mode .smart-delete-button {
  color: #e5edf8;
  background: rgba(15, 23, 42, 0.68);
  border: 1px solid rgba(226, 232, 240, 0.16);
  border-radius: 999px;
}

.smart-image-grid {
  display: grid;
  width: 100%;
  height: 100%;
  gap: 6px;
  padding: 6px;
}

.smart-image-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.smart-image-grid-3,
.smart-image-grid-4 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.smart-image-grid-5,
.smart-image-grid-6 {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(0, 1fr));
}

.smart-image-thumb {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 10px;
}

.smart-image-thumb:hover {
  border-color: #9bb7f5;
}

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

.smart-image-thumb span {
  position: absolute;
  left: 6px;
  top: 6px;
  min-width: 18px;
  height: 18px;
  color: #fff;
  background: rgba(17, 24, 39, 0.72);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 900;
  line-height: 18px;
}

.smart-thumb-remove {
  position: absolute;
  right: 5px;
  top: 5px;
  display: grid;
  width: 22px;
  height: 22px;
  place-items: center;
  color: #fff;
  background: rgba(17, 24, 39, 0.74);
  border: 0;
  border-radius: 50%;
  opacity: 0;
}

.smart-image-thumb:hover .smart-thumb-remove {
  opacity: 1;
}

.smart-thumb-remove:hover {
  background: #dc2626;
}

.smart-thumb-remove svg {
  width: 14px;
  height: 14px;
}

.image-placeholder {
  display: grid;
  place-items: center;
  gap: 8px;
  padding: 20px;
  text-align: center;
}

.image-placeholder svg {
  width: 26px;
  height: 26px;
}

.image-placeholder strong {
  font-size: 14px;
}

.image-placeholder small {
  max-width: 100%;
  overflow: hidden;
  color: #7c8798;
  font-size: 12px;
  line-height: 1.45;
  text-overflow: ellipsis;
}

.pending-placeholder {
  color: #52657d;
}

.failed-placeholder {
  color: #dc2626;
}

.spinner {
  width: 26px;
  height: 26px;
  border: 3px solid #dbeafe;
  border-top-color: #2563eb;
  border-radius: 50%;
  animation: spin 900ms linear infinite;
}

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

.port {
  position: absolute;
  top: 50%;
  z-index: 4;
  width: 18px;
  height: 18px;
  background: #111827;
  border: 2px solid #fff;
  border-radius: 50%;
  box-shadow: 0 0 0 1px #94a3b8;
  transform: translateY(-50%);
  cursor: crosshair;
}

.port.in {
  left: -9px;
}

.port.out {
  right: -9px;
}

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

.resize-handle {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 16px;
  height: 16px;
  border-radius: 8px 0 8px 0;
  cursor: nwse-resize;
}

.node-textarea {
  width: 100%;
  min-height: 120px;
  resize: none;
  color: #334155;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  outline: none;
  padding: 16px;
  line-height: 1.65;
}

.node-textarea:focus {
  border-color: #9bb7f5;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.prompt-node-input {
  height: 100%;
}

.node-counter {
  margin-top: 10px;
  color: #94a3b8;
  text-align: right;
  font-size: 13px;
  font-weight: 900;
}

.node-section-label {
  display: block;
  margin: 0 0 12px;
  color: #94a3b8;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1px;
}

.loop-card {
  display: grid;
  gap: 18px;
  padding: 14px;
  border: 1px solid #cbd8e8;
  border-radius: 20px;
}

.loop-row,
.loop-sources,
.llm-controls,
.api-controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.api-provider-row {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 8px;
  margin-bottom: 8px;
}

.api-generator-controls {
  display: grid;
  grid-template-columns: 86px 126px minmax(132px, 1fr) 96px 64px;
  gap: 8px;
}

.loop-row {
  padding-bottom: 16px;
  border-bottom: 1px solid #dfe8f3;
}

.loop-count {
  width: 66px;
  height: 44px;
  border: 1px solid #cbd8e8;
  border-radius: 14px;
  text-align: center;
  font-weight: 900;
}

.seg,
.loop-sources button {
  min-height: 36px;
  padding: 0 22px;
  color: #52657d;
  background: #fff;
  border: 1px solid #cbd8e8;
  border-radius: 999px;
  font-weight: 900;
}

.node-help {
  margin: 0;
  color: #7c8798;
  font-size: 12px;
  font-weight: 700;
}

.seg.active {
  color: #fff;
  background: #111827;
}

.llm-controls select,
.api-controls select,
.api-controls input,
.llm-controls input {
  height: 42px;
  min-width: 120px;
  padding: 0 14px;
  border: 1px solid #cbd8e8;
  border-radius: 999px;
  background: #fff;
  font-weight: 800;
}

.api-provider-row select,
.api-generator-controls select,
.api-generator-controls input {
  width: 100%;
  min-width: 0;
}

.api-custom-size {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 5px;
}

.api-custom-size b {
  color: #94a3b8;
  font-size: 12px;
}

.api-count {
  width: 70px;
  min-width: 70px;
  text-align: center;
}

.llm-input {
  height: 150px;
  margin-bottom: 18px;
}

.llm-output,
.api-image-drop {
  display: grid;
  min-height: 120px;
  place-items: center start;
  margin-bottom: 14px;
  padding: 16px;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 18px;
}

.api-image-drop {
  min-height: 112px;
  color: #c0cad8;
  font-weight: 800;
}

.api-image-drop.has-inputs {
  display: flex;
  align-items: center;
  gap: 12px;
  color: #52657d;
}

.api-ref-thumbs {
  display: flex;
  gap: 6px;
}

.api-ref-thumbs img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.api-prompt {
  min-height: 92px;
  margin: 12px 0;
}

.node-run-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  height: 48px;
  color: #fff;
  background: #111827;
  border: 0;
  border-radius: 16px;
  font-weight: 900;
}

.resize-handle::after {
  position: absolute;
  right: 4px;
  bottom: 4px;
  width: 7px;
  height: 7px;
  border-right: 2px solid #94a3b8;
  border-bottom: 2px solid #94a3b8;
  content: "";
}

.selection-box {
  position: absolute;
  display: none;
  z-index: 30;
  border: 1px solid var(--accent);
  background: rgba(37, 99, 235, 0.1);
  pointer-events: none;
}

.drop-overlay {
  position: absolute;
  inset: 22px;
  z-index: 50;
  display: none;
  place-items: center;
  color: var(--accent);
  font-weight: 800;
  background: rgba(219, 234, 254, 0.7);
  border: 2px dashed #7ba8f7;
  border-radius: 8px;
  pointer-events: none;
}

.smart-mode .drop-overlay {
  color: #bfdbfe;
  background: rgba(15, 23, 42, 0.62);
  border-color: rgba(147, 197, 253, 0.72);
}

.smart-error-panel {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 300;
  display: none;
  max-width: min(560px, calc(100vw - 36px));
  padding: 10px 12px;
  color: #fee2e2;
  background: rgba(127, 29, 29, 0.94);
  border: 1px solid rgba(254, 202, 202, 0.48);
  border-radius: 10px;
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.28);
  font-size: 13px;
  font-weight: 800;
}

.smart-error-panel.visible {
  display: block;
}

/* Smart canvas parity layer, modeled after hero8152/Infinite-Canvas smart canvas. */
.smart-mode {
  --page: #0f141d;
  --grid: rgba(148, 163, 184, 0.18);
  --smart-panel: rgba(23, 29, 41, 0.92);
  --smart-card: #171d29;
  --smart-text: #e5e9f0;
  --smart-muted: #8f9aab;
  --smart-faint: #657286;
  --smart-line: #2a3444;
  --smart-soft: #111722;
  --smart-shadow: rgba(0, 0, 0, 0.28);
  --smart-strong: #d8dee9;
  --smart-strong-text: #10141d;
}

.smart-mode .board {
  background-color: var(--page);
  background-image: radial-gradient(var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
  cursor: grab;
}

.smart-mode .smart-rail,
.smart-mode .canvas-topbar,
.smart-mode .smart-top-actions,
.smart-mode .canvas-toolbar {
  display: none !important;
}

.smart-back {
  position: absolute;
  left: 22px;
  top: 22px;
  z-index: 80;
  display: flex;
  height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: var(--smart-text);
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 999px;
  box-shadow: 0 16px 40px var(--smart-shadow);
  backdrop-filter: blur(16px);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.smart-back:hover {
  transform: translateY(-1px);
}

.smart-back svg {
  width: 16px;
  height: 16px;
}

.smart-title {
  position: absolute;
  left: 22px;
  top: 72px;
  z-index: 70;
  display: grid;
  max-width: min(420px, calc(100vw - 44px));
  gap: 2px;
  color: var(--smart-muted);
  pointer-events: auto;
}

.smart-title .ghost-title {
  width: min(240px, calc(100vw - 56px));
  height: 18px;
  color: var(--smart-text);
  font-size: 13px;
  font-weight: 900;
}

.smart-title span {
  color: var(--smart-muted);
  font-size: 12px;
  font-weight: 800;
}

.smart-title b,
.smart-title em {
  font-style: normal;
}

.smart-log-toggle,
.asset-toggle {
  position: absolute;
  top: 22px;
  z-index: 90;
  display: flex;
  height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  color: var(--smart-text);
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 999px;
  box-shadow: 0 14px 34px var(--smart-shadow);
  backdrop-filter: blur(16px);
  font-size: 12px;
  font-weight: 750;
}

.smart-log-toggle {
  right: 138px;
}

.asset-toggle {
  right: 22px;
}

.smart-log-toggle:hover,
.asset-toggle:hover {
  border-color: var(--smart-text);
  transform: translateY(-1px);
}

.smart-log-toggle svg,
.asset-toggle svg {
  width: 16px;
  height: 16px;
}

.smart-mode .canvas-status-strip {
  left: 22px;
  bottom: 0;
  height: 32px;
  color: var(--smart-muted);
  background: rgba(15, 23, 42, 0.52);
  border-color: var(--smart-line);
  border-radius: 14px 14px 0 0;
  box-shadow: none;
}

.smart-mode .minimap,
.smart-minimap {
  right: 22px;
  bottom: 22px;
  z-index: 50;
  width: 190px;
  height: 128px;
  border-radius: 18px;
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  box-shadow: 0 18px 44px var(--smart-shadow);
  backdrop-filter: blur(16px);
}

.smart-minimap-content {
  inset: 10px;
  border-radius: 12px;
  background-image: radial-gradient(var(--grid) 1px, transparent 1px);
  background-size: 12px 12px;
}

.smart-mode .smart-node {
  overflow: visible;
  background: transparent;
  border: 0;
  border-radius: 16px;
  box-shadow: none;
  cursor: move;
}

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

.smart-mode .node-smart-image.empty-node,
.smart-mode .node-smart-image:not(:has(.smart-image-zone.has-images)) {
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  box-shadow: 0 12px 34px var(--smart-shadow);
}

.smart-mode .node-smart-image .node-header {
  display: none;
}

.smart-mode .node-smart-image .node-body {
  height: 100%;
  min-height: 0;
  padding: 0;
}

.smart-mode .node-smart-prompt,
.smart-mode .node-smart-loop {
  padding: 12px;
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 16px;
  box-shadow: 0 20px 56px var(--smart-shadow);
  backdrop-filter: blur(20px);
}

.smart-mode .node-smart-prompt .node-header,
.smart-mode .node-smart-loop .node-header {
  display: none;
}

.smart-mode .node-smart-prompt .node-body,
.smart-mode .node-smart-loop .node-body {
  height: 100%;
  padding: 0;
}

.smart-mode .smart-image-zone {
  min-height: 100%;
  color: var(--smart-muted);
  background: transparent;
  border: 0;
  border-radius: 13px;
}

.smart-mode .smart-image-zone:not(.has-images) {
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
}

.smart-mode .smart-image-zone img {
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 13px;
  object-fit: cover;
}

.smart-mode .smart-node.selected .smart-image-zone img,
.smart-mode .smart-image-zone:hover img {
  border-color: var(--smart-strong);
  box-shadow: 0 0 0 1px var(--smart-strong);
}

.smart-mode .image-placeholder {
  color: var(--smart-faint);
  font-size: 13px;
  font-weight: 800;
}

.smart-image-size-label {
  position: absolute;
  left: 7px;
  top: 7px;
  z-index: 5;
  height: 22px;
  padding: 0 8px;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  font-size: 10px;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.smart-mode .smart-node:hover .smart-image-size-label,
.smart-mode .smart-node.selected .smart-image-size-label {
  opacity: 1;
  transform: translateY(0);
}

.smart-mode .smart-delete-button {
  position: absolute;
  right: 7px;
  top: 7px;
  z-index: 6;
  width: 24px;
  height: 24px;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
}

.smart-mode .smart-node:hover .smart-delete-button,
.smart-mode .smart-node.selected .smart-delete-button {
  opacity: 1;
  pointer-events: auto;
}

.smart-mode .smart-delete-button:hover {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.22);
  border-color: rgba(248, 113, 113, 0.36);
}

.smart-mode .port {
  width: 14px;
  height: 14px;
  background: var(--smart-card);
  border: 1.8px solid var(--smart-strong);
  opacity: 0;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.28);
}

.smart-mode .smart-node:hover .port,
.smart-mode .smart-node.selected .port {
  opacity: 1;
}

.smart-mode .port.in {
  left: -8px;
}

.smart-mode .port.out {
  right: -8px;
}

.smart-mode .composer {
  --ctrl-font: 10.5px;
  --ctrl-icon: 11px;
  --ctrl-height: 26px;
  --ctrl-gap: 4px;
  --ctrl-xpad: 8px;
  position: absolute;
  z-index: 75;
  width: 520px;
  padding: 0;
  color: var(--smart-text);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  transform: translateY(10px);
  opacity: 1;
  pointer-events: auto;
}

.smart-mode .composer.hidden {
  display: none;
}

.composer-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "head head"
    "thumbs thumbs"
    "prompt prompt"
    "params run"
    "status status";
  gap: 8px;
  align-items: start;
  padding: 10px;
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 18px;
  box-shadow: 0 20px 56px var(--smart-shadow);
  backdrop-filter: blur(20px);
}

.composer-head {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.engine-select {
  height: 24px;
  padding: 0 10px 0 9px;
  color: var(--smart-text);
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  border-radius: 999px;
  outline: none;
  font-size: 10.5px;
  font-weight: 700;
}

.kind-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  border-radius: 999px;
}

.kind-toggle button {
  display: inline-flex;
  height: 20px;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  color: var(--smart-muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
}

.kind-toggle button.active {
  color: var(--smart-strong-text);
  background: var(--smart-strong);
}

.kind-toggle button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.kind-toggle svg {
  width: 11px;
  height: 11px;
}

.smart-mode .composer-refs,
.input-thumbs-row {
  grid-area: thumbs;
  display: none;
  min-height: 0;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 2px 2px 4px;
  overflow-x: auto;
}

.smart-mode .composer-refs.has-items,
.input-thumbs-row.has-items {
  display: flex;
}

.smart-mode .composer-ref-thumb {
  width: 42px;
  height: 42px;
  border-radius: 9px;
  background: var(--smart-soft);
  border: 1px solid var(--smart-line);
}

.prompt-row {
  position: relative;
  grid-area: prompt;
  display: block;
  min-width: 0;
}

.smart-mode .prompt-input {
  width: 100%;
  height: 124px;
  min-height: 60px;
  max-height: 380px;
  overflow: auto;
  padding: 10px 12px;
  color: var(--smart-text);
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  border-radius: 13px;
  outline: none;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.smart-mode .prompt-input:empty::before {
  color: var(--smart-faint);
  content: attr(data-placeholder);
  font-size: 11px;
  font-weight: 400;
}

.smart-mode .prompt-input:focus {
  border-color: var(--smart-strong);
  box-shadow: 0 0 0 3px rgba(248, 250, 252, 0.08);
}

.prompt-resize {
  position: absolute;
  left: 50%;
  bottom: -3px;
  z-index: 3;
  display: flex;
  width: 36px;
  height: 8px;
  align-items: center;
  justify-content: center;
  cursor: ns-resize;
  opacity: 0.5;
}

.prompt-resize::after {
  width: 22px;
  height: 2px;
  background: var(--smart-muted);
  border-radius: 999px;
  content: "";
}

.param-row {
  grid-area: params;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--ctrl-gap);
  overflow: visible;
  flex-wrap: wrap;
}

.dynamic-params {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--ctrl-gap);
  overflow: visible;
  flex-wrap: wrap;
}

.smart-control {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
}

.smart-control::before {
  position: absolute;
  left: -6px;
  right: -6px;
  bottom: 100%;
  height: 10px;
  pointer-events: auto;
  content: "";
}

.smart-pill {
  display: flex;
  width: auto;
  max-width: 124px;
  height: var(--ctrl-height);
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
  padding: 0 var(--ctrl-xpad);
  color: var(--smart-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: var(--ctrl-font);
  font-weight: 700;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-pill svg {
  width: var(--ctrl-icon);
  height: var(--ctrl-icon);
  flex: 0 0 auto;
  opacity: 0.72;
}

.smart-pill .sub {
  min-width: 0;
  overflow: hidden;
  color: var(--smart-muted);
  text-overflow: ellipsis;
}

.smart-control:hover .smart-pill,
.smart-control.pinned .smart-pill {
  background: var(--smart-card);
  border-color: var(--smart-line);
}

.smart-control.pinned .smart-pill {
  border-color: var(--smart-strong);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.22);
}

.smart-popover {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 90;
  min-width: 190px;
  max-width: min(380px, calc(100vw - 40px));
  padding: 8px;
  color: var(--smart-text);
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 13px;
  box-shadow: 0 14px 40px var(--smart-shadow);
  backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
  visibility: hidden;
}

.smart-control:hover .smart-popover,
.smart-control:focus-within .smart-popover,
.smart-control.pinned .smart-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
  visibility: visible;
}

.smart-popover-title {
  margin: 0 2px 6px;
  color: var(--smart-faint);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.model-list {
  display: grid;
  gap: 4px;
}

.direct-option,
.seg-row button,
.ratio-option,
.count-cell {
  color: var(--smart-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 10.5px;
  font-weight: 700;
}

.direct-option {
  display: flex;
  min-height: 26px;
  align-items: center;
  justify-content: flex-start;
  padding: 0 8px;
}

.direct-option:hover,
.direct-option.active,
.seg-row button:hover,
.seg-row button.active,
.ratio-option:hover,
.ratio-option.active,
.count-cell:hover,
.count-cell.active {
  color: var(--smart-strong);
  background: var(--smart-card);
  border-color: var(--smart-line);
}

.ratio-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(42px, 1fr));
  gap: 4px;
}

.ratio-option {
  height: 34px;
  padding: 0 4px;
}

.seg-row,
.count-grid {
  display: grid;
  gap: 3px;
  padding: 3px;
  background: var(--smart-soft);
  border: 1px solid var(--smart-line);
  border-radius: 10px;
}

.seg-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.count-grid {
  grid-template-columns: repeat(4, 1fr);
}

.seg-row button,
.count-cell {
  height: 24px;
}

.composer-actions {
  grid-area: run;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.smart-mode .run-button,
.run-btn {
  display: flex;
  width: auto;
  min-width: 118px;
  height: var(--ctrl-height);
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 12px;
  color: var(--smart-strong-text);
  background: var(--smart-strong);
  border: 0;
  border-radius: 999px;
  font-size: var(--ctrl-font);
  font-weight: 700;
}

.run-btn:hover:not(:disabled) {
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.22);
  transform: translateY(-1px);
}

.run-btn svg {
  width: var(--ctrl-icon);
  height: var(--ctrl-icon);
}

.smart-mode .composer-status {
  grid-area: status;
  min-height: 16px;
  margin: 0;
  color: var(--smart-muted);
  font-size: 10.5px;
  font-weight: 700;
}

.smart-mode .context-menu {
  width: 420px;
  max-width: calc(100vw - 28px);
  padding: 10px;
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 18px;
  box-shadow: 0 22px 58px var(--smart-shadow);
  backdrop-filter: blur(20px);
}

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

.create-card {
  display: flex;
  min-height: 118px;
  align-items: flex-start;
  justify-content: space-between;
  flex-direction: column;
  gap: 10px;
  padding: 12px 10px;
  color: var(--smart-text);
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  border-radius: 14px;
  text-align: left;
}

.create-card:hover {
  border-color: var(--smart-strong);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.24);
  transform: translateY(-2px);
}

.create-card-icon {
  display: flex;
  width: 34px;
  height: 34px;
  align-items: center;
  justify-content: center;
  color: var(--smart-text);
  background: var(--smart-soft);
  border: 1px solid var(--smart-line);
  border-radius: 12px;
}

.create-card-icon svg {
  width: 18px;
  height: 18px;
}

.create-card-title {
  display: block;
  color: var(--smart-text);
  font-size: 12px;
  font-weight: 800;
}

.create-card-sub {
  display: block;
  margin-top: 4px;
  color: var(--smart-faint);
  font-size: 10px;
  font-style: normal;
  font-weight: 600;
  line-height: 1.35;
}

.drop-overlay.visible {
  display: grid;
}

.asset-library-panel {
  position: fixed;
  right: 18px;
  top: 78px;
  bottom: 18px;
  z-index: 120;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr);
  width: min(360px, calc(100vw - 36px));
  overflow: hidden;
  background: rgba(255, 255, 255, 0.98);
  border: 1px solid #dfe8f3;
  border-radius: 16px;
  box-shadow: 0 24px 72px rgba(15, 23, 42, 0.16);
}

.asset-library-panel.hidden {
  display: none;
}

.asset-library-header,
.asset-library-tools,
.asset-library-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid #edf2f7;
}

.asset-library-header {
  justify-content: space-between;
}

.asset-library-header h2 {
  margin: 0;
  font-size: 17px;
}

.asset-library-header p {
  margin: 5px 0 0;
  color: #7c8798;
  font-size: 12px;
  font-weight: 800;
}

.asset-library-tools select {
  min-width: 0;
  flex: 1;
  height: 36px;
  padding: 0 10px;
  color: #111827;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 10px;
  outline: none;
  font-weight: 800;
}

.asset-library-actions {
  justify-content: space-between;
}

.asset-library-actions .pill-button {
  box-shadow: none;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  overflow: auto;
  padding: 12px;
}

.asset-empty {
  grid-column: 1 / -1;
  display: grid;
  min-height: 160px;
  place-items: center;
  color: #94a3b8;
  background: #f8fafc;
  border: 1px dashed #cbd8e8;
  border-radius: 12px;
  font-size: 13px;
  font-weight: 800;
}

.asset-card {
  min-width: 0;
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
}

.asset-card:hover {
  border-color: #9bb7f5;
}

.asset-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  background: #f8fafc;
  border: 0;
  border-bottom: 1px solid #edf2f7;
}

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

.asset-card-meta {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 26px;
  align-items: center;
  gap: 6px;
  padding: 7px;
}

.asset-card-meta strong {
  overflow: hidden;
  color: #334155;
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.minimap {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  width: 180px;
  height: 120px;
  overflow: hidden;
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(24, 35, 52, 0.14);
}

.minimap-content {
  position: relative;
  width: 100%;
  height: 100%;
}

.minimap-node {
  position: absolute;
  background: rgba(37, 99, 235, 0.72);
  border-radius: 3px;
}

.minimap-view {
  position: absolute;
  border: 1px solid #111827;
  background: rgba(17, 24, 39, 0.06);
  border-radius: 3px;
}

.canvas-status-strip {
  position: absolute;
  left: 24px;
  bottom: 22px;
  z-index: 30;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  color: #6b778a;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid #e5ebf3;
  border-radius: 999px;
  box-shadow: 0 10px 28px rgba(31, 41, 55, 0.08);
  font-size: 12px;
  font-weight: 800;
}

.canvas-status-strip span + span::before {
  margin-right: 8px;
  color: #c1cbd8;
  content: "·";
}

.composer {
  position: absolute;
  z-index: 70;
  width: min(620px, calc(100vw - 128px));
  padding: 14px;
  background: rgba(255, 255, 255, 0.97);
  border: 1px solid #e2e8f0;
  border-radius: 22px;
  box-shadow: 0 18px 46px rgba(31, 41, 55, 0.12);
  transform-origin: 24px top;
}

.smart-mode .composer {
  padding: 12px;
  color: #e5edf8;
  background: rgba(15, 23, 42, 0.96);
  border-color: rgba(148, 163, 184, 0.28);
  border-radius: 18px;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.38);
}

.composer.hidden {
  display: none;
}

.composer-tabs,
.composer-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

.composer-tabs select,
.composer-footer select {
  height: 36px;
  padding: 0 10px;
  color: #111827;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 10px;
  outline: none;
  font-size: 13px;
  font-weight: 700;
}

.smart-mode .composer-tabs select,
.smart-mode .composer-footer select,
.smart-mode .composer-count-control {
  height: 30px;
  color: #e5edf8;
  background: rgba(15, 23, 42, 0.84);
  border-color: rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
}

.composer-tabs select:focus,
.composer-footer select:focus,
.prompt-input:focus {
  border-color: #9bb7f5;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.prompt-input.locked {
  color: #475569;
  background: #f8fafc;
  border-style: dashed;
}

.composer-tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 10px;
  color: #52657d;
  background: #f5f8fc;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.composer-tab.active {
  color: #fff;
  background: #111827;
  border-color: #111827;
}

.smart-mode .composer-tab {
  height: 30px;
  color: #94a3b8;
  background: rgba(15, 23, 42, 0.8);
  border-color: rgba(148, 163, 184, 0.24);
}

.smart-mode .composer-tab.active {
  color: #0f172a;
  background: #eef2f7;
  border-color: #eef2f7;
}

.composer-tab svg {
  width: 14px;
  height: 14px;
}

.composer-refs {
  display: flex;
  min-height: 42px;
  align-items: center;
  gap: 8px;
  margin: 10px 0;
  overflow-x: auto;
}

.smart-mode .composer-refs {
  min-height: 46px;
  margin: 10px 0;
}

.smart-mode .composer-refs .composer-status {
  color: #94a3b8;
}

.composer-ref-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  overflow: hidden;
  padding: 0;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
}

.smart-mode .composer-ref-thumb {
  width: 46px;
  height: 46px;
  background: rgba(30, 41, 59, 0.86);
  border-color: rgba(148, 163, 184, 0.22);
}

.composer-ref-thumb:hover {
  border-color: #9bb7f5;
}

.composer-ref-thumb.disabled {
  opacity: 0.45;
}

.composer-ref-thumb.drag-over {
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.composer-ref-thumb span {
  position: absolute;
  left: 4px;
  top: 4px;
  min-width: 16px;
  height: 16px;
  color: #fff;
  background: rgba(17, 24, 39, 0.72);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  line-height: 16px;
}

.composer-ref-thumb em {
  position: absolute;
  right: 3px;
  bottom: 3px;
  min-width: 18px;
  height: 16px;
  color: #fff;
  background: rgba(17, 24, 39, 0.72);
  border-radius: 999px;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  line-height: 16px;
}

.composer-ref-thumb.disabled em {
  background: #dc2626;
}

.prompt-input {
  width: 100%;
  height: 116px;
  min-height: 88px;
  max-height: 220px;
  padding: 12px;
  overflow-y: auto;
  color: #111827;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 14px;
  outline: none;
  line-height: 1.65;
}

.smart-mode .prompt-input {
  height: 132px;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.72);
  border-color: rgba(148, 163, 184, 0.24);
  border-radius: 14px;
  font-size: 14px;
  font-weight: 750;
}

.smart-mode .prompt-input.locked {
  color: #dbeafe;
  background: rgba(30, 41, 59, 0.68);
  border-style: solid;
}

.composer-prompt-editor:empty::before {
  color: #94a3b8;
  content: attr(data-placeholder);
}

.mention-token {
  display: inline-flex;
  max-width: 180px;
  align-items: center;
  padding: 2px 7px;
  color: #0f3f8a;
  background: #eaf2ff;
  border: 1px solid #bcd4ff;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 900;
  vertical-align: baseline;
  white-space: nowrap;
}

.mention-picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-height: 210px;
  margin-top: 10px;
  overflow: auto;
  padding: 8px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 14px;
}

.mention-picker.hidden {
  display: none;
}

.mention-option {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  grid-template-rows: auto auto;
  column-gap: 8px;
  min-width: 0;
  padding: 6px;
  text-align: left;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 10px;
}

.mention-option:hover {
  border-color: #9bb7f5;
}

.mention-option img {
  grid-row: 1 / 3;
  width: 42px;
  height: 42px;
  object-fit: cover;
  background: #f8fafc;
  border-radius: 8px;
}

.mention-option span,
.mention-option em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-option span {
  color: #334155;
  font-size: 12px;
  font-weight: 900;
}

.mention-option em,
.mention-empty {
  color: #94a3b8;
  font-size: 11px;
  font-style: normal;
  font-weight: 800;
}

.mention-empty {
  grid-column: 1 / -1;
  padding: 10px;
  text-align: center;
}

.composer-footer {
  margin-top: 10px;
  flex-wrap: wrap;
}

.smart-mode .composer-footer {
  align-items: center;
  gap: 9px;
}

.composer-count-control {
  display: inline-flex;
  height: 36px;
  align-items: center;
  gap: 6px;
  padding: 0 10px;
  color: #52657d;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 800;
}

.composer-count-control svg {
  width: 15px;
  height: 15px;
}

.composer-count-control input {
  width: 42px;
  height: 28px;
  padding: 0;
  text-align: center;
  background: transparent;
  border: 0;
  outline: none;
  font-weight: 900;
}

.run-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  height: 36px;
  margin-left: auto;
  padding: 0 16px;
  color: #fff;
  background: #111827;
  border: 1px solid #111827;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 800;
}

.smart-mode .run-button {
  height: 32px;
  color: #0f172a;
  background: #eef2f7;
  border-color: #eef2f7;
  font-size: 12px;
  font-weight: 950;
}

.run-button:disabled {
  cursor: wait;
  opacity: 0.72;
}

.composer-status {
  min-height: 18px;
  margin: 10px 0 0;
  color: #6b778a;
  font-size: 12px;
  font-weight: 700;
}

.smart-mode .composer-status {
  color: #94a3b8;
}

.composer-status[data-tone="error"] {
  color: #dc2626;
}

.composer-status[data-tone="ok"] {
  color: #15803d;
}

.context-menu {
  position: fixed;
  z-index: 100;
  min-width: 164px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.context-menu.hidden,
.lightbox.hidden {
  display: none;
}

.context-menu button {
  width: 100%;
  min-height: 34px;
  justify-content: flex-start;
  padding: 0 10px;
  color: var(--text);
  background: transparent;
}

.context-menu button:hover {
  background: var(--accent-soft);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 16px;
  padding: 56px 24px 24px;
  background: rgba(15, 23, 42, 0.82);
}

.lightbox-stage {
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  cursor: grab;
}

.lightbox-stage:active {
  cursor: grabbing;
}

.lightbox img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.28);
  transform-origin: center center;
  will-change: transform;
}

.lightbox > img {
  justify-self: center;
  align-self: center;
  grid-column: 1 / -1;
}

.lightbox-inspector {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto auto;
  gap: 14px;
  min-width: 0;
  max-height: calc(100vh - 80px);
  padding: 16px;
  overflow: hidden;
  color: #e5e7eb;
  background: rgba(15, 23, 42, 0.74);
  border: 1px solid rgba(226, 232, 240, 0.16);
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.2);
}

.lightbox-inspector h2 {
  margin: 0;
  font-size: 18px;
}

.lightbox-inspector p {
  max-height: 42vh;
  margin: 12px 0 0;
  overflow: auto;
  color: #cbd5e1;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
}

.lightbox-meta {
  display: grid;
  gap: 8px;
}

.lightbox-meta span {
  display: grid;
  gap: 4px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(226, 232, 240, 0.1);
  border-radius: 8px;
}

.lightbox-meta b {
  color: #94a3b8;
  font-size: 11px;
  font-weight: 900;
}

.lightbox-meta em {
  min-width: 0;
  overflow: hidden;
  color: #f8fafc;
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lightbox-tools {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.lightbox-tools .icon-button {
  color: #e5e7eb;
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(226, 232, 240, 0.16);
}

.lightbox-close {
  position: absolute;
  top: 18px;
  right: 18px;
  z-index: 2;
}

.image-editor {
  position: fixed;
  inset: 0;
  z-index: 230;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(15, 23, 42, 0.54);
}

.image-editor.hidden {
  display: none;
}

.image-editor-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  width: min(1040px, 100%);
  height: min(760px, calc(100vh - 48px));
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 8px;
  box-shadow: 0 24px 72px rgba(15, 23, 42, 0.28);
}

.image-editor-header,
.image-editor-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid #edf2f7;
}

.image-editor-footer {
  justify-content: flex-end;
  border-top: 1px solid #edf2f7;
  border-bottom: 0;
}

.image-editor-tabs,
.editor-mode-panel {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.editor-tab {
  height: 34px;
  padding: 0 14px;
  color: #52657d;
  background: #f8fafc;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 900;
}

.editor-tab.active {
  color: #fff;
  background: #111827;
  border-color: #111827;
}

.image-editor-stage {
  position: relative;
  display: grid;
  min-width: 0;
  min-height: 0;
  place-items: center;
  overflow: hidden;
  background:
    linear-gradient(45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(-45deg, #e5e7eb 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e5e7eb 75%),
    linear-gradient(-45deg, transparent 75%, #e5e7eb 75%);
  background-color: #f8fafc;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  cursor: grab;
}

.image-editor-stage:active {
  cursor: grabbing;
}

.image-editor-stage img {
  max-width: 88%;
  max-height: 88%;
  object-fit: contain;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.22);
  transform-origin: center center;
  will-change: transform;
}

.crop-box {
  position: absolute;
  left: 15%;
  top: 15%;
  right: 15%;
  bottom: 15%;
  border: 2px solid #fff;
  border-radius: 8px;
  box-shadow:
    0 0 0 9999px rgba(15, 23, 42, 0.42),
    0 0 0 1px #111827;
  pointer-events: none;
}

.crop-box.hidden,
.editor-mode-panel.hidden {
  display: none;
}

.editor-mode-panel label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: #52657d;
  font-size: 13px;
  font-weight: 900;
}

.editor-mode-panel input {
  width: 86px;
  height: 36px;
  padding: 0 10px;
  color: #111827;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
  outline: none;
  font-weight: 900;
}

.log-modal {
  position: fixed;
  inset: 0;
  z-index: 210;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(15, 23, 42, 0.36);
}

.log-modal.hidden {
  display: none;
}

.log-panel {
  width: min(760px, 100%);
  max-height: min(720px, calc(100vh - 56px));
  overflow: hidden;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  box-shadow: 0 24px 72px rgba(15, 23, 42, 0.24);
}

.log-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid #edf2f7;
}

.log-header h2 {
  margin: 0;
  font-size: 18px;
}

.log-header p {
  margin: 6px 0 0;
  color: #7c8798;
  font-size: 12px;
  font-weight: 700;
}

.log-list {
  display: grid;
  gap: 10px;
  max-height: calc(100vh - 170px);
  overflow: auto;
  padding: 14px 18px 18px;
}

.log-entry {
  display: grid;
  gap: 8px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
}

.log-entry.failed {
  background: #fff7f7;
  border-color: #fecaca;
}

.log-entry-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.log-entry strong {
  font-size: 13px;
}

.log-entry.failed strong {
  color: #dc2626;
}

.log-entry small {
  display: block;
  max-width: 360px;
  overflow: hidden;
  color: #94a3b8;
  font-size: 11px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-entry time {
  color: #7c8798;
  font-size: 12px;
  font-weight: 700;
}

.log-entry p {
  margin: 0;
  color: #334155;
  font-size: 13px;
  line-height: 1.6;
}

.log-entry-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.log-entry-meta span {
  padding: 3px 8px;
  color: #52657d;
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
}

.log-images {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 2px;
}

.log-image-group {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.log-image-label {
  color: #64748b;
  font-size: 11px;
  font-weight: 900;
}

.log-thumbs {
  display: flex;
  min-height: 44px;
  align-items: center;
  gap: 6px;
  overflow-x: auto;
}

.log-thumbs em {
  color: #94a3b8;
  font-size: 12px;
  font-style: normal;
  font-weight: 700;
}

.log-thumb {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  overflow: hidden;
  padding: 0;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
}

.log-thumb:hover {
  border-color: #9bb7f5;
}

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

@media (max-width: 860px) {
  .shell-page {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .app-sidebar {
    flex-direction: row;
    justify-content: space-between;
    gap: 16px;
    padding: 12px;
    border-right: 0;
    border-bottom: 1px solid #eef1f6;
  }

  .app-nav {
    display: flex;
    width: auto;
    gap: 8px;
  }

  .app-nav-item {
    min-height: 38px;
    padding: 0 12px;
  }

  .workspace {
    border-top-left-radius: 0;
  }

  .canvas-picker-panel,
  .settings-panel {
    top: 50%;
    width: calc(100% - 28px);
    padding: 18px;
    border-radius: 18px;
  }

  .picker-header {
    flex-direction: column;
  }

  .picker-actions {
    width: 100%;
    justify-content: flex-end;
  }

  .canvas-app {
    grid-template-columns: 1fr;
    grid-template-rows: auto minmax(0, 1fr);
  }

  .sidebar {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 10px;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .tool-group {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .status-panel,
  .selection-panel,
  .minimap {
    display: none;
  }

  .log-images {
    grid-template-columns: 1fr;
  }

  .lightbox {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1fr) auto;
    padding: 58px 14px 14px;
  }

  .lightbox-inspector {
    max-height: 34vh;
  }
}

/* Final smart canvas parity overrides. Keep this block last so the smart canvas
   is not pulled back into the traditional canvas visual system. */
.smart-mode {
  --page: #f8fafc;
  --grid: #d9e1ea;
  --smart-panel: rgba(255, 255, 255, 0.9);
  --smart-card: #ffffff;
  --smart-text: #111827;
  --smart-muted: #64748b;
  --smart-faint: #94a3b8;
  --smart-line: #e8edf3;
  --smart-soft: #f8fafc;
  --smart-shadow: rgba(15, 23, 42, 0.08);
  --smart-strong: #111827;
  --smart-strong-text: #ffffff;
  --ctrl-font: 10.5px;
  --ctrl-icon: 11px;
  --ctrl-height: 26px;
  --ctrl-gap: 4px;
  --ctrl-xpad: 8px;
  --ctrl-pop-font: 10.5px;
  --ctrl-pop-height: 24px;
}

.theme-dark .smart-mode,
.smart-mode.theme-dark {
  --page: #0f141d;
  --grid: rgba(148, 163, 184, 0.18);
  --smart-panel: rgba(23, 29, 41, 0.92);
  --smart-card: #171d29;
  --smart-text: #e5e9f0;
  --smart-muted: #8f9aab;
  --smart-faint: #657286;
  --smart-line: #2a3444;
  --smart-soft: #111722;
  --smart-shadow: rgba(0, 0, 0, 0.28);
  --smart-strong: #d8dee9;
  --smart-strong-text: #10141d;
}

body.smart-mode {
  overflow: hidden;
  color: var(--smart-text);
  background: var(--page);
}

.smart-mode [hidden] {
  display: none !important;
}

.smart-mode .canvas-app,
.smart-mode .canvas-app-full,
.smart-mode .board {
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--page);
  background-image: radial-gradient(var(--grid) 1px, transparent 1px);
  background-size: 24px 24px;
}

.smart-mode .board {
  cursor: grab;
}

.smart-mode .board:active {
  cursor: grabbing;
}

.smart-mode .canvas-toolbar,
.smart-mode .canvas-topbar,
.smart-mode .smart-rail,
.smart-mode .smart-top-actions {
  display: none !important;
}

.smart-mode .world,
.smart-mode .links,
.smart-mode .temp-link-layer,
.smart-mode .nodes-layer {
  width: 6000px;
  height: 4000px;
}

.smart-mode .smart-back {
  position: absolute;
  left: 22px;
  top: 22px;
  z-index: 90;
  display: flex;
  height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  color: var(--smart-text);
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 999px;
  box-shadow: 0 16px 40px var(--smart-shadow);
  backdrop-filter: blur(16px);
  font-size: 12px;
  font-weight: 850;
  text-decoration: none;
}

.smart-mode .smart-back:hover {
  transform: translateY(-1px);
}

.smart-mode .smart-back svg,
.smart-mode .smart-log-toggle svg,
.smart-mode .asset-toggle svg {
  width: 16px;
  height: 16px;
}

.smart-mode .smart-title {
  position: absolute;
  left: 22px;
  top: 72px;
  z-index: 70;
  display: grid;
  max-width: min(420px, calc(100vw - 44px));
  gap: 2px;
  color: var(--smart-muted);
}

.smart-mode .smart-title .ghost-title {
  width: min(280px, calc(100vw - 56px));
  height: 18px;
  padding: 0;
  color: var(--smart-text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 13px;
  font-weight: 900;
}

.smart-mode .smart-title span {
  color: var(--smart-muted);
  font-size: 12px;
  font-weight: 800;
}

.smart-mode .smart-title b,
.smart-mode .smart-title em {
  font-style: normal;
}

.smart-mode .smart-log-toggle,
.smart-mode .asset-toggle {
  position: absolute;
  top: 22px;
  z-index: 90;
  display: flex;
  height: 40px;
  align-items: center;
  gap: 8px;
  padding: 0 15px;
  color: var(--smart-text);
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 999px;
  box-shadow: 0 14px 34px var(--smart-shadow);
  backdrop-filter: blur(16px);
  font-size: 12px;
  font-weight: 750;
}

.smart-mode .smart-log-toggle {
  right: 138px;
}

.smart-mode .asset-toggle {
  right: 22px;
}

.smart-mode .smart-log-toggle:hover,
.smart-mode .asset-toggle:hover {
  border-color: var(--smart-text);
  transform: translateY(-1px);
}

.smart-mode .canvas-status-strip {
  left: 22px;
  bottom: 0;
  z-index: 30;
  height: 32px;
  color: var(--smart-muted);
  background: color-mix(in srgb, var(--smart-panel) 72%, transparent);
  border-color: var(--smart-line);
  border-radius: 14px 14px 0 0;
  box-shadow: none;
}

.smart-mode .minimap,
.smart-mode .smart-minimap {
  right: 22px;
  bottom: 22px;
  z-index: 50;
  width: 190px;
  height: 128px;
  overflow: hidden;
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 18px;
  box-shadow: 0 18px 44px var(--smart-shadow);
  backdrop-filter: blur(16px);
}

.smart-mode .smart-minimap-content,
.smart-mode .minimap-content {
  position: absolute;
  inset: 10px;
  width: auto;
  height: auto;
  overflow: hidden;
  background-image: radial-gradient(var(--grid) 1px, transparent 1px);
  background-size: 12px 12px;
  border-radius: 12px;
}

.smart-mode .minimap-node {
  background: var(--smart-strong);
  border-radius: 3px;
  opacity: 0.78;
}

.smart-mode .minimap-view {
  background: rgba(15, 23, 42, 0.06);
  border: 1px solid var(--smart-strong);
  border-radius: 8px;
}

.smart-mode .smart-node {
  overflow: visible;
  min-height: 0;
  background: transparent;
  border: 0;
  border-radius: 16px;
  box-shadow: none;
  cursor: move;
}

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

.smart-mode .node-smart-image.empty-node {
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  box-shadow: 0 12px 34px var(--smart-shadow);
}

.smart-mode .node-smart-image .node-header {
  display: none;
}

.smart-mode .node-smart-image .node-body {
  height: 100%;
  min-height: 0;
  padding: 0;
}

.smart-mode .node-smart-prompt,
.smart-mode .node-smart-loop {
  padding: 12px;
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 16px;
  box-shadow: 0 20px 56px var(--smart-shadow);
  backdrop-filter: blur(20px);
}

.smart-mode .node-smart-prompt .node-header,
.smart-mode .node-smart-loop .node-header {
  display: none;
}

.smart-mode .node-smart-prompt .node-body,
.smart-mode .node-smart-loop .node-body {
  height: 100%;
  min-height: 0;
  padding: 0;
}

.smart-mode .smart-image-zone {
  width: 100%;
  height: 100%;
  min-height: 100%;
  overflow: visible;
  color: var(--smart-muted);
  background: transparent;
  border: 0;
  border-radius: 13px;
}

.smart-mode .smart-image-zone:not(.has-images) {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  box-shadow: 0 12px 34px var(--smart-shadow);
}

.smart-mode .smart-image-zone img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: var(--smart-soft);
  border: 1px solid rgba(148, 163, 184, 0.3);
  border-radius: 13px;
}

.smart-mode .smart-node.selected .smart-image-zone img,
.smart-mode .smart-image-zone:hover img {
  border-color: var(--smart-strong);
  box-shadow: 0 0 0 1px var(--smart-strong);
}

.smart-mode .image-placeholder {
  color: var(--smart-faint);
  font-size: 13px;
  font-weight: 800;
}

.smart-mode .smart-image-node-actions {
  position: static;
}

.smart-mode .smart-image-size-label {
  position: absolute;
  left: 7px;
  top: 7px;
  z-index: 5;
  height: 22px;
  padding: 0 8px;
  color: #e2e8f0;
  background: rgba(15, 23, 42, 0.82);
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  font-size: 10px;
  font-weight: 800;
  line-height: 20px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-2px);
  transition: opacity 0.14s ease, transform 0.14s ease;
}

.smart-mode .smart-node:hover .smart-image-size-label,
.smart-mode .smart-node.selected .smart-image-size-label {
  opacity: 1;
  transform: translateY(0);
}

.smart-mode .smart-delete-button {
  position: absolute;
  right: 7px;
  top: 7px;
  z-index: 6;
  display: flex;
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
  background: rgba(15, 23, 42, 0.86);
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 999px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  opacity: 0;
  pointer-events: none;
}

.smart-mode .smart-delete-button svg {
  width: 13px;
  height: 13px;
}

.smart-mode .smart-node:hover .smart-delete-button,
.smart-mode .smart-node.selected .smart-delete-button {
  opacity: 1;
  pointer-events: auto;
}

.smart-mode .smart-delete-button:hover {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.22);
  border-color: rgba(248, 113, 113, 0.36);
}

.smart-mode .port {
  width: 14px;
  height: 14px;
  background: var(--smart-card);
  border: 1.8px solid var(--smart-strong);
  opacity: 0;
  box-shadow: 0 4px 10px var(--smart-shadow);
}

.smart-mode .smart-node:hover .port,
.smart-mode .smart-node.selected .port {
  opacity: 1;
}

.smart-mode .port.in {
  left: -8px;
}

.smart-mode .port.out {
  right: -8px;
}

.smart-mode .resize-handle {
  opacity: 0;
}

.smart-mode .smart-node:hover .resize-handle,
.smart-mode .smart-node.selected .resize-handle {
  opacity: 1;
}

.smart-mode .composer {
  position: absolute;
  z-index: 75;
  width: 520px;
  padding: 0;
  color: var(--smart-text);
  background: transparent;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  opacity: 1;
  pointer-events: auto;
  transform: translateY(10px);
  transform-origin: 24px top;
}

.smart-mode .composer.hidden {
  display: none !important;
}

.smart-mode .composer-card {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas:
    "head head"
    "thumbs thumbs"
    "prompt prompt"
    "params run"
    "status status";
  gap: 8px;
  align-items: start;
  padding: 10px;
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 18px;
  box-shadow: 0 20px 56px var(--smart-shadow);
  backdrop-filter: blur(20px);
}

.smart-mode .composer-head {
  grid-area: head;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 2px;
}

.smart-mode .engine-select {
  height: 24px;
  padding: 0 10px 0 9px;
  color: var(--smart-text);
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  border-radius: 999px;
  outline: none;
  font-size: 10.5px;
  font-weight: 500;
}

.smart-mode .kind-toggle {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  border-radius: 999px;
}

.smart-mode .kind-toggle button {
  display: inline-flex;
  height: 20px;
  align-items: center;
  gap: 4px;
  padding: 0 8px;
  color: var(--smart-muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 500;
}

.smart-mode .kind-toggle button.active {
  color: var(--smart-strong-text);
  background: var(--smart-strong);
}

.smart-mode .kind-toggle button:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.smart-mode .kind-toggle svg {
  width: 11px;
  height: 11px;
}

.smart-mode .composer-refs {
  grid-area: thumbs;
  display: none;
  min-height: 0;
  align-items: center;
  gap: 6px;
  margin: 0;
  padding: 2px 2px 4px;
  overflow-x: auto;
}

.smart-mode .composer-refs.has-items {
  display: flex;
}

.smart-mode .composer-ref-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  overflow: hidden;
  padding: 0;
  background: var(--smart-soft);
  border: 1px solid var(--smart-line);
  border-radius: 9px;
}

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

.smart-mode .composer-ref-thumb span,
.smart-mode .composer-ref-thumb em {
  position: absolute;
  min-width: 16px;
  height: 16px;
  color: #ffffff;
  background: rgba(17, 24, 39, 0.72);
  border-radius: 999px;
  font-size: 10px;
  font-style: normal;
  font-weight: 900;
  line-height: 16px;
  text-align: center;
}

.smart-mode .composer-ref-thumb span {
  left: 4px;
  top: 4px;
}

.smart-mode .composer-ref-thumb em {
  right: 3px;
  bottom: 3px;
}

.smart-mode .composer-ref-thumb.disabled {
  opacity: 0.45;
}

.smart-mode .composer-ref-thumb.disabled em {
  background: #dc2626;
}

.smart-mode .prompt-row {
  position: relative;
  grid-area: prompt;
  display: block;
  min-width: 0;
}

.smart-mode .prompt-input {
  width: 100%;
  height: 124px;
  min-height: 60px;
  max-height: 380px;
  overflow: auto;
  padding: 10px 12px;
  color: var(--smart-text);
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  border-radius: 13px;
  outline: none;
  font-size: 11.5px;
  font-weight: 400;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.smart-mode .prompt-input:empty::before {
  color: var(--smart-faint);
  content: attr(data-placeholder);
  font-size: 11px;
  font-weight: 400;
}

.smart-mode .prompt-input:focus {
  border-color: var(--smart-strong);
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.06);
}

.theme-dark .smart-mode .prompt-input:focus,
.smart-mode.theme-dark .prompt-input:focus {
  box-shadow: 0 0 0 3px rgba(248, 250, 252, 0.08);
}

.smart-mode .prompt-input.locked {
  cursor: default;
  background: var(--smart-soft);
  color: var(--smart-muted);
  border-style: dashed;
}

.smart-mode .prompt-resize {
  position: absolute;
  left: 50%;
  bottom: -3px;
  z-index: 3;
  display: flex;
  width: 36px;
  height: 8px;
  align-items: center;
  justify-content: center;
  cursor: ns-resize;
  opacity: 0.5;
}

.smart-mode .prompt-resize::after {
  width: 22px;
  height: 2px;
  background: var(--smart-muted);
  border-radius: 999px;
  content: "";
}

.smart-mode .param-row {
  grid-area: params;
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--ctrl-gap);
  overflow: visible;
  flex-wrap: wrap;
  row-gap: 4px;
}

.smart-mode .dynamic-params {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: var(--ctrl-gap);
  overflow: visible;
  flex-wrap: wrap;
  row-gap: 4px;
}

.smart-mode .smart-control {
  position: relative;
  flex: 0 0 auto;
  min-width: 0;
}

.smart-mode .smart-control::before {
  position: absolute;
  left: -6px;
  right: -6px;
  bottom: 100%;
  height: 10px;
  pointer-events: auto;
  content: "";
}

.smart-mode .smart-pill {
  display: flex;
  width: auto;
  max-width: 124px;
  height: var(--ctrl-height);
  align-items: center;
  justify-content: center;
  gap: 5px;
  overflow: hidden;
  padding: 0 var(--ctrl-xpad);
  color: var(--smart-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  font-size: var(--ctrl-font);
  font-weight: 500;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-mode .smart-pill svg {
  width: var(--ctrl-icon);
  height: var(--ctrl-icon);
  flex: 0 0 auto;
  opacity: 0.72;
}

.smart-mode .smart-pill .sub {
  min-width: 0;
  overflow: hidden;
  color: var(--smart-muted);
  font-weight: 500;
  text-overflow: ellipsis;
}

.smart-mode .model-control .smart-pill {
  max-width: 120px;
}

.smart-mode .provider-control .smart-pill {
  max-width: 118px;
}

.smart-mode .smart-control:hover .smart-pill,
.smart-mode .smart-control.pinned .smart-pill {
  background: var(--smart-card);
  border-color: var(--smart-line);
}

.smart-mode .smart-control.pinned .smart-pill {
  border-color: var(--smart-strong);
  box-shadow: 0 6px 16px var(--smart-shadow);
}

.smart-mode .smart-popover {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  z-index: 110;
  min-width: 190px;
  max-width: min(380px, calc(100vw - 40px));
  padding: 8px;
  color: var(--smart-text);
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 13px;
  box-shadow: 0 14px 40px var(--smart-shadow);
  backdrop-filter: blur(20px);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 4px);
  transition: opacity 0.14s ease, transform 0.14s ease, visibility 0.14s ease;
  visibility: hidden;
}

.smart-mode .smart-control:hover .smart-popover,
.smart-mode .smart-control:focus-within .smart-popover,
.smart-mode .smart-control.pinned .smart-popover {
  opacity: 1;
  pointer-events: auto;
  transform: translate(-50%, 0);
  visibility: visible;
}

.smart-mode .smart-popover-title {
  margin: 0 2px 6px;
  color: var(--smart-faint);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.smart-mode .compact-popover {
  min-width: 184px;
}

.smart-mode .model-popover {
  min-width: 280px;
}

.smart-mode .model-list {
  display: flex;
  max-height: 172px;
  flex-direction: column;
  gap: 1px;
  overflow: auto;
  padding-right: 2px;
}

.smart-mode .direct-option,
.smart-mode .seg-row button,
.smart-mode .ratio-option,
.smart-mode .count-cell {
  color: var(--smart-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: var(--ctrl-pop-font);
  font-weight: 500;
  line-height: 1;
}

.smart-mode .direct-option {
  display: flex;
  min-height: 22px;
  align-items: center;
  justify-content: flex-start;
  padding: 4px 8px;
  text-align: left;
}

.smart-mode .direct-option span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-mode .direct-option:hover,
.smart-mode .direct-option.active,
.smart-mode .seg-row button:hover,
.smart-mode .seg-row button.active,
.smart-mode .ratio-option:hover,
.smart-mode .ratio-option.active,
.smart-mode .count-cell:hover,
.smart-mode .count-cell.active {
  color: var(--smart-text);
  background: var(--smart-card);
  border-color: var(--smart-line);
}

.smart-mode .direct-option.active,
.smart-mode .ratio-option.active {
  color: var(--smart-strong);
  font-weight: 600;
}

.smart-mode .ratio-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(32px, 1fr));
  gap: 4px;
}

.smart-mode .ratio-option {
  display: flex;
  height: 34px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 0 2px;
  line-height: 1.05;
}

.smart-mode .ratio-icon {
  position: relative;
  width: 13px;
  height: 13px;
  border: 1.3px solid currentColor;
  border-radius: 2px;
  box-sizing: border-box;
}

.smart-mode .ratio-icon.r-portrait {
  width: 10px;
  height: 15px;
}

.smart-mode .ratio-icon.r-landscape {
  width: 18px;
  height: 12px;
}

.smart-mode .ratio-icon.r-portrait43 {
  width: 12px;
  height: 16px;
}

.smart-mode .ratio-icon.r-landscape43 {
  width: 16px;
  height: 12px;
}

.smart-mode .ratio-icon.r-story {
  width: 11px;
  height: 20px;
}

.smart-mode .ratio-icon.r-wide {
  width: 20px;
  height: 11px;
}

.smart-mode .ratio-icon.r-custom {
  border-style: dashed;
}

.smart-mode .ratio-icon.r-custom::after {
  position: absolute;
  left: 50%;
  top: 50%;
  color: currentColor;
  content: "+";
  font-size: 10px;
  font-weight: 700;
  line-height: 1;
  transform: translate(-50%, -52%);
}

.smart-mode .seg-row,
.smart-mode .count-grid {
  display: grid;
  gap: 3px;
  padding: 3px;
  background: var(--smart-soft);
  border: 1px solid var(--smart-line);
  border-radius: 10px;
}

.smart-mode .seg-row {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.smart-mode .count-grid {
  grid-template-columns: repeat(4, 1fr);
}

.smart-mode .seg-row button,
.smart-mode .count-cell {
  height: var(--ctrl-pop-height);
  padding: 0 4px;
  white-space: nowrap;
}

.smart-mode .inline-fields {
  display: inline-flex;
  height: var(--ctrl-height);
  align-items: center;
  gap: 3px;
  padding: 0 8px 0 10px;
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  border-radius: 999px;
}

.smart-mode .inline-label {
  color: var(--smart-faint);
  font-size: 9.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.smart-mode .inline-fields input {
  width: 48px;
  height: calc(var(--ctrl-height) - 4px);
  padding: 0;
  color: var(--smart-text);
  background: transparent;
  border: 0;
  outline: 0;
  text-align: center;
  font-size: var(--ctrl-font);
  font-variant-numeric: tabular-nums;
}

.smart-mode .inline-divider {
  color: var(--smart-faint);
  font-size: 11px;
}

.smart-mode .muted-note {
  min-height: var(--ctrl-height);
  display: flex;
  align-items: center;
  padding: 0 var(--ctrl-xpad);
  color: var(--smart-faint);
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: var(--ctrl-font);
  line-height: 1.35;
}

.smart-mode .composer-actions {
  grid-area: run;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
}

.smart-mode .run-button,
.smart-mode .run-btn {
  display: flex;
  width: auto;
  min-width: 118px;
  height: var(--ctrl-height);
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 0 12px;
  color: var(--smart-strong-text);
  background: var(--smart-strong);
  border: 0;
  border-radius: 999px;
  font-size: var(--ctrl-font);
  font-weight: 500;
}

.smart-mode .run-btn:hover:not(:disabled) {
  box-shadow: 0 6px 14px var(--smart-shadow);
  transform: translateY(-1px);
}

.smart-mode .run-btn svg {
  width: var(--ctrl-icon);
  height: var(--ctrl-icon);
}

.smart-mode .composer-status {
  grid-area: status;
  min-height: 16px;
  margin: -2px 2px 0;
  color: var(--smart-faint);
  font-size: 10.5px;
  font-weight: 600;
}

.smart-mode .composer-status:empty {
  display: none;
}

.smart-mode .composer-status[data-tone="error"] {
  color: #dc2626;
}

.smart-mode .composer-status[data-tone="ok"] {
  color: #16a34a;
}

.smart-mode .context-menu {
  position: fixed;
  z-index: 100;
  width: 302px;
  padding: 8px;
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 18px;
  box-shadow: 0 20px 56px var(--smart-shadow);
  backdrop-filter: blur(20px);
}

.smart-mode .context-menu.hidden {
  display: none !important;
}

.smart-mode .create-menu-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.smart-mode .create-card {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  width: 100%;
  min-height: 52px;
  padding: 8px;
  color: var(--smart-text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 13px;
  text-align: left;
}

.smart-mode .create-card:hover {
  background: var(--smart-card);
  border-color: var(--smart-line);
  transform: translateY(-1px);
}

.smart-mode .create-card-icon {
  display: flex;
  width: 36px;
  height: 36px;
  align-items: center;
  justify-content: center;
  color: var(--smart-strong);
  background: var(--smart-soft);
  border: 1px solid var(--smart-line);
  border-radius: 12px;
}

.smart-mode .create-card-icon svg {
  width: 17px;
  height: 17px;
}

.smart-mode .create-card-title {
  display: block;
  color: var(--smart-text);
  font-size: 12px;
  font-weight: 850;
}

.smart-mode .create-card-sub {
  display: block;
  min-width: 0;
  overflow: hidden;
  color: var(--smart-faint);
  font-size: 10.5px;
  font-style: normal;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-mode .asset-library-panel.asset-panel {
  position: absolute;
  right: 22px;
  top: 66px;
  bottom: 168px;
  z-index: 85;
  display: flex;
  width: 300px;
  max-width: calc(100vw - 44px);
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  color: var(--smart-text);
  background: var(--smart-panel);
  border: 1px solid var(--smart-line);
  border-radius: 18px;
  box-shadow: 0 22px 58px var(--smart-shadow);
  backdrop-filter: blur(20px);
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
  visibility: visible;
}

.smart-mode .asset-library-panel.hidden {
  display: none !important;
}

.smart-mode .asset-library-header,
.smart-mode .asset-library-tools,
.smart-mode .asset-library-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0;
  border: 0;
}

.smart-mode .asset-library-header {
  justify-content: space-between;
}

.smart-mode .asset-library-header h2 {
  margin: 0;
  color: var(--smart-text);
  font-size: 12px;
  font-weight: 850;
}

.smart-mode .asset-library-header p {
  margin: 3px 0 0;
  color: var(--smart-faint);
  font-size: 10.5px;
  font-weight: 650;
}

.smart-mode .asset-library-tools select {
  min-width: 0;
  flex: 1;
  height: 30px;
  padding: 0 8px;
  color: var(--smart-text);
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  border-radius: 10px;
  outline: none;
  font-size: 11px;
}

.smart-mode .asset-library-actions {
  justify-content: space-between;
}

.smart-mode .asset-library-actions .pill-button {
  height: 30px;
  min-height: 30px;
  padding: 0 10px;
  color: var(--smart-muted);
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  box-shadow: none;
  font-size: 11px;
  font-weight: 750;
}

.smart-mode .asset-grid {
  min-height: 0;
  flex: 1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
  overflow: auto;
  padding: 0 2px 0 0;
}

.smart-mode .asset-card {
  min-width: 0;
  overflow: hidden;
  background: var(--smart-card);
  border: 1px solid var(--smart-line);
  border-radius: 12px;
}

.smart-mode .asset-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  padding: 0;
  background: var(--smart-soft);
  border: 0;
}

.smart-mode .asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.smart-mode .asset-card-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 6px;
}

.smart-mode .asset-card-meta strong {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--smart-text);
  font-size: 10.5px;
  font-weight: 600;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.smart-mode .asset-empty {
  grid-column: 1 / -1;
  min-height: 120px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  color: var(--smart-faint);
  background: var(--smart-soft);
  border: 1px dashed var(--smart-line);
  border-radius: 14px;
  font-size: 11px;
  font-weight: 650;
  line-height: 1.5;
  text-align: center;
}

.smart-mode .icon-button,
.smart-mode .node-icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.smart-mode .asset-library-panel .icon-button {
  width: 26px;
  height: 26px;
  color: var(--smart-muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 9px;
}

.smart-mode .asset-library-panel .icon-button:hover {
  color: var(--smart-text);
  background: var(--smart-card);
  border-color: var(--smart-line);
}

.smart-mode .asset-library-panel .icon-button svg {
  width: 13px;
  height: 13px;
}

.smart-mode .drop-overlay {
  color: var(--smart-text);
  background: rgba(248, 250, 252, 0.64);
  backdrop-filter: blur(12px);
}

.theme-dark .smart-mode .drop-overlay,
.smart-mode.theme-dark .drop-overlay {
  background: rgba(2, 6, 23, 0.54);
}

@media (max-width: 760px) {
  .smart-mode .composer {
    width: min(540px, calc(100vw - 28px)) !important;
  }

  .smart-mode .composer-card {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .smart-mode .smart-minimap {
    width: 148px;
    height: 98px;
  }

  .smart-mode .smart-log-toggle span,
  .smart-mode .asset-toggle span,
  .smart-mode .smart-back span {
    display: none;
  }

  .smart-mode .smart-log-toggle {
    right: 80px;
  }
}

.account-card {
  display: flex;
  width: 100%;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
  margin-top: auto;
  padding: 9px;
  background: #fff;
  border: 1px solid #e8edf5;
  border-radius: 8px;
}

.account-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
  color: #fff;
  background: #111827;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 900;
}

.account-meta {
  display: grid;
  min-width: 0;
  gap: 1px;
  flex: 1;
}

.account-meta strong {
  overflow: hidden;
  color: #111827;
  font-size: 13px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-meta span {
  color: #52657d;
  font-size: 11px;
  font-weight: 800;
}

.account-card button {
  flex: 0 0 auto;
  height: 28px;
  padding: 0 7px;
  color: #64748b;
  background: #f8fafc;
  border: 1px solid #e5ebf3;
  border-radius: 7px;
  font-size: 11px;
  font-weight: 800;
}

.account-card button:hover {
  color: #111827;
}

.account-recharge {
  display: inline-flex;
  width: 100%;
  min-height: 34px;
  align-items: center;
  justify-content: center;
  gap: 7px;
  flex: 0 0 100%;
  color: #2563eb;
  background: #eff6ff;
  border: 1px solid #dbeafe;
  border-radius: 7px;
  font-size: 12px;
  font-weight: 900;
  text-decoration: none;
}

.account-recharge:hover {
  color: #fff;
  background: #2563eb;
  border-color: #2563eb;
}

.recharge-page .account-card .account-recharge,
.account-card .account-recharge[aria-current="page"] {
  color: #fff;
  background: #2563eb;
  border-color: #2563eb;
}

.account-recharge svg {
  width: 14px;
  height: 14px;
}

.points-pill,
.billing-toggle {
  display: inline-flex;
  height: 36px;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 12px;
  color: #52657d;
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid #dfe8f3;
  border-radius: 999px;
  box-shadow: 0 8px 22px rgba(31, 41, 55, 0.06);
  font-size: 13px;
  font-weight: 900;
  text-decoration: none;
  white-space: nowrap;
}

.points-pill b,
.billing-toggle b {
  color: #111827;
}

.billing-toggle {
  position: absolute;
  right: 138px;
  top: 22px;
  z-index: 90;
  color: var(--smart-text);
  background: var(--smart-panel);
  border-color: var(--smart-line);
  box-shadow: 0 20px 52px var(--smart-shadow);
  backdrop-filter: blur(20px);
}

.billing-toggle:hover {
  border-color: var(--smart-text);
  transform: translateY(-1px);
}

.billing-toggle svg {
  width: 16px;
  height: 16px;
}

.smart-mode .smart-log-toggle {
  right: 278px;
}

.smart-mode .asset-toggle {
  right: 22px;
}

.smart-actions-bar {
  position: absolute;
  top: 22px;
  right: 22px;
  z-index: 95;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: calc(100vw - 220px);
}

.smart-mode .smart-actions-bar .smart-log-toggle,
.smart-mode .smart-actions-bar .billing-toggle,
.smart-mode .smart-actions-bar .asset-toggle {
  position: static;
  inset: auto;
  flex: 0 0 auto;
}

.smart-mode .smart-actions-bar .billing-toggle {
  min-width: 0;
  max-width: min(280px, 34vw);
}

.smart-mode .smart-actions-bar .billing-toggle > span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.login-page {
  display: grid;
  min-height: 100vh;
  place-items: center;
  background-color: #fbfdff;
  background-image: radial-gradient(circle, #d8e7f6 1.15px, transparent 1.2px);
  background-size: 24px 24px;
}

.login-shell {
  width: min(420px, calc(100vw - 32px));
}

.login-panel {
  padding: 28px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  box-shadow: 0 22px 54px rgba(31, 41, 55, 0.12);
}

.login-brand {
  margin-bottom: 24px;
  color: #111827;
  font-size: 20px;
  font-weight: 900;
}

.login-copy h1,
.billing-header h1 {
  margin: 0;
  color: #111827;
  font-size: 24px;
  line-height: 1.15;
}

.login-copy p,
.billing-header p {
  margin: 8px 0 0;
  color: #7c8798;
  font-size: 13px;
  font-weight: 700;
}

.login-form {
  display: grid;
  gap: 14px;
  margin-top: 24px;
}

.login-form label {
  display: grid;
  gap: 7px;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.login-form input {
  height: 42px;
  padding: 0 12px;
  color: #111827;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
  outline: none;
  font-weight: 800;
}

.login-form input:focus {
  border-color: #9bb7f5;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.login-submit {
  width: 100%;
}

.billing-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  display: grid;
  width: min(900px, calc(100% - 64px));
  max-height: calc(100vh - 56px);
  gap: 18px;
  padding: 26px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  box-shadow: 0 22px 54px rgba(31, 41, 55, 0.12);
  transform: translate(-50%, -50%);
}

.billing-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.billing-balance {
  display: grid;
  min-width: 132px;
  gap: 3px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  text-align: right;
}

.billing-balance span,
.billing-summary span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.billing-balance strong {
  color: #111827;
  font-size: 24px;
  line-height: 1;
}

.billing-summary {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}

.billing-summary div {
  display: grid;
  gap: 4px;
  padding: 12px;
  background: #f8fafc;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
}

.billing-summary strong {
  color: #111827;
  font-size: 14px;
}

.billing-list {
  display: grid;
  gap: 8px;
  min-height: 160px;
  overflow: auto;
  padding-right: 2px;
}

.billing-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  padding: 12px;
  background: #fff;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
}

.billing-row.credit {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.billing-row strong {
  color: #111827;
  font-size: 14px;
}

.billing-row p {
  margin: 5px 0 0;
  color: #64748b;
  font-size: 12px;
  font-weight: 700;
}

.billing-row-meta {
  display: grid;
  gap: 4px;
  text-align: right;
  white-space: nowrap;
}

.billing-row-meta time,
.billing-row-meta span {
  color: #7c8798;
  font-size: 12px;
  font-weight: 700;
}

.billing-row-meta b {
  color: #dc2626;
  font-size: 14px;
}

.billing-row.credit .billing-row-meta b {
  color: #16a34a;
}

.billing-empty {
  display: grid;
  min-height: 160px;
  place-items: center;
  color: #64748b;
  background: #f8fafc;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  font-weight: 800;
}

.text2image-panel,
.feature-panel {
  display: grid;
  width: min(1120px, calc(100% - 64px));
  min-height: calc(100vh - 56px);
  gap: 16px;
  margin: 28px auto;
  padding: 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  box-shadow: 0 22px 54px rgba(31, 41, 55, 0.12);
}

.text2image-header,
.feature-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.text2image-header h1,
.feature-header h1 {
  margin: 0;
  color: #111827;
  font-size: 24px;
  line-height: 1.15;
}

.text2image-header p,
.feature-header p {
  margin: 8px 0 0;
  color: #7c8798;
  font-size: 13px;
  font-weight: 700;
}

.text2image-layout,
.prompt-assistant-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(320px, 0.98fr);
  align-items: stretch;
  gap: 16px;
  min-height: 0;
}

.text2image-form,
.prompt-assistant-form,
.prompt-output-card,
.text2image-results {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 0;
  padding: 14px;
  background: #f8fafc;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
}

.text2image-form {
  padding-bottom: 16px;
}

.text2image-form label,
.prompt-assistant-form label {
  display: grid;
  gap: 7px;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.text2image-form textarea,
.prompt-assistant-form textarea,
.prompt-output-card textarea {
  width: 100%;
  min-height: 150px;
  resize: vertical;
  padding: 12px;
  color: #111827;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
  outline: none;
  font-weight: 700;
  line-height: 1.6;
}

.prompt-output-card textarea {
  min-height: 330px;
  resize: none;
}

.text2image-form textarea:focus,
.prompt-assistant-form textarea:focus {
  border-color: #9bb7f5;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.prompt-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-presets button {
  min-height: 32px;
  padding: 0 11px;
  color: #52657d;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.prompt-presets button:hover {
  color: #111827;
  border-color: #b8c7dc;
}

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

.text2image-grid select {
  width: 100%;
  height: 38px;
  padding: 0 10px;
  color: #111827;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
  outline: none;
  font-weight: 800;
}

.text2image-run {
  display: inline-flex;
  height: 42px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 2px;
  position: relative;
  z-index: 1;
  color: #fff;
  background: #111827;
  border: 1px solid #111827;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 900;
}

.text2image-run:disabled {
  cursor: wait;
  opacity: 0.72;
}

.text2image-results-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.text2image-results-head strong {
  color: #111827;
  font-size: 14px;
}

.text2image-results-head button,
.text2image-results-head a {
  color: #64748b;
  background: transparent;
  border: 0;
  font-size: 12px;
  font-weight: 800;
  text-decoration: none;
}

.text-image-grid,
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
  min-height: 240px;
  overflow: auto;
}

.text-image-card,
.gallery-card {
  overflow: hidden;
  background: #fff;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
}

.text-image-card img,
.gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #eef2f7;
}

.text-image-card div,
.gallery-card div {
  display: grid;
  gap: 4px;
  padding: 10px;
}

.text-image-card strong,
.gallery-card strong {
  overflow: hidden;
  color: #111827;
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-image-card span,
.gallery-card span {
  overflow: hidden;
  color: #64748b;
  font-size: 11px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-image-empty {
  grid-column: 1 / -1;
  display: grid;
  min-height: 220px;
  place-items: center;
  gap: 8px;
  color: #64748b;
  background: #fff;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  font-weight: 800;
  text-align: center;
}

.gallery-panel {
  width: min(1180px, calc(100% - 64px));
}

.gallery-grid {
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
}

.recharge-panel {
  display: grid;
  width: min(1060px, calc(100% - 64px));
  min-height: calc(100vh - 56px);
  gap: 18px;
  margin: 28px auto;
  padding: 24px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  box-shadow: 0 22px 54px rgba(31, 41, 55, 0.12);
}

.recharge-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.recharge-header h1 {
  margin: 0;
  color: #111827;
  font-size: 24px;
  line-height: 1.15;
}

.recharge-header p {
  margin: 8px 0 0;
  color: #7c8798;
  font-size: 13px;
  font-weight: 700;
}

.recharge-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.84fr);
  gap: 16px;
  align-items: stretch;
}

.recharge-card {
  display: grid;
  align-content: start;
  gap: 16px;
  padding: 16px;
  background: #f8fafc;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
}

.recharge-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.recharge-section-head strong {
  color: #111827;
  font-size: 15px;
}

.recharge-section-head span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

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

.recharge-package,
.pay-method {
  display: grid;
  gap: 6px;
  min-height: 82px;
  padding: 14px;
  color: #111827;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
  text-align: left;
}

.recharge-package strong {
  font-size: 18px;
  line-height: 1.15;
}

.recharge-package span {
  color: #2563eb;
  font-size: 13px;
  font-weight: 900;
}

.recharge-package.active,
.pay-method.active {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.08);
}

.custom-recharge {
  display: grid;
  gap: 8px;
  color: #64748b;
  font-size: 13px;
  font-weight: 800;
}

.custom-recharge input {
  height: 42px;
  padding: 0 12px;
  color: #111827;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
  outline: none;
  font-weight: 800;
}

.custom-recharge input:focus {
  border-color: #9bb7f5;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

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

.pay-method {
  min-height: 64px;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
}

.pay-method span {
  font-size: 14px;
  font-weight: 900;
}

.pay-brand-icon {
  position: relative;
  display: inline-grid;
  width: 32px;
  height: 32px;
  flex: 0 0 auto;
  place-items: center;
}

.pay-method .pay-brand-icon {
  font-size: 16px;
  font-weight: 950;
}

.wechat-icon span {
  position: absolute;
  display: block;
  border-radius: 999px;
}

.wechat-icon span:first-child {
  left: 2px;
  top: 4px;
  width: 22px;
  height: 17px;
  background: #20c05c;
}

.wechat-icon span:first-child::before,
.wechat-icon span:first-child::after,
.wechat-icon span:nth-child(2)::before,
.wechat-icon span:nth-child(2)::after {
  position: absolute;
  top: 6px;
  width: 3px;
  height: 3px;
  background: #fff;
  border-radius: 50%;
  content: "";
}

.wechat-icon span:first-child::before {
  left: 6px;
}

.wechat-icon span:first-child::after {
  right: 6px;
}

.wechat-icon span:nth-child(2) {
  right: 1px;
  bottom: 4px;
  width: 21px;
  height: 16px;
  background: #12a64a;
  box-shadow: 0 0 0 2px #fff;
}

.wechat-icon span:nth-child(2)::before {
  left: 6px;
}

.wechat-icon span:nth-child(2)::after {
  right: 6px;
}

.wechat-icon::after {
  position: absolute;
  left: 6px;
  bottom: 3px;
  width: 0;
  height: 0;
  border-top: 6px solid #20c05c;
  border-right: 7px solid transparent;
  content: "";
}

.alipay-icon {
  color: #fff;
  background: #1677ff;
  border-radius: 8px;
  box-shadow: inset 0 -2px 0 rgba(15, 23, 42, 0.12);
  font-family: "Microsoft YaHei", Inter, sans-serif;
  line-height: 1;
}

.alipay-icon::after {
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 6px;
  height: 3px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 999px;
  transform: rotate(-14deg);
  content: "";
}

.payment-card {
  justify-items: stretch;
}

.payment-summary {
  display: grid;
  gap: 5px;
  padding: 14px;
  background: #fff;
  border: 1px solid #e5ebf3;
  border-radius: 8px;
  text-align: center;
}

.payment-summary span {
  color: #64748b;
  font-size: 12px;
  font-weight: 800;
}

.payment-summary strong {
  color: #111827;
  font-size: 24px;
  line-height: 1.15;
}

.payment-summary em {
  color: #2563eb;
  font-size: 14px;
  font-style: normal;
  font-weight: 900;
}

.fake-payment-qr {
  display: grid;
  min-height: 260px;
  place-items: center;
  gap: 12px;
  padding: 22px;
  background: #fff;
  border: 1px solid #dfe8f3;
  border-radius: 8px;
  text-align: center;
}

.fake-payment-qr strong {
  color: #111827;
  font-size: 15px;
}

.fake-payment-qr small {
  color: #64748b;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0;
}

.fake-qr-grid {
  display: grid;
  grid-template-columns: repeat(29, 5px);
  grid-template-rows: repeat(29, 5px);
  gap: 2px;
  padding: 14px;
  background: #fff;
  border: 10px solid #f8fafc;
  border-radius: 8px;
  box-shadow:
    0 0 0 1px #dfe8f3,
    0 16px 38px rgba(15, 23, 42, 0.08);
}

.fake-qr-grid span {
  display: block;
  background: transparent;
  border-radius: 1px;
}

.fake-qr-grid span.is-filled {
  background: #111827;
}

.fake-payment-qr[data-method="wechat"] .fake-qr-grid span.is-filled {
  background: #16a34a;
}

.fake-payment-qr[data-method="alipay"] .fake-qr-grid span.is-filled {
  background: #1677ff;
}

.payment-actions {
  display: grid;
  gap: 10px;
}

@media (max-height: 780px) and (min-width: 861px) {
  .text2image-panel {
    min-height: auto;
    margin-top: 18px;
    margin-bottom: 18px;
    padding: 18px;
  }

  .text2image-header {
    gap: 12px;
  }

  .text2image-header h1 {
    font-size: 22px;
  }

  .text2image-header p {
    margin-top: 6px;
  }

  .text2image-form,
  .text2image-results {
    gap: 8px;
    padding: 12px;
  }

  .text2image-form {
    padding-bottom: 14px;
  }

  .text2image-form textarea {
    min-height: 124px;
  }

  .prompt-presets {
    gap: 6px;
  }

  .prompt-presets button {
    min-height: 30px;
  }

  .text2image-grid select {
    height: 36px;
  }

  .text2image-run {
    height: 40px;
  }
}

@media (max-height: 700px) and (min-width: 861px) {
  .text2image-layout {
    grid-template-columns: minmax(0, 1fr) minmax(300px, 0.92fr);
  }

  .text2image-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .text2image-form textarea {
    min-height: 108px;
  }
}

@media (max-height: 620px) and (min-width: 861px) {
  .text2image-grid {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .account-card {
    display: none;
  }

  .billing-panel {
    top: 50%;
    width: calc(100% - 28px);
    padding: 18px;
  }

  .text2image-panel,
  .feature-panel {
    top: 50%;
    width: calc(100% - 28px);
    padding: 18px;
  }

  .billing-header,
  .billing-row,
  .text2image-header,
  .feature-header {
    grid-template-columns: 1fr;
  }

  .billing-header,
  .text2image-header,
  .feature-header {
    display: grid;
  }

  .billing-balance,
  .billing-row-meta {
    text-align: left;
  }

  .billing-summary {
    grid-template-columns: 1fr;
  }

  .text2image-layout,
  .prompt-assistant-layout,
  .text2image-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .smart-actions-bar {
    max-width: calc(100vw - 92px);
    gap: 8px;
  }

  .smart-actions-bar .billing-toggle span,
  .smart-actions-bar .smart-log-toggle span,
  .smart-actions-bar .asset-toggle span {
    display: none;
  }

  .smart-actions-bar .billing-toggle,
  .smart-actions-bar .smart-log-toggle,
  .smart-actions-bar .asset-toggle {
    width: 40px;
    padding: 0;
  }

  .smart-mode .smart-actions-bar .smart-log-toggle,
  .smart-mode .smart-actions-bar .billing-toggle,
  .smart-mode .smart-actions-bar .asset-toggle {
    position: static;
    right: auto;
  }
}
