:root {
  --bg: #0d1117;
  --surface: #161b22;
  --surface2: #21262d;
  --border: #30363d;
  --border-focus: #58a6ff;
  --primary: #58a6ff;
  --primary-dark: #1f6feb;
  --green: #3fb950;
  --orange: #d29922;
  --red: #f85149;
  --purple: #bc8cff;
  --text: #e6edf3;
  --text-muted: #8b949e;
  --text-dim: #484f58;
  --user-bubble: #1f6feb22;
  --ai-bubble: #21262d;
  --tool-bg: #0d1117;
  --table-header: #161b22;
  --scrollbar: #30363d;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 4px 16px rgba(0,0,0,0.4);
}

/* ===== Light mode ===== */
html.light {
  --bg: #f6f8fa;
  --surface: #ffffff;
  --surface2: #f0f2f5;
  --border: #d0d7de;
  --border-focus: #0969da;
  --primary: #0969da;
  --primary-dark: #0550ae;
  --green: #1a7f37;
  --orange: #9a6700;
  --red: #cf222e;
  --purple: #8250df;
  --text: #1f2328;
  --text-muted: #57606a;
  --text-dim: #6e7781;
  --user-bubble: #ddf4ff;
  --ai-bubble: #ffffff;
  --tool-bg: #f6f8fa;
  --table-header: #f0f2f5;
  --scrollbar: #d0d7de;
  --shadow: 0 4px 16px rgba(0,0,0,0.08);
}

