/* ═══════════════════════════════════════════════════════
   运营驾驶舱 v5 — 专业暗黑面板 · 蓝调高对比
   ═══════════════════════════════════════════════════════ */

/* ── 1. Design Tokens ── */
:root {
  --bg-deep:      #0c0e12;
  --bg-surface:   #12151a;
  --bg-elevated:  #181c23;
  --bg-hover:     #1e222a;
  --bg-input:     #181c23;
  --border-subtle: rgba(255,255,255,0.06);
  --border:       rgba(255,255,255,0.10);
  --border-act:   rgba(255,255,255,0.18);
  --text-pri:     #eeeff2;
  --text-sec:     #b0b4bd;
  --text-muted:   #747b87;
  --accent:       #5e9cf5;
  --accent-glow:  rgba(94,156,245,0.12);
  --accent-hover: #7ab3ff;
  --green:        #4ade80;
  --red:          #f87171;
  --orange:       #fb923c;
  --radius:       8px;
  --radius-sm:    4px;
  --radius-lg:    12px;
  --font:         'Inter', 'PingFang SC', 'Microsoft YaHei', system-ui, -apple-system, sans-serif;
  --font-mono:    'JetBrains Mono', 'Cascadia Code', 'Consolas', monospace;
  --transition:   150ms ease;
}

/* ── 2. Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-pri);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 13px;
  line-height: 1.5;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.hidden { display: none !important; }

/* ── 3. Header ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  height: 44px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
  z-index: 100;
}

.header-left { display: flex; align-items: center; gap: 16px; }
.header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-pri);
  letter-spacing: -0.2px;
}
.header-nav { display: flex; gap: 2px; }
.header-nav button {
  background: none;
  border: none;
  color: var(--text-sec);
  font-size: 12px;
  padding: 5px 10px;
  border-radius: 5px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  font-weight: 450;
}
.header-nav button:hover { color: var(--text-pri); background: var(--bg-hover); }

.header-right { display: flex; align-items: center; gap: 14px; }
.header-user { color: var(--accent); font-weight: 500; font-size: 12px; }
.header-date { color: var(--text-muted); font-size: 11px; }
.header-health { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-sec); }
.health-dot { width: 6px; height: 6px; border-radius: 50%; }
.health-dot.ok { background: var(--green); box-shadow: 0 0 5px rgba(74,222,128,0.35); }
.health-dot.err { background: var(--red); box-shadow: 0 0 5px rgba(248,113,113,0.35); }

/* ── 4. App Main Layout ── */
.app-main {
  flex: 1;
  display: flex;
  overflow: hidden;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

/* ── 5. Config Panel ── */
.config-panel {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.config-section { }
.config-section-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.8px;
  margin-bottom: 10px;
  padding-left: 2px;
}

/* ── 6. Platform Cards ── */
.platform-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.platform-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 14px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
  position: relative;
}

.platform-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
  transform: translateY(-1px);
}

.platform-card.selected {
  border-color: var(--accent);
  background: rgba(94,156,245,0.06);
}

.platform-card.selected::after {
  content: '✓';
  position: absolute;
  top: 8px;
  right: 10px;
  font-size: 11px;
  color: var(--accent);
  font-weight: 600;
}

.platform-card .pc-icon { font-size: 22px; margin-bottom: 6px; display: block; }
.platform-card .pc-name { font-size: 14px; font-weight: 550; margin-bottom: 2px; color: var(--text-pri); }
.platform-card .pc-category {
  font-size: 10px;
  color: var(--text-muted);
  font-weight: 400;
}
.platform-card.selected .pc-category { color: var(--accent); }
.platform-card .pc-desc {
  font-size: 11px;
  color: var(--text-sec);
  line-height: 1.4;
  margin-top: 6px;
}
.platform-card .pc-types {
  display: flex;
  gap: 4px;
  justify-content: center;
  margin-top: 8px;
  flex-wrap: wrap;
}
.pc-type-tag {
  font-size: 10px;
  padding: 2px 6px;
  border-radius: 3px;
  background: var(--bg-elevated);
  color: var(--text-muted);
}
.platform-card.selected .pc-type-tag { color: var(--text-sec); }

/* ── 7. Content Type Cards ── */
.ctype-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.ctype-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.ctype-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
}

.ctype-card.selected {
  border-color: var(--accent);
  background: rgba(94,156,245,0.06);
}

.ctype-card.disabled {
  opacity: 0.35;
  cursor: not-allowed;
  pointer-events: none;
}

