/* ═══════════════════════════════════════════════════════════
   Level Design Toolkit — Industrial Studio Aesthetic
   Typography: DM Sans + Noto Sans SC + JetBrains Mono
   Palette: Deep midnight + warm amber accent + cool teal
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── Base Surfaces ── */
  --bg: #0b0c10; --bg2: #0f1016;
  --surface: #14161e; --surface2: #1a1d28; --surface3: #222636;
  --surface-glass: rgba(20,22,30,.85);
  /* ── Borders ── */
  --border: #262a3a; --border2: #353a52;
  --border-glow: rgba(245,166,35,.12);
  /* ── Typography ── */
  --text: #e8eaf0; --text2: #9399b2; --text3: #5d6380;
  /* ── Accent: Warm Amber ── */
  --accent: #f5a623; --accent-dim: rgba(245,166,35,.12);
  --accent-hover: #ffbd45;
  /* ── Secondary: Cool Teal ── */
  --accent2: #4ecdc4; --accent2-dim: rgba(78,205,196,.10);
  /* ── Semantic ── */
  --red: #ef5350; --red-dim: rgba(239,83,80,.10);
  --green: #66bb6a; --green-dim: rgba(102,187,106,.10);
  --orange: #ffa726; --orange-dim: rgba(255,167,38,.10);
  --yellow: #ffee58; --yellow-dim: rgba(255,238,88,.10);
  --blue: #42a5f5; --blue-dim: rgba(66,165,245,.10);
  --pink: #ec407a;
  /* ── Spacing & Shape ── */
  --radius: 10px; --radius-sm: 6px; --radius-xs: 4px;
  --taskbar-w: 220px;
  --chat-w: 460px;
  --shadow: 0 4px 24px rgba(0,0,0,.4);
  --shadow-sm: 0 2px 8px rgba(0,0,0,.25);
  --scale: 1.5;
  /* ── Transitions ── */
  --ease: cubic-bezier(.22,.68,0,1);
  --dur: .2s;
}

