
/* ==================== Fonts ==================== */
@font-face {
  font-family: "PorscheNext";
  src: url("../fonts/porsche-next-latin-regular.woff2") format("woff2");
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "PorscheNext";
  src: url("../fonts/porsche-next-latin-semi-bold.woff2") format("woff2");
  font-weight: 600; font-style: normal; font-display: swap;
}
@font-face {
  font-family: "PorscheNext";
  src: url("../fonts/porsche-next-latin-bold.woff2") format("woff2");
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ==================== Reset & Tokens ==================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
:root {
  --bg: #f7f8fa;
  --surface: #ffffff;
  --surface-hover: #f1f3f5;
  --border: #e5e7eb;
  --border-light: #f0f1f3;
  --text-1: #111827;
  --text-2: #4b5563;
  --text-3: #9ca3af;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --accent-light: #eff6ff;
  --accent-ghost: #dbeafe;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --radius: 8px;
  --radius-sm: 6px;
  --radius-lg: 12px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.08), 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.08), 0 2px 4px -2px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.08), 0 4px 6px -4px rgba(0,0,0,.04);
  --sidebar-w: 260px;
  --font: "PorscheNext", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Consolas", monospace;
}
html, body { height: 100%; font-family: var(--font); font-size: 14px; color: var(--text-1); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }
input, select, textarea { font-family: inherit; font-size: 14px; }

/* ==================== Layout ==================== */
.app { display: flex; height: 100vh; overflow: hidden; }

/* Sidebar */
.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; background: var(--surface);
  border-right: 1px solid var(--border); display: flex; flex-direction: column;
}
.sidebar-header {
  padding: 20px 16px 16px; border-bottom: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 10px;
}
.sidebar-logo {
  width: 32px; height: 32px; background: var(--accent); border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.sidebar-logo svg { width: 18px; height: 18px; fill: #fff; }
.sidebar-title { font-size: 15px; font-weight: 600; color: var(--text-1); letter-spacing: -0.3px; }
.sidebar-subtitle { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.sidebar-nav { padding: 12px 8px; flex-shrink: 0; }
.nav-item {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 9px 12px; border-radius: var(--radius-sm); color: var(--text-2);
  font-size: 13.5px; font-weight: 500; transition: all .15s; text-align: left;
}
.nav-item:hover { background: var(--surface-hover); color: var(--text-1); }
.nav-item.active { background: var(--accent-light); color: var(--accent); }
.nav-item svg { width: 17px; height: 17px; flex-shrink: 0; }

.sidebar-divider { height: 1px; background: var(--border-light); margin: 8px 12px; }

.sidebar-section-label {
  padding: 8px 16px 4px; font-size: 11px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .5px;
}
.sidebar-tree { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.tree-node { user-select: none; }
.tree-row {
  display: flex; align-items: center; gap: 6px; padding: 6px 8px;
  border-radius: var(--radius-sm); cursor: pointer; transition: all .12s;
  color: var(--text-2); font-size: 13px;
}
.tree-row:hover { background: var(--surface-hover); }
.tree-row.active { background: var(--accent-light); color: var(--accent); font-weight: 500; }
.tree-row svg { width: 15px; height: 15px; flex-shrink: 0; opacity: .55; }
.tree-row.active svg { opacity: 1; }
.tree-row .tree-icon-toggle {
  width: 14px; height: 14px; display: flex; align-items: center; justify-content: center;
  border-radius: 3px; transition: background .12s;
}
.tree-row .tree-icon-toggle:hover { background: var(--border); }
.tree-children { margin-left: 16px; }
.tree-badge {
  margin-left: auto; font-size: 10px; color: var(--text-3);
  background: var(--surface-hover); padding: 1px 6px; border-radius: 10px;
}

.sidebar-footer {
  padding: 10px 12px; border-top: 1px solid var(--border-light);
  display: flex; align-items: center; gap: 8px;
}
.health-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--text-3); flex-shrink: 0; }
.health-dot.ok { background: var(--success); }
.health-dot.err { background: var(--danger); }
.sidebar-footer-text { font-size: 12px; color: var(--text-3); }

/* Main */
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.main-header {
  height: 56px; background: var(--surface); border-bottom: 1px solid var(--border);
  display: flex; align-items: center; padding: 0 24px; gap: 12px; flex-shrink: 0;
}
.main-header-title { font-size: 15px; font-weight: 600; color: var(--text-1); }
.main-header-sub { font-size: 12.5px; color: var(--text-3); margin-left: 4px; }
.main-header-actions { margin-left: auto; display: flex; gap: 8px; }
.main-content { flex: 1; overflow-y: auto; }
.page { display: none; padding: 24px; box-sizing: border-box; }
.page.active { display: flex; flex-direction: column; align-items: flex-start; }
.page.qa-page { height: 100%; min-height: 0; }

/* ==================== Buttons ==================== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 7px 14px; border-radius: var(--radius-sm); font-size: 13px; font-weight: 500;
  transition: all .15s; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--surface); color: var(--text-1); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--surface-hover); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-ghost { color: var(--text-2); padding: 6px 8px; }
.btn-ghost:hover { background: var(--surface-hover); color: var(--text-1); }
.btn-sm { padding: 5px 10px; font-size: 12px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 15px; height: 15px; }

/* ==================== Cards ==================== */
.card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px; box-shadow: var(--shadow-sm);
  width: 100%;
}
.card-title { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 16px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }

/* ==================== Form Elements ==================== */
.input, .select, .textarea {
  width: 100%; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: var(--radius-sm); font-size: 13.5px; color: var(--text-1);
  background: var(--surface); transition: border-color .15s, box-shadow .15s;
  -webkit-appearance: none; appearance: none;
}
.input:hover, .select:hover, .textarea:hover {
  border-color: var(--text-3);
}
.input:focus, .select:focus, .textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ghost);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.textarea { resize: vertical; min-height: 80px; }

