/* ===== Design tokens ===== */
:root {
  --page: #f4f5f8;
  --page-glow-a: rgba(99, 102, 241, .10);
  --page-glow-b: rgba(20, 184, 166, .09);
  --surface: #ffffff;
  --surface-2: #f8f9fb;
  --surface-3: #eef0f4;
  --ink: #0f1420;
  --ink-2: #2b3242;
  --muted: #6a7284;
  --faint: #9aa1b1;
  --line: #e4e7ee;
  --line-strong: #d2d7e1;
  --accent: #4f46e5;
  --accent-2: #6366f1;
  --accent-ink: #ffffff;
  --accent-soft: #eef0ff;
  --accent-line: #c9cdfb;
  --green: #0f8a5f;
  --green-soft: #e6f6ef;
  --green-line: #bfe6d3;
  --blue: #2563eb;
  --blue-soft: #e9f0ff;
  --blue-line: #c4d6fb;
  --red: #d23a4a;
  --red-soft: #fdecee;
  --red-line: #f5c3ca;
  --amber: #a16207;
  --amber-soft: #fef5dc;
  --amber-line: #f2dc9e;
  --violet: #7c3aed;
  --violet-soft: #f3ecff;
  --violet-line: #dccbfb;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow-sm: 0 1px 2px rgba(15, 20, 32, .05);
  --shadow: 0 1px 2px rgba(15, 20, 32, .04), 0 8px 28px rgba(15, 20, 32, .06);
  --shadow-lg: 0 24px 64px rgba(15, 20, 32, .18);
  --ring: 0 0 0 4px rgba(79, 70, 229, .16);
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --page: #0b0d13;
    --page-glow-a: rgba(99, 102, 241, .16);
    --page-glow-b: rgba(20, 184, 166, .10);
    --surface: #12151d;
    --surface-2: #171b25;
    --surface-3: #1e2330;
    --ink: #eef0f6;
    --ink-2: #cfd3df;
    --muted: #8d94a6;
    --faint: #646b7d;
    --line: #242a37;
    --line-strong: #323a4b;
    --accent: #818cf8;
    --accent-2: #a5b4fc;
    --accent-ink: #0b0d13;
    --accent-soft: rgba(129, 140, 248, .13);
    --accent-line: rgba(129, 140, 248, .35);
    --green: #34d399;
    --green-soft: rgba(52, 211, 153, .12);
    --green-line: rgba(52, 211, 153, .32);
    --blue: #60a5fa;
    --blue-soft: rgba(96, 165, 250, .12);
    --blue-line: rgba(96, 165, 250, .32);
    --red: #f87171;
    --red-soft: rgba(248, 113, 113, .12);
    --red-line: rgba(248, 113, 113, .32);
    --amber: #fbbf24;
    --amber-soft: rgba(251, 191, 36, .12);
    --amber-line: rgba(251, 191, 36, .3);
    --violet: #c4b5fd;
    --violet-soft: rgba(196, 181, 253, .12);
    --violet-line: rgba(196, 181, 253, .3);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3);
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 10px 30px rgba(0, 0, 0, .28);
    --shadow-lg: 0 24px 64px rgba(0, 0, 0, .55);
    --ring: 0 0 0 4px rgba(129, 140, 248, .22);
  }
}

:root[data-theme="dark"] {
  --page: #0b0d13;
  --surface: #12151d;
  --surface-2: #171b25;
  --surface-3: #1e2330;
  --ink: #eef0f6;
  --muted: #8d94a6;
  --line: #242a37;
  --line-strong: #323a4b;
}

/* ===== Base ===== */
* { box-sizing: border-box; }
*::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-width: 320px;
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font: 14px/1.6 Inter, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  -webkit-font-smoothing: antialiased;
}

.backdrop {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(900px 480px at 8% -8%, var(--page-glow-a), transparent 60%),
    radial-gradient(760px 420px at 100% 0%, var(--page-glow-b), transparent 60%);
}

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