/* Light-mode overrides for hardcoded dark-specific colors */
html.light .final-answer-box { background: #1a7f3710; }
html.light .final-answer-box code {
  background: #1a7f3718;
  border-color: #1a7f3740;
  color: #1a7f37;
}
html.light .notification.success { background: #d4edda; color: #1a7f37; }
html.light .badge.green { background: #1a7f3715; }
html.light .badge.orange { background: #9a670015; }
html.light .step-done .step-badge { background: #1a7f3715; }
html.light .step-done.reflect-indicator .reflect-badge { background: #1a7f3715; }
html.light .reflect-indicator { border-color: #8250df33; }
html.light input:checked + .code-track { background: #9a670055; }
html.light .skill-learned-badge { background: #1a7f3710; border-color: #1a7f3730; border-left-color: var(--green); }

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

html { transition: background 0.2s, color 0.2s; }

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

/* ---------- Scrollbars ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 3px; }

/* ---------- Layout ---------- */
#app {
  display: grid;
  grid-template-rows: 48px 1fr;
  grid-template-columns: 300px 1fr;
  height: 100vh;
  overflow: hidden;
}

/* ---------- Header ---------- */
#header {
  grid-column: 1 / -1;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 100;
}

#header .logo {
  display: flex;
  align-items: center;
  text-decoration: none;
  flex-shrink: 0;
}

/* Header logo image container */
.header-logo {
  display: flex;
  align-items: center;
  line-height: 0;
}

.header-logo img {
  height: 30px;
  width: auto;
  display: block;
}

html.light .header-logo {
  background: transparent;
  padding: 0;
}

#header .logo svg { flex-shrink: 0; }

#header-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Sidebar ---------- */
#sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  padding: 10px 4px;
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 11px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  transition: color 0.15s, background 0.15s;
  border-bottom: 2px solid transparent;
}

.sidebar-tab:hover { color: var(--text); background: var(--surface2); }
.sidebar-tab.active { color: var(--primary); border-bottom-color: var(--primary); }

.sidebar-panel {
  display: none;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}
.sidebar-panel.active { display: flex; }

.sidebar-panel-header {
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.sidebar-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

/* ---------- Tables panel ---------- */
.table-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
  position: relative;
}

.table-item:hover { background: var(--surface2); }
.table-item:hover .table-item-actions { opacity: 1; }

.table-item-icon { color: var(--primary); font-size: 16px; flex-shrink: 0; }

.table-item-info { flex: 1; min-width: 0; }
.table-item-name {
  font-weight: 500;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.table-item-meta { font-size: 11px; color: var(--text-muted); }
.table-item-badge {
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 10px;
  background: var(--primary-dark)33;
  color: var(--primary);
  flex-shrink: 0;
}
.table-item-badge.purple { background: #5a3f8033; color: var(--purple); }

.table-item-actions {
  opacity: 0;
  display: flex;
  gap: 4px;
  transition: opacity 0.15s;
}

.upload-area {
  margin: 8px;
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 12px;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.upload-area:hover, .upload-area.drag-over {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-dark)11;
}
.upload-area svg { display: block; margin: 0 auto 6px; }

/* ---------- Skills panel ---------- */
.skill-section-title {
  padding: 8px 4px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.skill-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 8px;
  align-items: flex-start;
  transition: background 0.1s;
  position: relative;
}
.skill-item:hover { background: var(--surface2); }
.skill-item:hover .skill-actions { opacity: 1; }
.skill-item:hover .skill-info-btn { opacity: 1; }

/* Built-in skills are clickable */
.skill-item-clickable { cursor: pointer; }
.skill-item-clickable:hover .skill-name { color: var(--primary); }

/* Info button on built-in skills — hidden until hover */
.skill-info-btn {
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
  font-style: normal;
  font-size: 13px;
  color: var(--primary);
  background: none;
  border: 1px solid var(--border);
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
}

.skill-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  margin-top: 4px;
  flex-shrink: 0;
}
.skill-dot.builtin { background: var(--green); }
.skill-dot.custom { background: var(--purple); }

.skill-info { flex: 1; min-width: 0; }
.skill-name { font-weight: 500; font-size: 12px; font-family: 'SF Mono', monospace; }
.skill-desc { font-size: 11px; color: var(--text-muted); margin-top: 1px; }
.skill-category { font-size: 10px; color: var(--text-dim); }

.skill-actions {
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  gap: 4px;
}

/* ---------- Memory panel ---------- */
.memory-category {
  margin-bottom: 4px;
}
.memory-category-header {
  padding: 8px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.memory-category-header .count {
  background: var(--surface2);
  border-radius: 10px;
  padding: 0 5px;
  font-size: 10px;
  color: var(--text-dim);
}

.memory-item {
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  display: flex;
  gap: 8px;
  align-items: flex-start;
  transition: background 0.1s;
  position: relative;
}
.memory-item:hover { background: var(--surface2); }
.memory-item:hover .mem-actions { opacity: 1; }

.memory-key {
  font-size: 12px;
  font-weight: 500;
  color: var(--primary);
  font-family: 'SF Mono', monospace;
  flex-shrink: 0;
  min-width: 80px;
}
.memory-value { font-size: 12px; color: var(--text); flex: 1; }
.memory-updated { font-size: 10px; color: var(--text-dim); }

.mem-actions {
  opacity: 0;
  transition: opacity 0.15s;
  display: flex;
  gap: 4px;
}

.memory-empty {
  padding: 16px 12px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

/* ---------- Main chat area ---------- */
#main {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
}

#chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Empty state */
#chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  gap: 12px;
  text-align: center;
}
#chat-empty h2 { font-size: 22px; color: var(--text); font-weight: 600; }
#chat-empty p { font-size: 14px; max-width: 360px; }

/* Brand logo in empty state */
.brand-logo-wrap {
  line-height: 0;
  margin-bottom: 6px;
}

.brand-logo {
  height: 90px;
  width: auto;
  display: block;
}
.suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-top: 8px;
}
.chip {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  transition: border-color 0.15s, color 0.15s;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }

/* ---------- Message bubbles ---------- */
.message {
  display: flex;
  gap: 10px;
  max-width: 900px;
  width: 100%;
  align-self: flex-start;
}
.message.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
  font-weight: 600;
}
.message.user .msg-avatar { background: var(--primary-dark); color: var(--primary); }
.message.assistant .msg-avatar { background: var(--surface2); color: var(--green); font-size: 16px; }

.msg-body { flex: 1; min-width: 0; }

.msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.message.user .msg-bubble {
  background: var(--user-bubble);
  border: 1px solid var(--primary-dark);
  color: var(--text);
}
.message.assistant .msg-bubble {
  background: var(--ai-bubble);
  border: 1px solid var(--border);
}

/* Markdown-style content in bubbles */
.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  background: var(--tool-bg);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--orange);
}
.msg-bubble pre {
  background: var(--tool-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px;
  overflow-x: auto;
  margin: 6px 0;
}
.msg-bubble pre code { background: none; padding: 0; color: var(--text); }
.msg-bubble ul, .msg-bubble ol { padding-left: 20px; margin-bottom: 8px; }
.msg-bubble li { margin-bottom: 2px; }
.msg-bubble strong { color: var(--text); font-weight: 600; }
.msg-bubble h3, .msg-bubble h4 { margin: 8px 0 4px; color: var(--text); }

/* Tool call blocks */
.tool-block {
  margin: 6px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  font-size: 12px;
}
.tool-block-header {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  background: var(--tool-bg);
  color: var(--text-muted);
  cursor: pointer;
  user-select: none;
}
.tool-block-header:hover { color: var(--text); }
.tool-name { color: var(--orange); font-family: monospace; font-weight: 600; }
.tool-status { margin-left: auto; }
.tool-status.ok { color: var(--green); }
.tool-status.err { color: var(--red); }

.tool-block-body {
  padding: 8px 10px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  font-family: 'SF Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 200px;
  overflow-y: auto;
}

/* Step progress */
.step-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin: 4px 0;
  font-size: 12px;
  border: 1px solid var(--border);
}
.step-badge {
  background: var(--primary-dark);
  color: var(--primary);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
}
.step-done .step-badge { background: #1a4d2322; color: var(--green); }
.step-desc { color: var(--text-muted); flex: 1; }

.reflect-indicator { border-color: #bc8cff33; }
.reflect-badge { background: #bc8cff22; color: var(--purple); border: 1px solid #bc8cff44; }
.step-done.reflect-indicator .reflect-badge { background: #1a4d2322; color: var(--green); }

/* Inline table result */
.table-result {
  margin: 8px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.table-result-header {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  background: var(--table-header);
  border-bottom: 1px solid var(--border);
  gap: 8px;
  font-size: 12px;
}
.table-result-name { font-weight: 600; color: var(--text); }
.table-result-meta { color: var(--text-muted); }
.table-result-actions { margin-left: auto; display: flex; gap: 6px; }
.table-scroll { overflow-x: auto; max-height: 300px; overflow-y: auto; }

table.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
table.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface2);
  padding: 6px 10px;
  text-align: left;
  font-weight: 600;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
}
table.data-table tbody tr:hover { background: var(--surface2); }
table.data-table tbody td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border)44;
  color: var(--text);
  max-width: 200px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'SF Mono', monospace;
  font-size: 11px;
}

.table-more-rows {
  padding: 6px 10px;
  font-size: 11px;
  color: var(--text-muted);
  text-align: center;
  background: var(--table-header);
  border-top: 1px solid var(--border);
}

/* Typing cursor */
.typing-cursor::after {
  content: '▋';
  animation: blink 0.75s step-end infinite;
  color: var(--primary);
}
@keyframes blink { 50% { opacity: 0; } }

/* Thinking indicator */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  color: var(--text-muted);
  font-size: 13px;
}
.thinking-dots span {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: bounce 1.2s ease infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); background: var(--primary); }
}