* { margin:0; padding:0; box-sizing:border-box; }
html, body { height:100%; }
body {
  font-family: 'DM Sans', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: calc(14px * var(--scale));
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app { display:flex; height:100vh; overflow:hidden; }

/* ─── Scrollbar ─── */
::-webkit-scrollbar { width:6px; height:6px; }
::-webkit-scrollbar-track { background:transparent; }
::-webkit-scrollbar-thumb { background:var(--border); border-radius:3px; }
::-webkit-scrollbar-thumb:hover { background:var(--border2); }

/* ═══════════ COLUMN 1: TASK BAR ═══════════ */
.taskbar {
  width: var(--taskbar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column; align-items: stretch;
  padding: 16px 10px; gap: 4px; flex-shrink: 0;
}
.tb-logo {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 12px; cursor: default; padding: 0 6px;
}
.tb-logo-icon {
  font-size: calc(22px * var(--scale));
  filter: drop-shadow(0 0 8px rgba(245,166,35,.4));
}
.tb-logo::after {
  content: 'Level Design';
  font-size: calc(12px * var(--scale));
  font-weight: 600;
  color: var(--text2);
  letter-spacing: .5px;
}
.tb-btn {
  height: calc(34px * var(--scale)); border: none; border-radius: var(--radius-sm);
  background: transparent; color: var(--text2); font-size: calc(13px * var(--scale));
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all var(--dur) var(--ease); padding: 0 12px;
}
.tb-btn:hover { background: var(--surface2); color: var(--text); }
.tb-new {
  background: linear-gradient(135deg, var(--accent-dim), rgba(245,166,35,.06));
  color: var(--accent); font-weight: 600; font-size: calc(13px * var(--scale));
  margin-bottom: 4px; border: 1px solid rgba(245,166,35,.15);
}
.tb-new:hover {
  background: linear-gradient(135deg, var(--accent), #e09000);
  color: #fff; border-color: var(--accent);
  box-shadow: 0 0 20px rgba(245,166,35,.25);
}
.tb-new::after { content: '新建项目'; font-size: calc(12px * var(--scale)); }

.tb-import {
  background: linear-gradient(135deg, rgba(80,160,255,.08), rgba(80,160,255,.03));
  color: var(--text2); font-weight: 600; font-size: calc(13px * var(--scale));
  margin-bottom: 10px; border: 1px solid rgba(80,160,255,.18);
}
.tb-import:hover {
  background: linear-gradient(135deg, rgba(80,160,255,.6), rgba(40,120,220,.7));
  color: #fff; border-color: rgba(80,160,255,.7);
  box-shadow: 0 0 20px rgba(80,160,255,.2);
}
.tb-import::after { content: '导入项目'; font-size: calc(12px * var(--scale)); }

.tb-projects { flex: 1; overflow-y: auto; width: 100%; display: flex; flex-direction: column; gap: 2px; padding: 4px 0; }
.tb-project {
  width: 36px; height: 36px; border-radius: var(--radius-sm); border: none;
  background: var(--surface2); color: var(--text2); font-size: 11px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all var(--dur) var(--ease); position: relative; overflow: hidden;
}
.tb-project:hover { background: var(--surface3); color: var(--text); }
.tb-project.active { background: var(--accent-dim); color: var(--accent); border: 1px solid var(--accent); }
.tb-project .tb-initials { pointer-events: none; }
.tb-bottom { margin-top: auto; padding-top: 10px; border-top: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tb-version { font-size: 9px; color: var(--text3); font-family: 'JetBrains Mono', monospace; opacity: 0.6; user-select: text; cursor: default; }

/* ═══════════ COLUMN 2: CHAT PANEL ═══════════ */
.chat-panel {
  width: var(--chat-w); background: var(--bg2); border-right: 1px solid var(--border);
  display: flex; flex-direction: column; flex-shrink: 0;
}
.chat-header {
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  display: flex; flex-direction: row; align-items: center; gap: 8px;
  background: linear-gradient(180deg, var(--surface), transparent);
}
.chat-header-title { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; }
.chat-project-name {
  font-size: calc(15px * var(--scale)); font-weight: 600; color: var(--text);
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chat-version {
  font-size: calc(10px * var(--scale));
  background: var(--accent-dim); color: var(--accent);
  padding: 3px 8px; border-radius: 10px;
  font-weight: 600; font-family: 'JetBrains Mono', monospace;
}
.chat-header-actions { display: flex; gap: 6px; }
.chat-select {
  flex: 1; padding: 4px 8px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text2); font-size: 11px;
}
.chat-select:focus { outline: none; border-color: var(--accent); }

/* Manual save button */
.btn-manual-save {
  flex-shrink: 0;
  padding: 4px 12px; border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text2);
  border: 1px solid var(--border); cursor: pointer;
  font-size: calc(12px * var(--scale)); font-weight: 500;
  transition: all .15s;
  white-space: nowrap;
}
.btn-manual-save:hover { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }
.btn-manual-save:active { transform: scale(.96); }
.btn-manual-save:disabled { opacity: .5; cursor: wait; }

/* Save toast notification */
.save-toast {
  position: fixed; top: 20px; right: 20px; z-index: 99999;
  padding: 10px 20px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  opacity: 0; transform: translateY(-10px);
  transition: opacity .3s, transform .3s;
  pointer-events: none; box-shadow: 0 4px 12px rgba(0,0,0,.15);
}
.save-toast.show { opacity: 1; transform: translateY(0); }
.save-toast-success { background: #0d7c3e; color: #fff; }
.save-toast-warning { background: #b45309; color: #fff; }
.save-toast-error { background: #c0392b; color: #fff; }

/* Messages */
.chat-messages { flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 14px; }

.chat-welcome {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; text-align: center; padding: 28px;
}
.welcome-icon {
  font-size: calc(48px * var(--scale)); margin-bottom: 16px;
  filter: drop-shadow(0 0 20px rgba(245,166,35,.3));
  animation: welcomePulse 3s ease-in-out infinite;
}
@keyframes welcomePulse {
  0%,100% { transform: scale(1); filter: drop-shadow(0 0 20px rgba(245,166,35,.3)); }
  50% { transform: scale(1.05); filter: drop-shadow(0 0 30px rgba(245,166,35,.5)); }
}
.welcome-title {
  font-size: calc(18px * var(--scale)); font-weight: 700; margin-bottom: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  background-clip: text;
}
.welcome-sub {
  font-size: calc(12px * var(--scale)); color: var(--text3);
  margin-bottom: 24px; max-width: 380px; line-height: 1.7;
}
.welcome-hints { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 380px; }
.hint {
  padding: 10px 14px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); font-size: calc(12px * var(--scale)); color: var(--text2);
  cursor: pointer; transition: all var(--dur) var(--ease); text-align: left;
}
.hint:hover {
  border-color: var(--accent); background: var(--accent-dim); color: var(--accent);
  transform: translateX(4px);
}

/* Message bubbles */
.chat-msg { display: flex; flex-direction: column; gap: 4px; }
.chat-msg.user { align-items: flex-end; }
.chat-msg.assistant { align-items: flex-start; }
.chat-msg-bubble {
  max-width: 90%; padding: 12px 16px; border-radius: 14px;
  font-size: calc(13px * var(--scale)); line-height: 1.7; word-break: break-word;
}
.chat-msg.user .chat-msg-bubble {
  background: linear-gradient(135deg, var(--accent), #e09000);
  color: #fff; border-bottom-right-radius: 4px;
}
.chat-msg.assistant .chat-msg-bubble {
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.chat-msg-time { font-size: calc(10px * var(--scale)); color: var(--text3); }
.chat-msg-actions { display: flex; gap: 4px; margin-top: 4px; }
.chat-msg-action {
  padding: 3px 8px; background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-xs); font-size: calc(10px * var(--scale)); color: var(--text2); cursor: pointer;
}
.chat-msg-action:hover { border-color: var(--accent); color: var(--accent); }

/* Typing indicator */
.chat-typing { display: flex; align-items: center; gap: 6px; padding: 8px 14px; }
.chat-typing-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--accent);
  animation: typing-bounce .6s ease-in-out infinite;
}
.chat-typing-dot:nth-child(2) { animation-delay: .15s; }
.chat-typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes typing-bounce { 0%,100%{opacity:.3;transform:translateY(0)} 50%{opacity:1;transform:translateY(-4px)} }

/* Input area */
.chat-input-area { padding: 14px 18px; border-top: 1px solid var(--border); background: var(--bg2); }
.chat-input-row { display: flex; gap: 10px; align-items: stretch; }
.chat-input {
  flex: 1; padding: 12px 16px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text); font-size: calc(13px * var(--scale));
  font-family: 'DM Sans', 'Noto Sans SC', sans-serif;
  resize: vertical; min-height: 120px; max-height: 300px; line-height: 1.6;
  transition: border-color var(--dur) var(--ease);
}
.chat-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.chat-send {
  width: 40px; height: 40px; border: none; border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent), #e09000);
  color: #fff; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all var(--dur) var(--ease); flex-shrink: 0;
  align-self: flex-end;
}
.chat-send:hover { transform: scale(1.05); box-shadow: 0 0 16px rgba(245,166,35,.35); }
.chat-send:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.chat-send.stop-mode {
  background: linear-gradient(135deg, #e74c3c, #c0392b);
  animation: stop-pulse 1.5s ease-in-out infinite;
}
.chat-send.stop-mode:hover {
  box-shadow: 0 0 16px rgba(231,76,60,.5);
  transform: scale(1.05);
}
@keyframes stop-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.8; }
}
.chat-input-hints { font-size: calc(10px * var(--scale)); color: var(--text3); margin-top: 8px; }
.chat-hint-key {
  display: inline-block; padding: 1px 5px; background: var(--surface2);
  border: 1px solid var(--border); border-radius: 3px; font-size: calc(9px * var(--scale));
  font-family: 'JetBrains Mono', monospace;
}

/* ═══════════ COLUMN 3: PREVIEW PANEL ═══════════ */
.preview-panel { flex: 1; display: flex; flex-direction: column; background: var(--bg); overflow: hidden; position: relative; }

/* Tab bar */
.preview-tabs {
  display: flex; align-items: center; padding: 0 12px; height: 44px;
  background: var(--surface); border-bottom: 1px solid var(--border); flex-shrink: 0;
  gap: 2px;
}
.ptab {
  padding: 10px 16px; border: none; background: transparent; color: var(--text3);
  font-size: calc(12px * var(--scale)); cursor: pointer; border-bottom: 2px solid transparent;
  transition: all var(--dur) var(--ease); white-space: nowrap; font-weight: 500;
}
.ptab:hover { color: var(--text2); background: var(--surface2); border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ptab.active {
  color: var(--accent); border-bottom-color: var(--accent); font-weight: 600;
  text-shadow: 0 0 12px rgba(245,166,35,.25);
}
.ptab-spacer { flex: 1; }
.ptab-action { color: var(--text2); font-size: 14px; }
.ptab-action:hover { color: var(--accent); }

/* Tab content */
.tab-content { display: none; flex: 1; overflow-y: auto; }
.tab-content.active { display: flex; flex-direction: column; }

/* Empty states */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  flex: 1; padding: 40px;
}
.empty-icon { font-size: calc(48px * var(--scale)); opacity: .3; margin-bottom: 16px; }
.empty-title { font-size: calc(16px * var(--scale)); font-weight: 600; color: var(--text2); margin-bottom: 8px; }
.empty-sub { font-size: calc(12px * var(--scale)); color: var(--text3); text-align: center; max-width: 420px; line-height: 1.7; }

/* ═══ LDD Doc tab ═══ */
.ldd-doc-container { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.ldd-doc-view {
  flex: 1; padding: 28px 36px; overflow-y: auto;
  font-size: calc(13px * var(--scale)); line-height: 1.8;
}
.ldd-doc-view h2 {
  font-size: calc(18px * var(--scale)); margin: 24px 0 10px;
  color: var(--accent); border-bottom: 2px solid var(--border); padding-bottom: 8px;
  font-weight: 700; letter-spacing: .3px;
}
.ldd-doc-view h3 { font-size: calc(15px * var(--scale)); margin: 16px 0 8px; color: var(--text); font-weight: 600; }
.ldd-doc-view h4 { font-size: calc(13px * var(--scale)); margin: 12px 0 6px; color: var(--text2); font-weight: 600; }
.ldd-doc-view p { margin: 6px 0; color: var(--text2); }
.ldd-doc-view ul, .ldd-doc-view ol { padding-left: 20px; margin: 4px 0; }
.ldd-doc-view li { margin: 2px 0; color: var(--text2); }
.ldd-doc-view code {
  background: var(--surface2); padding: 2px 6px; border-radius: 4px;
  font-size: calc(11px * var(--scale)); font-family: 'JetBrains Mono', monospace;
  color: var(--accent2);
}
.ldd-doc-view pre {
  background: var(--surface); padding: 14px; border-radius: var(--radius-sm);
  overflow-x: auto; font-size: calc(11px * var(--scale)); margin: 10px 0;
  font-family: 'JetBrains Mono', monospace; border: 1px solid var(--border);
}
.ldd-doc-view table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: calc(11px * var(--scale)); }
.ldd-doc-view th, .ldd-doc-view td {
  padding: 8px 12px; border: 1px solid var(--border); text-align: left;
}
.ldd-doc-view th { background: var(--surface); color: var(--text); font-weight: 600; }
.ldd-doc-view blockquote {
  border-left: 3px solid var(--accent); padding: 8px 14px; margin: 10px 0;
  color: var(--text3); font-style: italic; background: var(--surface2); border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* ═══ 3D Map tab ═══ */
.map3d-main-row { flex: 1; display: flex; position: relative; min-height: 0; }
.map3d-container { flex: 1; display: flex; position: relative; }
#tab-3d-map { position: relative; flex-direction: column; }
#tab-3d-map.active { display: flex; }
.map3d-sidebar {
  width: 300px; background: var(--surface); border-left: 1px solid var(--border);
  overflow-y: auto; flex-shrink: 0;
}
.sidebar-header { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sidebar-header h3 { font-size: calc(14px * var(--scale)); font-weight: 600; }
.sidebar-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 16px; transition: color .15s; }
.sidebar-close:hover { color: var(--text); }
.sidebar-section { padding: 14px 16px; border-bottom: 1px solid var(--border); }
.sidebar-section h4 {
  font-size: calc(10px * var(--scale)); text-transform: uppercase; letter-spacing: 1px;
  color: var(--text3); margin-bottom: 10px; font-weight: 600;
}
.region-list, .flow-list { font-size: calc(12px * var(--scale)); }
.region-item, .flow-item {
  display: flex; align-items: center; gap: 8px; padding: 5px 0;
  cursor: pointer; color: var(--text2); transition: all .15s;
}
.region-item:hover, .flow-item:hover { color: var(--accent); transform: translateX(2px); }
.region-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.topo-stats-mini { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: calc(11px * var(--scale)); }
.topo-stat-mini { display: flex; justify-content: space-between; padding: 4px 0; border-bottom: 1px solid var(--border); }
.topo-stat-mini .label { color: var(--text3); }
.topo-stat-mini .value { color: var(--accent2); font-weight: 600; font-variant-numeric: tabular-nums; font-family: 'JetBrains Mono', monospace; }

.map3d-sidebar-toggle {
  position: absolute; right: 14px; top: 14px; z-index: 10;
  width: 34px; height: 34px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  background: var(--surface-glass); color: var(--text2); font-size: 14px;
  cursor: pointer; backdrop-filter: blur(8px); transition: all .15s;
}
.map3d-sidebar-toggle:hover { border-color: var(--accent); color: var(--accent); }

/* ═══ AI Toolbar for 3D Map ═══ */
.map3d-ai-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: var(--surface); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.btn-ai {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 14px; border-radius: var(--radius-sm);
  font-size: calc(12px * var(--scale)); font-weight: 500;
  cursor: pointer; transition: all .2s;
  border: 1px solid color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--accent);
}
.btn-ai:hover {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  border-color: var(--accent);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent) 20%, transparent);
}
.btn-ai:active { transform: scale(0.97); }
.btn-ai:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-ai-sync {
  border-color: color-mix(in srgb, var(--accent2) 40%, transparent);
  background: color-mix(in srgb, var(--accent2) 8%, var(--surface));
  color: var(--accent2);
}
.btn-ai-sync:hover {
  background: color-mix(in srgb, var(--accent2) 18%, var(--surface));
  border-color: var(--accent2);
  box-shadow: 0 0 12px color-mix(in srgb, var(--accent2) 20%, transparent);
}
.btn-regenerate-map {
  padding: 5px 12px; font-size: calc(12px * var(--scale));
  margin-left: auto;
  border-color: color-mix(in srgb, var(--accent) 40%, transparent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--accent);
}
.btn-regenerate-map:hover {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface));
  border-color: var(--accent);
}
.btn-refresh-map {
  padding: 5px 12px; font-size: calc(12px * var(--scale));
}
.ai-icon { font-size: 14px; }
.ai-toolbar-status {
  font-size: calc(11px * var(--scale)); color: var(--text3);
  font-style: italic;
}
.ai-toolbar-status.loading { color: var(--accent); animation: pulse 1.5s infinite; }
.ai-toolbar-status.success { color: var(--green, #4ade80); }
.ai-toolbar-status.error { color: var(--red, #f87171); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* AI analysis result panel in the sidebar */
.ai-result-panel {
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.ai-result-panel h4 {
  font-size: calc(11px * var(--scale)); text-transform: uppercase; letter-spacing: .8px;
  color: var(--accent); margin-bottom: 10px; font-weight: 600;
}
.ai-result-content {
  font-size: calc(12px * var(--scale)); color: var(--text2); line-height: 1.6;
  max-height: 400px; overflow-y: auto;
}
.ai-result-content h5 { color: var(--text); margin: 10px 0 4px; font-size: calc(12px * var(--scale)); }
.ai-result-content ul { margin: 4px 0; padding-left: 18px; }
.ai-result-content li { margin: 2px 0; }
.ai-suggestion-item {
  padding: 8px 10px; margin: 6px 0; border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border-left: 3px solid var(--accent);
}
.ai-suggestion-item.warning { border-left-color: var(--yellow, #fbbf24); }
.ai-suggestion-item.error { border-left-color: var(--red, #f87171); }
.ai-apply-btn {
  margin-top: 4px; padding: 2px 8px; font-size: calc(10px * var(--scale));
  border: 1px solid var(--accent); border-radius: 3px; background: transparent;
  color: var(--accent); cursor: pointer; transition: all .15s;
}
.ai-apply-btn:hover { background: var(--accent); color: var(--bg); }

/* ═══ Topology ═══ */
.topo-container { flex: 1; display: flex; flex-direction: column; padding: 16px; gap: 16px; }

/* ═══ Flow/Emotion: Interactive Timeline Chart ═══ */
.flow-emotion-container { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
#emotionChartArea { flex: 1; display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
.emotion-header { display: flex; justify-content: space-between; align-items: center; padding: 18px 24px 10px; flex-shrink: 0; }
.emotion-header h3 { font-size: calc(14px * var(--scale)); font-weight: 700; }
.emotion-stats {
  display: flex; gap: 16px; font-size: calc(11px * var(--scale)); color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
}

.timeline-chart-wrap {
  position: relative; padding: 0 24px; height: 380px; min-height: 280px; flex-shrink: 0;
  cursor: crosshair; user-select: none;
}
.timeline-chart-wrap canvas { width: 100% !important; height: 100% !important; display: block; border-radius: var(--radius); }

/* Hover tooltip */
.timeline-tooltip {
  position: absolute; z-index: 50; pointer-events: none;
  background: var(--surface-glass); border: 1px solid var(--border2); border-radius: var(--radius);
  padding: 12px 16px; font-size: calc(12px * var(--scale)); color: var(--text);
  box-shadow: var(--shadow); max-width: 340px; transition: opacity .12s;
  backdrop-filter: blur(12px);
}
.timeline-tooltip .tt-time { font-family: 'JetBrains Mono', monospace; color: var(--accent); font-size: calc(11px * var(--scale)); font-weight: 600; }
.timeline-tooltip .tt-type { display: inline-block; padding: 2px 8px; border-radius: 4px; font-size: calc(10px * var(--scale)); margin-left: 8px; font-weight: 500; }
.timeline-tooltip .tt-desc { margin-top: 6px; color: var(--text2); line-height: 1.6; }
.timeline-tooltip .tt-location { margin-top: 4px; color: var(--text3); font-size: calc(10px * var(--scale)); }
.timeline-tooltip .tt-detail { margin-top: 4px; color: var(--text3); font-size: calc(10px * var(--scale)); font-style: italic; line-height: 1.5; max-height: 60px; overflow: hidden; }

/* Expanded event detail panel */
.event-detail-panel {
  padding: 14px 24px; background: var(--surface); border-top: 1px solid var(--border);
  position: relative; overflow-y: auto; flex-shrink: 0;
  animation: slideUp .2s var(--ease);
}
@keyframes slideUp { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.event-detail-close {
  position: absolute; right: 14px; top: 10px; background: none; border: none;
  color: var(--text3); cursor: pointer; font-size: 14px;
}
.event-detail-close:hover { color: var(--text); }

/* Legend bar */
.timeline-legend {
  display: flex; gap: 16px; padding: 10px 24px; flex-shrink: 0;
  font-size: calc(11px * var(--scale)); color: var(--text3); border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.legend-dot { width: 10px; height: 10px; border-radius: 50%; }

/* ═══ Event sequence table ═══ */
.event-table-section {
  flex: 1; min-height: 0; display: flex; flex-direction: column;
  border-top: 1px solid var(--border); padding: 0;
}
.event-table-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 24px 8px;
}
.event-table-header h4 {
  font-size: calc(13px * var(--scale)); font-weight: 700; margin: 0;
}
.event-table-count {
  font-size: calc(11px * var(--scale)); color: var(--text3); font-family: 'JetBrains Mono', monospace;
}
.event-table-scroll {
  flex: 1; min-height: 120px; overflow-y: auto; padding: 0 24px 16px;
}
.event-table {
  width: 100%; border-collapse: collapse; font-size: calc(12px * var(--scale));
}
.event-table thead { position: sticky; top: 0; z-index: 2; }
.event-table th {
  text-align: left; padding: 8px 10px; background: var(--bg2);
  color: var(--text3); font-weight: 600; font-size: calc(11px * var(--scale));
  border-bottom: 1px solid var(--border2); white-space: nowrap;
}
.event-table td {
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  color: var(--text2); vertical-align: top; line-height: 1.5;
}
.event-table tbody tr { cursor: pointer; transition: background .12s; }
.event-table tbody tr:hover { background: rgba(108,99,255,0.06); }
.event-table tbody tr.et-selected { background: rgba(108,99,255,0.12); }
.event-table tbody tr.et-selected td { color: var(--text); }
.et-col-idx { width: 36px; text-align: center; }
.et-col-time { width: 70px; font-family: 'JetBrains Mono', monospace; }
.et-col-type { width: 60px; }
.et-col-intensity { width: 60px; text-align: center; }
.et-col-location { width: 100px; }
.et-type-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: calc(10px * var(--scale)); font-weight: 500; white-space: nowrap;
}
.et-intensity-bar {
  display: inline-block; height: 6px; border-radius: 3px; min-width: 4px;
  vertical-align: middle;
}

/* ═══════════ Manual / Tutorial Overlay ═══════════ */
.manual-overlay {
  position: absolute; inset: 0; z-index: 110;
  background: rgba(0,0,0,.75); display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); animation: fadeIn .15s var(--ease);
}
.manual-dialog {
  width: 94vw; max-width: 1100px; height: 92vh; background: var(--surface);
  border-radius: var(--radius); border: 1px solid var(--border);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.manual-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 24px; border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.manual-header h2 { margin: 0; font-size: calc(18px * var(--scale)); font-weight: 700; color: var(--text); }
.manual-close {
  background: none; border: none; color: var(--text3); cursor: pointer;
  font-size: 20px; padding: 4px 8px; border-radius: 6px;
  transition: background .15s, color .15s;
}
.manual-close:hover { background: var(--surface2); color: var(--text); }

.manual-layout {
  display: flex; flex: 1; overflow: hidden;
}

/* ── Manual Nav ── */
.manual-nav {
  width: 200px; min-width: 180px; flex-shrink: 0;
  border-right: 1px solid var(--border); padding: 16px 0;
  overflow-y: auto; background: var(--surface);
}
.manual-nav-title {
  font-size: calc(10px * var(--scale)); font-weight: 700; color: var(--text3);
  text-transform: uppercase; letter-spacing: 1px;
  padding: 0 16px 10px; border-bottom: 1px solid var(--border); margin-bottom: 8px;
}
.manual-nav-item {
  display: block; padding: 7px 16px; color: var(--text2);
  font-size: calc(12px * var(--scale)); cursor: pointer; text-decoration: none;
  border-left: 3px solid transparent; transition: all .15s;
}
.manual-nav-item:hover { background: var(--surface2); color: var(--text); }
.manual-nav-item.active {
  border-left-color: var(--accent); color: var(--accent); font-weight: 600;
  background: var(--accent-dim);
}

/* ── Manual Body ── */
.manual-body {
  flex: 1; overflow-y: auto; padding: 24px 32px 48px;
  scroll-behavior: smooth;
}
.manual-body section {
  margin-bottom: 40px; padding-bottom: 24px;
  border-bottom: 1px solid var(--border);
}
.manual-body section:last-child { border-bottom: none; }
.manual-body h3 {
  font-size: calc(18px * var(--scale)); font-weight: 700; color: var(--text);
  margin: 0 0 14px;
}
.manual-body h4 {
  font-size: calc(14px * var(--scale)); font-weight: 600; color: var(--accent2);
  margin: 20px 0 10px;
}
.manual-body p {
  font-size: calc(13px * var(--scale)); color: var(--text2); line-height: 1.7;
  margin: 0 0 12px;
}
.manual-body ul, .manual-body ol {
  font-size: calc(13px * var(--scale)); color: var(--text2); line-height: 1.7;
  padding-left: 20px; margin: 0 0 12px;
}
.manual-body li { margin-bottom: 4px; }
.manual-body code {
  background: var(--surface2); padding: 1px 6px; border-radius: 4px;
  font-size: calc(12px * var(--scale)); color: var(--accent);
}
.manual-body kbd {
  display: inline-block; background: var(--surface3); border: 1px solid var(--border);
  border-radius: 4px; padding: 1px 7px; font-size: calc(11px * var(--scale));
  font-family: var(--mono); color: var(--text); box-shadow: 0 1px 0 var(--border);
}
.manual-body em { color: var(--text3); font-style: italic; }
.manual-body strong { color: var(--text); }

/* Feature grid */
.manual-feature-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px;
  margin: 16px 0;
}
@media (max-width: 900px) { .manual-feature-grid { grid-template-columns: repeat(2, 1fr); } }
.manual-feature {
  display: flex; gap: 10px; padding: 12px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
}
.mf-icon { font-size: 22px; flex-shrink: 0; }
.manual-feature div { font-size: calc(12px * var(--scale)); color: var(--text2); line-height: 1.6; }
.manual-feature strong { font-size: calc(13px * var(--scale)); }

/* Callout */
.manual-callout {
  background: var(--accent-dim); border: 1px solid var(--accent);
  border-left: 4px solid var(--accent); border-radius: var(--radius-sm);
  padding: 12px 16px; margin: 16px 0;
  font-size: calc(12px * var(--scale)); line-height: 1.7; color: var(--text2);
}
.manual-callout strong { color: var(--text); }

/* Steps */
.manual-steps { margin: 12px 0; }
.manual-step {
  display: flex; gap: 14px; margin-bottom: 20px; position: relative;
}
.manual-step::before {
  content: ''; position: absolute; left: 16px; top: 34px; bottom: -20px;
  width: 2px; background: var(--border);
}
.manual-step:last-child::before { display: none; }
.ms-num {
  width: 32px; height: 32px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: var(--accent); color: var(--bg);
  font-size: 14px; font-weight: 700; z-index: 1;
}
.ms-content { flex: 1; }
.ms-content strong {
  display: block; font-size: calc(14px * var(--scale)); color: var(--text);
  margin-bottom: 6px;
}
.ms-content p { margin: 0 0 8px; }
.ms-content ul { margin: 4px 0 8px; }

.manual-tip {
  font-size: calc(11px * var(--scale)) !important;
  color: var(--text3) !important;
  background: var(--surface2); padding: 6px 10px; border-radius: 6px;
  margin-top: 6px;
}

/* Table */
.manual-table {
  width: 100%; border-collapse: collapse; margin: 12px 0;
  font-size: calc(12px * var(--scale));
}
.manual-table th {
  background: var(--surface2); color: var(--text); font-weight: 600;
  padding: 8px 12px; text-align: left; border: 1px solid var(--border);
}
.manual-table td {
  padding: 7px 12px; color: var(--text2); border: 1px solid var(--border);
}
.manual-table tr:hover td { background: var(--surface2); }

/* FAQ */
.manual-faq { margin: 12px 0; }
.faq-item {
  margin-bottom: 16px; padding: 12px 16px; border-radius: var(--radius-sm);
  background: var(--surface2); border: 1px solid var(--border);
}
.faq-q { font-weight: 600; color: var(--text); margin-bottom: 6px; font-size: calc(13px * var(--scale)); }
.faq-a { color: var(--text2); font-size: calc(12px * var(--scale)); line-height: 1.7; }

/* ═══════════ Settings Overlay ═══════════ */
.settings-overlay {
  position: absolute; inset: 0; z-index: 100;
  background: rgba(0,0,0,.7); display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); animation: fadeIn .15s var(--ease);
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.settings-dialog {
  width: 92vw; max-width: 1200px; height: 90vh; background: var(--surface);
  border-radius: var(--radius); border: 1px solid var(--border);
  overflow: hidden; display: flex; flex-direction: column; box-shadow: var(--shadow);
}
.settings-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 18px 24px; border-bottom: 1px solid var(--border);
}
.settings-header h2 { font-size: calc(16px * var(--scale)); font-weight: 700; }
.settings-header-actions { display: flex; align-items: center; gap: 12px; }
.settings-close { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 18px; transition: color .15s; }
.settings-close:hover { color: var(--text); }
.btn-accent {
  background: var(--accent); color: var(--bg); border: none; border-radius: var(--radius-sm);
  padding: 8px 18px; font-weight: 600; font-size: calc(13px * var(--scale)); cursor: pointer;
  transition: background .15s, transform .1s;
}
.btn-accent:hover { filter: brightness(1.15); transform: translateY(-1px); }
.btn-accent:active { transform: translateY(0); }
.btn-accent.saved { background: var(--green); }
.settings-body { flex: 1; overflow-y: auto; padding: 24px; }
.settings-section { margin-bottom: 28px; }
.settings-section h3 { font-size: calc(14px * var(--scale)); margin-bottom: 14px; color: var(--text2); font-weight: 600; }

/* Settings Tabs */
.settings-tabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  padding: 0 24px; background: var(--surface); flex-shrink: 0;
}
.settings-tab {
  padding: 12px 20px; font-size: calc(13px * var(--scale)); font-weight: 500;
  color: var(--text3); background: none; border: none; border-bottom: 2px solid transparent;
  cursor: pointer; transition: all .15s var(--ease); font-family: inherit;
  white-space: nowrap;
}
.settings-tab:hover { color: var(--text); background: rgba(255,255,255,.03); }
.settings-tab.active { color: var(--accent); border-bottom-color: var(--accent); font-weight: 600; }
.settings-tab-panel { display: none; }
.settings-tab-panel.active { display: block; }

/* ═══════════ Shared Components ═══════════ */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface2); color: var(--text); font-size: calc(13px * var(--scale));
  cursor: pointer; transition: all var(--dur) var(--ease); font-family: inherit;
}
.btn:hover { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #e09000);
  border-color: var(--accent); color: #fff;
}
.btn-primary:hover { box-shadow: 0 0 20px rgba(245,166,35,.3); }
.btn-sm { padding: 5px 10px; font-size: calc(11px * var(--scale)); }
.btn:disabled { opacity: .4; cursor: default; }

.field { margin-bottom: 12px; }
.field label { display: block; font-size: calc(11px * var(--scale)); color: var(--text3); margin-bottom: 5px; font-weight: 500; }
.field input, .field select, .field textarea {
  width: 100%; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: calc(12px * var(--scale)); font-family: inherit;
  transition: border-color var(--dur) var(--ease);
}
.field input:focus, .field select:focus, .field textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
.label-hint { color: var(--text3); font-size: 10px; }

.text-muted { color: var(--text3); font-size: 13px; }

/* Loading spinner */
.spinner {
  width: 28px; height: 28px; border: 3px solid var(--border);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .8s linear infinite; margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

.loading-state { display: flex; flex-direction: column; align-items: center; padding: 40px; }
.loading-text { font-size: 14px; color: var(--text2); margin-bottom: 4px; }
.loading-sub { font-size: 12px; color: var(--text3); }

/* JSON view */
.json-view {
  background: var(--surface); padding: 16px; border-radius: var(--radius-sm);
  font-size: calc(11px * var(--scale)); font-family: 'JetBrains Mono', monospace; color: var(--text2);
  overflow: auto; white-space: pre-wrap; word-break: break-word; border: 1px solid var(--border);
}

/* Topo stats */
.topo-val { font-size: 18px; font-weight: 700; font-variant-numeric: tabular-nums; font-family: 'JetBrains Mono', monospace; }
.topo-val.high { color: var(--green); }
.topo-val.mid { color: var(--yellow); }
.topo-val.low { color: var(--red); }

/* ═══════ Chat Bubbles ═══════ */
.chat-bubble { display: flex; flex-direction: column; max-width: 95%; animation: fadeInUp .25s var(--ease); }
.chat-user { align-self: flex-end; }
.chat-assistant { align-self: flex-start; }
.chat-system { align-self: center; }

.chat-bubble .bubble-content {
  padding: 12px 16px; border-radius: 14px;
  font-size: calc(13px * var(--scale)); line-height: 1.7; word-break: break-word;
}
.chat-user .bubble-content {
  background: linear-gradient(135deg, var(--accent), #e09000);
  color: #fff; border-bottom-right-radius: 4px;
}
.chat-assistant .bubble-content {
  background: var(--surface); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px;
}
.chat-assistant .bubble-content h2,
.chat-assistant .bubble-content h3,
.chat-assistant .bubble-content h4,
.chat-assistant .bubble-content h5 { margin: 10px 0 6px; }
.chat-assistant .bubble-content p { margin: 4px 0; }
.chat-assistant .bubble-content strong { color: var(--accent); }
.chat-assistant .bubble-content code { background: var(--surface2); padding: 2px 5px; border-radius: 4px; font-size: calc(11px * var(--scale)); font-family: 'JetBrains Mono', monospace; }

.chat-system .bubble-content.system-msg {
  background: var(--accent2-dim); color: var(--accent2); border-radius: 10px;
  font-size: calc(12px * var(--scale)); text-align: center; font-weight: 500;
}
.chat-system .bubble-content.system-msg.error {
  background: var(--red-dim); color: var(--red);
}

.chat-loading .bubble-content { color: var(--text3); }

.typing-dots span {
  display: inline-block; animation: typingBounce .6s ease-in-out infinite; font-weight: 700;
  color: var(--accent);
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce { 0%,100%{opacity:.3;transform:translateY(0)} 50%{opacity:1;transform:translateY(-3px)} }
@keyframes fadeInUp { from{opacity:0;transform:translateY(10px)} to{opacity:1;transform:translateY(0)} }

/* ═══════ Streaming Bubble ═══════ */
.chat-streaming .bubble-content { position: relative; }
.chat-streaming .stream-status {
  display: flex; align-items: center; gap: 6px;
  padding-top: 8px; color: var(--text3); font-size: calc(12px * var(--scale));
}
.stream-thinking {
  margin-bottom: 10px; border-radius: var(--radius-sm);
  background: rgba(245,166,35,0.06); border: 1px solid rgba(245,166,35,0.15);
}
.stream-thinking-header {
  display: flex; align-items: center; gap: 6px; padding: 8px 12px;
  cursor: pointer; font-size: calc(12px * var(--scale)); color: var(--accent);
  user-select: none;
}
.stream-thinking-header:hover { background: rgba(245,166,35,0.08); }
.stream-thinking-icon { font-size: 14px; }
.stream-thinking-label { flex: 1; font-weight: 500; }
.stream-thinking-toggle { font-size: 10px; color: var(--text3); }
.stream-thinking-body {
  padding: 0 12px 10px; font-size: calc(12px * var(--scale)); color: var(--text3);
  white-space: pre-wrap; word-break: break-word; max-height: 300px; overflow-y: auto;
  line-height: 1.5; font-family: var(--font-mono);
}
.stream-content {
  white-space: pre-wrap; word-break: break-word; line-height: 1.6;
}

/* ═══════ Stage Streaming Bubble (typewriter) ═══════ */
.streaming-bubble {
  animation: fadeInUp 0.3s ease;
}
.streaming-bubble .streaming-label {
  font-size: calc(11px * var(--scale)); color: var(--accent); font-weight: 600;
  margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px solid var(--border);
}
.streaming-bubble .streaming-content {
  font-family: var(--font-mono);
  font-size: calc(11px * var(--scale));
  color: var(--text2);
  white-space: pre-wrap; word-break: break-word;
  line-height: 1.5;
  max-height: 300px; overflow-y: auto;
  padding: 4px 0;
}
.streaming-cursor {
  display: inline-block;
  color: var(--accent);
  animation: cursorBlink 0.8s step-end infinite;
  font-weight: 700;
}
@keyframes cursorBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ═══════ Project list items ═══════ */
.project-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; padding: 9px 12px; border-radius: var(--radius-sm);
  background: transparent; cursor: pointer; transition: all var(--dur) var(--ease);
  position: relative; overflow: hidden; flex-shrink: 0;
}
.project-item:hover { background: var(--surface2); }
.project-item.active {
  background: var(--accent-dim); border: 1px solid rgba(245,166,35,.2);
}
.project-item .pi-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text3); flex-shrink: 0; transition: all .15s;
}
.project-item.active .pi-dot { background: var(--accent); box-shadow: 0 0 6px rgba(245,166,35,.5); }
.project-item .pi-name {
  font-size: calc(12px * var(--scale)); color: var(--text2); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; flex: 1;
}
.project-item.active .pi-name { color: var(--accent); font-weight: 600; }
.project-item .pi-delete {
  font-size: calc(12px * var(--scale)); color: var(--text3); cursor: pointer;
  opacity: 0; transition: all .15s; width: calc(18px * var(--scale)); height: calc(18px * var(--scale));
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%; background: transparent; flex-shrink: 0;
}
.project-item:hover .pi-delete { opacity: 1; }
.project-item .pi-delete:hover { color: var(--red); background: var(--red-dim); }

/* ITER-001: Level code badge */
.project-item .pi-level-code {
  font-size: calc(9px * var(--scale)); color: var(--accent); opacity: 0.8;
  background: rgba(245,166,35,0.1); padding: 1px 5px; border-radius: 3px;
  margin-left: 4px; white-space: nowrap; font-family: 'JetBrains Mono', monospace;
  letter-spacing: 0.5px;
}
.project-item.active .pi-level-code { opacity: 1; background: rgba(245,166,35,0.15); }

/* ═══════ Project Rename Input ═══════ */
.pi-rename-input {
  width: 100%; background: var(--bg2); border: 1px solid var(--accent);
  color: var(--text); font-size: calc(12px * var(--scale)); padding: 3px 8px;
  border-radius: var(--radius-sm); outline: none; font-family: inherit;
}

/* ═══════ Context Menu ═══════ */
.context-menu {
  position: fixed; z-index: 10000; background: var(--surface2);
  border: 1px solid var(--border2); border-radius: var(--radius);
  box-shadow: 0 8px 40px rgba(0,0,0,.6); min-width: 200px;
  padding: 6px 0; animation: ctxFadeIn .12s var(--ease);
  backdrop-filter: blur(8px);
}
@keyframes ctxFadeIn { from { opacity:0; transform: scale(.95) translateY(-4px); } to { opacity:1; transform: scale(1) translateY(0); } }
.ctx-item {
  padding: 9px 18px; font-size: calc(12px * var(--scale)); color: var(--text);
  cursor: pointer; display: flex; align-items: center; gap: 10px; transition: all .12s;
}
.ctx-item:hover { background: var(--accent-dim); color: var(--accent); }
.ctx-danger:hover { background: var(--red-dim); color: var(--red); }
.ctx-divider { height: 1px; background: var(--border); margin: 4px 10px; }

/* ═══════ Settings Provider Blocks ═══════ */
.settings-provider {
  margin-bottom: 20px; padding: 18px;
  background: var(--surface2); border-radius: var(--radius); border: 1px solid var(--border);
  transition: border-color .15s;
}
.settings-provider:hover { border-color: var(--border2); }
.sp-header {
  display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px;
}
.sp-header strong { font-size: calc(14px * var(--scale)); }
.sp-row { margin-bottom: 12px; }
.sp-row label {
  font-size: calc(11px * var(--scale)); color: var(--text3); display: block; margin-bottom: 4px; font-weight: 500;
}
.sp-input {
  width: 100%; padding: 8px 12px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text); font-size: calc(12px * var(--scale));
  font-family: 'JetBrains Mono', monospace; transition: border-color var(--dur);
}
.sp-input:focus { outline: none; border-color: var(--accent); }
.sp-input-group { display: flex; gap: 6px; align-items: flex-end; }
.sp-input-group .sp-input { flex: 1; }
.sp-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.preset-chip {
  display: inline-block; padding: 5px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 14px;
  font-size: calc(11px * var(--scale)); color: var(--text2); cursor: pointer;
  transition: all .15s;
}
.preset-chip:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.sp-test-result { font-size: calc(11px * var(--scale)); min-height: 16px; margin-top: 8px; }

/* ═══════ LDD Section ═══════ */
.ldd-section { margin-bottom: 24px; }
.ldd-section h2 { font-size: calc(16px * var(--scale)); color: var(--accent); border-bottom: 2px solid var(--border); padding-bottom: 8px; margin-bottom: 10px; }
.ldd-section p { font-size: calc(13px * var(--scale)); color: var(--text2); line-height: 1.8; margin: 5px 0; }

/* ═══════ LDD v0.4 Phase Blocks ═══════ */
.ldd-header { padding-bottom: 14px; border-bottom: 2px solid var(--accent); margin-bottom: 20px; }
.ldd-header h2 {
  margin: 0 0 6px; color: var(--text); font-size: calc(22px * var(--scale)); font-weight: 700;
  letter-spacing: -.2px;
}
.ldd-meta-row {
  font-size: calc(12px * var(--scale)); color: var(--text3); margin: 3px 0;
  font-family: 'JetBrains Mono', monospace;
}
.ldd-phase {
  margin-bottom: 16px; border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: border-color .2s;
}
.ldd-phase:hover { border-color: var(--border2); }
.ldd-phase-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 16px;
  background: linear-gradient(135deg, var(--surface), var(--surface2));
  cursor: pointer; transition: background .15s;
}
.ldd-phase-header:hover { background: var(--surface2); }
.ldd-phase-header h3 { margin: 0; font-size: calc(14px * var(--scale)); color: var(--accent2); flex: 1; font-weight: 600; }
.ldd-phase-toggle {
  background: none; border: none; color: var(--text3); font-size: 12px; cursor: pointer; padding: 0; width: 18px;
  transition: transform .2s var(--ease);
}
.ldd-phase-edit {
  background: none; border: 1px solid var(--border); color: var(--text3); font-size: calc(11px * var(--scale));
  cursor: pointer; padding: 3px 10px; border-radius: var(--radius-sm); opacity: 0;
  transition: all .15s;
}
.ldd-phase:hover .ldd-phase-edit { opacity: 1; }
.ldd-phase-edit:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.ldd-phase-body { padding: 14px 18px; }
.ldd-phase-body h4 {
  font-size: calc(13px * var(--scale)); color: var(--text); margin: 14px 0 8px;
  border-bottom: 1px solid var(--border); padding-bottom: 5px; font-weight: 600;
  letter-spacing: .2px;
}
.ldd-kv { display: flex; gap: 10px; padding: 5px 0; font-size: calc(12px * var(--scale)); }
.ldd-k { color: var(--text3); min-width: 100px; flex-shrink: 0; font-weight: 600; }
.ldd-v { color: var(--text2); flex: 1; line-height: 1.7; }
.ldd-flow-route {
  background: linear-gradient(135deg, var(--surface2), var(--surface3));
  padding: 10px 14px; border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace; font-size: calc(12px * var(--scale));
  color: var(--accent); margin: 8px 0; letter-spacing: .5px;
  border-left: 3px solid var(--accent);
}
.ldd-subpath { padding: 5px 0; font-size: calc(12px * var(--scale)); color: var(--text2); }
.ldd-version-btn {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text3);
  font-size: calc(11px * var(--scale)); padding: 3px 12px; border-radius: var(--radius-sm);
  cursor: pointer; transition: all .15s; font-family: 'JetBrains Mono', monospace;
}
.ldd-version-btn:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.ldd-version-item {
  padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: pointer;
  transition: all .12s;
}
.ldd-version-item:hover { background: var(--surface2); }
.ldd-version-item.active { border-left: 3px solid var(--accent); }
.ldd-atmosphere {
  background: var(--surface2); padding: 12px 16px; border-radius: var(--radius-sm);
  font-style: italic; color: var(--text3); font-size: calc(12px * var(--scale)); line-height: 1.8;
  margin: 8px 0; border-left: 3px solid var(--accent2);
}
.ldd-summary {
  background: var(--surface2); padding: 12px 16px; border-radius: var(--radius-sm);
  color: var(--text2); font-size: calc(12px * var(--scale)); line-height: 1.8; margin: 8px 0;
}

/* ═══════ LDD New Section Styles (v0.4+) ═══════ */
.ldd-qa-item {
  padding: 8px 12px; margin: 4px 0; border-radius: var(--radius-sm);
  background: var(--surface2); border-left: 3px solid var(--accent2);
}
.ldd-qa-q { font-weight: 600; color: var(--accent2); font-size: calc(12px * var(--scale)); margin-bottom: 4px; }
.ldd-qa-a { color: var(--text2); font-size: calc(12px * var(--scale)); line-height: 1.6; }
.ldd-antipattern {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px; margin: 3px 0;
  border-radius: var(--radius-sm); font-size: calc(12px * var(--scale));
}
.ldd-antipattern.pass { background: var(--green-dim); color: var(--green); }
.ldd-antipattern.risk { background: var(--orange-dim); color: var(--orange); }
.ldd-antipattern.fail { background: var(--red-dim); color: var(--red); }
.ldd-wayfinding {
  padding: 8px 12px; margin: 6px 0; border-radius: var(--radius-sm);
  background: var(--surface2);
}
.ldd-wayfinding-loc { font-weight: 600; color: var(--text); margin-bottom: 4px; }
.ldd-wayfinding-q { color: var(--accent2); font-style: italic; font-size: calc(11px * var(--scale)); margin-bottom: 6px; }
.ldd-env-story {
  padding: 8px 12px; margin: 4px 0; border-radius: var(--radius-sm);
  background: var(--surface2); border-left: 2px solid var(--pink);
}
.ldd-narr-sync {
  display: flex; gap: 12px; padding: 6px 10px; margin: 3px 0;
  border-radius: var(--radius-sm); background: var(--surface2);
  font-size: calc(12px * var(--scale));
}
.ldd-completeness { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.ldd-check-item {
  display: flex; align-items: center; gap: 5px; padding: 4px 10px;
  border-radius: 12px; font-size: calc(11px * var(--scale)); font-weight: 500;
}
.ldd-check-item.done { background: var(--green-dim); color: var(--green); }
.ldd-check-item.todo { background: var(--red-dim); color: var(--red); }
.ldd-asset-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 8px; margin: 8px 0;
}
.ldd-asset-card {
  padding: 10px 12px; background: var(--surface2); border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: calc(12px * var(--scale));
}
.ldd-asset-card .asset-cat { color: var(--text3); font-weight: 600; margin-bottom: 4px; }
.ldd-asset-card .asset-count { color: var(--accent); font-family: 'JetBrains Mono', monospace; font-weight: 700; font-size: calc(14px * var(--scale)); }

/* Markdown table in bubbles/doc */
.md-table { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: calc(11px * var(--scale)); }
.md-table td, .md-table th {
  padding: 7px 12px; border: 1px solid var(--border); text-align: left; color: var(--text2);
}
.md-table tr:first-child td { font-weight: 600; background: var(--surface); color: var(--text); }
.md-li { font-size: calc(12px * var(--scale)); color: var(--text2); padding: 2px 0; }
.md-check { font-size: calc(12px * var(--scale)); color: var(--text2); padding: 2px 0; }
.md-check.done { color: var(--green); }

/* ═══════ Topo Stats Grid ═══════ */
.topo-stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 16px; }
.topo-stat {
  display: flex; flex-direction: column; gap: 4px;
  padding: 12px; background: var(--surface2); border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.topo-label { font-size: calc(10px * var(--scale)); color: var(--text3); text-transform: uppercase; letter-spacing: .8px; font-weight: 500; }
.topo-report-text {
  font-size: calc(12px * var(--scale)); line-height: 1.7; color: var(--text2); white-space: pre-wrap;
  background: var(--surface); padding: 14px; border-radius: var(--radius-sm); margin-top: 8px; border: 1px solid var(--border);
}

/* ═══════ Flow Entry ═══════ */
.flow-entry {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 10px; border-radius: var(--radius-sm); font-size: calc(12px * var(--scale));
  transition: all .12s; cursor: default;
}
.flow-entry:hover { background: var(--accent-dim); }
.flow-time { font-family: 'JetBrains Mono', monospace; color: var(--text3); min-width: 50px; font-size: calc(11px * var(--scale)); }
.flow-icon { font-size: 14px; flex-shrink: 0; }
.flow-desc { flex: 1; color: var(--text2); }
.flow-loc { color: var(--text3); font-size: calc(11px * var(--scale)); }

/* ═══════ Resize Handles ═══════ */
.resize-handle {
  width: 5px; cursor: col-resize; background: transparent;
  flex-shrink: 0; position: relative; z-index: 10;
  transition: background .15s;
}
.resize-handle:hover, .resize-handle.dragging {
  background: var(--accent);
}
.resize-handle::after {
  content: ''; position: absolute; top: 50%; left: 50%;
  transform: translate(-50%, -50%); width: 1px; height: 40px;
  background: var(--border2); border-radius: 1px;
}
.resize-handle:hover::after, .resize-handle.dragging::after {
  background: var(--accent); width: 2px;
}

/* ═══════ Chat Action Bar ═══════ */
.chat-action-bar {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 18px; border-bottom: 1px solid var(--border);
  background: var(--surface); flex-shrink: 0; flex-wrap: wrap;
}
.chat-action-btn {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 5px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface2);
  color: var(--text2); font-size: calc(11px * var(--scale));
  cursor: pointer; transition: all .15s; white-space: nowrap;
}
.chat-action-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-dim); }
.chat-action-btn:disabled { opacity: .4; cursor: default; }
.chat-action-btn .action-icon { font-size: calc(13px * var(--scale)); }

