:root {
  color-scheme: light;
  --ink: #22232e;
  --muted: #575b6c;
  --meta: #686c7d;
  --line: #e5e5ed;
  --border: #c9cbd7;
  --surface: #f5f5f9;
  --paper: #fff;
  --accent: #5040bc;
  --focus: #6953e4;
  --tint: #f0edff;
  --up: #087154;
  --down: #aa374d;
  --radius: 16px;
  --shell-width: 1056px;
  --gutter: clamp(16px, 3.4vw, 36px);
}
*, *::before, *::after {box-sizing: border-box}
[hidden] {display: none !important}
html {background: #f8f8fb; -webkit-text-size-adjust: 100%}
body {
  margin: 0;
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Hiragino Sans", "Yu Gothic", sans-serif;
  font-variant-numeric: tabular-nums;
}
.shell, .dock-inner {
  width: 100%;
  max-width: var(--shell-width);
  margin-inline: auto;
  padding-inline: max(var(--gutter), env(safe-area-inset-left)) max(var(--gutter), env(safe-area-inset-right));
}
main.shell {padding-block: 24px max(40px, env(safe-area-inset-bottom))}
h1, h2, h3, p, dl, dt, dd {margin: 0}
h1 {font-size: 17px; line-height: 1.35; font-weight: 720; letter-spacing: .01em}
h2 {font-size: clamp(23px, 3.2vw, 33px); line-height: 1.3; font-weight: 740; letter-spacing: -.025em}
h3 {font-size: 18px; line-height: 1.4; font-weight: 700}
a {color: var(--accent); text-underline-offset: 3px}
button, select, input {font: inherit; color: inherit; font-variant-numeric: inherit}
button, select, summary {cursor: pointer; -webkit-tap-highlight-color: transparent}
button, select {
  min-height: 44px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--paper);
  padding: 7px 12px;
  touch-action: manipulation;
}
select {
  appearance: none;
  -webkit-appearance: none;
  padding-inline: 12px 31px;
  background-image: linear-gradient(45deg, transparent 50%, var(--meta) 50%),
                    linear-gradient(135deg, var(--meta) 50%, transparent 50%);
  background-position: calc(100% - 17px) 53%, calc(100% - 12px) 53%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
}
button:disabled, select:disabled, input:disabled {color: #717381; background-color: var(--surface); cursor: default}
:focus-visible {position: relative; z-index: 1; outline: 3px solid var(--focus); outline-offset: 2px}
:where(h2, h3)[tabindex="-1"]:focus {outline: none}
.page-header {background: var(--paper); border-bottom: 1px solid var(--line)}
.page-header .shell {display: flex; align-items: center; gap: 11px; min-height: 58px}
.brand-mark {
  display: inline-grid;
  place-items: center;
  position: relative;
  flex: none;
  width: 32px;
  height: 32px;
  background: var(--accent);
  border-radius: 10px;
}
.brand-mark::before, .brand-mark::after {
  content: "";
  position: absolute;
  width: 23px;
  height: 13px;
  border: 1.5px solid white;
  border-radius: 20px;
  transform: rotate(-28deg);
}
.brand-mark::after {width: 15px; height: 6px; border-width: 1px}

#catalog, #race, #settings-view, #race-view {min-width: 0}
.switch, .view-tabs {
  display: inline-flex;
  gap: 3px;
  align-items: stretch;
  max-width: 100%;
  padding: 3px;
  background: #eeeef4;
  border-radius: 12px;
}
.switch button, .view-tabs button, .comparison-sheet :is(#sort-prob, #sort-change) {
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  padding-inline: 18px;
}
.switch button[aria-pressed="true"], .view-tabs button[aria-selected="true"],
.comparison-sheet :is(#sort-prob, #sort-change)[aria-pressed="true"] {
  background: var(--paper);
  color: var(--accent);
  border-color: #dedde8;
  box-shadow: 0 1px 3px #2022380b;
}
#catalog .switch:has(#replay-mode[hidden]) {display: none}
#catalog h2 {margin-block: 20px 14px}
.selectors {display: flex; flex-wrap: wrap; align-items: end; gap: 10px 14px; margin-block: 12px 16px}
.selectors label, .focus-panel label {font-size: 12px; color: var(--muted); font-weight: 650}
.selectors label {display: grid; gap: 5px; min-width: 0}
.selectors select {min-width: 140px; width: 100%; color: var(--ink); font-size: 16px; font-weight: 550}
#refresh {color: var(--muted); font-size: 13px; font-weight: 600}
#catalog-status, #preset-status {font-size: 13px; color: var(--muted)}
#catalog-status {margin-block: 12px 9px; overflow-wrap: anywhere}
#catalog-status[data-error="true"] {color: var(--down)}
.race-list, .table-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.race-list:empty {display: none}
.race-list > p {padding: 18px; color: var(--muted)}
.race-link {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  width: 100%;
  min-height: 66px;
  padding: 9px 16px;
  border: 0;
  border-radius: 0;
  text-align: left;
}
.race-link + .race-link {border-top: 1px solid var(--line)}
.race-link:first-child {border-start-start-radius: var(--radius); border-start-end-radius: var(--radius)}
.race-link:last-child {border-end-start-radius: var(--radius); border-end-end-radius: var(--radius)}
.race-link .number {
  display: grid; place-items: center; min-height: 35px;
  color: #424354; background: var(--surface); border-radius: 7px;
  font-size: 15px; font-weight: 750; white-space: nowrap;
}
.race-info, .horse-label {min-width: 0}
.race-info strong {display: block; font-size: 16px; line-height: 1.4; overflow-wrap: anywhere}
.race-info small {display: block; color: var(--muted); margin-top: 3px; font-size: 12px}
.race-action {font-size: 12px; font-weight: 650; color: var(--muted); text-align: end}
.race-action::after {content: ""; display: inline-block; width: 6px; height: 6px; border: solid currentColor; border-width: 1.5px 1.5px 0 0; transform: rotate(45deg); margin-inline: 6px 1px; vertical-align: .1em}
.race-link[data-state="ready"] .race-action {color: var(--accent)}
.race-link[data-state="ready"] .number {background: var(--tint); color: var(--accent)}

#back {border: 0; margin-inline-start: -4px; padding: 0 4px; background: transparent; color: var(--accent); font-size: 14px; font-weight: 650}
.race-head {margin-block: 0 15px}
.race-meta {display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; margin-top: 5px; color: var(--muted); font-size: 13px}
#race-context, #race-reason {color: var(--muted); font-size: 13px; overflow-wrap: anywhere}
#race-reason:not(:empty) {margin-top: 5px}
#going-choice {max-width: 100%; min-height: 44px; font-size: 16px; color: var(--ink)}
#going-label {display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; color: var(--muted); font-weight: 600}
.view-tabs {margin-bottom: 15px}
.view-tabs button {min-width: 112px}
#model-panel {margin-block-end: 16px}
.focus-panel {
  min-width: 0;
  padding: 15px 19px;
  border: 1px solid #d9d5ec;
  border-radius: var(--radius);
  background: linear-gradient(120deg, #fff 35%, #f0edff 100%);
}
.focus-line {display: flex; gap: 9px; align-items: center; min-width: 0}
.focus-line label {display: flex; flex: 1; align-items: center; gap: 9px; min-width: 0}
.focus-caption {flex: none; font-size: 12px}
#focus-bib, #dock-bib {display: inline-flex; flex: none}
#focused {min-width: 0; max-width: 100%; width: auto; font-size: 16px; font-weight: 700; color: var(--ink)}
.metric-line {display: flex; align-items: center; flex-wrap: wrap; gap: 8px 22px; margin-top: 9px}
.main-prob {display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap}
.metric-caption, .metric-side {color: var(--muted); font-size: 12px}
#current {color: #32295e; font-size: clamp(34px, 4vw, 46px); font-weight: 720; letter-spacing: -.045em; line-height: 1.1; white-space: nowrap}
.metric-side {display: flex; align-items: baseline; flex-wrap: wrap; gap: 3px 12px}
.metric-side > span, #base, #delta, #rank {white-space: nowrap}
#base, #delta, #rank {font-size: 14px; font-weight: 680}
#race-preset {color: var(--accent); font-size: 12px; font-weight: 650}
#last-change, #factor-help, #pedigree-note {font-size: 13px; color: var(--muted); line-height: 1.55}
#last-change:not(:empty) {margin-top: 6px}
.ranking-head {display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; padding: 12px 15px 10px}
.ranking-head h3 {font-size: 17px}
#runner-count {color: var(--muted); font-size: 13px}
.table-wrap {min-width: 0; max-width: 100%}
table {width: 100%; border-spacing: 0; border-collapse: separate; font-size: 14px}
th, td {text-align: left; padding: 4px 12px; border-bottom: 1px solid var(--line)}
th {padding-block: 8px; color: var(--muted); font-size: 12px; font-weight: 650; background: var(--surface)}
td {vertical-align: middle; line-height: 1.35}
tbody tr:last-child td {border-bottom: 0}
tbody tr:last-child td:first-child {border-end-start-radius: var(--radius)}
tbody tr:last-child td:last-child {border-end-end-radius: var(--radius)}
td.num, th.num, th:nth-child(n+3), th:nth-last-child(1):nth-child(2) {text-align: right; white-space: nowrap}
td.num:nth-child(3), td.num:nth-last-child(1):nth-child(2) {font-weight: 700}
#runner-list td:first-child:not(:has(.horse-pick)) {width: 4em; color: var(--muted); font-size: 13px}
.horse-pick {
  display: inline-flex; align-items: center; gap: 10px; min-width: 0; max-width: 100%;
  min-height: 44px; padding: 0; border: 0; border-radius: 4px;
  background: transparent; text-align: left;
}
.horse-label, .horse-label strong, .horse-label small {display: block}
.horse-label strong {font-size: 15px; line-height: 1.35; font-weight: 670; overflow-wrap: anywhere}
.horse-label small, td small {color: var(--muted); font-size: 11.5px; line-height: 1.45; margin-top: 2px}
tr[data-focused="true"] td {background: var(--tint)}
tr[data-focused="true"] td:first-child {box-shadow: inset 3px 0 0 var(--accent)}
tr[data-focused="true"] .horse-label strong {color: #392c86}
.bib {
  display: inline-grid; place-items: center; flex: none; min-width: 33px; height: 33px; padding-inline: 3px;
  border: 1px dashed var(--meta); border-radius: 7px; color: var(--ink); background: var(--surface);
  font-size: 17px; font-weight: 750; font-variant-numeric: tabular-nums; line-height: 1;
}
.bib[data-frame="1"] {background: #fff; color: var(--ink); border: 1px solid #9698a5}
.bib[data-frame="2"] {background: #292a34; color: #fff; border: 1px solid #292a34}
.bib[data-frame="3"] {background: #bf303e; color: #fff; border: 1px solid #ae2633}
.bib[data-frame="4"] {background: #2757a2; color: #fff; border: 1px solid #224b90}
.bib[data-frame="5"] {background: #ffda4d; color: #302a0b; border: 1px solid #d1ac30}
.bib[data-frame="6"] {background: #177147; color: #fff; border: 1px solid #10633e}
.bib[data-frame="7"] {background: #f5a04d; color: #3a2312; border: 1px solid #d3863d}
.bib[data-frame="8"] {background: #f0a7c1; color: #3d2230; border: 1px solid #d48ca7}
.up {color: var(--up)}
.down {color: var(--down)}
#presets, #race-details {border-bottom: 1px solid var(--line); margin-top: 8px}
summary {min-height: 44px; padding: 11px 3px; color: var(--muted); font-size: 14px; font-weight: 630}
.preset-actions {display: flex; flex-wrap: wrap; gap: 8px; margin-block: 6px 12px}
.preset-actions button {font-size: 14px}
#race-details a {display: inline-flex; align-items: center; min-height: 44px}
#source-time, #preset-status {padding-bottom: 8px; font-size: 13px; color: var(--muted)}
#preset-status:empty {padding: 0}

.settings-layout {display: grid; gap: 14px; align-items: start}
.preset-block, .factors-block {
  min-width: 0;
  padding: 17px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
.section-head {display: flex; align-items: center; gap: 8px; justify-content: space-between; margin-bottom: 13px}
.section-head h3 {font-size: 17px}
#preset-name, #race-preset {
  display: inline-block; max-width: 100%; padding: 3px 8px;
  border: 1px solid #dad4f1; border-radius: 20px; color: #554392;
  background: #f8f6ff; font-size: 12px; font-weight: 650; line-height: 1.35;
}
#preset-name:empty, #race-preset:empty {display: none}
.preset-grid {display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px}
.preset-grid button {
  position: relative;
  display: grid; align-content: center; gap: 2px; min-height: 62px; padding: 8px 11px;
  border-color: var(--line); border-radius: 10px; text-align: left;
}
.preset-grid strong {font-size: 15px; font-weight: 670}
.preset-grid small {color: var(--muted); font-size: 12px}
.preset-grid button[aria-pressed="true"] {background: var(--tint); border-color: var(--accent); box-shadow: inset 0 0 0 .5px var(--accent)}
.preset-grid button[aria-pressed="true"] strong {padding-right: 20px; color: var(--accent)}
.preset-grid button[aria-pressed="true"]::after {
  content: ""; position: absolute; inset: 12px 12px auto auto; width: 7px; height: 12px;
  border: solid var(--accent); border-width: 0 2px 2px 0; transform: rotate(42deg);
}
.preset-grid button:disabled {color: var(--muted); background: #f4f4f7; border-style: dashed}
#pedigree-note:not(:empty) {margin-top: 10px}
#changed-list {display: flex; flex-wrap: wrap; align-items: center; gap: 5px; color: var(--muted); font-size: 12px}
#changed-list:not(:empty) {margin-top: 11px}
.change-chip {
  display: inline-flex; flex-wrap: wrap; align-items: center; min-width: 0;
  padding: 3px 8px; border-radius: 6px; color: #4a3c8e; background: var(--tint);
  font-weight: 600; overflow-wrap: anywhere;
}
button.change-chip {min-height: 44px}
#factor-list {min-width: 0; border-top: 1px solid var(--line)}
.factor-row {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 48px;
  border: 0; border-radius: 0; border-bottom: 1px solid var(--line);
  padding: 6px 8px; text-align: left; background: var(--paper);
}
.factor-name {min-width: 0; flex: 1; font-size: 14px; font-weight: 600; overflow-wrap: anywhere}
.factor-value {flex: none; color: var(--muted); font-size: 14px; font-weight: 650}
.factor-row::after {
  content: ""; flex: none; width: 7px; height: 7px; border: solid var(--meta);
  border-width: 0 1.5px 1.5px 0; transform: rotate(45deg); margin: -3px 4px 0 2px;
}
.factor-row[data-changed="true"] .factor-value {color: var(--accent)}
.factor-row[data-active="true"] {background: var(--tint); border-color: var(--tint); color: var(--accent)}
.factor-row[data-active="true"] .factor-value {color: var(--accent)}
.factor-row[data-active="true"]::after {transform: rotate(225deg); margin-top: 4px; border-color: var(--accent)}
#factor-editor {padding: 12px; border: 1px solid #ded9f6; border-top: 0; border-radius: 0 0 9px 9px; background: #faf9ff}
.editor-head {display: flex; align-items: center; gap: 11px}
.editor-head {justify-content: space-between; color: var(--muted); font-size: 13px; font-weight: 600}
#weight {color: var(--accent); font-size: 19px; font-weight: 730}
.factor-levels {display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-block: 7px}
.factor-levels button {
  min-width: 0; min-height: 44px; padding: 4px 2px; background: var(--paper);
  font-size: .77rem; font-weight: 650; color: var(--text); overflow-wrap: anywhere;
}
.factor-levels button[aria-pressed="true"] {background: var(--accent); color: white; border-color: var(--accent)}
#learned {grid-column: 1 / -1; background: #f7f5ff; border-color: #dcd4f5}
#learned[aria-pressed="true"] {background: var(--tint); border-color: var(--accent)}
#learned strong {overflow-wrap: anywhere}
#learned-details {margin-top: 6px; padding: 0; border: 0}
#learned-details summary {min-height: 44px; padding: 10px 0; color: var(--accent); font-size: .82rem}
#learned-details p {font-size: .81rem; color: var(--muted)}
#learned-factors {list-style: none; margin: 6px 0; padding: 0; font-size: .8rem}
#learned-factors li {display: flex; justify-content: space-between; gap: 8px; padding: 5px 0; border-top: 1px solid var(--line)}
#learned-factors strong {color: var(--muted); white-space: nowrap}
.settings-layout #presets {margin: 0; padding-inline: 3px}
#settings-view {padding-bottom: calc(var(--impact-height, 220px) + 18px)}
html:has(#race:not([hidden]) #settings-view:not([hidden])) {scroll-padding-bottom: calc(var(--impact-height, 220px) + 10px)}
.impact-dock {
  position: fixed; z-index: 3; inset: auto 0 0; max-height: 40vh; max-height: 40dvh;
  overflow-y: auto; overscroll-behavior: contain; background: var(--paper);
  border-top: 1px solid #c8c2e1; box-shadow: 0 -4px 18px #26213b0c;
}
.dock-inner {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 13px; align-items: center;
  padding-block: 9px max(9px, env(safe-area-inset-bottom));
}
.dock-horse {display: flex; align-items: center; min-width: 0; gap: 7px}
.dock-horse .bib {min-width: 26px; height: 26px; border-radius: 5px; font-size: 14px}
#dock-name {min-width: 0; font-size: 15px; line-height: 1.35; overflow-wrap: anywhere}
#dock-rank {flex: none; font-size: 12px; font-weight: 630; color: var(--muted)}
.dock-values {display: flex; flex-wrap: wrap; align-items: baseline; gap: 2px 7px; line-height: 1.35; color: var(--muted); font-size: 12px}
.dock-values > span {white-space: nowrap}
#dock-current {font-size: 24px; line-height: 1.1; letter-spacing: -.04em; color: #32295e}
#dock-delta {font-weight: 660}
.dock-movers {display: flex; flex-wrap: wrap; gap: 3px 16px; min-width: 0; color: var(--muted); font-size: 12px}
.dock-movers > span {min-width: 0; overflow-wrap: anywhere}
.dock-movers b {font-weight: 600; color: var(--ink)}
.dock-movers b.up {color: var(--up)}
.dock-movers b.down {color: var(--down)}
#open-comparison {background: var(--accent); color: white; border-color: transparent; font-size: 13px; font-weight: 650}
#open-comparison span {margin-inline-start: 2px}
.comparison-sheet, .horse-sheet {
  width: min(740px, calc(100% - 48px)); max-width: 100%; max-height: 85vh; max-height: 85dvh;
  border: 1px solid var(--line); border-radius: 20px; padding: 0;
  color: var(--ink); overflow: hidden; box-shadow: 0 18px 70px #211d3924;
}
.comparison-sheet[open], .horse-sheet[open] {display: flex; flex-direction: column}
.comparison-sheet::backdrop, .horse-sheet::backdrop {background: #1c192853}
html.comparison-open, html.comparison-open body {overflow: hidden}
.sheet-head {display: flex; flex: none; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 18px 6px}
.sheet-head h3 {font-size: 19px}
#close-comparison, #horse-close {font-size: 13px; font-weight: 620; color: var(--muted); background: var(--surface); border-color: transparent}
.sheet-sort {display: flex; align-self: flex-start; flex: none; gap: 2px; padding: 2px; margin: 4px 18px 12px; background: var(--surface); border-radius: 10px}
.comparison-sheet :is(#sort-prob, #sort-change) {font-size: 13px; padding-inline: 12px}
.sheet-scroll {min-height: 0; overflow: auto; overscroll-behavior: contain; scrollbar-gutter: stable}
.sheet-scroll thead th {position: sticky; top: 0; z-index: 1; box-shadow: 0 1px 0 var(--line)}
.sheet-scroll th:nth-child(n+3), .sheet-scroll td:nth-child(n+3) {text-align: right; white-space: nowrap}
.sheet-scroll td:nth-child(3) {font-weight: 500}
.sheet-scroll td:nth-child(4) {font-weight: 700}
.sheet-scroll .horse-label strong {font-size: 14px}
.sheet-scroll .horse-pick {gap: 7px}

#dock-horse-open {
  justify-self: start;
  max-width: 100%;
  padding: 2px 7px 2px 0;
  border: 0;
  background: transparent;
  text-align: left;
}
#dock-horse-open > span:last-child {font-size: 20px; line-height: 1; color: var(--accent)}
.focus-panel:has(#focus-horse-open) {display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 8px}
.focus-panel:has(#focus-horse-open) .focus-line {grid-column: 1 / -1}
.focus-panel:has(#focus-horse-open) .metric-line {grid-area: 2 / 1}
.focus-panel:has(#focus-horse-open) #last-change {grid-row: 3; grid-column: 1 / -1}
#focus-horse-open {
  grid-area: 2 / 2; align-self: center; min-width: 0; padding: 5px 2px;
  border: 0; background: transparent; color: var(--accent); font-size: .78rem; font-weight: 650;
}
.horse-sheet {width: min(640px, calc(100% - 48px)); --chart-gutter: 22px}
.horse-sheet-head {
  display: flex; flex: none; align-items: center; gap: 9px;
  padding: 15px var(--chart-gutter) 12px;
  background: var(--paper);
}
#horse-detail-bib {display: inline-flex; flex: none}
.horse-sheet-identity {min-width: 0; flex: 1; overflow-wrap: anywhere}
#horse-detail-name {font-size: 1.12rem; font-weight: 720; line-height: 1.35}
#horse-detail-context {margin-top: 2px; color: var(--muted); font-size: .77rem}
.horse-sheet-metrics {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  flex: none; margin: 0 var(--chart-gutter) 14px; padding: 9px 0;
  background: #f7f6fb; border: 1px solid var(--line); border-radius: 11px;
}
.horse-sheet-metrics > div {display: grid; min-width: 0; align-content: start; gap: 2px; padding-inline: 12px}
.horse-sheet-metrics > div + div {border-inline-start: 1px solid #dedde7}
.horse-sheet-metrics span {font-size: .75rem; color: var(--muted)}
.horse-sheet-metrics strong {font-size: clamp(1.02rem, 2.6vw, 1.26rem); line-height: 1.25; letter-spacing: -.02em; overflow-wrap: anywhere}
#horse-current {color: #473685}
.horse-sheet[data-has-adjustment="false"] .horse-sheet-metrics {grid-template-columns: 1.35fr 1fr}
.horse-sheet[data-has-adjustment="false"] .horse-sheet-metrics > div:nth-child(2) {display: none}
.horse-sheet[data-has-adjustment="false"] #horse-standard {font-size: 1.38rem; color: #423467}
.horse-chart-tabs {
  display: flex; flex: none; gap: 5px; padding-inline: var(--chart-gutter);
  border-bottom: 1px solid var(--line);
}
.horse-chart-tabs button {
  position: relative; min-width: 0; border: 0; border-radius: 0;
  padding: 6px 9px 9px; color: var(--muted); background: transparent;
  font-size: .875rem; font-weight: 650;
}
.horse-chart-tabs button[aria-pressed="true"] {color: var(--accent)}
.horse-chart-tabs button[aria-pressed="true"]::after {
  content: ""; position: absolute; inset: auto 6px 0; height: 3px;
  border-radius: 4px 4px 0 0; background: currentColor;
}
.horse-chart-body {
  overflow: auto; min-height: 0; overscroll-behavior: contain;
  padding: 12px var(--chart-gutter) 18px;
}
.horse-chart-body:focus-visible {outline-offset: -3px}
#horse-chart-note {font-size: .81rem; color: var(--muted); line-height: 1.6}
#horse-chart-rows:not(:empty) {margin-top: 9px; border-top: 1px solid var(--line)}
.horse-impact-row {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(88px, .96fr) 6.3rem;
  grid-template-areas: "label bar value"; align-items: center; gap: 4px 12px;
  padding: 9px 0; min-height: 42px; border-bottom: 1px solid var(--line);
}
.horse-impact-label {grid-area: label; min-width: 0; overflow-wrap: anywhere; font-size: .9rem; font-weight: 620}
.horse-impact-weight {display: block; color: var(--muted); font-size: .74rem; font-weight: 450}
.horse-impact-value {
  grid-area: value; min-width: 6.3ch; justify-self: end; text-align: right;
  color: var(--muted); font-size: .85rem; white-space: nowrap;
}
.horse-impact-bar {grid-area: bar; display: block; width: 100%; height: 9px; background: #f1f1f5; border-radius: 3px}
.horse-impact-fill {fill: var(--meta)}
.horse-impact-zero {stroke: #9695a4; stroke-width: 1; vector-effect: non-scaling-stroke}
.horse-impact-row[data-sign="positive"] .horse-impact-value {color: var(--up)}
.horse-impact-row[data-sign="negative"] .horse-impact-value {color: var(--down)}
.horse-impact-row[data-sign="positive"] .horse-impact-fill {fill: #228368}
.horse-impact-row[data-sign="negative"] .horse-impact-fill {fill: #b64d60}
.horse-impact-row[data-kind="endpoint"] {
  background: #f7f6fb; border-radius: 7px; border-bottom: 0;
  padding-inline: 9px; margin-inline: -9px;
}
.horse-impact-row[data-kind="endpoint"] .horse-impact-value {color: #423467; font-size: 1rem}
.horse-impact-row[data-kind="endpoint"] .horse-impact-fill {fill: var(--accent)}
#horse-expand {
  display: block; width: 100%; margin-top: 10px; padding-inline: 8px;
  color: var(--accent); background: var(--paper); font-size: .84rem; font-weight: 650;
}
.horse-bridge-method, #horse-omissions p {margin: 10px 0 4px; color: var(--muted); font-size: .77rem}
#horse-omissions {margin-top: 8px; border-top: 1px solid var(--line)}
#horse-omissions summary {padding-block: 12px; min-height: 44px; color: var(--accent); font-size: .84rem; font-weight: 650; cursor: pointer}
#horse-omit-rows {list-style: none; padding: 0; margin: 6px 0 0}
#horse-omit-rows li {display: flex; justify-content: space-between; gap: 8px; padding-block: 8px; border-bottom: 1px solid var(--line); font-size: .81rem}
#horse-omit-rows strong {white-space: nowrap}

@media (min-width: 761px) {
  .settings-layout {grid-template-columns: minmax(270px, .85fr) minmax(0, 1.25fr); grid-template-rows: auto 1fr;
    grid-template-areas: "presets factors" "saved factors"; gap: 14px 22px}
  .preset-block {grid-area: presets}
  .factors-block {grid-area: factors}
  .settings-layout #presets {grid-area: saved}
  .dock-inner {grid-template-columns: minmax(0, 1fr) auto auto; gap: 3px 18px; padding-block: 12px max(12px, env(safe-area-inset-bottom))}
  .dock-horse {grid-column: 1; grid-row: 1}
  .dock-values {grid-column: 2; grid-row: 1}
  .dock-movers {grid-column: 1 / 3; grid-row: 2}
  #open-comparison {grid-column: 3; grid-row: 1 / 3}
}
@media (max-width: 760px) {
  main.shell {padding-top: 6px}
  .page-header .shell {min-height: 48px}
  .brand-mark {width: 29px; height: 29px; border-radius: 9px}
  .selectors {display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px}
  .selectors select {min-width: 0}
  .race-link {grid-template-columns: 39px minmax(0, 1fr) auto; gap: 9px; padding-inline: 10px; min-height: 61px}
  .race-action {max-width: 7.5em}
  #catalog h2 {margin-block: 14px 12px}
  .race-head {margin-bottom: 10px}
  .view-tabs {display: flex; margin-bottom: 12px}
  .view-tabs button {flex: 1; min-width: 0}
  #model-panel {margin-bottom: 12px}
  .focus-panel {padding: 11px 12px}
  .focus-line {display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 2px 7px}
  .focus-line label {position: relative; display: block}
  .focus-caption {position: absolute; top: 0; inset-inline-start: 0; pointer-events: none}
  #focused {min-height: 48px; width: 100%; border: 0; padding: 17px 21px 0 0; background-color: transparent;
    background-position: calc(100% - 10px) 52%, calc(100% - 5px) 52%}
  .metric-line {gap: 5px 12px; margin-top: 4px}
  .metric-side {gap: 2px 8px}
  .metric-side b {font-size: 13px}
  .ranking-head {padding: 9px 10px}
  th, td {padding-inline: 5px}
  th {font-size: 11px}
  #runner-list td:first-child:not(:has(.horse-pick)) {width: 2.4em}
  .horse-pick {gap: 6px}
  .horse-label strong {font-size: 14px}
  .bib {min-width: 29px; height: 29px; border-radius: 6px; font-size: 16px}
  td.num {font-size: 13px}
  .preset-block, .factors-block {padding: 12px}
  .section-head {margin-bottom: 9px}
  .settings-layout {gap: 10px}
  .dock-horse {grid-column: 1 / -1}
  .dock-values {grid-column: 1 / -1}
  .dock-movers {display: grid; gap: 1px; line-height: 1.35}
  .dock-inner {gap: 4px 8px}
  #open-comparison {align-self: end; padding-inline: 10px}
  .comparison-sheet, .horse-sheet {
    position: fixed; inset: auto 0 0; width: 100%; margin: 0;
    max-height: 88vh; max-height: 88dvh; border-bottom: 0; border-radius: 18px 18px 0 0;
    padding-inline: env(safe-area-inset-left) env(safe-area-inset-right); padding-bottom: env(safe-area-inset-bottom);
  }
  .sheet-head {padding: 9px var(--gutter) 3px}
  .sheet-sort {margin: 3px var(--gutter) 10px}
  .sheet-scroll {scrollbar-gutter: auto}
  .sheet-scroll td {font-size: 12px}
  .sheet-scroll .horse-pick {gap: 5px}
  .sheet-scroll .horse-label strong {font-size: 13px}
  .sheet-scroll .bib {min-width: 25px; height: 25px; font-size: 14px}
  .horse-sheet {--chart-gutter: var(--gutter)}
  .horse-sheet-head {padding-block: 10px}
  .horse-sheet-metrics {margin-bottom: 8px}
}
@media (max-width: 450px) {
  .horse-impact-row {
    grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "label value" "bar bar";
    gap: 5px; padding-block: 8px;
  }
  .horse-impact-label {line-height: 1.45}
  .horse-impact-weight {display: inline-block; margin-inline-start: 6px}
  .horse-impact-bar {height: 7px}
  .horse-sheet-metrics > div {padding-inline: 8px}
}
@media (max-width: 360px) {
  :root {--gutter: 10px}
  .race-link {grid-template-columns: 32px minmax(0, 1fr) auto; gap: 7px}
  .race-info strong {font-size: 15px}
  .race-action {font-size: 11px}
  th, td {padding-inline: 3px}
  .horse-pick {gap: 4px}
  .bib {min-width: 26px; height: 26px; font-size: 15px}
  #race-preset {font-size: 11px; padding-inline: 5px}
  .dock-movers, .sheet-scroll td {font-size: 11px}
  .dock-inner {gap: 3px 5px}
  #open-comparison {font-size: 12px; padding-inline: 7px}
  .horse-impact-row {padding-block: 6px}
}
@media (orientation: landscape) and (max-height: 520px) {
  .dock-inner {grid-template-columns: minmax(0, 1fr) auto auto; gap: 2px 8px; padding-block: 5px max(5px, env(safe-area-inset-bottom))}
  .dock-horse {grid-column: 1; grid-row: 1}
  .dock-values {grid-column: 2; grid-row: 1}
  .dock-movers {grid-column: 1 / 3; grid-row: 2; display: flex; gap: 2px 12px}
  #open-comparison {grid-column: 3; grid-row: 1 / 3; align-self: center}
  .comparison-sheet, .horse-sheet {max-height: 95vh; max-height: 95dvh}
}
@media (max-height: 430px) {
  .horse-sheet {overflow: auto; overscroll-behavior: contain}
  .horse-sheet-head {position: sticky; z-index: 1; top: 0; padding-block: 4px; border-bottom: 1px solid var(--line)}
  .horse-sheet-metrics {margin-block: 6px; padding-block: 4px}
  .horse-chart-body {flex: none; overflow: visible; padding-top: 8px}
}
@media (orientation: landscape) and (max-height: 430px) and (min-width: 451px) {
  .horse-impact-row {min-height: 34px; padding-block: 4px}
  .horse-impact-weight {display: inline-block; margin-inline-start: 6px}
}
@media (hover: hover) {
  button:enabled:hover, summary:hover {color: var(--accent)}
  .race-link:hover, .factor-row:hover, .preset-grid button:enabled:hover {background-color: #f7f5ff}
  .preset-grid button[aria-pressed="true"]:hover, .factor-row[data-active="true"]:hover {background-color: var(--tint)}
  #open-comparison:hover {background: #41319f; color: white}
  .horse-pick:is(button):hover .horse-label strong {text-decoration: underline; text-underline-offset: 2px}
}
@media (forced-colors: active) {
  select {appearance: auto; -webkit-appearance: auto; background-image: none}
  .bib, .impact-dock, .brand-mark {border: 1px solid CanvasText}
  .horse-impact-bar {border: 1px solid CanvasText}
  .horse-impact-fill {fill: Highlight !important}
  .horse-impact-zero {stroke: CanvasText}
  tr[data-focused="true"] td:first-child {border-inline-start: 3px solid Highlight}
  [aria-pressed="true"], [aria-selected="true"], .factor-row[data-active="true"] {outline: 2px solid Highlight; outline-offset: -2px}
}
