:root {
  color-scheme: light;
  --header-height: 64px;
  --bg: #ffffff;
  --surface: #ffffff;
  --surface-raised: #ffffff;
  --surface-soft: rgba(249, 250, 251, 0.72);
  --text: #111827;
  --muted: #6b7280;
  --muted-strong: #4b5563;
  --faint: #9ca3af;
  --line: #e5e7eb;
  --line-soft: #f3f4f6;
  --line-strong: #d1d5db;
  --table-line: #dfe3e8;
  --accent: #1a73e8;
  --accent-strong: #1769cf;
  --accent-soft: #f8fbff;
  --ci-line: #111111;
  /* Official-site-inspired table palette; provenance/adaptations in README. */
  --model-gpt: #10a37f;
  --model-deepseek: #4d6bfe;
  --model-claude: #d97757;
  --model-gemini: #ac87eb;
  --model-qwen: #7046d6;
  --model-kimi: #009ac9;
  --model-glm: #4d8a98;
  --model-grok: #7c7c83;
  --model-muse: #0064e0;
  --model-unknown: #949ca8;
  --sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "PingFang SC", "Microsoft YaHei", sans-serif;
  --mono: "SFMono-Regular", "Cascadia Code", "Roboto Mono", Consolas, monospace;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #000000;
  --surface: #0d0d0d;
  --surface-raised: #111827;
  --surface-soft: rgba(13, 13, 13, 0.72);
  --text: #f3f4f6;
  --muted: #9ca3af;
  --muted-strong: #d1d5db;
  --faint: #6b7280;
  --line: #1f2937;
  --line-soft: rgba(31, 41, 55, 0.6);
  --line-strong: #374151;
  --table-line: #2d3745;
  --accent: #8ab4f8;
  --accent-strong: #a9c8fa;
  --accent-soft: rgba(4, 30, 73, 0.4);
  --ci-line: #f3f4f6;
  /* Keep the light error whiskers legible on the two brightest fills. */
  --model-gemini: #9466cf;
  --model-kimi: #0085b5;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--header-height) + 16px);
}

body {
  min-width: 0;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background: var(--bg);
  font-family: var(--sans);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select {
  font: inherit;
  border-radius: 0;
}

button,
a,
select {
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
a:focus-visible,
select:focus-visible {
  outline: 3px solid rgb(107 114 128 / 0.4);
  outline-offset: 2px;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  top: 8px;
  left: 8px;
  z-index: 100;
  padding: 9px 13px;
  color: #ffffff;
  background: #111827;
  border-radius: 0;
  transform: translateY(-150%);
}

.skip-link:focus {
  transform: translateY(0);
}

.nav-shell {
  width: min(1392px, calc(100% - 48px));
  margin-inline: auto;
}

.section-shell {
  width: min(1240px, calc(100% - 64px));
  margin-inline: auto;
}

.section-anchor {
  scroll-margin-top: 0;
}

.site-header,
main,
.footer {
  position: relative;
  z-index: 1;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
}

.nav-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  min-height: var(--header-height);
  gap: 16px;
}

.brand {
  display: inline-flex;
  align-items: center;
  justify-self: start;
  min-width: 0;
  gap: 8px;
  font-size: 21px;
  font-weight: 650;
  letter-spacing: -0.02em;
}

.brand img {
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 0;
}

.brand span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#results {
  padding-top: 32px;
}

.results-content {
  padding-top: 0;
}

.nav-actions {
  display: flex;
  align-items: center;
  justify-self: end;
  gap: 8px;
}

.locale-control {
  position: relative;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  align-items: center;
  width: auto;
  min-height: 36px;
  padding: 0 10px;
  gap: 6px;
  overflow: visible;
  color: var(--muted-strong);
  border: 1px solid transparent;
  border-radius: 0;
  transition: border-color 160ms ease, background-color 160ms ease;
}

.locale-control:hover,
.theme-toggle:hover,
.github-link:hover {
  color: var(--text);
  border-color: var(--line);
  background: var(--surface-soft);
}

