:root {
  --bg: #f4f5f7; --panel: #ffffff; --panel2: #f0f2f5; --line: #dfe3e8;
  --text: #1b1f24; --sub: #5d6773; --faint: #8b949e;
  --accent: #c47a00; --accent-bg: #fff4dc; --link: #1f6feb;
  --turf: #2f8f4e; --dirt: #a8662b; --g1: #1f6feb; --g2: #d6336c; --g3: #2f8f4e;
  --good: #2f8f4e; --mid: #c47a00; --low: #8b949e; --danger: #cf222e;
  --bar: #c47a00; --shadow: 0 1px 2px rgba(0,0,0,.06);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1216; --panel: #171b21; --panel2: #1e232b; --line: #2a313b;
    --text: #e6e9ee; --sub: #a3adb9; --faint: #6e7781;
    --accent: #f0b429; --accent-bg: #3a2e10; --link: #6cb6ff;
    --turf: #56c271; --dirt: #e0a060; --g1: #6cb6ff; --g2: #ff7aa8; --g3: #56c271;
    --good: #56c271; --mid: #f0b429; --low: #6e7781; --danger: #ff6b6b;
    --bar: #f0b429; --shadow: none;
  }
}
:root[data-theme="dark"] {
  --bg: #0f1216; --panel: #171b21; --panel2: #1e232b; --line: #2a313b;
  --text: #e6e9ee; --sub: #a3adb9; --faint: #6e7781;
  --accent: #f0b429; --accent-bg: #3a2e10; --link: #6cb6ff;
  --turf: #56c271; --dirt: #e0a060; --g1: #6cb6ff; --g2: #ff7aa8; --g3: #56c271;
  --good: #56c271; --mid: #f0b429; --low: #6e7781; --danger: #ff6b6b;
  --bar: #f0b429; --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 14px/1.65 "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
}
a { color: var(--link); text-decoration: none; }
a:hover { text-decoration: underline; }
.num, td.n, .idx { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }
.wrap { max-width: 1120px; margin: 0 auto; padding: 0 16px; }

