:root {
  color-scheme: dark;
  --bg: #0f172a;
  --bg-start: #020617;
  --glow: rgba(56, 189, 248, 0.1);
  --topbar: rgba(15, 23, 42, 0.8);
  --panel: #1e293b;
  --panel-soft: #334155;
  --surface: #0f172a;
  --surface-2: #1e293b;
  --surface-3: #334155;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.15);
  --text: #cbd5e1;
  --text-strong: #f8fafc;
  --muted: #64748b;
  --table-head: #0f172a;
  --table-text: #e2e8f0;
  
  --green: #10b981;
  --blue: #3b82f6;
  --blue-hover: #2563eb;
  --cyan: #0ea5e9;
  --yellow: #f59e0b;
  --red: #ef4444;
  --red-bright: #f87171;
  
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --ring: rgba(59, 130, 246, 0.5);
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #f8fafc;
  --bg-start: #f1f5f9;
  --glow: rgba(56, 189, 248, 0.15);
  --topbar: rgba(255, 255, 255, 0.8);
  --panel: #ffffff;
  --panel-soft: #f1f5f9;
  --surface: #f8fafc;
  --surface-2: #ffffff;
  --surface-3: #e2e8f0;
  --line: #e2e8f0;
  --line-strong: #cbd5e1;
  --text: #475569;
  --text-strong: #0f172a;
  --muted: #94a3b8;
  --table-head: #f8fafc;
  --table-text: #334155;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
}

* { box-sizing: border-box; }

body {
  margin: 0; min-height: 100vh;
  background: radial-gradient(circle at top left, var(--glow), transparent 40%), linear-gradient(180deg, var(--bg-start) 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Inter", "Microsoft YaHei", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

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

.topbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 24px;
  height: 56px; padding: 0 24px;
  background: var(--topbar);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand {
  display: flex; align-items: center; gap: 10px;
  color: var(--text-strong); text-decoration: none; font-weight: 600; letter-spacing: -0.02em;
}

.brand-mark {
  position: relative; width: 24px; height: 24px; border-radius: 6px;
  background: linear-gradient(135deg, var(--cyan), var(--blue));
  box-shadow: var(--shadow-sm); display: flex; align-items: center; justify-content: center;
}

.signal-dot { width: 6px; height: 6px; background: white; border-radius: 50%; box-shadow: 0 0 10px rgba(255,255,255,0.8); }

.version {
  padding: 2px 8px; border-radius: 999px;
  background: rgba(59, 130, 246, 0.15); color: var(--blue); font-size: 11px; font-weight: 700;
}

.nav-tabs { display: flex; gap: 8px; height: 100%; align-items: center; flex: 1; }

.nav-tab {
  padding: 6px 14px; border: none; border-radius: 6px;
  color: var(--muted); background: transparent; cursor: pointer; font-weight: 500; font-size: 14px; transition: all 0.2s ease;
}
.nav-tab:hover { color: var(--text-strong); background: var(--line); }
.nav-tab.active { color: var(--text-strong); background: var(--panel-soft); box-shadow: var(--shadow-sm); }

.theme-toggle {
  height: 32px; border: 1px solid var(--line-strong); border-radius: 999px;
  padding: 0 16px; background: transparent; color: var(--text); font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.2s;
}
.theme-toggle:hover { background: var(--panel-soft); color: var(--text-strong); }

.workspace { max-width: 1200px; margin: 0 auto; padding: 32px 20px 64px; }
.view { display: none; animation: fadeIn 0.3s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
.view.active { display: grid; gap: 24px; }

.panel {
  border: 1px solid var(--line); border-radius: 16px; background: var(--panel);
  box-shadow: var(--shadow-lg); padding: 28px; transition: box-shadow 0.3s ease;
}

.panel-heading, .result-head { display: flex; align-items: flex-start; justify-content: space-between; margin-bottom: 24px; }

.eyebrow { margin: 0 0 4px; color: var(--blue); font-size: 12px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }

h1, h2 { margin: 0; color: var(--text-strong); font-weight: 600; letter-spacing: -0.02em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }

.status-pill {
  padding: 4px 12px; border-radius: 999px; background: var(--surface-3);
  color: var(--text); font-size: 12px; font-weight: 500; border: 1px solid var(--line);
}
.status-pill.running { background: rgba(16, 185, 129, 0.1); color: var(--green); border-color: rgba(16, 185, 129, 0.2); }
.status-pill.ok { background: rgba(14, 165, 233, 0.1); color: var(--cyan); border-color: rgba(14, 165, 233, 0.2); }

.field-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 16px; }
.field-grid.two { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.field-grid.three { grid-template-columns: 300px minmax(0, 1fr); }
.field { display: grid; gap: 8px; margin-bottom: 16px; }
.field.full { grid-column: 1 / -1; }

.field span, .hint { color: var(--text); font-size: 13px; font-weight: 500; }
.hint { color: var(--muted); line-height: 1.6; margin: 0; }

select, input, textarea {
  width: 100%; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); color: var(--text-strong); outline: none; font-size: 14px; transition: all 0.2s ease;
}
select, input { height: 44px; padding: 0 16px; }
textarea { min-height: 100px; resize: vertical; padding: 12px 16px; line-height: 1.5; }

select:hover, input:hover, textarea:hover { border-color: var(--muted); }
select:focus, input:focus, textarea:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--ring); background: var(--panel); }

