:root {
  --bg:           #0d0d0d;
  --fg:           #f5f0e8;
  --dim:          rgba(245, 240, 232, 0.32);
  --muted:        rgba(245, 240, 232, 0.58);
  --line:         rgba(245, 240, 232, 0.08);
  --line-strong:  rgba(255, 107, 53, 0.35);
  --accent:       #ff6b35;
  --panel:        rgba(255, 255, 255, 0.03);
  --panel-hover:  rgba(255, 107, 53, 0.05);
  --surface:      rgba(0, 0, 0, 0.6);
  --safe:         #3ecf8e;
  --kill:         #e84040;
  --coord:        rgba(245, 240, 232, 0.22);
  --blur:         blur(10px);
  --topbar-h:     56px;
  --statusbar-h:  30px;
}

/* ─── FONTS ───────────────────────────────────────────────────── */
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 400;
  src: url('./fonts/space-grotesk-latin-400.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 500;
  src: url('./fonts/space-grotesk-latin-500.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 600;
  src: url('./fonts/space-grotesk-latin-600.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
  font-display: swap;
}
@font-face {
  font-family: 'Space Grotesk';
  font-style: normal;
  font-weight: 700;
  src: url('./fonts/space-grotesk-latin-700.woff2') format('woff2');
  unicode-range: U+0000-00FF,U+0131,U+0152-0153,U+02BB-02BC,U+02C6,U+02DA,U+02DC,U+0300-0301,U+0303-0304,U+0308-0309,U+0323,U+0329,U+2000-206F,U+2074,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD;
  font-display: swap;
}
@font-face {
  font-family: 'Noto Sans SC';
  font-style: normal;
  font-weight: 400;
  src: url('./fonts/noto-sans-sc-chinese-simplified-400-normal.woff2') format('woff2');
  font-display: swap;
}
@font-face {
  font-family: 'Noto Sans SC';
  font-style: normal;
  font-weight: 500;
  src: url('./fonts/noto-sans-sc-chinese-simplified-400-normal.woff2') format('woff2');
  font-display: swap;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  color: var(--fg);
  background: var(--bg);
  font-family: 'Space Grotesk', 'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
  height: 100vh;
  width: 100vw;
}

a { color: inherit; text-decoration: none; }

/* ─── TOPBAR ─────────────────────────────────────────────────── */
.topbar {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 10;
  height: var(--topbar-h);
  background: rgba(13, 13, 13, 0.92);
  backdrop-filter: var(--blur);
  border-bottom: 1px solid var(--line);
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  overflow: hidden;
  flex-shrink: 1;
}

.topbar-brand {
  display: flex;
  flex-direction: column;
  gap: 1px;
  flex: 0 0 auto;
}

.topbar-brand h1 {
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--fg);
  white-space: nowrap;
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
}

.topbar-brand p {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
}

.topbar-divider {
  width: 1px;
  height: 24px;
  background: var(--line);
  flex: 0 0 auto;
}

.topbar-canvas-controls {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.topbar-canvas-controls select {
  max-width: 150px;
  min-height: 28px;
  padding: 4px 24px 4px 8px;
  font-size: 11px;
}

.topbar-canvas-controls input {
  max-width: 130px;
  min-height: 28px;
  padding: 4px 8px;
  font-size: 11px;
}

.topbar-canvas-controls .ghost-button {
  min-height: 28px;
  padding: 0 10px;
  font-size: 11px;
  white-space: nowrap;
}

.icon-button {
  padding: 0 8px !important;
  font-size: 14px !important;
  letter-spacing: 0 !important;
}

.topbar-center {
  display: flex;
  align-items: center;
  justify-content: center;
}

.canvas-meta-center {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--dim);
  text-align: center;
  white-space: nowrap;
}

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

.status-chip {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border: 1px solid var(--line);
  font-size: 10px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  background: var(--panel);
  white-space: nowrap;
  font-family: 'Space Grotesk', sans-serif;
}

.status-chip.loaded {
  border-color: rgba(62, 207, 142, 0.3);
  color: var(--safe);
}

/* ─── BUTTONS ────────────────────────────────────────────────── */
.ghost-button,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(245, 240, 232, 0.18);
  background: transparent;
  color: var(--fg);
  font-family: inherit;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 160ms ease, color 160ms ease, background 160ms ease;
  border-radius: 2px;
  white-space: nowrap;
}

.ghost-button:hover,
button:hover {
  border-color: rgba(255, 107, 53, 0.55);
  color: var(--accent);
  background: rgba(255, 107, 53, 0.04);
}

button.btn-primary {
  background: var(--accent);
  color: #0d0d0d;
  border-color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.24em;
}

button.btn-primary:hover {
  background: var(--fg);
  border-color: var(--fg);
  color: #0d0d0d;
}

button.btn-stop {
  border-color: rgba(232, 64, 64, 0.45);
  color: var(--kill);
  background: rgba(232, 64, 64, 0.06);
  font-weight: 700;
}

button.btn-stop:hover:not(:disabled) {
  border-color: rgba(232, 64, 64, 0.8);
  color: #fff;
  background: rgba(232, 64, 64, 0.18);
}

button.btn-stop:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.danger-button {
  border-color: rgba(232, 64, 64, 0.35);
  color: var(--kill);
}

.danger-button:hover {
  border-color: rgba(232, 64, 64, 0.7);
  color: #fff;
  background: rgba(232, 64, 64, 0.12);
}

button.danger-confirm {
  border-color: rgba(232, 64, 64, 0.55);
  color: #fff;
  background: rgba(232, 64, 64, 0.2);
  font-weight: 700;
}

button.danger-confirm:hover {
  border-color: rgba(232, 64, 64, 0.9);
  background: rgba(232, 64, 64, 0.35);
}

button:disabled,
button:disabled:hover {
  cursor: not-allowed;
  opacity: 0.5;
  border-color: rgba(245, 240, 232, 0.1);
  background: rgba(255, 255, 255, 0.02);
  color: var(--dim);
}

/* ─── CANVAS — Full-screen absolute mother layer ─────────────── */
.workspace {
  position: fixed;
  inset: 0;
  z-index: 1;
}

.canvas-panel {
  position: absolute;
  top: var(--topbar-h);
  left: 0;
  right: 0;
  bottom: var(--statusbar-h);
  z-index: 1;
}

.canvas {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  cursor: grab;
  background:
    linear-gradient(rgba(245, 240, 232, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245, 240, 232, 0.04) 1px, transparent 1px),
    linear-gradient(rgba(245, 240, 232, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(245, 240, 232, 0.015) 1px, transparent 1px),
    radial-gradient(circle at 50% -5%, rgba(255, 107, 53, 0.08), transparent 26%),
    var(--bg);
  background-size: 80px 80px, 80px 80px, 20px 20px, 20px 20px, auto, auto;
}

.canvas.panning {
  cursor: grabbing;
}

.canvas-pan {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  transform-origin: 0 0;
}

/* ─── MINIMAP OVERLAYS ───────────────────────────────────────── */
.minimap {
  position: absolute;
  z-index: 5;
  background: rgba(13, 13, 13, 0.45);
  backdrop-filter: blur(8px);
  border: 1px solid var(--line);
  pointer-events: auto;
  cursor: crosshair;
}

.minimap-v {
  top: 12px;
  bottom: 12px;
  right: 352px; /* 340 sidepanel + 12 gap */
  width: 44px;
  border-radius: 4px;
}

.minimap-h {
  left: 12px;
  right: 408px; /* 340 sidepanel + 12 gap + 44 v-minimap + 12 gap */
  bottom: 12px;
  height: 44px;
  border-radius: 4px;
}

.minimap-viewport {
  position: absolute;
  z-index: 2;
  border: 1.5px solid var(--accent);
  background: rgba(255, 107, 53, 0.08);
  border-radius: 2px;
  pointer-events: none;
}

.minimap-content {
  position: absolute;
  inset: 0;
  overflow: hidden;
  z-index: 1;
}

.minimap-dot {
  position: absolute;
  background: rgb(var(--nc, 100, 100, 100));
  opacity: 0.85;
  border-radius: 1px;
}

/* ─── SIDE PANEL ─────────────────────────────────────────────── */
.sidepanel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  bottom: var(--statusbar-h);
  width: 340px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  background: rgba(13, 13, 13, 0.92);
  backdrop-filter: var(--blur);
  border-left: 1px solid var(--line);
}

/* ─── MESSAGE LIST ───────────────────────────────────────────── */
.message-list-wrap {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
}

.message-list-wrap::-webkit-scrollbar { width: 3px; }
.message-list-wrap::-webkit-scrollbar-track { background: transparent; }
.message-list-wrap::-webkit-scrollbar-thumb { background: rgba(245, 240, 232, 0.1); border-radius: 2px; }

.message-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
  justify-content: flex-end;
}

.message-empty {
  font-size: 12px;
  color: var(--dim);
  text-align: center;
  padding: 24px 0;
  letter-spacing: 0.05em;
  line-height: 1.7;
}

/* Chat bubbles */
.msg {
  display: flex;
  flex-direction: column;
  gap: 3px;
  animation: msg-in 0.2s ease;
}

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

.msg-user {
  align-items: flex-end;
}

.msg-agent {
  align-items: flex-start;
}

.msg-label {
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
  padding: 0 4px;
}

