/* Case Benchmark — light default, no left accent bars */

:root {
  --bg: #f6f7f3;
  --surface: #ffffff;
  --elevated: #edf3ee;
  --text: #17201e;
  --muted: #66736f;
  --line: #dce5df;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-warm: #f59e0b;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --success: #059669;
  --shadow: 0 2px 4px rgba(15, 55, 50, 0.04), 0 0 0 1px rgba(15, 118, 110, 0.05);
  --dialog-shadow: 0 20px 60px rgba(15, 55, 50, 0.18), 0 0 0 1px rgba(15, 118, 110, 0.08);
  --rail: 260px;
  --topbar-height: 57px;
  --result-card-max-height: clamp(520px, 72dvh, 760px);
  --ease: cubic-bezier(0.23, 1, 0.32, 1);
  --font-ui: "Sora", -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  color-scheme: light;
}

html[data-theme="dark"] {
  --bg: #0d1414;
  --surface: #141d1d;
  --elevated: #1a2724;
  --text: #edf4ef;
  --muted: #91a39d;
  --line: #263936;
  --accent: #2dd4bf;
  --accent-strong: #5eead4;
  --accent-warm: #fbbf24;
  --accent-ink: #071b19;
  --danger: #f87171;
  --success: #34d399;
  --shadow: 0 2px 4px rgba(0, 0, 0, 0.22), 0 0 0 1px rgba(45, 212, 191, 0.04);
  --dialog-shadow: 0 20px 60px rgba(0, 0, 0, 0.48), 0 0 0 1px rgba(45, 212, 191, 0.08);
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; min-height: 100dvh; }

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.03;
  background-image:
    linear-gradient(var(--line) 1px, transparent 1px),
    linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px;
}

::selection {
  background: color-mix(in srgb, var(--accent) 35%, transparent);
  color: var(--text);
}

:focus-visible {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.app {
  position: relative;
  z-index: 1;
  min-height: 100dvh;
  display: grid;
  grid-template-rows: auto 1fr auto;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex-shrink: 0; }
.brand-mark {
  width: 28px; height: 28px; border-radius: 8px;
  background: var(--elevated); border: 1px solid var(--line);
  display: grid; place-items: center; flex-shrink: 0;
}
.brand-mark span {
  width: 10px; height: 10px; border-radius: 2px; background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}
.brand h1 { margin: 0; font-size: 15px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.2; white-space: nowrap; }
.brand p { margin: 0; font-size: 11px; color: var(--muted); }

.top-actions { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

.icon-btn, .tab-btn, .ghost-btn, .primary-btn {
  border-radius: 9px;
  transition: transform 120ms var(--ease), background 150ms var(--ease), border-color 150ms var(--ease), opacity 150ms var(--ease);
}

.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); background: var(--surface); color: var(--muted);
}
.icon-btn:hover { color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.icon-btn:active, .primary-btn:active, .ghost-btn:active { transform: scale(0.97); }
.icon-btn svg { width: 16px; height: 16px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.tab-btn {
  padding: 7px 11px; font-size: 12px; font-weight: 500; color: var(--muted); border: 1px solid transparent;
}
.tab-btn[aria-selected="true"] {
  color: var(--text); background: var(--elevated); border-color: var(--line);
}

.primary-btn {
  padding: 8px 14px; font-size: 12px; font-weight: 600;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid color-mix(in srgb, var(--accent) 70%, #000);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 18%, transparent);
}
.primary-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.primary-btn.loading { animation: pulse 1.1s var(--ease) infinite; }
@keyframes pulse { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.08); } }

.ghost-btn {
  padding: 8px 12px; font-size: 12px; font-weight: 500; color: var(--text);
  border: 1px solid var(--line); background: var(--surface);
}
.ghost-btn:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }
.ghost-btn.mini { padding: 4px 8px; font-size: 11px; }
.danger-btn { color: var(--danger); }
.danger-btn:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.danger-primary {
  background: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 72%, #000);
  box-shadow: 0 8px 18px color-mix(in srgb, var(--danger) 18%, transparent);
}

.main {
  display: grid;
  grid-template-columns: var(--rail) 1fr;
  min-height: 0; min-width: 0;
}

.rail {
  border-right: 1px solid var(--line);
  background: color-mix(in srgb, var(--surface) 80%, var(--bg));
  display: flex; flex-direction: column; min-height: 0;
  max-height: calc(100dvh - 57px);
}

.rail-head { padding: 12px 12px 8px; display: flex; flex: 0 0 auto; flex-direction: column; gap: 8px; }
.rail-head .label,
.label {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em;
  text-transform: uppercase; color: var(--muted);
}

.search-input {
  width: 100%; border: 1px solid var(--line); background: var(--bg);
  border-radius: 9px; padding: 8px 10px; font-size: 12px;
}

.filters { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  font-size: 11px; padding: 5px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg); color: var(--muted);
}
.chip[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 14%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
  color: var(--text); font-weight: 600;
}

.case-list {
  flex: 1 1 auto; min-height: 0; overflow: auto; padding: 4px 8px 16px;
  display: flex; flex-direction: column; gap: 4px;
  overscroll-behavior-y: contain; scrollbar-gutter: stable;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}