/* Select custom arrow */
.select {
  padding-right: 32px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 14px 14px;
  cursor: pointer;
}
.select option { font-family: var(--font); font-size: 13.5px; padding: 6px 8px; }
.select option:checked { background: var(--accent-light); color: var(--accent); }

.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--text-2); margin-bottom: 6px; }
.form-hint { font-size: 12px; color: var(--text-3); margin-top: 4px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }

/* Toggle switch */
.toggle { display: inline-block; position: relative; width: 40px; height: 22px; flex-shrink: 0; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; background: var(--border); border-radius: 11px;
  transition: background .2s; cursor: pointer;
}
.toggle-slider::before {
  content: ""; position: absolute; width: 18px; height: 18px;
  left: 2px; top: 2px; background: #fff; border-radius: 50%;
  transition: transform .2s; box-shadow: var(--shadow-sm);
}
.toggle input:checked + .toggle-slider { background: var(--accent); }
.toggle input:checked + .toggle-slider::before { transform: translateX(18px); }

/* ==================== Table ==================== */
.table { width: 100%; border-collapse: collapse; }
.table th {
  text-align: left; padding: 10px 12px; font-size: 12px; font-weight: 600;
  color: var(--text-3); text-transform: uppercase; letter-spacing: .3px;
  border-bottom: 1px solid var(--border);
}
.table td {
  padding: 12px; font-size: 13.5px; color: var(--text-1);
  border-bottom: 1px solid var(--border-light);
}
.table tr:hover td { background: var(--surface-hover); }
.table .actions { display: flex; gap: 4px; }
.table .row-action { text-align: right; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; border: none; background: transparent;
  border-radius: 6px; cursor: pointer; color: var(--text-3);
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--surface-hover); color: var(--text-1); }
.icon-btn.danger { color: var(--text-3); }
.icon-btn.danger:hover { background: var(--danger-light, #fdecec); color: var(--danger, #e5484d); }

/* ==================== Badges ==================== */
.badge {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 2px 8px; border-radius: 10px; font-size: 11.5px; font-weight: 500;
}
.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-green { background: var(--success-light); color: var(--success); }
.badge-gray { background: var(--surface-hover); color: var(--text-2); }
.badge-amber { background: var(--warning-light); color: var(--warning); }
.badge-red { background: var(--danger-light); color: var(--danger); }

/* ==================== Chat (QA Page) ==================== */
.qa-layout { display: flex; flex-direction: column; flex: 1; width: 100%; min-height: 0; }
.qa-folder-bar {
  display: flex; align-items: center; gap: 8px; padding: 0 0 16px;
}
.qa-folder-bar .label { font-size: 13px; color: var(--text-3); white-space: nowrap; }
.qa-folder-bar .select { width: 220px; padding: 6px 10px; font-size: 13px; }
.qa-folder-bar .scope-badge { font-size: 11.5px; color: var(--text-3); }
.qa-clear-btn {
  margin-left: auto; display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 10px; border-radius: var(--radius-sm); font-size: 12px; font-weight: 500;
  color: var(--text-3); background: transparent; border: 1px solid var(--border);
  transition: all .15s; white-space: nowrap;
}
.qa-clear-btn:hover { color: var(--danger); border-color: var(--danger); background: var(--danger-light); }
.qa-clear-btn:disabled { opacity: .4; cursor: not-allowed; }
.qa-clear-btn svg { width: 13px; height: 13px; }
.qa-toggle {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: var(--radius-sm);
  font-size: 12px; font-weight: 500; color: var(--text-3);
  background: transparent; border: 1px solid var(--border);
  cursor: pointer; transition: all .15s; white-space: nowrap; user-select: none;
}
.qa-toggle:hover { color: var(--text-2); background: var(--surface-hover); }
.qa-toggle.on { color: var(--accent); border-color: var(--accent); background: var(--accent-light); }
.qa-toggle input { width: 13px; height: 13px; margin: 0; accent-color: var(--accent); cursor: pointer; }

.chat-container {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 16px;
  padding: 20px 24px; background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); box-shadow: var(--shadow-sm);
}
.chat-msg { display: flex; gap: 12px; max-width: 85%; animation: msgIn .25s ease; }
.chat-msg.user { align-self: flex-end; flex-direction: row-reverse; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.chat-avatar {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
}
.chat-msg.assistant .chat-avatar { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%); }
.chat-msg.user .chat-avatar { background: var(--surface-hover); border: 1px solid var(--border); }
.chat-avatar svg { width: 16px; height: 16px; }
.chat-bubble {
  padding: 12px 16px; border-radius: var(--radius-lg); font-size: 14px;
  line-height: 1.65; word-break: break-word;
}
.chat-msg.assistant .chat-bubble { background: var(--surface); border: 1px solid var(--border); border-top-left-radius: 4px; box-shadow: var(--shadow-sm); }
.chat-msg.user .chat-bubble { background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%); color: #fff; border-top-right-radius: 4px; }
.chat-bubble p { margin-bottom: 8px; }
.chat-bubble-img {
  display: block; max-width: 240px; max-height: 240px;
  width: auto; height: auto; border-radius: 8px;
  margin-bottom: 8px; object-fit: cover;
  border: 1px solid rgba(255,255,255,.25);
  background: rgba(255,255,255,.08);
}
.chat-bubble.img-only { padding: 6px; }
.chat-bubble.img-only .chat-bubble-img { margin-bottom: 0; }
.chat-bubble p:last-child { margin-bottom: 0; }
.chat-bubble h1, .chat-bubble h2, .chat-bubble h3, .chat-bubble h4 { margin: 12px 0 6px; font-size: 15px; }
.chat-bubble ul, .chat-bubble ol { margin: 6px 0; padding-left: 20px; }
.chat-bubble li { margin-bottom: 4px; }
.chat-bubble code { background: rgba(0,0,0,.06); padding: 1px 5px; border-radius: 3px; font-family: var(--font-mono); font-size: 13px; }
.chat-msg.user .chat-bubble code { background: rgba(255,255,255,.2); }
.chat-bubble pre { background: #1e293b; color: #e2e8f0; padding: 12px; border-radius: var(--radius-sm); overflow-x: auto; margin: 8px 0; }
.chat-bubble pre code { background: none; color: inherit; padding: 0; }
.chat-bubble table { width: 100%; border-collapse: collapse; margin: 8px 0; }
.chat-bubble th, .chat-bubble td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; font-size: 13px; }
.chat-bubble th { background: var(--surface-hover); }

/* Sources */
.sources { margin-top: 10px; border-top: 1px solid var(--border-light); padding-top: 8px; }
.sources-toggle {
  display: flex; align-items: center; gap: 4px; font-size: 12px;
  color: var(--text-3); cursor: pointer; padding: 2px 0;
}
.sources-toggle:hover { color: var(--text-2); }
.sources-toggle svg { width: 12px; height: 12px; transition: transform .2s; }
.sources-toggle.open svg { transform: rotate(90deg); }
.sources-list { margin-top: 8px; }
.source-item {
  padding: 8px 10px; background: var(--surface-hover); border-radius: var(--radius-sm);
  margin-bottom: 6px; font-size: 12.5px; line-height: 1.5;
}
.source-item .source-meta { display: flex; gap: 8px; margin-bottom: 3px; }
.source-item .source-score { color: var(--success); font-weight: 600; }
.source-item .source-kw {
  color: var(--warning); font-weight: 500; cursor: help;
  padding: 0 5px; border-radius: 4px; background: var(--warning-light);
}
.source-item .source-folder { color: var(--text-3); }
.source-item .source-text { color: var(--text-2); }

/* Quick questions */
.quick-questions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.qq-item {
  display: flex; align-items: center; gap: 6px; padding: 7px 12px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px;
  font-size: 12.5px; color: var(--text-2); cursor: pointer; transition: all .15s;
}
.qq-item:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-light); }