.locale-icon {
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.locale-select {
  width: auto;
  min-width: 0;
  height: 34px;
  padding: 0;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  field-sizing: content;
  font-size: 14px;
}

.locale-select:focus {
  outline: 0;
}

.custom-select {
  position: relative;
  min-width: 0;
  color: inherit;
  font-weight: 400;
  letter-spacing: normal;
  text-transform: none;
}

.custom-select.is-open {
  z-index: 70;
}

.custom-select-native {
  position: absolute !important;
  width: 1px !important;
  min-width: 0 !important;
  height: 1px !important;
  margin: -1px !important;
  overflow: hidden !important;
  padding: 0 !important;
  opacity: 0 !important;
  border: 0 !important;
  pointer-events: none !important;
}

.custom-select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 12px;
  gap: 18px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
  font-size: 18px;
  font-weight: 400;
  text-align: left;
  transition: border-color 160ms ease, background-color 160ms ease, box-shadow 160ms ease;
}

.custom-select-trigger::after {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  content: "";
  transform: translateY(-2px) rotate(45deg);
  transition: transform 160ms ease;
}

.custom-select.is-open .custom-select-trigger::after {
  transform: translateY(2px) rotate(225deg);
}

.custom-select-trigger:hover {
  border-color: var(--line-strong);
}

.custom-select.is-open .custom-select-trigger {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--line));
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 12%, transparent);
}

.custom-select-value {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.custom-select-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  z-index: 80;
  width: max-content;
  min-width: 100%;
  max-width: min(340px, calc(100vw - 32px));
  max-height: min(360px, 60vh);
  overflow-y: auto;
  padding: 5px;
  color: var(--text);
  background: var(--surface-raised);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: 0 16px 38px rgb(15 23 42 / 0.2), 0 3px 10px rgb(15 23 42 / 0.08);
}

.custom-select-menu[hidden] {
  display: none;
}

.custom-select-option {
  display: grid;
  width: 100%;
  min-height: 38px;
  grid-template-columns: minmax(0, 1fr) 14px;
  align-items: center;
  padding: 7px 10px;
  gap: 14px;
  color: var(--muted-strong);
  background: transparent;
  border: 0;
  border-radius: 0;
  cursor: pointer;
  font-size: 16px;
  font-weight: 400;
  text-align: left;
  white-space: nowrap;
}

.custom-select-option:hover,
.custom-select-option:focus-visible,
.custom-select-option[data-active="true"] {
  color: var(--text);
  background: var(--surface-soft);
  outline: 0;
}

.custom-select-option[aria-selected="true"] {
  color: var(--text);
  background: var(--accent-soft);
}

.custom-select-option::after {
  width: 9px;
  height: 5px;
  border-left: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  content: "";
  opacity: 0;
  transform: translateY(-1px) rotate(-45deg);
}

.custom-select-option[aria-selected="true"]::after {
  opacity: 1;
}

.locale-custom-select {
  width: max-content;
}

.locale-custom-select .custom-select-trigger {
  width: auto;
  height: 34px;
  padding: 0;
  gap: 6px;
  color: inherit;
  background: transparent;
  border: 0;
  font-size: 14px;
  line-height: 20px;
}

.locale-custom-select .custom-select-trigger::after {
  width: 6px;
  height: 6px;
  margin-inline: 3px;
  border-width: 1.5px;
}

.locale-custom-select.is-open .custom-select-trigger {
  box-shadow: none;
}

.locale-custom-select .custom-select-menu {
  right: -10px;
  left: auto;
  width: 144px;
  min-width: 144px;
  padding: 4px;
  border-radius: 0;
  box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

.locale-custom-select .custom-select-option {
  min-height: 36px;
  padding: 7px 8px;
  border-radius: 0;
  color: var(--text);
  font-size: 14px;
}

.locale-custom-select .custom-select-option[aria-selected="true"] {
  background: var(--surface-soft);
}

.theme-toggle,
.github-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  gap: 6px;
  height: 36px;
  padding: 0;
  color: var(--muted-strong);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 0;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.theme-toggle {
  width: 36px;
}

.github-link {
  width: 36px;
  border-color: var(--line);
  background: var(--surface);
}

.nav-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 18px;
  font-weight: 650;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 0 20px;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 0;
  font-size: 18px;
  font-weight: 550;
  transition: background-color 160ms ease, border-color 160ms ease;
}

.button-primary {
  color: #ffffff;
  background: #111827;
  border-color: #111827;
}

.button-primary:hover {
  background: #374151;
  border-color: #374151;
}