@media (min-width: 901px) {
  .rail {
    position: fixed;
    top: var(--topbar-height);
    left: 0;
    width: var(--rail);
    height: calc(100dvh - var(--topbar-height));
    max-height: none;
    overflow: hidden;
    z-index: 10;
  }
  .stage { grid-column: 2; }
}

.case-item {
  text-align: left; padding: 10px;
  border-radius: 10px; border: 1px solid transparent;
  background: transparent; color: var(--muted);
}
.case-item:hover { background: var(--elevated); color: var(--text); }
/* Selected: full border + fill — NO left vertical bar */
.case-item.active {
  background: var(--elevated);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  color: var(--text);
  box-shadow: var(--shadow);
}
.case-item strong {
  display: block; font-size: 12.5px; font-weight: 600;
  letter-spacing: -0.01em; margin-bottom: 3px; color: inherit;
}
.case-item span { display: block; font-size: 11px; line-height: 1.4; color: var(--muted); }
.case-item .case-result-meta {
  margin-top: 7px;
  font-family: var(--font-mono);
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
}
.case-item .case-result-meta.ready { color: var(--accent-strong); }
.case-item .case-result-meta.pending { color: var(--muted); }
.case-item .meta { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }

.tag {
  font-family: var(--font-mono); font-size: 9px; padding: 2px 5px; border-radius: 4px;
  background: var(--bg); color: var(--muted); border: 1px solid var(--line);
}

.stage { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.stage-head {
  padding: 20px 18px 12px; display: grid; gap: 14px;
}
.stage-head h2 {
  margin: 0; font-size: clamp(18px, 2vw, 22px); letter-spacing: -0.03em;
  font-weight: 600; text-wrap: balance;
}
.stage-head .summary { margin: 0; color: var(--muted); font-size: 13px; max-width: 70ch; }

.case-heading-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
}
.case-heading-copy { min-width: 0; display: grid; gap: 5px; }
.case-heading-tags {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 6px;
  max-width: 42%;
}

.snapshot-strip {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--line));
  border-radius: 12px;
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  box-shadow: var(--shadow);
}
.snapshot-state { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.snapshot-state strong { font-size: 12px; font-weight: 600; text-wrap: pretty; }
.snapshot-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--muted);
  flex: 0 0 auto;
}
.snapshot-strip[data-state="published"] .snapshot-dot { background: var(--success); }
.snapshot-strip[data-state="live"] .snapshot-dot { background: var(--accent-warm); }
.snapshot-strip[data-state="empty"] .snapshot-dot { background: var(--muted); }
.snapshot-strip[data-state="error"] .snapshot-dot { background: var(--danger); }
.snapshot-facts { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px 12px; }
.snapshot-fact {
  color: var(--muted);
  font: 10px/1.4 var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.prompt-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 13px 14px; box-shadow: var(--shadow);
}
.prompt-panel { min-width: 0; }
.prompt-box .ph {
  display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 8px;
}
.prompt-box .ph span {
  font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.05em;
  text-transform: uppercase; color: var(--muted);
}
.prompt-copy { padding: 4px 8px; font-size: 11px; flex: 0 0 auto; }
.prompt-box pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: var(--font-ui); font-size: 14px; line-height: 1.7;
  color: var(--text); max-width: 65ch; text-wrap: pretty;
}

.rubric { display: flex; flex-wrap: wrap; gap: 6px; }
.rubric i {
  font-style: normal; font-size: 11px; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 999px; padding: 3px 8px;
}

.model-strip {
  padding: 10px 18px; border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  background: color-mix(in srgb, var(--bg) 70%, var(--surface));
}