/* ═══════ Legacy compat ═══════ */
.card {
  background:var(--surface); border:1px solid var(--border); border-radius:var(--radius);
  padding:20px 24px; margin-bottom:20px;
}
.card h2 { font-size:14px; color:var(--text2); margin-bottom:12px; font-weight:600; }
.json-input {
  width:100%; padding:12px; background:var(--bg); border:1px solid var(--border);
  border-radius:var(--radius-sm); font-size:calc(11px * var(--scale));
  font-family:'JetBrains Mono','Cascadia Code',monospace;
  line-height:1.5; color:var(--text2); resize:vertical;
}

/* ═══════ Phase iterate overlay ═══════ */
.phase-iterate-overlay .settings-dialog { animation: dialogSlideUp .2s var(--ease); }
@keyframes dialogSlideUp { from { opacity:0; transform: translateY(20px); } to { opacity:1; transform: translateY(0); } }

/* ═══════════════════════════════════════════════════════════
   STAGE PROGRESS BAR (Chat Panel top)
   ═══════════════════════════════════════════════════════════ */
.stage-progress {
  display: flex; align-items: center; justify-content: center;
  padding: 10px 16px; gap: 0;
  background: var(--glass); border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.stage-step {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  cursor: pointer; position: relative;
}
.stage-step span {
  font-size: calc(10px * var(--scale)); color: var(--text3);
  font-weight: 500; white-space: nowrap;
}
.stage-dot {
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--border);
  transition: all .25s var(--ease); position: relative;
}
.stage-step.completed .stage-dot {
  background: var(--accent); border-color: var(--accent);
}
.stage-step.completed .stage-dot::after {
  content: '✓'; position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 10px; font-weight: 700;
}
.stage-step.completed span { color: var(--accent); }
.stage-step.active .stage-dot {
  background: var(--accent2); border-color: var(--accent2);
  box-shadow: 0 0 0 4px rgba(var(--accent2-rgb, 232,167,35), .2);
  animation: stagePulse 1.5s ease-in-out infinite;
}
.stage-step.active span { color: var(--accent2); font-weight: 700; }
@keyframes stagePulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(232,167,35, .15); }
  50% { box-shadow: 0 0 0 8px rgba(232,167,35, .05); }
}
.stage-connector {
  width: 24px; height: 2px; background: var(--border);
  margin: 0 2px; margin-bottom: 18px;
  transition: background .25s var(--ease);
}
.stage-connector.done { background: var(--accent); }
.stage-step.clickable { cursor: pointer; }
.stage-step.clickable:hover .stage-dot { box-shadow: 0 0 0 4px rgba(232,167,35,.2); }
.stage-step.clickable:hover span { color: var(--accent); }
.stage-step.revising .stage-dot { box-shadow: 0 0 0 4px rgba(232,167,35,.45); animation: pulse-ring 1.2s ease infinite; }
.stage-step.revising span { color: var(--accent); font-weight: 600; }
@keyframes pulse-ring {
  0%, 100% { box-shadow: 0 0 0 4px rgba(232,167,35,.45); }
  50% { box-shadow: 0 0 0 8px rgba(232,167,35,.15); }
}

