[hidden] { display: none !important; }
:root {
  --turf: #12402f;
  --turf-2: #1b5a42;
  --page: #eef2ee;
  --surface: #ffffff;
  --ink: #17201b;
  --muted: #5d6a62;
  --line: #d6ddd7;
  --gold: #b88a1c;
  --gold-soft: #f6ecd2;
  --firm: #1d7a44;
  --drift: #b2392a;
  --bar: #2e7d5b;
  --bar-bg: #e3e9e4;
  --on-turf: #f3f7f4;
  --on-turf-muted: #b9cdc2;
  --cloth: #ffffff;
  --cloth-ink: #111;
  --focus: #e0a526;
  --radius-sm: 4px;
  --radius: 8px;
  color-scheme: light;
  font-family: "Barlow", "Segoe UI", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.45;
  box-sizing: border-box;
  padding-top: env(safe-area-inset-top, 0px);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
@media (prefers-color-scheme: dark) {
  :root {
    --turf: #163d2e;
    --turf-2: #1f5440;
    --page: #0d1511;
    --surface: #141f1a;
    --ink: #e5ece7;
    --muted: #93a39a;
    --line: #263630;
    --gold: #e0b44a;
    --gold-soft: #3a3118;
    --firm: #4cc27f;
    --drift: #f07862;
    --bar: #49a97d;
    --bar-bg: #22322a;
    --on-turf: #eef5f0;
    --on-turf-muted: #9fbcae;
    --cloth: #f2f2ee;
    --cloth-ink: #111;
    color-scheme: dark;
  }
}
*, *::before, *::after { box-sizing: inherit; }
html { scroll-padding-top: env(safe-area-inset-top, 0px); }
body { margin: 0; background: var(--page); color: var(--ink); }
button { font: inherit; color: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.num, .odds { font-family: "Barlow Condensed", "Arial Narrow", sans-serif; font-variant-numeric: tabular-nums; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: env(safe-area-inset-top, 0px); z-index: 20;
  display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 54px;
  background: var(--turf); color: var(--on-turf);
}
body::before {
  content: ""; position: fixed; inset: 0 0 auto; height: env(safe-area-inset-top, 0px);
  z-index: 30; background: var(--turf);
}
.brand { font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 1.45rem; letter-spacing: 0.01em; white-space: nowrap; }
.nav { display: flex; gap: 4px; }
.nav a {
  text-decoration: none; padding: 6px 12px; border-radius: var(--radius-sm); color: var(--on-turf-muted); font-weight: 500;
}
.nav a[aria-current="page"] { color: var(--on-turf); background: var(--turf-2); }
.nav a:hover { color: var(--on-turf); }
.feeds { margin-left: auto; display: flex; gap: 14px; font-size: 0.85rem; color: var(--on-turf-muted); }
.feed { display: inline-flex; align-items: center; gap: 6px; white-space: nowrap; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #8a9a91; }
.dot.ok { background: #5bd38f; }
.dot.bad { background: #ff7d6b; }
.demo-flag { background: var(--gold); color: #1d1606; font-weight: 600; font-size: 0.8rem; padding: 2px 8px; border-radius: var(--radius-sm); }

/* ---------- next to jump ---------- */
.ntj { display: flex; gap: 10px; overflow-x: auto; padding: 12px 20px; background: var(--surface); border-bottom: 1px solid var(--line); scrollbar-width: thin; }
.ntj-item {
  flex: 0 0 auto; min-width: 190px; text-align: left; cursor: pointer; background: none;
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 12px;
}
.ntj-item:hover { border-color: var(--bar); }
.ntj-top { display: flex; justify-content: space-between; gap: 10px; align-items: baseline; }
.ntj-venue { font-weight: 600; }
.ntj-time { font-family: "Barlow Condensed", sans-serif; font-size: 1.15rem; font-weight: 600; }
.ntj-time.soon { color: var(--drift); }
.ntj-pick { font-size: 0.85rem; color: var(--muted); margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 240px; }
.ntj-pick strong { color: var(--ink); font-weight: 600; }
.ntj-value { margin-top: 4px; }

/* ---------- layout ---------- */
.layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); min-height: calc(100vh - 54px); }
.rail { border-right: 1px solid var(--line); background: var(--surface); padding: 14px 0; }
.main { min-width: 0; padding: 20px 24px 60px; }
@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .rail, .main { min-width: 0; }
  .rail { border-right: 0; border-bottom: 1px solid var(--line); padding: 10px 0; }
  .main { padding: 14px 12px 50px; }
  .topbar { gap: 10px; padding: 0 12px; }
  .feeds .label { display: none; }
  .brand { font-size: 1.25rem; }
  .nav a { padding: 6px 8px; white-space: nowrap; }
  .feeds { gap: 8px; }
}
@media (max-width: 460px) {
  .brand { display: none; }
  .demo-flag .long { display: none; }
}

/* day switch */
.day-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; padding: 0 14px 12px; border-bottom: 1px solid var(--line); }
.day-tabs button {
  background: var(--page); border: 1px solid var(--line); border-radius: var(--radius); padding: 7px 10px; cursor: pointer;
  text-align: left; font-weight: 600; line-height: 1.2;
}
.day-tabs button span { display: block; font-weight: 400; font-size: 0.8rem; color: var(--muted); }
.day-tabs button[aria-selected="true"] { background: var(--turf); border-color: var(--turf); color: var(--on-turf); }
.day-tabs button[aria-selected="true"] span { color: var(--on-turf-muted); }
@media (max-width: 900px) { .day-tabs { padding: 0 12px 10px; } }

/* meetings list */
.meeting { padding: 10px 18px 12px; border-bottom: 1px solid var(--line); }
.meeting:last-child { border-bottom: 0; }
.meeting-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.meeting-name { font-weight: 600; font-size: 1.02rem; }
.meeting-state { color: var(--muted); font-size: 0.85rem; font-weight: 500; margin-left: 4px; }
.going { font-size: 0.8rem; font-weight: 600; padding: 1px 7px; border-radius: 10px; background: var(--bar-bg); white-space: nowrap; }
.going.soft { background: #dcebf6; color: #1d4b6e; }
.going.heavy { background: #d6dcf2; color: #27326e; }
@media (prefers-color-scheme: dark) {
  .going.soft { background: #1c3446; color: #a9cdec; }
  .going.heavy { background: #232a4a; color: #b8c2f0; }
}
.race-grid { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; }
.race-btn {
  width: 36px; height: 32px; border: 1px solid var(--line); background: var(--surface); border-radius: var(--radius-sm);
  font-family: "Barlow Condensed", sans-serif; font-weight: 600; font-size: 1rem; cursor: pointer;
}
.race-btn:hover { border-color: var(--bar); }
.race-btn.done { color: var(--muted); background: var(--page); }
.race-btn.next { border-color: var(--turf); box-shadow: inset 0 -3px 0 var(--gold); }
.race-btn[aria-current="true"] { background: var(--turf); color: var(--on-turf); border-color: var(--turf); }
@media (max-width: 900px) {
  .meetings { display: flex; overflow-x: auto; }
  .meeting { flex: 0 0 auto; border-bottom: 0; border-right: 1px solid var(--line); min-width: 230px; }
}

/* ---------- race header ---------- */
.race-head {
  background: var(--turf); color: var(--on-turf); border-radius: var(--radius); padding: 18px 22px;
  display: grid; grid-template-columns: auto 1fr auto; gap: 6px 22px; align-items: center;
}
.race-no { font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 4rem; line-height: 0.9; letter-spacing: -0.01em; }
.race-title { min-width: 0; }
.race-venue { font-family: "Barlow Condensed", sans-serif; font-size: 1.7rem; font-weight: 600; line-height: 1.1; }
.race-name { color: var(--on-turf-muted); margin-top: 2px; }
.race-facts { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-top: 8px; font-size: 0.92rem; }
.race-facts span b { font-weight: 600; color: var(--on-turf); }
.race-facts span { color: var(--on-turf-muted); }
.race-clock { text-align: right; }
.clock { font-family: "Barlow Condensed", sans-serif; font-size: 2.6rem; font-weight: 600; line-height: 1; font-variant-numeric: tabular-nums; }
.clock-sub { color: var(--on-turf-muted); font-size: 0.88rem; margin-top: 4px; }
@media (max-width: 640px) {
  .race-head { grid-template-columns: auto 1fr; padding: 14px 16px; }
  .race-no { font-size: 3rem; }
  .race-venue { font-size: 1.35rem; }
  .race-clock { grid-column: 1 / -1; text-align: left; display: flex; gap: 12px; align-items: baseline; }
  .clock { font-size: 2rem; }
}
.notice { margin: 12px 0 0; padding: 10px 14px; border-radius: var(--radius); background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 0.92rem; }
.notice.warn { border-color: var(--gold); background: var(--gold-soft); color: var(--ink); }

/* ---------- runners ---------- */
.legend { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 16px 2px 8px; font-size: 0.85rem; color: var(--muted); align-items: center; }
.legend .sort { margin-left: auto; display: inline-flex; gap: 4px; align-items: center; }
.legend .sort button { background: none; border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 2px 9px; cursor: pointer; color: var(--muted); }
.legend .sort button[aria-pressed="true"] { background: var(--turf); border-color: var(--turf); color: var(--on-turf); }
.legend .tick-sample { display: inline-block; width: 2px; height: 12px; background: var(--ink); vertical-align: -2px; margin-right: 5px; }
.legend .bar-sample { display: inline-block; width: 18px; height: 8px; background: var(--bar); border-radius: 2px; margin-right: 5px; }
.runners { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.runners-head, .runner-row {
  display: grid;
  grid-template-columns: 46px minmax(180px, 1.5fr) minmax(150px, 1.1fr) 64px 92px minmax(120px, 0.9fr);
  gap: 14px; align-items: center; padding: 10px 16px;
}
.runners-head { font-size: 0.8rem; color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); padding-top: 8px; padding-bottom: 8px; }
.runner { border-bottom: 1px solid var(--line); }
.runner:last-child { border-bottom: 0; }
.runner-row { cursor: pointer; width: 100%; text-align: left; background: none; border: 0; }
.runner-row:hover { background: color-mix(in srgb, var(--page) 60%, transparent); }
.runner.value .runner-row { background: color-mix(in srgb, var(--gold-soft) 70%, transparent); }
.runner.top .cloth { box-shadow: 0 0 0 2px var(--turf); }
.runner.scratched { opacity: 0.5; }
.runner.scratched .horse-name { text-decoration: line-through; }
.runner.won .cloth { box-shadow: 0 0 0 3px var(--gold); }

.cloth {
  width: 40px; height: 44px; background: var(--cloth); color: var(--cloth-ink); border: 1px solid #c9cfca;
  border-radius: 3px 3px 7px 7px; display: grid; place-items: center;
  font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 1.45rem;
}
.horse-name { font-weight: 600; font-size: 1.05rem; line-height: 1.2; }
.horse-meta { color: var(--muted); font-size: 0.85rem; margin-top: 2px; }
.horse-meta b { color: var(--ink); font-weight: 600; }
.lastten { font-family: "Barlow Condensed", sans-serif; letter-spacing: 0.06em; font-size: 0.95rem; }
.tags { display: inline-flex; gap: 5px; margin-left: 6px; vertical-align: 2px; }
.tag { font-size: 0.72rem; font-weight: 600; padding: 1px 6px; border-radius: 3px; background: var(--bar-bg); color: var(--ink); }
.tag.value { background: var(--gold); color: #1d1606; }
.tag.top { background: var(--turf); color: var(--on-turf); }
.tag.won { background: var(--gold); color: #1d1606; }

.chance { min-width: 0; }
.chance-figs { display: flex; justify-content: space-between; font-size: 0.85rem; color: var(--muted); }
.chance-figs .ours { font-family: "Barlow Condensed", sans-serif; font-size: 1.3rem; font-weight: 600; color: var(--ink); line-height: 1; }
.bar { position: relative; height: 8px; background: var(--bar-bg); border-radius: 4px; margin-top: 5px; }
.bar-fill { position: absolute; inset: 0 auto 0 0; background: var(--bar); border-radius: 4px; }
.bar-tick { position: absolute; top: -4px; width: 2px; height: 16px; background: var(--ink); border-radius: 1px; }
.fair { font-family: "Barlow Condensed", sans-serif; font-size: 1.2rem; font-weight: 600; }
.fair small { display: block; font-family: "Barlow", sans-serif; font-size: 0.72rem; color: var(--muted); font-weight: 500; }
.bf { display: grid; grid-template-columns: 1fr 1fr; gap: 3px; }
.bf span { font-family: "Barlow Condensed", sans-serif; font-weight: 600; font-size: 1.05rem; text-align: center; padding: 2px 0; border-radius: 3px; }
.bf .back { background: #d4e8fb; color: #0f3a62; }
.bf .lay { background: #f8dde4; color: #6b1630; }
@media (prefers-color-scheme: dark) {
  .bf .back { background: #183247; color: #b9dcfb; }
  .bf .lay { background: #3c1f28; color: #f6c3d0; }
}
.bf.thin span { opacity: 0.4; }
.flucs { display: flex; align-items: center; gap: 8px; min-width: 0; }
.flucs svg { flex: 1 1 auto; min-width: 50px; height: 28px; }
.flucs-figs { font-size: 0.8rem; color: var(--muted); white-space: nowrap; text-align: right; line-height: 1.25; }
.flucs-figs .move { font-weight: 600; }
.firm { color: var(--firm); }
.drift { color: var(--drift); }
.muted { color: var(--muted); }

@media (max-width: 900px) {
  .runners-head { display: none; }
  .runner-row {
    grid-template-columns: 42px 1fr auto; grid-template-areas: "cloth horse bf" "chance chance chance" "flucs flucs fair";
    gap: 8px 12px; padding: 12px;
  }
  .runner-row .cloth { grid-area: cloth; }
  .runner-row .horse { grid-area: horse; }
  .runner-row .chance { grid-area: chance; }
  .runner-row .fair { grid-area: fair; text-align: right; }
  .runner-row .bf { grid-area: bf; width: 88px; }
  .runner-row .flucs { grid-area: flucs; }
  .flucs svg { max-width: 160px; }
}

/* ---------- runner detail ---------- */
.detail { padding: 4px 16px 18px 76px; }
@media (max-width: 900px) { .detail { padding: 0 12px 16px; } }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 12px; overflow-x: auto; }
.tabs button { background: none; border: 0; padding: 8px 12px; cursor: pointer; color: var(--muted); font-weight: 600; border-bottom: 3px solid transparent; white-space: nowrap; }
.tabs button[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--turf); }
.reasons { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; max-width: 640px; }
.reasons li { display: flex; justify-content: space-between; gap: 16px; padding: 6px 10px; background: var(--page); border-radius: var(--radius-sm); }
.reasons .eff { font-family: "Barlow Condensed", sans-serif; font-weight: 600; }
.probs { display: flex; flex-wrap: wrap; gap: 8px 22px; margin: 0 0 12px; font-size: 0.92rem; }
.probs b { font-family: "Barlow Condensed", sans-serif; font-size: 1.15rem; }
.table-wrap { overflow-x: auto; }
table.data { border-collapse: collapse; width: 100%; font-size: 0.88rem; }
table.data th { text-align: left; font-weight: 600; color: var(--muted); padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td { padding: 6px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.data td.num { font-size: 1rem; }
table.data tr.win td:first-child { box-shadow: inset 3px 0 0 var(--gold); }
.pos { font-family: "Barlow Condensed", sans-serif; font-weight: 700; font-size: 1.05rem; }
.pos.p1 { color: var(--firm); }
.records { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.records div { background: var(--page); border-radius: var(--radius-sm); padding: 8px 10px; }
.records dt { font-size: 0.8rem; color: var(--muted); }
.records dd { margin: 0; font-family: "Barlow Condensed", sans-serif; font-size: 1.15rem; font-weight: 600; }
.kv { display: grid; grid-template-columns: minmax(140px, max-content) 1fr; gap: 3px 16px; font-size: 0.86rem; }
.kv dt { color: var(--muted); word-break: break-all; }
.kv dd { margin: 0; word-break: break-word; }

/* ---------- results + data pages ---------- */
.page-title { font-family: "Barlow Condensed", sans-serif; font-size: 2.2rem; font-weight: 700; margin: 0 0 4px; }
.page-intro { color: var(--muted); max-width: 70ch; margin: 0 0 20px; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; margin-bottom: 22px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; }
.stat-figure { font-family: "Barlow Condensed", sans-serif; font-size: 2.1rem; font-weight: 700; line-height: 1.05; }
.stat-text { color: var(--muted); font-size: 0.9rem; margin-top: 4px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; margin-bottom: 18px; }
.panel h2 { font-family: "Barlow Condensed", sans-serif; font-size: 1.35rem; margin: 0 0 4px; }
.panel p.sub { color: var(--muted); margin: 0 0 12px; font-size: 0.9rem; max-width: 75ch; }
pre.raw { background: var(--page); padding: 12px; border-radius: var(--radius-sm); overflow: auto; font-size: 0.78rem; max-height: 420px; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.empty strong { display: block; color: var(--ink); font-size: 1.1rem; margin-bottom: 4px; }
.btn { background: var(--turf); color: var(--on-turf); border: 0; border-radius: var(--radius-sm); padding: 8px 14px; font-weight: 600; cursor: pointer; }
.btn.quiet { background: var(--bar-bg); color: var(--ink); }
@media (prefers-reduced-motion: no-preference) {
  .detail { animation: open 0.16s ease-out; }
  @keyframes open { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
}