.result-toolbar {
  padding-top: 0;
  padding-bottom: 4px;
}
.result-toolbar .hint { font-family: var(--font-ui); line-height: 1.5; }
.result-toolbar .actions { align-items: center; }
.model-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 10px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface); font-size: 12px;
  max-width: min(360px, 100%);
}
.model-chip .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.model-chip.disabled .dot { background: var(--muted); opacity: 0.5; }
.model-chip.selected {
  border-color: color-mix(in srgb, var(--accent) 50%, var(--line));
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.model-chip.excluded {
  color: var(--muted); opacity: 0.58; background: transparent;
}
.model-chip.excluded .dot { background: var(--muted); }
.result-selection-count {
  color: var(--muted); font-family: var(--font-mono); font-size: 10px;
  white-space: nowrap;
}
.model-chip-model,
.model-chip-source {
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 10px;
  min-width: 0;
}
.model-chip-model {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toolbar {
  padding: 10px 18px 0;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between;
}
.toolbar .hint { font-size: 12px; color: var(--muted); font-family: var(--font-mono); }
.toolbar .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.compare {
  flex: 1; min-height: min(620px, calc(100dvh - 220px)); padding: 14px 18px 18px;
  display: grid; gap: 10px;
  grid-template-columns: repeat(var(--compare-cols, 3), minmax(0, 1fr));
  align-content: start; overflow: auto;
}

.published-compare {
  min-height: min(520px, calc(100dvh - 210px));
  padding-top: 8px;
}
.published-compare .published-col { animation: resultReveal 160ms var(--ease) both; }
.published-compare .published-col:nth-child(2) { animation-delay: 30ms; }
.published-compare .published-col:nth-child(3) { animation-delay: 60ms; }
.published-compare .published-col.text-col { min-height: 360px; }
.published-compare .published-col.artifact-col { min-height: clamp(460px, 56dvh, 680px); }
@keyframes resultReveal {
  from { opacity: 0; transform: translateY(5px); }
  to { opacity: 1; transform: translateY(0); }
}

.col {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  min-height: clamp(430px, 56dvh, 700px); max-height: var(--result-card-max-height);
  display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow);
}
.col-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  flex-shrink: 0; padding: 10px 12px; border-bottom: 1px solid var(--line); background: var(--elevated);
}
.col-head h3 {
  margin: 0; font-size: 12px; font-family: var(--font-mono); font-weight: 500;
  color: var(--accent); letter-spacing: -0.01em;
}
.col-head .stats {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.col-tabs {
  display: flex;
  flex-shrink: 0;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 8px 10px 0;
}
.col-tabs.recovery-tabs { justify-content: flex-end; }
.col-tabs.recovery-tabs .rerun-btn {
  padding: 5px 10px;
  border-color: color-mix(in srgb, var(--accent) 34%, var(--line));
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  color: var(--accent-strong);
  font-weight: 600;
}
.tab-set { display: flex; gap: 4px; min-width: 0; }
.col-tabs button {
  font-size: 11px; padding: 4px 8px; border-radius: 6px; color: var(--muted);
  border: 1px solid transparent;
}
.col-tabs button[aria-selected="true"] {
  background: var(--elevated); border-color: var(--line); color: var(--text); font-weight: 600;
}
.col-tabs .rerun-btn {
  flex-shrink: 0;
  border-color: var(--line);
  background: var(--surface);
  color: var(--text);
}
.col-tabs .rerun-btn:hover {
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.col-tabs .rerun-btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.col-body {
  flex: 1 1 auto; min-height: 0; padding: 12px; font-size: 13px; line-height: 1.65;
  overflow: auto; scrollbar-gutter: stable;
  scrollbar-width: thin;
  scrollbar-color: color-mix(in srgb, var(--accent) 30%, var(--line)) transparent;
  white-space: pre-wrap; word-break: break-word;
}
.col-body::-webkit-scrollbar { width: 8px; height: 8px; }
.col-body::-webkit-scrollbar-track { background: transparent; }
.col-body::-webkit-scrollbar-thumb {
  border: 2px solid transparent;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 30%, var(--line));
  background-clip: padding-box;
}
.col-body.empty { color: var(--muted); white-space: normal; }
.col-body.error { color: var(--danger); white-space: pre-wrap; }
.col-body.preview-body { padding: 8px; overflow: hidden; }
.col-body iframe {
  display: block; width: 100%; height: 100%; min-height: 0; border: 1px solid var(--line);
  border-radius: 8px; background: #fff;
}
.col-body pre.source {
  margin: 0; font-family: var(--font-mono); font-size: 11px; line-height: 1.5;
  white-space: pre-wrap; word-break: break-word;
}
.stream-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  white-space: normal;
}
.stream-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  width: fit-content;
  max-width: 100%;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--muted);
  font-size: 11px;
  font-family: var(--font-mono);
  white-space: normal;
}
.stream-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 38%, transparent);
  animation: streamPulse 1.2s var(--ease) infinite;
  flex-shrink: 0;
}
@keyframes streamPulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 38%, transparent); }
  50% { box-shadow: 0 0 0 6px transparent; }
}
.stream-placeholder {
  flex: 1;
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--bg);
  text-align: center;
  padding: 18px;
}
.partial-source {
  margin-top: 10px !important;
  color: var(--text);
}