button { cursor: pointer; }
button:disabled { cursor: not-allowed; }
button:focus-visible, input:focus-visible, select:focus-visible, dialog:focus-visible {
  outline: none;
  box-shadow: var(--ring);
}

h1, h2, h3, h4, p { margin: 0; }

/* ===== Top bar ===== */
.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
}

.topbar-inner, .shell, .page-footer {
  max-width: 960px;
  margin: 0 auto;
  padding-left: 24px;
  padding-right: 24px;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 9px;
  color: #fff;
  background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 55%, #14b8a6 130%);
}

.brand-text { display: flex; align-items: baseline; gap: 10px; min-width: 0; }
.brand h1 { font-size: 15px; font-weight: 700; line-height: 1.25; white-space: nowrap; }
.brand p { overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.top-actions { display: flex; align-items: center; gap: 8px; }
.config-toggle { color: var(--ink-2); }

/* ===== Buttons ===== */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid transparent;
  border-radius: 10px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  transition: background .16s ease, border-color .16s ease, color .16s ease, filter .16s ease;
}

.button:disabled { opacity: .45; }
.button-icon { font-size: 13px; line-height: 1; }
.button-label { line-height: 1; }

.button-primary { color: #fff; background: var(--accent); }
.button-primary:hover:not(:disabled) { filter: brightness(1.08); }

.button-ghost, .button-muted { color: var(--ink-2); border-color: var(--line); background: var(--surface); }
.button-ghost:hover:not(:disabled), .button-muted:hover:not(:disabled) { border-color: var(--line-strong); background: var(--surface-2); }

.button-accent { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.button-accent:hover:not(:disabled) { border-color: var(--accent); }

.button-danger { color: #fff; background: var(--red); }
.button-danger:hover:not(:disabled) { filter: brightness(1.08); }

.icon-button {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--muted);
  background: var(--surface);
  font-size: 16px;
  line-height: 1;
}

.icon-button:hover { color: var(--ink); border-color: var(--line-strong); background: var(--surface-2); }
.icon-button:disabled { opacity: .45; }
#configToggle[aria-expanded="true"] { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }

.spinner { display: inline-block; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ===== Layout ===== */
.shell {
  display: grid;
  gap: 20px;
  padding-top: 24px;
  padding-bottom: 32px;
}

.card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.config-band.collapsed { display: none; }

/* ===== Config ===== */
.config-card { display: grid; gap: 18px; padding: 22px 24px; }

.card-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.card-title { min-width: 0; }
.card-title h2 { font-size: 18px; font-weight: 700; line-height: 1.3; }
.card-title p { margin-top: 2px; color: var(--muted); font-size: 12.5px; }

.protocol-chip {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--muted);
  font: 600 11.5px/1.4 var(--mono);
  white-space: nowrap;
}

.chip-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--green); }

.config-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 14px;
}

.field { display: grid; gap: 6px; min-width: 0; }
.field label, .context-settings label, .access-form label {
  color: var(--ink-2);
  font-size: 12.5px;
  font-weight: 600;
}

.field input, .context-settings input, .access-form input {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  transition: border-color .16s ease, background .16s ease, box-shadow .16s ease;
}

.field input::placeholder { color: var(--faint); }
.field input:hover, .context-settings input:hover { border-color: var(--line-strong); }
.field input:focus, .context-settings input:focus, .access-form input:focus {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
  box-shadow: var(--ring);
}

.input-action { position: relative; }
.input-action input { padding-right: 46px; font-family: var(--mono); font-size: 13px; }

.inside-button {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: transparent;
  transform: translateY(-50%);
}

.inside-button:hover, .inside-button[aria-pressed="true"] { color: var(--accent); background: var(--accent-soft); }

.context-settings {
  display: grid;
  grid-template-columns: auto 160px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid var(--amber-line);
  border-radius: 10px;
  background: var(--amber-soft);
}

