#horse-history-dialog {
  color-scheme: light; color: #1c1c1e; background: #fff; width: min(680px, calc(100% - 24px)); max-width: none;
  max-height: calc(100dvh - 24px); padding: 0; border: 1px solid #d9dfe7; border-radius: 10px;
  box-shadow: 0 12px 40px #172b4630; overflow: auto;
}
#horse-history-dialog::backdrop { background: #172b4640; }
#horse-history-dialog button { font: inherit; color: #263344; cursor: pointer; }
#horse-history-dialog [hidden] { display: none !important; }
.history-head { position: sticky; top: 0; z-index: 4; background: #fff; display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; padding: 18px 22px 14px; }
.history-head h2 { font-size: 20px; margin: 0; overflow-wrap: anywhere; }
.history-head p { color: #606a77; font-size: 12px; margin: 4px 0 0; }
.history-close { min-height: 36px; border: 1px solid #d9dfe7; background: #fff; border-radius: 6px; padding: 6px 10px; white-space: nowrap; }
.history-summary { display: flex; align-items: baseline; flex-wrap: wrap; gap: 12px 34px; margin: 0 22px 22px; color: #606a77; font-size: 12px; }
.history-summary strong { display: block; margin-top: 2px; font-size: 28px; line-height: 1.2; color: #1c1c1e; font-variant-numeric: tabular-nums; }
.history-summary .history-primary strong { color: #1a56a0; font-size: 34px; }
.history-summary small { font-size: 11px; }
#history-chart-panel { padding: 0 18px 4px; }
.history-chart-heading { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 10px; margin: 0 4px 10px; font-size: 14px; }
.history-chart-heading span { font-size: 11px; color: #606a77; }
.history-legend { display: flex; flex-wrap: wrap; gap: 4px 24px; margin: 0 4px 10px; }
.history-legend button { display: inline-flex; align-items: center; gap: 7px; border: 0; border-radius: 0; background: transparent; padding: 4px 0; font-size: 12px !important; }
.history-legend button[aria-pressed="false"] { opacity: .5; text-decoration: line-through; }
.history-legend button:disabled { cursor: default !important; }
.history-legend i { width: 22px; position: relative; border-top: 3px solid #1a56a0; }
.history-legend i::after { content: ""; position: absolute; width: 6px; height: 6px; border: 2px solid #1a56a0; background: #fff; border-radius: 50%; left: 8px; top: -5px; }
.history-legend [data-history-series="average"] i { border-color: #39796c; border-top: 2px dotted #39796c; }
.history-legend [data-history-series="average"] i::after { border-color: #39796c; width: 5px; height: 5px; top: -3.5px; }
.history-chart { position: relative; height: 234px; }
.history-svg { width: 100%; height: 234px; display: block; overflow: visible; }
.history-svg text { fill: #1c1c1e; font: 12px "Hiragino Kaku Gothic ProN", Meiryo, sans-serif; }
.history-svg .history-tick { fill: #555f6b; }
.history-svg .history-value { font-weight: bold; }
.history-hit { position: absolute; border: 0; padding: 0; background: transparent; }
.history-tooltip { position: absolute; width: 180px; z-index: 3; pointer-events: none; padding: 8px 10px; border: 1px solid #cad3de; border-radius: 5px; background: #fff; color: #1c1c1e; box-shadow: 0 3px 12px #172b4620; font-size: 12px; }
.history-tooltip small { display: block; font-size: 11px; color: #606a77; margin-bottom: 4px; }
.history-tooltip p { margin: 0 0 5px; overflow-wrap: anywhere; }
.history-tooltip div { display: flex; justify-content: space-between; gap: 8px; }
.history-axis-note { font-size: 11px; color: #606a77; line-height: 1.6; margin: 2px 4px 14px; }
.history-selected { border-top: 1px solid #e4e8ec; padding-top: 10px; margin: 2px 4px 8px; font-size: 12px; color: #414c5b; }
.history-selected .history-race { display: block; margin-bottom: 6px; overflow-wrap: anywhere; }
.history-selected .history-values { display: flex; flex-wrap: wrap; gap: 6px 24px; }
.history-selected strong { font-size: 18px; color: #1c1c1e; font-variant-numeric: tabular-nums; }
.history-details { border-top: 1px solid #e4e8ec; padding: 16px 18px 0; }
.history-table-wrap { width: 100%; }
.history-table { border-collapse: collapse; table-layout: fixed; width: 100%; color: #1c1c1e; background: #fff; }
.history-table th, .history-table td { border: 0; border-bottom: 1px solid #e4e8ec; text-align: left; white-space: normal; padding: 12px 8px; font-size: 12px; vertical-align: middle; }
.history-table th { padding-block: 8px; font-size: 11px; background: #f3f5f7; color: #606a77; }
.history-table small { display: block; color: #606a77; font-size: 11px; margin-top: 2px; }
.history-table .history-date { width: 98px; }
.history-table .history-course { width: 128px; }
.history-table .history-finish { width: 48px; text-align: center; }
.history-table .history-score { width: 68px; text-align: right; font-variant-numeric: tabular-nums; }
.history-table td.history-score { font-size: 18px; font-weight: bold; }
.history-table tr[data-selected="true"] td { background: #edf4fb; }
.history-run-trigger { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; width: 100%; text-align: left; border: 0; padding: 3px 0; border-radius: 0; background: transparent; overflow-wrap: anywhere; }
.history-race-name { color: #1a56a0; font-weight: bold; text-decoration: underline; text-underline-offset: 3px; }
.history-grade { display: inline-block; padding: 0 4px; font-size: 11px; color: #4a5767; background: #eef1f4; border-radius: 3px; white-space: nowrap; }
.history-mobile-meta { display: none; }
.history-empty { margin: 0; padding: 28px 18px; text-align: center; color: #606a77; }
.history-foot { margin: 0; padding: 12px 22px 16px; color: #606a77; font-size: 11px; }
@media (max-width: 600px) {
  #horse-history-dialog { width: calc(100% - 16px); max-height: calc(100dvh - 16px); }
  .history-head { padding: 14px 14px 12px; }
  .history-head h2 { font-size: 18px; }
  .history-summary { margin: 0 14px 20px; gap: 12px 20px; font-size: 11px; }
  .history-summary strong { font-size: 24px; }
  .history-summary .history-primary strong { font-size: 30px; }
  #history-chart-panel { padding-inline: 10px; }
  .history-selected { font-size: 11px; }
  .history-details { padding: 14px 10px 0; }
  .history-table .history-date, .history-table .history-course { display: none; }
  .history-table th, .history-table td { padding-inline: 6px; }
  .history-table .history-finish { width: 40px; }
  .history-table .history-score { width: 58px; }
  .history-mobile-meta { display: block; color: #606a77; font-size: 11px; line-height: 1.6; }
  .history-foot { padding-inline: 14px; }
}
@media (pointer: coarse) {
  .horse-history-trigger, .history-close, .history-legend button, .history-run-trigger { min-height: 44px; }
}