/* ---------- Input area ---------- */
#input-area {
  padding: 12px 20px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  flex-shrink: 0;
}

.input-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.plan-mode-toggle {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
}
.plan-mode-toggle input { display: none; }
.toggle-track {
  width: 32px; height: 18px;
  background: var(--border);
  border-radius: 9px;
  position: relative;
  transition: background 0.2s;
}
.toggle-track::after {
  content: '';
  position: absolute;
  left: 2px; top: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: left 0.2s, background 0.2s;
}
input:checked + .toggle-track { background: var(--primary-dark); }
input:checked + .toggle-track::after { left: 16px; background: var(--primary); }

/* Code Tool toggle — orange accent */
input:checked + .code-track { background: #5a3a0066; }
input:checked + .code-track::after { background: var(--orange); }

/* Separator between toolbar groups */
.toolbar-sep {
  width: 1px;
  height: 16px;
  background: var(--border);
  margin: 0 4px;
}

/* Code tool block — orange accent */
.tool-block-code { border-color: var(--orange)55; }
.tool-block-code .tool-block-header { border-left: 3px solid var(--orange)88; }
.tool-block-code .tool-name { color: var(--orange); }

/* Code block inside tool body */
.tool-block-label {
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--text-dim);
  margin-bottom: 6px;
}