.ctype-card .ct-icon { font-size: 24px; margin-bottom: 8px; display: block; }
.ctype-card .ct-name { font-size: 14px; font-weight: 550; margin-bottom: 4px; color: var(--text-pri); }
.ctype-card .ct-tools { font-size: 11px; color: var(--text-muted); margin-bottom: 4px; }
.ctype-card .ct-hint { font-size: 10px; color: var(--text-muted); }

/* ── 7b. Video Mode Cards ── */
#videoModeSection.hidden { display: none; }

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

.video-mode-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: center;
}

.video-mode-card:hover {
  background: var(--bg-elevated);
  border-color: var(--border);
}

.video-mode-card.selected {
  border-color: var(--accent);
  background: rgba(94,156,245,0.06);
}

.video-mode-card .pc-icon { font-size: 22px; margin-bottom: 6px; display: block; }
.video-mode-card .pc-name { font-size: 14px; font-weight: 550; margin-bottom: 2px; color: var(--text-pri); }
.video-mode-card .pc-desc { font-size: 11px; color: var(--text-sec); line-height: 1.4; margin-top: 4px; }
.video-mode-card .ct-tools { font-size: 10px; color: var(--text-muted); margin-top: 6px; }
.video-mode-card .ct-hint { font-size: 10px; color: var(--accent); margin-top: 2px; }

/* Avatar source video selector */
.avatar-source-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 8px;
}
.avatar-source-select {
  flex: 1;
  padding: 9px 12px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-pri);
  font-size: 13px;
  cursor: pointer;
  color-scheme: dark;
  -webkit-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23888' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
}
.avatar-source-select option {
  background: #1a1a2e;
  color: #e0e0e0;
}
.btn-upload-avatar {
  display: inline-flex;
  align-items: center;
  padding: 9px 16px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 550;
  cursor: pointer;
  white-space: nowrap;
  transition: background .15s;
}
.btn-upload-avatar:hover { background: var(--accent-hover); }

/* ── 8. Topic Section ── */
.topic-section { display: flex; flex-direction: column; gap: 12px; }

.topic-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 14px;
  background: var(--bg-surface);
  border-radius: var(--radius);
  border: 1px solid var(--border-subtle);
  font-size: 12px;
  color: var(--text-sec);
  min-height: 40px;
  align-items: center;
}

.topic-summary:empty::after {
  content: '尚未选择平台和形式';
  color: var(--text-muted);
  font-style: italic;
}

.topic-summary .ts-tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  background: var(--bg-elevated);
  border-radius: 4px;
  font-size: 11px;
  color: var(--text-sec);
}

.topic-input, .topic-ref {
  width: 100%;
  padding: 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  color: var(--text-pri);
  font-family: var(--font);
  font-size: 13px;
  line-height: 1.6;
  resize: vertical;
  transition: border-color var(--transition);
  outline: none;
}

.topic-input:focus, .topic-ref:focus { border-color: var(--border-act); }

.topic-input { min-height: 80px; }
.topic-ref { min-height: 60px; font-size: 12px; }

.topic-input::placeholder, .topic-ref::placeholder { color: var(--text-muted); }

/* ── 9. Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition);
  letter-spacing: -0.1px;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  font-weight: 550;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-sec);
}

.btn-outline:hover {
  border-color: var(--border-act);
  color: var(--text-pri);
  background: var(--bg-hover);
}

.btn-sm { padding: 5px 10px; font-size: 11px; border-radius: 5px; }

.btn-gen {
  width: 100%;
  padding: 14px;
  font-size: 14px;
  font-weight: 550;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  letter-spacing: -0.2px;
}

.btn-gen:hover { background: var(--accent-hover); }
.btn-gen:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn-confirm-video {
  width: 100%;
  padding: 14px;
  font-size: 14px;
  font-weight: 550;
  background: var(--green);
  color: #0c0e12;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font);
  letter-spacing: -0.2px;
}

.btn-confirm-video:hover { filter: brightness(1.1); }
.btn-confirm-video.hidden { display: none; }

/* ── 10. Output Panel ── */
.output-panel {
  max-width: 900px;
  margin: 0 auto;
}

.output-panel .output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.output-panel .output-header h3 {
  font-size: 15px;
  font-weight: 550;
  color: var(--text-pri);
}

.viewer-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.viewer-tab {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-sec);
  padding: 7px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 450;
  font-family: var(--font);
  transition: all var(--transition);
  white-space: nowrap;
}

.viewer-tab:hover { color: var(--text-pri); border-color: var(--border); }
.viewer-tab.active {
  background: var(--bg-elevated);
  border-color: var(--border);
  color: var(--text-pri);
  font-weight: 500;
}

.viewer-tab .vt-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--bg-hover);
  font-size: 10px;
  font-weight: 500;
  margin-left: 6px;
  color: var(--text-muted);
}