.context-settings input { min-height: 36px; font-family: var(--mono); background: var(--surface); }
.context-settings span { color: var(--muted); font-size: 12px; }

.form-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.form-options { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; min-width: 0; }

.model-fixed {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  background: var(--surface-2);
  font: 600 12.5px/1 var(--mono);
}

.model-fixed-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }

.toggle {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  padding: 0 12px 0 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface-2);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  user-select: none;
}

.toggle em { color: var(--amber); font-size: 11px; font-style: normal; font-weight: 700; }
.toggle input { position: absolute; opacity: 0; pointer-events: none; }

.toggle span {
  position: relative;
  width: 30px;
  height: 18px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background .18s ease;
}

.toggle span::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #fff;
  transition: transform .18s ease;
}

.toggle input:checked + span { background: var(--amber); }
.toggle input:checked + span::after { transform: translateX(12px); }
.toggle input:focus-visible + span { box-shadow: var(--ring); }

.form-error { flex: 1 1 160px; min-width: 0; color: var(--red); font-size: 12.5px; font-weight: 600; text-align: right; }
.form-error:empty { flex-basis: 0; }
.form-actions #startButton { min-width: 132px; min-height: 40px; margin-left: auto; }

/* ===== Report ===== */
.report { display: grid; gap: 14px; }

.report-top { display: grid; }

.report-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  min-width: 0;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.report-title { display: grid; gap: 2px; min-width: 0; }
.report-heading h2 { font-size: 17px; font-weight: 700; line-height: 1.3; }
.report-heading p { overflow: hidden; color: var(--muted); font: 500 12px/1.5 var(--mono); text-overflow: ellipsis; white-space: nowrap; }

.run-state {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
  padding: 4px 10px 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--ink-2);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}

.state-dot { position: relative; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.state-dot:not(.done):not(.failed):not(.warn)::after {
  content: "";
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: .5;
  animation: pulse 1.4s ease-out infinite;
}
.state-dot.done { background: var(--green); }
.state-dot.warn { background: var(--amber); }
.state-dot.failed { background: var(--red); }
@keyframes pulse { from { transform: scale(.6); opacity: .6; } to { transform: scale(1.5); opacity: 0; } }

.report-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 20px;
}

.report-controls { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-width: 0; }
.report-controls .button { min-height: 34px; padding: 0 12px; }
.report-controls .icon-button { width: 34px; height: 34px; }

.segmented {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.detail-access-status, .detail-access-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 7px;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
}

.detail-access-status { color: var(--ink); background: var(--surface); box-shadow: var(--shadow-sm); }
.detail-access-status.unlocked { color: var(--accent); background: var(--accent-soft); box-shadow: none; }
.detail-access-button { color: var(--muted); background: transparent; }
.detail-access-button:hover { color: var(--ink); background: var(--surface); }
.detail-access-button:disabled { opacity: .45; }
.detail-access-button.unlocked { color: var(--ink-2); }
.detail-access-icon { font-size: 12px; line-height: 1; }

.share-button.copied { color: var(--green); border-color: var(--green-line); background: var(--green-soft); }

/* ===== Summary ===== */
.summary-band {
  display: grid;
  gap: 6px;
  padding: 16px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.summary-title { color: var(--muted); font-size: 12px; font-weight: 700; }
.summary-text { min-width: 0; color: var(--ink); font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }

/* 只测一个固定模型，统计格与模型卡重复，不展示 */
.summary-stats { display: none; }
.summary-stat strong { color: var(--ink); font: 700 16px/1.2 var(--mono); }
.summary-stat.verified strong { color: var(--violet); }
.summary-stat.official strong { color: var(--blue); }
.summary-stat.uncertain strong { color: var(--amber); }
.summary-stat.failed strong { color: var(--red); }

/* ===== Model cards ===== */
.model-grid { display: grid; grid-template-columns: minmax(0, 1fr); gap: 14px; }

.model-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.model-card.running { border-color: var(--accent-line); }
.model-card.failed { border-color: var(--red-line); }
.model-card.cancelled { opacity: .85; }

.model-header { display: grid; gap: 8px; padding: 16px 20px 0; }

.model-title-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  min-width: 0;
}