:root[data-theme="dark"] .button-primary {
  color: #111827;
  background: #f3f4f6;
  border-color: #f3f4f6;
}

:root[data-theme="dark"] .button-primary:hover {
  background: #ffffff;
  border-color: #ffffff;
}

.button-secondary {
  background: var(--surface);
}

.button-secondary:hover {
  background: var(--surface-soft);
}

.section {
  padding: 48px 0;
}

.section-heading {
  margin: 0 auto 24px;
  text-align: center;
}

.section-heading h1 {
  margin: 0;
  font-size: clamp(28px, 3vw, 40px);
  line-height: 1.25;
  letter-spacing: -0.025em;
}

.leaderboard-card {
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
}

.result-toolbar {
  position: sticky;
  top: var(--header-height);
  z-index: 12;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  padding: 0 0 8px;
  background: var(--bg);
}

.result-count {
  color: var(--muted);
  font-size: 13px;
}

.table-wrap {
  width: 100%;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  scroll-padding-top: 72px;
  scroll-padding-bottom: 8px;
  border-radius: 0;
  background: var(--surface);
}

.table-wrap:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.results-head th {
  position: sticky;
  top: 0;
  z-index: 6;
  background: var(--surface);
  box-shadow: inset 0 -1px 0 var(--table-line);
}

.results-head th.is-active {
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
}

table {
  /* Fit each column to its longest label/value; scroll instead of wrapping.
     Only the score tracks keep a fixed width. */
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  table-layout: auto;
  font-size: 14px;
}

th,
td {
  padding: 15px 18px;
  border-bottom: 1px solid var(--table-line);
  text-align: left;
  vertical-align: middle;
  white-space: nowrap;
}

th {
  height: 50px;
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
}

.results-head th:last-child {
  border-right: 1px solid var(--line);
}

tbody tr:last-child td {
  border-bottom: 0;
}

tbody tr:hover td {
  background: var(--surface-soft);
}

th.is-active,
td.is-active {
  background: color-mix(in srgb, var(--accent-soft) 72%, transparent);
}

th.is-active .sort-button {
  color: var(--text);
}

.row-number-cell {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

tbody tr:nth-child(-n + 3) .row-number-cell {
  color: var(--accent);
}

.harness-cell {
  --harness-icon-size: 16px;
  --harness-icon-gap: 5px;
}

.harness-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 6px 0 0 calc(var(--harness-icon-size) + var(--harness-icon-gap));
  color: var(--muted-strong);
  font-size: 11px;
}

.config-cell {
  font-variant-numeric: tabular-nums;
}

.cell-context {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted-strong);
}

.sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: flex-start;
  min-height: 24px;
  padding: 0;
  gap: 5px;
  color: inherit;
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
  text-transform: inherit;
  white-space: nowrap;
}

.sort-button:hover {
  color: var(--text);
}

.sort-arrow {
  width: 11px;
  flex: 0 0 11px;
  color: inherit;
  text-align: center;
}

.entity-name {
  display: flex;
  align-items: center;
  max-width: max-content;
  gap: 5px;
  color: var(--text);
  font-size: 14px;
  font-weight: 550;
}

.model-primary {
  display: flex;
  align-items: center;
  min-width: 0;
  flex-wrap: nowrap;
  gap: 7px;
}