.score-row {
  flex-shrink: 0; padding: 8px 10px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.score-control { display: grid; gap: 4px; min-width: 112px; }
.score-control > span { font-size: 10px; color: var(--muted); }
.score-segments { display: grid; grid-template-columns: repeat(5, 1fr); }
.score-segments button {
  min-width: 24px; height: 25px; padding: 0; border: 1px solid var(--line); border-right-width: 0;
  background: var(--bg); color: var(--muted); font: 10px var(--font-mono); border-radius: 0;
}
.score-segments button:first-child { border-radius: 6px 0 0 6px; }
.score-segments button:last-child { border-right-width: 1px; border-radius: 0 6px 6px 0; }
.score-segments button[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 700;
}

.col-actions {
  flex-shrink: 0; padding: 8px 10px; border-top: 1px solid var(--line); display: flex; gap: 6px; align-items: center;
}
.col-actions button,
.col-actions a {
  font-size: 11px; padding: 5px 8px; border-radius: 7px;
  border: 1px solid var(--line); color: var(--muted); background: transparent; text-decoration: none;
}
.col-actions .card-icon-btn {
  position: relative; display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0;
}
.col-actions .score-toggle {
  margin-left: auto; padding: 5px 2px; border-color: transparent;
  color: var(--accent-strong); font-weight: 600;
}
.col-actions .score-toggle:hover { color: var(--accent); border-color: transparent; }
.card-icon-btn svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[data-tooltip] { position: relative; }
[data-tooltip]::after {
  content: attr(data-tooltip); position: absolute; left: 50%; bottom: calc(100% + 7px); z-index: 20;
  transform: translate(-50%, 3px); padding: 5px 7px; border-radius: 5px; background: var(--text);
  color: var(--surface); font-size: 10px; line-height: 1; white-space: nowrap; opacity: 0; pointer-events: none;
  transition: opacity 120ms var(--ease), transform 120ms var(--ease);
}
[data-tooltip]:hover::after, [data-tooltip]:focus-visible::after { opacity: 1; transform: translate(-50%, 0); }
.col-actions button:hover,
.col-actions a:hover {
  color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.published-empty {
  grid-column: 1 / -1;
  min-height: 320px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
  padding: 28px;
  text-align: center;
}
.published-empty > div { display: grid; justify-items: center; gap: 8px; max-width: 48ch; }
.published-empty strong { font-size: 15px; font-weight: 600; }
.published-empty span { color: var(--muted); font-size: 13px; line-height: 1.65; }
.published-empty .ghost-btn { margin-top: 4px; }
.result-skeleton {
  min-height: clamp(430px, 56dvh, 700px);
  border: 1px solid var(--line);
  border-radius: 12px;
  background:
    linear-gradient(var(--elevated), var(--elevated)) 12px 14px / 42% 12px no-repeat,
    linear-gradient(var(--elevated), var(--elevated)) 12px 44px / calc(100% - 24px) 1px no-repeat,
    repeating-linear-gradient(to bottom, transparent 0 23px, color-mix(in srgb, var(--line) 55%, transparent) 23px 24px) 12px 66px / calc(100% - 24px) 68% no-repeat,
    var(--surface);
  box-shadow: var(--shadow);
}
.rail-empty span { margin-top: 5px; }

.stage-lower {
  display: grid;
  gap: 12px;
  padding: 0 18px 24px;
}
.snapshot-history {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: var(--shadow);
}
.rubric-disclosure {
  margin-top: 12px;
  border-top: 1px solid var(--line);
}
.rubric-disclosure > summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0 0;
  cursor: pointer;
  user-select: none;
}
.rubric-disclosure > summary::-webkit-details-marker { display: none; }
.rubric-disclosure > summary > span:first-child { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.rubric-disclosure > summary strong { font-size: 12px; font-weight: 600; }
.rubric-disclosure > summary small { color: var(--muted); font-size: 11px; }
.disclosure-action {
  color: var(--accent-strong);
  font-size: 11px;
  font-weight: 600;
}
.rubric-disclosure[open] .disclosure-action::before { content: "收起"; }
.rubric-disclosure[open] .disclosure-action { font-size: 0; }
.rubric-disclosure[open] .disclosure-action::before { font-size: 11px; }
.rubric-disclosure .rubric { margin-top: 10px; }

.snapshot-history { padding: 14px; }
.snapshot-history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.snapshot-history-head h3 { margin: 0; font-size: 13px; font-weight: 600; }
.snapshot-history-head span { color: var(--muted); font: 10px var(--font-mono); }
.snapshot-version-list { display: grid; gap: 4px; }
.snapshot-version {
  width: 100%;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 9px 10px;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  text-align: left;
}
.snapshot-version[aria-current="true"] {
  background: var(--elevated);
  border-color: color-mix(in srgb, var(--accent) 24%, var(--line));
}
.snapshot-version b,
.snapshot-version time { font: 10px var(--font-mono); font-variant-numeric: tabular-nums; }
.snapshot-version span { min-width: 0; font-size: 12px; overflow-wrap: anywhere; }
.snapshot-version time { color: var(--muted); }

.board { padding: 24px 18px 36px; display: grid; gap: 18px; align-content: start; }
.board > * { width: min(1180px, 100%); margin-inline: auto; }
.page-heading { display: flex; justify-content: space-between; align-items: end; gap: 16px; }
.page-heading h2 { margin: 4px 0 0; font-size: 24px; letter-spacing: -0.02em; }
.page-heading p { margin: 6px 0 0; color: var(--muted); font-size: 13px; }
.history-page { min-height: 560px; }
.board-grid {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px;
  align-items: start;
}
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 10px;
  padding: 16px; box-shadow: none; display: flex; flex-direction: column; gap: 10px;
  text-align: left; color: inherit; min-width: 0;
  transition: border-color 150ms var(--ease), transform 120ms var(--ease);
}
.tile:hover { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); }
.tile h3 { margin: 0; font-size: 14px; letter-spacing: -0.02em; }
.tile p { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.45; flex: 1; }
.tile .row { display: flex; flex-wrap: wrap; gap: 4px; }

.contrib-card {
  min-height: 220px;
  justify-content: flex-start;
}
.contrib-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: start;
}
.contrib-head h3 {
  min-width: 0;
  overflow-wrap: anywhere;
}
.contrib-preview {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 58px;
  overflow-wrap: anywhere;
  flex: 0;
}
.contrib-meta { align-items: center; color: var(--muted); font-size: 11px; gap: 0 !important; }
.contrib-meta > * + *::before { content: "·"; margin: 0 6px; color: var(--line); }
.result-count { white-space: nowrap; }
.model-pill-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}
.model-pill {
  max-width: 100%;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--accent) 24%, var(--line));
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 10px;
  line-height: 1.3;
  padding: 3px 7px;
  overflow-wrap: anywhere;
  white-space: normal;
}
.model-pill.more {
  color: var(--muted);
  background: var(--bg);
  border-color: var(--line);
}