.viewer-tab.active .vt-badge { background: var(--accent-glow); color: var(--accent); }

.viewer-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 200px;
}

.viewer-body .viewer-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 120px;
  color: var(--text-muted);
  font-size: 13px;
}

.content-block {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 20px;
  animation: fadeIn 300ms ease;
}

.content-block h1 { font-size: 15px; font-weight: 600; margin-bottom: 12px; color: var(--text-pri); }
.content-block h2 { font-size: 14px; font-weight: 550; margin: 14px 0 8px; color: var(--text-pri); }
.content-block h3 { font-size: 13px; font-weight: 500; margin: 10px 0 6px; color: var(--text-sec); }
.content-block p { margin-bottom: 8px; line-height: 1.65; }
.content-block ul, .content-block ol { margin: 6px 0 6px 18px; }
.content-block li { margin-bottom: 3px; }
.content-block strong { color: var(--accent); font-weight: 550; }
.content-block blockquote {
  border-left: 2px solid var(--accent);
  padding: 6px 14px;
  margin: 10px 0;
  color: var(--text-sec);
  background: var(--bg-elevated);
  border-radius: 0 4px 4px 0;
}
.content-block code {
  background: var(--bg-elevated);
  padding: 2px 5px;
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-sec);
}
.content-block hr { border: none; border-top: 1px solid var(--border-subtle); margin: 16px 0; }

.discuss-btn {
  margin-top: 16px;
  padding: 7px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-sec);
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  transition: all var(--transition);
}

.discuss-btn:hover {
  border-color: var(--border);
  color: var(--text-pri);
  background: var(--bg-hover);
}

/* ── 11. Mini Progress ── */
.mini-progress {
  margin-top: 16px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  display: none;
}

.mini-progress.active { display: block; }

.mp-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  font-size: 12px;
}

.mp-phase { color: var(--text-sec); font-weight: 450; }
.mp-count { color: var(--text-muted); font-size: 11px; }

.mp-bar-track {
  height: 3px;
  background: var(--bg-elevated);
  border-radius: 2px;
  overflow: hidden;
}

.mp-bar-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 300ms ease;
  width: 0%;
}

/* ── 12. Back to Config ── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-muted);
  cursor: pointer;
  background: none;
  border: none;
  font-family: var(--font);
  padding: 4px 0;
  transition: color var(--transition);
}

.back-link:hover { color: var(--text-sec); }

/* ── 13. AI Assistant Panel ── */
.assistant-panel {
  width: 340px;
  flex-shrink: 0;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  transition: width 200ms ease, margin 200ms ease;
  overflow: hidden;
}

.assistant-panel.collapsed {
  width: 0;
  min-width: 0;
  border-left: none;
}

.assistant-collapse-tab {
  display: none;
  position: fixed;
  right: 0;
  top: 50%;
  transform: translateY(-50%) rotate(-90deg);
  transform-origin: center center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  color: var(--text-sec);
  padding: 10px 16px;
  font-size: 12px;
  font-family: var(--font);
  cursor: pointer;
  z-index: 50;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

.assistant-panel.collapsed ~ .assistant-collapse-tab { display: block; }

.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 13px;
  font-weight: 550;
  color: var(--text-pri);
  flex-shrink: 0;
}

.assistant-collapse {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 2px 8px;
  border-radius: 4px;
  transition: all var(--transition);
  font-family: var(--font);
  line-height: 1;
}

.assistant-collapse:hover { color: var(--text-sec); background: var(--bg-hover); }

.assistant-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.assistant-msg {
  font-size: 12px;
  line-height: 1.6;
  padding: 10px 14px;
  border-radius: var(--radius);
  max-width: 90%;
  word-break: break-word;
}

.assistant-msg.user {
  align-self: flex-end;
  background: rgba(94,156,245,0.12);
  color: var(--text-pri);
  border: 1px solid rgba(94,156,245,0.18);
}

.assistant-msg.agent {
  align-self: flex-start;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  color: var(--text-pri);
}

.assistant-msg.auto {
  align-self: center;
  background: transparent;
  color: var(--text-muted);
  font-size: 11px;
  text-align: center;
  max-width: 100%;
  padding: 6px;
  border: none;
}

.assistant-msg p { margin-bottom: 4px; }
.assistant-msg h1, .assistant-msg h2, .assistant-msg h3 { font-size: 13px; margin: 8px 0 4px; }
.assistant-msg ul { margin: 4px 0 4px 16px; }
.assistant-msg code { background: var(--bg-hover); padding: 1px 4px; border-radius: 2px; font-size: 11px; }