.model-name { min-width: 0; font: 700 15px/1.3 var(--mono); overflow-wrap: anywhere; }

.channel-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 26px;
  padding: 3px 11px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 700;
  line-height: 1.4;
}

.channel-badge::before { content: ""; flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.channel-badge.max { color: var(--violet); background: var(--violet-soft); border-color: var(--violet-line); }
.channel-badge.official { color: var(--blue); background: var(--blue-soft); border-color: var(--blue-line); }
.channel-badge.reverse { color: var(--red); background: var(--red-soft); border-color: var(--red-line); }
.channel-badge.site { color: var(--green); background: var(--green-soft); border-color: var(--green-line); }
.channel-badge.unknown, .channel-badge.pending { color: var(--muted); background: var(--surface-3); border-color: var(--line); }

.model-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  color: var(--muted);
  font-size: 12px;
}

.model-meta span:empty { display: none; }

.channel-reason { color: var(--ink-2); font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.channel-reason:empty { display: none; }

.progress-track { height: 3px; margin: 4px 0 14px; overflow: hidden; border-radius: 999px; background: var(--surface-3); }
.progress-track span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent); transition: width .35s ease; }
.model-card.completed .progress-track span { background: var(--green); }
.model-card.failed .progress-track span { background: var(--red); }
.model-card.cancelled .progress-track span { background: var(--faint); }

.model-alerts { display: grid; gap: 8px; margin: 0 20px 12px; }

.model-alert, .model-error {
  padding: 9px 12px;
  border: 1px solid var(--red-line);
  border-radius: 10px;
  color: var(--red);
  background: var(--red-soft);
  font-size: 12.5px;
  overflow-wrap: anywhere;
}

.model-alert { display: flex; gap: 8px; font-weight: 600; }
.model-alert::before { content: "!"; font-weight: 800; }
.model-error { margin: 0 20px 12px; }

.phase-label {
  padding: 10px 20px 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.phase-list { display: grid; gap: 8px; padding: 0 12px 12px; }

.empty-phase {
  padding: 20px 12px;
  border: 1px dashed var(--line-strong);
  border-radius: 10px;
  color: var(--faint);
  text-align: center;
  font-size: 13px;
}

.empty-phase.locked { color: var(--muted); }

.phase {
  min-width: 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-left-width: 3px;
  border-radius: 10px;
  background: var(--surface-2);
}

.phase.pass { border-left-color: var(--green); }
.phase.fail { border-left-color: var(--red); }
.phase.warn { border-left-color: var(--amber); }
.phase.skip { border-left-color: var(--line-strong); }
.phase.running { border-left-color: var(--accent); }

.phase-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
}

.phase h4 { min-width: 0; font-size: 13px; font-weight: 650; overflow-wrap: anywhere; }

.phase-status {
  flex: 0 0 auto;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 700;
  white-space: nowrap;
}

.phase-status.pass { color: var(--green); background: var(--green-soft); }
.phase-status.fail { color: var(--red); background: var(--red-soft); }
.phase-status.warn { color: var(--amber); background: var(--amber-soft); }
.phase-status.skip { color: var(--muted); background: var(--surface-3); }
.phase-status.running { color: var(--accent); background: var(--accent-soft); }

.phase-summary { padding: 0 12px 9px; color: var(--muted); font-size: 12.5px; overflow-wrap: anywhere; }

.checks { border-top: 1px solid var(--line); background: var(--surface); }

.check-row {
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr);
  gap: 12px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12.5px;
}

.check-row:last-child { border-bottom: 0; }
.check-label { min-width: 0; color: var(--ink-2); font-weight: 600; overflow-wrap: anywhere; }

