/* ═══════════════════════════════════════════════════════════
   Components — 按钮、徽章、面板、表单、模态框、通知
   ═══════════════════════════════════════════════════════════ */

input, button, select, textarea { font: inherit; color: inherit; }

.section-kicker {
  font-size: 0.65rem; font-weight: 700; text-transform: uppercase;
  letter-spacing: 0.1em; color: var(--fg-tertiary);
}

.btn, button, .button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 38px; padding: 0 16px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  font-size: 0.85rem; font-weight: 600; line-height: 1;
  background: var(--surface); color: var(--fg);
  cursor: pointer; white-space: nowrap;
  transition: all var(--transition);
}

.btn:hover, button:hover, .button:hover {
  background: var(--surface-hover);
  border-color: rgba(255,255,255,0.1);
}

.button.primary, button.primary {
  background: var(--gradient-1); color: #fff; border: none;
  box-shadow: 0 0 20px var(--accent-glow);
}

.button.primary:hover {
  box-shadow: 0 0 30px var(--accent-glow);
  transform: translateY(-1px);
}

.button.secondary {
  background: var(--surface); color: var(--fg-secondary);
  border-color: var(--border);
}

.button.danger {
  background: transparent; color: var(--danger);
  border-color: rgba(248,113,113,0.2);
}

.button.danger:hover { background: var(--danger-dim); border-color: rgba(248,113,113,0.4); }

.button-sm { height: 32px; padding: 0 12px; font-size: 0.8rem; }

.button-xs { height: 28px; padding: 0 8px; font-size: 0.75rem; }

input, select, textarea {
  height: 38px; padding: 0 14px;
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--fg);
  outline: none; transition: all var(--transition);
}

textarea { height: auto; padding: 10px 14px; min-height: 80px; resize: vertical; }

.badge {
  display: inline-flex; align-items: center; gap: 5px;
  height: 24px; padding: 0 10px;
  border-radius: 999px; font-size: 0.72rem; font-weight: 600;
  white-space: nowrap; letter-spacing: 0.01em;
}

.badge::before { content: ''; width: 6px; height: 6px; border-radius: 999px; flex-shrink: 0; }

.badge.success { background: var(--success-dim); color: var(--success); }

.badge.success::before { background: var(--success); }

.badge.danger { background: var(--danger-dim); color: var(--danger); }

.badge.danger::before { background: var(--danger); }

.badge.warning { background: var(--warning-dim); color: var(--warning); }

.badge.warning::before { background: var(--warning); }

.badge.muted { background: var(--surface-hover); color: var(--fg-tertiary); }

.badge.muted::before { background: var(--fg-tertiary); }

.panel, .metric-card, .summary-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  transition: all var(--transition);
}

.panel:hover { border-color: rgba(255,255,255,0.08); }

.button i[data-lucide] { width: 16px; height: 16px; }

html.light .light-icon, html:not(.light) .dark-icon { display: none; }

.compact-summary .summary-item {
  border: 1px solid var(--border); background: var(--surface); box-shadow: none;
}

.panel { margin-bottom: 24px; overflow: hidden; }

.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; min-height: 54px; padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.01);
}

.panel-header.compact { min-height: 46px; }

.panel-heading { display: grid; gap: 3px; }

.empty-card { text-align: center; padding: 48px; color: var(--fg-tertiary); }

.toolbar-input { width: 280px; }

.stack-segment.cached { background: var(--accent); }

.stack-segment.uncached { background: #f59e0b; }

.stack-segment.output { background: var(--success); }

.vertical-chart { display: flex; align-items: end; justify-content: center; gap: 16px; padding: 24px 18px 16px; height: 200px; }

.vbar-item { display: grid; gap: 8px; justify-items: center; }

.vbar-track { width: 36px; height: 110px; background: var(--surface-hover); border-radius: 6px 6px 0 0; display: flex; align-items: end; overflow: hidden; }

.vbar-track span { display: block; width: 100%; background: var(--accent); border-radius: 6px 6px 0 0; transition: height 0.6s ease; }

.vbar-item strong { font-size: 0.72rem; font-weight: 600; }

.vbar-item small { font-size: 0.65rem; color: var(--fg-tertiary); }

.rank-chart { display: grid; gap: 6px; padding: 18px; }

.rank-row { display: grid; grid-template-columns: 150px 1fr 70px; gap: 14px; align-items: center; font-size: 0.8rem; }

.rank-label { color: var(--fg-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.rank-track { height: 16px; background: var(--surface-hover); border-radius: 4px; overflow: hidden; }

.rank-track span { display: block; height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.6s ease; }

.page-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 32px; height: 32px; padding: 0 8px;
  border: 1px solid var(--border); border-radius: 6px;
  background: var(--surface); color: var(--fg);
  font-size: 0.8rem; font-weight: 500; cursor: pointer;
  text-decoration: none; transition: all 0.15s ease;
}

.page-btn:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-glow); }