/* ── Typing Indicator ── */
.typing-indicator {
  align-self: flex-start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 14px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  max-width: 90%;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typingBounce 1.3s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.15s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.3s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.assistant-input-area {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.assistant-input {
  flex: 1;
  padding: 9px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-pri);
  font-family: var(--font);
  font-size: 12px;
  resize: none;
  outline: none;
  transition: border-color var(--transition);
  line-height: 1.5;
}

.assistant-input:focus { border-color: var(--border-act); }
.assistant-input::placeholder { color: var(--text-muted); }

.assistant-send {
  padding: 8px 16px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 550;
  font-family: var(--font);
  white-space: nowrap;
  transition: all var(--transition);
}

.assistant-send:hover { background: var(--accent-hover); }
.assistant-send:disabled { opacity: 0.35; cursor: not-allowed; }

/* ── 14. Login Overlay ── */
.login-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-deep);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.login-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 36px;
  width: 360px;
  text-align: center;
}

.login-box h2 { font-size: 20px; font-weight: 600; margin-bottom: 6px; letter-spacing: -0.3px; }
.login-sub { color: var(--text-muted); font-size: 13px; margin-bottom: 28px; }
.login-box input {
  display: block;
  width: 100%;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 6px;
  color: var(--text-pri);
  font-family: var(--font);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.login-box input:focus { border-color: var(--border-act); }
.login-btn {
  width: 100%;
  padding: 10px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 550;
  font-family: var(--font);
  cursor: pointer;
  margin-top: 8px;
  transition: all var(--transition);
}
.login-btn:hover { background: var(--accent-hover); }

/* ── 15. Modals ── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 2000;
  align-items: center;
  justify-content: center;
}

.modal-overlay.flex { display: flex; }

.modal-box {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: 600px;
  max-width: 90vw;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}

.modal-wide { width: 760px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-subtle);
  flex-shrink: 0;
}

.modal-header h3 { font-size: 15px; font-weight: 550; }

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: all var(--transition);
}

.modal-close:hover { color: var(--text-pri); background: var(--bg-hover); }

.modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.modal-actions {
  padding: 12px 20px;
  border-top: 1px solid var(--border-subtle);
  flex-shrink: 0;
  min-height: 44px;
}

.modal-actions:empty { display: none; }

/* ── 16. Toolbox Drawer ── */
.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 1500;
}

.drawer-panel {
  position: fixed;
  right: -420px;
  top: 44px;
  bottom: 0;
  width: 400px;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  z-index: 1501;
  overflow-y: auto;
  transition: right 200ms ease;
  padding: 20px;
}

.drawer-panel.open { right: 0; }

.drawer-section {
  margin-bottom: 28px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border-subtle);
}

.drawer-section:last-child { border-bottom: none; margin-bottom: 0; }

.drawer-section h4 {
  font-size: 12px;
  font-weight: 550;
  color: var(--text-sec);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
}

/* ── 17. Assets Grid ── */
.assets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.asset-card {
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  position: relative;
  background: var(--bg-elevated);
  cursor: pointer;
  transition: all var(--transition);
}

.asset-card:hover { opacity: 0.9; }

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

.asset-delete {
  position: absolute;
  top: 4px;
  right: 4px;
  background: rgba(0,0,0,0.7);
  color: var(--red);
  border: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-size: 12px;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.asset-card:hover .asset-delete { display: flex; }

/* ── 18. Toast ── */
.toast-container {
  position: fixed;
  top: 56px;
  right: 20px;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toast {
  padding: 10px 16px;
  border-radius: 6px;
  font-size: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text-pri);
  animation: slideIn 200ms ease;
  max-width: 360px;
  word-break: break-word;
}

.toast.success { border-color: rgba(74,222,128,0.3); }
.toast.error { border-color: rgba(248,113,113,0.4); color: var(--red); }

@keyframes slideIn {
  from { opacity: 0; transform: translateX(20px); }
  to { opacity: 1; transform: translateX(0); }
}

/* ── 19. History List ── */
.history-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition);
  border: 1px solid transparent;
}

.history-item:hover { background: var(--bg-hover); }
.history-item.expanded { background: var(--bg-elevated); border-color: var(--border-subtle); }

.hi-header { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.hi-date { color: var(--text-muted); font-size: 11px; white-space: nowrap; }
.hi-topic { font-size: 13px; font-weight: 500; color: var(--text-pri); }
.hi-meta { font-size: 11px; color: var(--text-muted); }
.hi-files { margin-top: 8px; }

.file-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 12px;
}

