:root {
  --ink: #173a2e;
  --ink-2: #244b3d;
  --cream: #f5f1e8;
  --paper: #fffdf8;
  --orange: #f47b46;
  --orange-dark: #d95f2c;
  --mint: #b8dbc9;
  --line: #d7ddd5;
  --muted: #6e7c74;
  --danger: #b74335;
  --shadow: 0 18px 50px rgba(24, 52, 42, .13);
  --radius: 18px;
}

* { box-sizing: border-box; }
html { color-scheme: light; scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; color: var(--ink); background: var(--cream); font-family: "DM Sans", "Noto Sans JP", system-ui, sans-serif; }
.visually-hidden { 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; }
.app-loading { position: fixed; inset: 0; z-index: 1000; display: grid; place-content: center; justify-items: center; gap: 9px; padding: 24px; color: var(--ink); background: rgba(245,241,232,.92); backdrop-filter: blur(4px); text-align: center; }
.app-loading[hidden] { display: none; }
.app-loading strong { font-size: 16px; }
.app-loading small { max-width: 340px; color: var(--muted); font-size: 11px; line-height: 1.6; }
.loading-spinner { width: 34px; height: 34px; margin-bottom: 5px; border: 4px solid #d8e0da; border-top-color: var(--orange); border-radius: 50%; animation: loading-spin .8s linear infinite; }
@keyframes loading-spin { to { transform: rotate(360deg); } }
.viewer-badge { display: inline-flex; align-items: center; min-height: 34px; padding: 0 14px; border: 1px solid #c8d8d1; border-radius: 999px; background: #edf5f1; color: #315e4f; font-size: 12px; font-weight: 800; letter-spacing: .04em; white-space: nowrap; }
.public-viewer #race-dialog, .public-viewer #data-dialog, .public-viewer #races-dialog, .public-viewer #confirm-dialog { display: none !important; }
button, input, textarea, select { font: inherit; }
button { color: inherit; }
button, select, summary { cursor: pointer; }
:focus-visible { outline: 3px solid rgba(244,123,70,.45); outline-offset: 2px; }

.app-header { height: 76px; padding: 0 clamp(18px, 4vw, 64px); display: flex; align-items: center; justify-content: space-between; gap: 24px; background: var(--paper); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 20; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; min-width: 200px; }
.brand-mark { display: grid; place-items: center; width: 37px; height: 37px; border-radius: 11px 4px 11px 4px; color: white; background: var(--orange); font-weight: 800; font-size: 21px; }
.brand strong, .brand small { display: block; line-height: 1.1; }
.brand strong { font-size: 18px; letter-spacing: -.02em; }
.brand small { margin-top: 4px; color: var(--muted); font-size: 10px; letter-spacing: .08em; }
.header-actions { display: flex; align-items: center; gap: 8px; }
.primary-tabs { width: min(1480px, 100%); display: grid; grid-template-columns: 1fr 1fr; margin: 0 auto; padding: 12px clamp(18px, 4vw, 64px) 0; }
.primary-tab { min-height: 48px; padding: 0 20px; border: 0; border-bottom: 3px solid var(--line); background: transparent; color: var(--muted); font-size: 13px; font-weight: 800; text-align: left; }
.primary-tab span { margin-right: 10px; color: #a8b2ac; font-size: 9px; letter-spacing: .12em; }
.primary-tab.active { border-color: var(--orange); color: var(--ink); background: rgba(255,253,248,.45); }
.primary-tab.active span { color: var(--orange-dark); }

.button { min-height: 42px; padding: 0 18px; border: 1px solid transparent; border-radius: 10px; background: transparent; font-weight: 700; transition: .18s ease; }
.button:hover { transform: translateY(-1px); }
.button-primary { color: white; background: var(--orange); box-shadow: 0 7px 20px rgba(244,123,70,.23); }
.button-primary:hover { background: var(--orange-dark); }
.button-dark { color: white; background: var(--ink); }
.button-quiet { color: var(--ink); background: #edf1ec; }
.button-outline { border-color: var(--ink); }
.button-danger { color: white; background: var(--danger); }
.button:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.text-button { padding: 5px 2px; border: 0; background: transparent; color: var(--orange-dark); font-weight: 700; }
.icon-button { display: inline-grid; place-items: center; width: 38px; height: 38px; padding: 0; border: 0; border-radius: 50%; background: #edf1ec; font-size: 22px; }

main { width: min(1480px, 100%); margin: 0 auto; padding: 0 clamp(18px, 4vw, 64px) 80px; }
.hero { min-height: 260px; display: grid; grid-template-columns: minmax(380px, 1.4fr) minmax(360px, .9fr); align-items: center; gap: 48px; padding: 54px 0 42px; border-bottom: 1px solid rgba(23,58,46,.18); }
.eyebrow { margin: 0 0 8px; color: var(--orange-dark); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
.hero h1 { margin: 0; max-width: 680px; font-family: "Noto Sans JP", sans-serif; font-size: clamp(34px, 4.2vw, 61px); line-height: 1.16; letter-spacing: -.055em; }
.hero h1 em { color: var(--orange); font-style: normal; }
.hero-copy { max-width: 610px; margin: 20px 0 0; color: var(--muted); font-size: 15px; line-height: 1.8; }
.hero-stats { display: grid; grid-template-columns: repeat(3, 1fr); background: var(--ink); color: white; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); }
.hero-stats div { min-height: 132px; display: flex; flex-direction: column; justify-content: center; align-items: center; border-right: 1px solid rgba(255,255,255,.14); }
.hero-stats div:last-child { border: 0; }
.hero-stats strong { font-size: clamp(30px, 4vw, 48px); line-height: 1; }
.hero-stats span { margin-top: 10px; color: #bdd2c7; font-size: 12px; letter-spacing: .12em; }

.toolbar { display: flex; align-items: center; gap: 16px; padding: 24px 0 14px; }
.toolbar-spacer { flex: 1; }
.search-box { width: min(320px, 34vw); display: flex; align-items: center; gap: 8px; padding: 0 13px; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); }
.search-box input { width: 100%; height: 42px; border: 0; outline: 0; background: transparent; }
.switch-row, .select-row { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 700; white-space: nowrap; }
.segmented { position: relative; display: grid; grid-template-columns: 1fr 1fr; width: 124px; height: 38px; padding: 3px; border: 0; border-radius: 9px; background: #dde4de; font-size: 11px; font-weight: 700; }
.segmented::before { content: ""; position: absolute; inset: 3px 50% 3px 3px; border-radius: 7px; background: var(--paper); box-shadow: 0 2px 7px rgba(20,50,39,.1); transition: .2s; }
.segmented[aria-checked="false"]::before { transform: translateX(calc(100% - 3px)); }
.segmented span { position: relative; z-index: 1; display: grid; place-items: center; }
.select-row select { height: 38px; padding: 0 28px 0 10px; border: 1px solid var(--line); border-radius: 9px; background: var(--paper); color: var(--ink); }
.filter-panel { margin: 2px 0 12px; padding: 17px 19px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,253,248,.7); }
.filter-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 12px; }
.filter-heading .eyebrow { margin-bottom: 2px; font-size: 9px; }
.filter-heading h2 { margin: 0; font-size: 16px; }
.filter-grid { display: flex; align-items: end; flex-wrap: wrap; gap: 10px; }
.filter-grid > label { min-width: 150px; flex: 1 1 160px; }
.surface-filter-control { min-width: 230px; flex: 1.35 1 250px; display: grid; gap: 4px; color: var(--ink); font-size: 12px; font-weight: 700; }
.surface-mode-tabs { display: inline-flex; width: fit-content; padding: 3px; border-radius: 10px; background: #e3e8e3; }
.surface-mode-tabs button { min-width: 66px; min-height: 34px; padding: 0 13px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 10px; font-weight: 800; }
.surface-mode-tabs button.active, .surface-mode-tabs button[aria-pressed="true"] { color: white; background: var(--ink); box-shadow: 0 2px 7px rgba(23,58,46,.18); }
.surface-mode-tabs.compact button { min-width: 46px; min-height: 30px; padding-inline: 9px; font-size: 9px; }
.filter-grid select, .filter-grid input { margin-top: 4px; }
.distance-range { flex: 2 1 330px; display: grid; grid-template-columns: 1fr auto 1fr auto; align-items: end; gap: 7px; }
.distance-range > span { padding-bottom: 11px; color: var(--muted); font-size: 11px; }
.filter-summary { margin: 11px 0 0; color: var(--muted); font-size: 10px; }
.legend { display: flex; flex-wrap: wrap; gap: 10px 24px; padding: 10px 0 22px; color: var(--muted); font-size: 12px; }
.legend span:last-child { color: var(--danger); font-weight: 700; }
.legend-line { display: inline-block; width: 26px; height: 0; margin-right: 5px; border-top: 1px solid var(--ink); vertical-align: middle; }
.legend-dot { display: inline-block; width: 8px; height: 8px; margin-right: 5px; border-radius: 50%; background: var(--orange); }

.rating-map { display: grid; gap: 26px; }
.empty-state { padding: 80px 30px; text-align: center; background: rgba(255,255,255,.52); border: 1px dashed #b9c2bb; border-radius: var(--radius); }
.empty-state .empty-mark { display: inline-grid; place-items: center; width: 64px; height: 64px; margin-bottom: 14px; border-radius: 50%; background: var(--mint); font-size: 28px; }
.empty-state h2 { margin: 0; font-size: 24px; }
.empty-state p { margin: 9px 0 22px; color: var(--muted); }
.component-card { overflow: hidden; border: 1px solid var(--line); border-radius: var(--radius); background: var(--paper); box-shadow: 0 10px 28px rgba(23,58,46,.06); }
.component-header { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 18px 22px; background: var(--ink); color: white; }
.component-title { display: flex; align-items: center; gap: 12px; }
.component-badge { display: grid; place-items: center; min-width: 42px; height: 42px; border-radius: 12px; background: var(--orange); font-size: 13px; font-weight: 800; }
.component-header h2 { margin: 0; font-size: 17px; }
.component-header p { margin: 3px 0 0; color: #b8cec3; font-size: 11px; }
.component-meta { display: flex; gap: 18px; color: #c9dacf; font-size: 11px; }
.component-meta strong { color: white; }
.rate-table { width: 100%; border-collapse: collapse; table-layout: fixed; }
.rate-table th { width: 118px; padding: 0 14px; color: var(--muted); background: #f0eee7; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); text-align: right; font-size: 11px; font-weight: 600; }
.rate-table td { min-height: 55px; padding: 7px 12px; border-bottom: 1px solid #e2e5df; background-image: linear-gradient(90deg, transparent 0, transparent calc(100% - 1px), rgba(23,58,46,.04) calc(100% - 1px)); }
.rate-table tr:last-child td, .rate-table tr:last-child th { border-bottom: 0; }
.scale-main { display: block; color: var(--ink); font-size: 13px; }
.scale-sub { color: var(--orange-dark); font-size: 10px; }
.horse-bucket { display: flex; flex-wrap: wrap; gap: 7px; }
.horse-chip { min-width: 190px; flex: 0 1 245px; display: grid; grid-template-columns: 1fr auto; gap: 2px 10px; padding: 9px 11px; border: 1px solid #d7dfd8; border-left: 4px solid var(--orange); border-radius: 9px; background: white; text-align: left; box-shadow: 0 2px 8px rgba(20,52,40,.06); transition: .15s; }
.horse-chip:hover { transform: translateY(-1px); border-color: var(--orange); box-shadow: 0 5px 15px rgba(20,52,40,.11); }
.horse-name { overflow: hidden; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.horse-rating { grid-row: span 2; align-self: center; font-size: 16px; font-weight: 800; }
.horse-rating small { color: var(--muted); font-size: 10px; font-weight: 600; }
.horse-uncertainty { color: var(--muted); font-size: 10px; }
.horse-chip.match { outline: 3px solid rgba(244,123,70,.28); background: #fff7ef; }
.horse-chip.dim { opacity: .36; }
.gap-row td { height: 34px; padding: 0 18px; color: var(--muted); background: repeating-linear-gradient(135deg, rgba(23,58,46,.025), rgba(23,58,46,.025) 5px, transparent 5px, transparent 10px); font-size: 10px; text-align: center; }

.dialog { width: min(760px, calc(100vw - 32px)); max-height: calc(100dvh - 32px); padding: 0; border: 0; border-radius: 20px; background: var(--paper); color: var(--ink); box-shadow: var(--shadow); }
.dialog-wide { width: min(1140px, calc(100vw - 32px)); }
.dialog-confirm { width: min(560px, calc(100vw - 32px)); }
.dialog::backdrop { background: rgba(10,28,21,.62); backdrop-filter: blur(5px); }
.dialog-frame { margin: 0; }
.dialog-header { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 22px 26px 16px; background: rgba(255,253,248,.96); border-bottom: 1px solid var(--line); }
.dialog-header h2 { margin: 0; font-size: 25px; }
.dialog-header .eyebrow { margin-bottom: 5px; }
.dialog-footer { position: sticky; bottom: 0; z-index: 4; display: flex; align-items: center; justify-content: flex-end; gap: 16px; padding: 16px 26px; background: rgba(255,253,248,.97); border-top: 1px solid var(--line); }
.dialog-footer p { margin: 0 auto 0 0; color: var(--muted); font-size: 11px; }
.input-flow { max-height: calc(100dvh - 190px); overflow-y: auto; }
.paste-panel, .batch-panel, .preview-panel { padding: 24px 26px; }
.paste-panel { background: #eef2ec; }
.batch-panel { border-bottom: 1px solid var(--line); background: #f8f5ed; }
.batch-list { display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 8px; }
.batch-item { min-width: 210px; display: grid; grid-template-columns: 1fr 32px; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: white; }
.batch-item.active { border-color: var(--orange); box-shadow: 0 0 0 2px rgba(244,123,70,.18); }
.batch-select { padding: 10px 11px; border: 0; background: transparent; text-align: left; }
.batch-select strong, .batch-select small { display: block; }
.batch-select strong { font-size: 12px; }
.batch-select small { margin-top: 3px; color: var(--muted); font-size: 9px; }
.batch-remove { border: 0; border-left: 1px solid var(--line); background: #f4f4ef; color: var(--muted); font-size: 17px; }
.batch-warning { color: #9a6516 !important; }
.section-heading { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.section-heading h3 { margin: 0; font-size: 16px; }
.section-heading p { margin: 2px 0 0; color: var(--muted); font-size: 11px; }
.step { display: grid; place-items: center; width: 30px; height: 30px; border-radius: 50%; color: white; background: var(--orange); font-weight: 800; }
textarea { width: 100%; resize: vertical; padding: 14px; border: 1px solid #cbd4cc; border-radius: 10px; background: var(--paper); line-height: 1.5; }
.row-actions { display: flex; align-items: center; gap: 16px; margin-top: 12px; }
.auto-parse-note { margin: 0; color: var(--ink-2); font-size: 11px; font-weight: 700; }
.auto-parse-note span { color: var(--orange-dark); font-size: 16px; vertical-align: -1px; }
.warning-list { margin: 0 0 15px; padding: 12px 16px; border-left: 4px solid #e49b26; border-radius: 7px; background: #fff2d9; color: #6c4b17; font-size: 12px; line-height: 1.7; }
.meta-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-bottom: 20px; }
.meta-grid .span-2 { grid-column: span 2; }
label { font-size: 11px; font-weight: 700; }
label input, label select { width: 100%; height: 39px; margin-top: 5px; padding: 0 9px; border: 1px solid #cbd4cc; border-radius: 8px; background: white; color: var(--ink); }
.result-editor { display: grid; gap: 9px; }
.result-card { overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: white; }
.result-primary { display: grid; grid-template-columns: 62px minmax(170px, 1.3fr) minmax(110px, .7fr) minmax(95px, .6fr) 36px; gap: 8px; align-items: end; padding: 10px; }
.result-card .icon-button { width: 34px; height: 34px; margin-bottom: 2px; font-size: 17px; }
.result-status-badge { display: inline-block; margin-left: 4px; padding: 2px 6px; border-radius: 999px; color: white; background: var(--danger); font-size: 9px; font-style: normal; line-height: 1.2; }
.result-card details { border-top: 1px solid #edf0ec; }
.result-card summary { padding: 8px 12px; color: var(--muted); font-size: 10px; font-weight: 700; }
.result-details { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; padding: 2px 12px 12px; }
.add-row-button { margin-top: 12px; }
.data-actions { display: grid; gap: 12px; padding: 24px; }
.data-actions article { display: grid; grid-template-columns: 52px 1fr; gap: 14px; padding: 19px; border: 1px solid var(--line); border-radius: 13px; }
.data-actions h3, .danger-zone h3 { margin: 0; font-size: 15px; }
.data-actions p, .danger-zone p { margin: 5px 0 13px; color: var(--muted); font-size: 12px; }
.data-icon { display: grid; place-items: center; width: 48px; height: 48px; border-radius: 12px; background: var(--mint); font-size: 24px; }
.file-button { display: inline-grid; place-items: center; width: fit-content; }
.file-button input { display: none; }
.danger-zone { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin: 0 24px 18px; padding: 18px; border: 1px solid #e9c0bb; border-radius: 12px; background: #fff5f2; }
.storage-note { margin: 0; padding: 15px 24px; background: #eef2ec; color: var(--muted); font-size: 11px; }
.compare-main { padding-top: 0; }
.compare-workbench { display: grid; grid-template-columns: minmax(330px, .85fr) minmax(0, 1.15fr); gap: 18px; padding: 18px 0 60px; }
.compare-input-card, .pair-panel, .entrant-panel { border: 1px solid var(--line); border-radius: 15px; background: var(--paper); box-shadow: 0 8px 24px rgba(23,58,46,.05); }
.compare-input-card { grid-column: 1 / -1; align-self: start; padding: 17px 20px; }
.compare-input-card textarea { max-height: 150px; }
.entrant-panel { grid-column: 1; grid-row: 2; min-width: 0; padding: 20px; }
.pair-panel { position: sticky; top: 88px; grid-column: 2; grid-row: 2; align-self: start; min-width: 0; max-height: calc(100dvh - 106px); overflow-y: auto; padding: 20px; }
.compare-input-card h2, .pair-panel h2, .entrant-panel h2 { margin: 0; font-size: 17px; }
.compare-body { display: grid; gap: 14px; padding: 24px; }
.compare-auto-note { margin: -8px 0 0; color: var(--muted); font-size: 10px; }
.compare-legend { display: flex; flex-wrap: wrap; gap: 7px; }
.compare-legend span { padding: 5px 9px; border-radius: 999px; font-size: 9px; font-weight: 800; }
.legend-primary { color: #164f3c; background: #dcefe6; }
.legend-secondary { color: #765014; background: #fff0cf; }
.legend-unrated { color: #53605a; background: #e8ece9; }
.legend-missing { color: #8a2f29; background: #ffe3df; }
.compare-results { display: grid; gap: 14px; }
.compare-card-header { display: flex; align-items: end; justify-content: space-between; gap: 12px; padding: 13px 15px; border: 1px solid var(--line); border-radius: 11px; background: #f7f8f4; }
.compare-card-header div { display: grid; gap: 2px; }
.compare-card-header span, .compare-card-header small { color: var(--muted); font-size: 10px; }
.compare-card-header strong { font-size: 16px; }
.compare-summary { margin: 0; padding: 11px 14px; border-left: 4px solid; border-radius: 8px; font-size: 11px; }
.compare-summary.is-complete { border-color: #3f8c6d; color: #164f3c; background: #e8f5ee; }
.compare-summary.is-partial { border-color: #d79122; color: #6c4b17; background: #fff4dc; }
.compare-summary.is-unavailable { border-color: #bd5149; color: #7c2a24; background: #ffebe8; }
.compare-group { overflow: hidden; border: 1px solid var(--line); border-radius: 12px; }
.compare-group h3, .compare-unrated h3, .compare-missing h3 { margin: 0; padding: 11px 14px; font-size: 13px; }
.compare-group.is-primary { border-color: #9bc9b5; }
.compare-group.is-primary h3 { color: white; background: #23654f; }
.compare-group.is-secondary { border-color: #e2bf78; }
.compare-group.is-secondary h3 { color: #fff; background: #9b6b1d; }
.compare-group.is-tertiary { border-color: #91b9d2; }
.compare-group.is-tertiary h3 { color: #fff; background: #397293; }
.compare-group.is-quaternary { border-color: #baa5d2; }
.compare-group.is-quaternary h3 { color: #fff; background: #715493; }
.compare-group.is-quinary { border-color: #d6a2b6; }
.compare-group.is-quinary h3 { color: #fff; background: #914c68; }
.compare-group h3 small { margin-left: 8px; color: #bfd1c7; font-size: 9px; font-weight: 500; }
.compare-group:not(.is-primary) h3 small { color: #f7eee0; }
.compare-horse-row { display: grid; grid-template-columns: 104px minmax(0, 1fr); border-bottom: 1px solid var(--line); background: white; }
.compare-horse-row:last-child { border-bottom: 0; }
.compare-horse-row.selected { background: #fff8ec; box-shadow: inset 4px 0 var(--orange); }
.pair-pick { align-self: center; min-height: 34px; margin: 10px; padding: 5px 8px; border: 1px solid var(--orange); border-radius: 8px; background: white; color: var(--orange-dark); font-size: 10px; font-weight: 800; }
.compare-horse-row.selected .pair-pick { color: white; background: var(--orange); }
.compare-horse-main { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 2px 12px; padding: 11px 14px 11px 4px; border: 0; background: transparent; text-align: left; }
.compare-entry { display: grid; gap: 2px; }
.compare-entry > small { color: var(--muted); font-size: 9px; font-weight: 500; }
.compare-entry strong { font-size: 13px; }
.compare-entry i { margin-left: 5px; padding: 1px 4px; border-radius: 3px; color: white; background: #496a83; font-size: 8px; font-style: normal; }
.compare-score { align-self: center; font-weight: 800; }
.compare-score small { color: var(--muted); font-weight: 600; }
.compare-delta { grid-column: 1 / -1; color: var(--muted); }
.evidence-count { width: fit-content; margin-top: 3px; color: var(--muted); font-size: 8px; font-style: normal; font-weight: 700; }
.compare-unrated, .compare-missing { overflow: hidden; border-radius: 11px; }
.compare-unrated { border: 1px solid #cbd2cd; background: #f1f3f1; }
.compare-unrated h3 { color: #48554e; background: #dfe4e1; }
.compare-unrated .compare-horse-main { display: grid; gap: 3px; }
.compare-unrated .compare-horse-main span { color: var(--muted); font-size: 9px; }
.compare-missing { border: 1px solid #efbbb5; background: #fff0ee; color: #7c2a24; }
.compare-missing h3 { background: #f7d8d4; }
.compare-missing p, .compare-empty { margin: 0; padding: 11px 14px; font-size: 11px; }
.pair-comparison { min-height: 170px; }
.pair-empty { min-height: 170px; display: grid; place-content: center; gap: 5px; border: 1px dashed #b9c2bb; border-radius: 11px; color: var(--muted); text-align: center; }
.pair-empty strong { color: var(--ink); font-size: 15px; }
.pair-empty span { font-size: 10px; }
.pair-verdict { display: grid; gap: 4px; padding: 14px; border-radius: 11px; }
.pair-verdict span { font-size: 10px; }
.pair-verdict.unavailable { color: #77332e; background: #fbe5e2; }
.pair-formula-result { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 14px; padding: 14px; border: 1px solid #cbd4cc; border-left: 4px solid var(--orange); border-radius: 11px; background: #f7f8f4; }
.pair-formula-result > div { display: grid; gap: 4px; }
.pair-formula-result span { color: var(--muted); font-size: 9px; }
.pair-formula-result strong { font-size: 18px; }
.pair-formula-result small { color: var(--muted); font-size: 10px; }
.pair-formula-result > div:last-child { min-width: 100px; text-align: right; }
.pair-formula-result > div:last-child strong { color: var(--orange-dark); font-size: 25px; }
.pair-equation { display: grid; gap: 5px; margin-top: 10px; padding: 12px; border-radius: 9px; color: white; background: #173a2e; }
.pair-equation span { color: #bfd1c7; font-size: 9px; }
.pair-equation strong { overflow-wrap: anywhere; font-size: 13px; }
.pair-equation small { color: #bfd1c7; font-size: 9px; line-height: 1.6; }
.pair-horses { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; margin-top: 12px; }
.pair-horses > button { display: grid; gap: 4px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: white; text-align: left; }
.pair-horses > button strong { font-size: 18px; }
.pair-horses > button small { color: var(--muted); font-size: 10px; }
.pair-horses > div { display: grid; gap: 2px; min-width: 82px; text-align: center; }
.pair-horses > div strong { color: var(--orange-dark); font-size: 14px; }
.pair-horses > div span { color: var(--muted); font-size: 8px; }
.pair-metrics { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; margin-top: 10px; }
.pair-metrics div { display: grid; gap: 3px; padding: 9px; border-radius: 8px; background: #f1f2ed; }
.pair-metrics span { color: var(--muted); font-size: 8px; }
.pair-metrics strong { font-size: 12px; }
.pair-table-wrap { margin-top: 14px; overflow-x: auto; }
.pair-table-wrap h3 { margin: 0 0 7px; font-size: 12px; }
.snapshot-pair-note { padding: 10px 12px; border-radius: 9px; background: #f2f0e9; }
.snapshot-pair-note > p:last-child { margin: 7px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.snapshot-link-note { margin: 7px 0 0; color: var(--muted); font-size: 8px; }
.path-line { margin: 0 0 8px; color: var(--orange-dark); font-size: 10px; font-weight: 800; }
.evidence-table { width: 100%; min-width: 620px; border-collapse: collapse; font-size: 11px; }
.evidence-table th, .evidence-table td { padding: 7px 8px; border-bottom: 1px solid var(--line); text-align: left; }
.evidence-table th { color: var(--muted); background: #f1f2ed; }
.table-link { padding: 0; border: 0; background: transparent; color: var(--orange-dark); font-size: inherit; font-weight: 800; text-decoration: underline; }
.pair-caution { margin: 10px 0 0; color: var(--muted); font-size: 9px; line-height: 1.6; }
.race-library { display: grid; gap: 9px; max-height: calc(100dvh - 130px); overflow-y: auto; padding: 22px; }
.race-library-row { display: grid; grid-template-columns: minmax(260px, 1fr) auto; gap: 14px; align-items: center; padding: 15px 17px; border: 1px solid var(--line); border-radius: 11px; }
.race-library-row h3 { margin: 0; font-size: 15px; }
.race-library-row p { margin: 4px 0 0; color: var(--muted); font-size: 11px; }
.race-row-actions { display: flex; gap: 7px; }
.confirm-list { max-height: 260px; overflow: auto; margin: 18px 26px; padding: 0; list-style: none; }
.confirm-list li { padding: 9px 0; border-bottom: 1px solid var(--line); font-size: 12px; }

.horse-drawer { position: fixed; z-index: 40; top: 0; right: 0; width: min(470px, 94vw); height: 100dvh; padding: 32px; overflow-y: auto; background: var(--paper); box-shadow: -20px 0 60px rgba(12,36,27,.2); transform: translateX(105%); transition: transform .25s ease; }
.horse-drawer.open { transform: translateX(0); }
.drawer-scrim { position: fixed; z-index: 35; inset: 0; pointer-events: none; opacity: 0; background: rgba(12,32,25,.45); transition: opacity .2s; }
.drawer-scrim.open { pointer-events: auto; opacity: 1; }
.drawer-close { position: absolute; top: 18px; right: 18px; }
.drawer-hero { padding: 18px 0 25px; border-bottom: 1px solid var(--line); }
.drawer-hero h2 { margin: 5px 0 14px; font-size: 29px; }
.drawer-score { display: flex; align-items: baseline; gap: 9px; }
.drawer-score strong { color: var(--orange-dark); font-size: 42px; }
.drawer-score span { color: var(--muted); font-size: 17px; }
.drawer-delta { margin: 7px 0 0; color: var(--muted); font-size: 12px; }
.drawer-section { padding: 23px 0 4px; }
.drawer-section h3 { margin: 0 0 12px; font-size: 14px; }
.drawer-section h3 small { margin-left: 5px; color: var(--muted); font-size: 9px; font-weight: 500; }
.history-list, .evidence-list { display: grid; gap: 8px; }
.history-item, .evidence-item { padding: 12px; border: 1px solid var(--line); border-radius: 9px; background: white; }
.history-item { width: 100%; text-align: left; }
.history-item strong, .history-item span { display: block; }
.history-item span, .evidence-item small { margin-top: 4px; color: var(--muted); font-size: 11px; }
.history-item em { display: block; margin-top: 7px; color: var(--orange-dark); font-size: 9px; font-style: normal; font-weight: 800; }
.evidence-item { display: grid; grid-template-columns: 1fr auto; gap: 6px; }
.evidence-item b { font-size: 12px; }
.evidence-item .residual-bad { color: var(--danger); }
.uncertainty-note { padding: 13px; border-radius: 9px; background: #eef2ec; color: var(--muted); font-size: 11px; line-height: 1.6; }
.race-detail-content { max-height: calc(100dvh - 110px); overflow-y: auto; padding: 22px; }
.race-detail-hero { padding: 3px 2px 18px; }
.race-detail-hero h2 { margin: 0; font-size: 24px; }
.race-detail-hero p:not(.eyebrow) { margin: 6px 0 3px; color: var(--muted); font-size: 12px; }
.race-detail-hero > small { color: var(--orange-dark); font-size: 9px; font-weight: 800; }
.race-detail-head, .race-detail-row { display: grid; grid-template-columns: 42px 58px minmax(180px, 1fr) minmax(100px, .55fr) 80px; align-items: center; gap: 9px; }
.race-detail-head { padding: 7px 11px; color: var(--muted); background: #eef1ec; font-size: 9px; font-weight: 800; }
.race-detail-row { width: 100%; padding: 10px 11px; border: 0; border-bottom: 1px solid var(--line); background: white; text-align: left; }
.race-detail-row:hover { background: #fff8ee; }
.race-finish { color: var(--orange-dark); font-size: 15px; font-weight: 900; }
.race-number { color: var(--muted); font-size: 9px; }
.race-horse, .race-time, .race-rate { display: grid; gap: 2px; }
.race-horse small, .race-time small, .race-rate small { color: var(--muted); font-size: 9px; }
.race-rate { text-align: right; font-weight: 900; }

.toast-region { position: fixed; z-index: 80; right: 20px; bottom: 20px; display: grid; gap: 9px; }
.toast { min-width: 260px; max-width: 420px; padding: 13px 16px; border-radius: 10px; color: white; background: var(--ink); box-shadow: var(--shadow); font-size: 12px; animation: toast-in .22s ease; }
.toast.error { background: var(--danger); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* 出馬表比較は内部に閉じ込めず、ページ全体を自然に縦へ伸ばす。 */
.compare-main { height: auto; overflow: visible; padding-bottom: 64px; }
.compare-workbench { height: auto; grid-template-columns: minmax(560px, 1.2fr) minmax(390px, .8fr); grid-template-rows: auto auto; align-items: start; gap: 14px; padding: 14px 0 16px; }
.compare-input-card { display: flex; align-items: center; gap: 16px; padding: 10px 14px; }
.compare-input-card details { min-width: 260px; flex: 1 1 420px; }
.compare-input-card details[open] { align-self: stretch; }
.compare-input-card summary { display: flex; align-items: baseline; gap: 10px; padding: 8px 2px; list-style-position: inside; }
.compare-input-card summary strong { font-size: 13px; }
.compare-input-card summary span { color: var(--muted); font-size: 9px; }
.compare-input-card textarea { min-height: 108px; max-height: 150px; margin-top: 6px; border: 2px dashed #e19a65; background: #fffaf3; box-shadow: inset 0 0 0 3px rgba(255,255,255,.72); font-size: 12px; line-height: 1.65; }
.compare-input-card textarea:focus { border-color: var(--orange); background: white; box-shadow: 0 0 0 4px rgba(239,113,61,.12); }
.compare-input-card textarea::placeholder { color: #8b6e5c; opacity: 1; }
.compare-paste-status { margin: 5px 2px 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.compare-savebar { flex: 1 1 auto; display: flex; align-items: end; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
.compare-savebar .button { min-height: 36px; padding-inline: 13px; font-size: 10px; }
.compare-savebar .share-comparison { border-color: #77a894; color: #175941; background: #edf7f1; }
.compare-savebar .share-comparison:disabled { cursor: not-allowed; opacity: .45; }
.compare-savebar label { min-width: 160px; color: var(--muted); font-size: 9px; }
.compare-savebar select { height: 36px; margin-top: 3px; }
.compare-delete { align-self: center; font-size: 10px; }
.compare-delete:disabled { cursor: not-allowed; opacity: .4; }
.compare-time-toggle { display: flex; align-items: center; gap: 3px; min-height: 36px; padding: 3px; border: 1px solid var(--line); border-radius: 9px; background: #eef1ec; }
.compare-time-toggle[hidden] { display: none; }
.compare-time-toggle > span { max-width: 150px; padding: 0 6px; overflow: hidden; color: var(--muted); font-size: 8px; text-overflow: ellipsis; white-space: nowrap; }
.compare-time-toggle button { min-height: 28px; padding: 4px 9px; border: 0; border-radius: 6px; color: var(--muted); background: transparent; font-size: 9px; font-weight: 800; }
.compare-time-toggle button[aria-pressed="true"] { color: white; background: var(--green); }
.compare-time-toggle button:disabled { cursor: not-allowed; opacity: .45; }
.entrant-panel, .pair-panel { height: auto; padding: 16px; }
.entrant-panel { display: block; }
.pair-panel { position: static; max-height: none; overflow: visible; }
.compare-panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 48px; margin-bottom: 10px; }
.compare-panel-heading h2 { margin: 0; font-size: 16px; }
.compare-panel-heading p { margin: 3px 0 0; color: var(--muted); font-size: 9px; }
.compare-heading-actions { display: flex; align-items: center; justify-content: flex-end; gap: 9px; flex-wrap: wrap; }
.compare-sort-tabs { display: inline-flex; padding: 3px; border-radius: 9px; background: #e5e9e4; }
.compare-sort-tabs button { min-height: 30px; padding: 0 10px; border: 0; border-radius: 7px; color: var(--muted); background: transparent; font-size: 9px; font-weight: 800; }
.compare-sort-tabs button.active { color: white; background: var(--ink); box-shadow: 0 2px 6px rgba(23,58,46,.18); }
.compare-panel-heading .compare-legend { justify-content: flex-end; }
.compare-panel-heading .compare-legend span { padding: 4px 7px; font-size: 8px; }
.surface-warning { margin: 0 0 10px; padding: 9px 12px; border-left: 4px solid #d79122; border-radius: 8px; color: #694814; background: #fff3d8; font-size: 10px; line-height: 1.55; }
.surface-warning strong { display: block; margin-bottom: 2px; font-size: 11px; }
.pair-surface-warning { margin: 0 0 10px; padding: 9px 12px; border: 1px solid #e7c47a; border-radius: 8px; color: #694814; background: #fff7e5; font-size: 10px; line-height: 1.55; }
.compare-results { min-height: 0; display: block; overflow: visible; }
.entry-table-wrap { height: auto; overflow: hidden; border: 1px solid var(--line); border-radius: 10px; background: white; }
.entry-table { width: 100%; min-width: 0; table-layout: fixed; border-collapse: separate; border-spacing: 0; font-size: 10px; }
.entry-table th { position: static; height: 34px; padding: 7px 4px; border-bottom: 1px solid var(--line); color: var(--muted); background: #f0f2ed; font-size: 9px; text-align: left; white-space: nowrap; }
.entry-table td { height: 54px; padding: 7px 4px; border-bottom: 1px solid #e4e8e2; background: rgba(255,255,255,.96); vertical-align: middle; white-space: nowrap; }
.entry-table th:nth-child(1) { width: 38px; }
.entry-table th:nth-child(2) { width: 42px; }
.entry-table th:nth-child(3) { width: 40px; }
.entry-table th:nth-child(5) { width: 58px; }
.entry-table th:nth-child(6) { width: 54px; }
.entry-table th:nth-child(7) { width: 72px; }
.entry-table th:nth-child(8) { width: 55px; }
.entry-table th:nth-child(9) { width: 57px; }
.entry-table th:nth-child(10) { width: 58px; }
.entry-table th:nth-child(1), .entry-table th:nth-child(2), .entry-table th:nth-child(3), .entry-table th:nth-child(6), .entry-table th:nth-child(8), .entry-table th:nth-child(9), .entry-table th:nth-child(10) { text-align: center; }
.entry-table th:nth-child(5), .entry-table th:nth-child(7) { text-align: right; }
.entry-table tbody tr:last-child td { border-bottom: 0; }
.entry-table .frame-cell { width: 38px; padding-inline: 5px; text-align: center; }
.frame-badge { display: inline-grid; place-items: center; width: 28px; height: 32px; border: 1px solid rgba(0,0,0,.14); border-radius: 5px; font-size: 12px; font-weight: 900; }
.waku-1 { color: #222; background: #fff; }
.waku-2 { color: #fff; background: #222; }
.waku-3 { color: #fff; background: #d8413c; }
.waku-4 { color: #fff; background: #3568c8; }
.waku-5 { color: #222; background: #f4d940; }
.waku-6 { color: #fff; background: #48a45d; }
.waku-7 { color: #fff; background: #ec8537; }
.waku-8 { color: #222; background: #ef9cba; }
.horse-number { width: 44px; text-align: center; font-size: 12px; font-weight: 900; }
.entry-mark { position: relative; width: 40px; text-align: center; font-size: 13px; font-weight: 900; }
.entry-mark select { width: 32px; height: 30px; padding: 0; border: 1px solid #cbd4cc; border-radius: 6px; appearance: none; color: var(--ink); background: white; font-size: 11px; font-weight: 900; text-align: center; text-align-last: center; }
.entry-mark::after { content: "▾"; position: absolute; top: 50%; right: 5px; color: var(--muted); font-size: 8px; font-weight: 700; pointer-events: none; transform: translateY(-50%); }
.entry-name { min-width: 0; overflow: hidden; }
.entry-name button { display: grid; gap: 2px; width: 100%; padding: 0; border: 0; color: #163f73; background: transparent; text-align: left; }
.entry-name strong { overflow: hidden; font-size: 12px; text-overflow: ellipsis; }
.entry-name small, .entry-odds small, .entry-rating small, .entry-evidence small { display: block; margin-top: 2px; color: var(--muted); font-size: 8px; }
.entry-odds, .entry-rating { text-align: right; }
.entry-odds strong { color: var(--orange-dark); font-size: 11px; }
.entry-group { font-weight: 900; }
.entry-rating strong { font-size: 13px; }
.entry-gap { color: var(--muted); }
.entry-evidence strong { font-size: 10px; }
.entry-pair button { min-width: 50px; min-height: 30px; padding: 4px 8px; border: 1px solid var(--orange); border-radius: 7px; color: var(--orange-dark); background: white; font-size: 9px; font-weight: 800; }
.entry-row.selected td { background: #fff7eb; }
.entry-row.selected .entry-pair button { color: white; background: var(--orange); }
.entry-row.group-tone-0 td:first-child { box-shadow: inset 4px 0 #267157; }
.entry-row.group-tone-1 td:first-child { box-shadow: inset 4px 0 #b27921; }
.entry-row.group-tone-2 td:first-child { box-shadow: inset 4px 0 #397da0; }
.entry-row.group-tone-3 td:first-child { box-shadow: inset 4px 0 #76589a; }
.entry-row.group-tone-4 td:first-child { box-shadow: inset 4px 0 #a34e70; }
.entry-row.unrated td { background: #f1f3f1; }
.entry-row.missing td { color: #7c2a24; background: #fff0ee; }
.pair-comparison { min-height: 0; }
.pair-empty { min-height: 210px; }
.pair-summary-shell { position: relative; }
.pair-formula-result { padding: 11px 12px; }
.pair-formula-result strong { font-size: 16px; }
.pair-formula-result > div:last-child strong { font-size: 21px; }
.pair-index { grid-template-columns: 1fr auto; align-items: center; }
.pair-index > span, .pair-index > strong { grid-column: 1; }
.pair-info { position: relative; grid-column: 2; grid-row: 1 / span 2; align-self: center; }
.pair-info summary { display: grid; place-items: center; width: 30px; height: 30px; border: 1px solid #b9c4bc; border-radius: 50%; color: var(--ink); background: white; font-family: Georgia, serif; font-size: 16px; font-weight: 800; list-style: none; }
.pair-info summary::-webkit-details-marker { display: none; }
.pair-info[open] summary { color: white; background: var(--ink); }
.pair-info-content { position: absolute; z-index: 8; top: 38px; right: 0; width: min(540px, calc(100vw - 64px)); padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: var(--paper); box-shadow: var(--shadow); }
.pair-metrics { gap: 5px; margin-top: 8px; }
.pair-metrics div { padding: 7px; }
.pair-equation { margin-top: 8px; padding: 10px; }
.pair-table-wrap { margin-top: 10px; }
.pair-route-wrap { margin-top: 12px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: #fbfcf8; }
.pair-route-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 9px; }
.pair-route-heading h3 { margin: 0; font-size: 12px; }
.pair-route-heading p { margin: 3px 0 0; color: var(--muted); font-size: 8px; }
.route-targets { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; gap: 10px; margin: 0 0 9px; padding: 8px 10px; border: 1px solid #d6dfd8; border-radius: 9px; background: white; }
.route-targets > b { color: var(--orange-dark); font-size: 10px; letter-spacing: .08em; }
.route-target { display: flex; min-width: 0; align-items: center; gap: 8px; }
.route-target:last-child { justify-content: flex-end; text-align: right; }
.route-target > span { display: grid; min-width: 0; gap: 1px; }
.route-target small { color: var(--muted); font-size: 7px; font-weight: 800; }
.route-target strong { overflow: hidden; font-size: 10px; text-overflow: ellipsis; white-space: nowrap; }
.route-horse-number { display: inline-grid; flex: 0 0 auto; place-items: center; width: 28px; height: 28px; border: 1px solid rgba(0,0,0,.16); border-radius: 7px; color: var(--ink); background: #eef1ed; font-size: 11px; font-style: normal; font-weight: 900; }
.route-horse-number.waku-1 { color: #222; background: #fff; }
.route-horse-number.waku-2 { color: #fff; background: #222; }
.route-horse-number.waku-3 { color: #fff; background: #d8413c; }
.route-horse-number.waku-4 { color: #fff; background: #3568c8; }
.route-horse-number.waku-5 { color: #222; background: #f4d940; }
.route-horse-number.waku-6 { color: #fff; background: #48a45d; }
.route-horse-number.waku-7 { color: #fff; background: #ec8537; }
.route-horse-number.waku-8 { color: #222; background: #ef9cba; }
.pair-route-svg { display: block; width: 100%; height: auto; max-height: 300px; border-radius: 8px; background: linear-gradient(#f2f4ef 1px, transparent 1px) 0 0 / 100% 34px; }
.line-race { cursor: pointer; }
.line-race rect { fill: #e8eee9; stroke: #b8c7bd; stroke-width: 1; }
.line-race text { fill: var(--orange-dark); font-size: 7px; font-weight: 900; text-anchor: middle; text-decoration: underline; }
.line-race-axis { stroke: var(--orange); stroke-width: 3; stroke-linecap: round; }
.line-shared { stroke: #557568; stroke-width: 1.5; stroke-dasharray: 5 4; }
.line-node circle { fill: white; stroke: var(--ink); stroke-width: 1.5; }
.line-node.route-start circle, .line-node.route-end circle { fill: #fff0e7; stroke: var(--orange-dark); stroke-width: 2.5; }
.line-node text { fill: var(--ink); font-size: 8px; font-weight: 900; text-anchor: middle; }
.line-value rect { fill: white; stroke: #e5b79d; stroke-width: 1; }
.line-value text { fill: var(--orange-dark); font-size: 7px; font-weight: 900; text-anchor: middle; }
.line-route-legend { display: flex; flex-wrap: wrap; gap: 5px 10px; padding-top: 8px; border-top: 1px solid var(--line); }
.line-route-legend button { display: inline-flex; align-items: center; gap: 5px; padding: 3px 0; border: 0; color: var(--ink); background: transparent; font-size: 9px; font-weight: 800; }
.line-route-legend button span { display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; color: white; background: var(--ink); font-size: 8px; }
.evidence-table { min-width: 0; table-layout: fixed; font-size: 9px; }
.evidence-table th, .evidence-table td { padding: 6px; }
.evidence-table th, .evidence-table td, .path-line { overflow-wrap: anywhere; white-space: normal; }
.uncertainty-map { display: grid; gap: 12px; margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.uncertainty-map:empty { display: none; }
.uncertainty-map-heading { display: flex; align-items: end; justify-content: space-between; gap: 12px; }
.uncertainty-map-heading h3 { margin: 0; font-size: 14px; }
.uncertainty-map-heading p { margin: 3px 0 0; color: var(--muted); font-size: 9px; line-height: 1.5; }
.uncertainty-map-heading > span { color: #8a4a20; font-size: 8px; font-weight: 800; white-space: nowrap; }
.uncertainty-group { padding-left: 10px; border-left: 4px solid #267157; }
.uncertainty-group.group-tone-1 { border-color: #b27921; }
.uncertainty-group.group-tone-2 { border-color: #397da0; }
.uncertainty-group.group-tone-3 { border-color: #76589a; }
.uncertainty-group.group-tone-4 { border-color: #a34e70; }
.uncertainty-group > header { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 7px; }
.uncertainty-group > header strong { font-size: 11px; }
.uncertainty-group > header span { color: var(--muted); font-size: 8px; }
.uncertainty-axis { display: grid; grid-template-columns: 1fr auto 1fr; margin: 0 68px 4px 118px; color: var(--muted); font-size: 7px; }
.uncertainty-axis span:nth-child(2) { text-align: center; }
.uncertainty-axis span:last-child { text-align: right; }
.uncertainty-row { display: grid; grid-template-columns: 110px minmax(100px, 1fr) 62px; align-items: center; gap: 8px; min-height: 34px; padding: 3px 0; }
.uncertainty-name { display: grid; grid-template-columns: 24px minmax(0, 1fr); align-items: center; gap: 4px; min-width: 0; padding: 0; border: 0; color: var(--ink); background: transparent; text-align: left; }
.uncertainty-name small { color: var(--muted); font-size: 8px; }
.uncertainty-name strong { overflow: hidden; font-size: 9px; text-overflow: ellipsis; white-space: nowrap; }
.uncertainty-track { position: relative; height: 20px; border-radius: 5px; background: linear-gradient(#edf0eb, #edf0eb) center / 100% 3px no-repeat; }
.uncertainty-interval { position: absolute; top: 9px; height: 3px; min-width: 3px; color: #267157; background: currentColor; }
.range-arrow { position: absolute; top: 50%; color: currentColor; font-size: 15px; font-style: normal; font-weight: 900; line-height: 1; transform: translateY(-53%); }
.range-start { left: -5px; }
.range-end { right: -5px; }
.uncertainty-point { position: absolute; z-index: 2; top: 50%; width: 9px; height: 9px; border: 2px solid white; border-radius: 50%; background: var(--orange); box-shadow: 0 0 0 1px var(--orange-dark); transform: translate(-50%, -50%); }
.third-reference { position: absolute; z-index: 1; top: 0; bottom: 0; border-left: 1px dashed #b5582e; }
.third-candidate .uncertainty-name strong { color: var(--orange-dark); }
.third-candidate .uncertainty-interval { color: var(--orange-dark); }
.uncertainty-value { text-align: right; font-size: 9px; font-weight: 900; white-space: nowrap; }
.uncertainty-value small { color: var(--muted); font-size: 8px; }

@media (max-width: 900px) {
  .app-header { height: 68px; }
  .hero { grid-template-columns: 1fr; gap: 30px; padding: 38px 0 34px; }
  .hero-stats div { min-height: 98px; }
  .toolbar { flex-wrap: wrap; }
  .toolbar-spacer { display: none; }
  .search-box { width: 100%; }
  .switch-row { margin-right: auto; }
  .meta-grid { grid-template-columns: repeat(3, 1fr); }
  .result-details { grid-template-columns: repeat(3, 1fr); }
  .component-meta { display: none; }
  .rate-table th { width: 92px; }
  .horse-chip { min-width: 180px; flex-basis: 220px; }
}

@media (max-width: 1060px) {
  .compare-main { min-height: calc(100dvh - 128px); }
  .compare-workbench { grid-template-columns: 1fr; }
  .compare-input-card { align-items: stretch; flex-direction: column; }
  .compare-input-card, .entrant-panel, .pair-panel { position: static; grid-column: 1; grid-row: auto; height: auto; max-height: none; }
  .entrant-panel { order: 2; }
  .pair-panel { order: 3; }
}

@media (max-width: 620px) {
  .brand small { display: none; }
  .brand strong { display: none; }
  .brand { min-width: auto; }
  .header-actions { gap: 4px; }
  .header-actions .button { min-height: 38px; padding: 0 9px; font-size: 0; }
  .header-actions .button::after { content: attr(data-short); font-size: 11px; white-space: nowrap; }
  .primary-tabs { padding-inline: 14px; }
  .primary-tab { padding-inline: 10px; font-size: 11px; }
  main { padding-inline: 14px; }
  .hero { min-height: 0; }
  .hero h1 { font-size: 35px; }
  .hero-copy { font-size: 13px; }
  .hero-stats strong { font-size: 30px; }
  .toolbar { gap: 11px; }
  .select-row { width: 100%; }
  .select-row select { flex: 1; }
  .filter-panel { padding: 14px; }
  .filter-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .filter-grid > label, .distance-range { min-width: 0; width: 100%; }
  .surface-filter-control { min-width: 0; grid-column: 1 / -1; }
  .surface-mode-tabs { width: 100%; }
  .surface-mode-tabs button { min-width: 0; flex: 1; }
  .distance-range { grid-column: 1 / -1; }
  .compare-workbench { padding-top: 14px; }
  .compare-input-card, .pair-panel, .entrant-panel { padding: 14px; }
  .compare-horse-row { grid-template-columns: 86px minmax(0, 1fr); }
  .pair-pick { margin: 7px; font-size: 9px; }
  .compare-horse-main { grid-template-columns: 1fr; padding-left: 4px; }
  .compare-score { justify-self: start; }
  .pair-horses { grid-template-columns: 1fr; }
  .pair-horses > div { order: 2; }
  .pair-horses > button:last-child { order: 3; }
  .pair-formula-result { grid-template-columns: 1fr; }
  .pair-formula-result > div:last-child { min-width: 0; text-align: left; }
  .pair-metrics { grid-template-columns: repeat(2, 1fr); }
  .uncertainty-map-heading { align-items: start; flex-direction: column; }
  .uncertainty-axis { margin-left: 92px; margin-right: 58px; }
  .uncertainty-row { grid-template-columns: 84px minmax(90px, 1fr) 54px; gap: 5px; }
  .race-detail-content { padding: 13px; }
  .race-detail-head { display: none; }
  .race-detail-row { grid-template-columns: 34px 42px minmax(110px, 1fr) auto; }
  .race-rate { display: none; }
  .legend { display: grid; }
  .component-header { padding: 14px; }
  .component-title { gap: 8px; }
  .component-header h2 { font-size: 14px; }
  .rate-table th { width: 76px; padding: 0 8px; }
  .rate-table td { padding: 6px; }
  .horse-chip { min-width: 100%; flex-basis: 100%; }
  .dialog { width: calc(100vw - 12px); max-height: calc(100dvh - 12px); border-radius: 14px; }
  .dialog-header, .paste-panel, .preview-panel, .dialog-footer { padding-left: 15px; padding-right: 15px; }
  .dialog-footer { align-items: stretch; flex-direction: column; }
  .meta-grid { grid-template-columns: repeat(2, 1fr); }
  .meta-grid .span-2 { grid-column: span 2; }
  .result-primary { grid-template-columns: minmax(86px, .8fr) minmax(105px, 1fr) 34px; }
  .result-primary .order-field { grid-column: 1; grid-row: 1; }
  .result-primary label:nth-of-type(2) { grid-column: 2; grid-row: 1; }
  .result-primary .row-remove { grid-column: 3; grid-row: 1; }
  .result-primary label:nth-of-type(3) { grid-column: 1; grid-row: 2; }
  .result-primary label:nth-of-type(4) { grid-column: 2 / 4; grid-row: 2; }
  .result-details { grid-template-columns: repeat(2, 1fr); }
  .race-library-row { grid-template-columns: 1fr; }
  .danger-zone { align-items: stretch; flex-direction: column; }
  .horse-drawer { padding: 25px 20px; }
}

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