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

:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --elevated: #f0f0ec;
  --text: #18181b;
  --muted: #71717a;
  --line: #e4e4e7;
  --accent: #0d9488;
  --accent-ink: #ffffff;
  --danger: #dc2626;
  --success: #059669;
  --shadow: 0 8px 24px rgba(24, 24, 27, 0.06), 0 0 0 1px rgba(13, 148, 136, 0.06);
  --rail: 260px;
  --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: #0e1015;
  --surface: #171b24;
  --elevated: #1a2030;
  --text: #e8eaef;
  --muted: #8b93a7;
  --line: #2a3140;
  --accent: #2dd4bf;
  --accent-ink: #042f2e;
  --danger: #f87171;
  --success: #34d399;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.28), 0 0 0 1px rgba(45, 212, 191, 0.04);
  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) 92%, transparent);
  backdrop-filter: blur(10px);
  position: sticky;
  top: 0;
  z-index: 20;
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 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; }
.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);
}
.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)); }

.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-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 {
  overflow: auto; padding: 4px 8px 16px; display: flex; flex-direction: column; gap: 4px;
  scrollbar-width: thin; scrollbar-color: var(--line) transparent;
}

.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 .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: 16px 18px 12px; border-bottom: 1px solid var(--line); display: grid; gap: 10px;
}
.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; }

.prompt-box {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 12px 14px; box-shadow: var(--shadow);
}
.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-box pre {
  margin: 0; white-space: pre-wrap; word-break: break-word;
  font-family: var(--font-ui); font-size: 13px; line-height: 1.6;
  color: var(--text); max-height: 160px; overflow: auto;
}

.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));
}
.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;
}
.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));
}

.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: 280px; padding: 14px 18px 18px;
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  align-content: start; overflow: auto;
}

.col {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  min-height: 240px; display: flex; flex-direction: column; overflow: hidden;
  box-shadow: var(--shadow);
}
.col-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  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; gap: 4px; padding: 8px 10px 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-body {
  flex: 1; padding: 12px; font-size: 13px; line-height: 1.65;
  overflow: auto; white-space: pre-wrap; word-break: break-word; min-height: 180px;
}
.col-body.empty { color: var(--muted); white-space: normal; }
.col-body.error { color: var(--danger); white-space: pre-wrap; }
.col-body iframe {
  width: 100%; min-height: 320px; 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;
}

.score-row {
  padding: 8px 10px; border-top: 1px solid var(--line);
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center;
}
.score-row label { font-size: 10px; color: var(--muted); }
.score-row select {
  border: 1px solid var(--line); background: var(--bg); border-radius: 6px;
  padding: 3px 6px; font-size: 11px;
}

.col-actions {
  padding: 8px 10px; border-top: 1px solid var(--line); display: flex; gap: 6px;
}
.col-actions button {
  font-size: 11px; padding: 5px 8px; border-radius: 7px;
  border: 1px solid var(--line); color: var(--muted);
}
.col-actions button:hover {
  color: var(--text); border-color: color-mix(in srgb, var(--accent) 40%, var(--line));
}

.board { padding: 16px 18px 28px; display: grid; gap: 12px; }
.board-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px;
}
.tile {
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px;
  padding: 14px; box-shadow: var(--shadow); display: flex; flex-direction: column; gap: 8px;
  text-align: left; color: inherit;
  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; }

.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; }

.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: space-between;
  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); }

.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;
}
.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(--shadow); padding: 18px;
}
.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, .field textarea, .field select {
  width: 100%; border: 1px solid var(--line); background: var(--bg);
  border-radius: 9px; padding: 9px 11px; font-size: 13px;
}
.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;
}

.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;
}
.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: 1fr; }
  .rail {
    max-height: none; border-right: 0; border-bottom: 1px solid var(--line);
  }
  .case-list { flex-direction: row; overflow-x: auto; padding-bottom: 12px; }
  .case-item { min-width: 200px; }
  .brand p { display: none; }
}

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

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