.file-row .file-name { color: var(--text-sec); }
.file-row button {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 11px;
  cursor: pointer;
  font-family: var(--font);
  padding: 2px 6px;
  border-radius: 3px;
}

.file-row button:hover { color: var(--text-pri); background: var(--bg-hover); }

/* ── 20. Performance Form ── */
.perf-form input, .perf-form select {
  width: 100%;
  padding: 8px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-pri);
  font-family: var(--font);
  font-size: 12px;
  outline: none;
  margin-bottom: 8px;
  transition: border-color var(--transition);
}

.perf-form input:focus, .perf-form select:focus { border-color: var(--border-act); }
.perf-form select option { background: var(--bg-elevated); color: var(--text-pri); }

.perf-row { display: flex; gap: 8px; }
.perf-row input, .perf-row select { flex: 1; }

/* ── 21. Stats ── */
.stats-grid { display: grid; grid-template-columns: repeat(4,1fr); gap: 10px; margin-bottom: 20px; }

.stat-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius);
  padding: 16px;
  text-align: center;
}

.stat-value { font-size: 24px; font-weight: 600; color: var(--text-pri); }
.stat-label { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

.stats-grid + h4, .stats-grid + table + h4 {
  font-size: 13px;
  font-weight: 550;
  color: var(--text-sec);
  margin: 16px 0 8px;
}

/* ── 22. Tables ── */
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

th, td {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-subtle);
}

th { color: var(--text-muted); font-weight: 500; font-size: 11px; text-transform: uppercase; letter-spacing: 0.4px; }
td { color: var(--text-sec); }

tr:hover td { background: var(--bg-hover); }

/* ── 23. Knowledge Items ── */
.knowledge-item {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  align-items: center;
}

.knowledge-item:hover { background: var(--bg-hover); }

.kw-cat {
  font-size: 10px;
  color: var(--accent);
  background: var(--accent-glow);
  padding: 2px 6px;
  border-radius: 3px;
  white-space: nowrap;
}

.kw-name { font-size: 13px; font-weight: 450; flex: 1; }
.kw-mtime { font-size: 11px; color: var(--text-muted); }
.kw-size { font-size: 10px; color: var(--text-muted); }

/* ── 24. MD Content Viewer ── */
.md-content { font-size: 13px; line-height: 1.7; }
.md-content h1 { font-size: 18px; font-weight: 600; margin: 20px 0 10px; color: var(--text-pri); }
.md-content h2 { font-size: 15px; font-weight: 550; margin: 16px 0 8px; color: var(--text-pri); }
.md-content h3 { font-size: 13px; font-weight: 500; margin: 12px 0 6px; color: var(--text-sec); }
.md-content p { margin-bottom: 10px; }
.md-content ul, .md-content ol { margin: 6px 0 6px 20px; }
.md-content li { margin-bottom: 4px; }
.md-content strong { color: var(--accent); font-weight: 550; }
.md-content blockquote {
  border-left: 2px solid var(--accent);
  padding: 8px 16px;
  margin: 12px 0;
  color: var(--text-sec);
  background: var(--bg-elevated);
  border-radius: 0 6px 6px 0;
}
.md-content img { max-width: 100%; border-radius: var(--radius); }
.md-content a { color: var(--accent); }

/* ── 25. Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

/* ── 26. Animations ── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

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

/* ── 27. Avatar Pipeline Status Card ── */
.avatar-pipeline {
  padding: 16px 0;
}

.ap-script {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.7;
  color: var(--text-pri);
  max-height: 240px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.ap-steps {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.ap-step {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-muted);
  transition: all 0.3s ease;
  flex-wrap: wrap;
}

.ap-step.active {
  color: var(--text-pri);
  background: var(--accent-glow);
}

.ap-step.done {
  color: var(--text-sec);
}

.ap-icon {
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  font-size: 12px;
  flex-shrink: 0;
}

.ap-icon.pending {
  border: 1.5px solid rgba(255,255,255,0.12);
  color: var(--text-muted);
}

.ap-icon.active {
  border: 1.5px solid var(--accent);
  color: var(--accent);
  animation: pulse 1.2s ease-in-out infinite;
}

.ap-icon.done {
  background: rgba(94,156,245,0.2);
  border: 1.5px solid var(--accent);
  color: var(--accent);
}

.ap-step-label {
  flex: 1;
}

.ap-step-pct {
  font-size: 12px;
  color: var(--accent);
  font-weight: 600;
  min-width: 36px;
  text-align: right;
}

.ap-heygem-bar {
  width: 100%;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  margin-top: 2px;
}

.ap-heygem-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.5s ease;
}

.ap-result {
  margin-top: 16px;
  padding: 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
}

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