.model-primary .entity-name {
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.model-effort {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 14px;
  font-weight: 400;
  white-space: nowrap;
}

.rate-cell {
  display: flex;
  align-items: center;
  gap: 12px;
  font-variant-numeric: tabular-nums;
}

.rate-cell strong {
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
}

.rate-copy {
  display: flex;
  align-items: baseline;
  width: 112px;
  flex: 0 0 112px;
  gap: 4px;
  white-space: nowrap;
}

.rate-copy span {
  color: var(--text);
  font-size: 14px;
}

.accuracy-track {
  position: relative;
  display: block;
  width: 260px;
  min-width: 260px;
  height: 14px;
  flex: 0 0 260px;
  overflow: visible;
  border-radius: 0;
  background: var(--line);
}

.accuracy-fill {
  position: absolute;
  inset: 0 auto 0 0;
  border-radius: 0;
  background: var(--model-unknown);
}

.accuracy-fill[data-model-series="gpt"] { background: var(--model-gpt); }
.accuracy-fill[data-model-series="deepseek"] { background: var(--model-deepseek); }
.accuracy-fill[data-model-series="claude"] { background: var(--model-claude); }
.accuracy-fill[data-model-series="gemini"] { background: var(--model-gemini); }
.accuracy-fill[data-model-series="qwen"] { background: var(--model-qwen); }
.accuracy-fill[data-model-series="kimi"] { background: var(--model-kimi); }
.accuracy-fill[data-model-series="glm"] { background: var(--model-glm); }
.accuracy-fill[data-model-series="grok"] { background: var(--model-grok); }
.accuracy-fill[data-model-series="muse"] { background: var(--model-muse); }

.accuracy-ci {
  position: absolute;
  z-index: 2;
  top: 50%;
  height: 1px;
  border-radius: 0;
  background: var(--ci-line);
  transform: translateY(-50%);
}

.accuracy-cap {
  position: absolute;
  z-index: 2;
  top: 50%;
  width: 1px;
  height: 18px;
  border-radius: 0;
  background: var(--ci-line);
  transform: translate(-50%, -50%);
}

.source-label {
  color: var(--text);
  font-size: inherit;
  font-weight: 400;
  white-space: nowrap;
}

.number-cell {
  color: var(--text);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  font-weight: 400;
}

.missing-value {
  color: var(--muted);
  font-weight: 400;
}

.harness-details-button {
  display: inline-grid;
  grid-template-columns: var(--harness-icon-size) minmax(0, 1fr);
  align-items: center;
  max-width: 100%;
  padding: 0;
  gap: var(--harness-icon-gap);
  color: var(--text);
  background: transparent;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: color 160ms ease;
}

.harness-logo {
  grid-column: 1;
  grid-row: 1;
  width: var(--harness-icon-size);
  height: var(--harness-icon-size);
  object-fit: contain;
}

.harness-details-button > :not(.harness-logo) {
  grid-column: 2;
  grid-row: 1;
}

:root[data-theme="dark"] .harness-logo-monochrome {
  filter: invert(1);
}

.harness-details-button:hover {
  color: var(--accent);
}

.harness-details-button .entity-name {
  min-width: 0;
  overflow: hidden;
  color: inherit;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.harness-details-button:hover .entity-name,
.harness-details-button:focus-visible .entity-name {
  text-decoration: underline;
  text-decoration-color: currentColor;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.loading-cell,
.empty-cell {
  height: 120px;
  color: var(--muted);
  text-align: center;
}

.result-dialog {
  width: min(780px, calc(100% - 32px));
  max-height: min(820px, calc(100dvh - 32px));
  overflow: hidden;
  padding: 0;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: 0;
  box-shadow: 0 24px 80px rgb(0 0 0 / 0.28);
}

.result-dialog::backdrop {
  background: rgb(3 7 18 / 0.58);
  backdrop-filter: blur(4px);
}

.dialog-shell {
  display: flex;
  max-height: min(820px, calc(100dvh - 32px));
  flex-direction: column;
}

.dialog-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 24px 24px 20px;
  gap: 20px;
  border-bottom: 1px solid var(--line);
}

.dialog-header .eyebrow {
  margin-bottom: 6px;
  font-size: 16px;
}

.dialog-header h2 {
  margin: 0;
  font-size: 28px;
  letter-spacing: -0.03em;
}

.dialog-subtitle {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: 17px;
}

.dialog-close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 0;
  cursor: pointer;
  font-size: 25px;
  line-height: 1;
}

.dialog-close:hover {
  color: var(--text);
  background: var(--surface-soft);
}

.dialog-body {
  display: grid;
  padding: 22px 24px;
  gap: 14px;
  overflow-y: auto;
}

.detail-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.detail-summary > div {
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface-soft);
}

.detail-summary strong {
  display: block;
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

.detail-summary span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 16px;
}

.detail-groups {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 12px;
}

.detail-group {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 0;
}

.detail-group h3 {
  margin: 0 0 12px;
  font-size: 18px;
}

.detail-list {
  display: grid;
  margin: 0;
  gap: 9px;
}

.detail-item {
  display: grid;
  grid-template-columns: minmax(90px, 0.9fr) minmax(0, 1.1fr);
  gap: 12px;
  font-size: 16.5px;
}

.detail-item dt {
  color: var(--muted);
  min-width: 0;
  overflow-wrap: anywhere;
}