/* Chat input */
.chat-input-wrap {
  display: flex; flex-direction: column; gap: 8px; padding-top: 12px;
  border-top: 1px solid var(--border-light);
}
.chat-input-row {
  display: flex; gap: 8px; align-items: center;
}
.chat-input-box {
  flex: 1; position: relative; min-width: 0; display: flex; align-items: center;
}
.chat-input-box .chat-input {
  width: 100%; box-sizing: border-box; flex: none;
  height: 44px; min-height: 44px; max-height: 160px;
}
/* 图片预览（输入框上方独立一条） */
.chat-img-preview {
  position: relative; width: 56px; height: 56px; flex-shrink: 0;
}
.chat-img-thumb {
  width: 56px; height: 56px; border-radius: 8px;
  object-fit: cover; display: block;
  border: 1px solid var(--border); background: var(--surface-hover);
}
.chat-img-remove {
  position: absolute; top: -6px; right: -6px;
  width: 18px; height: 18px; border-radius: 50%;
  background: var(--text-2); color: #fff;
  border: 2px solid var(--surface);
  cursor: pointer; font-size: 12px; line-height: 1; padding: 0;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s;
}
.chat-img-remove:hover { background: var(--danger); }
.img-btn {
  width: 44px; height: 44px; border-radius: var(--radius);
  background: transparent; border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2); cursor: pointer; transition: all .15s; flex-shrink: 0;
}
.img-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-ghost); }
.img-btn svg { width: 20px; height: 20px; }
.chat-input {
  flex: 1; min-height: 44px; max-height: 160px; padding: 10px 14px;
  border: 1px solid var(--border); border-radius: var(--radius);
  font-size: 14px; line-height: 1.5; resize: none;
  transition: border-color .15s, box-shadow .15s;
}
.chat-input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-ghost); }
.send-btn {
  width: 44px; height: 44px; border-radius: var(--radius);
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-hover) 100%);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0; box-shadow: var(--shadow-sm);
}
.send-btn:hover { background: var(--accent-hover); box-shadow: var(--shadow); transform: translateY(-1px); }
.send-btn:active { transform: translateY(0); }
.send-btn:disabled { background: var(--border); cursor: not-allowed; box-shadow: none; }
.send-btn svg { width: 18px; height: 18px; fill: #fff; }
.stop-btn {
  width: 44px; height: 44px; border-radius: var(--radius);
  background: var(--danger, #ef4444);
  display: flex; align-items: center; justify-content: center;
  transition: all .15s; flex-shrink: 0; box-shadow: var(--shadow-sm);
  cursor: pointer; border: none;
}
.stop-btn:hover { background: #dc2626; box-shadow: var(--shadow); transform: translateY(-1px); }
.stop-btn:active { transform: translateY(0); }
.stop-btn svg { width: 18px; height: 18px; fill: #fff; }

/* Typing indicator */
.typing-indicator { display: flex; gap: 4px; padding: 4px 0; }
.typing-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--text-3);
  animation: typingBounce 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: .15s; }
.typing-dot:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

/* Empty state */
.empty-state {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 60px 20px; color: var(--text-3); text-align: center;
}
.empty-state svg { width: 48px; height: 48px; margin-bottom: 16px; opacity: .3; }
.empty-state h3 { font-size: 16px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.empty-state p { font-size: 13px; max-width: 360px; line-height: 1.5; }

/* ==================== Upload ==================== */
.upload-zone {
  border: 2px dashed var(--border); border-radius: var(--radius-lg);
  padding: 48px 24px; text-align: center; cursor: pointer;
  transition: all .2s; background: var(--surface);
}
.upload-zone:hover, .upload-zone.dragover {
  border-color: var(--accent); background: var(--accent-light);
}
.upload-zone svg { width: 40px; height: 40px; color: var(--text-3); margin-bottom: 12px; }
.upload-zone h3 { font-size: 15px; font-weight: 600; color: var(--text-1); margin-bottom: 4px; }
.upload-zone p { font-size: 13px; color: var(--text-3); }
.upload-zone .formats { margin-top: 8px; font-size: 11.5px; color: var(--text-3); }
.upload-progress { margin-top: 16px; }
.progress-bar { height: 4px; background: var(--border); border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; transition: width .3s; }
.progress-text { font-size: 12px; color: var(--text-3); margin-top: 6px; }

/* ==================== Stats ==================== */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 24px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 20px;
}
.stat-card .stat-label { font-size: 12.5px; color: var(--text-3); margin-bottom: 6px; }
.stat-card .stat-value { font-size: 28px; font-weight: 700; color: var(--text-1); letter-spacing: -0.5px; }
.stat-card .stat-sub { font-size: 12px; color: var(--text-3); margin-top: 4px; }

/* ==================== Settings ==================== */
.settings-section { margin-bottom: 24px; }
.settings-section h3 { font-size: 14px; font-weight: 600; color: var(--text-1); margin-bottom: 16px; padding-bottom: 10px; border-bottom: 1px solid var(--border-light); }
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-bottom: 1px solid var(--border-light);
}
.settings-row:last-child { border-bottom: none; }
.settings-row .s-label { font-size: 13.5px; color: var(--text-1); }
.settings-row .s-desc { font-size: 12px; color: var(--text-3); margin-top: 2px; }

/* ==================== Modal ==================== */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 1000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.modal-overlay.open { opacity: 1; pointer-events: auto; }
.modal {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); width: 440px; max-width: 90vw;
  transform: scale(.95); transition: transform .2s;
}
.modal-overlay.open .modal { transform: scale(1); }