.empty-state {
  padding: 48px 20px; text-align: center; color: var(--muted);
  border: 1px dashed var(--line); border-radius: 14px; background: var(--surface);
}
.empty-state strong { display: block; color: var(--text); margin-bottom: 6px; font-size: 14px; }
.empty-state.slim { padding: 18px 14px; font-size: 12px; }

.test-board {
  align-content: start;
}
.test-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 12px;
  align-items: stretch;
}
.test-composer,
.test-model-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  padding: 12px;
  min-width: 0;
}
.test-composer h2 {
  margin: 2px 0 8px;
  font-size: 20px;
  letter-spacing: -0.03em;
}
.test-composer textarea {
  min-height: 116px;
}
.prompt-field-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.prompt-field-head label {
  font-size: 12px;
  font-weight: 500;
  color: var(--muted);
}
.prompt-library-trigger {
  position: relative;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 7%, var(--surface));
}
.prompt-library-trigger:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
}
.prompt-library-trigger svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.test-controls {
  display: flex;
  gap: 10px;
  align-items: end;
  justify-content: space-between;
  flex-wrap: wrap;
}
.compact-field {
  display: grid;
  gap: 6px;
  min-width: min(260px, 100%);
}
.compact-field span {
  font-size: 12px;
  color: var(--muted);
  font-weight: 500;
}
.compact-field select {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 9px;
  padding: 8px 10px;
  font-size: 13px;
}
.test-model-panel {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.test-model-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 285px;
  overflow: auto;
  padding-right: 2px;
}
.test-provider-group {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: var(--bg);
}
.test-provider-head {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  padding: 9px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.test-provider-head.selected {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}
.test-provider-head input,
.test-model-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}
.test-provider-title {
  display: grid;
  gap: 1px;
  min-width: 0;
}
.test-provider-title b {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.test-provider-title span {
  color: var(--muted);
  font-size: 10px;
}
.test-provider-models {
  display: grid;
}
.test-model-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 9px;
  align-items: center;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: var(--bg);
  padding: 9px;
  min-width: 0;
}
.test-model-row:last-child { border-bottom: 0; }
.test-model-row.selected {
  background: color-mix(in srgb, var(--accent) 9%, var(--surface));
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
}
.test-model-row input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--accent);
}
.test-model-main {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.test-model-main b {
  font-size: 12px;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.test-model-main span {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--muted);
  overflow-wrap: anywhere;
}
.test-toolbar {
  padding: 2px 0 0;
}

.guide {
  margin: 14px 18px 0; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--surface); box-shadow: var(--shadow);
}
.guide ol { margin: 8px 0 0; padding-left: 1.2em; color: var(--muted); font-size: 13px; }
.guide li { margin: 4px 0; }

.footer {
  border-top: 1px solid var(--line); padding: 12px 18px;
  display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; justify-content: flex-end;
  color: var(--muted); font-size: 12px; background: var(--surface);
}
.footer-links { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.footer a { color: var(--muted); }
.footer a:hover { color: var(--accent); }
.footer-action {
  display: inline-flex; align-items: center; gap: 5px; padding: 3px 0;
  color: var(--muted); font-size: 11px;
}
.footer-action:hover { color: var(--text); }
.footer-action svg {
  width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 1.75;
  stroke-linecap: round; stroke-linejoin: round;
}

.overlay {
  position: fixed; inset: 0; background: rgba(8, 10, 14, 0.45);
  z-index: 40; display: none; align-items: center; justify-content: center; padding: 20px;
  overscroll-behavior: contain;
}
.overlay.open { display: flex; }

.modal {
  width: min(560px, 100%); max-height: min(88dvh, 780px); overflow: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: 14px;
  box-shadow: var(--dialog-shadow); padding: 18px;
  overscroll-behavior: contain;
}
.modal.wide { width: min(920px, 100%); }
.modal h2 { margin: 0 0 6px; font-size: 16px; letter-spacing: -0.02em; }
.modal .hint { margin: 0 0 14px; font-size: 12px; color: var(--muted); line-height: 1.5; }

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field > label { font-size: 12px; font-weight: 500; color: var(--muted); }
.field input:not([type="checkbox"]):not([type="radio"]),
.field textarea,
.field select {
  width: 100%; border: 1px solid var(--line); background: var(--bg);
  border-radius: 9px; padding: 9px 11px; font-size: 13px;
}
.field input[type="checkbox"],
.field input[type="radio"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: 0;
  background: transparent;
  accent-color: var(--accent);
  flex-shrink: 0;
}
.field textarea { min-height: 88px; resize: vertical; }
.field textarea.mono { font-family: var(--font-mono); font-size: 12px; }
.field.hp { position: absolute; left: -9999px; opacity: 0; height: 0; overflow: hidden; }

.model-editor {
  border: 1px solid var(--line); border-radius: 12px; padding: 12px;
  margin-bottom: 10px; background: var(--elevated);
}
.model-editor h3 {
  margin: 0 0 10px; font-size: 13px; display: flex; justify-content: space-between; align-items: center;
}

.modal-actions {
  display: flex; flex-wrap: wrap; gap: 8px; justify-content: flex-end; margin-top: 8px;
}

.delete-record-modal { width: min(430px, 100%); }
.delete-record-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 12px;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--danger) 25%, var(--line));
}
.delete-record-mark svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.prompt-library-modal {
  width: min(860px, 100%);
  height: min(82dvh, 760px);
  max-height: min(92dvh, 820px);
  overflow: hidden;
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr);
  gap: 12px;
}
.prompt-library-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
}
.prompt-library-head h2 { margin-top: 2px; }
.prompt-library-head .hint { margin-bottom: 0; }
.prompt-library-search {
  position: relative;
  display: block;
}
.prompt-library-search svg {
  position: absolute;
  left: 12px;
  top: 50%;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-width: 1.75;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}