.msg-bubble {
  max-width: 92%;
  padding: 9px 12px;
  border-radius: 3px;
  font-size: 13px;
  line-height: 1.65;
  word-break: break-word;
  white-space: pre-wrap;
}

.msg-user .msg-bubble {
  background: rgba(255, 107, 53, 0.15);
  border: 1px solid rgba(255, 107, 53, 0.3);
  color: var(--fg);
}

.msg-agent .msg-bubble {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--muted);
}

.msg-agent.msg-error .msg-bubble {
  background: rgba(232, 64, 64, 0.08);
  border-color: rgba(232, 64, 64, 0.25);
  color: var(--kill);
}

.msg-agent.msg-success .msg-bubble {
  background: rgba(62, 207, 142, 0.07);
  border-color: rgba(62, 207, 142, 0.2);
  color: var(--safe);
}

/* ─── CHAT STREAMING BUBBLE ─────────────────────────────────── */
.msg-streaming .msg-bubble {
  border-color: rgba(255, 107, 53, 0.3);
}

.chat-tool-status {
  font-size: 10px;
  letter-spacing: 0.06em;
  color: var(--dim);
  margin-bottom: 6px;
  padding: 3px 6px;
  background: rgba(255, 107, 53, 0.06);
  border: 1px solid rgba(255, 107, 53, 0.15);
  border-radius: 2px;
}

.chat-tool-status.hidden {
  display: none;
}

.chat-content {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg);
  line-height: 1.65;
}

/* markdown rendered content inside chat bubble */
.chat-content p  { margin: 0 0 0.5em; }
.chat-content p:last-child { margin-bottom: 0; }
.chat-content ul, .chat-content ol { padding-left: 1.4em; margin: 0.4em 0; }
.chat-content code { font-family: inherit; background: rgba(255,255,255,0.07); padding: 1px 4px; border-radius: 2px; }
.chat-content pre  { background: rgba(255,255,255,0.05); padding: 8px 10px; border-radius: 3px; overflow-x: auto; }
.chat-content h1, .chat-content h2, .chat-content h3 { margin: 0.6em 0 0.3em; font-weight: 600; }
.chat-content strong { color: var(--fg); }
.chat-content a { color: var(--accent); }

.chat-cursor {
  display: inline-block;
  color: var(--accent);
  animation: cursor-blink 0.8s steps(1) infinite;
  margin-left: 1px;
  font-size: 0.9em;
}

@keyframes cursor-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* ── Agent question (awaiting_input) ─────────────────────────────────────── */
.msg-agent.msg-question .msg-bubble {
  background: rgba(155, 109, 255, 0.08);
  border-color: rgba(155, 109, 255, 0.35);
  border-left: 3px solid rgb(155, 109, 255);
  color: var(--fg);
}

/* ─── CONFIRM BUBBLE ────────────────────────────────────────── */
.confirm-bubble {
  background: rgba(255, 160, 50, 0.08) !important;
  border-color: rgba(255, 160, 50, 0.4) !important;
  border-left: 3px solid rgb(255, 160, 50) !important;
}
.confirm-desc {
  margin-bottom: 10px;
  line-height: 1.5;
}
.confirm-actions {
  display: flex;
  gap: 8px;
}
.confirm-yes-btn {
  padding: 5px 14px;
  font-size: 12px;
  background: rgba(255, 80, 80, 0.18);
  border: 1px solid rgba(255, 80, 80, 0.5);
  color: rgb(255, 120, 120);
  border-radius: 4px;
  cursor: pointer;
  transition: background 150ms;
}
.confirm-yes-btn:hover {
  background: rgba(255, 80, 80, 0.32);
}
.confirm-no-btn {
  padding: 5px 14px;
  font-size: 12px;
  background: transparent;
  border: 1px solid rgba(245, 240, 232, 0.15);
  color: rgba(245, 240, 232, 0.5);
  border-radius: 4px;
  cursor: pointer;
  transition: background 150ms;
}
.confirm-no-btn:hover {
  background: rgba(245, 240, 232, 0.06);
}

/* ─── ACTIVITY / TOOL CARDS ──────────────────────────────────── */
.msg-agent.msg-activity .msg-bubble,
.msg-agent.msg-tool .msg-bubble,
.msg-agent.msg-asset .msg-bubble {
  max-width: 96%;
  background: rgba(255, 255, 255, 0.02);
  border-color: rgba(245, 240, 232, 0.08);
  padding: 10px 12px;
}

.msg-agent.msg-tool .msg-bubble {
  border-left: 3px solid rgba(0, 201, 192, 0.8);
}

.msg-agent.msg-asset .msg-bubble {
  border-left: 3px solid rgba(255, 107, 138, 0.85);
}

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

.activity-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dim);
  flex: 0 0 auto;
}

.activity-title {
  font-size: 12px;
  color: var(--fg);
  letter-spacing: 0.06em;
  line-height: 1.5;
}

.activity-body {
  margin-top: 6px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}

.activity-meta {
  margin-top: 7px;
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--dim);
}

.activity-body.hidden,
.activity-meta.hidden {
  display: none;
}

.msg-agent.activity-active .msg-bubble {
  border-color: rgba(245, 240, 232, 0.16);
}

.msg-agent.activity-active .activity-dot {
  background: var(--accent);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.msg-agent.activity-done .activity-dot {
  background: var(--safe);
}

.msg-agent.activity-waiting .msg-bubble {
  border-color: rgba(155, 109, 255, 0.35);
}

.msg-agent.activity-waiting .activity-dot {
  background: rgb(155, 109, 255);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.msg-agent.activity-error .msg-bubble {
  border-color: rgba(232, 64, 64, 0.4);
}

.msg-agent.activity-error .activity-dot {
  background: var(--kill);
}

/* ─── TYPING INDICATOR ───────────────────────────────────────── */
.msg-agent.msg-typing .msg-bubble {
  background: rgba(255, 255, 255, 0.04);
  border-color: var(--line);
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 8px 12px;
  min-height: 0;
}
.typing-text {
  font-size: 11px;
  color: var(--fg-dim, rgba(255,255,255,0.45));
  letter-spacing: 0.02em;
}
.typing-dots {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  animation: typing-bounce 1.2s infinite ease-in-out;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.35; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* ─── COMPOSER ───────────────────────────────────────────────── */
.composer-panel {
  flex: 0 0 auto;
  border-top: 1px solid var(--line);
  padding: 10px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: rgba(0, 0, 0, 0.3);
  transition: border-top-color 200ms ease;
}

/* Reply mode: purple accent to signal awaiting_input */
.composer-panel.reply-mode {
  border-top-color: rgba(155, 109, 255, 0.6);
  background: rgba(155, 109, 255, 0.04);
}
.composer-panel.reply-mode textarea {
  border-color: rgba(155, 109, 255, 0.3);
}
.composer-panel.reply-mode #submit-run {
  background: rgb(155, 109, 255);
  border-color: rgb(155, 109, 255);
  color: #0d0d0d;
}
.composer-panel.reply-mode #submit-run:hover {
  background: rgb(135, 89, 235);
  border-color: rgb(135, 89, 235);
}

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

.composer-actions button {
  min-height: 34px;
  padding: 0 20px;
  font-size: 11px;
}

.mode-select {
  margin-right: auto;
  height: 34px;
  padding: 0 24px 0 8px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  font-family: inherit;
  font-size: 11px;
  letter-spacing: 0.08em;
  border-radius: 3px;
  cursor: pointer;
  min-width: 52px;
  transition: border-color 0.15s, color 0.15s;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%23666'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.mode-select:hover,
.mode-select:focus {
  border-color: var(--accent);
  color: var(--fg);
  outline: none;
}

.mode-select option {
  background: #1a1a1a;
  color: var(--fg);
}

/* ─── GENERATION TOOLBAR ─────────────────────────────────────── */
.gen-toolbar.hidden {
  display: none;
}

.gen-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
  align-items: center;
  padding: 4px 0 2px;
  flex-shrink: 0;
}
.gen-toolbar-group {
  display: flex;
  align-items: center;
  gap: 4px;
}
.gen-label {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  cursor: default;
  display: flex;
  align-items: center;
  gap: 3px;
}
.gen-select {
  height: 24px;
  padding: 2px 20px 2px 6px;
  font-size: 10px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(245, 240, 232, 0.12);
  color: var(--fg);
  cursor: pointer;
  min-width: 70px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%23888'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 6px center;
}
.gen-select:focus {
  border-color: var(--accent);
  outline: none;
}
.gen-check {
  appearance: auto;
  width: 12px;
  height: 12px;
  accent-color: var(--accent);
  cursor: pointer;
}

/* ─── INPUTS ─────────────────────────────────────────────────── */
input, textarea, select {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(245, 240, 232, 0.1);
  color: var(--fg);
  padding: 8px 10px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
  border-radius: 2px;
  transition: border-color 160ms;
  -webkit-appearance: none;
  appearance: none;
}

input:focus, textarea:focus, select:focus {
  border-color: rgba(255, 107, 53, 0.5);
}

input::placeholder, textarea::placeholder {
  color: var(--dim);
  font-size: 12px;
}

select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' viewBox='0 0 10 6' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1L5 5L9 1' stroke='%23f5f0e8' stroke-opacity='0.3' stroke-width='1.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

select option {
  background: #1a1a1a;
  color: var(--fg);
}

textarea {
  resize: none;
  min-height: 72px;
  line-height: 1.65;
  font-size: 13px;
}

label {
  display: block;
  font-size: 9px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 4px;
}

/* ─── STATUS BAR ─────────────────────────────────────────────── */
.statusbar {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 10;
  height: var(--statusbar-h);
  background: rgba(10, 10, 10, 0.96);
  backdrop-filter: var(--blur);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  padding: 0 14px;
  gap: 0;
}

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

.statusbar-sep {
  color: var(--dim);
  font-size: 10px;
}

.statusbar-meta {
  font-size: 10px;
  color: var(--dim);
  letter-spacing: 0.1em;
  white-space: nowrap;
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.statusbar-ticker-wrap {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  padding: 0 16px 0 12px;
  border-left: 1px solid var(--line);
  margin-left: 10px;
}

.status-ticker {
  display: block;
  font-size: 10px;
  color: var(--muted);
  letter-spacing: 0.08em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  animation: ticker-in 0.25s ease;
}

@keyframes ticker-in {
  from { opacity: 0.2; transform: translateY(3px); }
  to   { opacity: 1;   transform: translateY(0); }
}

/* ─── RUN STATE ──────────────────────────────────────────────── */
.run-state {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
  border-radius: 2px;
}

.run-state .run-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--dim);
  flex: 0 0 auto;
}