/* ═══════════════════════════════════════════════════════════
   INIT FORM (Right Panel — compact two-column layout)
   ═══════════════════════════════════════════════════════════ */
.init-form-panel {
  max-width: 100%; margin: 0 auto; padding: 16px 24px;
  animation: fadeInUp .3s var(--ease);
  display: flex; flex-direction: column;
  flex: 1; min-height: 0; overflow: hidden; box-sizing: border-box;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.init-form-header { text-align: center; margin-bottom: 10px; flex-shrink: 0; }
.init-form-header h2 {
  font-size: calc(17px * var(--scale)); font-weight: 700; color: var(--text1);
  margin-bottom: 3px;
}

/* Clipboard bar — copy / paste buttons */
.init-clipboard-bar {
  display: flex; gap: 8px; justify-content: center; margin-top: 8px;
}
.btn-clipboard {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 5px 14px; font-size: calc(12px * var(--scale));
  background: var(--surface2); color: var(--text2);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  cursor: pointer; transition: all .2s;
}
.btn-clipboard:hover {
  background: var(--accent2); color: #fff; border-color: var(--accent2);
}

/* Toast notification */
.init-toast {
  position: fixed; bottom: 32px; left: 50%; transform: translateX(-50%) translateY(16px);
  padding: 10px 22px; border-radius: 8px;
  background: var(--surface2); color: var(--text1); border: 1px solid var(--border);
  font-size: calc(13px * var(--scale)); box-shadow: 0 4px 16px rgba(0,0,0,.25);
  opacity: 0; transition: opacity .25s, transform .25s;
  z-index: 9999; pointer-events: none;
}
.init-toast-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.init-toast-warn { border-color: #e8a723; color: #e8a723; }
.init-form-sub {
  font-size: calc(12px * var(--scale)); color: var(--text3);
  line-height: 1.4;
}
.init-form-body { flex: 1; min-height: 0; overflow-y: auto; }

/* Two-column layout */
.init-two-col {
  display: grid; grid-template-columns: 1fr 1fr; gap: 20px;
}
.init-col { display: flex; flex-direction: column; gap: 0; min-width: 0; }
.init-group-label {
  font-size: calc(12px * var(--scale)); font-weight: 600;
  color: var(--accent2); margin: 10px 0 6px; padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.init-group-label:first-child { margin-top: 0; }

.init-compact-field { margin-bottom: 10px; }
.init-compact-field label {
  display: block; font-size: calc(12px * var(--scale)); font-weight: 500;
  color: var(--text2); margin-bottom: 4px;
}
.init-compact-field label .req { color: var(--accent2); }
.init-compact-field input,
.init-compact-field textarea {
  width: 100%; padding: 8px 12px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text1);
  font-size: calc(12px * var(--scale)); font-family: inherit;
  line-height: 1.4; transition: border-color .2s;
  box-sizing: border-box;
}
.init-compact-field input:focus,
.init-compact-field textarea:focus {
  outline: none; border-color: var(--accent2);
  box-shadow: 0 0 0 2px rgba(232,167,35, .1);
}
.init-compact-field textarea { resize: vertical; min-height: 48px; }
/* Let the last textarea in each column stretch to fill remaining space */
.init-compact-field.init-flex-grow { flex: 1; display: flex; flex-direction: column; }
.init-compact-field.init-flex-grow textarea { flex: 1; min-height: 64px; }
.init-compact-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

/* ── Style Anchor block (collapsible) ── */
.init-style-anchor {
  margin-top: 14px; margin-bottom: 4px;
  background: linear-gradient(135deg, rgba(108,99,255,.06), rgba(123,237,159,.06));
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.init-style-anchor[open] { border-color: var(--accent2); }
.init-style-anchor-toggle {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; cursor: pointer;
  font-size: calc(12px * var(--scale)); font-weight: 600;
  color: var(--accent2); list-style: none; user-select: none;
}
.init-style-anchor-toggle::-webkit-details-marker { display: none; }
.init-style-anchor-toggle::marker { display: none; content: ""; }
.init-style-anchor-arrow { margin-left: auto; transition: transform .2s; font-size: 10px; }
.init-style-anchor-arrow::after { content: "▸"; }
.init-style-anchor[open] .init-style-anchor-arrow { transform: rotate(90deg); }
.init-style-anchor-body { padding: 0 16px 10px; }
.init-style-anchor .init-group-label {
  color: var(--accent2);
}

/* ── Style Anchor: Upload Zone ── */
.sa-upload-zone { margin-top: 4px; }
.sa-upload-dropzone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-sm);
  padding: 14px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  color: var(--text3);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: calc(12px * var(--scale));
}
.sa-upload-dropzone:hover,
.sa-upload-dropzone.sa-drag-over {
  border-color: var(--accent2);
  background: rgba(var(--accent2-rgb, 99,102,241), 0.06);
  color: var(--text2);
}
.sa-upload-icon { font-size: 16px; }
.sa-upload-previews {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}
.sa-preview-item {
  position: relative;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.sa-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.sa-preview-delete {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0,0,0,0.65);
  color: #fff;
  border: none;
  cursor: pointer;
  font-size: 10px;
  line-height: 18px;
  text-align: center;
  padding: 0;
  opacity: 0;
  transition: opacity .2s;
}
.sa-preview-item:hover .sa-preview-delete { opacity: 1; }
.sa-upload-dropzone.sa-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.init-hint {
  font-weight: 400; font-size: calc(10px * var(--scale)); color: var(--text3);
}

.init-form-footer {
  display: flex; gap: 12px; justify-content: center;
  margin-top: 10px; padding-top: 10px; flex-shrink: 0;
  border-top: 1px solid var(--border);
}
.btn-lg { padding: 10px 24px; font-size: calc(13px * var(--scale)); }
.btn-ghost {
  background: transparent; border: 1px solid var(--border);
  color: var(--text2); padding: 10px 20px; border-radius: var(--radius-sm);
  cursor: pointer; font-size: calc(13px * var(--scale));
  transition: all .2s;
}
.btn-ghost:hover { border-color: var(--text2); color: var(--text1); }

/* ═══════════════════════════════════════════════════════════
   STAGE ACTION BAR (in LDD doc view, per-stage confirm/revise)
   ═══════════════════════════════════════════════════════════ */
.stage-action-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; margin: 16px 0;
  background: linear-gradient(135deg, rgba(74,222,128,.08), rgba(232,167,35,.08));
  border: 1px solid var(--border); border-radius: var(--radius);
}
.stage-action-bar .stage-label {
  font-size: calc(13px * var(--scale)); font-weight: 600;
  color: var(--accent2); flex: 1;
}
.stage-action-bar .btn {
  padding: 6px 16px; font-size: calc(12px * var(--scale));
}
.stage-action-bar .btn-confirm {
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer; font-weight: 600;
  transition: all .2s;
}
.stage-action-bar .btn-confirm:hover { filter: brightness(1.1); }
.stage-action-bar .btn-revise {
  background: transparent; color: var(--accent2); border: 1px solid var(--accent2);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: all .2s;
}
.stage-action-bar .btn-revise:hover { background: rgba(232,167,35,.1); }

/* Stage generating indicator */
.stage-generating {
  display: flex; align-items: center; gap: 8px;
  padding: 16px; margin: 12px 0;
  background: var(--glass); border: 1px solid var(--accent2);
  border-radius: var(--radius); color: var(--accent2);
  font-size: calc(13px * var(--scale)); font-weight: 500;
}
.stage-generating .spinner {
  width: 16px; height: 16px; border: 2px solid var(--border);
  border-top-color: var(--accent2); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* All-stages-complete banner */
.ldd-complete-banner {
  text-align: center; padding: 20px;
  background: linear-gradient(135deg, rgba(74,222,128,.1), rgba(74,222,128,.05));
  border: 1px solid var(--accent); border-radius: var(--radius);
  margin: 16px 0;
}
.ldd-complete-banner h3 { color: var(--accent); margin-bottom: 6px; }
.ldd-complete-banner p { color: var(--text3); font-size: calc(12px * var(--scale)); }

/* ═══════ System Log Bubble (Chat Panel) ═══════ */
.system-log {
  padding: 8px 14px; margin: 4px 12px;
  font-size: calc(12px * var(--scale)); color: var(--text3);
  background: var(--glass); border-radius: var(--radius-sm);
  border-left: 3px solid var(--accent2); line-height: 1.5;
  max-width: 100%; overflow-wrap: break-word;
}

/* ═══════ LDD v0.7 Card-based Staged Rendering ═══════ */
.ldd-stage-section {
  margin-bottom: 32px; padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}
.ldd-stage-section:last-child { border-bottom: none; }

.ldd-stage-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 16px; padding: 12px 16px;
  background: linear-gradient(135deg, var(--surface), var(--glass));
  border-radius: var(--radius-md); border: 1px solid var(--border);
}
.ldd-stage-icon { font-size: calc(18px * var(--scale)); }
.ldd-stage-title {
  flex: 1; margin: 0;
  font-size: calc(16px * var(--scale)); font-weight: 700;
  color: var(--text);
}

/* ── Per-field edit button ── */
.btn-icon { background: none; border: none; cursor: pointer; padding: 2px 4px; opacity: 0.4; transition: opacity .2s; font-size: calc(13px * var(--scale)); }
.btn-icon:hover { opacity: 1; }
.btn-stage-edit { opacity: 0.3; }
.ldd-stage-header:hover .btn-stage-edit { opacity: 0.8; }
.btn-field-edit { opacity: 0; font-size: calc(12px * var(--scale)); }
.ldd-field-block:hover .btn-field-edit,
.ldd-card:hover .btn-field-edit,
.ldd-card-header:hover .btn-field-edit { opacity: 0.7; }
.btn-field-edit:hover { opacity: 1 !important; }

/* ── Cards ── */
.ldd-card {
  background: var(--glass); border: 1px solid var(--border);
  border-radius: var(--radius-md); padding: 14px 18px;
  margin-bottom: 12px; transition: border-color .2s;
}
.ldd-card:hover { border-color: var(--border2); }
.ldd-card-accent {
  border-left: 3px solid var(--accent2);
}

.ldd-card-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px; font-size: calc(13px * var(--scale));
  font-weight: 600; color: var(--accent2);
}

.ldd-card-group { display: flex; flex-direction: column; gap: 0; }

.ldd-card-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 8px;
}
.ldd-kv-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 12px; background: var(--surface);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.ldd-kv-label {
  font-size: calc(10px * var(--scale)); color: var(--text3);
  font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
}
.ldd-kv-value {
  font-size: calc(13px * var(--scale)); color: var(--text); font-weight: 500;
}

/* ── Field blocks (key-value with edit) ── */
.ldd-field-block {
  padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,.04);
  transition: background .15s;
}
.ldd-field-block:last-child { border-bottom: none; }
.ldd-field-block:hover { background: rgba(255,255,255,.02); }
.ldd-field-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 4px;
}
.ldd-field-label {
  font-size: calc(12px * var(--scale)); font-weight: 600;
  color: var(--accent2);
}
.ldd-field-value {
  font-size: calc(13px * var(--scale)); color: var(--text2);
  line-height: 1.7; white-space: pre-wrap;
}

/* ── Inline editing ── */
.editable-cell { cursor: text; border-radius: 3px; transition: background .15s; }
.editable-cell:hover { background: rgba(255,255,255,.05); }
.inline-edit-input, .inline-edit-textarea {
  width: 100%; box-sizing: border-box;
  font: inherit; color: var(--text); line-height: 1.6;
  background: var(--surface); border: 1px solid var(--accent);
  border-radius: 4px; padding: 4px 8px; outline: none;
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 25%, transparent);
}
.inline-edit-textarea { resize: vertical; min-height: 48px; }
/* In table cells */
td .inline-edit-input, td .inline-edit-textarea {
  padding: 2px 6px; font-size: inherit;
}

/* ── Region chips ── */
.ldd-region-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ldd-chip {
  display: flex; flex-direction: column; gap: 2px;
  padding: 8px 12px; background: var(--surface);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  min-width: 120px; flex: 1;
}
.ldd-chip strong { font-size: calc(12px * var(--scale)); color: var(--text); }
.ldd-chip span { font-size: calc(11px * var(--scale)); color: var(--text3); line-height: 1.4; }

/* ── Flow items ── */
.ldd-flow-item { padding: 8px 0; }
.ldd-flow-label {
  font-size: calc(11px * var(--scale)); font-weight: 600;
  color: var(--accent2); text-transform: uppercase; letter-spacing: .5px;
  margin-bottom: 4px; display: block;
}
.ldd-flow-item p { font-size: calc(13px * var(--scale)); color: var(--text2); line-height: 1.7; margin: 2px 0; }
.ldd-branch { padding-left: 8px; }

/* ── Tables ── */
.ldd-table {
  width: 100%; border-collapse: collapse; font-size: calc(12px * var(--scale));
  margin: 4px 0;
}
.ldd-table thead th {
  text-align: left; padding: 8px 10px;
  background: var(--surface); color: var(--text3);
  font-weight: 600; border-bottom: 2px solid var(--border);
  font-size: calc(10px * var(--scale)); text-transform: uppercase; letter-spacing: .3px;
}
.ldd-table td {
  padding: 7px 10px; border-bottom: 1px solid rgba(255,255,255,.04);
  color: var(--text2); line-height: 1.5; vertical-align: top;
}
.ldd-table tbody tr:hover td { background: rgba(255,255,255,.02); }

/* ── Tags & badges ── */
.ldd-tag {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: rgba(232,167,35,.1); color: var(--accent2);
  font-size: calc(11px * var(--scale)); font-weight: 500;
}
.ldd-tag-dim {
  display: inline-block; padding: 2px 8px; border-radius: 10px;
  background: var(--surface); color: var(--text3);
  font-size: calc(11px * var(--scale));
}
.ldd-badge {
  display: inline-block; padding: 2px 6px; border-radius: 4px;
  background: var(--accent-dim); color: var(--accent);
  font-family: 'JetBrains Mono', monospace; font-size: calc(11px * var(--scale)); font-weight: 600;
}