.actions, .tool-actions, .header-actions { display: flex; gap: 12px; margin-top: 24px; align-items: center;}
.header-actions { margin-top: 0; }

.input-with-actions { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }

.mini-action {
  height: 44px; padding: 0 16px; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface-2); color: var(--text); cursor: pointer; font-weight: 500; transition: all 0.2s;
}
.mini-action:hover { background: var(--surface-3); color: var(--text-strong); }

/* 全新滚动列表 UI */
.scrollable-list {
  height: 180px; overflow-y: auto; border: 1px solid var(--line-strong); border-radius: 8px;
  background: var(--surface); padding: 8px; display: flex; flex-direction: column; gap: 6px;
}
.scrollable-list::-webkit-scrollbar { width: 6px; }
.scrollable-list::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: 4px; }

.list-item {
  display: flex; align-items: center; justify-content: space-between;
  min-height: 38px; padding: 0 12px; border: 1px solid var(--line); border-radius: 6px;
  background: var(--surface-2); color: var(--text); font-size: 13px; cursor: pointer; transition: all 0.2s;
}
.list-item:hover { border-color: var(--muted); }
.list-item.active { border-color: var(--blue); background: rgba(59, 130, 246, 0.1); color: var(--blue); font-weight: 600; }

.list-item-delete {
  color: var(--muted); font-size: 18px; line-height: 1; width: 24px; height: 24px;
  display: flex; align-items: center; justify-content: center; border-radius: 4px; transition: all 0.2s;
}
.list-item-delete:hover { background: rgba(239, 68, 68, 0.15); color: var(--red-bright); }


button {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; padding: 0 24px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 600; cursor: pointer; transition: all 0.2s ease;
}
.primary-btn { background: var(--text-strong); color: var(--bg); box-shadow: var(--shadow-sm); }
.primary-btn:hover:not(:disabled) { transform: translateY(-1px); box-shadow: var(--shadow); opacity: 0.9; }
.secondary-btn { background: var(--surface-3); color: var(--text-strong); }
.secondary-btn:hover:not(:disabled) { background: var(--line-strong); }
.danger-btn { background: rgba(239, 68, 68, 0.1); color: var(--red-bright); }
.danger-btn:hover:not(:disabled) { background: var(--red); color: white; }
.ghost-btn { height: 32px; padding: 0 12px; background: transparent; color: var(--muted); font-size: 13px; }
.ghost-btn:hover { background: var(--surface-3); color: var(--text-strong); }
button:disabled { opacity: 0.5; cursor: not-allowed; }