.tool-code-block {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  overflow-x: auto;
  white-space: pre;
  word-break: normal;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.55;
  color: var(--text);
  margin: 0 0 6px;
}

.tool-code-block code {
  background: none;
  border: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

.tool-code-result-name {
  font-size: 11px;
  color: var(--text-dim);
  display: block;
  margin-top: 2px;
}
.tool-code-result-name code {
  color: var(--orange);
  background: var(--tool-bg);
  border: 1px solid var(--border);
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11px;
}

.tool-params-pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

#message-input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  color: var(--text);
  font-size: 14px;
  resize: none;
  min-height: 44px;
  max-height: 160px;
  line-height: 1.5;
  transition: border-color 0.15s;
  font-family: inherit;
  overflow-y: auto;
}
#message-input:focus { outline: none; border-color: var(--border-focus); }
#message-input::placeholder { color: var(--text-dim); }

#send-btn {
  width: 44px; height: 44px;
  border-radius: var(--radius);
  background: var(--primary-dark);
  border: none;
  color: var(--primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
#send-btn:hover:not(:disabled) { background: var(--primary); color: var(--bg); }
#send-btn:active { transform: scale(0.95); }
#send-btn:disabled { opacity: 0.4; cursor: not-allowed; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 500;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.btn:hover { background: var(--surface); color: var(--text); border-color: var(--text-dim); }
.btn.primary { background: var(--primary); color: var(--bg); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-dark); color: var(--primary); border-color: var(--primary-dark); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red)22; border-color: var(--red); }
.btn.icon-only { padding: 4px 6px; min-width: 28px; justify-content: center; }
.btn.sm { padding: 3px 8px; font-size: 11px; }

/* ---------- Modals ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
  animation: fadeIn 0.15s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  animation: slideUp 0.15s ease;
  position: relative;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }

.modal-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
.modal-title { font-weight: 700; font-size: 16px; flex: 1; }
.modal-subtitle { font-size: 12px; color: var(--text-muted); }
.modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 18px; line-height: 1;
  padding: 2px 6px;
  border-radius: 4px;
}
.modal-close:hover { color: var(--text); background: var(--surface2); }

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

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

/* Plan editor */
.plan-modal { width: 600px; }

.plan-step-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 8px;
  background: var(--surface2);
  transition: border-color 0.15s;
}
.plan-step-item:hover { border-color: var(--border-focus); }
.plan-step-item:focus-within { border-color: var(--border-focus); }