.detail-item dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.detail-item a {
  color: var(--accent);
}

.dialog-footer {
  display: flex;
  justify-content: flex-end;
  padding: 16px 24px;
  gap: 9px;
  border-top: 1px solid var(--line);
}

.footer {
  border-top: 1px solid var(--line);
}

.footer-inner {
  display: grid;
  min-height: 72px;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 32px;
  color: var(--muted);
  font-size: 14px;
}

.footer-inner a {
  justify-self: end;
}

.footer a:hover {
  color: var(--text);
}

@media (max-width: 980px) {
  .brand span {
    display: none;
  }

}

@media (max-width: 760px) {

  .nav-shell {
    grid-template-columns: 36px minmax(0, 1fr);
    gap: 6px;
  }

  .brand img {
    width: 26px;
    height: 26px;
  }

  .locale-control {
    display: grid;
    grid-template-columns: 1fr;
    place-items: center;
    width: 36px;
    padding: 0;
    gap: 0;
  }

  .locale-icon {
    grid-area: 1 / 1;
  }

  .locale-custom-select {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
  }

  .locale-custom-select .custom-select-trigger {
    width: 100%;
    height: 100%;
    padding: 0;
    opacity: 0;
  }

  .locale-control:has(.custom-select-trigger:focus-visible) {
    outline: 3px solid rgb(107 114 128 / 0.4);
    outline-offset: 2px;
  }

  .locale-custom-select .custom-select-menu {
    top: calc(100% + 6px);
    right: 0;
    width: max-content;
    min-width: 170px;
  }

  .github-link {
    display: none;
  }

  .section {
    padding: 32px 0;
  }

  .detail-groups {
    grid-template-columns: 1fr;
  }

  .footer-inner {
    display: flex;
    padding: 32px 0;
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 460px) {
  .nav-shell,
  .section-shell {
    width: calc(100% - 20px);
  }

  .button {
    width: 100%;
  }

  .result-dialog {
    width: calc(100% - 20px);
    max-height: calc(100dvh - 20px);
  }

  .dialog-shell {
    max-height: calc(100dvh - 20px);
  }

  .dialog-header,
  .dialog-body,
  .dialog-footer {
    padding-right: 16px;
    padding-left: 16px;
  }

  .detail-summary {
    grid-template-columns: 1fr;
  }

  .dialog-footer {
    flex-direction: column;
  }
}

@media (max-width: 360px) {
  .brand {
    display: none;
  }

  .nav-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .nav-actions {
    grid-column: 1;
  }
}

/* Table mode is a viewport-sized workspace. Only its rows scroll; the title,
   navigation and toolbar stay in their normal layout above the scrollport.
   Pareto keeps its existing page-scrolling layout. */
:root[data-result-view="table"] body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

:root[data-result-view="table"] .site-header,
:root[data-result-view="table"] .footer,
:root[data-result-view="table"] .results-heading,
:root[data-result-view="table"] .result-toolbar {
  flex: 0 0 auto;
}

:root[data-result-view="table"] main {
  flex: 1;
  min-height: 0;
}

:root[data-result-view="table"] #results {
  height: 100%;
  padding-bottom: 24px;
}

:root[data-result-view="table"] .results-content {
  display: flex;
  flex-direction: column;
  height: 100%;
}

:root[data-result-view="table"] .leaderboard-card,
:root[data-result-view="table"] #table-panel {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

:root[data-result-view="table"] .result-toolbar {
  position: relative;
  top: auto;
}

:root[data-result-view="table"] .table-wrap {
  flex: 1;
  min-height: 0;
}

:root[data-result-view="table"] .footer-inner {
  display: grid;
  min-height: 44px;
  padding-block: 10px;
  gap: 16px;
}

@media (max-height: 600px) {
  :root[data-result-view="table"] #results {
    padding-block: 12px;
  }

  :root[data-result-view="table"] .results-heading {
    margin-bottom: 12px;
  }
}

#pareto {
  padding: 24px 16px 12px;
}

.pareto-panel {
  min-width: 0;
  width: 100%;
  max-width: 1280px;
  margin-inline: auto;
  padding: 0;
  text-align: left;
  scroll-margin-top: 24px;
}

.pareto-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.pareto-heading {
  margin: 0 0 12px;
  flex-wrap: wrap;
}