.metrics { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 16px; margin-bottom: 24px; }
.metrics article { padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
.metrics span { color: var(--muted); font-size: 13px; font-weight: 500; }
.metrics strong { display: block; margin-top: 8px; color: var(--text-strong); font-size: 24px; }

.progress-wrap { margin-bottom: 24px; }
.progress-label { display: flex; justify-content: space-between; margin-bottom: 8px; color: var(--muted); font-size: 13px; font-weight: 500;}
.progress-bar { height: 6px; border-radius: 999px; background: var(--surface-3); overflow: hidden; }
.progress-bar span { display: block; height: 100%; background: var(--blue); transition: width 0.3s ease; }

.log-list {
  display: grid; gap: 8px; max-height: 280px; overflow-y: auto; margin: 0; padding: 16px;
  list-style: none; background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace; font-size: 13px;
}
.log-list li { color: var(--muted); line-height: 1.5; }
.log-list li:first-child { color: var(--text-strong); }

.tool-row { display: flex; gap: 16px; margin-bottom: 24px; }
.tool-row textarea { flex: 1; margin: 0; }
.tool-actions { flex-direction: column; margin: 0; gap: 8px; }
.tool-actions button { width: 100%; }

.validation-board, .result-board, .generator-board, .stats-board {
  padding: 24px; border: 1px solid var(--line); border-radius: 16px; background: var(--surface-2); margin-bottom: 24px;
}
.result-board { padding: 0; border: none; background: transparent; }

/* 强制隐藏类 - 解决收纳失效问题 */
.collapsed-block { display: none !important; }

.result-card {
  display: flex; justify-content: space-between; align-items: center;
  padding: 20px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); transition: all 0.2s; margin-bottom: 12px;
}
.result-card:hover { border-color: var(--line-strong); transform: translateY(-1px); box-shadow: var(--shadow); }

.result-card-label { color: var(--muted); font-size: 12px; font-weight: 600; text-transform: uppercase; }
.result-card strong { display: block; margin: 4px 0 8px; color: var(--text-strong); font-size: 18px; font-family: monospace; }
.result-card p { color: var(--text); font-size: 14px; margin: 0 0 16px; }

.result-meta { display: flex; gap: 8px; flex-wrap: wrap; }
.result-chip { padding: 4px 10px; border-radius: 6px; background: var(--surface-3); color: var(--text); font-size: 12px; font-weight: 500; }
.result-latency { padding: 6px 14px; border-radius: 8px; background: rgba(16, 185, 129, 0.1); color: var(--green); font-weight: 600; font-size: 16px; }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 14px 16px; border-bottom: 1px solid var(--line); font-size: 14px; }
th { color: var(--muted); font-weight: 600; font-size: 13px; text-transform: uppercase; letter-spacing: 0.05em; }
td { color: var(--text-strong); }
tr:last-child td { border-bottom: none; }
tr:hover td { background: var(--surface-2); }

.tag { padding: 4px 8px; border-radius: 6px; font-size: 12px; font-weight: 600; background: var(--surface-3); color: var(--muted); }
.tag.valid { background: rgba(16, 185, 129, 0.1); color: var(--green); }
.tag.invalid, .tag.error { background: rgba(239, 68, 68, 0.1); color: var(--red); }
.tag.checking { background: rgba(245, 158, 11, 0.1); color: var(--yellow); }

.row-btn { height: 28px; padding: 0 12px; border-radius: 6px; background: var(--surface-3); color: var(--text); font-size: 12px; }
.row-btn:hover { background: var(--blue); color: white; }

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.filter-label { color: var(--muted); font-size: 13px; font-weight: 600; margin-right: 8px; }
.filter-chip { height: 32px; padding: 0 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--text); font-size: 13px; cursor: pointer;}
.filter-chip.active { background: var(--text-strong); color: var(--bg); border-color: var(--text-strong); }

@media (max-width: 980px) {
  .field-grid, .field-grid.two, .field-grid.three { grid-template-columns: 1fr; }
  .tool-row { flex-direction: column; }
  .tool-actions { flex-direction: row; width: 100%; }
  .tool-actions button { flex: 1; }
}

@media (max-width: 640px) {
  .topbar { padding: 0 16px; height: auto; flex-wrap: wrap; padding-bottom: 12px; }
  .workspace { padding: 16px 12px 32px; }
  .panel { padding: 20px 16px; }
  .result-card { flex-direction: column; align-items: flex-start; }
  .result-card-side { margin-top: 16px; width: 100%; }
  .result-latency { width: 100%; text-align: center; }
}