/* ============================================================
   大禹 · 大模型平台 — Design System v2
   ============================================================ */

/* ----- Font Import ----- */
@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600&family=Fira+Sans:wght@400;500;600;700&display=swap');

/* ----- CSS Variables ----- */
:root {
  /* Brand — refined blue */
  --brand-50: #eff6ff;
  --brand-100: #dbeafe;
  --brand-200: #bfdbfe;
  --brand-400: #60a5fa;
  --brand-500: #3b82f6;
  --brand-600: #2563eb;
  --brand-700: #1d4ed8;

  /* Accent — amber CTA */
  --accent-50: #fffbeb;
  --accent-400: #fbbf24;
  --accent-500: #f59e0b;
  --accent-600: #d97706;

  /* Surfaces */
  --bg-root: #f8fafc;
  --bg-surface: #ffffff;
  --bg-subtle: #e8ecf2;
  --bg-raised: #ffffff;

  /* Text */
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-tertiary: #94a3b8;
  --text-inverse: #ffffff;

  /* Borders */
  --border-light: #e8ecf2;
  --border-default: #cbd5e1;
  --border-strong: #94a3b8;

  /* Semantic */
  --green-50: #f0fdf4;
  --green-600: #16a34a;
  --green-700: #15803d;
  --red-50: #fef2f2;
  --red-500: #ef4444;
  --red-600: #dc2626;
  --amber-50: #fffbeb;
  --amber-600: #d97706;
  --teal-50: #f0fdfa;
  --teal-600: #0d9488;
  --blue-50: #eff6ff;
  --blue-600: #1e40af;
  --indigo-50: #eef2ff;
  --indigo-600: #4f46e5;

  /* Radii */
  --r-xs: 4px;
  --r-sm: 6px;
  --r-md: 10px;
  --r-lg: 14px;
  --r-xl: 18px;

  /* Shadows — layered depth */
  --shadow-xs: 0 1px 2px rgba(15,23,42,.04);
  --shadow-sm: 0 1px 3px rgba(15,23,42,.06), 0 1px 2px rgba(15,23,42,.04);
  --shadow-md: 0 4px 6px -1px rgba(15,23,42,.08), 0 2px 4px -2px rgba(15,23,42,.04);
  --shadow-lg: 0 10px 15px -3px rgba(15,23,42,.10), 0 4px 6px -4px rgba(15,23,42,.05);
  --shadow-xl: 0 20px 25px -5px rgba(15,23,42,.12), 0 8px 10px -6px rgba(15,23,42,.04);
  --shadow-glow: 0 0 0 3px rgba(59,130,246,.15), 0 2px 8px rgba(59,130,246,.10);

  /* Transitions */
  --t-fast: 150ms ease;
  --t-base: 200ms ease;
  --t-slow: 300ms ease;
}

/* ----- Reset & Base ----- */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
fieldset { border: none; margin: 0; padding: 0; min-width: 0; }
legend { float: none; width: auto; max-width: 100%; padding: 0; margin: 0; }

/* ----- Focus states (CRITICAL - a11y) ----- */
:focus-visible {
  outline: 2px solid var(--brand-500);
  outline-offset: 2px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible, .btn:focus-visible {
  outline: none;
  box-shadow: var(--shadow-glow);
}

/* ----- Tooltip ----- */
[data-tooltip] {
  position: relative;
  cursor: help;
}
[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--brand-700);
  color: #fff;
  font-size: .7rem;
  padding: 4px 10px;
  border-radius: var(--r-xs);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--t-fast);
  z-index: 50;
}
[data-tooltip]:hover::after { opacity: 1; }
html { font-size: clamp(14px, 0.85rem + 0.2vw, 18px); -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
body {
  font-family: "Fira Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  background: var(--bg-root);
  color: var(--text-primary);
  line-height: 1.65;
  min-height: 100vh;
  zoom: 0.9;
  /* Subtle atmospheric background */
  background-image:
    radial-gradient(ellipse 90% 70% at 20% -30%, rgba(37,99,235,.04), transparent),
    radial-gradient(ellipse 60% 50% at 80% 100%, rgba(245,158,11,.02), transparent),
    linear-gradient(180deg, rgba(37,99,235,.015) 0%, transparent 60%);
  background-attachment: fixed;
  touch-action: manipulation;
  overscroll-behavior: contain;
}

/* ----- Layout ----- */
#app { max-width: 1400px; margin: 0 auto; padding: clamp(20px, 2vw, 32px) clamp(16px, 1.5vw, 28px) clamp(40px, 4vw, 56px); }

/* ============================================================
   HEADER
   ============================================================ */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 36px;
  padding: 0 0 16px 0;
  border-bottom: 1px solid var(--border-default);
  position: relative;
}
header::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 80px;
  height: 3px;
  background: linear-gradient(90deg, var(--brand-500) 0%, var(--accent-500) 100%);
  border-radius: 2px;
}
.header-brand {
  display: flex;
  align-items: center;
}
header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.02em;
}
header h1 span { color: var(--brand-600); }
.version-tag { font-size: .7em; font-weight: 600; color: var(--brand-500); margin-left: 12px; vertical-align: middle; }

/* Nav */
nav { display: flex; gap: 2px; background: var(--bg-subtle); border-radius: var(--r-md); padding: 4px; }
nav a {
  text-decoration: none;
  color: var(--text-secondary);
  padding: 9px 20px;
  border-radius: var(--r-sm);
  font-size: .85rem;
  font-weight: 500;
  transition: all var(--t-fast);
  position: relative;
}
nav a:hover { color: var(--text-primary); background: rgba(255,255,255,.5); }
nav a.active {
  background: var(--bg-surface);
  color: var(--brand-600);
  box-shadow: var(--shadow-sm);
  font-weight: 600;
  position: relative;
}
nav a.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 25%;
  right: 25%;
  height: 2px;
  background: linear-gradient(90deg, var(--brand-500), var(--brand-400));
  border-radius: 1px;
}

/* Mobile nav toggle */
#nav-toggle {
  display: none;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  padding: 7px 10px;
  cursor: pointer;
  color: var(--text-primary);
  font-size: 1.1rem;
  line-height: 1;
  box-shadow: var(--shadow-xs);
}
#nav-toggle:active { background: var(--bg-subtle); }

/* ============================================================
   TOOLBAR
   ============================================================ */
.toolbar-hint { font-size: .8rem; color: var(--text-tertiary); }
.toolbar-hint strong { color: var(--text-secondary); font-weight: 600; }

/* ============================================================
   CAPABILITY TABS (Pill style)
   ============================================================ */