.check-value {
  min-width: 0;
  display: flex;
  gap: 7px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 12px;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.check-value::before { content: "✓"; flex: 0 0 auto; color: var(--green); font-weight: 800; }
.check-row.fail .check-value { color: var(--red); }
.check-row.fail .check-value::before { content: "×"; color: var(--red); }
.check-row.warn .check-value { color: var(--amber); }
.check-row.warn .check-value::before { content: "!"; color: var(--amber); }
.check-row.skip .check-value { color: var(--faint); }
.check-row.skip .check-value::before { content: "–"; color: var(--faint); }

.check-longtext {
  min-width: 0;
  grid-column: 1 / -1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface-2);
}

.check-longtext summary { padding: 7px 10px; color: var(--accent); font-size: 12px; font-weight: 600; cursor: pointer; }

.check-longtext-body {
  max-width: 100%;
  max-height: 420px;
  margin: 0;
  padding: 10px;
  border-top: 1px solid var(--line);
  overflow: auto;
  color: var(--ink-2);
  font: 12px/1.6 var(--mono);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
  word-break: break-word;
}

.metrics-wrap { overflow-x: auto; border-top: 1px solid var(--line); background: var(--surface); }
.metrics { width: 100%; border-collapse: collapse; font: 12px/1.5 var(--mono); }
.metrics th, .metrics td { padding: 7px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.metrics th { color: var(--muted); font-family: inherit; font-weight: 600; background: var(--surface-2); }
.metrics th:first-child, .metrics td:first-child { text-align: left; }
.metric-ok { color: var(--green); font-weight: 800; }
.metric-warn { color: var(--amber); font-weight: 800; }
.metric-bad { color: var(--red); font-weight: 800; }
.metric-skip { color: var(--faint); }

.coarse-model-summary {
  display: grid;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
}

.coarse-model-summary > div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
}

.coarse-model-summary > div:last-child { border-bottom: 0; }
.coarse-model-summary span { flex: 0 0 auto; color: var(--muted); font-size: 12.5px; }
.coarse-model-summary strong { min-width: 0; font-size: 13px; font-weight: 650; text-align: right; overflow-wrap: anywhere; }

.model-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
  background: var(--surface-2);
}

.model-footer span { color: var(--muted); font-size: 12px; }
.final-score { font: 700 16px/1 var(--mono); }

/* ===== History ===== */
.history-inner {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}

.history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 12px 20px;
  border-bottom: 1px solid var(--line);
}

.history-head h2 { font-size: 15px; font-weight: 700; }
.history-head small { margin-left: 6px; color: var(--faint); font-size: 12px; font-weight: 500; }
.history-actions { display: flex; align-items: center; gap: 8px; }
.history-actions .button { min-height: 32px; padding: 0 12px; font-size: 12.5px; }
.history-actions .icon-button { width: 32px; height: 32px; font-size: 15px; }

.history-list { display: grid; }

/* 徽标完整显示、地址单独截断，两者各占一列不会重叠 */
.history-row {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr) max-content;
  grid-template-areas: "badge host time";
  align-items: center;
  gap: 14px;
  width: 100%;
  min-width: 0;
  padding: 10px 20px;
  border: 0;
  border-bottom: 1px solid var(--line);
  color: inherit;
  background: transparent;
  text-align: left;
}

.history-row:last-child { border-bottom: 0; }
.history-row:hover { background: var(--surface-2); }

.history-badge {
  grid-area: badge;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
}

.history-badge.max { color: var(--violet); background: var(--violet-soft); }
.history-badge.official { color: var(--blue); background: var(--blue-soft); }
.history-badge.reverse { color: var(--red); background: var(--red-soft); }
.history-badge.site { color: var(--green); background: var(--green-soft); }
.history-badge.uncertain { color: var(--amber); background: var(--amber-soft); }
.history-badge.failed { color: var(--muted); background: var(--surface-3); }