.pareto-heading h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.pareto-plot-shell {
  background: var(--surface);
}

.pareto-chart {
  position: relative;
  overflow-x: auto;
}

.pareto-empty {
  margin: 0;
  padding: 48px 16px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.pareto-svg {
  display: block;
  width: 100%;
  min-width: 640px;
}

.pareto-plot-background {
  fill: var(--surface);
}

.pareto-grid {
  stroke: var(--line);
  stroke-width: 1;
  stroke-dasharray: 3 5;
}

.pareto-grid-vertical {
  opacity: 0.7;
}

.pareto-envelope {
  fill: color-mix(in srgb, var(--text) 4%, var(--surface));
}

.pareto-tick,
.pareto-axis-label {
  fill: var(--muted-strong);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.pareto-frontier {
  fill: none;
  stroke: var(--muted-strong);
  stroke-width: 1.5;
  stroke-linejoin: round;
}

.pareto-axis {
  fill: none;
  stroke: var(--faint);
  stroke-width: 1;
}

.pareto-point {
  cursor: pointer;
  outline: none;
}

.pareto-point-hit {
  fill: transparent;
  stroke: transparent;
}

.pareto-point-dot {
  fill: var(--faint);
  stroke: var(--surface);
  stroke-width: 1;
  pointer-events: none;
}

.pareto-point:not(.is-frontier):not(.is-selected) .pareto-point-dot {
  opacity: 0.45;
}

.pareto-point.is-frontier .pareto-point-dot {
  fill: var(--text);
}

.pareto-point:focus-visible .pareto-point-hit {
  fill: color-mix(in srgb, var(--accent) 12%, transparent);
  stroke: var(--accent);
  stroke-width: 1.5;
}

.pareto-point.is-selected .pareto-point-dot {
  stroke: var(--text);
}

.pareto-interval {
  stroke: var(--muted-strong);
  stroke-width: 1;
  fill: none;
  opacity: 0.3;
  pointer-events: none;
}

.pareto-interval.is-frontier {
  opacity: 0.8;
}

.pareto-point-label {
  fill: var(--faint);
  font-size: 13px;
  paint-order: stroke;
  stroke: var(--surface);
  stroke-width: 3px;
  stroke-linejoin: round;
  cursor: pointer;
  pointer-events: bounding-box;
}

.pareto-label-leader {
  display: none;
  fill: none;
  stroke: var(--muted-strong);
  stroke-width: 0.7;
  opacity: 0.55;
  pointer-events: none;
}

.pareto-label-leader.is-selected {
  display: block;
  stroke: var(--accent);
  opacity: 0.9;
}

.pareto-point-label.is-selected {
  fill: var(--text);
  text-decoration: underline;
}

.pareto-chart.has-hover-point {
  cursor: pointer;
}

.pareto-point-label.is-frontier {
  fill: var(--text);
  font-weight: 500;
}

.pareto-tooltip {
  position: fixed;
  z-index: 30;
  width: 320px;
  max-width: calc(100% - 16px);
  padding: 16px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 0;
  box-shadow: 0 4px 16px rgb(0 0 0 / 10%);
  overflow-y: auto;
  pointer-events: auto;
  font-size: 14px;
  line-height: 1.5;
}

.pareto-tooltip > strong,
.pareto-tooltip > span,
.pareto-tooltip > small {
  display: block;
  overflow-wrap: anywhere;
}

.pareto-tooltip > span,
.pareto-tooltip > small {
  color: var(--muted-strong);
  margin-top: 4px;
}

.pareto-tooltip-metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-block: 12px 8px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
  font-variant-numeric: tabular-nums;
}

.pareto-tooltip-metrics span,
.pareto-tooltip-metrics small {
  display: block;
  color: var(--muted-strong);
  font-size: 12px;
}

.pareto-tooltip-metrics b {
  display: block;
  margin-top: 2px;
  font-size: 20px;
  font-weight: 600;
}

/* Source identity is preserved even when both frontiers share the axes. */
.pareto-frontier[data-source="penguin_run"] {
  stroke: var(--accent);
  stroke-width: 2;
  stroke-dasharray: 2 6;
  stroke-linecap: round;
}

.pareto-point[data-source="penguin_run"] .pareto-point-dot {
  fill: var(--accent);
  stroke: var(--surface);
  stroke-width: 2;
}

.pareto-point-label[data-source="penguin_run"] {
  fill: var(--accent-strong);
  font-size: 13px;
  font-weight: 500;
  stroke-width: 3px;
}

.filter-menu-wrap { position: relative; }
.filter-toggle, .view-tabs button, .action-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--muted-strong);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}
.filter-toggle { min-width: 36px; gap: 6px; padding: 0 9px; }
.result-actions { position: relative; display: flex; gap: 8px; margin-right: auto; }
.action-button { width: 34px; padding: 0; }
.action-button:hover, .action-button[aria-expanded="true"] { background: var(--surface-soft); color: var(--text); }
.action-button[aria-busy="true"] { opacity: 0.5; cursor: progress; }
.action-tooltip-wrap { position: relative; display: flex; }
.action-tooltip {
  display: none;
  position: absolute;
  z-index: 1;
  bottom: calc(100% + 8px);
  left: 0;
  width: max-content;
  max-width: calc(100vw - 64px);
  padding: 6px 10px;
  color: var(--surface);
  background: var(--text);
  font-size: 12px;
  line-height: 1.5;
}
.action-tooltip::before {
  content: "";
  position: absolute;
  top: 100%;
  left: 0;
  width: 100%;
  height: 8px;
}
.action-tooltip::after {
  content: "";
  position: absolute;
  top: 100%;
  left: 12px;
  border: 5px solid transparent;
  border-top-color: var(--text);
}
.action-tooltip-wrap:not([data-tooltip-dismissed]):hover > .action-tooltip,
.action-tooltip-wrap:not([data-tooltip-dismissed]) > .action-button:focus-visible + .action-tooltip {
  display: block;
}
.action-tooltip-wrap .export-toggle[aria-expanded="true"] + .action-tooltip { display: none; }
.export-menu-wrap { position: relative; }
.export-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 190px;
  max-width: calc(100vw - 24px);
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 0 6px 20px rgb(0 0 0 / 10%);
}
.export-menu button {
  display: block;
  width: 100%;
  padding: 8px 10px;
  color: var(--text);
  background: transparent;
  border: 0;
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
  font-size: 13px;
}
.export-menu button:hover, .export-menu button:focus-visible { background: var(--line-soft); }
.action-status {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  width: max-content;
  max-width: min(320px, calc(100vw - 24px));
  padding: 8px 12px;
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--line);
  font-size: 13px;
  pointer-events: none;
}
.filter-toggle[aria-expanded="true"], .filter-toggle.has-filters { color: var(--accent); border-color: var(--accent); }
.filter-count { font-size: 11px; }
.view-tabs { display: flex; }
.view-tabs button { min-width: 78px; padding: 0 16px; text-transform: uppercase; }
.view-tabs button + button { border-left: 0; }
.view-tabs button[aria-selected="true"] { color: var(--text); background: var(--line-soft); font-weight: 600; }
.filter-toggle:hover, .view-tabs button:hover { background: var(--surface-soft); }
.filter-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  display: grid;
  grid-template-columns: 148px minmax(0, 280px);
  width: 428px;
  max-width: calc(100vw - 40px);
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: var(--surface);
  box-shadow: 0 6px 20px rgb(0 0 0 / 10%);
}
.filter-categories { display: flex; flex-direction: column; padding: 2px 4px 2px 0; border-right: 1px solid var(--line); }
.filter-categories button { flex-shrink: 0; }
.filter-options { max-height: min(360px, 55vh); overflow-y: auto; padding: 2px 0 2px 4px; }
.filter-menu button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  min-height: 36px;
  padding: 8px 10px;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}
.filter-menu button span:first-child { overflow-wrap: anywhere; }
.filter-menu button:hover, .filter-category.is-active { background: var(--line-soft); }
.filter-menu button[aria-checked="true"] { color: var(--accent); }
.filter-menu .filter-clear { margin-top: auto; border-top: 1px solid var(--line); }
@media (max-width: 380px) {
  .result-toolbar { gap: 8px; }
  .view-tabs button { min-width: 64px; padding: 0 10px; }
}
@media (max-width: 700px) {
  .filter-menu { position: fixed; top: calc(var(--header-height) + 56px); left: 20px; right: 20px; width: auto; grid-template-columns: 110px minmax(0, 1fr); }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    transition: none !important;
  }

}
