:root {
  --bg: #0c1210;
  --bg-elev: #161d19;
  --bg-chip: #1e2823;
  --line: #2a3831;
  --text: #edf3ee;
  --muted: #9aab9f;
  --gold: #d4a017;
  --gold-dim: #8a6a12;
  --go: #3dcc8a;
  --go-bg: #143528;
  --amber: #e6b325;
  --amber-bg: #3a2f0d;
  --stop: #e85d5d;
  --stop-bg: #3a1518;
  --blue: #7eb0ff;
  --radius: 16px;
  --pad: 16px;
  --max: 520px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --sticky-offset: calc(var(--safe-top) + 148px);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; background: var(--bg); color: var(--text); }
html {
  scroll-padding-top: var(--sticky-offset);
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  line-height: 1.45;
  max-width: var(--max);
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  min-height: -webkit-fill-available;
  padding-left: var(--safe-left);
  padding-right: var(--safe-right);
  overscroll-behavior-y: contain;
  -webkit-tap-highlight-color: transparent;
}
h1, h2, h3 { margin: 0; font-weight: 650; }
h1 { font-size: 1.05rem; letter-spacing: 0.02em; }
h2 { font-size: 0.95rem; margin-bottom: 6px; }
h3 { font-size: 0.85rem; margin: 10px 0 4px; color: var(--text); }
button, textarea, select, input { font: inherit; }
/* Android Chrome：输入框小于 16px 会在聚焦时强制放大页面 */
textarea, input, select {
  font-size: 16px;
  max-width: 100%;
}
.sticky-shell {
  position: sticky;
  top: 0;
  z-index: 40;
  padding-top: var(--safe-top);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}
