.theme-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid #d8dbcf;
  border-radius: 999px;
  background: #fffffb;
  color: #4d5549;
  font-size: 12px;
  line-height: 1.25;
  white-space: nowrap;
}

.theme-toggle:hover,
.theme-toggle:focus-visible {
  border-color: #a229a0;
  color: #5b1553;
}

.theme-toggle:focus-visible {
  outline: 2px solid #a229a0;
  outline-offset: 2px;
}

@media (min-width: 761px) and (max-width: 1150px) {
  .topbar {
    height: auto;
    min-height: var(--topbar-h);
    padding-block: 8px;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  background: #14121a;
  color: #f4eef8;
}

:root[data-theme="dark"] a,
:root[data-theme="dark"] .chat-link,
:root[data-theme="dark"] .submission-modal-details a,
:root[data-theme="dark"] .submission-modal-note a {
  color: #d9b3ff;
}

:root[data-theme="dark"] .topbar {
  border-color: #403648;
  background: rgba(28, 23, 34, .94);
}

:root[data-theme="dark"] .brand,
:root[data-theme="dark"] .contest-tab:hover,
:root[data-theme="dark"] .pareto-track-tab:hover {
  color: #f8f2fb;
}

:root[data-theme="dark"] .contest-tab,
:root[data-theme="dark"] .pareto-track-tab,
:root[data-theme="dark"] .theme-toggle {
  border-color: #51465a;
  background: #292331;
  color: #e4d8ea;
}

:root[data-theme="dark"] .contest-tab.is-active,
:root[data-theme="dark"] .contest-tab.is-active:hover,
:root[data-theme="dark"] .pareto-track-tab.is-active,
:root[data-theme="dark"] .pareto-track-tab.is-active:hover {
  border-color: #d77bd5;
  background: #a229a0;
  color: #fff;
}

:root[data-theme="dark"] .theme-toggle[aria-pressed="true"] {
  border-color: #d77bd5;
  background: #512952;
  color: #fce6fa;
}

:root[data-theme="dark"] .contest-tab-paper::after {
  background: #51465a;
}

:root[data-theme="dark"] .hero {
  border-color: #403648;
  background: #1e1926;
}

:root[data-theme="dark"] .hero::after {
  background:
    linear-gradient(90deg, rgba(22, 18, 29, .97), rgba(22, 18, 29, .78) 38%, rgba(22, 18, 29, .22) 75%),
    linear-gradient(0deg, rgba(22, 18, 29, .85), transparent 52%);
}

:root[data-theme="dark"] .hero-ecc-legend,
:root[data-theme="dark"] .hero-ecc-status,
:root[data-theme="dark"] .metric-leader,
:root[data-theme="dark"] .submission-current-leader {
  border-color: #51465a;
  background: rgba(33, 28, 40, .93);
  color: #f4eef8;
}

:root[data-theme="dark"] .metric,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .row,
:root[data-theme="dark"] .frontier-strip,
:root[data-theme="dark"] .pareto-stat,
:root[data-theme="dark"] .pareto-panel,
:root[data-theme="dark"] .champion-chat-panel,
:root[data-theme="dark"] .chat-message-main,
:root[data-theme="dark"] .submission-modal-dialog,
:root[data-theme="dark"] .pareto-submission-dialog,
:root[data-theme="dark"] .pareto-tooltip {
  border-color: #473c50;
  background: #211c28;
}

:root[data-theme="dark"] .hero .metric {
  background: rgba(33, 28, 40, .87);
}

:root[data-theme="dark"] .lede,
:root[data-theme="dark"] .submission-modal-note,
:root[data-theme="dark"] .hero-ecc-legend,
:root[data-theme="dark"] .pareto-lede {
  color: #cbc0d2;
}

:root[data-theme="dark"] .eyebrow,
:root[data-theme="dark"] .pareto-eyebrow-lead,
:root[data-theme="dark"] .submission-paper-downloads a:hover {
  color: #e1a3e1;
}

:root[data-theme="dark"] .metric-value,
:root[data-theme="dark"] .metric-leader-name,
:root[data-theme="dark"] .metric-hardware-leader,
:root[data-theme="dark"] .frontier-rank,
:root[data-theme="dark"] .frontier-score,
:root[data-theme="dark"] .solver-name,
:root[data-theme="dark"] .score-main,
:root[data-theme="dark"] .pareto-stat-solver-link,
:root[data-theme="dark"] .pareto-tip-solver,
:root[data-theme="dark"] .chat-author,
:root[data-theme="dark"] .champion-message-body,
:root[data-theme="dark"] .champion-empty-state h2,
:root[data-theme="dark"] .submission-modal-details dd,
:root[data-theme="dark"] .submission-modal-note :is(h1, h2, h3, h4, h5, h6, strong) {
  color: #f8f2fb;
}

:root[data-theme="dark"] .muted,
:root[data-theme="dark"] .metric-label,
:root[data-theme="dark"] .metric-detail,
:root[data-theme="dark"] .metric-leader-link-icon,
:root[data-theme="dark"] .site-footer,
:root[data-theme="dark"] .chat-subtitle,
:root[data-theme="dark"] .chat-time,
:root[data-theme="dark"] .solver-meta,
:root[data-theme="dark"] .score-sub,
:root[data-theme="dark"] .created-cell,
:root[data-theme="dark"] .submission-modal-meta,
:root[data-theme="dark"] .submission-detail-pane h3,
:root[data-theme="dark"] .submission-modal-details dt,
:root[data-theme="dark"] .pareto-stat-aside,
:root[data-theme="dark"] .pareto-tip-sub,
:root[data-theme="dark"] .pareto-tip-metric,
:root[data-theme="dark"] .pareto-tip-grid dt,
:root[data-theme="dark"] .pareto-tip-validation-title,
:root[data-theme="dark"] .pareto-tip-validation-note,
:root[data-theme="dark"] .pareto-tip-note,
:root[data-theme="dark"] .pareto-legend,
:root[data-theme="dark"] .pareto-notes,
:root[data-theme="dark"] .pareto-readout,
:root[data-theme="dark"] .pareto-readout-counts {
  color: #bfb3c9;
}

:root[data-theme="dark"] .pareto-eyebrow-rest,
:root[data-theme="dark"] .pareto-external,
:root[data-theme="dark"] .pareto-filter-title,
:root[data-theme="dark"] .pareto-filter-count,
:root[data-theme="dark"] .pareto-replay-status {
  color: #b7aac2;
}

:root[data-theme="dark"] .frontier-list li,
:root[data-theme="dark"] .note,
:root[data-theme="dark"] .copy-box,
:root[data-theme="dark"] .champion-chat-header,
:root[data-theme="dark"] .champion-message-list,
:root[data-theme="dark"] .submission-metric-pair > div,
:root[data-theme="dark"] .submission-diagram-source,
:root[data-theme="dark"] .submission-modal-note,
:root[data-theme="dark"] .master-paper-body,
:root[data-theme="dark"] .pareto-plot-bg {
  border-color: #473c50;
  background: #1a1621;
  color: #f4eef8;
}

:root[data-theme="dark"] .frontier-list li,
:root[data-theme="dark"] .submission-modal-note,
:root[data-theme="dark"] .submission-diagram-source {
  border: 1px solid #473c50;
}

:root[data-theme="dark"] .site-footer span,
:root[data-theme="dark"] .pareto-filter-panel,
:root[data-theme="dark"] .pareto-area-tooltip,
:root[data-theme="dark"] .pareto-badge-pill,
:root[data-theme="dark"] .model-icon,
:root[data-theme="dark"] .submission-modal-note code,
:root[data-theme="dark"] .submission-modal-note pre {
  border-color: #51465a;
  background: #302938;
  color: #f4eef8;
}

:root[data-theme="dark"] .pareto-submission-note th,
:root[data-theme="dark"] .pareto-submission-note td {
  border-color: #51465a;
}

:root[data-theme="dark"] .pareto-tip-close {
  color: #f4eef8;
}

:root[data-theme="dark"] .pareto-replay-date {
  background: #211c29e6;
  color: #f4eef8;
}

:root[data-theme="dark"] .pareto-root.is-fullscreen {
  background: #14121a;
}

:root[data-theme="dark"] .pareto-root.is-fullscreen .pareto-showcase-link {
  background: #211c28e6;
}

:root[data-theme="dark"] .pareto-area-tooltip small {
  color: #c5afc9;
}

:root[data-theme="dark"] .pareto-tip-badge,
:root[data-theme="dark"] .pareto-stat-flag,
:root[data-theme="dark"] .status {
  border-color: #65556e;
  background: #3d3347;
  color: #f0e1f4;
}

:root[data-theme="dark"] .button.secondary,
:root[data-theme="dark"] .icon-button,
:root[data-theme="dark"] .submission-diagram-mode button,
:root[data-theme="dark"] .submission-diagram-toolbar button {
  border-color: #51465a;
  background: #302938;
  color: #f4eef8;
}

:root[data-theme="dark"] .button.secondary.pareto-button {
  border-color: #51465a;
  color: #d5c8de;
}

:root[data-theme="dark"] .button.secondary.pareto-button:hover,
:root[data-theme="dark"] .button.secondary.pareto-button:focus-visible {
  border-color: #a66ba9;
  color: #fff;
}

:root[data-theme="dark"] .button.secondary.pareto-replay-speed[aria-pressed="true"],
:root[data-theme="dark"] .button.secondary.pareto-replay-repeat[aria-pressed="true"] {
  border-color: #bb78bc;
  background: #512952;
  color: #fce6fa;
}

:root[data-theme="dark"] .metric-mode-toggle button,
:root[data-theme="dark"] .metric-mode-toggle button.is-active {
  border-color: #51465a;
  background: #302938;
  color: #f4eef8;
}

:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
  border-color: #51465a;
  background: #1a1621;
  color: #f4eef8;
}

