:root {
  --primary: #1976d2;
  --primary-dark: #1565c0;
  --primary-light: #bbdefb;
  --bg: #f5f5f5;
  --surface: #ffffff;
  --ink: #212121;
  --body: #333333;
  --muted: #616161;
  --disabled: #9e9e9e;
  --line: #e0e0e0;
  --warn: #d32f2f;
  --ok: #388e3c;
  --shadow: 0 1px 3px rgba(0,0,0,.12), 0 1px 2px rgba(0,0,0,.08);
  --radius: 12px;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 7rem; }
html, body { margin: 0; padding: 0; }
body {
  font-family: Roboto, "Noto Sans TC", "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
a { color: var(--primary); text-underline-offset: 3px; }
a:hover { color: var(--primary-dark); }

.appbar {
  position: sticky;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 6vw;
  height: 56px;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--shadow);
  z-index: 30;
}
.appbar .mark {
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.92rem;
}
.appbar nav { display: flex; gap: 1.1rem; font-size: 0.9rem; }
.appbar nav a { color: #e3f2fd; text-decoration: none; }
.appbar nav a:hover,
.appbar nav a.on { color: #fff; }

main { flex: 1; padding: 1.2rem 6vw 4rem; max-width: 920px; width: 100%; margin: 0 auto; view-transition-name: ht-main; }
body.page-race { overscroll-behavior-x: contain; }
.crumb { font-size: 0.82rem; color: var(--muted); }
.kicker {
  letter-spacing: 0.14em;
  font-size: 0.72rem;
  color: var(--primary-light);
  margin: 0 0 0.4rem;
}

.hero {
  display: block;
  text-decoration: none;
  color: #fff;
  background: var(--primary);
  padding: 1.7rem 1.4rem 1.5rem;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.2rem;
}
.hero h1 { margin: 0 0 0.45rem; font-size: 1.6rem; line-height: 1.3; color: #fff; }
.hero p { margin: 0; color: #e3f2fd; }
.hero-meta { margin-top: 0.65rem !important; font-size: 0.82rem; color: var(--primary-light) !important; }
.hero.idle { background: #455a64; }

.panel, .card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.05rem 1.1rem 1rem;
  margin: 0 0 1rem;
}
.panel h2, .card h2 {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--primary);
  letter-spacing: 0.04em;
}
.panel h2::before, .card h2::before {
  content: "";
  display: inline-block;
  width: 0.35rem;
  height: 0.9rem;
  background: var(--primary);
  border-radius: 2px;
  margin-right: 0.45rem;
  vertical-align: -0.1rem;
}

.race-nav {
  position: sticky;
  top: 56px;
  z-index: 20;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  padding: 0.5rem 6vw;
}
.chips {
  display: flex;
  gap: 0.45rem;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips a {
  flex: 0 0 auto;
  text-decoration: none;
  background: var(--bg);
  color: var(--muted);
  padding: 0.38rem 0.8rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 10px;
  white-space: nowrap;
}
.chip-race {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.05rem;
  min-width: 4.6rem;
  padding: 0.35rem 0.7rem !important;
  line-height: 1.15;
}
.chip-race span {
  font-size: 0.68rem;
  font-weight: 500;
  color: inherit;
  opacity: 0.78;
}
.chips a.on { background: var(--primary); color: #fff; }
.chips a:hover { color: var(--primary-dark); }
.chips a.on:hover { color: #fff; }

.index { list-style: none; padding: 0; margin: 0; }
.index li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 0;
  border-bottom: 1px solid var(--line);
}
.index span { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.empty, .empty-verdict { color: var(--muted); }

.lede { color: var(--muted); margin: 0; }

.focus-row, .badge-list {
  --badge-gap: 0.4rem;
  display: flex;
  gap: var(--badge-gap);
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 0.15rem;
  scrollbar-width: none;
}
.focus-row::-webkit-scrollbar, .badge-list::-webkit-scrollbar { display: none; }
.focus-row { --badge-show: 3.3; }
.badge-list { --badge-show: 2.7; }
.badge-card {
  flex: 0 0 calc((100% - (var(--badge-show) - 1) * var(--badge-gap)) / var(--badge-show));
  min-width: 0;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.42rem 0.5rem;
  background: #fafafa;
}
.badge-value {
  padding: 0.55rem 0.62rem;
  border-radius: 10px;
}
.badge-card.is-focus,
.badge-card:target {
  border-color: var(--primary);
  background: #e3f2fd;
  box-shadow: 0 0 0 2px var(--primary-light);
}
.badge-head {
  display: flex;
  align-items: baseline;
  gap: 0.28rem;
  min-width: 0;
}
.badge-head .badge-no {
  display: inline;
  font-size: 0.92rem;
  line-height: 1.1;
  flex: 0 0 auto;
}
.badge-value .badge-no { font-size: 1.05rem; }
.badge-head .badge-name {
  margin: 0;
  font-size: 0.84rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.badge-value .badge-name { font-size: 0.95rem; }
.badge-card .badge-meta {
  display: flex;
  gap: 0.35rem;
  margin-top: 0.18rem;
  font-size: 0.66rem;
  white-space: nowrap;
}
.badge-value .badge-meta { font-size: 0.75rem; }
.focus-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.85rem 0 0;
}
.focus-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.2rem;
  height: 2.2rem;
  padding: 0 0.35rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--primary);
  text-decoration: none;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
}
.focus-chip.on,
.focus-chip:hover,
.focus-chip:focus-visible {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}
.badge-no { color: var(--primary); font-weight: 700; }
.badge-name { font-weight: 700; }
.badge-meta { color: var(--muted); }

.race-list {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
}
.nav-row {
  border: 0;
  border-radius: 0;
  border-bottom: 1px solid var(--line);
  background: #fff;
  overflow: hidden;
}
.nav-row:last-child { border-bottom: 0; }
a.nav-row {
  text-decoration: none;
  color: inherit;
  padding: 0.72rem 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.7rem;
}
a.nav-row:hover,
.nav-row summary:hover {
  background: #f7fbff;
}
.nav-row[open] { background: #f7fbff; }
a.nav-row.live-row { background: #e3f2fd; }
a.nav-row.live-row:hover { background: #d2e9fb; }
.nav-row summary {
  list-style: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.72rem 0.85rem;
}
.nav-row summary::-webkit-details-marker { display: none; }
.nav-no {
  flex: 0 0 auto;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.78rem;
}
.live-row .nav-no { background: var(--primary-dark); letter-spacing: 0.02em; }
.nav-copy {
  flex: 1;
  min-width: 0;
}
.nav-copy strong,
.nav-copy span {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.nav-copy strong {
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 700;
  line-height: 1.25;
}
.nav-copy span {
  font-size: 0.75rem;
  color: var(--muted);
  margin-top: 0.08rem;
}
.nav-chev,
.nav-go {
  flex: 0 0 auto;
  color: var(--muted);
}
.nav-go { font-size: 1rem; font-weight: 600; color: var(--primary); }
.nav-chev {
  width: 0.48rem;
  height: 0.48rem;
  border-right: 2px solid var(--muted);
  border-bottom: 2px solid var(--muted);
  transform: rotate(45deg);
  transition: transform 0.16s ease, border-color 0.16s ease;
  margin: -0.18rem 0.2rem 0 0;
}
.nav-row[open] .nav-chev {
  width: auto;
  height: auto;
  border: 0;
  transform: none;
  margin: 0 0.05rem 0 0;
  color: var(--primary);
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1;
}
.nav-row[open] .nav-chev::before {
  content: "→";
}
.early-preview {
  border-top: 1px solid var(--line);
  padding: 0.65rem 0.85rem 0.8rem 3.4rem;
  background: #fff;
}
.early-preview p {
  margin: 0;
  color: var(--body);
  font-size: 0.88rem;
  line-height: 1.5;
}
.nav-facts {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
}
.nav-facts li {
  display: grid;
  grid-template-columns: 1.35rem minmax(0, 1fr);
  column-gap: 0.5rem;
  align-items: start;
}
.fact-no {
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  background: var(--primary-light);
  color: var(--primary-dark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.72rem;
  font-weight: 700;
  margin-top: 0.08rem;
}
.fact-copy {
  min-width: 0;
  font-size: 0.88rem;
  color: var(--body);
  line-height: 1.5;
}
.fact-copy strong {
  font-weight: 700;
  color: var(--ink);
}

.race-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(7.2rem, 1fr));
  gap: 0.6rem;
}
.race-grid a {
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0.75rem 0.7rem;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}
.race-grid a:hover { border-color: var(--primary); }
.race-grid strong { color: var(--primary); }
.race-grid span { font-size: 0.75rem; color: var(--muted); }
.race-grid .live-tile { background: #e3f2fd; }

.card.late { border: 2px solid var(--ok); }
.card.locked { color: var(--muted); }
.card.early .verdict { color: var(--body); }
.card.early .verdict p { margin: 0.35rem 0; line-height: 1.65; }
.card.early .verdict p:first-child { margin-top: 0; }
.card.early .verdict p:last-child { margin-bottom: 0; }
.race-info h1 { margin: 0 0 0.35rem; font-size: 1.25rem; }
.race-info p { margin: 0; color: var(--muted); }

.note-scratch { color: var(--warn); font-weight: 700; margin: 0 0 0.6rem; }
.badge-out { color: var(--warn); font-weight: 700; margin-left: 0.3rem; }
mark.close-pick, mark.close-drag, mark.close-power, mark.close-edge {
  background: none;
  padding: 0;
  font-weight: 700;
  color: var(--ink);
}

.runners { list-style: none; padding: 0; margin: 0; }
.runner {
  display: grid;
  grid-template-columns: 2.1rem minmax(0, 1fr);
  column-gap: 0.65rem;
  row-gap: 0.12rem;
  padding: 0.65rem 0.1rem;
  border-top: 1px solid var(--line);
  align-items: start;
}
.num {
  grid-column: 1;
  grid-row: 1 / -1;
  align-self: start;
  margin-top: 0.12rem;
  width: 1.85rem;
  height: 1.85rem;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
}
.r1, .r2, .r3, .r4, .r5 { grid-column: 2; min-width: 0; }
.r1 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.3;
}
.r1, .r1 * { white-space: nowrap; }
.horse { font-weight: 700; }
.jt { font-size: 0.82rem; color: var(--muted); }
.jt b { font-weight: 600; color: var(--ink); }
.r2 {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  gap: 0.55rem 0.85rem;
  font-variant-numeric: tabular-nums;
  font-size: 0.84rem;
  white-space: nowrap;
}
.draw {
  display: inline-flex;
  align-items: center;
  font-weight: 700;
  border-radius: 4px;
  padding: 0.05rem 0.32rem;
  background: #f5f5f5;
}
.draw-in { background: #e8f5e9; color: #2e7d32; }
.draw-out { background: #ffebee; color: #c62828; }
.wt { font-weight: 600; }
.cd { font-size: 0.84rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.r3 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem 0.7rem;
}
.form { display: flex; gap: 0.18rem; flex-wrap: nowrap; flex: 0 0 auto; }
.form i {
  display: inline-flex;
  min-width: 1.2rem;
  height: 1.2rem;
  padding: 0 0.15rem;
  align-items: center;
  justify-content: center;
  font-style: normal;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 3px;
  color: #fff;
  background: var(--muted);
  font-variant-numeric: tabular-nums;
}
.form-1 { background: #f9a825; }
.form-2 { background: #90a4ae; }
.form-3 { background: #ef6c00; }
.form-mid { background: #bdbdbd; color: #424242; }
.form-deep { background: #616161; }
.form-empty { color: var(--muted); font-size: 0.8rem; }
.cond { font-size: 0.84rem; font-weight: 700; font-variant-numeric: tabular-nums; }
.cond-ap, .cond-a { color: #2e7d32; }
.cond-am { color: #43a047; }
.cond-bp, .cond-b, .cond-bm { color: #ef6c00; }
.cond-b { font-weight: 600; }
.cond-cp { color: #e53935; }
.cond-c, .cond-cm { color: #c62828; }
.r4 {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.28rem;
  padding-top: 0.08rem;
}
.flag {
  appearance: none;
  border: 0;
  background: #f5f5f5;
  border-radius: 999px;
  padding: 0.08rem 0.42rem;
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1.25;
}
.flag[aria-expanded="true"] { background: #e3f2fd; }
.r5 {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
  line-height: 1.45;
}
.inj { display: inline; margin-left: 0.15rem; }
.inj summary {
  display: inline;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 700;
  list-style: none;
}
.inj summary::-webkit-details-marker { display: none; }
.inj-mild, .flag.inj-mild { color: #ef6c00; }
.inj-bone, .flag.inj-bone { color: #e65100; }
.inj-soft, .flag.inj-soft { color: #c62828; }
.inj span { display: inline; margin-left: 0.15rem; font-size: 0.72rem; color: var(--muted); font-weight: 400; }

.runner.out {
  background: #e0e0e0;
  opacity: 0.5;
}
.runner.out .num { background: var(--disabled); }
.runner.out .horse { text-decoration: line-through; }

.changed-blue { color: var(--primary) !important; }

.feed-head { display: flex; justify-content: space-between; gap: 1rem; align-items: center; flex-wrap: wrap; }
.feed-head h1 { margin: 0; font-size: 1.25rem; }
.btn {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  padding: 0.45rem 0.9rem;
  border-radius: 99px;
  font-size: 0.85rem;
  font-weight: 600;
}
.btn:hover { background: var(--primary-dark); color: #fff; }
.timeline { list-style: none; padding: 0; margin: 0.8rem 0 0; }
.timeline li { border-bottom: 1px solid var(--line); }
.timeline a {
  display: block;
  padding: 0.85rem 0.1rem;
  text-decoration: none;
  color: var(--ink);
}
.timeline time { display: block; color: var(--primary); font-size: 0.78rem; margin-bottom: 0.2rem; }

footer {
  padding: 1.1rem 6vw 1.4rem;
  color: var(--muted);
  font-size: 0.78rem;
}

.toast {
  position: fixed;
  top: 7.2rem;
  right: 1rem;
  max-width: 22rem;
  background: #212121;
  color: #fff;
  padding: 0.95rem 1rem;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0,0,0,.28);
  z-index: 50;
  opacity: 0;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.toast.show { opacity: 1; transform: none; }
.toast-kicker { margin: 0 0 0.3rem; font-weight: 700; }
.toast-body { margin: 0 0 0.7rem; color: #eeeeee; font-size: 0.9rem; }
.toast-go {
  display: inline-block;
  background: var(--primary);
  color: #fff;
  text-decoration: none;
  padding: 0.32rem 0.75rem;
  border-radius: 99px;
  font-size: 0.8rem;
  font-weight: 600;
}

.kicker.ink { color: var(--primary); letter-spacing: 0.12em; margin-bottom: 0.35rem; }

.shikma-article { padding: 1.4rem 1.25rem 1.6rem; }
.shikma-article h1 { margin: 0 0 1rem; font-size: 1.55rem; line-height: 1.3; }
.shikma-article h2 {
  margin: 1.7rem 0 0.7rem;
  font-size: 1.12rem;
  color: var(--primary-dark);
  line-height: 1.4;
}
.shikma-article h3 {
  margin: 1.25rem 0 0.45rem;
  font-size: 1rem;
  color: var(--ink);
}
.shikma-article p { margin: 0.45rem 0; color: var(--body); }
.shikma-article p.lede {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.7;
  margin: 0 0 1.1rem;
}
.shikma-article ul { margin: 0.4rem 0 0.8rem; padding-left: 1.2rem; }
.shikma-article li { margin: 0.25rem 0; }
.shikma-article .table-wrap { overflow-x: auto; margin: 0.7rem 0 1rem; }
.shikma-article table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.shikma-article th,
.shikma-article td {
  border-bottom: 1px solid var(--line);
  padding: 0.42rem 0.5rem;
  text-align: left;
  vertical-align: top;
}
.shikma-article th { color: var(--muted); font-weight: 600; background: #fafafa; }
.shikma-article .formula {
  overflow-x: auto;
  background: #f7fbff;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.7rem 0.8rem;
  font-size: 0.86rem;
  line-height: 1.55;
  white-space: pre-wrap;
}
.shikma-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 1.1rem;
  font-size: 0.88rem;
}
.shikma-pager a { text-decoration: none; }

.term-list { margin: 0.4rem 0 0; }
.term-list > div {
  display: grid;
  grid-template-columns: 5.5rem 1fr;
  gap: 0.55rem 1rem;
  padding: 0.7rem 0;
  border-bottom: 1px solid var(--line);
}
.term-list dt { font-weight: 700; color: var(--primary-dark); }
.term-list dd { margin: 0; color: var(--body); }

@media (max-width: 720px) {
  .term-list > div { grid-template-columns: 1fr; gap: 0.2rem; }
}

.pick-yes,
.pick-no {
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border-left: 3px solid var(--ok);
  background: #f1f8f2;
}
.pick-no {
  border-left-color: var(--warn);
  background: #fdf3f3;
}

.appbar nav { gap: 0.85rem; }

@media (min-width: 760px) {
  .runner { padding: 0.5rem 0.1rem; }
}

@media (max-width: 720px) {
  main, .appbar, .race-nav, footer { padding-left: 1rem; padding-right: 1rem; }
  .hero h1, .race-info h1 { font-size: 1.28rem; }
  .toast { left: 1rem; right: 1rem; max-width: none; }
  .early-preview { padding-left: 0.85rem; }
}

html { view-transition-name: none; }
::view-transition-old(ht-main),
::view-transition-new(ht-main) {
  animation-duration: 0.22s;
}