.capability-tabs {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0 16px;
  flex-wrap: nowrap;
  overflow-x: auto;
}
.tab-item {
  padding: 10px 24px;
  font-size: .9rem;
  font-weight: 600;
  color: var(--text-tertiary);
  cursor: pointer;
  border-radius: 24px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all var(--t-fast);
  user-select: none;
}
.tab-item:hover { color: var(--text-primary); background: #e2e8f0; }
.tab-item.active {
  color: #fff;
  font-weight: 700;
  background: linear-gradient(135deg, var(--brand-700), var(--brand-600));
  box-shadow: 0 3px 12px rgba(37,99,235,.35);
}
.tab-badge {
  font-size: .6875rem;
  font-weight: 500;
  padding: 2px 9px;
  border-radius: 12px;
  background: #e2e8f0;
  color: #475569;
}
.tab-item.active .tab-badge {
  background: rgba(255,255,255,.2);
  color: #fff;
}
.tab-divider { width: 1px; height: 28px; background: var(--border-light); }
.btn-icon {
  width: 36px; height: 36px; border-radius: var(--r-md); border: 1px solid var(--border-default);
  background: var(--bg-surface); cursor: pointer; display: flex; align-items: center;
  justify-content: center; color: var(--text-tertiary); font-size: 1.1rem;
  transition: all var(--t-fast);
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-subtle); }

/* List toolbar — 与能力标签行分立的第二行：新增模型主按钮（左）+ 搜索/批量/更多（右） */
.list-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}
.list-toolbar .btn-primary { padding: 9px 22px; font-weight: 600; }
.list-toolbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.tab-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
.tab-actions .search-input { width: 180px; font-size: .8rem; }

/* Dropdown menu */
.dropdown { position: relative; }
.dropdown-menu {
  position: absolute; right: 0; top: 100%; margin-top: 4px;
  background: var(--bg-surface); border: 1px solid var(--border-default);
  border-radius: var(--r-md); box-shadow: var(--shadow-md);
  min-width: 140px; z-index: 50; display: none;
}
.dropdown.open .dropdown-menu { display: block; }
.dropdown-menu-item {
  display: block; width: 100%; padding: 9px 14px; font-size: .8125rem;
  color: var(--text-secondary); background: none; border: none; text-align: left;
  cursor: pointer; transition: background var(--t-fast);
}
.dropdown-menu-item:hover { background: var(--bg-subtle); }
.dropdown-menu-item + .dropdown-menu-item { border-top: 1px solid var(--border-light); }

