/* Racing stats dashboard.  Tokens on :root; dark mode from the system setting unless the user picked one. */
:root {
  --bg: #f6f7f9; --panel: #ffffff; --text: #1b1f24; --muted: #5f6b7a; --line: #e2e6eb; --accent: #1f6feb; --accent-soft: #e8f0fe;
  --plus: #1a7f37; --plus-soft: #e6f4ea; --minus: #b42318; --minus-soft: #fdecea; --caution: #9a6700; --caution-soft: #fff4d6;
  --info-soft: #eef1f5; --nr: #9aa4b1; --radius: 8px; --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --panel: #171b21; --text: #e6e9ee; --muted: #93a0b0; --line: #2a313a; --accent: #6ea8ff; --accent-soft: #1c2a40;
    --plus: #56d364; --plus-soft: #1b3325; --minus: #ff7b72; --minus-soft: #3a1e1c; --caution: #e3b341; --caution-soft: #3a3016; --info-soft: #222a33; --nr: #5b6572;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --text: #e6e9ee; --muted: #93a0b0; --line: #2a313a; --accent: #6ea8ff; --accent-soft: #1c2a40;
  --plus: #56d364; --plus-soft: #1b3325; --minus: #ff7b72; --minus-soft: #3a1e1c; --caution: #e3b341; --caution-soft: #3a3016; --info-soft: #222a33; --nr: #5b6572;
}
* { box-sizing: border-box; }
html { background: var(--bg); }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.45 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
main { max-width: 1400px; margin: 0 auto; padding: 16px; }
footer { max-width: 1400px; margin: 24px auto; padding: 0 16px 24px; color: var(--muted); font-size: 12.5px; }
h1 { font-size: 1.5rem; margin: .2em 0; } h2 { font-size: 1.15rem; margin: 1.2em 0 .5em; } h3 { font-size: 1rem; margin: .6em 0; }
h4 { font-size: .92rem; margin: .8em 0 .3em; } h5 { font-size: .85rem; margin: .8em 0 .2em; color: var(--muted); }
.muted { color: var(--muted); } .small-text { font-size: 12.5px; }
.empty-state { color: var(--muted); font-style: italic; margin: .4em 0; }
.hint { font-size: 11.5px; padding: 0 5px; border-radius: 4px; background: var(--caution-soft); color: var(--caution); white-space: nowrap; }
.note { background: var(--accent-soft); padding: 8px 10px; border-radius: var(--radius); }
.source { font-size: 12px; padding: 1px 6px; border-radius: 4px; background: var(--info-soft); color: var(--muted); }
button.ghost { background: none; border: 0; color: var(--muted); cursor: pointer; font: inherit; padding: 2px 4px; }

/* header */
header.top { position: sticky; top: 0; z-index: 10; display: flex; gap: 14px; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); }
.brand { font-weight: 700; color: var(--text); }
header.top nav { display: flex; gap: 12px; }
.search { position: relative; flex: 1; max-width: 420px; margin-left: auto; }
.search input { width: 100%; padding: 7px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
#search-results { position: absolute; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 4px; list-style: none; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgb(0 0 0 / .12); max-height: 60vh; overflow: auto; }
#search-results li a { display: flex; justify-content: space-between; gap: 8px; padding: 6px 8px; border-radius: 6px; color: var(--text); }
#search-results li a:hover, #search-results li a.active { background: var(--accent-soft); text-decoration: none; }
#search-results .kind { color: var(--muted); font-size: 12px; }

/* today */
.day-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 8px; }
.day-toggle { display: flex; gap: 6px; }
.chip { display: inline-block; padding: 2px 10px; border-radius: 999px; background: var(--info-soft); color: var(--muted); font-size: 13px; }
.chip.on { background: var(--accent); color: #fff; }
.next-off { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 12px; }
.next { flex: 0 0 auto; display: flex; gap: 8px; align-items: center; padding: 8px 12px; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); color: var(--text); }
.next .t { font-weight: 700; } .countdown { color: var(--accent); font-variant-numeric: tabular-nums; }
.meetings { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; }
.meeting { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; }
.meeting header h2 { margin: 0 0 4px; }
.meeting .going { font-size: 14px; } .meeting .weather { font-size: 13px; }
.races { list-style: none; padding: 0; margin: 10px 0 0; }
.races li a { display: grid; grid-template-columns: 48px 1fr auto; column-gap: 8px; padding: 6px 4px; border-top: 1px solid var(--line); color: var(--text); }
.races li a:hover { background: var(--accent-soft); text-decoration: none; }
.races .t { font-weight: 700; font-variant-numeric: tabular-nums; } .races .name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.races .meta { grid-column: 2; color: var(--muted); font-size: 12.5px; } .races .done { grid-row: 1; grid-column: 3; color: var(--plus); }