.page-btn.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.page-ellipsis { padding: 0 4px; color: var(--fg-tertiary); }

.field { display: grid; gap: 6px; }

.field span { font-size: 0.8rem; font-weight: 600; color: var(--fg); }

.field input, .field select, .field textarea { width: 100%; }

.alert, .notice {
  border-radius: var(--radius); margin-bottom: 20px;
}

.alert {
  padding: 14px 18px; border: 1px solid rgba(251,191,36,0.2);
  background: rgba(251,191,36,0.05); color: var(--warning);
  font-weight: 600; font-size: 0.82rem;
}

.notice {
  display: grid; grid-template-columns: 1fr auto; gap: 20px;
  align-items: center; padding: 18px 22px;
  border: 1px solid rgba(167,139,250,0.2);
  background: var(--accent-glow);
  border-radius: var(--radius-lg);
}

.notice-title { font-weight: 700; font-size: 0.9rem; }

.notice-copy { font-size: 0.78rem; color: var(--fg-secondary); margin-top: 3px; }

.secret-row { display: grid; grid-template-columns: 1fr auto; gap: 10px; }

.secret-row input { width: 100%; font-family: var(--font-mono); font-size: 0.82rem; }

.endpoint-list, .settings-list, .check-list { display: grid; }

.endpoint-list > div, .settings-list > div, .check-list > div {
  display: grid; gap: 6px; padding: 14px 20px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}

.endpoint-list > div:last-child, .settings-list > div:last-child, .check-list > div:last-child { border-bottom: 0; }

.endpoint-list span, .settings-list span, .check-list small { font-size: 0.7rem; font-weight: 700; color: var(--fg-tertiary); text-transform: uppercase; letter-spacing: 0.05em; }

.check-list > div { grid-template-columns: auto 1fr 1fr; align-items: center; gap: 14px; }

.api-nav-toggle {
  display: none;
  width: 100%; padding: 10px 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--fg-secondary);
  font-size: 0.82rem; font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
}

.api-nav-toggle:hover { background: var(--surface-hover); color: var(--fg); }

.api-doc-layout {
  display: grid; grid-template-columns: 220px 1fr; gap: 24px; align-items: start;
}

.api-doc-nav {
  position: sticky; top: 24px;
  display: grid; gap: 2px; padding: 12px;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface);
}

.api-doc-nav a {
  display: block; padding: 8px 12px; border-radius: var(--radius-sm);
  font-size: 0.84rem; font-weight: 500; color: var(--fg-secondary);
  transition: all var(--transition);
}

.api-doc-nav a:hover { background: var(--surface-hover); color: var(--fg); }

.api-section { scroll-margin-top: 32px; margin-bottom: 20px; }

.api-section-body { padding: 20px; display: grid; gap: 16px; }

.doc-lead { font-size: 0.92rem; color: var(--fg-secondary); max-width: 800px; line-height: 1.75; }

.doc-note { font-size: 0.8rem; color: var(--fg-tertiary); }

.doc-note a { color: var(--accent); font-weight: 600; }

.doc-note a:hover { color: var(--accent-strong); }

.api-meta-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(170px,1fr)); gap: 12px;
}

.api-meta-grid > div {
  padding: 14px; background: rgba(255,255,255,0.02);
  border: 1px solid var(--border); border-radius: var(--radius-sm);
  display: grid; gap: 5px;
}

.api-meta-grid span { font-size: 0.65rem; font-weight: 700; color: var(--fg-tertiary); text-transform: uppercase; letter-spacing: 0.06em; }

.api-meta-grid strong, .api-meta-grid code { font-size: 0.86rem; }

.api-meta-grid code { word-break: break-all; overflow-wrap: anywhere; }

.api-table td { white-space: normal; vertical-align: top; }

.method-badge {
  display: inline-flex; align-items: center; justify-content: center;
  height: 24px; padding: 0 10px; border-radius: 5px;
  font-size: 0.7rem; font-weight: 700; font-family: var(--font-mono); text-transform: uppercase;
}

.method-badge.get { background: var(--success-dim); color: var(--success); }

.method-badge.post { background: rgba(167,139,250,0.15); color: var(--accent-strong); }

.method-badge.delete { background: var(--danger-dim); color: var(--danger); }

