:root {
  --invert-primary: #476c9b;
  /* Full palette: #984447, #984447, #476C9B, #468C98, #101419, #F4A261 */
  --invert-accent: #f4a261;
}

/* Larger header logo */
.md-header__button.md-logo :is(img, svg) {
  height: 2.4rem;
  width: auto;
}

@media (max-width: 600px) {
  .md-header__button.md-logo :is(img, svg) {
    height: 2.1rem;
  }
}

/* Brand colors (Material "custom" palette) */
[data-md-color-scheme="default"],
[data-md-color-scheme="slate"] {
  --md-primary-fg-color: var(--invert-primary);
  --md-accent-fg-color: var(--invert-accent);
}

/* Slightly brighter text in dark mode for contrast */
[data-md-color-scheme="slate"] {
  --md-default-fg-color: rgba(255, 255, 255, 0.92);
  --md-default-fg-color--light: rgba(255, 255, 255, 0.72);
  --md-default-fg-color--lighter: rgba(255, 255, 255, 0.56);
  --md-default-fg-color--lightest: rgba(255, 255, 255, 0.34);
}

/* Subtle polish */
.md-typeset a:hover {
  text-decoration-thickness: 2px;
  text-underline-offset: 0.2em;
}

.md-typeset code {
  border: 1px solid color-mix(in srgb, var(--md-default-fg-color) 12%, transparent);
  border-radius: 0.25rem;
  padding: 0.05em 0.25em;
}

.md-typeset pre > code {
  border: 0;
  /* More breathing room, especially for 1-line commands */
  padding: 0.9rem 1.1rem;
}

.solver-id {
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
}

.solver-id:hover code {
  border-color: color-mix(in srgb, var(--md-accent-fg-color) 55%, transparent);
}

.md-typeset table:not([class]) {
  border: 1px solid color-mix(in srgb, var(--md-default-fg-color) 12%, transparent);
  border-radius: 0.5rem;
  overflow: hidden;
}

.md-typeset table:not([class]) th {
  background: color-mix(in srgb, var(--md-default-fg-color) 6%, transparent);
}

.md-typeset table:not([class]) tr:hover td {
  background: color-mix(in srgb, var(--md-accent-fg-color) 10%, transparent);
}

/* Benchmarks page */
.benchmarks-page .md-main__inner {
  max-width: none;
  margin-left: auto;
  margin-right: auto;
}

.benchmarks-page .md-sidebar--secondary {
  display: none;
}

.benchmarks-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1rem;
  align-items: flex-end;
  margin: 0.75rem 0 0.75rem;
}

.benchmarks-controls label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-weight: 600;
  font-size: 0.85rem;
}

.benchmarks-controls select {
  padding: 0.35rem 0.5rem;
  border: 1px solid color-mix(in srgb, var(--md-default-fg-color) 20%, transparent);
  border-radius: 0.4rem;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  min-width: 14rem;
}

.benchmarks-metric-toggle {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.benchmarks-metric-toggle button {
  padding: 0.3rem 0.55rem;
  font-size: 0.8rem;
  border: 1px solid color-mix(in srgb, var(--md-default-fg-color) 20%, transparent);
  border-radius: 0.4rem;
  background: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  cursor: pointer;
}

.benchmarks-metric-toggle button.active {
  background: var(--md-primary-fg-color);
  color: var(--md-primary-bg-color, #fff);
  border-color: var(--md-primary-fg-color);
}

.benchmarks-summary {
  font-size: 0.85rem;
  color: color-mix(in srgb, var(--md-default-fg-color) 70%, transparent);
  margin: 0.25rem 0 0.75rem;
}

.benchmarks-meta {
  border: 1px solid color-mix(in srgb, var(--md-default-fg-color) 12%, transparent);
  border-radius: 0.5rem;
  padding: 0.65rem 0.75rem;
  background: color-mix(in srgb, var(--md-default-bg-color) 96%, var(--md-default-fg-color) 4%);
  color: var(--md-default-fg-color);
}

.benchmarks-meta-section + .benchmarks-meta-section {
  margin-top: 0.65rem;
}

.benchmarks-meta-title {
  font-weight: 700;
  font-size: 0.85rem;
  margin-bottom: 0.35rem;
}

.benchmarks-meta-collapsible > summary.benchmarks-meta-title {
  cursor: pointer;
  list-style: none;
  user-select: none;
}

.benchmarks-meta-collapsible > summary.benchmarks-meta-title::-webkit-details-marker {
  display: none;
}

.benchmarks-meta-collapsible > summary.benchmarks-meta-title::before {
  content: "▸ ";
  display: inline;
}

.benchmarks-meta-collapsible[open] > summary.benchmarks-meta-title::before {
  content: "▾ ";
}

.benchmarks-meta-headline {
  font-weight: 700;
  margin-top: -0.1rem;
}

.benchmarks-meta-desc {
  margin: 0.2rem 0 0.35rem;
  color: color-mix(in srgb, var(--md-default-fg-color) 75%, transparent);
  font-size: 0.82rem;
}

.benchmarks-meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12.5rem, 1fr));
  gap: 0.35rem 0.9rem;
}