/* race card */
.crumbs { color: var(--muted); font-size: 13px; }
.race-head h1 .t { font-variant-numeric: tabular-nums; }
.race-name { margin: 0 0 10px; color: var(--muted); }
.facts { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 8px 16px; margin: 8px 0; }
.facts dt { font-size: 12px; color: var(--muted); } .facts dd { margin: 0; }
.draw { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; margin: 10px 0; max-width: 640px; }
.strip { display: flex; flex-wrap: wrap; gap: 6px 14px; padding: 8px 12px; margin: 8px 0; background: var(--accent-soft); border-radius: var(--radius); font-size: 14px; }
.strip span + span::before { content: "· "; color: var(--muted); }
.controls { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; margin: 8px 0; font-size: 14px; }
.colpick { position: relative; } .colpick summary { cursor: pointer; }
#colpick { position: absolute; z-index: 5; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px; display: grid; grid-template-columns: repeat(3, auto); gap: 2px 12px; }
.table-wrap { overflow-x: auto; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; }
table.card, table.list { width: 100%; font-size: 13.5px; }
table.card th, table.list th { position: sticky; top: 0; background: var(--panel); text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap; }
th[data-sort] { cursor: pointer; } th[data-sort]:hover { color: var(--text); } th.sorted-asc::after { content: " ▲"; } th.sorted-desc::after { content: " ▼"; }
table.card td, table.list td { padding: 6px; border-bottom: 1px solid var(--line); white-space: nowrap; vertical-align: middle; font-variant-numeric: tabular-nums; }
tbody.rg:hover tr.runner td, tbody.rg:hover tr.comment td { background: var(--accent-soft); }
tbody.rg.nr td, tbody.rg.nr a { color: var(--nr); } tbody.rg.nr tr.runner td { text-decoration: line-through; text-decoration-color: var(--nr); }
tbody.rg.nr .flags, tbody.rg.nr td:first-child { text-decoration: none; }
/* Racing Post-style runner row: things stacked vertically rather than spread sideways */
table.card tr.runner td { vertical-align: top; padding-top: 7px; padding-bottom: 7px; }
table.card tr.runner:has(+ tr.comment) td { border-bottom: 0; }
td.pos { font-weight: 700; font-size: 1.15rem; } td.no strong { font-size: 1.05rem; }
sup.dr { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 1px; }
td.btn { font-size: 13px; }
td.silkform { text-align: center; width: 44px; }
img.silk { width: 30px; height: 30px; display: block; margin: 0 auto 2px; }
td.silkform .form { font-size: 12px; color: var(--muted); letter-spacing: .5px; }
td.horse { white-space: normal !important; min-width: 170px; }
td.horse .hl { font-weight: 600; font-size: 14.5px; } td.horse .cloth { color: var(--muted); font-weight: 400; }
sup.dsl { font-size: 11px; font-weight: 400; color: var(--muted); margin-left: 2px; }
td.horse .sub { font-size: 12.5px; margin-top: 1px; }
td.horse button.expand { padding: 0; font-size: 12.5px; }
td.wt div + div { font-weight: 600; }
.hg { display: inline-block; font-size: 11px; font-weight: 700; line-height: 1; padding: 2px 3px; border: 1px solid var(--caution); border-radius: 3px;
  color: var(--caution); cursor: help; vertical-align: 1px; } .hg sup { font-size: 9px; }
td.jt { line-height: 1.35; } td.jt .lbl { color: var(--muted); font-size: 12px; } td.jt sup { font-size: 10.5px; color: var(--muted); }
td.price .pv { font-weight: 600; } td.price .arrow { margin-left: 3px; font-size: 11px; }
tr.comment td { padding: 0 6px 7px; font-size: 12.5px; color: var(--muted); white-space: normal !important; }
/* full-width rows stay inside the visible area when the table is scrolled sideways on a narrow screen */
tr.comment td > div, tr.details td > .drawer { position: sticky; left: 6px; max-width: min(1360px, calc(100vw - 48px)); }
.arrow.in { color: var(--plus); } .arrow.out { color: var(--minus); }
.flags { white-space: normal !important; min-width: 96px; max-width: 170px; }
.flag { position: relative; display: inline-block; margin: 1px 2px 1px 0; padding: 1px 7px; border-radius: 999px; font-size: 12px; cursor: help; background: var(--info-soft); color: var(--text); }
.flag.tone-plus { background: var(--plus-soft); color: var(--plus); } .flag.tone-minus { background: var(--minus-soft); color: var(--minus); }
.flag.tone-caution { background: var(--caution-soft); color: var(--caution); }
/* compact icons, Racing Post style: letter squares (C, D, CD, BF ...) and small symbols */
.flag.ico { display: inline-flex; align-items: center; gap: 1px; height: 20px; min-width: 20px; padding: 0 3px; border-radius: 4px; justify-content: center;
  font-size: 11px; line-height: 1; vertical-align: middle; border: 1px solid transparent; }