/* ── Encounters ── */
.ldd-encounter {
  padding: 10px 14px; margin: 6px 0;
  background: var(--surface); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.ldd-encounter-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.ldd-encounter-head strong { color: var(--text); font-size: calc(12px * var(--scale)); }
.ldd-encounter p { margin: 2px 0; font-size: calc(12px * var(--scale)); color: var(--text2); line-height: 1.6; }
.ldd-hint { color: var(--text3); font-style: italic; }

/* ── Sight / Route ── */
.ldd-sight {
  padding: 6px 0; font-size: calc(12px * var(--scale)); color: var(--text2);
  border-bottom: 1px solid rgba(255,255,255,.03);
}
.ldd-sight:last-child { border-bottom: none; }
.ldd-route-path { padding: 6px 0; font-size: calc(13px * var(--scale)); color: var(--accent); }

/* ── Atmosphere ── */
.ldd-atmosphere-text {
  font-size: calc(13px * var(--scale)); color: var(--text2);
  line-height: 1.8; font-style: italic;
}

/* ── Stage action bar (next stage button) ── */
.stage-action-bar.pending {
  display: flex; flex-direction: column; align-items: stretch; gap: 12px;
  padding: 16px 0; margin-top: 8px;
}
.region-progress-chips {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 0 4px;
}
.region-chip {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: 20px;
  font-size: calc(12px * var(--scale)); font-weight: 500;
  background: var(--glass); border: 1px solid var(--border);
  color: var(--text3); transition: all .2s;
}
.region-chip.done {
  background: rgba(74,222,128,.12); border-color: rgba(74,222,128,.3);
  color: var(--accent2);
}
.region-chip.next {
  background: rgba(232,167,35,.12); border-color: rgba(232,167,35,.4);
  color: var(--accent2); font-weight: 700;
  animation: pulse-glow 2s ease-in-out infinite;
}
.region-action-buttons {
  display: flex; align-items: center; gap: 12px;
}
.btn-next-stage {
  padding: 10px 24px !important; font-size: calc(14px * var(--scale)) !important;
  font-weight: 700 !important; letter-spacing: .3px;
  animation: pulse-glow 2s ease-in-out infinite;
}
@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(232,167,35,.3); }
  50% { box-shadow: 0 0 12px 4px rgba(232,167,35,.15); }
}

/* ── Sticky bottom action bar (pinned inside lddDocView) ── */
.sticky-stage-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 20px;
  background: var(--surface2);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
  flex-shrink: 0;
}
.sticky-stage-progress {
  display: flex; align-items: center; gap: 6px; flex-shrink: 1; min-width: 0; overflow: hidden;
}
.sticky-stage-label {
  font-size: calc(12px * var(--scale)); font-weight: 600; color: var(--text2);
  white-space: nowrap;
}
.sticky-chip {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 22px; padding: 0 6px;
  border-radius: 11px; font-size: 10px; font-weight: 600;
  background: var(--glass); border: 1px solid var(--border); color: var(--text3);
  white-space: nowrap;
}
.sticky-chip.done {
  background: rgba(74,222,128,.15); border-color: rgba(74,222,128,.35); color: var(--accent);
}
.sticky-stage-actions {
  display: flex; align-items: center; gap: 8px; flex-shrink: 0;
}
.sticky-stage-actions .btn { font-size: calc(12px * var(--scale)); padding: 6px 16px; }

/* ── Region Overview Cards (phase_0a enriched) ── */
.ldd-regions-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px; padding: 4px 0;
}
.ldd-region-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: 14px 16px; background: var(--surface2);
  transition: border-color .2s;
}
.ldd-region-card:hover { border-color: var(--accent2); }
.ldd-region-card-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.ldd-region-id {
  font-size: calc(10px * var(--scale)); color: var(--accent2);
  background: rgba(232,167,35,.1); padding: 2px 6px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-weight: 600;
}
.ldd-region-card-head strong { font-size: calc(13px * var(--scale)); color: var(--text1); }
.ldd-region-brief {
  font-size: calc(12px * var(--scale)); color: var(--text2);
  margin: 0 0 8px; line-height: 1.5;
}
.ldd-region-meta {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px;
}
.ldd-region-tag {
  font-size: calc(11px * var(--scale)); color: var(--text2);
  background: var(--surface1); padding: 2px 8px; border-radius: 4px;
  border: 1px solid var(--border);
}
.ldd-region-pos {
  font-size: calc(11px * var(--scale)); color: var(--text3);
  margin-top: 4px; padding-top: 6px; border-top: 1px dashed var(--border);
}

/* ── Reference Image Cards (phase_0d v0.7) ── */
.ldd-ref-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(calc(200px * var(--scale)), 1fr));
  gap: calc(12px * var(--scale)); padding: 4px 0;
}
.ldd-ref-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface2);
  transition: border-color .2s, box-shadow .2s;
}
.ldd-ref-card:hover {
  border-color: var(--accent2);
  box-shadow: 0 2px 8px rgba(0,0,0,.2);
}
.ldd-ref-img {
  width: 100%; aspect-ratio: 16 / 10;
  background-size: cover; background-position: center;
  background-color: var(--surface1);
}
.ldd-ref-placeholder {
  width: 100%; aspect-ratio: 16 / 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: calc(8px * var(--scale)); background: var(--surface1);
  border-bottom: 1px solid var(--border);
}
.ref-placeholder-icon { font-size: calc(28px * var(--scale)); opacity: .4; }
.ldd-ref-placeholder .btn-sm {
  font-size: calc(11px * var(--scale)); padding: 3px 10px;
}
.ldd-ref-desc { padding: 10px 12px; }
.ldd-ref-desc p {
  font-size: calc(12px * var(--scale)); color: var(--text2);
  margin: 0 0 6px; line-height: 1.5;
}
.ldd-ref-prompt {
  font-size: calc(11px * var(--scale)); color: var(--text3);
  margin-top: 6px;
}
.ldd-ref-prompt summary {
  cursor: pointer; color: var(--accent2); font-weight: 500;
  font-size: calc(11px * var(--scale));
}
.ldd-ref-prompt code {
  display: block; margin-top: 4px; padding: 6px 8px;
  background: var(--surface1); border-radius: 4px;
  font-size: calc(10px * var(--scale)); line-height: 1.4;
  word-break: break-word; white-space: pre-wrap;
  color: var(--text2); font-family: 'JetBrains Mono', monospace;
}
.ldd-ref-search {
  display: flex; align-items: center; gap: 4px;
  font-size: calc(10px * var(--scale)); color: var(--text3);
  margin-top: 4px;
}
.ldd-ref-search-label { opacity: .6; }

/* ref image action overlay (hover) */
.ldd-ref-img { position: relative; }
.ldd-ref-actions {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,.6); display: flex; align-items: center; justify-content: center;
  gap: 6px; opacity: 0; transition: opacity .2s;
}
.ldd-ref-img:hover .ldd-ref-actions { opacity: 1; }
.ref-act-btn {
  background: rgba(255,255,255,.15); border: 1px solid rgba(255,255,255,.25); border-radius: 6px;
  color: #fff; font-size: calc(16px * var(--scale)); padding: calc(6px * var(--scale)) calc(10px * var(--scale)); cursor: pointer; transition: .15s;
  backdrop-filter: blur(4px);
}
.ref-act-btn:hover { background: rgba(255,255,255,.3); transform: scale(1.1); }
.ref-act-btn.danger:hover { background: rgba(255,68,68,.5); border-color: rgba(255,68,68,.6); }
.ref-placeholder-btns { display: flex; gap: calc(4px * var(--scale)); flex-wrap: wrap; justify-content: center; }

/* ═══════════════════════════════════════════════════════════
   REFERENCE GALLERY TAB
   ═══════════════════════════════════════════════════════════ */
.gallery-container {
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
}
.gallery-view {
  flex: 1; overflow-y: auto; padding: 20px 24px;
}

/* ── Gallery toolbar ── */
.gallery-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 0; margin-bottom: 16px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.gallery-toolbar .gallery-title {
  font-size: calc(16px * var(--scale)); font-weight: 700; color: var(--text1);
  margin-right: auto;
}
.gallery-filter-btn {
  background: var(--surface2); border: 1px solid var(--border); border-radius: 20px;
  padding: 5px 14px; font-size: calc(11px * var(--scale)); color: var(--text2);
  cursor: pointer; transition: .15s; white-space: nowrap;
}
.gallery-filter-btn:hover { border-color: var(--accent2); color: var(--text1); }
.gallery-filter-btn.active {
  background: var(--accent2); color: #fff; border-color: var(--accent2);
}
.gallery-batch-all-btn {
  margin-left: auto; white-space: nowrap; font-size: calc(12px * var(--scale));
  padding: 5px 16px; border-radius: 20px;
}
.gallery-stats {
  font-size: calc(11px * var(--scale)); color: var(--text3);
  margin-left: 8px;
}

/* ── Gallery category section ── */
.gallery-category {
  margin-bottom: 24px;
}
.gallery-cat-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 0 10px; margin-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.gallery-cat-icon {
  font-size: calc(16px * var(--scale));
}
.gallery-cat-title {
  font-size: calc(14px * var(--scale)); font-weight: 600; color: var(--text1);
  flex: 1;
}
.gallery-cat-count {
  font-size: calc(11px * var(--scale)); color: var(--text3);
  background: var(--surface1); padding: 2px 8px; border-radius: 10px;
}
.gallery-cat-actions {
  display: flex; gap: 4px;
}

/* ── Gallery image grid ── */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(220px * var(--scale)), 1fr));
  gap: calc(14px * var(--scale));
}

/* ── Gallery card ── */
.gallery-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface2);
  transition: border-color .2s, box-shadow .2s, transform .15s;
  cursor: pointer; position: relative;
}
.gallery-card:hover {
  border-color: var(--accent2);
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  transform: translateY(-2px);
}
.gallery-card-img {
  width: 100%; aspect-ratio: 16 / 10;
  background-size: cover; background-position: center;
  background-color: var(--surface1);
  position: relative;
}
.gallery-card-placeholder {
  width: 100%; aspect-ratio: 16 / 10;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: calc(8px * var(--scale)); background: var(--surface1);
  border-bottom: 1px solid var(--border);
  position: relative;
}
.gallery-card-placeholder-icon { font-size: calc(32px * var(--scale)); opacity: .3; }

/* ── Card hover overlay ── */
.gallery-card-overlay {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,.65); display: flex; align-items: center; justify-content: center;
  gap: 6px; opacity: 0; transition: opacity .2s;
}
.gallery-card-img:hover .gallery-card-overlay { opacity: 1; }
.gallery-card-placeholder:hover .gallery-card-overlay { opacity: 1; }

/* ── Card info (below image) ── */
.gallery-card-info {
  padding: calc(10px * var(--scale)) calc(12px * var(--scale));
}
.gallery-card-cat {
  font-size: calc(10px * var(--scale)); color: var(--accent2); font-weight: 500;
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em;
}
.gallery-card-desc {
  font-size: calc(12px * var(--scale)); color: var(--text2);
  line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.gallery-card-prompt {
  font-size: calc(10px * var(--scale)); color: var(--text3);
  margin-top: 4px; font-style: italic;
  display: -webkit-box; -webkit-line-clamp: 1;
  -webkit-box-orient: vertical; overflow: hidden;
  flex: 1; min-width: 0;
}

/* ── Prompt row with copy button ── */
.gallery-card-prompt-row {
  display: flex; align-items: flex-start; gap: 4px; margin-top: 4px;
}
.ldd-ref-prompt-row {
  display: flex; align-items: flex-start; gap: 4px;
}
.btn-copy-prompt {
  flex-shrink: 0; background: none; border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text3);
  cursor: pointer; font-size: 12px; padding: 2px 5px; line-height: 1;
  transition: color .15s, border-color .15s, background .15s;
}
.btn-copy-prompt:hover { color: var(--accent); border-color: var(--accent); background: var(--accent-dim); }
.btn-copy-prompt.copied { color: var(--green); border-color: var(--green); }

/* ── Lightbox modal ── */
.gallery-lightbox {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.85); z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .25s;
}
.gallery-lightbox.show { opacity: 1; pointer-events: all; }
.gallery-lightbox-inner {
  max-width: 90vw; max-height: 90vh; position: relative;
}
.gallery-lightbox-inner img {
  max-width: 100%; max-height: 85vh; border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.gallery-lightbox-close {
  position: absolute; top: -36px; right: 0;
  background: none; border: none; color: #fff; font-size: 24px;
  cursor: pointer; opacity: .7; transition: .15s;
}
.gallery-lightbox-close:hover { opacity: 1; }
.gallery-lightbox-info {
  color: #ccc; font-size: 13px; margin-top: 10px; max-width: 600px;
}
.gallery-lightbox-info .lb-desc { color: #eee; margin-bottom: 4px; }
.gallery-lightbox-info .lb-prompt {
  font-size: 11px; color: #999; font-family: 'JetBrains Mono', monospace;
}

/* ── Inline region image thumbnail (LDD doc) ── */
.ldd-region-thumbs {
  display: flex; gap: 6px; margin-top: 8px; flex-wrap: wrap;
}
.ldd-region-thumb {
  width: 60px; height: 42px; border-radius: 4px;
  background-size: cover; background-position: center;
  border: 1px solid var(--border); cursor: pointer;
  transition: border-color .15s, transform .15s;
}
.ldd-region-thumb:hover {
  border-color: var(--accent2); transform: scale(1.05);
}

/* ═══════════════════════════════════════════════════════════
   CONCEPT ART & SCENE PAINTINGS TAB
   ═══════════════════════════════════════════════════════════ */
.concept-container {
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
}
.concept-view {
  flex: 1; overflow-y: auto; padding: 20px 24px;
  display: flex; flex-direction: column; gap: 0;
}

/* ── Toolbar ── */
.concept-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 0 0 12px; margin-bottom: 0;
  border-bottom: 1px solid var(--border);
}
.concept-title {
  font-size: calc(16px * var(--scale)); font-weight: 700; color: var(--text1);
  margin-right: auto;
}
.concept-toolbar-right {
  display: flex; align-items: center; gap: 10px;
}
.concept-stats {
  font-size: calc(11px * var(--scale)); color: var(--text3);
  background: var(--surface1); padding: 3px 10px; border-radius: 10px;
}

/* ── Sub-tabs ── */
.concept-subtabs {
  display: flex; gap: 0; border-bottom: 1px solid var(--border);
  margin-bottom: 16px;
}
.concept-subtab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 10px 18px; font-size: calc(12px * var(--scale));
  color: var(--text2); cursor: pointer; transition: .15s;
  font-weight: 500; white-space: nowrap;
}
.concept-subtab:hover { color: var(--text1); background: var(--surface1); }
.concept-subtab.active {
  color: var(--accent2); border-bottom-color: var(--accent2); font-weight: 600;
}

/* ── Sub-panels ── */
.concept-subpanel { display: none; flex-direction: column; gap: 16px; }
.concept-subpanel.active { display: flex; }

/* ── Gen bar ── */
.concept-gen-bar {
  display: flex; flex-wrap: wrap; gap: 10px;
  align-items: center; padding: 12px 16px;
  background: var(--surface1); border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.concept-gen-controls {
  display: flex; flex-wrap: wrap; gap: 8px; flex: 1; min-width: 0;
}
.concept-select {
  font-size: calc(12px * var(--scale)); padding: 6px 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text1);
  cursor: pointer; max-width: 220px;
}
.concept-input {
  font-size: calc(12px * var(--scale)); padding: 6px 10px;
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-xs); color: var(--text1);
  flex: 1; min-width: 120px;
}
.concept-input::placeholder { color: var(--text3); }
.concept-gen-actions {
  display: flex; gap: 6px; flex-shrink: 0;
}

/* ── Prompt preview ── */
.concept-prompt-preview {
  background: var(--surface1); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 12px 14px;
}
.concept-prompt-header {
  display: flex; align-items: center; justify-content: space-between;
  font-size: calc(12px * var(--scale)); font-weight: 600; color: var(--text2);
  margin-bottom: 8px;
}
.concept-prompt-textarea {
  width: 100%; resize: vertical; background: var(--surface2);
  border: 1px solid var(--border); border-radius: var(--radius-xs);
  color: var(--text1); font-size: calc(11px * var(--scale));
  font-family: 'JetBrains Mono', monospace; padding: 8px 10px;
  line-height: 1.6;
}
.concept-prompt-actions {
  display: flex; gap: 8px; margin-top: 8px; justify-content: flex-end;
}

/* ── Concept / Painting grid ── */
.concept-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(240px * var(--scale)), 1fr));
  gap: calc(14px * var(--scale));
}
.concept-grid-empty {
  grid-column: 1 / -1;
  text-align: center; padding: 60px 20px; color: var(--text3);
  font-size: calc(13px * var(--scale));
}

/* ── Concept card ── */
.concept-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface2);
  transition: border-color .2s, box-shadow .2s, transform .15s;
  position: relative;
}
.concept-card:hover {
  border-color: var(--accent2);
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  transform: translateY(-2px);
}
.concept-card.selected {
  border-color: var(--green); border-width: 2px;
  box-shadow: 0 0 0 3px rgba(123, 237, 159, .15);
}
.concept-card-img {
  width: 100%; aspect-ratio: 16 / 10;
  background-size: cover; background-position: center;
  background-color: var(--surface1); cursor: pointer;
  position: relative;
}
.concept-card-badge {
  position: absolute; top: 8px; left: 8px;
  background: var(--green); color: #111; font-size: 10px;
  padding: 2px 8px; border-radius: 10px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .03em;
}
.concept-card-overlay {
  position: absolute; top: 0; right: 0; bottom: 0; left: 0;
  background: rgba(0,0,0,.65); display: flex; align-items: center;
  justify-content: center; gap: 6px;
  opacity: 0; transition: opacity .2s;
}
.concept-card-img:hover .concept-card-overlay { opacity: 1; }
.concept-card-info {
  padding: calc(10px * var(--scale)) calc(12px * var(--scale));
}
.concept-card-cat {
  font-size: calc(10px * var(--scale)); color: var(--accent2); font-weight: 500;
  margin-bottom: 4px; text-transform: uppercase; letter-spacing: .03em;
}
.concept-card-prompt {
  font-size: calc(10px * var(--scale)); color: var(--text3);
  margin-top: 4px; font-style: italic;
  display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden;
}
.concept-card-actions {
  display: flex; gap: 4px; padding: 0 calc(10px * var(--scale)) calc(8px * var(--scale));
}