.code-block {
  margin: 0; padding: 18px; overflow-x: auto;
  border-radius: var(--radius-sm);
  background: #0c0a09; color: #e7e5e4;
  font-family: var(--font-mono); font-size: 0.82rem; line-height: 1.7;
  border: 1px solid rgba(255,255,255,0.05);
}

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

.pg-sidebar-title { font-size: 0.82rem; font-weight: 700; color: var(--fg); }

.pg-sidebar-close {
  width: 30px; height: 30px; display: grid; place-items: center;
  background: none; border: none; color: var(--fg-tertiary);
  border-radius: 6px; cursor: pointer; transition: all var(--transition);
}

.pg-sidebar-close:hover { background: var(--surface-hover); color: var(--fg); }

.pg-sidebar-close i { width: 16px; height: 16px; }

.welcome-icon {
  width: 56px; height: 56px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-glow);
}

.welcome-icon i { width: 28px; height: 28px; color: var(--accent); }

.welcome-prompts {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 10px; max-width: 560px; width: 100%;
}

.prompt-chip {
  padding: 14px 16px; border-radius: 14px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface);
  color: var(--fg-secondary); font-size: 0.84rem; font-weight: 500;
  text-align: left; transition: all 0.2s ease; font-family: inherit;
  line-height: 1.5;
}

.prompt-chip:hover {
  border-color: var(--accent); color: var(--accent);
  background: var(--accent-glow);
  transform: translateY(-1px);
}

.prompt-chip:active { transform: translateY(0); }

html.light .chat-text pre { background: #f8f8f6; border-color: rgba(0,0,0,0.06); }

html.light .chat-text pre code { color: #1c1917; }

html.light .chat-text code { background: rgba(0,0,0,0.06); }

.streaming-cursor {
  display: inline-block;
  width: 2px; height: 1.15em;
  margin-left: 2px; vertical-align: text-bottom;
  background: var(--accent); border-radius: 1px;
  will-change: opacity;
  animation: cursorBlink 0.7s step-end infinite;
}

.status-thinking { color: var(--accent); display: flex; align-items: center; gap: 4px; }

.status-done { color: var(--success); display: flex; align-items: center; gap: 4px; }

.status-error { color: var(--danger); display: flex; align-items: center; gap: 4px; }

.status-stopped { color: var(--warning); display: flex; align-items: center; gap: 4px; }

.typing-dots {
  display: inline-flex; gap: 3px; align-items: center; margin-right: 5px;
}

.typing-dots i {
  display: block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent);
  will-change: transform, opacity;
  animation: typingBounce 1.2s ease-in-out infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 0.18s; }

.typing-dots i:nth-child(3) { animation-delay: 0.36s; }

.token-bar { height: 4px; border-radius: 2px; background: var(--border); overflow: hidden; margin-top: 2px; }

.token-bar-fill { height: 100%; border-radius: 2px; background: var(--gradient-1); transition: width 0.5s cubic-bezier(0.16,1,0.3,1); min-width: 0; }

.image-preview-strip { display: flex; gap: 8px; flex-wrap: wrap; padding: 0 0 8px 0; }

.modal-backdrop {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0,0,0,0.65);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  animation: modalFadeIn 0.2s ease;
  padding: 20px;
}

.modal-backdrop.hiding { animation: modalFadeOut 0.15s ease forwards; }

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
  max-width: 420px; width: 100%;
  animation: modalScaleIn 0.25s cubic-bezier(0.16,1,0.3,1);
  overflow: hidden;
}

.modal-backdrop.hiding .modal-card { animation: modalScaleOut 0.12s ease forwards; }

.modal-icon-row {
  display: flex; align-items: center; justify-content: center;
  padding: 28px 24px 0;
}

.modal-icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center; font-size: 1.5rem;
}

.modal-icon.danger  { background: rgba(239,68,68,0.15);  color: #ef4444; }

.modal-icon.warning { background: rgba(245,158,11,0.15); color: #f59e0b; }

.modal-icon.info    { background: rgba(96,165,250,0.15); color: #60a5fa; }

.modal-body {
  padding: 20px 28px 8px;
  text-align: center;
}

.modal-body h3 {
  margin: 0 0 8px; font-size: 1.05rem; font-weight: 600;
  color: var(--fg);
}

.modal-body p {
  margin: 0; font-size: 0.875rem; color: var(--fg-secondary);
  line-height: 1.55;
}

.modal-actions {
  display: flex; gap: 10px; padding: 16px 28px 24px;
}

.modal-actions .button { flex: 1; justify-content: center; }

@media (max-width: 640px) {
  .modal-card { max-width: 100%; }
  .modal-body { padding: 16px 20px 4px; }
  .modal-actions { padding: 12px 20px 20px; }
}