.plan-step-num {
  background: var(--primary-dark);
  color: var(--primary);
  border-radius: 50%;
  width: 22px; height: 22px;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.plan-step-text {
  flex: 1;
  background: none;
  border: none;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  resize: none;
  line-height: 1.5;
  min-height: 20px;
}
.plan-step-text:focus { outline: none; }
.plan-step-controls { display: flex; gap: 3px; flex-shrink: 0; }

/* Skill / Memory forms */
.form-group { margin-bottom: 14px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.form-input, .form-textarea, .form-select {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  color: var(--text);
  font-size: 13px;
  font-family: inherit;
  transition: border-color 0.15s;
}
.form-input:focus, .form-textarea:focus, .form-select:focus {
  outline: none;
  border-color: var(--border-focus);
}
.form-textarea { resize: vertical; min-height: 80px; }

/* Table view modal */
.table-modal { width: 90vw; max-width: 1100px; }
.table-modal .modal-body { padding: 0; }

/* ---------- Notifications ---------- */
#notifications {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
}
.notification {
  padding: 10px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  pointer-events: all;
  animation: notifIn 0.2s ease;
  max-width: 300px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: var(--shadow);
}
@keyframes notifIn { from { transform: translateX(40px); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
.notification.success { background: #1a4d23; border: 1px solid var(--green); color: var(--green); }
.notification.error { background: #4d1a1a; border: 1px solid var(--red); color: var(--red); }
.notification.info { background: var(--primary-dark)33; border: 1px solid var(--primary); color: var(--primary); }

/* ---------- Misc ---------- */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); }
.text-primary { color: var(--primary); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }

.divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
}

.badge {
  display: inline-flex;
  align-items: center;
  padding: 1px 6px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 600;
  text-transform: uppercase;
}
.badge.green { background: #1a4d2333; color: var(--green); }
.badge.blue { background: var(--primary-dark)33; color: var(--primary); }
.badge.purple { background: #5a3f8033; color: var(--purple); }
.badge.orange { background: #5a3a0033; color: var(--orange); }

.forget-bar {
  display: flex;
  gap: 8px;
  padding: 8px;
  border-top: 1px solid var(--border);
  margin-top: 8px;
  flex-shrink: 0;
}
.forget-bar input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  color: var(--text);
  font-size: 12px;
  font-family: inherit;
}
.forget-bar input:focus { outline: none; border-color: var(--border-focus); }

/* =========================================================================
   Demo / one-click experience styles
   ========================================================================= */

.demo-modal { width: 780px; }

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

.demo-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  background: var(--surface2);
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.demo-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 1px var(--primary)33;
}

.demo-card-header { display: flex; align-items: center; gap: 10px; }
.demo-card-icon { font-size: 26px; line-height: 1; }
.demo-card-title { font-weight: 700; font-size: 14px; }
.demo-card-steps-count { font-size: 11px; color: var(--text-dim); margin-top: 1px; }
.demo-card-desc { font-size: 12px; color: var(--text-muted); line-height: 1.6; flex: 1; }

.demo-card-files { display: flex; gap: 4px; flex-wrap: wrap; }

.demo-card-steps-list {
  list-style: none;
  padding: 0;
  margin: 0;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
.demo-card-steps-list li {
  font-size: 11px;
  color: var(--text-muted);
  padding: 2px 0;
  display: flex;
  gap: 6px;
  align-items: baseline;
}
.demo-card-steps-list li::before {
  content: "›";
  color: var(--primary);
  flex-shrink: 0;
}
.demo-card-steps-list .more-steps { color: var(--text-dim); font-style: italic; }

/* Demo control bar — shown above input while demo runs */
#demo-control {
  background: var(--surface);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 20px;
  flex-shrink: 0;
}
.demo-control-inner {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  color: var(--text-muted);
}
.demo-progress-dots span {
  display: inline-block;
  width: 5px; height: 5px;
  border-radius: 50%;
  background: var(--primary);
  margin-right: 3px;
  animation: bounce 1.2s ease infinite;
}
.demo-progress-dots span:nth-child(2) { animation-delay: 0.2s; }
.demo-progress-dots span:nth-child(3) { animation-delay: 0.4s; }

.demo-control-title { color: var(--text); font-weight: 600; }
.demo-control-step { color: var(--primary); }
.demo-control-spacer { flex: 1; }

/* Chat: system message (info line between messages) */
.system-message {
  display: flex;
  align-items: center;
  gap: 8px;
  align-self: center;
  max-width: 500px;
  color: var(--text-dim);
  font-size: 11px;
  padding: 4px 12px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: 20px;
}

/* Chat: step divider between demo queries */
.demo-step-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.3px;
}
.demo-step-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--border), transparent);
}
.demo-step-label {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2px 10px;
  white-space: nowrap;
  color: var(--primary);
}

/* =========================================================================
   Markdown rendered by marked.js inside .msg-bubble
   ========================================================================= */

/* Reset margins on first/last children */
.msg-bubble > *:first-child { margin-top: 0; }
.msg-bubble > *:last-child  { margin-bottom: 0; }

/* Paragraphs */
.msg-bubble p { margin: 0 0 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }

/* Headings */
.msg-bubble h1, .msg-bubble h2 {
  font-size: 16px; font-weight: 700;
  margin: 14px 0 6px; color: var(--text);
  border-bottom: 1px solid var(--border); padding-bottom: 4px;
}
.msg-bubble h3 { font-size: 14px; font-weight: 700; margin: 10px 0 4px; color: var(--text); }
.msg-bubble h4 { font-size: 13px; font-weight: 600; margin: 8px 0 3px; color: var(--text-muted); }