/* ── Style Guide ── */
.style-guide-bar {
  display: flex; align-items: center; gap: 16px;
  padding: 12px 16px; background: var(--surface1);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.style-guide-desc {
  font-size: calc(12px * var(--scale)); color: var(--text2); flex: 1; margin: 0;
}
.style-guide-content {
  padding: 16px 0; font-size: calc(13px * var(--scale)); color: var(--text1);
  line-height: 1.7;
}
.style-guide-content h1, .style-guide-content h2, .style-guide-content h3 {
  margin-top: 20px; margin-bottom: 8px; color: var(--text1);
}
.style-guide-content ul { padding-left: 20px; }
.style-guide-content li { margin-bottom: 4px; }
.style-guide-content code {
  background: var(--surface1); padding: 2px 6px;
  border-radius: 3px; font-size: 0.9em;
}

/* ── Loading spinner on gen buttons ── */
.concept-generating {
  pointer-events: none; opacity: 0.6;
}
.concept-generating::after {
  content: " ⏳"; animation: conceptPulse 1.2s infinite;
}
@keyframes conceptPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Painting filter bar ── */
.painting-filter-bar {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  padding: 8px 0;
}
.painting-filter-label {
  font-size: calc(11px * var(--scale)); color: var(--text3); margin-right: 4px;
}
.painting-filter-btn {
  background: var(--surface1); border: 1px solid var(--border);
  border-radius: 12px; padding: 3px 12px; font-size: calc(11px * var(--scale));
  color: var(--text2); cursor: pointer; transition: .15s;
}
.painting-filter-btn:hover { color: var(--text1); border-color: var(--accent2); }
.painting-filter-btn.active {
  background: var(--accent2); color: #111; border-color: var(--accent2); font-weight: 600;
}

/* ── Painting entry cards (v2) ── */
.pe-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--surface1);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
  margin-bottom: 12px;
}
.pe-toolbar-hint { font-size: calc(11px * var(--scale)); color: var(--text3); }

/* ═══ Painting Entries: horizontal strip layout (v3) ═══ */
.pe-grid {
  display: flex; flex-direction: column; gap: 10px;
}
.pe-strip {
  background: var(--surface1); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
  transition: border-color .15s;
}
.pe-strip:hover { border-color: var(--accent2); }

/* ── Strip header: seq + inline editable fields ── */
.pe-strip-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--surface2);
  border-bottom: 1px solid var(--border); flex-wrap: wrap;
}
.pe-seq {
  font-size: calc(10px * var(--scale)); font-weight: 700;
  font-family: 'JetBrains Mono', monospace;
  color: var(--accent2); white-space: nowrap; min-width: 50px;
}
.pe-inline-input {
  background: transparent; border: 1px solid transparent;
  color: var(--text1); font-size: calc(12px * var(--scale));
  padding: 2px 6px; border-radius: 4px;
  transition: border-color .15s;
}
.pe-inline-input:hover { border-color: var(--border); }
.pe-inline-input:focus { border-color: var(--accent2); outline: none; background: var(--surface1); }
.pe-title-input { flex: 1; min-width: 120px; font-weight: 600; }
.pe-region-input { width: 100px; }
.pe-inline-select {
  background: transparent; border: 1px solid transparent;
  color: var(--text2); font-size: calc(11px * var(--scale));
  padding: 2px 4px; border-radius: 4px; cursor: pointer;
}
.pe-inline-select:hover { border-color: var(--border); }
.pe-inline-select:focus { border-color: var(--accent2); outline: none; }
.pe-inline-select option { background: var(--surface1); color: var(--text1); }
.pe-status-badge {
  font-size: calc(10px * var(--scale)); padding: 1px 8px;
  border-radius: 10px; white-space: nowrap;
}
.pe-st-draft { background: rgba(160,160,160,.15); color: var(--text3); }
.pe-st-gen { background: rgba(255,159,67,.15); color: var(--orange); }
.pe-st-done { background: rgba(46,213,115,.15); color: var(--green); }
.pe-source-badge { font-size: calc(10px * var(--scale)); padding: 1px 6px; border-radius: 10px; white-space: nowrap; }
.pe-src-upload { background: rgba(99,179,237,.15); color: var(--blue, #63b3ed); }
.pe-delete { font-size: 12px; opacity: .4; margin-left: auto; }
.pe-delete:hover { opacity: 1; color: var(--red); }

/* ── Strip body: 2/3 refs + 1/3 result ── */
.pe-strip-body {
  display: flex; min-height: 110px;
}
.pe-strip-refs {
  flex: 2; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px;
  border-right: 1px solid var(--border); min-width: 0;
}
.pe-refs-row {
  display: flex; align-items: center; gap: 6px;
}
.pe-refs-tag {
  font-size: calc(10px * var(--scale)); color: var(--text3);
  white-space: nowrap; min-width: 50px;
}
.pe-refs-thumbs {
  display: flex; gap: 5px; flex-wrap: wrap; align-items: center;
}
.pe-ref-thumb {
  width: 52px; height: 52px; border-radius: 6px;
  background-size: cover; background-position: center;
  position: relative; border: 1px solid var(--border);
  cursor: pointer; flex-shrink: 0;
}
.pe-ref-thumb:hover { border-color: var(--accent2); }
.pe-ref-remove {
  position: absolute; top: -4px; right: -4px;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--red); color: #fff; border: none;
  font-size: 9px; cursor: pointer; display: none;
  align-items: center; justify-content: center; line-height: 1;
}
.pe-ref-thumb:hover .pe-ref-remove { display: flex; }
.pe-ref-add {
  width: 52px; height: 52px; border-radius: 6px;
  border: 1px dashed var(--border); display: flex;
  align-items: center; justify-content: center;
  color: var(--text3); font-size: 18px; cursor: pointer;
  transition: border-color .15s;
}
.pe-ref-add:hover { border-color: var(--accent2); color: var(--accent2); }
.pe-desc-input {
  background: transparent; border: 1px solid transparent;
  color: var(--text2); font-size: calc(10px * var(--scale));
  padding: 3px 6px; border-radius: 4px; resize: vertical;
  width: 100%; font-family: inherit;
}
.pe-desc-input:hover { border-color: var(--border); }
.pe-desc-input:focus { border-color: var(--accent2); outline: none; background: var(--surface2); }

/* ── Result area (right 1/3) ── */
.pe-strip-result {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 8px; min-width: 180px;
}
.pe-result-img {
  width: 100%; max-height: 140px; object-fit: cover;
  border-radius: var(--radius-sm); cursor: pointer;
  border: 1px solid var(--border);
}
.pe-result-img:hover { border-color: var(--accent2); }
.pe-result-actions {
  display: flex; gap: 4px; margin-top: 4px; justify-content: center;
  flex-wrap: wrap;
}
.pe-result-del { opacity: .5; }
.pe-result-del:hover { opacity: 1; color: var(--red); }
.pe-result-placeholder {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 4px; width: 100%; height: 100%;
  min-height: 90px; border: 1px dashed var(--border);
  border-radius: var(--radius-sm); cursor: pointer;
  color: var(--text3); font-size: calc(11px * var(--scale));
  transition: border-color .15s, color .15s;
}
.pe-result-placeholder:hover { border-color: var(--accent2); color: var(--accent2); }
.pe-result-placeholder.pe-generating { cursor: default; opacity: .7; }
.pe-gen-icon { font-size: 1.8em; }
.spinner-sm {
  width: 18px; height: 18px; border: 2px solid var(--border);
  border-top-color: var(--accent2); border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.btn-xs {
  font-size: calc(10px * var(--scale)) !important;
  padding: 2px 6px !important;
}

/* ═══ Breakdown Accordion (v3: per-entry collapsible) ═══ */
.bd-panel-hint {
  font-size: calc(11px * var(--scale)); color: var(--text3);
  padding: 6px 0 10px;
}
.bd-accordion {
  border: 1px solid var(--border); border-radius: var(--radius);
  margin-bottom: 8px; overflow: hidden;
}
.bd-acc-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; background: var(--surface2);
  cursor: pointer; user-select: none;
  transition: background .15s;
}
.bd-acc-header:hover { background: var(--surface1); }
.bd-acc-arrow {
  font-size: 10px; color: var(--text3); width: 14px;
  text-align: center; transition: transform .2s;
}
.bd-acc-seq {
  font-size: calc(10px * var(--scale)); font-weight: 700;
  font-family: 'JetBrains Mono', monospace; color: var(--accent2);
}
.bd-acc-title {
  font-size: calc(12px * var(--scale)); font-weight: 600;
  color: var(--text1); flex: 1; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}
.bd-acc-stats {
  font-size: calc(10px * var(--scale)); color: var(--text3);
  white-space: nowrap;
}
.bd-acc-actions {
  display: flex; gap: 4px;
}
.bd-acc-body {
  padding: 12px; background: var(--surface1);
  border-top: 1px solid var(--border);
}
/* Overview row: painting input → sheet output */
.bd-acc-overview {
  display: flex; align-items: center; gap: 12px;
  margin-bottom: 12px; padding: 10px;
  background: var(--surface2); border-radius: var(--radius-sm);
}
.bd-ov-item { flex: 1; text-align: center; }
.bd-ov-label {
  font-size: calc(10px * var(--scale)); color: var(--text3);
  margin-bottom: 6px;
}
.bd-ov-img {
  max-width: 100%; max-height: 160px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); cursor: pointer;
}
.bd-ov-img:hover { border-color: var(--accent2); }
.bd-ov-empty {
  padding: 20px; color: var(--text3); font-size: calc(11px * var(--scale));
  border: 1px dashed var(--border); border-radius: var(--radius-sm);
}
.bd-ov-arrow {
  font-size: 20px; color: var(--text3); flex-shrink: 0;
}
.bd-acc-assets {
  display: flex; flex-direction: column; gap: 6px;
}
.bd-acc-empty {
  text-align: center; color: var(--text3);
  font-size: calc(11px * var(--scale)); padding: 16px;
}

/* ── Generic modal overlay (shared by ref picker, etc.) ── */
.modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.55); z-index: 9000;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(2px);
}
.modal-box {
  background: var(--surface); border-radius: 12px;
  box-shadow: 0 8px 40px rgba(0,0,0,.4);
  display: flex; flex-direction: column;
  width: 90%; overflow: hidden;
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 18px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: calc(14px * var(--scale));
}
.modal-header .btn-icon {
  background: none; border: none; font-size: 18px;
  cursor: pointer; color: var(--text3); padding: 2px 6px;
  border-radius: 6px; transition: .15s;
}
.modal-header .btn-icon:hover { background: var(--surface2); color: var(--text); }
.modal-body { padding: 16px 18px; }
.modal-footer {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-top: 1px solid var(--border);
  justify-content: flex-end;
}

/* ── Ref picker modal ── */
.rp-section { margin-bottom: 16px; }
.rp-section-title {
  font-weight: 600; font-size: calc(12px * var(--scale));
  margin-bottom: 8px; color: var(--text2);
}
.rp-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 8px;
}
.rp-thumb {
  aspect-ratio: 1; border-radius: 8px;
  background-size: cover; background-position: center;
  cursor: pointer; border: 2px solid transparent;
  position: relative; transition: border-color .15s;
}
.rp-thumb:hover { border-color: var(--accent2); }
.rp-thumb.rp-picked {
  border-color: var(--green, #4caf50);
  box-shadow: 0 0 0 2px var(--green, #4caf50);
}
.rp-thumb.rp-picked::after {
  content: '✓'; position: absolute; top: 4px; right: 4px;
  background: var(--green, #4caf50); color: #fff;
  width: 18px; height: 18px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
}
.rp-thumb-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  background: rgba(0,0,0,.6); color: #fff;
  font-size: 9px; padding: 2px 6px;
  border-radius: 0 0 6px 6px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ── Painting card viewpoint badge ── */
.painting-card-vp-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(0,0,0,.7); color: #fff; font-size: 10px;
  padding: 2px 8px; border-radius: 10px; font-weight: 600;
  backdrop-filter: blur(4px);
}
.painting-card-region-badge {
  position: absolute; top: 8px; right: 8px;
  background: rgba(78, 119, 255, .8); color: #fff; font-size: 10px;
  padding: 2px 8px; border-radius: 10px; font-weight: 600;
  backdrop-filter: blur(4px);
}
.painting-card-time {
  font-size: calc(9px * var(--scale)); color: var(--text3); margin-top: 2px;
}

/* ── Breakdown panel ── */
.breakdown-stats-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 8px 16px; background: var(--surface1);
  border-radius: var(--radius-sm); border: 1px solid var(--border);
}
.breakdown-legend {
  display: flex; gap: 10px; font-size: calc(10px * var(--scale));
}
.bd-legend-item { white-space: nowrap; }

.breakdown-list {
  display: flex; flex-direction: column; gap: 8px;
}

/* ── Breakdown asset row ── */
.bd-asset-row {
  display: flex; align-items: stretch; gap: 0;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  overflow: hidden; background: var(--surface2);
  transition: border-color .2s;
}
.bd-asset-row:hover { border-color: var(--accent2); }

.bd-asset-info {
  flex: 1; padding: 10px 14px; display: flex; flex-direction: column; gap: 4px;
  min-width: 0;
}
.bd-asset-header {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
}
.bd-asset-id {
  font-size: calc(10px * var(--scale)); font-weight: 700;
  color: var(--text3); font-family: 'JetBrains Mono', monospace;
}
.bd-asset-name {
  font-size: calc(13px * var(--scale)); font-weight: 600; color: var(--text1);
}
.bd-asset-name-cn {
  font-size: calc(11px * var(--scale)); color: var(--text2);
}
.bd-priority-badge {
  font-size: 9px; font-weight: 700; padding: 1px 6px;
  border-radius: 8px; text-transform: uppercase;
}
.bd-priority-P0 { background: rgba(255, 71, 87, .2); color: var(--red); }
.bd-priority-P1 { background: rgba(255, 159, 67, .2); color: var(--orange); }
.bd-priority-P2 { background: rgba(78, 119, 255, .2); color: var(--blue); }
.bd-priority-P3 { background: rgba(160, 160, 160, .2); color: var(--text3); }

.bd-asset-cat {
  font-size: calc(10px * var(--scale)); color: var(--accent2);
}
.bd-asset-desc {
  font-size: calc(10px * var(--scale)); color: var(--text3); font-style: italic;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* ── Multiview thumbnails area ── */
.bd-multiview-area {
  display: flex; align-items: center; gap: 4px;
  padding: 8px; background: var(--surface1);
  min-width: 260px;
}
.bd-mv-thumb {
  width: 56px; height: 56px; border-radius: 4px;
  background-size: cover; background-position: center;
  background-color: var(--surface2); border: 1px solid var(--border);
  cursor: pointer; position: relative;
  transition: border-color .2s;
}
.bd-mv-thumb:hover { border-color: var(--accent2); }
.bd-mv-thumb.empty {
  display: flex; align-items: center; justify-content: center;
  font-size: 18px; color: var(--text3); cursor: default;
}
.bd-mv-label {
  position: absolute; bottom: 0; left: 0; right: 0;
  font-size: 8px; text-align: center; background: rgba(0,0,0,.6);
  color: #fff; padding: 1px 0;
}

/* ── Breakdown actions ── */
.bd-actions {
  display: flex; flex-direction: column; gap: 4px;
  padding: 8px 10px; justify-content: center;
  border-left: 1px solid var(--border);
}
.bd-actions .btn { font-size: calc(10px * var(--scale)); padding: 4px 8px; }

/* ── Sheet preview (Step 2 result) ── */
.bd-sheet-preview {
  margin: 8px 0; padding: 8px; background: var(--surface1);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.bd-sheet-label {
  font-size: calc(11px * var(--scale)); color: var(--text2); margin-bottom: 6px;
}
.bd-sheet-img {
  max-width: 100%; max-height: 300px; border-radius: 4px;
  cursor: pointer; border: 1px solid var(--border);
  transition: border-color .2s;
}
.bd-sheet-img:hover { border-color: var(--accent2); }

/* ── Extracted thumb highlight ── */
.bd-extracted-thumb {
  border: 2px solid var(--accent2) !important;
}
.bd-arrow {
  font-size: 16px; color: var(--text3); padding: 0 2px;
  display: flex; align-items: center;
}

/* ── Tripo 3D Generation Panel (Phase 4) ── */
.tripo-panel-content { padding: 4px 0; }

.tripo-header { margin-bottom: 10px; }
.tripo-config-row {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 8px 12px; background: var(--surface1); border-radius: var(--radius-sm);
  border: 1px solid var(--border); font-size: calc(11px * var(--scale));
}
.tripo-config-row label { color: var(--text2); white-space: nowrap; }
.tripo-batch-row {
  display: flex; align-items: center; gap: 8px; margin-top: 8px;
}
.tripo-status-summary {
  font-size: calc(11px * var(--scale)); color: var(--accent2); margin-left: 8px;
}

.tripo-stats-bar {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 6px 12px; background: var(--surface1); border-radius: var(--radius-sm);
  border: 1px solid var(--border); margin-bottom: 10px;
}
.tripo-stat { font-size: calc(11px * var(--scale)); white-space: nowrap; }

.tripo-asset-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 10px;
}
.tripo-asset-card {
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface2); padding: 10px; transition: border-color .2s;
  display: flex; flex-direction: column; gap: 6px;
}
.tripo-asset-card:hover { border-color: var(--accent2); }
.tripo-task-only { opacity: 0.7; }

.tripo-card-header {
  display: flex; align-items: center; justify-content: space-between; gap: 6px;
}
.tripo-checkbox {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  font-size: calc(11px * var(--scale));
}
.tripo-checkbox input { margin: 0; }
.tripo-asset-name { font-weight: 600; color: var(--text1); font-size: calc(12px * var(--scale)); }
.tripo-cat-badge {
  font-size: 9px; padding: 1px 6px; border-radius: 8px;
  background: rgba(78, 119, 255, .15); color: var(--accent2);
}

.tripo-thumb {
  border-radius: var(--radius-sm); overflow: hidden; background: var(--bg2);
  aspect-ratio: 1; display: flex; align-items: center; justify-content: center;
}
.tripo-thumb img { width: 100%; height: 100%; object-fit: cover; }

.tripo-card-actions {
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
  font-size: calc(10px * var(--scale));
}
.tripo-mv-count { color: var(--text3); }

.tripo-status { font-size: calc(10px * var(--scale)); white-space: nowrap; }
.tripo-status-queued { color: var(--text3); }
.tripo-status-success { color: var(--green); }
.tripo-status-failed { color: var(--red); }

.tripo-progress-wrap {
  display: flex; align-items: center; gap: 6px; flex: 1; min-width: 80px;
}
.tripo-progress-bar {
  flex: 1; height: 6px; background: var(--bg3); border-radius: 3px; overflow: hidden;
}
.tripo-progress-fill {
  height: 100%; background: var(--orange); border-radius: 3px;
  transition: width .3s ease;
}
.tripo-progress-text { font-size: 10px; color: var(--orange); min-width: 30px; }

.btn-xs {
  font-size: calc(10px * var(--scale)); padding: 2px 8px; border-radius: 4px;
}

/* ── Tripo Model Preview Overlay ── */
.tripo-preview-overlay {
  position: fixed; inset: 0; z-index: 10000;
  background: rgba(0,0,0,.75); display: none;
  align-items: center; justify-content: center;
}
.tripo-preview-dialog {
  width: min(90vw, 700px); height: min(80vh, 600px);
  background: var(--bg1); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column;
  box-shadow: 0 8px 32px rgba(0,0,0,.5);
}
.tripo-preview-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; border-bottom: 1px solid var(--border);
  font-weight: 600; font-size: calc(13px * var(--scale));
}
.tripo-preview-body { flex: 1; overflow: hidden; position: relative; }
.tripo-preview-footer {
  display: flex; align-items: center; justify-content: flex-end; gap: 8px;
  padding: 8px 16px; border-top: 1px solid var(--border);
}