.topbar {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 10px var(--pad) 8px;
  background: transparent;
}
.brand { display: flex; gap: 10px; align-items: center; }
.mark {
  width: 36px; height: 36px; border-radius: 10px;
  background: linear-gradient(145deg, #f0c14b, #8a5a00);
  color: #1a1404; font-weight: 800; display: grid; place-items: center;
  letter-spacing: -0.04em;
}
.tagline, .meta, .hint, footer { color: var(--muted); font-size: 0.75rem; }
.tagline { line-height: 1.35; }
.meta { text-align: right; flex: 0 0 auto; white-space: nowrap; }
.sample-badge, .live-badge {
  display: inline-block; margin-top: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 650;
}
.sample-badge { background: #3a2f0d; color: #f0c14b; }
.live-badge { background: #143528; color: var(--go); }
.budget-bar { padding: 0 var(--pad) 10px; }
.budget-main {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
  font-size: 0.8rem;
}
.budget-race { font-weight: 750; color: var(--gold); }
.budget-label { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.budget-input-wrap {
  display: inline-flex; align-items: center; gap: 0;
  color: var(--text); font-weight: 650;
}
.budget-input-wrap input {
  width: 4.8em;
  background: #0e1512; color: var(--text);
  border: 1px solid var(--line); border-radius: 8px;
  padding: 6px 8px; min-height: 40px; margin-left: 2px;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}
.budget-progress { font-variant-numeric: tabular-nums; font-weight: 700; }
.budget-progress.tight { color: var(--amber); }
.budget-progress.empty { color: var(--muted); font-weight: 650; }
.budget-jumps { display: flex; gap: 8px; margin-top: 8px; }
.budget-jumps .btn { flex: 1; min-height: 44px; font-size: 0.8rem; }
#suggestions-card, #odds-card { scroll-margin-top: var(--sticky-offset); }
main { padding: 12px var(--pad) calc(24px + var(--safe-bottom)); }
.disclaimer, .install-card, .storage-note {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-left: 3px solid var(--gold); border-radius: 12px;
  padding: 10px 12px; font-size: 0.8rem; color: #d5ddd7; margin-bottom: 12px;
}
.install-card { border-left-color: var(--blue); }
.install-card h2 { font-size: 0.92rem; margin-bottom: 6px; color: var(--text); }
.install-card h3 { font-size: 0.82rem; margin: 12px 0 2px; color: var(--blue); }
.install-card ol { margin: 6px 0 0; padding-left: 1.2em; }
.install-card li { margin: 4px 0; }
.install-card.hidden { display: none; }
.install-card .row-actions { margin-top: 10px; }
.install-actions { margin: 10px 0 4px; }
.install-actions .btn { width: 100%; min-height: 48px; font-size: 0.95rem; }
.install-actions .btn[hidden] { display: none !important; }
.install-platform { margin-top: 4px; }
.storage-note { border-left-color: var(--muted); }
.race-tabs {
  display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 12px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch;
}
.race-tabs::-webkit-scrollbar { display: none; }
.race-tabs button {
  flex: 0 0 auto; border: 1px solid var(--line); background: var(--bg-chip);
  color: var(--text); border-radius: 999px; padding: 8px 12px; min-width: 52px;
}
.race-tabs button.active { background: var(--gold); color: #1a1404; border-color: var(--gold); font-weight: 700; }
.race-head { margin-bottom: 12px; }
.race-head h2 { font-size: 1.15rem; }
.card {
  background: var(--bg-elev); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 14px; margin-bottom: 12px;
}
.section-head { margin-bottom: 8px; }
.section-head .hint { margin: 0 0 8px; }
.mode-switch { display: flex; gap: 8px; margin: 8px 0 4px; }
.mode-switch .btn { flex: 1; min-height: 40px; font-size: 0.8rem; }
.mode-switch .btn[aria-pressed="true"] {
  background: var(--gold); color: #1a1404; border-color: var(--gold); font-weight: 700;
}
.verdict {
  border-radius: var(--radius); padding: 16px; margin-bottom: 12px;
  border: 1px solid var(--line);
}
.verdict.bet { background: var(--go-bg); border-color: #2a7a54; }
.verdict.probe { background: var(--amber-bg); border-color: #8a6a12; }
.verdict.abandon { background: var(--stop-bg); border-color: #8a3232; }
.verdict .kicker { font-size: 0.72rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.verdict .title { font-size: 1.2rem; font-weight: 750; margin-bottom: 8px; }
.verdict .reason { font-size: 0.86rem; color: #e8eee9; }
.banner { word-break: keep-all;
  background: #2a2410; border: 1px solid #6a5420; color: #f6e2a2;
  border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 0.88rem;
}
.horse-row {
  border-top: 1px solid var(--line); padding: 12px 0;
}
.horse-row:first-child { border-top: 0; }
.horse-top { display: flex; justify-content: space-between; gap: 8px; align-items: flex-start; }
.horse-id { font-weight: 750; font-size: 1.05rem; }
.horse-id .no { color: var(--gold); margin-right: 6px; }
.muted { color: var(--muted); font-size: 0.75rem; }
.pills { display: flex; flex-wrap: wrap; gap: 4px; margin: 6px 0; }
.pill {
  font-size: 0.68rem; padding: 2px 7px; border-radius: 999px;
  background: var(--bg-chip); border: 1px solid var(--line); color: #d5ddd7;
}
.pill.top4 { background: #1c3a2c; border-color: #2a7a54; color: var(--go); }
.pill.reserve { background: #2a2410; border-color: #8a6a12; color: var(--amber); }
.pill.replaced { background: var(--stop-bg); border-color: #8a3232; color: var(--stop); }
.pill.hard { background: #2a2410; border-color: #8a6a12; color: var(--amber); }
.pill.move-down { background: #143528; border-color: #2a7a54; color: var(--go); }
.pill.move-up { background: var(--stop-bg); border-color: #8a3232; color: var(--stop); }
.pill.ticket { background: #1c3a2c; border-color: #2a7a54; color: var(--go); }
.pill.skipped { background: var(--bg-chip); border-color: var(--line); color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; font-size: 0.75rem; margin: 6px 0 8px; }
.stats b { display: block; color: var(--muted); font-weight: 500; font-size: 0.68rem; }
.score-pad { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.score-pad button, .stepper button, .btn {
  border-radius: 10px; border: 1px solid var(--line); background: var(--bg-chip); color: var(--text);
  padding: 8px 0; min-height: 40px;
}
.score-pad button.active { background: var(--gold); color: #1a1404; border-color: var(--gold); font-weight: 700; }
.score-pad button.warn { outline: 1px solid var(--stop); }
.row-actions { display: flex; gap: 8px; margin-top: 8px; }
.row-actions .btn { flex: 1; font-size: 0.8rem; }
.btn.primary { background: var(--gold); color: #1a1404; border-color: var(--gold); font-weight: 700; }
.btn.danger { background: var(--stop-bg); color: #ffd4d4; border-color: #8a3232; }
.btn.active-danger { background: var(--stop); color: #1a0404; border-color: var(--stop); }
.btn[disabled] { opacity: 0.55; }
.focus-list, .reserve-choices { display: flex; flex-direction: column; gap: 8px; }
.focus-item, .reserve-choice {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--bg-chip); border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px;
}
.reserve-choice.selected { border-color: var(--gold); box-shadow: inset 0 0 0 1px var(--gold); }
.reserve-choice button { min-width: 72px; }
.suggestion {
  border-top: 1px solid var(--line); padding: 12px 0;
}
.suggestion:first-child { border-top: 0; }
.suggestion .line1 { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; font-weight: 650; word-break: keep-all; }
.suggestion .line1 span:first-child { flex: 1; min-width: 0; }
.suggestion .ev { font-variant-numeric: tabular-nums; }
.suggestion .ev.bet { color: var(--go); }
.suggestion .ev.probe { color: var(--amber); }
.suggestion .ev.abandon { color: var(--stop); }
.suggestion .meta-line { font-size: 0.8rem; color: #d5ddd7; margin: 4px 0; }
.suggestion.in-ticket { }
.ticket-summary {
  background: var(--bg-chip); border: 1px solid var(--gold-dim);
  border-radius: 12px; padding: 10px 12px; margin-bottom: 12px;
}
.ticket-summary h3 { font-size: 0.88rem; margin-bottom: 6px; }
.ticket-summary ol { margin: 6px 0; padding-left: 1.2em; font-size: 0.85rem; }
.ticket-summary li { margin: 3px 0; }
.ticket-summary .total { font-weight: 700; margin-top: 6px; }
.ticket-summary .downgrade { color: var(--amber); font-size: 0.78rem; }
.wp-hint {
  background: #162028; border: 1px solid #3a5070; color: #d5e4f6;
  border-radius: 12px; padding: 10px 12px; margin-bottom: 10px; font-size: 0.82rem;
}
.ev-fold {
  margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 8px;
}
.ev-fold summary {
  cursor: pointer; color: var(--muted); font-size: 0.82rem;
  list-style: none; min-height: 40px; display: flex; align-items: center;
}
.ev-fold summary::-webkit-details-marker { display: none; }
.ev-fold summary::after { content: " ▾"; }
.ev-fold[open] summary::after { content: " ▴"; }
.horse-row.compact { padding: 8px 0; cursor: pointer; }
.horse-compact-line {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 8px;
}
.horse-compact-line .horse-id { font-size: 0.95rem; }
.horse-compact-meta { text-align: right; font-size: 0.72rem; color: var(--muted); flex: 0 0 auto; }
.horse-row.compact .horse-details { display: none; }
.horse-row.is-open .horse-details { display: block; }
.horse-row.is-open { cursor: default; }
.snapshot { font-size: 0.8rem; padding: 8px 0; border-top: 1px solid var(--line); }
.snapshot:first-child { border-top: 0; }
.snapshot.current { border-left: 3px solid var(--go); padding-left: 8px; }
.snapshot.previous { border-left: 3px solid var(--amber); padding-left: 8px; }
.paste-form { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
textarea {
  width: 100%; background: #0e1512; color: var(--text);
  border: 1px solid var(--line); border-radius: 12px; padding: 10px;
  resize: vertical;
  font-size: 16px;
  line-height: 1.4;
  min-height: 120px;
}
.history-item { font-size: 0.82rem; padding: 8px 0; border-top: 1px solid var(--line); }
.history-item:first-child { border-top: 0; }
.empty { color: var(--muted); font-size: 0.85rem; padding: 8px 0; }
footer { text-align: center; padding: 8px 16px calc(20px + var(--safe-bottom)); }
.loading { color: var(--muted); padding: 24px; text-align: center; }
.offline-pill {
  display: none; margin-top: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 0.7rem; font-weight: 650; background: var(--bg-chip); color: var(--muted); border: 1px solid var(--line);
}
body.offline .offline-pill { display: inline-block; }

.data-warning {
  background: var(--stop-bg);
  border: 1px solid #8a3232;
  color: #ffd6d6;
  border-radius: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.4;
}
.data-warning[hidden] { display: none; }
.runners-card details > summary {
  cursor: pointer;
  font-weight: 700;
  font-size: 0.95rem;
  list-style: none;
  min-height: 44px;
  display: flex;
  align-items: center;
}
.runners-card details > summary::-webkit-details-marker { display: none; }
.runners-card details > summary::after { content: " ▾"; color: var(--muted); }
.runners-card details[open] > summary::after { content: " ▴"; }
.form-errors {
  background: var(--stop-bg);
  border: 1px solid #8a3232;
  color: #ffd6d6;
  border-radius: 10px;
  padding: 8px 10px;
  margin-top: 8px;
  font-size: 0.8rem;
}
.form-errors[hidden] { display: none; }
.runner-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  border-top: 1px solid var(--line);
  padding: 8px 0;
  font-size: 0.88rem;
}
.runner-row:first-child { border-top: 0; }
.runner-row.scratched { opacity: 0.72; }
.runner-row.scratched .runner-name { text-decoration: line-through; color: var(--muted); }
.pill.scratched { background: var(--stop-bg); border-color: #8a3232; color: var(--stop); }
.scratched-block { margin-top: 10px; }
.scratched-block h3 { font-size: 0.82rem; color: var(--muted); margin-bottom: 4px; }
.result-row { display: flex; gap: 8px; }
.result-row input {
  flex: 1;
  background: #0e1512;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  min-height: 44px;
  font-size: 16px;
}
.official-box {
  background: var(--bg-chip);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  margin: 8px 0;
  font-size: 0.85rem;
}
.history-odds { font-variant-numeric: tabular-nums; }

/* Android Chrome 地址栏伸缩时，粘性顶栏与滚动锚点更稳 */
@supports (height: 100dvh) {
  body { min-height: 100dvh; }
}
@media (max-width: 520px) {
  .topbar { padding-left: max(var(--pad), var(--safe-left)); padding-right: max(var(--pad), var(--safe-right)); }
  .budget-bar { padding-left: max(var(--pad), var(--safe-left)); padding-right: max(var(--pad), var(--safe-right)); }
  main { padding-left: max(var(--pad), var(--safe-left)); padding-right: max(var(--pad), var(--safe-right)); }
}
@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .install-card { display: none !important; }
}