/* 上传遮罩 */
.upload-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  opacity: 0; pointer-events: none; transition: opacity .2s;
}
.upload-overlay.open { opacity: 1; pointer-events: auto; }
.upload-overlay-card {
  background: var(--surface); border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg); padding: 32px 40px;
  display: flex; flex-direction: column; align-items: center; gap: 16px;
  min-width: 280px;
}
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.upload-overlay-text { font-size: 14px; color: var(--text-2); text-align: center; }
.modal-header {
  padding: 16px 20px 0; display: flex; align-items: center; justify-content: space-between;
}
.modal-title { font-size: 15px; font-weight: 600; }
.modal-close {
  width: 28px; height: 28px; border-radius: 50%; display: flex;
  align-items: center; justify-content: center; color: var(--text-3);
}
.modal-close:hover { background: var(--surface-hover); color: var(--text-1); }
.modal-body { padding: 16px 20px; }
.modal-footer { padding: 0 20px 16px; display: flex; justify-content: flex-end; gap: 8px; }

/* ==================== Toast ==================== */
.toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: var(--shadow-md); padding: 12px 16px; font-size: 13px;
  display: flex; align-items: center; gap: 8px; min-width: 240px;
  animation: toastIn .3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }
.toast-success { border-left: 3px solid var(--success); }
.toast-error { border-left: 3px solid var(--danger); }
.toast-info { border-left: 3px solid var(--accent); }
.toast-icon { width: 18px; height: 18px; flex-shrink: 0; }

/* ==================== Footer ==================== */
.main-footer {
    padding: 12px 24px; border-top: 1px solid var(--border-light);
    background: var(--surface); font-size: 12px; color: var(--text-3); text-align: center; flex-shrink: 0;
}
.main-footer a { color: var(--text-2); text-decoration: none; }
.main-footer a:hover { color: var(--accent); }
.main-footer .sep { margin: 0 8px; opacity: .4; }

/* ==================== 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(--text-3); }

/* ==================== Responsive ==================== */
@media (max-width: 768px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .form-row { grid-template-columns: 1fr; }
  .chat-msg { max-width: 95%; }
}