.prompt-library-search input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--bg);
  padding: 10px 12px 10px 38px;
  font-size: 13px;
}
.prompt-library-filters {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  padding: 1px 1px 3px;
  scrollbar-width: thin;
}
.prompt-library-filters .chip { white-space: nowrap; }
.prompt-library-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.5;
}
.prompt-library-meta > span:first-child {
  flex: 0 0 auto;
  font-family: var(--font-mono);
}
.prompt-library-sources { text-align: right; }
.prompt-library-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 8px;
  padding: 1px 3px 3px 1px;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}
.prompt-library-card {
  width: 100%;
  min-width: 0;
  min-height: 148px;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 7px;
  padding: 12px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  color: var(--text);
}
.prompt-library-card:hover {
  border-color: color-mix(in srgb, var(--accent) 42%, var(--line));
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
}
.prompt-library-card:disabled { cursor: not-allowed; opacity: 0.55; }
.prompt-library-card-head,
.prompt-library-card-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.prompt-library-card strong {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: -0.01em;
}
.prompt-library-card .tag { flex: 0 0 auto; }
.prompt-library-card-summary {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.prompt-library-card-prompt {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
  overflow: hidden;
  color: var(--text);
  font: 11px/1.55 var(--font-mono);
}
.prompt-library-card-foot {
  color: var(--muted);
  font-size: 10px;
}
.prompt-library-use { color: var(--accent-strong); font-weight: 600; }
.prompt-library-empty {
  grid-column: 1 / -1;
  min-height: 220px;
  display: grid;
  place-content: center;
  gap: 8px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line);
  border-radius: 10px;
}
.prompt-library-empty strong { color: var(--text); font-size: 13px; }

.publish-modal { width: min(480px, 100%); }
.publish-mark {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 12px;
  color: var(--accent-strong);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 26%, var(--line));
}
.publish-mark svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.publish-checklist {
  display: grid;
  gap: 6px;
  margin: 12px 0;
  padding: 10px 12px;
  border-radius: 8px;
  background: var(--bg);
  border: 1px solid var(--line);
}
.publish-checklist span {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}
.publish-checklist span::before {
  content: "";
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--success);
  flex: 0 0 auto;
}

.toast {
  position: fixed; bottom: 24px; left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--elevated); color: var(--text); border: 1px solid var(--line);
  border-radius: 999px; padding: 10px 16px; font-size: 13px; z-index: 50;
  opacity: 0; pointer-events: none;
  transition: opacity 180ms var(--ease), transform 180ms var(--ease);
  box-shadow: var(--shadow);
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.hidden { display: none !important; }

/* qmreader-style AI config */
.modal.ai-modal {
  width: min(880px, 100%);
  max-height: min(92dvh, 900px);
}
.ai-modal-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 14px;
}
.ai-section {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--line);
}
.ai-section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  font-family: var(--font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.ai-layout {
  display: grid;
  grid-template-columns: 200px 1fr;
  gap: 12px;
  min-height: 320px;
}
.ai-profile-side {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--elevated);
  overflow: auto;
  max-height: 420px;
}
.ai-profile-list { display: flex; flex-direction: column; padding: 6px; gap: 4px; }
.ai-profile-item {
  text-align: left;
  padding: 9px 10px;
  border-radius: 9px;
  border: 1px solid transparent;
  color: var(--muted);
  font-size: 12px;
}
.ai-profile-item strong { display: block; color: var(--text); font-size: 12.5px; margin-bottom: 2px; }
.ai-profile-item .sub {
  font-family: var(--font-mono); font-size: 10px; color: var(--muted);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.ai-profile-item.active {
  background: var(--surface);
  border-color: color-mix(in srgb, var(--accent) 35%, var(--line));
  box-shadow: var(--shadow);
  color: var(--text);
}
.ai-profile-item .flags { margin-top: 4px; display: flex; gap: 4px; flex-wrap: wrap; }
.ai-profile-form {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  padding: 12px;
}
.ai-template-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.ai-template-list button {
  font-size: 11px;
  padding: 5px 9px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
}
.ai-template-list button:hover,
.ai-template-list button.active {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--line));
  color: var(--text);
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.ai-key-link {
  font-size: 11px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-family: var(--font-ui);
}
.ai-quick-models {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: -4px 0 12px;
}
.ai-quick-models button {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px dashed var(--line);
  color: var(--muted);
  background: var(--bg);
}
.ai-quick-models button:hover {
  color: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}