.run-state.running {
  border-color: rgba(62, 207, 142, 0.3);
  color: var(--safe);
}

.run-state.running .run-dot {
  background: var(--safe);
  animation: pulse-dot 1.6s ease-in-out infinite;
}

.run-state.idle .run-dot {
  background: var(--dim);
}

@keyframes pulse-dot {
  0%, 100% { opacity: 1; transform: scale(1); }
  50%      { opacity: 0.3; transform: scale(0.7); }
}

/* ─── NODE CARDS ─────────────────────────────────────────────── */
.node-card {
  position: absolute;
  width: 256px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(4px);
  cursor: grab;
  user-select: none;
  overflow: hidden;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.node-card:hover {
  border-color: rgba(245, 240, 232, 0.2);
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.node-card.dragging {
  cursor: grabbing;
  border-color: rgba(245, 240, 232, 0.25);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

.node-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(255, 107, 53, 0.2);
}

/* Functional nodes (todo_list): smaller, more transparent */
.node-card.functional {
  width: 200px;
  opacity: 0.7;
  font-size: 11px;
  background: rgba(0, 0, 0, 0.45);
  border-color: rgba(245, 240, 232, 0.1);
}
.node-card.functional:hover {
  opacity: 0.9;
}

/* Asset nodes: slightly accented border to emphasize content */
.node-card.asset {
  border-color: rgba(245, 240, 232, 0.18);
}

/* ── Per-type color tokens (--nc = R,G,B triple for rgba()) ─────────────── */
.node-card[data-node-type="request"]      { --nc: 74,  158, 255; }
.node-card[data-node-type="text_output"]  { --nc: 62,  207, 142; }
.node-card[data-node-type="summary"]      { --nc: 155, 109, 255; }
.node-card[data-node-type="todo_list"]    { --nc: 255, 170,   0; }
.node-card[data-node-type="image_prompt"] { --nc: 245, 212,  66; }
.node-card[data-node-type="image_asset"]  { --nc: 255, 107, 138; }
.node-card[data-node-type="audio_asset"]  { --nc:   0, 201, 192; }
.node-card[data-node-type="video_asset"]  { --nc: 255, 112,  67; }
.node-card[data-node-type="audio_script"] { --nc: 126, 211,  33; }
.node-card[data-node-type="video_script"] { --nc: 233,  30,  99; }

/* Apply type color: 3px left accent bar + tinted border */
.node-card[data-node-type] {
  border-left: 3px solid rgb(var(--nc));
  border-color: rgba(var(--nc), 0.38);
  border-left-color: rgb(var(--nc));
}
.node-card[data-node-type]:hover {
  border-color: rgba(var(--nc), 0.65);
  border-left-color: rgb(var(--nc));
  box-shadow: 0 4px 24px rgba(var(--nc), 0.14);
}
.node-card[data-node-type].selected {
  border-color: rgba(var(--nc), 0.9);
  border-left-color: rgb(var(--nc));
  box-shadow: 0 0 0 1px rgba(var(--nc), 0.3), 0 4px 24px rgba(var(--nc), 0.18);
}
/* Type-colored icon badge */
.node-card[data-node-type] .node-icon {
  border-color: rgba(var(--nc), 0.5);
  color: rgb(var(--nc));
  background: rgba(var(--nc), 0.1);
}

/* ── Image / video: show at natural aspect ratio, no crop ───────────────── */
.node-card[data-node-type="image_asset"] .node-preview img,
.node-card[data-node-type="video_asset"] .node-preview video {
  height: auto;
  max-height: none;
  object-fit: fill;
}

/* Conversation nodes (request/text_output direct/summary): subtler on canvas */
.node-card.conversation {
  opacity: 0.85;
  background: rgba(0, 0, 0, 0.5);
  border-style: dashed;
  border-color: rgba(245, 240, 232, 0.12);
}
.node-card.conversation:hover {
  opacity: 1;
  border-style: solid;
}

/* ── Upload placeholder ──────────────────────────────────────────────────── */
.node-card.uploading {
  opacity: 0.8;
  pointer-events: none;
  border-style: dashed;
  border-color: rgba(245, 240, 232, 0.25);
  animation: pulse-border 1.2s ease-in-out infinite;
}

@keyframes pulse-border {
  0%, 100% { border-color: rgba(245, 240, 232, 0.15); }
  50%       { border-color: rgba(245, 240, 232, 0.35); }
}

.node-card.upload-error {
  border-color: rgba(229, 62, 62, 0.6);
  border-style: solid;
  opacity: 0.9;
}

.upload-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(245, 240, 232, 0.12);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  margin: 6px auto 2px;
}

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

.upload-status {
  font-size: 10px;
  color: var(--muted);
  text-align: center;
  margin-top: 4px;
}

/* ── Canvas drop-active state ────────────────────────────────────────────── */
#canvas.drop-active {
  outline: 2px dashed var(--accent);
  outline-offset: -3px;
}

/* ── Drop toast ──────────────────────────────────────────────────────────── */
.drop-toast {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  padding: 5px 16px;
  border-radius: 3px;
  font-size: 12px;
  z-index: 60;
  pointer-events: none;
  white-space: nowrap;
  animation: fadeIn 0.15s ease;
}
.drop-toast-error { background: rgba(229, 62, 62, 0.88); color: #fff; }
.drop-toast-info  { background: rgba(30, 30, 30, 0.88); color: var(--text); }

.node-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--line);
  background: rgba(245, 240, 232, 0.02);
}

.node-kind {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.node-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border: 1px solid rgba(245, 240, 232, 0.15);
  background: rgba(245, 240, 232, 0.04);
  color: var(--accent);
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0;
  flex: 0 0 auto;
}

.node-type {
  font-size: 9px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--dim);
}

.node-status {
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dim);
}

.node-status.active { color: var(--safe); }
.node-status.error  { color: var(--kill); }
.node-status.pending { color: var(--accent); }

.node-body {
  padding: 10px;
  display: grid;
  gap: 7px;
}

.node-title {
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--fg);
  line-height: 1.4;
}

.node-summary {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 64px;
  overflow: hidden;
}

.node-preview {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  min-height: 60px;
  overflow: hidden;
}

.node-preview img,
.node-preview video {
  display: block;
  width: 100%;
  max-height: 160px;
  object-fit: cover;
  background: #000;
}

/* Video without src still shows controls; min-height prevents collapse */
.node-preview video {
  min-height: 120px;
}

.node-preview audio {
  display: block;
  width: 100%;
  height: 32px;
}

/* ─── NODE TOOLTIP ───────────────────────────────────────────── */
.node-tooltip {
  position: fixed;
  z-index: 200;
  width: 220px;
  padding: 10px 12px;
  background: rgba(10, 10, 10, 0.97);
  border: 1px solid rgba(245, 240, 232, 0.14);
  border-radius: 3px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  pointer-events: none;
  animation: tooltip-in 0.15s ease;
}

.node-tooltip.hidden { display: none; }

/* ─── NODE ACTION BAR (Floating) ─────────────────────────────── */
.node-action-bar {
  position: fixed;
  z-index: 190;
  display: flex;
  gap: 4px;
  padding: 4px;
  background: rgba(10, 10, 10, 0.9);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(245, 240, 232, 0.15);
  border-radius: 4px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  animation: actionbar-in 0.2s ease;
}

.node-action-bar.hidden { display: none; }

@keyframes actionbar-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.node-action-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.1s ease;
}

.node-action-btn:hover {
  background: rgba(245, 240, 232, 0.08);
  color: var(--fg);
  border-color: rgba(245, 240, 232, 0.1);
}

.node-action-btn.danger:hover {
  background: rgba(255, 69, 58, 0.15);
  color: #ff453a;
  border-color: rgba(255, 69, 58, 0.3);
}

.node-action-btn .icon {
  font-size: 12px;
}

@keyframes tooltip-in {
  from { opacity: 0; transform: translateX(-4px); }
  to   { opacity: 1; transform: translateX(0); }
}