.history-host { grid-area: host; min-width: 0; overflow: hidden; font: 500 13px/1.4 var(--mono); text-overflow: ellipsis; white-space: nowrap; }
/* 模型固定为同一个，历史里不再重复显示 */
.history-model { display: none; }
.history-time { grid-area: time; color: var(--faint); font: 12px/1.4 var(--mono); white-space: nowrap; }
.history-empty { padding: 28px 20px; color: var(--faint); text-align: center; }

.page-footer {
  padding-bottom: 28px;
  color: var(--faint);
  font-size: 12px;
  text-align: center;
}

/* ===== Dialogs ===== */
.access-dialog {
  width: min(400px, calc(100vw - 32px));
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 16px;
  color: var(--ink);
  background: var(--surface);
  box-shadow: var(--shadow-lg);
}

.access-dialog[open] { animation: dialog-in .18s ease; }
.access-dialog::backdrop { background: rgba(8, 10, 16, .45); backdrop-filter: blur(4px); }
@keyframes dialog-in { from { opacity: 0; transform: translateY(8px) scale(.98); } }

.access-form { display: grid; gap: 10px; padding: 20px; }

.access-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}

.access-dialog-head h2 { font-size: 16px; font-weight: 700; }
.access-dialog-close { width: 30px; height: 30px; font-size: 18px; }
.access-form input { min-height: 42px; }
#shareLinkInput { font: 12.5px var(--mono); }
.access-error { min-height: 18px; color: var(--red); font-size: 12.5px; font-weight: 600; }
.access-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

/* ===== Hidden helpers ===== */
.share-copy-buffer,
.export-measure-host {
  position: fixed;
  top: 0;
  left: -10000px;
  opacity: 0;
  pointer-events: none;
}

.share-copy-buffer { width: 1px; height: 1px; }
.export-measure-host { min-height: 1px; }
.export-report { padding: 24px !important; }

/* ===== Responsive ===== */
@media (max-width: 700px) {
  .topbar-inner, .shell, .page-footer { padding-left: 16px; padding-right: 16px; }
  .brand p { display: none; }
  .shell { gap: 14px; padding-top: 16px; }
  .config-card { padding: 18px 16px; gap: 16px; }
  .card-head { flex-direction: column; gap: 8px; }
  .config-fields { grid-template-columns: minmax(0, 1fr); }
  .context-settings { grid-template-columns: minmax(0, 1fr); gap: 8px; }
  .form-error { flex-basis: 100%; order: 3; text-align: left; }
  .form-actions #startButton { width: 100%; margin-left: 0; }
  .report-heading { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px 16px; }
  .report-heading p { white-space: normal; overflow-wrap: anywhere; }
  .report-toolbar { flex-direction: column; align-items: stretch; padding: 10px 16px 14px; }
  .segmented > * { flex: 1 1 0; justify-content: center; }
  .report-controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)) auto; }
  .report-controls .share-button, #cancelButton { grid-column: 1 / -1; }
  .report-controls .button { width: 100%; }
  .summary-band { padding: 14px 16px; }
  .model-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .model-header { padding: 14px 16px 0; }
  .model-alerts, .model-error { margin-left: 16px; margin-right: 16px; }
  .phase-label { padding: 10px 16px 8px; }
  .phase-list { padding: 0 10px 10px; }
  .model-footer { padding: 10px 16px; }
  .check-row { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .history-head { padding: 12px 16px; }
  .history-row {
    grid-template-columns: minmax(0, 1fr) max-content;
    grid-template-areas: "badge time" "host host";
    gap: 4px 12px;
    padding: 10px 16px;
  }
  .history-badge { justify-self: start; max-width: 100%; white-space: normal; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

@media print {
  .topbar, .config-band, .history, .report-toolbar, .page-footer, .backdrop { display: none !important; }
  body { background: #fff; }
  .model-card, .summary-band, .card { box-shadow: none; break-inside: avoid; }
}