.field.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.check-line {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.check-line input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  padding: 0;
  flex-shrink: 0;
  accent-color: var(--accent);
}
.field-tip {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}
.model-pick-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}
.model-select {
  margin-top: 8px;
  width: 100%;
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 9px;
  padding: 9px 11px;
  font-size: 13px;
}
@media (max-width: 760px) {
  .ai-layout { grid-template-columns: 1fr; }
  .ai-profile-side { max-height: 160px; }
  .field.two-col { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .main { grid-template-columns: minmax(0, 1fr); }
  .rail {
    width: 100%; min-width: 0; max-height: none; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .case-list { width: 100%; min-width: 0; flex-direction: row; overflow-x: auto; padding-bottom: 12px; }
  .case-item { min-width: 200px; }
  .brand p { display: none; }
  .test-layout { grid-template-columns: 1fr; }
  .test-model-list { max-height: 220px; }
  .compare { min-height: 420px; overflow: visible; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .published-compare { grid-template-columns: minmax(0, 1fr); }
  .col { min-height: 500px; }
  .case-heading-row { align-items: flex-start; }
}

@media (max-width: 640px) {
  .topbar {
    flex-wrap: wrap;
    align-items: center;
  }
  .brand {
    width: 100%;
  }
  .top-actions {
    width: 100%;
    justify-content: flex-start;
    overflow-x: auto;
    flex-wrap: nowrap;
    padding-bottom: 2px;
  }
  .top-actions > * { flex: 0 0 auto; }
  .case-heading-row,
  .snapshot-strip { align-items: flex-start; flex-direction: column; }
  .case-heading-tags { max-width: none; justify-content: flex-start; }
  .snapshot-facts { justify-content: flex-start; }
  .result-toolbar { align-items: flex-start; }
  .result-toolbar .actions { width: 100%; }
  .result-toolbar .actions > button { flex: 1 1 auto; }
  .stage-head { padding-inline: 14px; }
  .compare { padding-inline: 14px; }
  .stage-lower { padding-inline: 14px; }
  .snapshot-version { grid-template-columns: auto minmax(0, 1fr); }
  .snapshot-version time { grid-column: 2; }
  .col { min-height: 440px; }
  .compare { grid-template-columns: minmax(0, 1fr); }
  .col-body { min-height: 0; }
  .stream-placeholder { min-height: 140px; }
}

@media (hover: hover) and (pointer: fine) {
  .tile:hover { transform: translateY(-1px); }
}

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

.brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 9px;
  border: 1px solid color-mix(in srgb, var(--accent-warm) 34%, var(--line));
  box-shadow: 0 8px 18px color-mix(in srgb, var(--accent) 18%, transparent);
  object-fit: cover;
  flex-shrink: 0;
}
.brand { color: inherit; text-decoration: none; }
.top-actions .tab-btn { text-decoration: none; display: inline-flex; align-items: center; }
.model-checks {
  max-height: 240px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 6px;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: left;
}
.model-checks .model-check-row {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  column-gap: 10px;
  width: 100%;
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  text-align: left;
  box-sizing: border-box;
}
.model-checks .model-check-row:hover {
  background: var(--elevated);
}
.model-checks .model-check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  min-width: 16px;
  margin: 0;
  padding: 0;
  justify-self: start;
  accent-color: var(--accent);
}
.model-checks .model-id {
  display: block;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.4;
  color: var(--text);
  word-break: break-word;
  overflow-wrap: anywhere;
  text-align: left;
}
.col-head h3 .provider {
  display: block;
  font-size: 10px;
  color: var(--muted);
  font-weight: 400;
  margin-bottom: 2px;
}
.col-body.md {
  white-space: normal;
  font-size: 14px;
  line-height: 1.7;
}
.col-body.md h1,.col-body.md h2,.col-body.md h3 { margin: 0.8em 0 0.35em; letter-spacing: -0.02em; }
.col-body.md p { margin: 0.5em 0; }
.col-body.md pre {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
}
.col-body.md code { font-family: var(--font-mono); font-size: 0.92em; }
.col-body.md ul { padding-left: 1.2em; }
.artifact-note {
  margin: 0 0 10px;
  padding: 8px 10px;
  border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line));
  border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}
#modal-preview-fs { padding: 16px; }
.fs-modal {
  width: min(1600px, 100%);
  height: calc(100dvh - 32px);
  max-height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}
.fs-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--line);
}
.fs-body {
  flex: 1;
  min-height: 0;
  background: #fff;
  overscroll-behavior: contain;
}
.fs-body iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}
.fs-body iframe:focus-visible,
.fs-body > [tabindex]:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}
#modal-detail .contribution-detail-modal {
  width: min(1280px, calc(100vw - 40px));
  height: min(92dvh, 920px);
  max-height: min(92dvh, 920px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
#detail-compare {
  flex: 1 1 auto;
  min-height: 0;
  padding: 12px 0 0;
  overflow: auto;
  overscroll-behavior: contain;
}
#detail-compare .col { min-height: 420px; }
.more-fields {
  margin: 8px 0 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  background: var(--elevated);
}
.more-fields summary {
  cursor: pointer;
  font-size: 12px;
  color: var(--muted);
  font-weight: 600;
}
.more-fields[open] summary { margin-bottom: 10px; }