.tooltip-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--fg);
  margin-bottom: 6px;
  line-height: 1.4;
}

.tooltip-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  padding: 2px 0;
  border-bottom: 1px solid var(--line);
}

.tooltip-row:last-of-type { border-bottom: none; }

.tooltip-row span:first-child {
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--dim);
  flex: 0 0 auto;
}

.tooltip-row span:last-child {
  font-size: 11px;
  color: var(--muted);
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tooltip-summary {
  margin-top: 7px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.55;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}

/* ─── NODE DETAIL MODAL ──────────────────────────────────────── */
.node-detail-card {
  width: min(680px, calc(100vw - 40px));
  max-height: min(85vh, 800px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 24px;
}

.node-detail-card.text-mode {
  width: min(860px, calc(100vw - 40px));
  max-height: min(90vh, 900px);
}

.node-detail-card::-webkit-scrollbar { width: 4px; }
.node-detail-card::-webkit-scrollbar-track { background: transparent; }
.node-detail-card::-webkit-scrollbar-thumb { background: rgba(245, 240, 232, 0.12); border-radius: 2px; }

.node-detail-content {
  flex: 1;
}

.node-detail-content h2 {
  font-size: 16px;
  font-weight: 600;
  color: var(--fg);
  letter-spacing: 0.06em;
  margin-bottom: 12px;
  line-height: 1.4;
}

.node-detail-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 12px;
  align-items: baseline;
  padding: 10px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  margin-bottom: 14px;
}

.node-detail-meta .meta-label {
  font-size: 9px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}

.node-detail-meta .meta-value {
  font-size: 12px;
  color: var(--muted);
  word-break: break-all;
}

.node-detail-preview {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.3);
  margin-bottom: 14px;
  overflow: hidden;
}

.node-detail-preview img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  background: #000;
}

.node-detail-preview video {
  display: block;
  width: 100%;
  max-height: 420px;
  background: #000;
}

.node-detail-preview audio {
  display: block;
  width: 100%;
  height: 40px;
}

.node-detail-summary {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  margin-bottom: 14px;
}

/* Markdown-rendered text content (text-mode modal) */
.node-detail-text-content {
  max-height: min(60vh, 680px);
  overflow-y: auto;
  padding: 14px 16px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-bottom: 14px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--fg);
  white-space: pre-wrap;
  word-break: break-word;
}

.node-detail-text-content::-webkit-scrollbar { width: 6px; }
.node-detail-text-content::-webkit-scrollbar-track { background: transparent; }
.node-detail-text-content::-webkit-scrollbar-thumb { background: rgba(245, 240, 232, 0.1); border-radius: 3px; }

/* Markdown body styles */
.markdown-body h1,
.markdown-body h2,
.markdown-body h3,
.markdown-body h4 {
  color: var(--fg);
  font-weight: 600;
  line-height: 1.25;
  margin: 0.6em 0 0.25em;
}
.markdown-body h1 { font-size: 16px; }
.markdown-body h2 { font-size: 14px; }
.markdown-body h3 { font-size: 13px; }
.markdown-body h4 { font-size: 12px; }
.markdown-body p { margin: 0.3em 0; }
.markdown-body ul,
.markdown-body ol { margin: 0.3em 0; padding-left: 1.4em; }
.markdown-body li { margin: 0.15em 0; }
.markdown-body code {
  background: rgba(255, 255, 255, 0.08);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: "Fira Code", "Cascadia Code", monospace;
}
.markdown-body pre {
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 10px;
  overflow-x: auto;
  max-height: 220px;
  margin: 0.4em 0;
}
.markdown-body pre code {
  background: none;
  padding: 0;
  font-size: 11px;
  line-height: 1.5;
}
.markdown-body blockquote {
  border-left: 3px solid var(--accent);
  margin: 0.4em 0;
  padding: 3px 10px;
  color: var(--dim);
}
.markdown-body strong { color: var(--fg); font-weight: 600; }
.markdown-body em { color: var(--muted); }
.markdown-body hr {
  border: none;
  border-top: 1px solid var(--line);
  margin: 0.6em 0;
}
.markdown-body a { color: var(--accent); text-decoration: underline; }
.markdown-body table {
  border-collapse: collapse;
  width: 100%;
  margin: 0.4em 0;
  font-size: 12px;
}
.markdown-body th,
.markdown-body td {
  border: 1px solid var(--line);
  padding: 4px 8px;
  text-align: left;
}
.markdown-body th { background: rgba(255, 255, 255, 0.04); }

/* Collapsible "other fields" section */
.node-detail-other-fields {
  margin-top: 10px;
}

.node-detail-other-fields summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 4px 0;
}

.node-detail-other-fields summary:hover { opacity: 0.7; }

.other-fields-grid {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 16px;
  margin-top: 8px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid var(--line);
  border-radius: 3px;
  max-height: 200px;
  overflow-y: auto;
}

.other-field-item {
  display: contents;
}

.other-field-key {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--dim);
  white-space: nowrap;
  padding-top: 2px;
}

.other-field-val {
  font-size: 11px;
  color: var(--muted);
  word-break: break-all;
  white-space: pre-wrap;
}

/* ── Image Lightbox ─────────────────────────────────────────────────────────── */

.image-lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.96);
  display: flex;
  flex-direction: column;
}
.image-lightbox.hidden { display: none; }

.ilb-close {
  position: absolute;
  top: 12px;
  right: 18px;
  background: none;
  border: none;
  color: rgba(255, 255, 255, 0.45);
  font-size: 30px;
  line-height: 1;
  cursor: pointer;
  z-index: 10;
  padding: 0 4px;
  transition: color 0.15s;
}
.ilb-close:hover { color: rgba(255, 255, 255, 0.9); }

.ilb-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 56px 10px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  min-height: 44px;
}

.ilb-title {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.75);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  letter-spacing: 0.04em;
}

.ilb-zoom-label {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.35);
  min-width: 38px;
  text-align: right;
}

.ilb-ctrl-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 4px;
  color: rgba(255, 255, 255, 0.65);
  font-size: 16px;
  line-height: 1;
  width: 30px;
  height: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, color 0.12s;
}
.ilb-ctrl-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.9);
}

.ilb-stage {
  flex: 1;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  position: relative;
  min-height: 0;
}
.ilb-stage.panning { cursor: grabbing; }

.ilb-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  transform-origin: center center;
  user-select: none;
  pointer-events: none;
  will-change: transform;
}

.ilb-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  flex-shrink: 0;
  max-height: 220px;
  overflow-y: auto;
}

.ilb-footer details { padding: 0; }

.ilb-footer summary {
  padding: 8px 16px;
  font-size: 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.3);
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 6px;
  user-select: none;
}
.ilb-footer summary::before {
  content: "▶";
  font-size: 8px;
  transition: transform 0.15s;
}
.ilb-footer details[open] summary::before { transform: rotate(90deg); }
.ilb-footer summary:hover { color: rgba(255, 255, 255, 0.6); }

.ilb-meta {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 14px;
  padding: 6px 16px 14px;
}

.ilb-meta-key {
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.25);
  white-space: nowrap;
  padding-top: 2px;
}

.ilb-meta-val {
  font-size: 11px;
  color: rgba(255, 255, 255, 0.5);
  word-break: break-all;
  white-space: pre-wrap;
}

.ilb-footer::-webkit-scrollbar { width: 4px; }
.ilb-footer::-webkit-scrollbar-track { background: transparent; }
.ilb-footer::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }

/* ── end Image Lightbox ─────────────────────────────────────────────────────── */

.node-detail-content details {
  margin-top: 10px;
}

.node-detail-content summary {
  color: var(--accent);
  cursor: pointer;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  padding: 4px 0;
}

.node-detail-content summary:hover { opacity: 0.7; }

.node-detail-content pre {
  margin: 8px 0 0;
  padding: 12px;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.35);
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  overflow: auto;
  max-height: 300px;
}