.benchmarks-meta-item {
  min-width: 0;
}

.benchmarks-meta-k {
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--md-default-fg-color) 65%, transparent);
}

.benchmarks-meta-v {
  font-size: 0.86rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
}

.benchmarks-meta-footer {
  margin-top: 0.65rem;
  font-size: 0.8rem;
  color: color-mix(in srgb, var(--md-default-fg-color) 70%, transparent);
}

.benchmarks-table-wrap {
  border: 1px solid color-mix(in srgb, var(--md-default-fg-color) 12%, transparent);
  border-radius: 0.5rem;
  overflow-x: auto;
  overflow-y: visible;
  -webkit-overflow-scrolling: touch;
}

.benchmarks-table {
  width: 100%;
  border-collapse: collapse;
  background: var(--md-default-bg-color);
}

.benchmarks-table th,
.benchmarks-table td {
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid color-mix(in srgb, var(--md-default-fg-color) 10%, transparent);
  font-size: 0.85rem;
  vertical-align: middle;
}

.benchmarks-table th {
  position: sticky;
  top: 0;
  background: color-mix(in srgb, var(--md-default-bg-color) 92%, var(--md-default-fg-color) 8%);
  text-align: left;
  white-space: nowrap;
  cursor: default;
  user-select: none;
}

.benchmarks-table th.num {
  text-align: right;
}

.benchmarks-table th.sortable {
  cursor: pointer;
}

.benchmarks-table th.sortable:hover {
  background: color-mix(in srgb, var(--md-default-bg-color) 88%, var(--md-default-fg-color) 12%);
}

.benchmarks-sort-indicator {
  display: inline-block;
  width: 0.9rem;
  height: 0.9rem;
  margin-left: 0.35rem;
  vertical-align: -0.15em;
  background-color: color-mix(in srgb, var(--md-default-fg-color) 55%, transparent);
  -webkit-mask-image: var(--md-typeset-table-sort-icon);
  mask-image: var(--md-typeset-table-sort-icon);
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  -webkit-mask-size: contain;
  mask-size: contain;
  opacity: 0.35;
}

.benchmarks-table th.sorted .benchmarks-sort-indicator {
  opacity: 0.85;
}

.benchmarks-table th.sorted[data-sort-dir="asc"] .benchmarks-sort-indicator {
  -webkit-mask-image: var(--md-typeset-table-sort-icon--asc);
  mask-image: var(--md-typeset-table-sort-icon--asc);
}

.benchmarks-table th.sorted[data-sort-dir="desc"] .benchmarks-sort-indicator {
  -webkit-mask-image: var(--md-typeset-table-sort-icon--desc);
  mask-image: var(--md-typeset-table-sort-icon--desc);
}

.benchmarks-table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.benchmarks-table tr:hover td {
  background: color-mix(in srgb, var(--md-accent-fg-color) 10%, transparent);
}

.benchmarks-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.benchmarks-dot {
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 999px;
  background: var(--benchmarks-category-color, var(--md-accent-fg-color));
  opacity: 0.9;
}

.benchmarks-solver-link {
  color: var(--md-typeset-a-color);
}

.benchmarks-link-icon::after {
  content: "↗";
  display: inline-block;
  margin-left: 0.25rem;
  font-size: 0.85em;
  vertical-align: 0.1em;
}