:root[data-theme="dark"] label,
:root[data-theme="dark"] .key-value dt {
  color: #c3b7cf;
}

:root[data-theme="dark"] table,
:root[data-theme="dark"] .score-table {
  border-color: #473c50;
  background: #211c28;
}

:root[data-theme="dark"] th,
:root[data-theme="dark"] .score-table th {
  border-color: #51465a;
  background: #342b3e;
  color: #c9bad2;
}

:root[data-theme="dark"] td,
:root[data-theme="dark"] .score-table td,
:root[data-theme="dark"] .submission-modal-head,
:root[data-theme="dark"] .submission-detail-pane,
:root[data-theme="dark"] .pareto-tip-validation,
:root[data-theme="dark"] .pareto-legend,
:root[data-theme="dark"] .pareto-filter-rule,
:root[data-theme="dark"] .pareto-replay-controls,
:root[data-theme="dark"] .pareto-readout {
  border-color: #473c50;
}

:root[data-theme="dark"] .leaderboard-row:hover,
:root[data-theme="dark"] .score-link:focus-visible,
:root[data-theme="dark"] .icon-button:hover,
:root[data-theme="dark"] .icon-button:focus-visible {
  background: #3e2b4a;
}

:root[data-theme="dark"] .pareto-sort-arrow {
  color: #e7b8ec;
}