/* ─── EMPTY STATE ────────────────────────────────────────────── */
.empty-state {
  display: grid;
  place-items: center;
  height: 100%;
  padding: 40px;
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

/* ─── MODAL ──────────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: var(--blur);
}

.modal.hidden { display: none; }

.modal-card {
  width: min(440px, calc(100vw - 40px));
  border: 1px solid var(--line);
  border-radius: 3px;
  background: rgba(13, 13, 13, 0.97);
  backdrop-filter: var(--blur);
  padding: 22px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
}

.modal-card h2 {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--fg);
  margin-bottom: 8px;
}

.modal-card p {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 16px;
  letter-spacing: 0.04em;
  line-height: 1.65;
}

.modal-card input {
  margin-bottom: 12px;
}

.template-modal-card {
  width: min(960px, calc(100vw - 40px));
  max-height: min(84vh, 920px);
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) auto;
}

.template-library-meta {
  margin-bottom: 10px;
  color: var(--dim);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.template-capsules {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
}

.template-capsules-secondary { margin-bottom: 12px; }

.template-capsule {
  min-height: 28px;
  padding: 0 12px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: none;
}

.template-capsule.active {
  border-color: rgba(255, 107, 53, 0.55);
  background: rgba(255, 107, 53, 0.12);
  color: var(--accent);
}

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

.template-card {
  min-height: 180px;
  display: grid;
  align-content: start;
  gap: 10px;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  font-size: 12px;
  letter-spacing: normal;
  text-transform: none;
  color: var(--fg);
}

.template-card:hover {
  border-color: rgba(255, 107, 53, 0.55);
  background: rgba(255, 107, 53, 0.05);
  color: var(--fg);
}

.template-card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.template-card-title {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--fg);
}

.template-card-category {
  flex: 0 0 auto;
  padding: 3px 6px;
  border: 1px solid var(--line);
  color: var(--accent);
  font-size: 9px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.template-card-description {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.template-card-taxonomy {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.template-card-taxonomy span {
  padding: 2px 6px;
  border: 1px solid var(--line);
  color: var(--dim);
  font-size: 9px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.template-card-prompt {
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--fg);
  font-size: 11px;
  line-height: 1.6;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  padding: 8px;
  max-height: 160px;
  overflow: auto;
}

.template-empty {
  display: grid;
  place-items: center;
  min-height: 160px;
  border: 1px dashed var(--line);
  color: var(--dim);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 12px;
}

.modal-actions button {
  min-height: 34px;
  padding: 0 16px;
  font-size: 10px;
}

/* ─── SCROLLBARS GLOBAL ─────────────────────────────────────── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(245, 240, 232, 0.1); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(245, 240, 232, 0.2); }

/* ─── RECOVERY MODAL ────────────────────────────────────────── */
.recovery-run-list {
  max-height: 400px;
  overflow-y: auto;
  margin: 14px 0;
}

.recovery-run-item {
  border: 1px solid var(--line);
  padding: 12px;
  margin-bottom: 10px;
  background: rgba(255, 255, 255, 0.02);
}

.recovery-run-info {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.recovery-run-id {
  font-weight: 500;
  color: var(--fg);
  font-size: 12px;
}

.recovery-run-status {
  font-size: 9px;
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.recovery-run-status.status-running {
  background: rgba(62, 207, 142, 0.2);
  color: var(--safe);
}

.recovery-run-status.status-awaiting_input {
  background: rgba(255, 107, 53, 0.2);
  color: var(--accent);
}

.recovery-run-status.status-queued {
  background: rgba(245, 240, 232, 0.1);
  color: var(--muted);
}

.recovery-run-phase {
  color: var(--dim);
  font-size: 10px;
}

.recovery-run-checkpoint {
  color: var(--dim);
  font-size: 10px;
  margin-left: auto;
}

.recovery-run-goal {
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.recovery-run-actions {
  display: flex;
  gap: 8px;
}

.recovery-btn {
  padding: 4px 12px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.02);
  color: var(--muted);
  cursor: pointer;
}

.recovery-btn:hover { background: rgba(255, 255, 255, 0.05); }

.recovery-btn.resume {
  border-color: rgba(62, 207, 142, 0.4);
  color: var(--safe);
}

.recovery-btn.resume:hover { background: rgba(62, 207, 142, 0.1); }

.recovery-btn.cancel {
  border-color: rgba(232, 64, 64, 0.4);
  color: var(--kill);
}

.recovery-btn.cancel:hover { background: rgba(232, 64, 64, 0.1); }

/* ─── RESPONSIVE ─────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .sidepanel { width: 300px; }
  .topbar-canvas-controls input { max-width: 100px; }
  .topbar-canvas-controls select { max-width: 120px; }
}

@media (max-width: 800px) {
  .sidepanel {
    top: auto;
    bottom: var(--statusbar-h);
    left: 0;
    right: 0;
    width: 100%;
    height: 50vh;
    border-left: none;
    border-top: 1px solid var(--line);
  }

  .topbar-brand p { display: none; }
  .topbar-divider { display: none; }
  .topbar-canvas-controls { display: none; }
  .topbar-right .status-chip { display: none; }
  .template-modal-card { width: calc(100vw - 20px); padding: 16px; }
  .template-library-list { grid-template-columns: 1fr; }
}

/* ─── TOPBAR NAV ─────────────────────────────────────────────── */
.topbar-nav {
  display: flex;
  gap: 4px;
  align-items: center;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-item {
  padding: 6px 12px;
  border-radius: 3px;
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
  letter-spacing: 0.02em;
  transition: all 0.15s;
  border: 1px solid transparent;
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
}

.nav-item:hover {
  color: var(--fg);
  background: rgba(255,255,255,0.05);
}

.nav-item.active {
  color: var(--accent);
  border-color: rgba(255, 107, 53, 0.3);
  background: rgba(255, 107, 53, 0.08);
}

/* ─── IMAGE GEN LAYOUT ──────────────────────────────────────── */
.gen-layout {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.gen-main {
  display: grid;
  grid-template-columns: 1.5fr 160px 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.gen-left,
.gen-center,
.gen-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

.gen-section {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
}

.gen-section .gen-label {
  display: block;
  font-size: 10px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--dim);
  margin-bottom: 8px;
}

.gen-section textarea {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  line-height: 1.5;
  padding: 8px;
  resize: vertical;
}

.gen-section textarea:focus {
  outline: none;
  border-color: var(--line-strong);
}

.char-count {
  text-align: right;
  font-size: 10px;
  color: var(--dim);
  margin-top: 4px;
}

.gen-hint {
  font-weight: normal;
  color: var(--dim);
  font-size: 9px;
}

.gen-select {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 24px 6px 8px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%23888'%3E%3Cpath d='M0 0l5 6 5-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  cursor: pointer;
}

.gen-select:focus {
  outline: none;
  border-color: var(--line-strong);
}

.gen-input {
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--fg);
  font-family: inherit;
  font-size: 12px;
  padding: 6px 8px;
}

.gen-input:focus {
  outline: none;
  border-color: var(--line-strong);
}

.gen-check {
  margin-right: 6px;
}

/* Reference images grid */
.ref-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.ref-slot {
  aspect-ratio: 1;
  background: rgba(0,0,0,0.3);
  border: 1px dashed var(--line);
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: var(--dim);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
  min-height: 80px;
}

.ref-slot:hover {
  border-color: var(--line-strong);
  color: var(--accent);
}

.ref-slot.has-image {
  border-style: solid;
  border-color: rgba(255,107,53,0.3);
}

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

.ref-slot .ref-tag {
  position: absolute;
  bottom: 2px;
  left: 2px;
  font-size: 8px;
  background: rgba(0,0,0,0.7);
  padding: 1px 4px;
  border-radius: 2px;
}

.ref-slot .ref-remove {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  background: rgba(0,0,0,0.7);
  border: none;
  border-radius: 50%;
  color: var(--kill);
  font-size: 10px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.ref-slot.has-image:hover .ref-remove {
  display: flex;
}

/* Style presets */
.style-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.style-btn {
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.style-btn:hover {
  border-color: rgba(255,107,53,0.4);
  color: var(--fg);
}

.style-btn.active {
  background: rgba(255,107,53,0.15);
  border-color: rgba(255,107,53,0.5);
  color: var(--accent);
}

/* Ratio grid */
.ratio-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.ratio-btn {
  padding: 8px 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.ratio-btn:hover {
  border-color: rgba(255,107,53,0.4);
  color: var(--fg);
}

.ratio-btn.active {
  background: rgba(255,107,53,0.15);
  border-color: rgba(255,107,53,0.5);
  color: var(--accent);
}

/* Count grid */
.count-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.count-btn {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.count-btn:hover {
  border-color: rgba(255,107,53,0.4);
  color: var(--fg);
}

.count-btn.active {
  background: rgba(255,107,53,0.15);
  border-color: rgba(255,107,53,0.5);
  color: var(--accent);
}

/* Seed row */
.seed-row {
  display: flex;
  gap: 8px;
}

.seed-row .gen-input {
  flex: 1;
}

.seed-row .ghost-button {
  padding: 6px 12px;
}

/* Watermark section */
.watermark-section {
  padding: 8px 12px;
}

.watermark-section .gen-label {
  display: flex;
  align-items: center;
  margin-bottom: 0;
  font-size: 11px;
  cursor: pointer;
}

/* Gen actions */
.gen-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

.gen-actions .btn-primary {
  flex: 1;
  padding: 10px;
  background: var(--accent);
  border: none;
  border-radius: 4px;
  color: white;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.gen-actions .btn-primary:hover {
  background: #ff8555;
}

.gen-actions .btn-primary:disabled {
  background: rgba(255,107,53,0.3);
  cursor: not-allowed;
}

.gen-actions .ghost-button {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.15s;
}

.gen-actions .ghost-button:hover {
  border-color: rgba(255,107,53,0.4);
  color: var(--fg);
}

/* ─── RESULT AREA ────────────────────────────────────────────── */
.result-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.result-status {
  font-size: 10px;
  color: var(--dim);
}

.result-preview {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--line);
  border-radius: 4px;
  min-height: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
}

.result-placeholder {
  color: var(--dim);
  font-size: 12px;
}

.result-preview img {
  max-width: 100%;
  max-height: 300px;
  object-fit: contain;
  border-radius: 3px;
}

.result-thumbs {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

/* Image generation loading animation */
.img-loading-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  padding: 4px;
  width: 100%;
}

.img-loading-box {
  position: relative;
  aspect-ratio: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  animation: img-loading-pulse 1.4s ease-in-out infinite;
}

.img-loading-shimmer {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255,255,255,0.06) 50%,
    transparent 100%
  );
  animation: img-loading-shimmer 1.8s ease-in-out infinite;
}

.img-loading-num {
  position: absolute;
  bottom: 6px;
  right: 8px;
  font-size: 11px;
  color: var(--muted);
  font-family: 'Space Grotesk', monospace;
}

@keyframes img-loading-pulse {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

@keyframes img-loading-shimmer {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(100%); }
}

.result-thumb {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border: 2px solid transparent;
  border-radius: 3px;
  cursor: pointer;
  overflow: hidden;
  transition: all 0.15s;
}

.result-thumb:hover {
  border-color: rgba(255,107,53,0.4);
}

.result-thumb.selected {
  border-color: var(--accent);
}

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

.result-meta {
  font-size: 10px;
  color: var(--dim);
  margin-bottom: 8px;
  line-height: 1.6;
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.action-btn {
  padding: 6px 4px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 10px;
  cursor: pointer;
  transition: all 0.15s;
  text-align: center;
}

.action-btn:hover:not(:disabled) {
  border-color: rgba(255,107,53,0.4);
  color: var(--fg);
}

.action-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ─── HISTORY ───────────────────────────────────────────────── */
.gen-history {
  height: 80px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}

.history-header {
  margin-bottom: 6px;
}

.history-list {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  flex: 1;
}

.history-empty {
  color: var(--dim);
  font-size: 11px;
  display: flex;
  align-items: center;
  height: 100%;
}

.history-item {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.15s;
}

.history-item:hover {
  border-color: rgba(255,107,53,0.4);
}

.history-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ─── VIDEO GEN LAYOUT ──────────────────────────────────────── */
.video-layout {
  display: flex;
  flex-direction: column;
  padding: 16px;
  gap: 12px;
  height: calc(100vh - var(--topbar-h));
  overflow: hidden;
}

.video-main {
  display: grid;
  grid-template-columns: 260px 200px 1fr;
  gap: 16px;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

.video-left,
.video-center,
.video-right {
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
}

/* Reference slots for video */
.ref-slots-video {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ref-slot-video {
  min-height: 132px;
  height: 132px;
  background: rgba(0,0,0,0.3);
  border: 1px dashed var(--line);
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--dim);
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
  overflow: hidden;
}

.ref-slot-video:hover {
  border-color: var(--line-strong);
}

.ref-slot-video .slot-icon {
  font-size: 20px;
  margin-bottom: 3px;
}

.ref-slot-video .slot-type {
  font-size: 9px;
  text-transform: uppercase;
}

.ref-slot-video.has-content {
  border-style: solid;
  border-color: rgba(255,107,53,0.3);
}

.ref-slot-video img,
.ref-slot-video video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* Prompt editor */
.prompt-editor {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.prompt-mode-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}

.prompt-mode-tab {
  padding: 6px 12px;
  border: 1px solid var(--line);
  border-radius: 3px 3px 0 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  border-bottom: none;
  transition: all 0.15s;
}

.prompt-mode-tab:hover {
  color: var(--fg);
}

.prompt-mode-tab.active {
  background: rgba(255,107,53,0.1);
  border-color: rgba(255,107,53,0.4);
  color: var(--accent);
  border-bottom: 1px solid var(--panel);
  margin-bottom: -1px;
  position: relative;
  z-index: 1;
}

.prompt-textarea {
  flex: 1;
  width: 100%;
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--line);
  border-radius: 0 3px 3px 3px;
  color: var(--fg);
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
  font-size: 14px;
  line-height: 1.6;
  padding: 12px;
  resize: none;
}

.prompt-textarea:focus {
  outline: none;
  border-color: var(--line-strong);
}

.prompt-hint {
  font-size: 10px;
  color: var(--dim);
  margin-top: 4px;
  line-height: 1.4;
}

.prompt-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
}

.prompt-action-btn {
  padding: 4px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
}

.prompt-action-btn:hover {
  border-color: rgba(255,107,53,0.4);
  color: var(--fg);
}

/* Video preview */
.video-preview {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--line);
  border-radius: 4px;
  aspect-ratio: 9/16;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 8px;
  position: relative;
  overflow: hidden;
}

.video-placeholder {
  color: var(--dim);
  font-size: 12px;
}

/* Loading Animation */
.video-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  gap: 16px;
}

.video-loading-rings {
  position: relative;
  width: 80px;
  height: 80px;
}

.video-loading-ring {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  border: 3px solid transparent;
  animation: spin 2s linear infinite;
}

.video-loading-ring:nth-child(1) {
  border-top-color: var(--accent);
  animation-duration: 1.5s;
}

.video-loading-ring:nth-child(2) {
  top: 8px; left: 8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  border-right-color: rgba(255,107,53,0.5);
  animation-duration: 2s;
  animation-direction: reverse;
}

.video-loading-ring:nth-child(3) {
  top: 16px; left: 16px;
  width: calc(100% - 32px);
  height: calc(100% - 32px);
  border-bottom-color: rgba(255,107,53,0.3);
  animation-duration: 2.5s;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.video-loading-text {
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.video-loading-step {
  color: var(--accent);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.video-loading-progress {
  width: 120px;
  height: 3px;
  background: var(--line);
  border-radius: 2px;
  overflow: hidden;
  margin-top: 8px;
}

.video-loading-progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff9f6b);
  border-radius: 2px;
  transition: width 0.5s ease;
  animation: progress-pulse 1.5s ease-in-out infinite;
}

@keyframes progress-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

/* Task Queue Improvements */
.task-queue {
  max-height: 200px;
  overflow-y: auto;
}

.task-item {
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-bottom: 6px;
  background: rgba(0,0,0,0.2);
  transition: all 0.3s ease;
}

.task-item.active {
  border-color: var(--accent);
  background: rgba(255,107,53,0.08);
  box-shadow: 0 0 12px rgba(255,107,53,0.15);
}

.task-item.completed {
  border-color: var(--safe);
  background: rgba(62,207,142,0.08);
}

.task-item.error {
  border-color: var(--kill);
  background: rgba(232,64,64,0.08);
}

.task-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 4px;
}

.task-status-dot.pending {
  background: var(--dim);
}

.task-status-dot.running {
  background: var(--accent);
  animation: pulse-dot 1s ease-in-out infinite;
}

.task-status-dot.completed {
  background: var(--safe);
}

.task-status-dot.error {
  background: var(--kill);
}

@keyframes pulse-dot {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.4); opacity: 0.7; }
}

.task-info {
  flex: 1;
  min-width: 0;
}

.task-prompt {
  font-size: 11px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.task-meta {
  font-size: 10px;
  color: var(--dim);
}

.task-time {
  font-size: 10px;
  color: var(--dim);
  flex-shrink: 0;
}

.video-preview video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-controls {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
}

.video-ctrl-btn {
  flex: 1;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.15s;
}

.video-ctrl-btn:hover {
  border-color: rgba(255,107,53,0.4);
  color: var(--fg);
}

/* Task queue */
.task-queue {
  max-height: 200px;
  overflow-y: auto;
}

.task-item {
  display: flex;
  gap: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 3px;
  margin-bottom: 6px;
  background: rgba(0,0,0,0.2);
}

.task-thumb {
  width: 48px;
  height: 48px;
  border-radius: 2px;
  background: var(--panel);
  flex-shrink: 0;
  overflow: hidden;
}

.task-thumb img,
.task-thumb video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.task-info {
  flex: 1;
  min-width: 0;
}

.task-title {
  font-size: 11px;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.task-meta {
  font-size: 9px;
  color: var(--dim);
}

.task-status {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 10px;
}

.task-status.pending {
  background: rgba(255,107,53,0.15);
  color: var(--accent);
}

.task-status.processing {
  background: rgba(255,200,50,0.15);
  color: #ffc832;
}

.task-status.done {
  background: rgba(62,207,142,0.15);
  color: var(--safe);
}

.task-status.failed {
  background: rgba(232,64,64,0.15);
  color: var(--kill);
}

/* Video params bar */
.video-params {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 12px;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.param-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.param-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--dim);
}

.param-select {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--fg);
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
  font-size: 12px;
  padding: 4px 24px 4px 8px;
  min-width: 80px;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' fill='%23888'%3E%3Cpath d='M0 0l5 6 5-6z'/%E3C%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
}

.param-select:focus {
  outline: none;
  border-color: var(--line-strong);
}

.param-input {
  background: rgba(0,0,0,0.4);
  border: 1px solid var(--line);
  border-radius: 3px;
  color: var(--fg);
  font-family: inherit;
  font-size: 11px;
  padding: 4px 8px;
  width: 60px;
  text-align: center;
}

.param-input:focus {
  outline: none;
  border-color: var(--line-strong);
}

.param-unit {
  font-size: 11px;
  color: var(--dim);
}

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

.param-slider input[type="range"] {
  width: 80px;
  accent-color: var(--accent);
}

.param-slider span {
  font-size: 10px;
  color: var(--dim);
  min-width: 30px;
}

/* ─── GRAPHITE STUDIO REDESIGN ────────────────────────────────
   Global visual layer for the canvas, image generation, and video generation
   workspaces. The interface should recede so media and written prompts lead. */
:root {
  --bg: #0a0d10;
  --fg: #eceff4;
  --dim: rgba(236, 239, 244, 0.3);
  --muted: rgba(236, 239, 244, 0.56);
  --line: rgba(236, 239, 244, 0.045);
  --line-strong: rgba(156, 170, 205, 0.24);
  --accent: #8d9fcb;
  --accent-strong: #a1b0da;
  --accent-soft: rgba(143, 163, 216, 0.09);
  --panel: rgba(255, 255, 255, 0.018);
  --panel-hover: rgba(143, 163, 216, 0.035);
  --surface: rgba(8, 11, 14, 0.68);
  --safe: #7fc29b;
  --kill: #d06f77;
  --coord: rgba(236, 239, 244, 0.2);
  --blur: blur(18px);
  --topbar-h: 64px;
  --statusbar-h: 34px;
}

body {
  color: var(--fg);
  background:
    radial-gradient(circle at 50% -24%, rgba(88, 97, 118, 0.075), transparent 32%),
    linear-gradient(180deg, #090c0f 0%, #050608 100%);
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 13px;
  letter-spacing: 0;
}

input,
textarea,
select,
button {
  font-family: inherit;
}

input,
textarea,
select,
.gen-select,
.gen-input,
.param-select,
.topbar-canvas-controls input,
.topbar-canvas-controls select {
  min-height: 38px;
  border-color: rgba(236, 239, 244, 0.09);
  border-radius: 6px;
  background-color: rgba(0, 0, 0, 0.18);
  color: rgba(236, 239, 244, 0.88);
  box-shadow: none;
}

textarea,
.gen-section textarea,
.prompt-textarea {
  line-height: 1.72;
  font-size: 13px;
}

input:focus,
textarea:focus,
select:focus,
.gen-select:focus,
.gen-input:focus,
.param-select:focus {
  outline: none;
  border-color: rgba(143, 163, 216, 0.2);
  background-color: rgba(0, 0, 0, 0.28);
}

label,
.gen-section .gen-label,
.param-label,
.msg-label,
.node-type,
.node-status,
.canvas-meta-center,
.statusbar-meta,
.template-library-meta {
  letter-spacing: 0.055em;
  text-transform: none;
}

.topbar {
  background: rgba(5, 7, 9, 0.78);
  border-bottom-color: rgba(236, 239, 244, 0.04);
  box-shadow: none;
  padding: 0 22px;
}

.topbar-brand h1 {
  font-size: 15px;
  font-weight: 680;
  letter-spacing: -0.01em;
}

.topbar-brand p {
  display: none;
}

.topbar-divider {
  opacity: 0.35;
}

.topbar-nav {
  gap: 16px;
}

.nav-item {
  min-height: var(--topbar-h);
  display: inline-flex;
  align-items: center;
  padding: 0 12px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  color: rgba(236, 239, 244, 0.58);
  font-size: 15px;
  font-weight: 550;
  letter-spacing: 0;
  font-family: 'Space Grotesk', 'Noto Sans SC', sans-serif;
}

.nav-item:hover {
  background: transparent;
  color: rgba(236, 239, 244, 0.86);
}

.nav-item.active {
  color: var(--fg);
  border-color: var(--accent);
  background: transparent;
}

.topbar-right {
  gap: 12px;
}

.status-chip,
.run-state {
  min-height: 28px;
  border-radius: 999px;
  border-color: rgba(236, 239, 244, 0.05);
  background: rgba(255, 255, 255, 0.018);
  color: rgba(236, 239, 244, 0.46);
  letter-spacing: 0.06em;
}

.status-chip.loaded,
.run-state.running {
  border-color: rgba(127, 194, 155, 0.24);
  color: var(--safe);
}

.ghost-button,
button,
.action-btn,
.video-ctrl-btn,
.prompt-action-btn,
.style-btn,
.ratio-btn,
.count-btn,
.template-capsule,
.template-card,
.recovery-btn {
  min-height: 38px;
  border-radius: 6px;
  border-color: rgba(236, 239, 244, 0.045);
  background: rgba(255, 255, 255, 0.012);
  color: rgba(236, 239, 244, 0.58);
  font-size: 12px;
  font-weight: 520;
  letter-spacing: 0;
  text-transform: none;
  box-shadow: none;
}

.ghost-button:hover,
button:hover,
.action-btn:hover:not(:disabled),
.video-ctrl-btn:hover,
.prompt-action-btn:hover,
.style-btn:hover,
.ratio-btn:hover,
.count-btn:hover,
.template-capsule:hover,
.template-card:hover,
.recovery-btn:hover {
  border-color: rgba(143, 163, 216, 0.22);
  background: rgba(143, 163, 216, 0.035);
  color: rgba(236, 239, 244, 0.82);
}

button.btn-primary,
.gen-actions .btn-primary {
  min-height: 46px;
  border-color: rgba(143, 163, 216, 0.2);
  background: rgba(143, 163, 216, 0.075);
  color: rgba(236, 239, 244, 0.86);
  font-weight: 650;
  letter-spacing: 0;
}

button.btn-primary:hover,
.gen-actions .btn-primary:hover {
  border-color: rgba(167, 183, 230, 0.34);
  background: rgba(143, 163, 216, 0.12);
  color: #fff;
}

button:disabled,
button:disabled:hover,
.action-btn:disabled {
  opacity: 0.36;
  border-color: rgba(236, 239, 244, 0.06);
  background: rgba(255, 255, 255, 0.018);
  color: rgba(236, 239, 244, 0.32);
}

.canvas {
  background:
    linear-gradient(rgba(236, 239, 244, 0.01) 1px, transparent 1px),
    linear-gradient(90deg, rgba(236, 239, 244, 0.01) 1px, transparent 1px),
    radial-gradient(circle at 50% -12%, rgba(143, 163, 216, 0.045), transparent 26%),
    #050708;
  background-size: 72px 72px, 72px 72px, auto, auto;
}

.sidepanel,
.statusbar,
.modal-card,
.node-action-bar,
.node-tooltip {
  background: rgba(12, 15, 19, 0.88);
  border-color: rgba(236, 239, 244, 0.04);
  box-shadow: none;
}

.sidepanel {
  width: 380px;
}

.statusbar {
  padding: 0 20px;
}

.message-list-wrap {
  padding: 18px;
}

.msg-bubble,
.activity-card,
.composer-panel,
.recovery-run-item,
.template-card,
.template-card-prompt,
.other-fields-grid,
.node-detail-text-content,
.node-detail-preview,
.node-preview {
  border-radius: 8px;
  border-color: rgba(236, 239, 244, 0.04);
  background: rgba(255, 255, 255, 0.014);
}

.msg-user .msg-bubble {
  background: rgba(143, 163, 216, 0.08);
  border-color: rgba(143, 163, 216, 0.1);
}

.msg-agent .msg-bubble {
  background: rgba(255, 255, 255, 0.012);
}

.composer-panel textarea {
  border-radius: 8px;
}

.node-card {
  width: 280px;
  border-radius: 10px;
  background: rgba(8, 11, 14, 0.56);
  border-color: rgba(236, 239, 244, 0.045);
  box-shadow: none;
}

.node-card[data-node-type],
.node-card.asset,
.node-card.conversation {
  border-left: 1px solid rgba(236, 239, 244, 0.04);
  border-color: rgba(236, 239, 244, 0.045);
}

.node-card[data-node-type]:hover,
.node-card:hover,
.node-card.functional:hover,
.node-card.conversation:hover {
  border-color: rgba(143, 163, 216, 0.18);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);
}

.node-card.selected,
.node-card[data-node-type].selected {
  border-color: rgba(143, 163, 216, 0.34);
  box-shadow: 0 0 0 1px rgba(143, 163, 216, 0.08);
}

.node-card[data-node-type] .node-icon {
  border-color: rgba(236, 239, 244, 0.09);
  color: rgba(236, 239, 244, 0.64);
  background: rgba(255, 255, 255, 0.035);
}

.node-head {
  padding: 9px 12px;
  background: transparent;
}

.node-body {
  padding: 12px;
}

.node-title {
  font-size: 14px;
  font-weight: 620;
}

.node-summary {
  color: rgba(236, 239, 244, 0.58);
}

.minimap {
  right: 392px;
  background: rgba(12, 15, 19, 0.52);
  border-color: rgba(236, 239, 244, 0.07);
}

.minimap-h {
  right: 448px;
}

.modal-card,
.node-detail-card {
  border-radius: 12px;
}

.gen-layout,
.video-layout {
  margin-top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  padding: 18px 20px 20px;
  gap: 14px;
  background:
    radial-gradient(circle at 58% -18%, rgba(143, 163, 216, 0.045), transparent 34%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.012), transparent 45%);
}

.gen-main,
.video-main {
  gap: 14px;
}

.gen-main {
  grid-template-columns: minmax(280px, 340px) minmax(230px, 280px) minmax(0, 1fr);
}

.video-main {
  grid-template-columns: minmax(280px, 340px) minmax(420px, 0.95fr) minmax(380px, 1fr);
}

.gen-left,
.gen-center,
.gen-right,
.video-left,
.video-center,
.video-right {
  gap: 14px;
  scrollbar-gutter: stable;
}

.gen-section {
  border-radius: 10px;
  border-color: rgba(236, 239, 244, 0.022);
  background: rgba(255, 255, 255, 0.008);
  padding: 14px;
}

.gen-section:hover {
  border-color: rgba(236, 239, 244, 0.045);
  background: rgba(255, 255, 255, 0.012);
}

.gen-section .gen-label {
  color: rgba(236, 239, 244, 0.54);
  font-size: 12px;
  font-weight: 620;
  margin-bottom: 10px;
}

.gen-hint,
.prompt-hint,
.char-count,
.result-status,
.history-empty,
.task-empty,
.video-placeholder,
.result-placeholder {
  color: rgba(236, 239, 244, 0.38);
}

.style-presets,
.prompt-actions {
  gap: 8px;
}

.style-btn,
.prompt-action-btn {
  min-height: 34px;
  border-radius: 999px;
  padding: 0 12px;
}

.style-btn.active,
.ratio-btn.active,
.count-btn.active,
.prompt-mode-tab.active,
.template-capsule.active {
  border-color: rgba(143, 163, 216, 0.34);
  background: rgba(143, 163, 216, 0.1);
  color: rgba(236, 239, 244, 0.92);
}

.ref-grid,
.ref-slots-video {
  gap: 10px;
}

.ref-slot,
.ref-slot-video {
  border-radius: 8px;
  border-color: rgba(236, 239, 244, 0.055);
  background: rgba(0, 0, 0, 0.1);
  color: rgba(236, 239, 244, 0.26);
}

.ref-slot:hover,
.ref-slot-video:hover {
  border-color: rgba(143, 163, 216, 0.18);
  color: rgba(236, 239, 244, 0.62);
  background: rgba(143, 163, 216, 0.026);
}

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

.ratio-btn,
.count-btn {
  min-height: 42px;
}

.gen-actions {
  gap: 10px;
  margin-top: auto;
}

.gen-actions .ghost-button {
  min-height: 46px;
  padding: 0 16px;
}

.gen-right .gen-section:first-child,
.video-right .gen-section:first-child,
.prompt-editor {
  flex: 1;
  min-height: 0;
}

.gen-right .gen-section:first-child,
.video-right .gen-section:first-child {
  display: flex;
  flex-direction: column;
}

.result-preview,
.video-preview {
  flex: 1;
  min-height: 360px;
  border-radius: 10px;
  border-color: rgba(236, 239, 244, 0.026);
  background:
    radial-gradient(circle at 50% 50%, rgba(236, 239, 244, 0.018), transparent 62%),
    rgba(0, 0, 0, 0.18);
}

.result-preview:hover,
.video-preview:hover {
  border-color: rgba(236, 239, 244, 0.05);
}

.result-preview img,
.video-preview video {
  width: 100%;
  height: 100%;
  max-height: none;
  object-fit: contain;
}

.video-preview {
  aspect-ratio: auto;
}

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

.action-btn,
.video-ctrl-btn {
  min-height: 40px;
}

.gen-history,
.video-params {
  min-height: 92px;
  height: auto;
  border-radius: 10px;
  border-color: rgba(236, 239, 244, 0.022);
  background: rgba(255, 255, 255, 0.008);
  padding: 14px;
}

.gen-history:hover,
.video-params:hover {
  border-color: rgba(236, 239, 244, 0.045);
  background: rgba(255, 255, 255, 0.012);
}

.gen-section textarea,
.prompt-textarea,
.custom-select-trigger,
.gen-input,
.param-slider input[type="range"] {
  border-color: rgba(236, 239, 244, 0.035);
}

.ratio-btn,
.count-btn,
.style-btn,
.prompt-action-btn,
.action-btn,
.video-ctrl-btn {
  border-color: rgba(236, 239, 244, 0.032);
  background: rgba(255, 255, 255, 0.006);
}

.video-params {
  align-items: end;
  gap: 18px;
}

.param-group {
  gap: 7px;
}

.param-label {
  color: rgba(236, 239, 244, 0.5);
  font-size: 12px;
  font-weight: 560;
}

.param-select {
  min-width: 112px;
}

.param-slider input[type="range"] {
  width: 120px;
  accent-color: var(--accent);
}

.prompt-mode-tabs {
  border: 1px solid rgba(236, 239, 244, 0.035);
  border-radius: 8px;
  padding: 3px;
  gap: 4px;
  background: rgba(0, 0, 0, 0.08);
}

.prompt-mode-tab {
  flex: 1;
  min-height: 36px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(236, 239, 244, 0.52);
}

.prompt-mode-tab.active {
  margin-bottom: 0;
  border: 0;
  background: rgba(143, 163, 216, 0.045);
}

.native-select-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.custom-select {
  position: relative;
  display: inline-block;
  width: 100%;
  min-width: 0;
}

.topbar-canvas-controls .custom-select,
.composer-actions .custom-select,
.gen-toolbar .custom-select,
.param-group .custom-select {
  width: auto;
}

.custom-select-trigger {
  width: 100%;
  min-height: 38px;
  justify-content: space-between;
  padding: 0 34px 0 12px;
  border-color: rgba(236, 239, 244, 0.045);
  background: rgba(0, 0, 0, 0.18);
  color: rgba(236, 239, 244, 0.74);
  font-size: 13px;
  font-weight: 480;
  text-align: left;
  position: relative;
}

.custom-select-trigger::after {
  content: "";
  position: absolute;
  right: 12px;
  top: 50%;
  width: 7px;
  height: 7px;
  border-right: 1px solid rgba(236, 239, 244, 0.42);
  border-bottom: 1px solid rgba(236, 239, 244, 0.42);
  transform: translateY(-65%) rotate(45deg);
}

.custom-select.open .custom-select-trigger {
  border-color: rgba(143, 163, 216, 0.22);
  background: rgba(6, 9, 12, 0.92);
}

.custom-select-list {
  position: absolute;
  z-index: 300;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  display: none;
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid rgba(236, 239, 244, 0.055);
  border-radius: 8px;
  background: rgba(12, 15, 19, 0.98);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.32);
}