/* Direction badge (inbound → outbound) */
.direction-badge { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.direction-arrow { color: var(--text-tertiary); display: inline-flex; align-items: center; }
.direction-arrow svg { width: 14px; height: 14px; }

/* Stats row */
.stats-row {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  padding: 18px 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  transition: all var(--t-base);
  position: relative;
  overflow: hidden;
  cursor: default;
}
.stat-card::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 4px;
  border-radius: 0 2px 2px 0;
}
.stat-card:hover { box-shadow: var(--shadow-lg); transform: translateY(-2px); }
.stat-card-icon {
  width: 40px; height: 40px;
  border-radius: var(--r-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 1.1rem;
}
.stat-card-icon svg { width: 22px; height: 22px; }
.stat-card-content { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.stat-card-label { font-size: .72rem; font-weight: 500; color: var(--text-tertiary); letter-spacing: .02em; }
.stat-card-value { font-size: 1.6rem; font-weight: 700; color: var(--text-primary); line-height: 1.1; }
.stat-card-sub { font-size: .72rem; color: var(--text-tertiary); }
.stat-card-accent::before { background: linear-gradient(180deg, var(--brand-400) 0%, var(--brand-600) 100%); }
.stat-card-accent .stat-card-icon { background: var(--brand-50); color: var(--brand-600); }
.stat-card-green::before { background: linear-gradient(180deg, var(--green-600) 0%, var(--green-700) 100%); }
.stat-card-green .stat-card-icon { background: var(--green-50); color: var(--green-600); }
.stat-card-teal::before { background: linear-gradient(180deg, var(--teal-600) 0%, #0d9488 100%); }
.stat-card-teal .stat-card-icon { background: var(--teal-50); color: var(--teal-600); }
.stat-card-indigo::before { background: linear-gradient(180deg, var(--indigo-600) 0%, #4338ca 100%); }
.stat-card-indigo .stat-card-icon { background: var(--indigo-50); color: var(--indigo-600); }
.stat-card-purple::before { background: linear-gradient(180deg, #9333ea 0%, #7e22ce 100%); }
.stat-card-purple .stat-card-icon { background: #faf5ff; color: #9333ea; }

/* ============================================================
   TABLE
   ============================================================ */
.table {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-default);
}
.table th, .table td {
  padding: 14px 20px;
  text-align: left;
  font-size: .85rem;
  border-bottom: 1px solid var(--border-default);
  border-right: 1px solid var(--border-light);
}
.table th:last-child, .table td:last-child { border-right: none; }
.table th {
  background: linear-gradient(180deg, var(--brand-700) 0%, var(--brand-600) 100%);
  font-weight: 600;
  color: #e8ecf5;
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .07em;
  border-bottom: 2px solid var(--accent-500);
}
.table tbody tr:nth-child(even) { background: #f6f8fb; }
.table tbody tr:nth-child(odd) { background: #ffffff; }
.table tbody tr { transition: all var(--t-fast); animation: rowIn .2s ease; }
@keyframes rowIn { from { opacity: 0; } to { opacity: 1; } }
.table tbody tr:hover { background: #eef3ff; box-shadow: inset 3px 0 0 var(--brand-600); }
.table tbody tr:last-child td { border-bottom: none; }

.action-cell {
  display: flex;
  gap: 6px;
  justify-content: center;
  flex-wrap: nowrap;
}
.action-cell .btn { white-space: nowrap; }

/* Table column styles */
.table td[data-label="模型名"] {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text-primary);
}
.table td[data-label="转换方向"] {
  font-size: .85rem;
}
.table td[data-label="后端地址"] {
  font-size: .75rem;
  color: var(--text-tertiary);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.table td[data-label="启用"] {
  text-align: center;
}
.table td[data-label="最近测试结果"] {
  text-align: center;
  white-space: nowrap;
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 20px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  cursor: pointer;
  font-size: .85rem;
  font-weight: 500;
  color: var(--text-primary);
  transition: all var(--t-fast);
  white-space: nowrap;
  min-height: 38px;
  box-shadow: var(--shadow-xs);
}
.btn:hover { background: var(--bg-subtle); border-color: var(--border-strong); box-shadow: 0 4px 10px rgba(15,23,42,.08); transform: translateY(-1px); }
.btn:active { transform: scale(.975); }
.btn-primary {
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border-color: transparent;
  box-shadow: 0 2px 6px rgba(37,99,235,.2);
}
.btn-primary:hover { background: linear-gradient(135deg, #1d4ed8, #2563eb); border-color: transparent; box-shadow: 0 6px 16px rgba(37,99,235,.3); transform: translateY(-2px); }
.btn-cta {
  background: var(--accent-500);
  color: #fff;
  border-color: var(--accent-500);
  box-shadow: 0 1px 2px rgba(245,158,11,.18), 0 2px 4px rgba(245,158,11,.08);
  font-weight: 600;
}
.btn-cta:hover { background: var(--accent-600); border-color: var(--accent-600); box-shadow: 0 2px 6px rgba(245,158,11,.22); }
.btn-sm { padding: 8px 18px; font-size: .85rem; min-height: 36px; border-radius: var(--r-xs); }
.btn-green { background: linear-gradient(135deg, #16a34a, #22c55e); color: #fff; border-color: transparent; box-shadow: 0 2px 6px rgba(22,163,74,.2); }
.btn-green:hover { background: linear-gradient(135deg, #15803d, #16a34a); border-color: transparent; box-shadow: 0 6px 16px rgba(22,163,74,.3); transform: translateY(-2px); }
.btn-amber { background: linear-gradient(135deg, #d97706, #f59e0b); color: #fff; border-color: transparent; box-shadow: 0 2px 6px rgba(217,119,6,.2); }
.btn-amber:hover { background: linear-gradient(135deg, #b45309, #d97706); border-color: transparent; box-shadow: 0 6px 16px rgba(217,119,6,.3); transform: translateY(-2px); }
.btn-teal { background: linear-gradient(135deg, #f0fdfa, #ccfbf1); color: #0d9488; border-color: #99f6e4; box-shadow: 0 1px 3px rgba(13,148,136,.08); }
.btn-teal:hover { background: linear-gradient(135deg, #ccfbf1, #99f6e4); border-color: #5eead4; box-shadow: 0 4px 10px rgba(13,148,136,.15); transform: translateY(-1px); }
.btn-blue { background: linear-gradient(135deg, #1e40af, #3b82f6); color: #fff; border-color: transparent; box-shadow: 0 2px 6px rgba(37,99,235,.2); }
.btn-blue:hover { background: linear-gradient(135deg, #1e3a8a, #2563eb); border-color: transparent; box-shadow: 0 6px 16px rgba(37,99,235,.3); transform: translateY(-2px); }
.btn-red { background: linear-gradient(135deg, #dc2626, #ef4444); color: #fff; border-color: transparent; box-shadow: 0 2px 6px rgba(220,38,38,.2); }
.btn-red:hover { background: linear-gradient(135deg, #b91c1c, #dc2626); border-color: transparent; box-shadow: 0 6px 16px rgba(220,38,38,.3); transform: translateY(-2px); }
.btn-icon {
  padding: 6px 10px;
  min-width: 36px;
  min-height: 32px;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border-color: var(--border-light);
  box-shadow: none;
}
.btn-icon:hover {
  background: var(--brand-50);
  color: var(--brand-600);
  border-color: var(--brand-200);
}

/* ============================================================
   FORM
   ============================================================ */
.form {
  max-width: 1220px;
  width: 100%;
  margin: 0 auto;
  background: var(--bg-surface);
  padding: 36px 40px;
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-default);
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 40px;
}
.form .form-actions {
  grid-column: 1 / -1;
}
.form fieldset { min-width: 0; }
#form-title {
  max-width: 1220px;
  width: 100%;
  margin: 0 auto 28px auto;
  padding: 0 40px;
  font-size: 1.35rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
  line-height: 1.3;
  text-align: left;
  box-sizing: border-box;
}
@media (max-width: 768px) {
  #form-title { padding: 0 24px; max-width: 100%; }
}
@media (max-width: 480px) {
  #form-title { padding: 0 18px; max-width: 100%; }
}
.form-row { margin-bottom: 20px; }
.form-row label {
  display: block;
  font-size: .85rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-secondary);
  line-height: 1.4;
}
.form-row input,
.form-row select {
  width: 100%;
  padding: 11px 16px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  font-size: .9rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: all var(--t-fast);
  box-shadow: var(--shadow-xs);
  line-height: 1.4;
}
.form-row input:focus,
.form-row select:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--shadow-glow);
}
.form-row input[type="checkbox"] {
  width: auto;
  height: auto;
  box-shadow: none;
  vertical-align: middle;
  margin: 0;
  margin-left: 8px;
  margin-top: 0;
}
.form-actions { display: flex; gap: 12px; margin-top: 28px; flex-wrap: wrap; }
.form-section {
  border: none;
  margin-bottom: 28px;
  padding: 0;
  width: 100%;
  display: block;
}
.form-section legend {
  font-size: .76rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin: 0 0 18px 0;
  padding: 4px 0 8px 10px;
  border-left: 3px solid var(--brand-500);
  border-bottom: 1px solid var(--border-light);
  display: block;
  line-height: 1.4;
  width: 100%;
}
.form-row-inline {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  align-items: start;
}
.form-row-inline .form-row { margin-bottom: 0; }
.form-row-inline .form-row label {
  min-height: 22px;
  display: flex;
  align-items: center;
}
.form-row-checkbox { justify-content: flex-end; }
.form-row-checkbox label {
  display: inline !important;
  margin-bottom: 0 !important;
  min-height: auto !important;
  cursor: pointer;
}
.form-help { font-size: .72rem; color: var(--text-tertiary); margin: 5px 0 0; line-height: 1.45; }
.form-check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: .78rem;
  color: var(--text-secondary);
  cursor: pointer;
  margin-top: 8px;
}
.form-check input[type="checkbox"] { width: auto; }

/* ============================================================
   DETAIL GRID
   ============================================================ */
.detail-grid {
  display: grid;
  grid-template-columns: 150px 1fr;
  gap: 0;
  font-size: .825rem;
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  margin-bottom: 20px;
  overflow: hidden;
}
.detail-grid dt {
  padding: 13px 18px;
  font-weight: 600;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  border-bottom: 1px solid var(--border-light);
  font-size: .75rem;
  letter-spacing: .02em;
}
.detail-grid dd {
  padding: 13px 18px;
  color: var(--text-primary);
  word-break: break-all;
  border-bottom: 1px solid var(--border-light);
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
}
.detail-grid dt:last-of-type,
.detail-grid dd:last-of-type { border-bottom: none; }

/* Detail page — single column layout */
.detail-header-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
  padding: 8px 0;
}
.detail-header-bar h2 {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text-primary);
}
.detail-header-bar h2 span {
  font-weight: 400;
  color: var(--text-tertiary);
  font-size: .85rem;
}
.detail-header-actions {
  display: flex;
  gap: 8px;
  flex-shrink: 0;
  margin-left: auto;
}
.detail-layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}
.detail-section {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  transition: box-shadow var(--t-base);
}
.detail-section:hover { box-shadow: var(--shadow-md); }
.detail-section-title {
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  padding: 14px 18px 10px;
  border-bottom: 1px solid var(--border-light);
  background: var(--bg-subtle);
}
.detail-section .detail-grid {
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  border-top: 1px solid var(--border-light);
}
.detail-section .action-bar {
  margin: 0;
  border: none;
  border-radius: 0;
  box-shadow: none;
  border-top: 1px solid var(--border-light);
  background: transparent;
}
.detail-result-area {
  padding: 0 18px 18px;
}
.result-box-inline {
  margin: 0;
  max-height: 480px;
  border-radius: var(--r-sm);
}

/* Edit modal form */
.modal-panel-form {
  width: min(820px, calc(100vw - 28px));
  max-height: 85vh;
  overflow-y: auto;
}
/* ============================================================
   BATCH IMPORT
   ============================================================ */
.modal-panel-wide {
  width: min(960px, calc(100vw - 28px));
  max-height: 88vh;
  overflow-y: auto;
}
.batch-input-tabs {
  display: flex;
  gap: 0;
  margin-bottom: 12px;
  background: var(--bg-subtle);
  border-radius: var(--r-sm);
  padding: 3px;
}
.batch-tab {
  flex: 1;
  padding: 7px 16px;
  border: none;
  background: transparent;
  border-radius: var(--r-xs);
  cursor: pointer;
  font-size: .8rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: all var(--t-fast);
}
.batch-tab.active {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}
.batch-tab-panel { margin-bottom: 12px; }
.batch-drop-zone {
  border: 2px dashed var(--border-default);
  border-radius: var(--r-md);
  padding: 32px 20px;
  text-align: center;
  cursor: pointer;
  transition: all var(--t-fast);
  color: var(--text-tertiary);
}
.batch-drop-zone:hover, .batch-drop-zone.dragover {
  border-color: var(--brand-500);
  background: var(--brand-50);
  color: var(--brand-600);
}
.batch-drop-zone svg { display: block; margin: 0 auto 10px; opacity: .5; }
.batch-drop-zone p { font-size: .85rem; }
.batch-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: .78rem;
  color: var(--text-secondary);
}
.batch-preview-table-wrap {
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border-light);
  border-radius: var(--r-sm);
}
.batch-table { border: none; border-radius: 0; box-shadow: none; table-layout: auto; }
.batch-table th { position: sticky; top: 0; z-index: 1; }
.batch-table td { font-size: .78rem; padding: 8px 12px; }
.batch-table th { font-size: .65rem; padding: 8px 12px; }
.batch-item-action {
  padding: 4px 8px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-xs);
  font-size: .72rem;
  cursor: pointer;
  background: var(--bg-surface);
  color: var(--text-primary);
}
.batch-item-action:focus { outline: none; border-color: var(--brand-500); }
.batch-status-new { color: var(--green-600); font-weight: 500; font-size: .75rem; }
.batch-status-dup { color: var(--amber-600); font-weight: 500; font-size: .75rem; }
.batch-result {
  margin: 12px 0;
  padding: 14px 16px;
  border-radius: var(--r-sm);
  font-size: .8rem;
  line-height: 1.6;
}
.batch-result-success { background: var(--green-50); color: var(--green-600); }
.batch-result-partial { background: var(--amber-50); color: var(--amber-600); }

.batch-progress {
  margin-bottom: 14px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.batch-progress-bar {
  width: 100%;
  height: 6px;
  background: var(--bg-subtle);
  border-radius: 3px;
  overflow: hidden;
}
.batch-progress-fill {
  height: 100%;
  background: var(--brand-600);
  border-radius: 3px;
  width: 0%;
  transition: width var(--t-base);
}
.batch-progress-text {
  font-size: .75rem;
  color: var(--text-secondary);
}

.form-modal {
  max-width: 100%;
  padding: 0;
  box-shadow: none;
  border: none;
  border-radius: 0;
  grid-template-columns: 1fr;
}

/* Global toast notification */
.global-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  padding: 10px 24px;
  border-radius: 8px;
  font-size: .85rem;
  font-weight: 500;
  z-index: 9999;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s, transform .25s;
  box-shadow: 0 4px 16px rgba(0,0,0,.12);
}
.global-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
  pointer-events: auto;
}
.global-toast.ok { background: var(--green-600); color: #fff; }
.global-toast.err { background: var(--red-600); color: #fff; }

/* ============================================================
   ACTION BAR
   ============================================================ */
.action-bar {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 14px 18px;
  background: var(--bg-surface);
  border-radius: var(--r-md);
  border: 1px solid var(--border-default);
  box-shadow: var(--shadow-sm);
}
.curl-key-toggle { font-size: .75rem; display: flex; align-items: center; gap: 5px; color: var(--text-secondary); }
.copy-status { font-size: .75rem; min-width: 64px; font-weight: 500; }
.copy-status.ok { color: var(--green-600); }
.copy-status.err { color: var(--red-600); }

/* ============================================================
   INVOKE TARGET & RESULT BOX
   ============================================================ */
.invoke-target {
  margin: 0 0 14px;
  padding: 12px 16px;
  border: 1px solid var(--brand-200);
  background: var(--brand-50);
  color: var(--brand-700);
  border-radius: var(--r-sm);
  font-size: .75rem;
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
}
.result-box {
  background: #1e1b4b;
  color: #cbd5e1;
  padding: 20px;
  border-radius: var(--r-md);
  font-size: .75rem;
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 440px;
  overflow: auto;
  line-height: 1.65;
  border: 1px solid #2d2a5e;
  position: relative;
}
.result-copy-bar {
  position: sticky;
  top: 0;
  float: right;
  display: flex;
  gap: 6px;
  z-index: 2;
  margin-bottom: -28px;
  pointer-events: none;
}
.result-copy-btn {
  pointer-events: auto;
  padding: 4px 10px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.12);
  border-radius: 6px;
  color: rgba(255,255,255,.6);
  font-size: 11px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
  backdrop-filter: blur(4px);
  transition: all .15s;
  font-family: inherit;
  white-space: nowrap;
}
.result-copy-btn:hover {
  background: rgba(255,255,255,.16);
  color: rgba(255,255,255,.9);
}
.result-copy-btn.copied {
  background: rgba(22,163,74,.2);
  border-color: rgba(22,163,74,.3);
  color: #86efac;
}
.result-box .result-text {
  margin: 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: inherit;
  font-size: inherit;
  line-height: inherit;
}

/* ============================================================
   BADGES
   ============================================================ */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: .6875rem;
  font-weight: 600;
  letter-spacing: .01em;
  white-space: nowrap;
}
.badge-green { background: var(--green-50); color: var(--green-600); }
.badge-red { background: var(--red-50); color: var(--red-600); }
.badge-gray { background: var(--bg-subtle); color: var(--text-secondary); }
.badge-blue { background: var(--blue-50); color: var(--blue-600); }
.badge-teal { background: var(--teal-50); color: var(--teal-600); }
.badge-indigo { background: var(--indigo-50); color: var(--indigo-600); }
.badge-purple { background: #faf5ff; color: #9333ea; }
.badge-cyan { background: #ecfeff; color: #0891b2; }
.badge-orange { background: #fff7ed; color: #ea580c; }
.badge-pink { background: #fdf2f8; color: #db2777; }

/* Status dot (inside badge) */
.badge-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: currentColor;
  flex-shrink: 0;
}
.badge-green .badge-dot { animation: pulse-dot 2s ease-in-out infinite; }
@keyframes pulse-dot {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.badge-clickable {
  cursor: pointer;
  transition: all var(--t-fast);
}
.badge-clickable:hover {
  opacity: .8;
  transform: scale(1.06);
}
.badge-clickable:active {
  transform: scale(.94);
}

/* ============================================================
   TOGGLE SWITCH (table inline)
   ============================================================ */
.table-toggle {
  display: inline-block;
  width: 44px;
  height: 24px;
  background: var(--border-strong);
  border-radius: 12px;
  position: relative;
  cursor: pointer;
  transition: background 0.25s;
  vertical-align: middle;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
}
.table-toggle.active {
  background: var(--brand-600);
  box-shadow: inset 0 1px 2px rgba(37,99,235,.15);
}
.table-toggle-knob {
  display: block;
  width: 20px;
  height: 20px;
  background: #fff;
  border-radius: 50%;
  position: absolute;
  top: 2px;
  left: 2px;
  transition: left 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 1px 3px rgba(0,0,0,.2);
}
.table-toggle.active .table-toggle-knob {
  left: 22px;
}
.table-toggle:hover { opacity: .85; }
.table-toggle:active .table-toggle-knob { width: 24px; }

/* ============================================================
   MODAL
   ============================================================ */
.modal { position: fixed; inset: 0; z-index: 1000; }
.modal-backdrop {
  position: absolute; inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
  animation: fadeIn .2s ease;
}
.modal-panel {
  position: relative;
  width: min(780px, calc(100vw - 28px));
  margin: 5vh auto;
  background: var(--bg-surface);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(15,23,42,.05);
  padding: 22px 26px;
  z-index: 1;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp .25s ease;
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes modalFadeOut {
  from { opacity: 1; }
  to   { opacity: 0; }
}
.modal-panel.closing { animation: modalFadeOut .15s ease forwards; }
.modal-panel h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 12px; color: var(--text-primary); }
.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}
.modal-header-row h3 { margin-bottom: 0; }
.modal-close {
  width: 28px; height: 28px;
  background: var(--bg-subtle);
  border: none; border-radius: 6px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background var(--t-fast);
  color: var(--text-secondary);
  flex-shrink: 0;
}
.modal-close:hover { background: var(--border-default); }
.modal-path {
  font-size: .75rem;
  color: var(--text-tertiary);
  margin-bottom: 14px;
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  background: var(--bg-subtle);
  padding: 8px 12px;
  border-radius: var(--r-xs);
  word-break: break-all;
}
.modal-label { display: block; font-size: .75rem; font-weight: 600; color: var(--text-secondary); margin: 12px 0 6px; }
.modal-stream-mode { margin-top: 10px; }
.modal-select {
  width: 100%;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  padding: 9px 12px;
  font-size: .8125rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color var(--t-fast);
  box-shadow: var(--shadow-xs);
}
.modal-select:focus { outline: none; border-color: var(--brand-500); }
.modal-textarea {
  width: 100%;
  min-height: 290px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  padding: 14px;
  font-size: .75rem;
  font-family: "Fira Code", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  line-height: 1.6;
  resize: vertical;
  background: #faf8fc;
  color: var(--text-primary);
  transition: border-color var(--t-fast);
}
.modal-textarea:focus { outline: none; border-color: var(--brand-500); }
.modal-textarea-sm { min-height: 104px; }
.modal-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 16px; }
.login-error { color: #e53e3e; font-size: 13px; margin: 8px 0 0; min-height: 18px; }

/* 登录页（独立整屏页，非弹窗） */
.login-page {
  position: fixed; inset: 0; z-index: 2000;
  display: flex; align-items: center; justify-content: center;
  padding: 24px; box-sizing: border-box;
  background: radial-gradient(120% 120% at 50% 0%, var(--brand-50) 0%, var(--bg-root) 55%, var(--bg-subtle) 100%);
  animation: fadeIn .25s ease;
}
.login-card {
  width: min(380px, 100%);
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-xl), 0 0 0 1px rgba(15,23,42,.04);
  padding: 36px 32px 32px;
  text-align: center;
  display: flex; flex-direction: column; align-items: stretch;
}
.login-logo {
  width: 72px; height: 72px; border-radius: 50%;
  margin: 0 auto 10px; display: block;
  box-shadow: 0 6px 18px rgba(37,99,235,.18);
}
.login-title { font-size: 1.1rem; font-weight: 700; color: var(--text-primary); margin: 4px 0 2px; }
.login-subtitle { font-size: .82rem; color: var(--text-secondary); margin: 0 0 16px; }
.login-input {
  width: 100%; box-sizing: border-box;
  border: 1px solid var(--border-default); border-radius: var(--r-sm);
  padding: 11px 14px; font-size: .9rem;
  background: var(--bg-surface); color: var(--text-primary);
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}
.login-input:focus { outline: none; border-color: var(--brand-500); box-shadow: 0 0 0 3px var(--brand-50); }
.login-submit { width: 100%; margin-top: 16px; padding: 11px 16px; }

/* Loading modal */
.modal-panel-loading {
  width: min(360px, calc(100vw - 28px));
  text-align: center;
  padding: 40px 28px;
}
.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.loading-content p {
  font-size: .95rem;
  font-weight: 500;
  color: var(--text-secondary);
}
.spinner-lg {
  width: 36px;
  height: 36px;
  border-width: 3px;
  color: var(--brand-600);
}

/* ============================================================
   CAPABILITY PAGES
   ============================================================ */
.capability-page { min-height: calc(100vh - 180px); display: flex; flex-direction: column; gap: 16px; }
.capability-page-llm { gap: 12px; }

.capability-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.capability-title {
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -.01em;
}
.capability-subtitle { color: var(--text-tertiary); font-size: .8rem; margin-top: 1px; }
.capability-toolbar-inline { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.capability-label { font-size: .75rem; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }

.capability-select {
  min-width: 200px;
  padding: 7px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  background: var(--bg-surface);
  font-size: .85rem;
  color: var(--text-primary);
  transition: border-color var(--t-fast);
  box-shadow: var(--shadow-xs);
  cursor: pointer;
}
.capability-select:focus { outline: none; border-color: var(--brand-500); }
.capability-select-sm { min-width: 110px; }

.capability-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-md);
  padding: 26px;
}

.capability-list-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.capability-input-list { display: flex; flex-direction: column; gap: 10px; }
.capability-input-row { display: flex; gap: 10px; align-items: center; }
.capability-input-line {
  flex: 1;
  min-height: 46px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  padding: 11px 15px;
  font-size: .875rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color var(--t-fast);
  box-shadow: var(--shadow-xs);
}
.capability-input-line:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--shadow-glow); }
.capability-row-remove { flex-shrink: 0; }
.capability-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

.capability-textarea {
  width: 100%;
  min-height: 180px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  padding: 13px 15px;
  font-size: .875rem;
  line-height: 1.65;
  resize: vertical;
  background: var(--bg-surface);
  color: var(--text-primary);
  transition: border-color var(--t-fast);
  box-shadow: var(--shadow-xs);
}
.capability-textarea:focus { outline: none; border-color: var(--brand-500); box-shadow: var(--shadow-glow); }
.capability-textarea-sm { min-height: 110px; }
.capability-result { margin-top: 20px; display: block; max-height: 420px; }
.capability-form-grid { display: grid; gap: 20px; }

/* Model test tab switcher */
.model-test-switcher { background: var(--bg-subtle); padding: 3px; border-radius: 100px; gap: 2px !important; }
.model-test-switcher .btn {
  border: none;
  background: transparent;
  box-shadow: none;
  border-radius: 100px;
  padding: 7px 22px;
  font-size: .8rem;
  color: var(--text-secondary);
  min-height: 34px;
}
.model-test-switcher .btn:hover { background: rgba(255,255,255,.6); }
.model-test-switcher .btn.btn-primary {
  background: var(--bg-surface);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

/* ============================================================
   LLM CHAT
   ============================================================ */
.llm-shell {
  height: calc(100vh - 160px);
  max-height: calc(100vh - 150px);
  display: flex;
  flex-direction: column;
  background: var(--bg-surface);
  border: 1px solid var(--border-default);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

/* Empty state */
.llm-empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 40px 20px;
  background:
    radial-gradient(ellipse 60% 50% at 50% 40%, rgba(37,99,235,.04), transparent);
}
.llm-bot-avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
  background: linear-gradient(135deg, var(--brand-50) 0%, var(--brand-100) 40%, var(--brand-200) 100%);
  box-shadow: 0 8px 24px rgba(37,99,235,.18), inset 0 2px 0 rgba(255,255,255,.7);
  position: relative;
}
/* Subtle ring */
.llm-bot-avatar::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(37,99,235,.12);
  pointer-events: none;
}
.llm-empty-state h3 { font-size: 1.35rem; font-weight: 700; color: var(--text-primary); }
.llm-empty-state p { font-size: .95rem; color: var(--text-tertiary); max-width: 320px; }

/* Messages */
.llm-messages {
  display: none;
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px;
  scroll-behavior: smooth;
  background: #f8f6fc;
}
.llm-shell.has-messages .llm-empty-state { display: none; }
.llm-shell.has-messages .llm-messages {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.llm-message {
  max-width: 78%;
  padding: 10px 16px;
  border-radius: var(--r-md);
  font-size: .875rem;
  line-height: 1.5;
  word-break: break-word;
  animation: msgIn .3s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.llm-message-user {
  align-self: flex-end;
  background: linear-gradient(135deg, #2563eb, #3b82f6);
  color: #fff;
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 3px 10px rgba(37,99,235,.2);
}
.llm-message-assistant {
  align-self: flex-start;
  background: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-default);
  border-radius: 14px 14px 14px 4px;
  box-shadow: var(--shadow-xs);
}
.llm-message-meta { display: block; font-size: .6875rem; opacity: .65; margin-bottom: 8px; font-weight: 600; letter-spacing: .02em; }
.llm-message-body h1, .llm-message-body h2, .llm-message-body h3 { margin: 8px 0 4px; line-height: 1.3; }
.llm-message-body h1 { font-size: 1.2rem; }
.llm-message-body h2 { font-size: 1.08rem; }
.llm-message-body h3 { font-size: 1rem; }
.llm-message-body p { margin: 0 0 6px; }
.llm-message-body p:last-child { margin-bottom: 0; }
.llm-message-body ul, .llm-message-body ol { margin: 4px 0; padding-left: 18px; }
.llm-message-body li { margin-bottom: 2px; }
.llm-message-body code { background: rgba(0,0,0,.08); padding: 1px 4px; border-radius: 3px; font-family: "Fira Code", ui-monospace, monospace; font-size: .82em; }
.llm-message-body pre { background: #1e293b; color: #e2e8f0; padding: 10px 14px; border-radius: var(--r-sm); overflow-x: auto; margin: 6px 0; font-size: .75rem; line-height: 1.5; }
.llm-message-body pre code { background: none; padding: 0; color: inherit; font-size: inherit; }
.llm-message-body blockquote { border-left: 3px solid var(--border-default); margin: 8px 0; padding: 4px 12px; color: var(--text-secondary); }
.llm-message-body table { border-collapse: collapse; width: 100%; margin: 8px 0; font-size: .78rem; }
.llm-message-body th, .llm-message-body td { border: 1px solid var(--border-default); padding: 6px 10px; text-align: left; }
.llm-message-body th { background: var(--bg-subtle); font-weight: 600; }
.llm-message-body a { color: var(--brand-600); text-decoration: underline; }
.llm-message-body hr { border: none; border-top: 1px solid var(--border-light); margin: 12px 0; }
.llm-message-body strong { font-weight: 600; }
.llm-message-body em { font-style: italic; }
.llm-message-user .llm-message-body code { background: rgba(255,255,255,.15); }
.llm-message-user .llm-message-body a { color: #fff; text-decoration: underline; }
.llm-message-user .llm-message-body blockquote { border-left-color: rgba(255,255,255,.3); color: rgba(255,255,255,.85); }
.llm-msg-avatar {
  width: 28px; height: 28px;
  background: linear-gradient(135deg, #eff6ff, #dbeafe);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}
.typing-cursor {
  display: inline-block;
  width: 2px; height: 14px;
  background: var(--brand-600);
  animation: blink 1s step-end infinite;
  vertical-align: text-bottom;
  margin-left: 1px;
}

/* Composer */
.llm-composer-wrap { padding: 12px 20px; background: var(--bg-surface); border-top: 1px solid var(--border-light); }
.llm-composer {
  width: 100%;
  background: var(--bg-subtle);
  border: 1px solid var(--border-default);
  border-radius: var(--r-md);
  padding: 8px 10px;
  transition: all var(--t-base);
}
.llm-composer:focus-within {
  background: var(--bg-surface);
  border-color: var(--brand-200);
  box-shadow: 0 0 0 3px rgba(37,99,235,.08);
}
.llm-input {
  width: 100%;
  min-height: 40px;
  max-height: 120px;
  border: none;
  outline: none;
  resize: none;
  font-size: .88rem;
  line-height: 1.5;
  background: transparent;
  color: var(--text-primary);
}
.llm-input::placeholder { color: var(--text-tertiary); }
.llm-composer-actions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--border-light);
}

/* ============================================================
   TOGGLE SWITCH
   ============================================================ */
input[type="checkbox"][id="f-enabled"] {
  appearance: none;
  width: 44px; height: 26px;
  background: var(--border-strong);
  border-radius: 13px;
  position: relative;
  cursor: pointer;
  transition: background var(--t-base);
  border: none;
  vertical-align: middle;
  box-shadow: inset 0 1px 2px rgba(0,0,0,.08);
}
input[type="checkbox"][id="f-enabled"]::after {
  content: '';
  position: absolute;
  top: 2px; left: 2px;
  width: 22px; height: 22px;
  background: #fff;
  border-radius: 50%;
  transition: transform var(--t-base);
  box-shadow: 0 1px 3px rgba(0,0,0,.15), 0 1px 1px rgba(0,0,0,.06);
}
input[type="checkbox"][id="f-enabled"]:checked { background: var(--brand-600); }
input[type="checkbox"][id="f-enabled"]:checked::after { transform: translateX(18px); }

/* ============================================================
   UTILITY ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
#main { animation: fadeIn .25s ease; }

/* ============================================================
   SCROLLBARS
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-strong); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }
.result-box::-webkit-scrollbar-thumb { background: #3d3a6e; }
.result-box::-webkit-scrollbar-thumb:hover { background: #4d4a7e; }

/* ============================================================
   SELECTION
   ============================================================ */
::selection { background: rgba(37,99,235,.12); }

/* ============================================================
   SKELETON LOADING
   ============================================================ */
@keyframes skeleton-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .4; }
}
.skeleton {
  background: linear-gradient(90deg, var(--bg-subtle) 25%, var(--border-light) 50%, var(--bg-subtle) 75%);
  background-size: 200% 100%;
  animation: skeleton-pulse 1.8s ease-in-out infinite;
  border-radius: var(--r-xs);
}
.skeleton-row {
  display: grid;
  grid-template-columns: 60px 1fr 80px 80px 1fr 70px 70px 70px;
  gap: 12px;
  padding: 14px 16px;
  align-items: center;
}
.skeleton-row .skeleton { height: 16px; }
.skeleton-table {
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--r-lg);
  box-shadow: var(--shadow-sm);
  padding: 12px 0;
  display: flex;
  flex-direction: column;
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner {
  display: inline-block;
  width: 16px; height: 16px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin .5s linear infinite;
  vertical-align: -3px;
}
.btn:disabled,
.btn[disabled] {
  opacity: .6;
  cursor: not-allowed;
  pointer-events: none;
}
.btn.loading { pointer-events: none; }

/* ============================================================
   SEARCH INPUT
   ============================================================ */
.search-input {
  padding: 7px 14px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-sm);
  font-size: .8125rem;
  background: var(--bg-surface);
  color: var(--text-primary);
  min-width: 200px;
  transition: all var(--t-fast);
  box-shadow: var(--shadow-xs);
  font-family: inherit;
}
.search-input:focus {
  outline: none;
  border-color: var(--brand-500);
  box-shadow: var(--shadow-glow);
}
.search-input::placeholder { color: var(--text-tertiary); }

/* ============================================================
   PAGINATION
   ============================================================ */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin-top: 16px;
  padding: 10px 0;
}
.pagination button {
  padding: 6px 12px;
  border: 1px solid var(--border-default);
  border-radius: var(--r-xs);
  background: var(--bg-surface);
  color: var(--text-primary);
  font-size: .8rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--t-fast);
  min-width: 34px;
  text-align: center;
}
.pagination button:hover:not(:disabled) {
  background: var(--bg-subtle);
  border-color: var(--border-strong);
}
.pagination button:disabled {
  opacity: .4;
  cursor: default;
}
.pagination button.active {
  background: var(--brand-600);
  color: #fff;
  border-color: var(--brand-600);
  font-weight: 600;
}
.pagination-info {
  font-size: .78rem;
  color: var(--text-tertiary);
  margin: 0 8px;
}

/* ============================================================
   REDUCED MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
  .badge-green .badge-dot { animation: none; }
  .skeleton { animation: none; background: var(--bg-subtle); }
}

/* ============================================================
   NAV SVG ICONS
   ============================================================ */
.nav-icon { display: block; width: 20px; height: 20px; }
#nav-toggle .icon-close { display: none; }
#nav-toggle.open .icon-menu { display: none; }
#nav-toggle.open .icon-close { display: block; }

/* ============================================================
   RESPONSIVE — Large Desktop (≥1440px)
   ============================================================ */
@media (min-width: 1440px) {
  html { font-size: 17px; }
  #app { max-width: 1400px; }
}

/* ============================================================
   RESPONSIVE — Tablet (≤1024px)
   ============================================================ */
@media (max-width: 1024px) {
  #app { padding: 24px 20px 48px; }
  .llm-shell { height: calc(100vh - 220px); max-height: none; }
  .capability-page { min-height: auto; }
  .detail-grid { grid-template-columns: 120px 1fr; }
  .form, #form-title { max-width: 100%; }
}

/* ============================================================
   RESPONSIVE — Small Tablet / Large Phone (≤768px)
   ============================================================ */
@media (max-width: 768px) {
  html { font-size: 15px; }
  #app { padding: 14px 10px 32px; }

  /* Header */
  header { flex-wrap: wrap; gap: 10px; }
  header h1 { font-size: 1.05rem; }
  #nav-toggle { display: block; }
  nav {
    display: none;
    width: 100%;
    flex-direction: column;
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--r-md);
    padding: 4px;
    box-shadow: var(--shadow-md);
  }
  nav.open { display: flex; }
  nav a { padding: 11px 14px; font-size: .875rem; border-radius: var(--r-xs); }

  /* Capability tabs */
  .capability-tabs { flex-wrap: wrap; gap: 6px; }
  .tab-item { padding: 8px 14px; font-size: .8rem; }
  .tab-divider { display: none; }
  .list-toolbar-actions { width: 100%; margin-left: 0; padding: 8px 0; flex-wrap: wrap; }
  .list-toolbar .search-input { width: 100%; }

  /* Table → cards */
  .table, .table tbody, .table tr, .table td { display: block; width: 100%; }
  .table thead { display: none; }
  .table { border: none; background: transparent; box-shadow: none; border-radius: 0; }
  .table tbody { display: flex; flex-direction: column; gap: 10px; }
  .table tr {
    background: var(--bg-surface);
    border: 1px solid var(--border-default);
    border-radius: var(--r-md);
    padding: 4px 14px;
    box-shadow: var(--shadow-sm);
  }
  .table td {
    padding: 8px 0;
    border-bottom: 1px solid var(--border-light);
    border-right: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    font-size: .8125rem;
  }
  .table td:last-child { border-bottom: none; }
  .table td::before {
    content: attr(data-label);
    font-weight: 600;
    font-size: .6875rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: .04em;
    flex-shrink: 0;
  }
  .table td:last-child { justify-content: flex-start; gap: 6px; flex-wrap: wrap; }
  .table td:last-child::before { display: none; }
  .table tbody tr:nth-child(even),
  .table tbody tr:nth-child(odd) { background: var(--bg-surface); }

  /* Stats */
  .stats-row { grid-template-columns: repeat(2, 1fr); gap: 12px; }
  .stat-card { padding: 16px 18px; }
  .stat-card-icon { width: 36px; height: 36px; }
  .stat-card-icon svg { width: 18px; height: 18px; }
  .stat-card-value { font-size: 1.4rem; }
  .toolbar { padding: 10px 12px; }

  /* Detail */
  .detail-header-bar { flex-wrap: wrap; padding: 4px 0; }
  .detail-header-bar h2 { font-size: 1rem; width: 100%; }
  .detail-layout { gap: 14px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid dt {
    padding: 10px 14px 4px;
    background: transparent;
    border-bottom: none;
    font-size: .6875rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: .04em;
  }
  .detail-grid dd { padding: 0 14px 12px; border-bottom: 1px solid var(--border-light); }

  /* Form */
  .form-row-inline { grid-template-columns: 1fr; gap: 0; }
  .form-row-inline .form-row { margin-bottom: 20px; }
  .form { padding: 28px 24px; grid-template-columns: 1fr; gap: 0; }

  /* Action bar */
  .action-bar { gap: 6px; padding: 10px 12px; }

  /* Forms */
  .form { max-width: 100%; padding: 20px 16px; }

  /* Capability */
  .capability-topbar { flex-direction: column; gap: 14px; }
  .capability-select { min-width: 100%; }
  .capability-toolbar-inline { width: 100%; flex-direction: column; align-items: stretch; }
  .capability-toolbar-inline .capability-label { margin-bottom: 2px; }
  .capability-card { padding: 18px 14px; }
  .capability-list-header { flex-direction: column; align-items: stretch; }
  .capability-input-row { flex-direction: column; align-items: stretch; }
  .capability-textarea { min-height: 140px; }
  .capability-page-llm { gap: 14px; }

  /* LLM chat */
  .llm-shell { border-radius: var(--r-lg); height: calc(100vh - 160px); max-height: none; }
  .llm-messages { padding: 16px 14px; }
  .llm-message { max-width: 92%; padding: 9px 13px; font-size: .8125rem; }
  .llm-composer-wrap { padding: 10px 14px; }
  .llm-composer { padding: 6px 8px; }
  .llm-input { min-height: 38px; font-size: .85rem; }
  .llm-bot-avatar { width: 60px; height: 60px; font-size: 28px; }
  .llm-empty-state h3 { font-size: 1.2rem; }
  .llm-empty-state p { font-size: .85rem; }

  /* Modal */
  .modal-panel { margin: 2vh auto; padding: 16px 14px; max-height: 95vh; }
  .modal-textarea { min-height: 200px; }

  /* Search */
  .search-input { min-width: 0; flex: 1; }
  .toolbar { flex-wrap: wrap; }

  /* Skeleton */
  .skeleton-row { grid-template-columns: 1fr; gap: 8px; }

  /* Model test tabs */
  .model-test-switcher { flex-direction: row !important; flex-wrap: wrap; }
}

/* ============================================================
   RESPONSIVE — Phone (≤480px)
   ============================================================ */
@media (max-width: 480px) {
  html { font-size: 14px; }
  #app { padding: 10px 6px 28px; }

  header { padding: 0; }
  header h1 { font-size: .95rem; }

  .table tr { padding: 2px 10px; margin-bottom: 0; }
  .table td { padding: 7px 0; font-size: .75rem; }

  .action-bar .btn { flex: 1 1 auto; min-width: 0; font-size: .6875rem; padding: 5px 8px; }
  .action-bar { gap: 4px; padding: 8px 10px; }
  .curl-key-toggle { width: 100%; justify-content: flex-start; margin-top: 4px; }

  .form { padding: 24px 18px; grid-template-columns: 1fr; gap: 0; }
  .form-row { margin-bottom: 14px; }
  .form-actions .btn { flex: 1; }

  /* Stats */
  .stats-row { grid-template-columns: 1fr 1fr; gap: 10px; }
  .stat-card { padding: 14px 14px; }
  .stat-card-icon { width: 32px; height: 32px; }
  .stat-card-icon svg { width: 16px; height: 16px; }
  .stat-card-value { font-size: 1.3rem; }
  .toolbar { padding: 8px 10px; gap: 6px; }

  /* Detail */
  .detail-layout { gap: 12px; }
  .detail-section-title { padding: 10px 14px 8px; font-size: .6875rem; }
  .detail-grid { border-radius: var(--r-md); }
  .detail-grid dt { padding: 8px 10px 2px; }
  .detail-grid dd { padding: 0 10px 10px; }
  .detail-side .result-box { margin: 0 10px 10px; }
  .detail-side .invoke-target { margin: -8px 10px 0; }

  .llm-shell { border-radius: var(--r-md); height: calc(100vh - 140px); max-height: none; }
  .llm-messages { padding: 12px 10px; }
  .llm-message { max-width: 95%; padding: 8px 11px; font-size: .8125rem; }
  .llm-composer-wrap { padding: 8px 10px; }
  .llm-composer { padding: 5px 6px; border-radius: var(--r-md); }
  .llm-input { min-height: 36px; }
  .llm-composer-actions .btn { flex: 1; }
  .llm-bot-avatar { width: 52px; height: 52px; font-size: 24px; }
  .llm-empty-state { padding: 28px 16px; }

  .capability-card { padding: 14px 10px; border-radius: var(--r-md); }
  .capability-title { font-size: 1.2rem; }

  .modal-panel { padding: 14px 10px; border-radius: var(--r-md); margin: 1vh auto; }
  .modal-actions { flex-wrap: wrap; }
  .modal-actions .btn { flex: 1; }

  .btn { padding: 6px 14px; font-size: .75rem; min-height: 32px; }
  .btn-sm { padding: 4px 10px; font-size: .6875rem; min-height: 28px; }

  .model-test-switcher .btn { flex: 1; text-align: center; padding: 6px 10px; font-size: .7rem; }

  .search-input { width: 100%; min-width: 0; }

  .badge { padding: 2px 8px; font-size: .625rem; }
}

/* Thinking block (collapsible reasoning) */
.thinking-block {
  margin-bottom: 8px;
  border-left: 3px solid #8b5cf6;
  border-radius: 4px;
  background: rgba(139, 92, 246, 0.05);
}
.thinking-block summary {
  padding: 6px 10px;
  cursor: pointer;
  font-size: 0.85em;
  color: #8b5cf6;
  user-select: none;
}
.thinking-block .thinking-content {
  padding: 4px 10px 8px;
  font-size: 0.85em;
  color: #666;
  max-height: 300px;
  overflow-y: auto;
}

/* ── ASR Upload Zone ─────────────────────────────────────────── */
.asr-upload-zone {
  border: 2px dashed var(--border-default);
  border-radius: var(--r-lg);
  padding: 28px 20px;
  text-align: center;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  color: var(--text-tertiary);
  margin-bottom: 16px;
}
.asr-upload-zone:hover,
.asr-upload-zone.drag-over {
  border-color: var(--brand-400);
  background: var(--brand-50);
}
.asr-upload-zone.has-file {
  border-color: var(--green-500);
  background: var(--green-50);
}
.asr-upload-zone svg {
  margin-bottom: 8px;
  opacity: .6;
}
.asr-upload-zone p {
  margin: 0;
  font-size: .85rem;
}
.asr-file-name {
  margin-top: 6px;
  font-weight: 600;
  color: var(--text-secondary);
}
.asr-params {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.asr-params .capability-input,
.asr-params .capability-select {
  width: 100%;
  box-sizing: border-box;
}