/* ── Mechanism Cards (phase_0b) — redesigned ── */
.ldd-mech-section-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0 6px; margin-bottom: 4px;
  font-size: calc(13px * var(--scale)); font-weight: 600; color: var(--accent2);
}
.ldd-mech-section-header:hover .btn-field-edit { opacity: 0.7; }

.ldd-mech-card {
  border: 1px solid var(--border); border-radius: var(--radius-md);
  background: var(--glass); margin-bottom: 12px; overflow: hidden;
  transition: border-color .2s;
}
.ldd-mech-card:hover { border-color: var(--border2); }

.ldd-mech-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; background: var(--surface2);
  border-bottom: 1px solid var(--border);
}
.ldd-mech-id {
  font-size: calc(10px * var(--scale)); color: var(--accent2);
  background: rgba(232,167,35,.12); padding: 2px 8px; border-radius: 4px;
  font-family: 'JetBrains Mono', monospace; font-weight: 600;
  white-space: nowrap;
}
.ldd-mech-card-title {
  font-size: calc(14px * var(--scale)); color: var(--text1); font-weight: 600;
}

.ldd-mech-tagline {
  padding: 10px 16px; font-size: calc(12px * var(--scale));
  color: var(--text2); line-height: 1.65; white-space: pre-wrap;
  background: rgba(232,167,35,.04);
  border-bottom: 1px solid rgba(255,255,255,.04);
}

.ldd-mech-section {
  padding: 10px 16px; border-bottom: 1px solid rgba(255,255,255,.04);
}
.ldd-mech-section:last-child { border-bottom: none; }
.ldd-mech-section-label {
  font-size: calc(11px * var(--scale)); font-weight: 600;
  color: var(--accent2); margin-bottom: 6px;
  letter-spacing: 0.3px;
}
.ldd-mech-section-body {
  font-size: calc(12px * var(--scale)); color: var(--text2);
  line-height: 1.7; white-space: pre-wrap;
}

/* Collapsible details */
.ldd-mech-details {
  border-top: 1px solid rgba(255,255,255,.04);
}
.ldd-mech-details[open] {
  border-top: 1px solid var(--border);
}
.ldd-mech-details-summary {
  padding: 8px 16px; font-size: calc(11px * var(--scale));
  font-weight: 600; color: var(--text3); cursor: pointer;
  user-select: none; list-style: none; display: flex; align-items: center; gap: 6px;
  transition: color .15s, background .15s;
}
.ldd-mech-details-summary::-webkit-details-marker { display: none; }
.ldd-mech-details-summary::before {
  content: '▶'; font-size: 9px; color: var(--text3);
  transition: transform .2s;
}
.ldd-mech-details[open] > .ldd-mech-details-summary::before {
  transform: rotate(90deg);
}
.ldd-mech-details-summary:hover { color: var(--accent2); background: rgba(255,255,255,.02); }
.ldd-mech-details-body {
  padding: 4px 16px 12px; display: flex; flex-direction: column; gap: 6px;
}

/* Edge case items */
.ldd-mech-edge-item {
  padding: 8px 12px; background: var(--surface2); border-radius: var(--radius-sm);
  border-left: 2px solid rgba(232,167,35,.3);
}
.ldd-mech-edge-label {
  font-size: calc(10px * var(--scale)); font-weight: 700;
  color: var(--accent2); margin-bottom: 4px; text-transform: uppercase;
}
.ldd-mech-edge-text {
  font-size: calc(12px * var(--scale)); color: var(--text2);
  line-height: 1.65; white-space: pre-wrap;
}

/* Extension items */
.ldd-mech-ext-item {
  padding: 8px 12px; background: var(--surface2); border-radius: var(--radius-sm);
  border-left: 2px solid rgba(76,175,80,.3);
}
.ldd-mech-ext-head {
  display: flex; align-items: center; gap: 8px; margin-bottom: 4px;
}
.ldd-mech-ext-head strong {
  font-size: calc(12px * var(--scale)); color: var(--text1);
}
.ldd-mech-ext-desc {
  font-size: calc(12px * var(--scale)); color: var(--text2);
  line-height: 1.65; white-space: pre-wrap;
}

/* Legacy compat — old phase_0b classes no longer emitted by renderPhaseContent */

/* ── Region Detail Cards (phase_0c new format) ── */
.ldd-region-detail-card {
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface); margin-bottom: 12px; overflow: hidden;
}
.ldd-region-detail-card .ldd-card-header {
  display: flex; align-items: center; gap: 8px; padding: 12px 16px;
  background: var(--surface2); border-bottom: 1px solid var(--border);
}
.ldd-region-section {
  padding: 8px 16px; border-bottom: 1px solid color-mix(in srgb, var(--border) 50%, transparent);
}
.ldd-region-section:last-child { border-bottom: none; }
.ldd-region-section-title {
  font-size: calc(12px * var(--scale)); font-weight: 600; color: var(--text2);
  margin-bottom: 6px; padding-bottom: 4px; border-bottom: 1px dashed var(--border);
}
.ldd-region-field {
  display: grid; grid-template-columns: 100px 1fr; gap: 6px;
  padding: 3px 0; font-size: calc(12px * var(--scale)); line-height: 1.5;
}
.ldd-region-field-label {
  color: var(--text3); font-weight: 500; white-space: nowrap; font-size: calc(11px * var(--scale));
}
.ldd-region-field-val { color: var(--text1); cursor: text; border-radius: 3px; transition: background .15s; }
.ldd-region-field-val:hover { background: rgba(255,255,255,.05); }
.ldd-mech-section-body { cursor: text; border-radius: 3px; transition: background .15s; }
.ldd-mech-section-body:hover { background: rgba(255,255,255,.05); }
.ldd-region-highlight { color: var(--accent) !important; font-weight: 600; }

/* ── Lock-Key Structure Cards ── */
.ldd-lock-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px; padding: 8px 0;
}
.ldd-lock-item {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px;
  border-left: 3px solid #ffd93d;
  transition: border-color .2s, background .15s, box-shadow .2s;
}
.ldd-lock-item:hover {
  border-color: #ffd93d; background: var(--surface2);
  box-shadow: 0 2px 8px rgba(255,217,61,.12);
}
.ldd-lock-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
}
.ldd-lock-type {
  font-size: calc(11px * var(--scale)); font-weight: 600; color: #1a1a2e;
  background: #ffd93d; padding: 2px 10px; border-radius: 10px;
  white-space: nowrap;
}
.ldd-lock-flow {
  display: flex; align-items: center; gap: 0; margin: 6px 0 8px;
  background: var(--surface2); border-radius: 6px; padding: 8px 12px;
  border: 1px solid var(--border);
}
.ldd-lock-node {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 0; flex: 1;
}
.ldd-lock-node-icon { font-size: calc(16px * var(--scale)); }
.ldd-lock-node-label {
  font-size: calc(11px * var(--scale)); color: var(--text1); font-weight: 500;
  text-align: center; word-break: break-word;
}
.ldd-lock-arrow {
  font-size: calc(16px * var(--scale)); color: #ffd93d; opacity: .8;
  flex-shrink: 0; padding: 0 6px;
}
.ldd-lock-detail {
  font-size: calc(11px * var(--scale)); color: var(--text2); line-height: 1.6;
  padding: 4px 0 0 2px;
  border-top: 1px dashed var(--border); margin-top: 4px; padding-top: 6px;
}
/* Legacy compat */
.ldd-lock-route {
  display: flex; align-items: center; gap: 6px;
  font-size: calc(12px * var(--scale)); color: var(--text1); font-weight: 500;
}
.ldd-lock-route .lock-icon { opacity: .7; }

/* Event sequence timeline */
.ldd-event-sequence {
  display: flex; flex-direction: column; gap: 0; padding: 4px 0 4px 0;
  border-left: 2px solid var(--accent); margin-left: 12px;
}
.ldd-event-node {
  display: flex; gap: 10px; padding: 6px 0 6px 14px; position: relative;
}
.ldd-event-node::before {
  content: ''; position: absolute; left: -6px; top: 14px;
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--accent); border: 2px solid var(--surface);
}
.ldd-event-order {
  font-size: calc(10px * var(--scale)); font-weight: 700; color: var(--accent);
  min-width: 18px; text-align: center; padding-top: 2px;
  font-family: 'JetBrains Mono', monospace;
}
.ldd-event-body { flex: 1; }
.ldd-event-main { display: flex; align-items: center; gap: 6px; margin-bottom: 2px; }
.ldd-tag-beat { background: var(--accent); color: var(--bg1); font-size: calc(10px * var(--scale)); padding: 1px 6px; border-radius: 3px; font-weight: 600; }
.ldd-event-line {
  font-size: calc(11.5px * var(--scale)); line-height: 1.5; color: var(--text2);
}
.ldd-event-label {
  display: inline-block; width: 36px; color: var(--text3); font-weight: 500;
  font-size: calc(10px * var(--scale));
}

/* ═══════════════════════════════════════════════════════════
   ENGINE BRIDGE — UE5 连接状态 & 操作面板
   ═══════════════════════════════════════════════════════════ */

/* 状态指示点 (taskbar) */
.bridge-dot {
  display: inline-block; width: 8px; height: 8px;
  border-radius: 50%; margin: 0 auto;
  transition: background .3s, box-shadow .3s;
}
.bridge-dot-disconnected {
  background: var(--text3); opacity: .4;
}
.bridge-dot-connected {
  background: #4caf50;
  box-shadow: 0 0 6px rgba(76,175,80,.6);
  opacity: 1;
}

/* Bridge mini trigger (clickable dot area) */
.bridge-mini-trigger {
  cursor: pointer;
  width: 28px; height: 28px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 6px;
  transition: background .15s;
  position: relative;
}
.bridge-mini-trigger:hover {
  background: var(--bg2);
}

/* Bridge mini popover panel */
.bridge-mini-panel {
  position: fixed;
  bottom: 8px;
  left: 60px;  /* right of taskbar */
  width: 260px;
  background: var(--bg1);
  border: 1px solid var(--border);
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35);
  z-index: 9000;
  font-size: calc(12px * var(--scale));
  overflow: hidden;
  animation: bridge-panel-in .15s ease-out;
}
@keyframes bridge-panel-in {
  from { opacity: 0; transform: translateY(8px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.bridge-mini-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px 6px;
  border-bottom: 1px solid var(--border);
  cursor: move;
  user-select: none;
}
.bridge-mini-title {
  font-weight: 600; font-size: calc(12px * var(--scale));
  color: var(--text);
}
.bridge-mini-close {
  background: none; border: none; color: var(--text3);
  cursor: pointer; font-size: 14px; line-height: 1;
  padding: 2px 4px; border-radius: 4px;
}
.bridge-mini-close:hover { background: var(--bg2); color: var(--text); }

.bridge-mini-status {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px 4px;
  font-size: calc(11px * var(--scale));
  color: var(--text2);
}
.bridge-mini-dot {
  display: inline-block; width: 6px; height: 6px;
  border-radius: 50%; flex-shrink: 0;
}

.bridge-mini-project {
  padding: 6px 12px;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  margin: 4px 0;
}
.bridge-mini-label {
  font-size: calc(10px * var(--scale));
  color: var(--text3);
  margin-bottom: 2px;
}
.bridge-mini-project-name {
  font-weight: 600;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.bridge-mini-project-code {
  font-size: calc(10px * var(--scale));
  color: var(--accent2);
  font-family: 'JetBrains Mono', monospace;
}
.bridge-mini-level {
  font-size: calc(10px * var(--scale));
  color: var(--accent2);
  font-family: 'JetBrains Mono', monospace;
  margin-top: 1px;
}

.bridge-mini-actions {
  display: flex; gap: 6px; padding: 8px 12px;
  flex-wrap: wrap; align-items: center;
}
.bridge-mini-actions .btn-sm {
  font-size: calc(11px * var(--scale));
  padding: 4px 10px;
}

.bridge-mini-log {
  max-height: 80px; overflow-y: auto;
  font-size: calc(10px * var(--scale));
  padding: 0 12px 8px;
  color: var(--text3);
}

/* Bridge 映射表 */
.bridge-table {
  width: 100%; border-collapse: collapse; table-layout: fixed;
  font-size: calc(11px * var(--scale));
  margin-top: 8px;
}
.bridge-table th {
  text-align: left; padding: 6px 8px;
  border-bottom: 1px solid var(--border);
  color: var(--text3); font-weight: 500;
  font-size: calc(10px * var(--scale));
  text-transform: uppercase; letter-spacing: .04em;
  position: sticky; top: 0; background: var(--surface); z-index: 1;
}
.bridge-table td {
  padding: 5px 8px; border-bottom: 1px solid var(--border);
  color: var(--text2); max-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.bridge-table td:nth-child(1) { width: 80px; min-width: 60px; }
.bridge-table td:nth-child(2) { width: auto; }
.bridge-table td:nth-child(3) { width: 48px; min-width: 48px; text-align: center; }
.bridge-table tr:hover td {
  background: var(--surface1);
}

/* Bridge 冲突面板 */
.bridge-conflicts-header {
  color: #ff9800; font-weight: 600;
  font-size: calc(12px * var(--scale));
  margin-bottom: 6px; padding: 6px 0;
  border-bottom: 1px solid rgba(255,152,0,.3);
}
.bridge-conflict-item {
  background: var(--surface1); border: 1px solid rgba(255,152,0,.2);
  border-radius: var(--radius-sm); padding: 10px 12px;
  margin-bottom: 6px; font-size: calc(11px * var(--scale));
}
.bridge-conflict-item code {
  background: var(--surface2); padding: 1px 5px;
  border-radius: 3px; font-family: 'JetBrains Mono', monospace;
  font-size: calc(10px * var(--scale));
}
.bridge-empty {
  color: var(--text3); font-style: italic;
  text-align: center; padding: 16px 0;
}

/* Bridge 日志面板 */
#bridgeLog > div {
  padding: 3px 0; border-bottom: 1px solid var(--border);
  line-height: 1.5;
}
#bridgeLog > div:last-child { border-bottom: none; }

/* ═══ Export Format Modal ═══ */
.export-modal-overlay {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,.7); z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
  backdrop-filter: blur(4px);
}
.export-modal-overlay.show { opacity: 1; pointer-events: all; }
.export-modal {
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius); width: 380px; max-width: 90vw;
  box-shadow: 0 16px 48px rgba(0,0,0,.5);
  animation: exportModalIn .25s ease-out;
}
@keyframes exportModalIn {
  from { transform: translateY(20px) scale(.96); opacity: 0; }
  to   { transform: translateY(0) scale(1); opacity: 1; }
}
.export-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.export-modal-header h3 {
  margin: 0; font-size: calc(15px * var(--scale)); color: var(--text); font-weight: 600;
}
.export-modal-close {
  background: none; border: none; color: var(--text3); font-size: 18px;
  cursor: pointer; padding: 4px 8px; border-radius: var(--radius-sm);
  transition: color .15s, background .15s;
}
.export-modal-close:hover { color: var(--text); background: var(--surface2); }
.export-modal-body { padding: 20px; }
.export-modal-desc {
  margin: 0 0 16px; font-size: calc(13px * var(--scale)); color: var(--text2);
}
.export-section { margin-bottom: 16px; }
.export-section:last-child { margin-bottom: 0; }
.export-section-label {
  margin: 0 0 10px; font-size: calc(11px * var(--scale)); color: var(--text3);
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600;
}
.export-format-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
}
.export-grid-2col { grid-template-columns: 1fr 1fr; }
.export-format-glb {
  background: linear-gradient(135deg, var(--surface2), rgba(126, 87, 194, 0.08));
  border-color: rgba(126, 87, 194, 0.3);
}
.export-format-glb:hover {
  border-color: #7e57c2; background: rgba(126, 87, 194, 0.15);
}
.export-format-bundle {
  background: linear-gradient(135deg, var(--surface2), rgba(74, 144, 226, 0.08));
  border-color: rgba(74, 144, 226, 0.3);
}
.export-format-bundle:hover {
  border-color: #4a90e2; background: rgba(74, 144, 226, 0.15);
}
.export-format-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 20px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface2);
  cursor: pointer; transition: border-color .2s, background .2s, transform .15s;
  color: var(--text);
}
.export-format-card:hover {
  border-color: var(--accent); background: var(--accent-dim);
  transform: translateY(-2px);
}
.export-format-icon { font-size: 28px; }
.export-format-name {
  font-size: calc(13px * var(--scale)); font-weight: 600;
}
.export-format-ext {
  font-size: calc(11px * var(--scale)); color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
}
.export-format-hint {
  font-size: calc(10px * var(--scale)); color: var(--text3);
  opacity: 0.7; margin-top: 2px;
}