.custom-select.drop-up .custom-select-list {
  top: auto;
  bottom: calc(100% + 6px);
}

.custom-select.open .custom-select-list {
  display: grid;
  gap: 2px;
}

.custom-select-group {
  padding: 8px 9px 4px;
  color: rgba(236, 239, 244, 0.35);
  font-size: 11px;
  font-weight: 620;
}

.custom-select-option {
  width: 100%;
  min-height: 34px;
  justify-content: flex-start;
  padding: 0 10px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: rgba(236, 239, 244, 0.72);
  font-size: 13px;
}

.custom-select-option:hover,
.custom-select-option[aria-selected="true"] {
  background: rgba(143, 163, 216, 0.1);
  color: rgba(236, 239, 244, 0.94);
}

.topbar-canvas-controls .custom-select-trigger,
.composer-actions .custom-select-trigger,
.gen-toolbar .custom-select-trigger {
  min-height: 34px;
  font-size: 12px;
}

.param-group .custom-select-trigger {
  min-width: 132px;
}

.ref-slot-video .slot-icon {
  width: 34px;
  height: 24px;
  display: grid;
  place-items: center;
  margin-bottom: 6px;
  border: 1px solid rgba(236, 239, 244, 0.045);
  border-radius: 5px;
  color: transparent;
  font-size: 0;
  background: rgba(255, 255, 255, 0.012);
}