/* header */
header.top { background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.bar1 { display: flex; align-items: center; gap: 12px; height: 52px; }
.logo { display: flex; align-items: center; gap: 8px; color: var(--text); font-weight: 700; font-size: 17px; white-space: nowrap; }
.logo:hover { text-decoration: none; }
.logo .mark { width: 26px; height: 26px; border-radius: 6px; background: var(--accent); color: #111; display: grid; place-items: center; font-size: 13px; font-weight: 800; }
.search { margin-left: auto; display: flex; flex: 0 1 320px; min-width: 0; }
.search input { flex: 1; min-width: 0; height: 32px; border: 1px solid var(--line); border-radius: 6px 0 0 6px; background: var(--panel2); color: var(--text); padding: 0 10px; font: inherit; }
.search button, .btn { height: 32px; border: 1px solid var(--line); background: var(--panel2); color: var(--text); padding: 0 12px; font: inherit; cursor: pointer; }
.search button { border-radius: 0 6px 6px 0; border-left: 0; }
.theme { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.theme button { border: 0; background: none; color: var(--sub); padding: 4px 9px; cursor: pointer; font: inherit; font-size: 12px; }
.theme button[aria-pressed="true"] { background: var(--panel2); color: var(--text); }
nav.tabs { display: flex; overflow-x: auto; scrollbar-width: none; }
nav.tabs::-webkit-scrollbar { display: none; }
nav.tabs a { flex: 1 0 auto; text-align: center; padding: 9px 14px; color: var(--sub); border-bottom: 2px solid transparent; white-space: nowrap; }
nav.tabs a:hover { text-decoration: none; color: var(--text); }
nav.tabs a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
nav.tabs a.ai { color: var(--accent); }

/* ticker */
.ticker { background: var(--panel); border-bottom: 1px solid var(--line); }
.ticker .wrap { display: flex; align-items: center; gap: 14px; padding-top: 8px; padding-bottom: 8px; overflow-x: auto; }
.ticker .date { font-weight: 700; font-size: 20px; white-space: nowrap; }
.ticker .date small { display: block; font-size: 11px; color: var(--faint); font-weight: 400; line-height: 1; }
.ticker .feat { flex: 1; min-width: 240px; border: 1px solid var(--line); border-radius: 6px; padding: 6px 12px; display: flex; gap: 10px; align-items: center; white-space: nowrap; }
.ticker .feat .lbl { font-size: 11px; color: var(--danger); font-weight: 700; }

main { padding: 18px 0 40px; }
h1.lead { font-size: 22px; margin: 4px 0 4px; }
h1.lead em { font-style: normal; color: var(--accent); }
.leadsub { color: var(--sub); margin: 0 0 18px; font-size: 13px; }
h2.sec { font-size: 17px; margin: 26px 0 10px; display: flex; align-items: baseline; gap: 10px; }
h2.sec::before { content: ""; width: 4px; height: 16px; background: var(--accent); border-radius: 2px; align-self: center; }
h2.sec .more { margin-left: auto; font-size: 12px; font-weight: 400; }
h2.sec small { color: var(--faint); font-weight: 400; font-size: 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }

.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid.two { grid-template-columns: repeat(auto-fill, minmax(420px, 1fr)); }
@media (max-width: 520px) { .grid.two { grid-template-columns: 1fr; } }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 14px; box-shadow: var(--shadow); min-width: 0; }
.card.link { display: block; color: inherit; }
.card.link:hover { text-decoration: none; border-color: var(--accent); }
.card h4 { margin: 0 0 6px; font-size: 15px; }
.meta { color: var(--faint); font-size: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.between { justify-content: space-between; }
.big { font-size: 26px; font-weight: 700; line-height: 1.2; }

.badge { display: inline-block; font-size: 11px; line-height: 18px; padding: 0 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--sub); white-space: nowrap; }
.badge.GI, .badge.JpnI { color: #fff; background: var(--g1); border-color: var(--g1); }
.badge.GII { color: #fff; background: var(--g2); border-color: var(--g2); }
.badge.GIII { color: #fff; background: var(--g3); border-color: var(--g3); }
.badge.turf { color: var(--turf); border-color: var(--turf); }
.badge.dirt { color: var(--dirt); border-color: var(--dirt); }
.badge.high { color: var(--good); border-color: var(--good); }
.badge.mid { color: var(--mid); border-color: var(--mid); }
.badge.low { color: var(--low); }
.badge.sample { color: var(--accent); background: var(--accent-bg); border-color: var(--accent); }
.badge.warn { color: var(--danger); border-color: var(--danger); }

.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
.stat { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; color: inherit; }
.stat:hover { text-decoration: none; border-color: var(--accent); }
.stat .k { font-size: 12px; color: var(--sub); }
.stat .v { font-size: 22px; font-weight: 700; }
.stat .v small { font-size: 12px; color: var(--faint); font-weight: 400; margin-left: 2px; }

/* tables */
.tbl-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 8px; background: var(--panel); }
table { border-collapse: collapse; width: 100%; font-size: 13px; }
th, td { padding: 7px 10px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { background: var(--panel2); color: var(--sub); font-weight: 600; font-size: 12px; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
td.n { text-align: right; white-space: nowrap; }
th.n { text-align: right; }
td.hn, table.nowrap td { white-space: nowrap; }
td.kname { white-space: nowrap; color: var(--sub); width: 1%; }
.waku { display: inline-grid; place-items: center; width: 22px; height: 22px; border-radius: 3px; font-size: 12px; font-weight: 700; border: 1px solid var(--line); }
.w1 { background: #fff; color: #111; } .w2 { background: #222; color: #fff; } .w3 { background: #e03131; color: #fff; }
.w4 { background: #1c7ed6; color: #fff; } .w5 { background: #fcc419; color: #111; } .w6 { background: #2f9e44; color: #fff; }
.w7 { background: #f76707; color: #fff; } .w8 { background: #f783ac; color: #111; }
.idxbar { display: flex; align-items: center; gap: 8px; min-width: 150px; }
.idxbar .b { height: 8px; background: var(--bar); border-radius: 4px; }
.idxbar .v { font-weight: 700; width: 3.2em; text-align: right; }
tr.top1 td { background: var(--accent-bg); }
.rank { font-weight: 700; }

/* course list */
.courses { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
@media (max-width: 420px) { .courses { grid-template-columns: 1fr; } }
.course h4 { display: flex; gap: 8px; align-items: center; }
.course table td { padding: 5px 8px; font-size: 12.5px; }
.kyaku { display: flex; height: 18px; border-radius: 4px; overflow: hidden; margin: 6px 0 2px; font-size: 10px; }
.kyaku span { display: grid; place-items: center; color: #111; white-space: nowrap; overflow: hidden; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.chip { border: 1px solid var(--line); background: var(--panel); color: var(--sub); border-radius: 999px; padding: 3px 12px; cursor: pointer; font: inherit; font-size: 13px; }
.chip.on { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 600; }

/* race page */
.rgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 6px; }
.rbox { position: relative; display: flex; flex-direction: column; align-items: center; padding: 6px 4px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--text); line-height: 1.3; }
.rbox:hover { text-decoration: none; border-color: var(--accent); }
.rbox.on { background: var(--accent-bg); border-color: var(--accent); }
.rbox .dot { position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 50%; background: var(--good); }
nav.tabs2 { display: flex; overflow-x: auto; border-bottom: 1px solid var(--line); scrollbar-width: none; }
nav.tabs2 a { padding: 8px 14px; color: var(--sub); border-bottom: 2px solid transparent; white-space: nowrap; }
nav.tabs2 a:hover { text-decoration: none; color: var(--text); }
nav.tabs2 a.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }

/* markdown */
.md { overflow-wrap: anywhere; }
.md h2 { font-size: 16px; margin: 22px 0 8px; padding-bottom: 4px; border-bottom: 1px solid var(--line); }
.md h3 { font-size: 14.5px; margin: 16px 0 6px; }
.md ul, .md ol { padding-left: 1.4em; margin: 6px 0; }
.md li { margin: 2px 0; }
.md table { margin: 10px 0; display: block; overflow-x: auto; }
.md code { background: var(--panel2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.md strong { color: var(--accent); }
.md blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--line); color: var(--sub); }
.wl.miss { color: var(--sub); border-bottom: 1px dotted var(--faint); }

.notice { background: var(--accent-bg); border: 1px solid var(--accent); color: var(--text); border-radius: 8px; padding: 10px 14px; font-size: 13px; margin: 10px 0; }
.empty { color: var(--faint); padding: 18px; text-align: center; border: 1px dashed var(--line); border-radius: 8px; }
.crumbs { font-size: 12px; color: var(--faint); margin-bottom: 6px; }

/* AI form */
.btn.primary { background: var(--accent); border-color: var(--accent); color: #111; font-weight: 700; border-radius: 6px; height: 38px; padding: 0 20px; }
.btn.primary:disabled { opacity: .5; cursor: wait; }
.ctx-list { font-size: 12px; color: var(--sub); margin: 6px 0 0; padding-left: 1.2em; }

footer { border-top: 1px solid var(--line); background: var(--panel); color: var(--faint); font-size: 12px; padding: 18px 0 28px; }
footer p { margin: 4px 0; }
.flinks { display: flex; flex-wrap: wrap; gap: 6px 18px; margin-bottom: 12px; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.flinks a { color: var(--sub); font-size: 13px; }
.flinks a:hover { color: var(--text); }
.flinks a.on { color: var(--text); font-weight: 600; }
.page-body { max-width: 760px; }
.news-item { padding: 10px 0; border-bottom: 1px solid var(--line); }
.news-item:last-child { border-bottom: 0; }

/* トップ (今日) */
.ticker .feat { overflow: hidden; }
.ticker .feat.right { flex: 0 0 auto; min-width: 0; }
.dtabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.dtab { display: block; text-align: center; padding: 10px 6px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel); color: var(--sub); font-size: 13px; }
.dtab b { color: var(--text); margin-right: 4px; }
.dtab:hover { text-decoration: none; border-color: var(--accent); }
.dtab.on { background: var(--accent-bg); border-color: var(--accent); color: var(--text); }
.dtab.off { color: var(--faint); }
.vgrid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.vcard { display: flex; flex-direction: column; scroll-margin-top: 12px; }
.vcard .next { display: block; margin-top: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 6px; background: var(--panel2); color: inherit; }
.vcard .next:hover { text-decoration: none; border-color: var(--accent); }
.vcard .vall { margin-top: auto; display: block; text-align: center; padding: 8px; border-top: 1px solid var(--line); margin: 10px -14px -14px; color: var(--link); }
.vcard .rgrid { grid-template-columns: repeat(auto-fill, minmax(64px, 1fr)); }
.finder { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.finder .card { padding: 10px 12px; }
.cal { background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 10px; margin: 4px 0 18px; }
.cal-head { margin-bottom: 8px; }
.cal-head .btn { display: grid; place-items: center; border-radius: 6px; height: 28px; font-size: 12px; }
.cal-head .btn:hover { text-decoration: none; border-color: var(--accent); }
.cal-head .btn.off { color: var(--faint); cursor: default; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 3px; }
.cal-w { text-align: center; font-size: 11px; color: var(--faint); }
.cal-w.sun { color: var(--danger); } .cal-w.sat { color: var(--link); }
.cal-d { display: flex; flex-direction: column; gap: 1px; min-height: 64px; padding: 3px 4px; border: 1px solid var(--line); border-radius: 5px; background: var(--panel2); color: var(--text); font-size: 10.5px; line-height: 1.25; overflow: hidden; }
.cal-d b { font-size: 13px; }
.cal-d i { font-style: normal; color: var(--sub); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cal-d i.jra { color: var(--link); }
.cal-d em { font-style: normal; color: var(--accent); font-size: 10px; }
a.cal-d:hover { text-decoration: none; border-color: var(--accent); }
.cal-d.on { background: var(--accent-bg); border-color: var(--accent); }
.cal-d.today b { color: var(--accent); text-decoration: underline; }
.cal-d.none { background: transparent; color: var(--faint); }
.cal-d.out { border: 0; background: transparent; }
.cal-note { margin-top: 6px; font-size: 11px; } .cal-note i { font-style: normal; color: var(--link); }
@media (max-width: 520px) { .cal-d { min-height: 52px; font-size: 9.5px; padding: 2px; } .cal-d em { display: none; } }
.cal-fold { display: none; width: 100%; margin-top: 6px; background: none; border: 0; color: var(--link); font: inherit; font-size: 12.5px; cursor: pointer; }
.cal-fold .c, .cal.fold .cal-fold .o { display: inline; } .cal-fold .o, .cal.fold .cal-fold .c { display: none; }
@media (max-width: 520px) { .cal-fold { display: block; } .cal.fold .cal-d:not(.cw) { display: none; } }

/* レースページ: レース番号の帯・見出し・出馬表 */
.rnav { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.rn-side { flex: 0 0 auto; font-size: 12.5px; white-space: nowrap; }
.rn-side.off { color: var(--faint); }
.rn-list { flex: 1; display: flex; gap: 4px; overflow-x: auto; scrollbar-width: none; }
.rn { position: relative; flex: 0 0 auto; display: flex; align-items: baseline; gap: 4px; padding: 4px 9px; border: 1px solid var(--line); border-radius: 4px; background: var(--panel); color: var(--text); font-size: 13px; }
.rn:hover { text-decoration: none; border-color: var(--accent); }
.rn small { font-size: 10.5px; color: var(--faint); }
.rn.on { background: var(--text); color: var(--panel); border-color: var(--text); }
.rn.on small { color: var(--panel); opacity: .75; }
.rn .dot { position: absolute; top: 2px; right: 2px; width: 6px; height: 6px; border-radius: 50%; background: var(--good); }
.rhead { display: flex; align-items: center; gap: 10px; margin: 6px 0 2px; }
.rhead h1 { margin: 0; font-size: 22px; line-height: 1.3; }
.rhead h1 small { font-size: 15px; font-weight: 500; color: var(--sub); }
.rnum { flex: 0 0 auto; display: grid; place-items: center; min-width: 40px; height: 30px; padding: 0 6px; border-radius: 4px; background: var(--text); color: var(--panel); font-weight: 700; }
.rmeta { gap: 14px; margin: 2px 0 12px; font-size: 13px; color: var(--sub); }
.rmeta b { color: var(--text); }
table.shutuba td { vertical-align: middle; }
table.shutuba td.wb { white-space: nowrap; font-variant-numeric: tabular-nums; }
table.shutuba td.mk { text-align: center; font-size: 15px; }
table.shutuba td.hn { line-height: 1.35; }
table.shutuba .ped { font-size: 11.5px; color: var(--sub); font-weight: 400; }
table.shutuba tr.out td { opacity: .45; }
.f5s { white-space: nowrap; }
.f5 { display: inline-grid; place-items: center; width: 20px; height: 20px; margin-right: 2px; border-radius: 3px; background: var(--panel2); font-size: 11px; font-weight: 700; color: var(--sub); }
.f5.p1 { background: #f0b429; color: #111; } .f5.p2 { background: #adb5bd; color: #111; } .f5.p3 { background: #d9a074; color: #111; }
@media (max-width: 520px) { .rn-side { display: none; } .rhead h1 { font-size: 18px; } }

/* データ (データを探す) */
.crumbs { font-size: 12.5px; color: var(--sub); margin: 10px 0 2px; }
.topics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.topic { display: block; padding: 10px 12px; border-radius: 6px; border-top: 4px solid #b5452f; background: var(--panel); color: var(--text); box-shadow: var(--shadow); }
.topic:hover { text-decoration: none; border-color: var(--accent); }
.topic .k { font-size: 11.5px; color: var(--sub); }
.topic b { display: block; font-size: 19px; line-height: 1.35; text-decoration: underline; text-underline-offset: 3px; }
.cats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 14px 0 10px; }
.cat { display: flex; align-items: center; gap: 10px; padding: 12px 14px; border-radius: 8px; border: 1px solid var(--line); background: var(--panel); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; text-align: left; }
.cat b { color: var(--accent); }
.cat:hover { border-color: var(--accent); }
.ic { flex: 0 0 auto; display: inline-block; width: 26px; height: 26px; border-radius: 50%; background: var(--accent); position: relative; }
.ic::after { content: ""; position: absolute; inset: 8px; border-radius: 2px; background: #fff; }
.ic-chart { background: #b5452f; } .ic-cal { background: #b8742a; } .ic-track { background: #7a5a9e; }
.qlinks { display: flex; flex-wrap: wrap; gap: 6px 26px; padding: 12px 18px; border-left: 4px solid #b5452f; background: var(--panel2); margin-bottom: 18px; font-size: 13.5px; }
.qlinks a { color: var(--text); }
.dsec { display: flex; align-items: center; gap: 10px; font-size: 19px; margin: 22px 0 6px; padding-bottom: 8px; border-bottom: 2px solid #b5452f; }
.dlist { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 24px; }
.dlist a { display: block; padding: 10px 2px; border-bottom: 1px solid var(--line); color: var(--text); }
.dlist a:hover { text-decoration: none; color: var(--accent); }
.dlist b { display: block; font-size: 15px; }
.dlist span { font-size: 12.5px; color: var(--sub); }
@media (max-width: 640px) { .topics, .cats { grid-template-columns: 1fr; } .dlist { grid-template-columns: 1fr; } }
.ic-lock { background: #4d6a7a; }
td.ppl { white-space: normal; min-width: 22em; font-size: 12.5px; line-height: 1.7; }
.w1st { color: var(--accent); }