/* Lists — properly indented and spaced */
.msg-bubble ul, .msg-bubble ol {
  padding-left: 22px;
  margin: 4px 0 8px;
}
.msg-bubble li { margin-bottom: 3px; line-height: 1.55; }
.msg-bubble li > p { margin: 0; }
.msg-bubble ul ul, .msg-bubble ol ol,
.msg-bubble ul ol, .msg-bubble ol ul {
  margin: 2px 0;
}

/* Blockquote */
.msg-bubble blockquote {
  border-left: 3px solid var(--primary);
  margin: 6px 0;
  padding: 6px 14px;
  color: var(--text-muted);
  background: var(--surface2);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  font-style: italic;
}
.msg-bubble blockquote p { margin: 0; }

/* Horizontal rule */
.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* Inline code */
.msg-bubble code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  background: var(--tool-bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
  color: var(--orange);
}

/* Fenced code blocks */
.msg-bubble pre {
  background: var(--tool-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  overflow-x: auto;
  margin: 8px 0;
  line-height: 1.5;
}
.msg-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text);
  font-size: 12px;
}

/* Markdown tables (from LLM text output, not skill result tables) */
.msg-bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 8px 0;
  font-size: 12px;
  display: block;
  overflow-x: auto;
}
.msg-bubble table thead tr { background: var(--surface2); }
.msg-bubble table th {
  padding: 6px 12px;
  border: 1px solid var(--border);
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  white-space: nowrap;
}
.msg-bubble table td {
  padding: 5px 12px;
  border: 1px solid var(--border)66;
  color: var(--text);
  font-family: 'SF Mono', monospace;
}
.msg-bubble table tbody tr:nth-child(even) { background: var(--surface2)44; }
.msg-bubble table tbody tr:hover { background: var(--surface2); }

/* Strikethrough */
.msg-bubble del { color: var(--text-muted); }

/* Strong / em */
.msg-bubble strong { font-weight: 600; color: var(--text); }
.msg-bubble em { color: var(--text-muted); font-style: italic; }

/* =========================================================================
   Final answer box (✅ 最终结论 / 操作结果)
   ========================================================================= */

.final-answer-box {
  margin-top: 14px;
  border: 1px solid var(--green);
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
  padding: 12px 16px;
  background: #1a4d2322;
}

.final-answer-box h1,
.final-answer-box h2,
.final-answer-box h3 {
  color: var(--green);
  border-bottom-color: #3fb95044;
  font-size: 14px;
  margin-top: 0;
  margin-bottom: 8px;
  padding-bottom: 6px;
}

.final-answer-box ul,
.final-answer-box ol {
  margin-top: 4px;
  padding-left: 18px;
}

.final-answer-box li { margin-bottom: 5px; line-height: 1.6; }

.final-answer-box strong { color: var(--green); }

.final-answer-box code {
  background: #1a4d2344;
  border-color: #3fb95044;
  color: #57d669;
}

/* =========================================================================
   Result download panel — shown below message when tables were created
   ========================================================================= */

.result-download-panel {
  margin-top: 10px;
  border: 1px solid var(--primary)55;
  border-radius: var(--radius);
  background: var(--surface2);
  overflow: hidden;
}

.rdp-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--primary-dark)22;
}

.rdp-title {
  font-weight: 600;
  font-size: 12px;
  color: var(--primary);
}

.rdp-hint {
  font-size: 11px;
  color: var(--text-dim);
  margin-left: auto;
}

.rdp-list { display: flex; flex-direction: column; }

.rdp-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--surface);
}

.rdp-item:not(:last-child) { border-bottom: 1px solid var(--border)55; }
.rdp-item:hover { background: var(--surface2); }

.rdp-table-name {
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  flex-shrink: 0;
}

.rdp-table-meta {
  font-size: 11px;
  color: var(--text-muted);
  flex: 1;
}

.rdp-actions { display: flex; gap: 6px; flex-shrink: 0; }

/* =========================================================================
   Built-in skill detail modal
   ========================================================================= */

.skill-detail-desc {
  font-size: 13px;
  color: var(--text-muted);
  margin-bottom: 16px;
  line-height: 1.6;
}

.skill-detail-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.skill-params-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.skill-params-table th {
  padding: 6px 10px;
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.3px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  background: var(--surface2);
  white-space: nowrap;
}

.skill-params-table td {
  padding: 7px 10px;
  border-bottom: 1px solid var(--border)55;
  vertical-align: top;
  color: var(--text);
  line-height: 1.5;
}