.prompt-editor-inline {
  margin-top: 8px;
}
.prompt-editor-inline textarea {
  width: 100%;
  min-height: 148px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  padding: 10px;
  font-size: 12.5px;
  line-height: 1.6;
  box-sizing: border-box;
}
.admin-prompt-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 10px;
}
.history-layout {
  display: grid;
  grid-template-columns: minmax(240px, 280px) minmax(0, 1fr);
  gap: 14px;
  min-height: 420px;
}
.history-list {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface);
  padding: 8px;
  overflow: auto;
}
.history-item {
  width: 100%;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  padding: 12px;
  text-align: left;
  cursor: pointer;
}
.history-item strong,
.history-item span,
.history-item time {
  display: block;
  overflow-wrap: anywhere;
}
.history-item strong {
  font-size: 13px;
  margin-bottom: 4px;
}
.history-item span,
.history-item time {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}
.history-item.active,
.history-item:hover {
  background: color-mix(in srgb, var(--accent) 10%, var(--surface));
}
.history-item.active { box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 32%, var(--line)); }
.history-detail {
  min-width: 0;
  overflow: auto;
}
.history-detail-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 8px;
}
.history-detail-title {
  min-width: 0;
  display: grid;
  gap: 2px;
}
.history-detail-actions {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  flex: 0 0 auto;
}
.history-delete-btn {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--danger);
  background: var(--surface);
}
.history-delete-btn:hover { border-color: color-mix(in srgb, var(--danger) 45%, var(--line)); }
.history-delete-btn svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.history-detail-head strong {
  color: var(--text);
}
.history-prompt {
  max-height: 96px;
  overflow: auto;
  white-space: pre-wrap;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  font-size: 12px;
  line-height: 1.55;
}
.history-compare {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 10px 0 0;
  max-height: none;
}
.history-compare .col {
  min-height: 360px;
}
.history-compare .col-body,
.history-compare .col-body iframe {
  min-height: 260px;
}
.history-empty { min-height: 180px; display: grid; place-content: center; }
.history-empty span { font-size: 12px; }

@media (max-width: 900px) {
  .board-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 760px) {
  .prompt-library-modal { height: min(90dvh, 760px); padding: 14px; }
  .prompt-library-list { grid-template-columns: minmax(0, 1fr); }
  .prompt-library-sources { display: none; }
  .history-layout {
    grid-template-columns: 1fr;
  }
  .history-compare {
    grid-template-columns: minmax(0, 1fr);
  }
  .board-grid { grid-template-columns: minmax(0, 1fr); }
  .page-heading { align-items: start; }
}

@media (max-width: 640px) {
  #modal-preview-fs { padding: 0; }
  .fs-modal {
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    border: 0;
    border-radius: 0;
  }
  .fs-bar {
    min-height: 52px;
    padding: max(10px, env(safe-area-inset-top)) 12px 10px;
  }
  .fs-bar button { min-width: 44px; min-height: 44px; }
  #modal-detail .contribution-detail-modal {
    width: 100%;
    height: min(94dvh, 920px);
    max-height: min(94dvh, 920px);
  }
}

/* Dual-pane compare */
.dual-compare {
  margin: 0 18px 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.dual-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  background: var(--elevated);
}
.dual-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
}
.dual-picks label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--muted);
}
.dual-picks select {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  max-width: 220px;
  color: var(--text);
}
.dual-sync input {
  width: 14px;
  height: 14px;
  accent-color: var(--accent);
}
.dual-panes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  min-height: 320px;
  max-height: min(62dvh, 640px);
}
.dual-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: 1px solid var(--line);
}
.dual-pane:last-child { border-right: 0; }
.dual-pane-head {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent);
  background: color-mix(in srgb, var(--elevated) 80%, var(--surface));
}
.dual-pane-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 12px 14px;
  font-size: 13px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.dual-pane-body.md {
  white-space: normal;
}
.col-head h3 .winner-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  font-family: var(--font-ui);
  color: var(--accent-ink);
  background: var(--accent);
  vertical-align: middle;
}
.col.winner-col {
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--accent) 45%, var(--line)), var(--shadow);
}
button.pick-winner {
  font-size: 11px;
  padding: 5px 8px;
  border-radius: 7px;
  border: 1px solid var(--line);
  color: var(--muted);
  background: var(--surface);
}
button.pick-winner:hover,
button.pick-winner.is-active {
  color: var(--accent-ink);
  background: var(--accent);
  border-color: color-mix(in srgb, var(--accent) 70%, #000);
}
@media (max-width: 900px) {
  .dual-panes { grid-template-columns: 1fr; max-height: none; }
  .dual-pane {
    border-right: 0;
    border-bottom: 1px solid var(--line);
    max-height: 40dvh;
  }
  .dual-pane:last-child { border-bottom: 0; }
}