.ref-slot-video .slot-icon::before {
  color: rgba(236, 239, 244, 0.34);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0.04em;
}

.ref-slot-video[data-type="image"] .slot-icon::before {
  content: "IMG";
}

.ref-slot-video[data-type="video"] .slot-icon::before {
  content: "VID";
}

.ref-slot-video[data-type="audio"] .slot-icon::before {
  content: "AUD";
}

.prompt-textarea {
  border-radius: 8px;
  min-height: 0;
}

.video-center .prompt-editor {
  min-height: 0;
  overflow: hidden;
}

.video-center .prompt-textarea {
  flex: 1;
}

.task-item {
  border-radius: 8px;
  border-color: rgba(236, 239, 244, 0.07);
  background: rgba(255, 255, 255, 0.026);
}

.task-status.pending,
.task-status.processing,
.task-status.done,
.task-status.failed {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: rgba(236, 239, 244, 0.14);
}

::-webkit-scrollbar-thumb:hover {
  background: rgba(236, 239, 244, 0.24);
}

@media (max-width: 1180px) {
  .gen-main,
  .video-main {
    grid-template-columns: minmax(250px, 300px) minmax(320px, 1fr);
  }

  .gen-right,
  .video-right {
    grid-column: 1 / -1;
    min-height: 360px;
  }

  .result-preview,
  .video-preview {
    min-height: 320px;
  }
}

@media (max-width: 820px) {
  body {
    overflow: auto;
    height: auto;
    min-height: 100vh;
  }

  .topbar {
    position: sticky;
    grid-template-columns: 1fr auto;
    height: auto;
    min-height: var(--topbar-h);
    padding: 0 14px;
  }

  .topbar-nav {
    overflow-x: auto;
    gap: 10px;
  }

  .topbar-right {
    display: none;
  }

  .gen-layout,
  .video-layout {
    height: auto;
    min-height: calc(100vh - var(--topbar-h));
    overflow: visible;
    padding: 14px;
  }

  .gen-main,
  .video-main {
    display: flex;
    flex-direction: column;
    overflow: visible;
  }

  .gen-left,
  .gen-center,
  .gen-right,
  .video-left,
  .video-center,
  .video-right {
    overflow: visible;
  }

  .result-preview,
  .video-preview {
    min-height: 280px;
  }
}