.skill-params-table tr:last-child td { border-bottom: none; }
.skill-params-table tr:hover td { background: var(--surface2)66; }

.skill-params-table code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  color: var(--orange);
  background: var(--tool-bg);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 3px;
}

/* =========================================================================
   Memory overview / summary modal
   ========================================================================= */

.memory-summary-modal { width: 600px; }

.memory-summary-loading {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 0;
  color: var(--text-muted);
  font-size: 13px;
}

.memory-summary-content {
  min-height: 60px;
  line-height: 1.7;
}

/* Override msg-bubble margins for standalone use */
.memory-summary-content > *:first-child { margin-top: 0; }
.memory-summary-content > *:last-child  { margin-bottom: 0; }

/* =========================================================================
   Custom skill modal — mode tabs (Prompt / Python Code)
   ========================================================================= */

.skill-mode-toggle-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.skill-mode-tabs {
  display: flex;
  gap: 4px;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.skill-mode-tab {
  padding: 4px 14px;
  font-size: 12px;
  font-weight: 500;
  border: none;
  border-radius: calc(var(--radius-sm) - 1px);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.skill-mode-tab:hover { color: var(--text); }

.skill-mode-tab.active {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

/* Hint text under textarea labels */
.form-hint {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 6px;
  line-height: 1.5;
}

.form-hint code {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 11px;
  color: var(--orange);
  background: var(--tool-bg);
  border: 1px solid var(--border);
  padding: 0 4px;
  border-radius: 3px;
}

/* Code textarea in skill modal */
.form-code-input {
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  line-height: 1.6;
  tab-size: 4;
}

/* =========================================================================
   Multi-Agent pool UI
   ========================================================================= */

.agent-pool {
  margin: 8px 0;
  padding: 10px;
  background: var(--surface2);
  border: 1px solid #bc8cff33;
  border-radius: var(--radius);
}

.agent-pool-header {
  font-size: 12px;
  font-weight: 600;
  color: var(--purple);
  margin-bottom: 10px;
}

.agent-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(175px, 1fr));
  gap: 8px;
}

.agent-card {
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
  transition: border-color 0.2s;
}

.agent-card.running { border-color: var(--primary)55; }
.agent-card.done    { border-color: var(--green)55; }

.agent-card-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}

.agent-status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--border);
  flex-shrink: 0;
  transition: background 0.2s;
}

.agent-card.running .agent-status-dot {
  background: var(--primary);
  animation: pulse-dot 1.5s ease-in-out infinite;
}

.agent-card.done .agent-status-dot { background: var(--green); }

@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.3; }
}

.agent-card-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-height: 18px;
  margin-bottom: 5px;
}

.agent-tool-badge {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: 'SF Mono', 'Fira Code', monospace;
}

.agent-card-text {
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.45;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  min-height: 16px;
}

/* Aggregation header */
.aggregate-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: var(--surface2);
  border: 1px solid #bc8cff33;
  border-radius: var(--radius-sm);
  margin: 6px 0;
  font-size: 12px;
  color: var(--purple);
}

.aggregate-spinner {
  width: 12px;
  height: 12px;
  border: 2px solid #bc8cff33;
  border-top-color: var(--purple);
  border-radius: 50%;
  animation: spin-agg 0.8s linear infinite;
  flex-shrink: 0;
}

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

/* Uncertainty markers */
.uncertainty-badge {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 1px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  vertical-align: middle;
  margin: 0 3px;
  white-space: nowrap;
}

.uncertainty-badge.consensus {
  background: #3fb95022;
  color: var(--green);
  border: 1px solid #3fb95055;
}

.uncertainty-badge.uncertain {
  background: #d2992222;
  color: var(--orange);
  border: 1px solid #d2992255;
}

/* Intent Clarification Card */
.clarify-bubble {
  max-width: 520px;
  margin: 4px 0 8px 0;
  padding: 14px 16px;
  background: var(--surface2);
  border: 1px solid #58a6ff44;
  border-left: 3px solid var(--primary);
  border-radius: var(--radius);
}

.clarify-question {
  font-size: 13px;
  color: var(--text);
  font-weight: 500;
  margin-bottom: 10px;
}