.flag.ico svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.flag.ico b { font-weight: 700; letter-spacing: -.2px; }
.flag.ico.letters { background: var(--text); color: var(--bg); }
.flag.ico.letters.tone-plus { background: var(--plus); color: #fff; } .flag.ico.letters.tone-minus { background: var(--minus); color: #fff; }
.flag.ico.letters.tone-caution { background: var(--caution); color: #fff; }
.legend { position: relative; } .legend summary { cursor: pointer; }
.legend ul { position: absolute; z-index: 6; left: 0; width: max-content; max-width: min(460px, 90vw); list-style: none; margin: 4px 0 0; padding: 8px 10px;
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: 0 6px 20px rgb(0 0 0 / .12); font-size: 13px; }
.legend li { padding: 2px 0; } .legend .flag { cursor: default; }
td.chev, th.chev { width: 22px; padding-left: 4px !important; padding-right: 0 !important; }
button.expand { background: none; border: 0; cursor: pointer; color: var(--minus); font: 700 18px/1 var(--font); padding: 0 4px; transition: transform .15s; }
tbody.rg.open button.expand { transform: rotate(90deg); }
tbody.rg tr.runner { cursor: pointer; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.drawer .notes { grid-column: 1 / -1; } .drawer .notes p { margin: .3em 0; }
.drawer .moves { grid-column: span 2; } @media (max-width: 720px) { .drawer .moves { grid-column: auto; } }
.story { margin: 4px 0 10px; } .story .st-head { font-size: 12px; color: var(--muted); }
.story .st-line { font-size: 13.5px; margin: 2px 0; } .story .st-pt { white-space: nowrap; }
.story .mv { margin-left: 8px; font-size: 12.5px; font-weight: 600; white-space: nowrap; }
.mv-shortened { color: var(--plus); } .mv-drifted { color: var(--minus); } .mv-steady { color: var(--muted); }
.story svg.spark { width: 220px; height: 44px; } .story svg.spark circle { fill: currentColor; }
.fig { cursor: help; white-space: nowrap; } .fig .wl { color: var(--muted); font-size: 12px; }
.fig .own { color: var(--muted); font-size: 11px; margin-left: 2px; vertical-align: super; }
.fig-note { margin-top: 10px; }
.flag.open::after { content: attr(data-detail); position: absolute; left: 0; top: 120%; z-index: 20; width: max-content; max-width: 280px; white-space: normal; padding: 6px 8px; border-radius: 6px; background: var(--text); color: var(--bg); font-size: 12px; }
tr.details td { background: var(--bg); white-space: normal !important; }
.drawer { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 6px 18px; padding: 2px 4px 6px; }
.drawer h4 { margin: .4em 0 .3em; }
.drawer .ext { font-size: 12.5px; margin: 4px 0; }
.detail-grid { display: grid; grid-template-columns: minmax(260px, 1fr) minmax(320px, 2fr); gap: 16px; padding: 4px 6px; }
dl.kv { display: grid; grid-template-columns: auto 1fr; gap: 3px 12px; margin: 0; } dl.kv dt { color: var(--muted); } dl.kv dd { margin: 0; }
svg.spark { width: 200px; height: 40px; color: var(--accent); display: block; }
td.flash, .stamp b.flash { animation: flash 1.6s ease-out; } @keyframes flash { from { background: var(--caution-soft); } to { background: transparent; } }
/* course-page draw charts (brief 6.8) and the horse page's ratings chart */
.draw-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin: 8px 0; }
.draw-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px; min-width: 0; }
.draw-card h4 { margin: .2em 0 .4em; } .draw-card table.mini { width: 100%; }
svg.drawchart { width: 100%; max-width: 260px; height: auto; display: block; }
svg.drawchart .bar { fill: var(--accent); } svg.drawchart .bar.small { fill: var(--muted); opacity: .55; }
svg.drawchart text { font-size: 10px; fill: var(--text); } svg.drawchart text.k { fill: var(--muted); }
svg.drawchart .axis, svg.ratings .axis { stroke: var(--line); stroke-width: 1; }
svg.ratings { width: 100%; max-width: 640px; height: auto; display: block; margin: 4px 0 8px; }
svg.ratings text { font-size: 10px; fill: var(--muted); } svg.ratings polyline { fill: none; stroke-width: 1.8; }
.rt-or { stroke: var(--accent); fill: var(--accent); } .rt-rpr { stroke: var(--plus); fill: var(--plus); } .rt-ts { stroke: var(--caution); fill: var(--caution); }
.rt-tfm { stroke: var(--minus); fill: var(--minus); }
.legend-inline span { margin-right: 12px; font-size: 12px; } .legend-inline i { display: inline-block; width: 10px; height: 3px; margin-right: 4px; vertical-align: middle; }
.login { max-width: 340px; margin: 40px auto; } .login form { display: grid; gap: 10px; margin: 12px 0; }
.login label { display: grid; gap: 4px; font-size: 13px; color: var(--muted); }
.login input { padding: 8px 10px; border-radius: var(--radius); border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
.login-error { background: var(--minus-soft); color: var(--minus); padding: 8px 10px; border-radius: var(--radius); }
.signout { display: inline-flex; align-items: center; gap: 4px; margin: 0; }
.back { margin: 0 0 6px; font-size: 13px; } .news { font-size: 12.5px; color: var(--muted); cursor: help; } th .own, h4 .own { color: var(--muted); font-weight: 400; }
/* "last updated" stamps (brief section 5): quiet, never louder than the data they date */
.stamp { font-size: 12px; font-weight: 400; color: var(--muted); } .stamp b { font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; }
h2 .stamp, h3 .stamp, h4 .stamp { margin-left: 6px; }
.stamps { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.6; } .stamps .stamp { white-space: nowrap; }

/* rates and small tables */
.rate { font-variant-numeric: tabular-nums; } .rate.small { color: var(--muted); } .rate.small::after { content: " ·small sample"; font-size: 11px; }
.rate.empty { color: var(--muted); font-style: italic; } .place { color: var(--muted); font-size: 12.5px; }
table.mini { font-size: 13px; margin: 4px 0; } table.mini th { text-align: left; color: var(--muted); font-weight: 600; padding: 3px 10px 3px 0; }
table.mini td { padding: 3px 10px 3px 0; border-top: 1px solid var(--line); vertical-align: top; }
.windows { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; }
.window { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; } .window .label { color: var(--muted); font-size: 12.5px; }
.splits { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.profile-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 0 24px; }
.profile-grid h2 { font-size: 1.02rem; }
ul.plain { list-style: none; padding: 0; } ul.plain li { padding: 3px 0; }

/* admin */
.queue-item { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 12px; margin: 8px 0; }
.queue-item .actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 6px; }
.queue-item input { padding: 4px 8px; border-radius: 6px; border: 1px solid var(--line); background: var(--bg); color: var(--text); font: inherit; }
button.act { padding: 4px 10px; border-radius: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--text); cursor: pointer; font: inherit; }
button.act.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.queue-item.done { opacity: .55; }
.queue-item .figure { color: var(--text); font-size: 13px; }
.candidate { margin: 8px 0 4px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--bg); }
.candidate .where { font-size: 11.5px; }
ul.evidence { list-style: none; margin: 6px 0; padding: 0; font-size: 13px; }
ul.evidence li { padding: 1px 0 1px 18px; position: relative; }
ul.evidence li::before { position: absolute; left: 0; font-weight: 700; }
ul.evidence .ev-strong::before { content: "✓✓"; color: var(--plus); font-size: 10px; top: 4px; }
ul.evidence .ev-supporting::before { content: "✓"; color: var(--plus); }
ul.evidence .ev-against::before { content: "✗"; color: var(--minus); }

@media (max-width: 720px) {
  header.top { flex-wrap: wrap; } .search { order: 3; max-width: none; flex-basis: 100%; }
  .detail-grid { grid-template-columns: 1fr; }
  .meetings { grid-template-columns: 1fr; }
  table.card td, table.card th { padding-left: 4px; padding-right: 4px; }
  td.horse { min-width: 130px; }
}