/* ═══ LDD Quick Nav ═══ */
#tab-ldd-doc { position: relative; overflow: hidden; }

.ldd-nav-toggle {
  position: absolute; top: 12px; right: 16px; z-index: 100;
  width: 36px; height: 36px; border-radius: var(--radius-sm);
  background: var(--surface3); border: 1px solid var(--border2);
  color: var(--accent2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s, border-color .15s;
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.ldd-nav-toggle:hover { background: var(--surface3); color: var(--accent); border-color: var(--accent); }
.ldd-nav-toggle.active { background: var(--accent-dim); color: var(--accent); border-color: var(--accent); }

.ldd-nav-panel {
  position: absolute; top: 8px; right: 8px; z-index: 99;
  width: 240px; max-height: calc(100% - 16px);
  background: var(--surface); border: 1px solid var(--border2);
  border-radius: var(--radius); box-shadow: 0 8px 32px rgba(0,0,0,.45);
  display: flex; flex-direction: column;
  opacity: 0; pointer-events: none;
  transform: translateX(12px);
  transition: opacity .2s, transform .2s;
}
.ldd-nav-panel.show {
  opacity: 1; pointer-events: all; transform: translateX(0);
}

.ldd-nav-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--border);
  font-size: calc(12px * var(--scale)); font-weight: 600; color: var(--text);
}
.ldd-nav-close {
  background: none; border: none; color: var(--text3); font-size: 14px;
  cursor: pointer; padding: 2px 6px; border-radius: var(--radius-xs);
  transition: color .15s;
}
.ldd-nav-close:hover { color: var(--text); }

.ldd-nav-list {
  overflow-y: auto; flex: 1; padding: 6px 0;
}
.ldd-nav-empty {
  padding: 16px; text-align: center;
  font-size: calc(11px * var(--scale)); color: var(--text3);
}

.ldd-nav-group { margin-bottom: 2px; }
.ldd-nav-group-title {
  padding: 6px 14px; font-size: calc(10px * var(--scale));
  font-weight: 700; color: var(--accent2); text-transform: uppercase;
  letter-spacing: .5px;
}
.ldd-nav-item {
  display: block; width: 100%; text-align: left;
  padding: 5px 14px 5px 24px; border: none; background: none;
  font-size: calc(12px * var(--scale)); color: var(--text2);
  cursor: pointer; transition: background .12s, color .12s;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ldd-nav-item:hover { background: var(--surface2); color: var(--text); }
.ldd-nav-item.active { color: var(--accent); background: var(--accent-dim); }
.ldd-nav-item .nav-id {
  display: inline-block; min-width: 28px;
  font-family: 'JetBrains Mono', monospace; font-size: calc(10px * var(--scale));
  color: var(--text3); margin-right: 4px;
}

/* ═══════════════════════════════════════════════════════════
   ASSET REQUIREMENTS — 资产需求表
   ═══════════════════════════════════════════════════════════ */

.asset-reqs-container {
  height: 100%; overflow-y: auto; padding: 0;
}
.asset-reqs-view {
  display: flex; flex-direction: column; height: 100%;
}

/* ─── Toolbar ─── */
.asset-reqs-toolbar {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 20px; border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.asset-reqs-title {
  font-size: calc(16px * var(--scale)); font-weight: 700; color: var(--text1);
}
.asset-reqs-stats {
  margin-left: auto; font-size: calc(12px * var(--scale)); color: var(--text3);
}

/* ─── Category Tabs ─── */
.asset-reqs-tabs {
  display: flex; gap: 0; padding: 0 20px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
  overflow-x: auto;
}
.asset-req-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 10px 16px; border: none; background: none;
  color: var(--text2); font-size: calc(13px * var(--scale));
  cursor: pointer; border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s, background .15s;
  white-space: nowrap;
}
.asset-req-tab:hover { background: var(--surface2); color: var(--text1); }
.asset-req-tab.active {
  color: var(--accent2); border-bottom-color: var(--accent2);
  font-weight: 600;
}
.asset-req-tab-icon { font-size: calc(16px * var(--scale)); }
.asset-req-tab-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 20px; height: 18px; padding: 0 6px;
  background: var(--surface3); border-radius: 9px;
  font-size: calc(10px * var(--scale)); color: var(--text3); font-weight: 600;
}
.asset-req-tab.active .asset-req-tab-count {
  background: var(--accent-dim); color: var(--accent2);
}

/* ─── Content area ─── */
.asset-reqs-content {
  flex: 1; overflow-y: auto; padding: 16px 20px 24px;
}

/* ─── Category header ─── */
.asset-req-cat-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 16px; gap: 12px;
}
.asset-req-cat-title {
  display: flex; align-items: center; gap: 8px;
  font-size: calc(15px * var(--scale)); font-weight: 600; color: var(--text1);
}
.asset-req-cat-count {
  font-size: calc(12px * var(--scale)); color: var(--text3); font-weight: 400;
}
.asset-req-cat-actions {
  display: flex; gap: 8px;
}

/* ─── Empty state ─── */
.asset-req-empty {
  text-align: center; padding: 60px 20px; color: var(--text3);
  font-size: calc(14px * var(--scale));
}

/* ─── Table layout ─── */
.asset-req-table-wrap {
  overflow-x: auto;
}
.asset-req-table {
  width: 100%; border-collapse: collapse;
  font-size: calc(12px * var(--scale));
}
.asset-req-table thead {
  position: sticky; top: 0; z-index: 2;
}
.asset-req-table th {
  padding: 8px 10px; text-align: left;
  background: var(--surface3); color: var(--text2);
  font-weight: 600; font-size: calc(11px * var(--scale));
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}
.asset-req-table td {
  padding: 10px 10px; vertical-align: top;
  border-bottom: 1px solid var(--border);
  color: var(--text1);
}
.asset-req-row:hover td {
  background: var(--surface2);
}

/* Column widths */
.col-idx    { width: 36px; text-align: center; color: var(--text3); }
.col-rating { width: 48px; text-align: center; }
.col-name   { width: 100px; font-weight: 600; white-space: nowrap; }
.col-engine { width: 180px; }
.col-scene  { width: 110px; }
.col-desc   { min-width: 200px; }
.col-ref    { width: 64px; text-align: center; }
.col-note   { width: 120px; font-size: calc(11px * var(--scale)); color: var(--text2); }
.col-actions { width: 60px; text-align: center; white-space: nowrap; }

/* Rating badges */
.asset-rating-badge {
  display: inline-block; padding: 2px 8px; border-radius: 4px;
  font-size: calc(10px * var(--scale)); font-weight: 700; letter-spacing: .5px;
  min-width: 22px; text-align: center;
}
.rating-s { background: rgba(255,67,67,.2); color: #ff4343; }
.rating-a { background: rgba(245,166,35,.2); color: #f5a623; }
.rating-b { background: rgba(115,180,255,.2); color: #73b4ff; }
.rating-c { background: rgba(160,160,160,.2); color: #a0a0a0; }

/* Engine name code */
.engine-code {
  font-family: 'Consolas', 'Menlo', monospace;
  font-size: calc(10.5px * var(--scale)); color: var(--accent2);
  background: var(--surface3); padding: 1px 5px; border-radius: 3px;
  word-break: break-all;
}

/* Scene tag */
.scene-tag {
  font-size: calc(11px * var(--scale)); color: var(--text2);
  background: var(--surface3); padding: 2px 8px; border-radius: 4px;
  white-space: nowrap;
}

/* Description cell */
.desc-cell {
  font-size: calc(11.5px * var(--scale)); line-height: 1.55; color: var(--text2);
  max-height: 100px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}

/* Ref image thumb */
.ref-thumb {
  width: 48px; height: 48px; border-radius: 4px;
  background-size: cover; background-position: center;
  cursor: pointer; margin: 0 auto;
  border: 1px solid var(--border);
  transition: transform .15s;
}
.ref-thumb:hover { transform: scale(1.15); }

.btn-ref-gen {
  background: none; border: 1px dashed var(--border); border-radius: 4px;
  width: 48px; height: 48px; cursor: pointer; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto; transition: border-color .2s, background .2s;
}
.btn-ref-gen:hover {
  border-color: var(--accent2); background: var(--accent-dim);
}

/* ═══════════════════════════════════════════════════════════
   REVIEW DISCUSSION — 审查讨论面板
   ═══════════════════════════════════════════════════════════ */

.review-container {
  height: 100%; overflow-y: auto; padding: 0;
}

.review-panel { padding: 0; }

/* ─── Review Results ─── */
.review-results { padding: 0 24px 24px; }

/* ─── Agent Grid ─── */
.review-agents-grid {
  display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px;
  margin-bottom: 20px; padding: 0 24px; padding-top: 16px;
}
@media (max-width: 1200px) {
  .review-agents-grid { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 800px) {
  .review-agents-grid { grid-template-columns: repeat(2, 1fr); }
}

.review-agent-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  padding: 14px 8px 10px; border-radius: var(--radius);
  background: var(--surface2); border: 2px solid transparent;
  cursor: pointer; transition: border-color .2s, background .2s, transform .15s;
  text-align: center;
}
.review-agent-card:hover { background: var(--surface3); transform: translateY(-1px); }
.review-agent-card.selected {
  border-color: var(--accent); background: var(--accent-dim);
}
.review-agent-card.running {
  border-color: var(--accent); box-shadow: 0 0 12px var(--accent-dim);
  animation: reviewPulse 2s infinite;
}
@keyframes reviewPulse {
  0%, 100% { box-shadow: 0 0 8px var(--accent-dim); }
  50% { box-shadow: 0 0 20px rgba(245,166,35,.25); }
}

.rac-icon { font-size: 24px; line-height: 1; }
.rac-name {
  font-size: calc(11px * var(--scale)); font-weight: 600; color: var(--text);
  line-height: 1.3;
}
.rac-dept {
  font-size: calc(9px * var(--scale)); color: var(--text3); margin-bottom: 4px;
}
.rac-round-count {
  display: inline-block; padding: 1px 6px; border-radius: 8px;
  font-size: calc(9px * var(--scale)); font-weight: 600;
  background: var(--surface3); color: var(--text3); margin-top: 2px;
}
.review-status {
  display: inline-block; padding: 2px 8px; border-radius: 12px;
  font-size: calc(9px * var(--scale)); font-weight: 600;
}
.review-status.pending { background: var(--surface3); color: var(--text3); }
.review-status.running { background: var(--accent-dim); color: var(--accent); }
.review-status.verdict-reject { background: var(--red-dim); color: var(--red); }
.review-status.verdict-conditional { background: var(--orange-dim); color: var(--orange); }
.review-status.verdict-pass { background: var(--green-dim); color: var(--green); }

/* ─── Detail Header ─── */
.review-detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px; margin-bottom: 12px;
  background: var(--surface2); border-bottom: 1px solid var(--border);
}
.rdh-left { display: flex; align-items: center; gap: 10px; }
.rdh-icon { font-size: 22px; }
.rdh-title { font-size: calc(15px * var(--scale)); font-weight: 700; color: var(--text); }
.rdh-dept { font-size: calc(11px * var(--scale)); color: var(--text3); }
.rdh-round-badge {
  padding: 2px 10px; border-radius: 12px;
  background: var(--accent-dim); color: var(--accent);
  font-size: calc(11px * var(--scale)); font-weight: 600;
}

/* ─── Review Results ─── */
.review-no-results {
  text-align: center; padding: 40px 20px;
  font-size: calc(13px * var(--scale)); color: var(--text3);
}

.review-round-block { margin-bottom: 20px; }
.review-round-block.collapsed { margin-bottom: 8px; }

.review-round-header {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px; background: var(--surface2); border-radius: var(--radius-sm);
  font-size: calc(13px * var(--scale)); font-weight: 600; color: var(--text);
  cursor: pointer; user-select: none;
  transition: background .15s;
}
.review-round-header:hover { background: var(--surface3); }
.review-round-header .rrc-verdict { margin-left: auto; }
.review-round-toggle {
  font-size: 10px; width: 16px; text-align: center; color: var(--text3);
}
.review-round-meta {
  font-weight: 400; font-size: calc(11px * var(--scale)); color: var(--text3);
}

.review-round-body { margin-top: 12px; display: flex; flex-direction: column; gap: 16px; }

/* ─── Round Action Buttons (delete / revise) ─── */
.review-round-actions {
  display: flex; gap: 8px; padding: 0 4px;
}
.review-action-btn {
  font-size: calc(11px * var(--scale)) !important;
  padding: 4px 10px !important;
  border-radius: var(--radius-sm) !important;
  color: var(--text2) !important;
  opacity: 0.7;
  transition: opacity .15s, color .15s, background .15s;
}
.review-action-btn:hover { opacity: 1; background: var(--surface3) !important; }
.review-delete-btn:hover { color: var(--red) !important; }

/* ─── Single Agent Result Card ─── */
.review-result-card {
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px 20px;
  border-left: 3px solid var(--border2);
}
.review-result-card.verdict-reject { border-left-color: var(--red); }
.review-result-card.verdict-conditional { border-left-color: var(--orange); }
.review-result-card.verdict-pass { border-left-color: var(--green); }

.rrc-header {
  display: flex; align-items: center; gap: 10px; margin-bottom: 10px;
}
.rrc-icon { font-size: 20px; }
.rrc-title {
  flex: 1; font-size: calc(14px * var(--scale)); font-weight: 600; color: var(--text);
}
.rrc-verdict {
  padding: 3px 12px; border-radius: 12px;
  font-size: calc(11px * var(--scale)); font-weight: 600;
}
.rrc-verdict.verdict-reject { background: var(--red-dim); color: var(--red); }
.rrc-verdict.verdict-conditional { background: var(--orange-dim); color: var(--orange); }
.rrc-verdict.verdict-pass { background: var(--green-dim); color: var(--green); }

.rrc-verdict-reason {
  font-size: calc(12px * var(--scale)); color: var(--text2);
  margin-bottom: 12px; font-style: italic;
  padding-left: 30px;
}

/* Objections */
.rrc-objections { margin-bottom: 16px; }
.rrc-section-title {
  font-size: calc(12px * var(--scale)); font-weight: 600; color: var(--accent2);
  margin-bottom: 10px; padding-left: 30px;
}

.rrc-objection {
  margin-left: 30px; padding: 10px 14px;
  background: var(--surface); border-radius: var(--radius-sm);
  margin-bottom: 8px; border-left: 3px solid var(--text3);
}
.rrc-objection.sev-critical { border-left-color: var(--red); }
.rrc-objection.sev-major { border-left-color: var(--orange); }
.rrc-objection.sev-minor { border-left-color: var(--blue); }

.rrc-obj-header {
  display: flex; align-items: center; gap: 8px; margin-bottom: 6px;
}
.rrc-sev-badge {
  padding: 1px 8px; border-radius: 8px;
  font-size: calc(9px * var(--scale)); font-weight: 700;
  letter-spacing: .5px;
}
.rrc-sev-badge.sev-critical { background: var(--red-dim); color: var(--red); }
.rrc-sev-badge.sev-major { background: var(--orange-dim); color: var(--orange); }
.rrc-sev-badge.sev-minor { background: var(--blue-dim); color: var(--blue); }

.rrc-obj-title {
  font-size: calc(12px * var(--scale)); font-weight: 600; color: var(--text);
}
.rrc-obj-detail {
  font-size: calc(12px * var(--scale)); color: var(--text2); line-height: 1.6;
}
.rrc-obj-ref {
  margin-top: 6px; font-size: calc(10px * var(--scale)); color: var(--text3);
  font-family: 'JetBrains Mono', monospace;
}

/* Resolution Proposal */
.rrc-resolution {
  background: var(--surface); border-radius: var(--radius-sm);
  padding: 14px 18px; margin-left: 30px;
  border: 1px solid var(--border);
}
.rrc-resolution .rrc-section-title { padding-left: 0; margin-bottom: 8px; }
.rrc-res-summary {
  font-size: calc(12px * var(--scale)); color: var(--text); line-height: 1.6;
  margin-bottom: 10px;
}
.rrc-res-steps {
  margin: 0 0 10px 18px; padding: 0;
  font-size: calc(12px * var(--scale)); color: var(--text2); line-height: 1.8;
}
.rrc-res-steps li { margin-bottom: 2px; }
.rrc-res-compromise {
  font-size: calc(11px * var(--scale)); color: var(--accent2);
  padding-top: 8px; border-top: 1px solid var(--border);
}