.clarify-options {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 10px;
}

.clarify-option {
  padding: 5px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text);
  font-size: 12px;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}

.clarify-option:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: #58a6ff11;
}

.clarify-option.selected {
  background: #1f6feb33;
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.clarify-custom-row {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}

.clarify-input {
  flex: 1;
  padding: 5px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 12px;
  outline: none;
}

.clarify-input:focus {
  border-color: var(--border-focus);
}

.clarify-submit-btn {
  padding: 5px 14px;
  background: var(--primary-dark);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
}

.clarify-submit-btn:hover {
  background: var(--primary);
}

.clarify-bubble.answered {
  opacity: 0.65;
  pointer-events: none;
  border-left-color: var(--border);
}

.clarify-bubble.answered .clarify-option.selected {
  opacity: 1;
}


/* Compact Notice */
.compact-notice {
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  border-radius: var(--radius-sm);
  background: var(--primary-dark)11;
  padding: 10px 14px;
  font-size: 12px;
  color: var(--text-muted);
}
.compact-notice-header {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--primary);
  font-weight: 600;
  margin-bottom: 0;
}
.compact-notice-summary {
  margin-top: 8px;
  color: var(--text-muted);
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  border-top: 1px solid var(--border);
  padding-top: 8px;
}
html.light .compact-notice { background: var(--primary-dark)08; }

/* Lab credit */
.lab-credit {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 10px;
  color: var(--text-dim);
  text-align: center;
  border-top: 1px solid var(--border);
  line-height: 1.4;
}

/* Lang toggle button */
.lang-btn {
  font-size: 12px;
  font-weight: 600;
  min-width: 28px;
  letter-spacing: 0.02em;
}

/* Skill Learned Badge */
.skill-learned-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 8px;
  padding: 8px 12px;
  background: #3fb95011;
  border: 1px solid #3fb95033;
  border-left: 3px solid var(--green);
  border-radius: var(--radius-sm);
  font-size: 12px;
  color: var(--text-muted);
}

.skill-learned-icon {
  flex-shrink: 0;
  font-size: 14px;
}

.skill-learned-text {
  flex: 1;
  line-height: 1.4;
}

.skill-learned-text strong {
  color: var(--text);
}

.skill-learned-mode {
  flex-shrink: 0;
  padding: 2px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 10px;
  color: var(--text-dim);
  white-space: nowrap;
}

/* ===== Auth page ===== */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.auth-container {
  width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 32px;
  box-shadow: var(--shadow);
}

.auth-logo {
  text-align: center;
  margin-bottom: 24px;
}

.auth-logo img {
  width: 56px;
  height: 56px;
  object-fit: contain;
  margin-bottom: 8px;
}

.auth-logo h1 {
  font-size: 22px;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 4px;
}

.auth-tagline {
  font-size: 12px;
  color: var(--text-muted);
}

.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 20px;
}

.auth-tab {
  flex: 1;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  padding: 8px 0;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 500;
  transition: color 0.15s, border-color 0.15s;
}

.auth-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.auth-form .form-group {
  margin-bottom: 14px;
}

.auth-submit-btn {
  width: 100%;
  justify-content: center;
  padding: 9px 0;
  margin-top: 4px;
  font-size: 14px;
}

.auth-error {
  color: var(--red);
  font-size: 12px;
  margin-bottom: 10px;
  padding: 6px 10px;
  background: #f851491a;
  border-radius: var(--radius-sm);
}

/* ===== Settings panel ===== */
.settings-section {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}

.settings-section:last-child {
  border-bottom: none;
}

.settings-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.settings-user-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-username {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

.own-key-badge {
  font-size: 10px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 10px;
  background: #3fb95020;
  color: var(--green);
  border: 1px solid #3fb95040;
}

.settings-token-text {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
}

/* ===== Token bar ===== */
.token-bar-wrap {
  width: 100%;
}

.token-bar {
  height: 6px;
  background: var(--surface2);
  border-radius: 3px;
  overflow: hidden;
}

.token-bar-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

/* ===== Token quota footer ===== */
.token-quota-footer {
  padding: 6px 12px;
  font-size: 11px;
  color: var(--text-muted);
  border-top: 1px solid var(--border);
  background: var(--surface);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