:root[data-theme="dark"] .pareto-leaderboard-tabs {
  border-color: #51465a;
}

:root[data-theme="dark"] .pareto-leaderboard-tab {
  color: #c9bad2;
}

:root[data-theme="dark"] .pareto-leaderboard-tab:hover,
:root[data-theme="dark"] .pareto-leaderboard-tab:focus-visible,
:root[data-theme="dark"] .pareto-leaderboard-tab.is-active {
  color: #f4e8f8;
}

:root[data-theme="dark"] .pareto-area-avatar {
  border-color: #51465a;
  background: #342b3e;
}

:root[data-theme="dark"] .pareto-area-avatar-unknown {
  color: #f4e8f8;
}

:root[data-theme="dark"] .pareto-submission-dialog {
  color: #f4eef8;
}

:root[data-theme="dark"] .pareto-leaderboard-table tbody tr:hover {
  background: #3a2d44;
}

:root[data-theme="dark"] .champion-message-self .chat-message-main,
:root[data-theme="dark"] .notice {
  border-color: #655073;
  background: #33263d;
  color: #f4e8f8;
}

:root[data-theme="dark"] .champion-compose {
  border-color: #473c50;
  background: #211c28;
}

:root[data-theme="dark"] .error,
:root[data-theme="dark"] .status.danger {
  border-color: #895354;
  background: #422629;
  color: #ffd2d2;
}

:root[data-theme="dark"] .status.pending {
  background: #49391f;
  color: #ffe0a0;
}

:root[data-theme="dark"] .submission-diagram-mode,
:root[data-theme="dark"] .submission-diagram-toolbar {
  border-color: #51465a;
  background: rgba(33, 28, 40, .96);
}

/* The diagram and PDF frames retain their own document colors. */
:root[data-theme="dark"] .submission-diagram,
:root[data-theme="dark"] .submission-paper-view {
  border-color: #51465a;
}

:root[data-theme="dark"] .pareto-plot-bg {
  fill: #1a1621;
  stroke: #51465a;
}

:root[data-theme="dark"] .pareto-grid {
  stroke: #3d3347;
}

:root[data-theme="dark"] .pareto-score-line,
:root[data-theme="dark"] .pareto-score-leader {
  stroke: #9eacc2;
}

:root[data-theme="dark"] .pareto-score-label {
  fill: #c2cede;
  stroke: #1a1621;
}

:root[data-theme="dark"] .pareto-legend-score-line {
  border-color: #9eacc2;
}

:root[data-theme="dark"] .pareto-tick,
:root[data-theme="dark"] .pareto-axis-title {
  fill: #c5b8ce;
}

:root[data-theme="dark"] .pareto-frontier-line,
:root[data-theme="dark"] .pareto-legend-line {
  stroke: #e07cda;
  border-color: #e07cda;
}

:root[data-theme="dark"] .pareto-frontier-fill {
  fill: #5a315a;
  opacity: .25;
}

:root[data-theme="dark"] .pareto-dot:not(.is-tiered) {
  stroke: #1a1621;
}

:root[data-theme="dark"] .pareto-point.is-active .pareto-ring {
  stroke: #f8f2fb;
}

:root[data-theme="dark"] .pareto-badge-arxiv {
  color: #ff7777;
}

@media (max-width: 760px) {
  :root[data-theme="dark"] .hero::after {
    background:
      linear-gradient(90deg, rgba(22, 18, 29, .98), rgba(22, 18, 29, .76) 65%, rgba(22, 18, 29, .3)),
      linear-gradient(0deg, rgba(22, 18, 29, .88), transparent 60%);
  }
}
