/* CHINEN EYE - styles */
:root {
  --ink: #17231d;
  --ink-2: #2a3630;
  --muted: #6f7a73;
  --muted-2: #8c958f;
  --turf: #0c4a33;
  --turf-2: #146344;
  --turf-3: #2a8b62;
  --lime: #d7e8a3;
  --lime-2: #e9f2c8;
  --gold: #b9964f;
  --gold-2: #e4d3a8;
  --cream: #f3efe3;
  --paper: #fffdf7;
  --paper-2: #faf6eb;
  --line: #ded7c6;
  --line-2: #ebe6d8;
  --red: #b22d2a;
  --red-2: #f5e3e1;
  --blue: #2f5f8f;
  --green-soft: #e8f0e2;
  --shadow: 0 18px 44px rgba(23, 35, 29, .09);
  --shadow-sm: 0 6px 18px rgba(23, 35, 29, .06);
  --radius: 18px;
  --font-body: "Zen Kaku Gothic New", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
  --font-display: "Shippori Mincho", "Yu Mincho", serif;
  --font-num: "Bebas Neue", "Oswald", sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(1200px 500px at 85% -10%, rgba(215, 232, 163, .28), transparent 60%),
    radial-gradient(900px 450px at -10% 20%, rgba(42, 139, 98, .08), transparent 55%),
    var(--cream);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}
body.modal-open { overflow: hidden; }
a { color: var(--turf-2); }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
h1, h2, h3, p { margin: 0; }
h1, h2, h3 { font-family: var(--font-display); font-weight: 600; line-height: 1.35; letter-spacing: .01em; }
em { font-style: normal; }
[hidden] { display: none !important; }

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 60;
  height: 68px; display: flex; align-items: center; gap: 22px;
  padding: 0 clamp(16px, 4vw, 46px);
  color: var(--paper);
  background: rgba(9, 40, 27, .97);
  border-bottom: 1px solid rgba(215, 232, 163, .18);
  backdrop-filter: blur(14px);
}
.brand { display: flex; align-items: center; gap: 10px; color: var(--lime); text-decoration: none; flex: 0 0 auto; }
.brand-mark { width: 36px; height: 36px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.05; }
.brand-text b { font-family: var(--font-num); font-size: 22px; letter-spacing: .16em; font-weight: 400; }
.brand-text small { font-size: 9px; letter-spacing: .28em; color: rgba(244, 240, 229, .62); margin-top: 4px; }
.main-nav { display: flex; gap: 6px; margin-left: 12px; }
.nav-btn {
  border: 0; background: transparent; color: rgba(244, 240, 229, .62);
  padding: 8px 14px; border-radius: 999px; font-size: 13px; letter-spacing: .08em;
  transition: .2s;
}
.nav-btn:hover { color: var(--paper); background: rgba(255, 255, 255, .06); }
.nav-btn.active { color: var(--turf); background: var(--lime); font-weight: 700; }
.api-status {
  margin-left: auto; display: flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: .12em; color: rgba(244, 240, 229, .65);
  border: 1px solid rgba(215, 232, 163, .22); padding: 6px 11px; border-radius: 999px;
}
.api-status .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 0 3px rgba(215, 232, 163, .15); }
.api-status.offline .dot { background: #d98d83; box-shadow: none; }

/* ---------- hero ---------- */
.hero {
  position: relative; overflow: hidden;
  background:
    radial-gradient(700px 300px at 82% 18%, rgba(42, 139, 98, .5), transparent 65%),
    radial-gradient(500px 240px at 10% 100%, rgba(215, 232, 163, .12), transparent 70%),
    linear-gradient(140deg, #082d1e 0%, #0c4a33 58%, #0b3d2b 100%);
  color: var(--paper);
  padding: 76px 0 126px;
}
.hero::before {
  content: "CHINEN"; position: absolute; right: -28px; top: -38px;
  font-family: var(--font-num); font-size: 300px; line-height: 1; letter-spacing: .02em;
  color: transparent; -webkit-text-stroke: 1px rgba(215, 232, 163, .11); pointer-events: none;
}
.hero::after {
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background-image: linear-gradient(rgba(215, 232, 163, .035) 1px, transparent 1px), linear-gradient(90deg, rgba(215, 232, 163, .035) 1px, transparent 1px);
  background-size: 64px 64px;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.8), transparent 85%);
}
.hero-grid {
  position: relative; z-index: 2; max-width: 1240px; margin: 0 auto;
  padding: 0 clamp(20px, 4vw, 40px);
  display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(300px, .7fr); gap: 44px; align-items: center;
}
.eyebrow, .section-kicker {
  font-size: 10px; letter-spacing: .26em; font-weight: 700; color: var(--gold);
  margin-bottom: 12px;
}
.hero .eyebrow { color: var(--lime); }
.hero h1 {
  font-size: clamp(36px, 4.2vw, 58px); font-weight: 600; line-height: 1.28;
  letter-spacing: .015em; margin-bottom: 22px;
}
.hero h1 em { color: var(--lime); white-space: nowrap; }
.hero .lead {
  max-width: 570px; font-size: 15px; line-height: 2; color: rgba(244, 240, 229, .72);
}
.hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.hero-tags span {
  font-size: 11px; letter-spacing: .08em; padding: 6px 11px; border-radius: 999px;
  border: 1px solid rgba(215, 232, 163, .28); color: rgba(244, 240, 229, .82);
}
.hero-visual { position: relative; min-height: 290px; }
.track-art { width: 100%; height: auto; filter: drop-shadow(0 18px 30px rgba(0,0,0,.18)); }
.hero-weather {
  position: absolute; right: 0; bottom: -4px; width: min(260px, 88%);
  padding: 14px 16px; border-radius: 14px;
  background: rgba(7, 32, 22, .62); border: 1px solid rgba(215, 232, 163, .22);
  backdrop-filter: blur(10px);
  display: flex; flex-direction: column; gap: 2px;
}
.hw-label { font-size: 9px; letter-spacing: .22em; color: var(--lime); }
.hero-weather strong { font-family: var(--font-display); font-size: 17px; font-weight: 500; }
.hero-weather span:last-child { font-size: 11px; color: rgba(244, 240, 229, .65); line-height: 1.5; }

/* ---------- layout ---------- */
main { min-height: 60vh; }
.card {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.setup {
  position: relative; z-index: 5; max-width: 1184px; margin: -76px auto 0;
  padding: clamp(20px, 3vw, 34px);
}
#card-section, .results, #history-view, #about-view { max-width: 1184px; margin: 24px auto 0; }
#card-section { padding: clamp(20px, 3vw, 30px); }
.card-head { display: flex; justify-content: space-between; align-items: flex-end; gap: 18px; margin-bottom: 22px; }
.card-head h2 { font-size: clamp(20px, 2.2vw, 26px); }
.head-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- form ---------- */
.form-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); grid-auto-flow: dense; gap: 14px 14px; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field > span { font-size: 11px; font-weight: 700; letter-spacing: .06em; color: var(--muted); }
.field input, .field select {
  height: 44px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px;
  background: #fffef9; color: var(--ink); min-width: 0; transition: .18s;
}
.field select { padding-right: 30px; }
.field input:focus, .field select:focus, textarea:focus {
  outline: none; border-color: var(--turf-3); box-shadow: 0 0 0 3px rgba(42, 139, 98, .12);
}
.field input:hover, .field select:hover { border-color: #c9c0ab; }
.field.wide { grid-column: span 2; }
.form-foot { display: flex; justify-content: space-between; align-items: center; gap: 20px; margin-top: 18px; flex-wrap: wrap; }
.form-note { font-size: 11px; color: var(--muted); }
.switch { display: inline-flex; align-items: center; gap: 9px; font-size: 12px; color: var(--ink-2); cursor: pointer; user-select: none; }
.switch input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch-track { width: 36px; height: 21px; border-radius: 999px; background: #d8d2c3; position: relative; transition: .2s; flex: 0 0 auto; }
.switch-track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 15px; height: 15px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.2); transition: .2s; }
.switch input:checked + .switch-track { background: var(--turf-2); }
.switch input:checked + .switch-track::after { transform: translateX(15px); }
.switch.small { font-size: 11px; color: var(--muted); }
.switch.small .switch-track { width: 32px; height: 19px; }
.switch.small .switch-track::after { width: 13px; height: 13px; }
.switch.small input:checked + .switch-track::after { transform: translateX(13px); }

.weather-panel {
  display: grid; grid-template-columns: 52px minmax(0, 1fr) auto; align-items: center; gap: 16px;
  margin-top: 22px; padding: 16px 18px; border-radius: 14px;
  background: linear-gradient(135deg, var(--green-soft), #f4f7ee);
  border: 1px solid #d7e2ca;
}
.weather-icon { width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center; background: var(--paper); color: var(--turf-2); border: 1px solid #d7e2ca; }
.weather-icon svg { width: 30px; height: 30px; }
.weather-icon .sun-icon { color: var(--gold); }
.weather-copy { min-width: 0; }
.mini-label { font-size: 9px; letter-spacing: .2em; color: var(--turf-3); font-weight: 700; }
.weather-copy strong { display: block; font-size: 16px; font-family: var(--font-display); font-weight: 600; margin: 2px 0 1px; }
.weather-copy p { font-size: 11px; line-height: 1.6; color: var(--muted); }
.going-badge {
  display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border-radius: 999px;
  background: var(--turf); color: var(--lime); font-size: 12px; font-weight: 700; white-space: nowrap;
}
.going-badge.manual { background: var(--gold); color: #fff; }
.going-badge.official { background: #2f5f8f; color: #fff; }

.live-bar {
  margin-top: 12px; padding: 12px 16px; border: 1px solid #d7e2ca; border-radius: 12px;
  background: #f8fbf4; display: flex; align-items: center; gap: 18px; flex-wrap: wrap;
}
.live-status { display: flex; align-items: center; gap: 10px; min-width: 150px; }
.live-status b { display: block; font-size: 12px; line-height: 1.2; }
.live-status small { display: block; font-size: 9.5px; color: var(--muted); line-height: 1.4; }
.live-pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--turf-3); box-shadow: 0 0 0 0 rgba(42,139,98,.5); animation: livepulse 2.4s infinite; flex: 0 0 auto; }
.live-pulse.off { background: #bdb6a6; animation: none; box-shadow: none; }
@keyframes livepulse { 0% { box-shadow: 0 0 0 0 rgba(42,139,98,.45); } 70% { box-shadow: 0 0 0 7px rgba(42,139,98,0); } 100% { box-shadow: 0 0 0 0 rgba(42,139,98,0); } }
.live-meta { display: flex; gap: 20px; margin-left: auto; flex-wrap: wrap; }
.live-meta span { font-size: 9px; color: var(--muted); letter-spacing: .04em; }
.live-meta b { display: block; color: var(--ink-2); font-size: 11px; font-weight: 700; font-variant-numeric: tabular-nums; }
.live-actions { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; }
.live-actions .btn { min-height: 32px; font-size: 10px; padding: 0 11px; }
.live-actions .switch { margin-right: 2px; }

.trend-box { margin-top: 14px; padding: 14px 16px; border: 1px solid #cfdec5; border-radius: 12px; background: #f7fbf2; }
.trend-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 9px; }
.trend-head b { font-size: 12px; }
.trend-head .chip { background: #e5efd8; }
.trend-stats { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 8px; }
.trend-stat { background: var(--paper); border: 1px solid var(--line-2); border-radius: 9px; padding: 8px 10px; }
.trend-stat span { display: block; font-size: 9px; color: var(--muted); }
.trend-stat b { display: block; font-size: 15px; color: var(--turf); margin-top: 1px; }
.trend-note { font-size: 10px; color: var(--muted); line-height: 1.6; margin-top: 9px; }

.schema {
  margin: 14px 0 0; padding: 12px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: #f7f3e7; color: #4c534b; font-size: 10px; line-height: 1.6;
  white-space: pre-wrap; max-height: 220px; overflow: auto;
}
.provider-ok { color: var(--turf-2); font-weight: 700; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--ink); font-size: 12.5px; font-weight: 700;
  letter-spacing: .04em; transition: .18s; text-decoration: none;
}
.btn:hover { background: var(--paper-2); border-color: #c9c0ab; transform: translateY(-1px); }
.btn.primary { background: var(--turf); border-color: var(--turf); color: var(--paper); padding: 0 22px; }
.btn.primary:hover { background: var(--turf-2); border-color: var(--turf-2); }
.btn.ghost { background: rgba(255, 253, 247, .7); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-2); border-color: #e4b9b5; }
.btn .arrow { font-size: 16px; line-height: 1; }
.btn[disabled] { opacity: .5; pointer-events: none; }
.icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line);
  background: transparent; color: var(--muted); font-size: 20px; line-height: 1; display: grid; place-items: center;
}
.icon-btn:hover { background: var(--paper-2); color: var(--ink); }
.file-btn { position: relative; overflow: hidden; }
.file-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }

/* ---------- horse table ---------- */
.table-meta { display: flex; justify-content: space-between; align-items: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.legend { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--muted); flex-wrap: wrap; }
.chip { display: inline-flex; align-items: center; padding: 3px 9px; border-radius: 999px; background: var(--green-soft); color: var(--turf-2); font-size: 10px; font-weight: 700; letter-spacing: .06em; white-space: nowrap; }
.dot-sep { color: var(--line); }
.table-wrap { overflow: auto; border: 1px solid var(--line); border-radius: 12px; background: #fffef9; max-height: 68vh; }
.horse-table { width: 100%; min-width: 1300px; border-collapse: separate; border-spacing: 0; font-size: 12px; }
.horse-table th {
  position: sticky; top: 0; z-index: 2; background: #eee8d9; color: var(--muted);
  font-size: 10px; font-weight: 700; letter-spacing: .04em; text-align: left;
  padding: 8px 6px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.horse-table td { padding: 4px 4px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.horse-table tr:last-child td { border-bottom: 0; }
.horse-table tr:hover td { background: #fbf8ee; }
.horse-table .adv { display: none; }
body.show-adv .horse-table .adv { display: table-cell; }
.horse-table input, .horse-table select {
  width: 100%; height: 33px; border: 1px solid transparent; border-radius: 6px;
  background: transparent; padding: 0 6px; font-size: 12px; min-width: 0;
}
.horse-table input:hover, .horse-table select:hover { border-color: var(--line); background: #fff; }
.horse-table input:focus, .horse-table select:focus { outline: none; border-color: var(--turf-3); background: #fff; box-shadow: 0 0 0 2px rgba(42,139,98,.1); }
.horse-table .col-num { width: 54px; }
.horse-table .col-num input { font-weight: 700; }
.horse-table .col-frame { width: 44px; }
.horse-table .col-name { width: 142px; }
.horse-table .col-name input { font-weight: 700; }
.horse-table .col-weight { width: 58px; }
.horse-table .col-odds { width: 64px; }
.horse-table .col-odds input { font-weight: 700; }
.horse-table .col-last5 { width: 112px; }
.horse-table .col-memo { width: 170px; }
.horse-table td:nth-child(4) input { width: 52px; }
.horse-table td:nth-child(6) input { width: 78px; }
.horse-table td:nth-child(8) input { width: 44px; }
.horse-table td:nth-child(11) input { width: 58px; }
.horse-table .del-cell { width: 36px; }
.row-del { border: 0; background: transparent; color: #b9b1a0; width: 26px; height: 26px; border-radius: 50%; font-size: 16px; }
.row-del:hover { color: var(--red); background: var(--red-2); }
.horse-table tbody tr.mark-row td { background: #fbf7e9; }
.card-foot { display: flex; justify-content: space-between; align-items: center; gap: 18px; margin-top: 18px; flex-wrap: wrap; }
.hint { font-size: 11px; color: var(--muted); max-width: 640px; }

/* ---------- results ---------- */
.results { position: relative; scroll-margin-top: 82px; }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.result-hero {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 26px; align-items: center;
  background:
    radial-gradient(500px 220px at 90% 0%, rgba(42,139,98,.45), transparent 60%),
    linear-gradient(135deg, #082d1e, #0c4a33);
  color: var(--paper); border-radius: 20px; padding: clamp(22px, 3vw, 32px);
  box-shadow: var(--shadow); position: relative; overflow: hidden;
}
.result-hero::after {
  content: ""; position: absolute; right: -80px; top: -120px; width: 340px; height: 340px;
  border: 1px solid rgba(215,232,163,.16); border-radius: 50%;
  box-shadow: 0 0 0 38px rgba(215,232,163,.04), 0 0 0 78px rgba(215,232,163,.03);
}
.result-hero > * { position: relative; z-index: 1; }
.result-title h2 { font-size: clamp(24px, 3vw, 38px); color: var(--paper); margin: 2px 0 8px; }
.result-title .meta { display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12px; color: rgba(244,240,229,.72); }
.result-title .meta b { color: var(--lime); font-weight: 500; }
.result-right { display: flex; gap: 18px; align-items: center; }
.confidence-block { text-align: center; border-left: 1px solid rgba(215,232,163,.22); padding-left: 18px; }
.confidence-block span { display: block; font-size: 9px; letter-spacing: .18em; color: rgba(244,240,229,.6); }
.confidence-block b { display: block; font-family: var(--font-display); font-size: 30px; color: var(--lime); line-height: 1.2; }
.confidence-block small { font-size: 10px; color: rgba(244,240,229,.65); }
.final-marks { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.final-mark { display: flex; align-items: center; gap: 7px; background: rgba(255,255,255,.07); border: 1px solid rgba(215,232,163,.2); padding: 6px 10px 6px 6px; border-radius: 999px; font-size: 11px; color: var(--paper); }
.final-mark .mark { width: 24px; height: 24px; font-size: 13px; }

.result-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 14px; }
.result-actions .btn { background: rgba(255,255,255,.08); border-color: rgba(215,232,163,.28); color: var(--paper); }
.result-actions .btn:hover { background: rgba(255,255,255,.14); }

.section-nav {
  position: sticky; top: 68px; z-index: 30; display: flex; gap: 6px; overflow-x: auto;
  padding: 12px 0 10px; margin-bottom: 2px; background: linear-gradient(var(--cream) 70%, rgba(243,239,227,0));
  scrollbar-width: none;
}
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a {
  flex: 0 0 auto; font-size: 10px; letter-spacing: .06em; color: var(--muted); text-decoration: none;
  border: 1px solid var(--line); background: var(--paper); padding: 5px 10px; border-radius: 999px;
}
.section-nav a:hover { color: var(--turf); border-color: var(--turf-3); }

.analysis-section {
  background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius);
  padding: clamp(20px, 2.6vw, 30px); margin-top: 16px; box-shadow: var(--shadow-sm);
  scroll-margin-top: 126px;
}
.section-head { display: flex; gap: 14px; align-items: flex-start; margin-bottom: 18px; }
.section-num { font-family: var(--font-num); font-size: 34px; line-height: 1; color: var(--gold); min-width: 44px; padding-top: 2px; }
.section-head h2 { font-size: clamp(20px, 2.3vw, 26px); }
.section-head p { font-size: 11px; color: var(--muted); margin-top: 3px; }
.section-head .head-right { margin-left: auto; align-self: center; }
.subhead { font-size: 13px; font-weight: 700; margin: 20px 0 10px; display: flex; align-items: center; gap: 8px; }
.subhead::before { content: ""; width: 3px; height: 14px; border-radius: 2px; background: var(--turf-3); }
.muted { color: var(--muted); font-size: 12px; line-height: 1.7; }
.callout {
  border-left: 3px solid var(--gold); background: #fbf6e8; padding: 12px 16px; border-radius: 0 10px 10px 0;
  font-size: 12px; color: #5c5138; line-height: 1.75; margin-top: 14px;
}
.callout.danger { border-left-color: var(--red); background: var(--red-2); color: #6f2c29; }
.callout.ok { border-left-color: var(--turf-3); background: var(--green-soft); color: #2c4a37; }
.callout b { font-weight: 700; }

/* generic data table */
.data-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.data-table th {
  text-align: left; font-size: 10px; letter-spacing: .05em; color: var(--muted);
  padding: 8px 8px; border-bottom: 1px solid var(--line); white-space: nowrap; background: #f6f1e4;
}
.data-table td { padding: 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.data-table tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover td { background: #fbf8ee; }
.data-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.data-table .nowrap { white-space: nowrap; }
.data-table .name { font-weight: 700; }
.data-table .strong { font-weight: 700; }
.data-table .sub { display: block; font-size: 10px; color: var(--muted); font-weight: 400; }
.scroll-x { overflow-x: auto; border: 1px solid var(--line); border-radius: 12px; }
.scroll-x .data-table { min-width: 860px; }
.scroll-x .data-table th:first-child, .scroll-x .data-table td:first-child { padding-left: 12px; }

/* marks */
.mark { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; font-size: 14px; font-weight: 700; line-height: 1; flex: 0 0 auto; }
.mark-honmei { background: var(--red); color: #fff; }
.mark-taikou { background: var(--blue); color: #fff; }
.mark-tanana { background: var(--turf-2); color: #fff; }
.mark-renka { background: #eee8d9; color: #5f5a4c; border: 1px solid #ddd5c2; }
.mark-ana { background: #f2e3b8; color: #7b5c14; border: 1px solid #e2cb8b; }
.mark-keshi { background: #f0eee8; color: #9a9488; border: 1px solid #e2ded3; }
.mark-none { background: transparent; color: var(--muted); border: 1px dashed var(--line); }
.mark-sm { width: 18px; height: 18px; font-size: 10px; vertical-align: middle; }

/* meta grids */
.info-grid { display: grid; grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
.info-cell { background: var(--paper-2); border: 1px solid var(--line-2); border-radius: 10px; padding: 10px 12px; min-width: 0; }
.info-cell span { display: block; font-size: 9px; letter-spacing: .12em; color: var(--muted); }
.info-cell b { display: block; font-size: 13px; font-weight: 700; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.source-list { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.source-list span { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 4px 9px; background: #fffef9; }

.confidence-bar { display: flex; align-items: center; gap: 12px; margin: 12px 0 6px; }
.confidence-bar .bar { flex: 1; height: 8px; border-radius: 99px; background: #e8e2d4; overflow: hidden; }
.confidence-bar .bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--gold), var(--turf-3)); }
.confidence-bar b { font-size: 12px; }

.missing-list { margin: 10px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.missing-list li { font-size: 12px; padding-left: 16px; position: relative; color: var(--ink-2); }
.missing-list li::before { content: "!"; position: absolute; left: 0; top: 0; width: 13px; height: 13px; border-radius: 50%; background: #f0e2bf; color: #7b5c14; font-size: 9px; font-weight: 700; display: grid; place-items: center; margin-top: 4px; }

/* course */
.profile-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
.profile-chip { background: var(--paper-2); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 11px; color: var(--muted); }
.profile-chip b { display: block; font-size: 15px; color: var(--ink); font-weight: 700; }
.course-notes { margin: 0; padding: 0; list-style: none; display: grid; gap: 7px; }
.course-notes li { font-size: 12px; padding-left: 16px; position: relative; }
.course-notes li::before { content: ""; position: absolute; left: 2px; top: 9px; width: 5px; height: 5px; border-radius: 50%; background: var(--turf-3); }

/* pace */
.pace-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.pace-card { border: 1px solid var(--line); border-radius: 14px; padding: 16px; background: var(--paper-2); position: relative; }
.pace-card.main { border-color: var(--turf-3); background: linear-gradient(145deg, #edf4e6, #fbf9f0); box-shadow: 0 0 0 3px rgba(42,139,98,.08); }
.pace-top { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.pace-top b { font-family: var(--font-display); font-size: 18px; }
.pace-prob { font-family: var(--font-num); font-size: 30px; line-height: 1; color: var(--turf); }
.pace-prob small { font-size: 12px; font-family: var(--font-body); }
.pace-bar { height: 6px; border-radius: 99px; background: #e2ddce; overflow: hidden; margin: 10px 0 12px; }
.pace-bar i { display: block; height: 100%; background: var(--turf-3); border-radius: inherit; }
.pace-card.main .pace-bar i { background: var(--turf); }
.pace-desc { font-size: 11.5px; line-height: 1.7; color: var(--ink-2); }
.pace-fit { margin-top: 10px; font-size: 10px; color: var(--muted); }
.pace-fit b { color: var(--turf-2); }
.pace-risk { margin-top: 6px; font-size: 10px; color: #8a6a4a; }
.pace-summary { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; margin-top: 14px; font-size: 12px; }
.pace-summary .leaders { color: var(--muted); font-size: 11px; }

/* score table & details */
.score-cell { display: flex; align-items: center; gap: 8px; min-width: 100px; }
.score-cell .bar { width: 52px; height: 5px; border-radius: 99px; background: #e8e2d4; overflow: hidden; }
.score-cell .bar i { display: block; height: 100%; background: var(--turf-3); border-radius: inherit; }
.score-cell b { font-size: 13px; min-width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.pos-text { font-size: 10.5px; color: var(--muted); line-height: 1.55; max-width: 360px; }
.pos-text b { color: var(--ink-2); }
.tag-list { display: flex; flex-wrap: wrap; gap: 4px; }
.tag { font-size: 9px; padding: 2px 7px; border-radius: 999px; background: var(--green-soft); color: #3f6248; }
.tag.warn { background: var(--red-2); color: #7c3632; }
.tag.neutral { background: #eee9dc; color: #6e6757; }

details.score-detail { border-bottom: 1px solid var(--line-2); }
details.score-detail:last-child { border-bottom: 0; }
details.score-detail > summary {
  list-style: none; cursor: pointer; padding: 11px 2px; display: grid;
  grid-template-columns: 36px minmax(150px, 1.2fr) 90px minmax(0, 1fr) 20px; gap: 10px; align-items: center;
}
details.score-detail > summary::-webkit-details-marker { display: none; }
details.score-detail > summary:hover { background: #fbf8ee; }
.sum-name { font-weight: 700; font-size: 12.5px; }
.sum-name small { display: block; color: var(--muted); font-size: 10px; font-weight: 400; }
.sum-score { font-family: var(--font-num); font-size: 24px; text-align: right; color: var(--turf); }
.sum-tags { display: flex; gap: 4px; flex-wrap: wrap; }
.sum-chevron { color: var(--muted); transition: .2s; font-size: 12px; }
details[open] .sum-chevron { transform: rotate(90deg); }
.detail-body { padding: 4px 2px 18px 46px; display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(220px, .8fr); gap: 24px; }
.comp-bars { display: grid; gap: 7px; }
.comp-row { display: grid; grid-template-columns: 92px minmax(0,1fr) 38px; gap: 8px; align-items: center; font-size: 10.5px; }
.comp-row span:first-child { color: var(--muted); }
.comp-row .bar { height: 6px; background: #eae5d8; border-radius: 99px; overflow: hidden; }
.comp-row .bar i { display: block; height: 100%; background: linear-gradient(90deg, var(--turf-3), var(--lime)); border-radius: inherit; }
.comp-row b { text-align: right; font-variant-numeric: tabular-nums; }
.detail-notes { font-size: 11px; line-height: 1.7; }
.detail-notes h4 { margin: 0 0 4px; font-size: 10px; letter-spacing: .1em; color: var(--turf-2); font-family: var(--font-body); }
.detail-notes ul { margin: 0 0 12px; padding: 0; list-style: none; }
.detail-notes li { position: relative; padding-left: 12px; }
.detail-notes li::before { content: "＋"; position: absolute; left: 0; color: var(--turf-3); }
.detail-notes ul.minus li::before { content: "−"; color: var(--red); }
.detail-notes ul.cond li::before { content: "→"; color: var(--gold); }

/* probability table */
.sum-check { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.sum-check span { font-size: 10px; background: var(--green-soft); color: var(--turf-2); padding: 4px 9px; border-radius: 999px; border: 1px solid #d6e3cc; }
.value-big { color: #8a6a14; font-weight: 700; }
.value-mid { color: var(--turf-2); font-weight: 700; }
.value-none { color: var(--muted); }
.odds-est { font-size: 9px; color: var(--muted); display: block; }

/* rankings */
.rank-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; }
.rank-card { border: 1px solid var(--line); border-radius: 12px; padding: 13px; background: var(--paper-2); }
.rank-card h3 { font-family: var(--font-body); font-size: 11px; font-weight: 700; color: var(--muted); letter-spacing: .04em; margin-bottom: 8px; min-height: 32px; }
.rank-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.rank-list li { display: flex; align-items: center; gap: 6px; font-size: 10.5px; min-width: 0; }
.rank-list .rk { width: 16px; height: 16px; border-radius: 50%; background: var(--turf); color: var(--lime); font-size: 8px; display: grid; place-items: center; flex: 0 0 auto; }
.rank-list .nm { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.rank-list .vl { color: var(--muted); font-variant-numeric: tabular-nums; font-size: 9.5px; }
.rank-card .note { font-size: 9px; color: var(--muted); line-height: 1.5; margin-top: 8px; border-top: 1px dashed var(--line); padding-top: 6px; }

/* marks section */
.mark-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
.mark-card { border: 1px solid var(--line); border-radius: 12px; padding: 13px 14px; background: var(--paper-2); display: grid; grid-template-columns: 32px minmax(0,1fr); gap: 10px; }
.mark-card .mark { width: 32px; height: 32px; font-size: 16px; }
.mark-card h4 { margin: 0; font-family: var(--font-body); font-size: 13px; }
.mark-card h4 small { color: var(--muted); font-weight: 400; margin-left: 6px; font-size: 10px; }
.mark-card p { font-size: 10.5px; color: var(--muted); line-height: 1.6; margin-top: 2px; }
.condition-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.condition-chips span { font-size: 9px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 2px 7px; color: #5f5a4c; }
.cut-list { margin-top: 12px; display: flex; flex-wrap: wrap; gap: 6px; }
.cut-item { font-size: 10px; color: var(--muted); border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px; background: #f7f4ea; }
.cut-item b { color: var(--ink-2); font-weight: 700; }

/* bets */
.bet-summary { display: grid; grid-template-columns: repeat(5, minmax(0,1fr)); gap: 10px; margin-bottom: 16px; }
.bet-stat { border: 1px solid var(--line); border-radius: 12px; padding: 12px; background: var(--paper-2); }
.bet-stat span { display: block; font-size: 9px; letter-spacing: .1em; color: var(--muted); }
.bet-stat b { display: block; font-size: 18px; font-family: var(--font-display); margin-top: 2px; }
.bet-stat b small { font-size: 10px; font-family: var(--font-body); color: var(--muted); }
.bet-stat.highlight { background: var(--turf); border-color: var(--turf); color: var(--paper); }
.bet-stat.highlight span { color: rgba(244,240,229,.65); }
.bet-stat.highlight b { color: var(--lime); }
.bet-stat.highlight b small { color: rgba(244,240,229,.6); }
.bet-table td { font-size: 11.5px; }
.bet-label { font-size: 9px; font-weight: 700; padding: 3px 8px; border-radius: 999px; white-space: nowrap; }
.bet-label.main { background: var(--turf); color: var(--lime); }
.bet-label.sub { background: #eee8d9; color: #5f5a4c; }
.bet-label.ana { background: #f2e3b8; color: #7b5c14; }
.bet-combo { font-weight: 700; }
.bet-combo small { display: block; color: var(--muted); font-weight: 400; font-size: 9px; }
.bet-notes { margin: 14px 0 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.bet-notes li { font-size: 11px; color: var(--muted); padding-left: 14px; position: relative; }
.bet-notes li::before { content: "·"; position: absolute; left: 2px; color: var(--gold); font-weight: 700; }
.trifecta-panels { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; margin-top: 16px; }
.mini-panel { border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; background: var(--paper-2); }
.mini-panel h4 { margin: 0 0 7px; font-family: var(--font-body); font-size: 11px; color: var(--muted); letter-spacing: .04em; }
.mini-panel ol { margin: 0; padding-left: 18px; font-size: 11px; }
.mini-panel li { margin-bottom: 3px; }

/* risk */
.risk-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
.risk-card { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--paper-2); }
.risk-card span { display: block; font-size: 9px; letter-spacing: .12em; color: var(--muted); margin-bottom: 3px; }
.risk-card b { font-size: 14px; }
.risk-card p { font-size: 11px; color: var(--muted); line-height: 1.7; margin-top: 3px; }
.risk-card.alert { border-color: #e4c7c4; background: #fcf1ef; }
.risk-card.alert b { color: var(--red); }
.risk-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.risk-list li { font-size: 11px; color: var(--muted); padding-left: 14px; position: relative; }
.risk-list li::before { content: "→"; position: absolute; left: 0; color: var(--gold); }

.verify-cta { display: flex; align-items: center; justify-content: space-between; gap: 18px; flex-wrap: wrap; background: linear-gradient(135deg, #0c4a33, #082d1e); color: var(--paper); border-radius: var(--radius); padding: 22px 26px; margin-top: 16px; }
.verify-cta h3 { font-size: 19px; color: var(--paper); }
.verify-cta p { font-size: 11px; color: rgba(244,240,229,.7); }
.verify-cta .btn { background: var(--lime); border-color: var(--lime); color: var(--turf); }

/* history */
.page-head { padding: clamp(30px, 5vw, 56px) 4px 10px; }
.page-head h1 { font-size: clamp(30px, 4vw, 46px); margin-bottom: 12px; }
.page-head .lead { max-width: 720px; color: var(--muted); font-size: 13.5px; line-height: 1.9; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; margin-top: 22px; }
.stat-card { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 16px 18px; box-shadow: var(--shadow-sm); }
.stat-card span { font-size: 10px; color: var(--muted); letter-spacing: .06em; }
.stat-card b { display: block; font-family: var(--font-num); font-size: 34px; line-height: 1.2; color: var(--turf); margin-top: 2px; }
.stat-card small { font-size: 10px; color: var(--muted); }
#history-view .card { margin-top: 16px; padding: clamp(20px, 3vw, 28px); }
.history-list { display: grid; gap: 10px; }
.history-item { border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; background: var(--paper-2); }
.history-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.history-date { font-family: var(--font-num); font-size: 20px; color: var(--gold); min-width: 92px; }
.history-race { font-weight: 700; font-size: 13px; }
.history-race small { display: block; color: var(--muted); font-weight: 400; font-size: 10px; }
.history-marks { display: flex; gap: 4px; margin-left: auto; }
.history-result { font-size: 11px; color: var(--muted); margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); display: flex; gap: 14px; flex-wrap: wrap; }
.history-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.history-actions .btn { min-height: 32px; padding: 0 12px; font-size: 10px; }
.empty-state { text-align: center; padding: 44px 20px; color: var(--muted); font-size: 12px; }
.empty-state b { display: block; font-family: var(--font-display); font-size: 18px; color: var(--ink); margin-bottom: 4px; }

/* about */
.about-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 14px; margin-top: 20px; }
.about-card { padding: 24px; }
.about-card h2 { font-size: 22px; margin-bottom: 12px; }
.about-card p { font-size: 12px; line-height: 1.85; color: var(--ink-2); margin-bottom: 10px; }
.weight-list { margin: 0 0 14px; padding: 0; list-style: none; }
.weight-list li { display: flex; justify-content: space-between; gap: 12px; font-size: 12px; padding: 7px 0; border-bottom: 1px solid var(--line-2); }
.weight-list li:last-child { border-bottom: 0; }
.weight-list b { font-family: var(--font-num); font-size: 18px; color: var(--turf); line-height: 1; }
.formula { background: #f7f3e7; border: 1px dashed var(--line); border-radius: 10px; padding: 12px 14px; font-size: 12px; line-height: 1.9; color: var(--turf-2); font-weight: 700; margin: 10px 0; font-variant-numeric: tabular-nums; }
.data-list { margin: 0 0 12px; font-size: 12px; }
.data-list dt { font-weight: 700; margin-top: 8px; }
.data-list dd { margin: 0; color: var(--muted); font-size: 11.5px; }
.caution-list { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.caution-list li { font-size: 12px; padding-left: 18px; position: relative; color: var(--ink-2); line-height: 1.7; }
.caution-list li::before { content: "—"; position: absolute; left: 0; color: var(--gold); }

/* footer */
.site-footer {
  margin-top: 54px; padding: 28px clamp(20px, 4vw, 48px);
  background: #082d1e; color: rgba(244,240,229,.65); display: flex; justify-content: space-between; gap: 20px; flex-wrap: wrap;
}
.site-footer b { font-family: var(--font-num); font-size: 20px; letter-spacing: .14em; color: var(--lime); font-weight: 400; }
.site-footer span { font-size: 10px; margin-left: 10px; letter-spacing: .1em; }
.site-footer p { font-size: 10px; max-width: 620px; line-height: 1.8; margin: 0; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 100; display: grid; place-items: center; padding: 18px; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(6, 24, 16, .62); backdrop-filter: blur(4px); }
.modal-panel {
  position: relative; z-index: 1; width: min(660px, 100%); max-height: 90vh; overflow: auto;
  background: var(--paper); border-radius: 18px; padding: 24px; box-shadow: 0 30px 80px rgba(0,0,0,.3);
}
.modal-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; margin-bottom: 14px; }
.modal-head h2 { font-size: 24px; }
.modal-panel textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; background: #fffef9;
  padding: 12px; font-family: ui-monospace, "Consolas", monospace; font-size: 11px; line-height: 1.6; resize: vertical;
}
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; flex-wrap: wrap; }
.modal-panel .field { margin-top: 12px; }
.form-grid.compact { grid-template-columns: repeat(2, minmax(0,1fr)); }
.form-error { margin-top: 10px; padding: 9px 12px; border-radius: 8px; background: var(--red-2); color: #7c3632; font-size: 11px; white-space: pre-wrap; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%);
  background: #082d1e; color: var(--lime); padding: 10px 18px; border-radius: 999px;
  font-size: 12px; z-index: 120; box-shadow: 0 12px 30px rgba(0,0,0,.25); border: 1px solid rgba(215,232,163,.3);
  animation: toastin .25s ease;
}
@keyframes toastin { from { opacity: 0; transform: translate(-50%, 8px); } }

/* spinner */
.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,.3); border-top-color: currentColor; border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* responsive */
@media (max-width: 1080px) {
  .hero-grid { grid-template-columns: 1fr; gap: 28px; }
  .hero-visual { display: none; }
  .hero { padding-bottom: 112px; }
  .form-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .field.wide { grid-column: span 2; }
  .rank-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .bet-summary { grid-template-columns: repeat(3, minmax(0,1fr)); }
  .info-grid { grid-template-columns: repeat(3, minmax(0,1fr)); }
}
@media (max-width: 820px) {
  .topbar { gap: 10px; }
  .api-status { display: none; }
  .main-nav { margin-left: auto; }
  .nav-btn { padding: 7px 11px; font-size: 12px; }
  .brand-text small { display: none; }
  .form-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .pace-grid, .rank-grid, .mark-grid, .risk-grid, .about-grid, .trifecta-panels { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .detail-body { grid-template-columns: 1fr; padding-left: 0; }
  .result-hero { grid-template-columns: 1fr; }
  .result-right { justify-content: space-between; }
  .final-marks { justify-content: flex-start; }
  .bet-summary { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .info-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .trend-stats { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .live-meta { margin-left: 0; gap: 14px; }
  details.score-detail > summary { grid-template-columns: 30px minmax(120px,1fr) 70px 18px; }
  .sum-tags { display: none; }
}
@media (max-width: 560px) {
  body { font-size: 14px; }
  .topbar { height: 60px; padding: 0 14px; }
  .brand-mark { width: 30px; height: 30px; }
  .brand-text b { font-size: 19px; }
  .main-nav { gap: 2px; }
  .nav-btn { padding: 6px 9px; font-size: 11px; }
  .hero { padding: 50px 0 100px; }
  .hero::before { font-size: 180px; }
  .hero h1 { font-size: 34px; }
  .hero h1 em { white-space: normal; }
  .hero .lead { font-size: 13px; }
  .setup { margin-top: -68px; padding: 18px; }
  .card-head { flex-direction: column; align-items: flex-start; }
  .head-actions { justify-content: flex-start; }
  .form-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .field.wide { grid-column: span 2; }
  .weather-panel { grid-template-columns: 40px 1fr; }
  .going-badge { grid-column: span 2; justify-self: start; }
  .weather-icon { width: 40px; height: 40px; }
  .live-bar { padding: 12px; gap: 10px; }
  .live-status { width: 100%; }
  .live-meta { width: 100%; justify-content: space-between; }
  .live-actions { width: 100%; }
  .trend-stats { grid-template-columns: 1fr 1fr; }
  .section-nav { top: 60px; }
  .analysis-section { padding: 18px; }
  .section-head { gap: 8px; }
  .section-num { font-size: 26px; min-width: 34px; }
  .info-grid, .bet-summary, .stat-grid { grid-template-columns: 1fr 1fr; }
  .result-right { flex-direction: column; align-items: flex-start; }
  .confidence-block { border-left: 0; border-top: 1px solid rgba(215,232,163,.22); padding: 10px 0 0; text-align: left; }
  .confidence-block b { font-size: 24px; }
  .detail-body { grid-template-columns: 1fr; }
  .site-footer { flex-direction: column; }
  .modal-panel { padding: 18px; }
  .form-grid.compact { grid-template-columns: 1fr 1fr; }
}

/* print */
@media print {
  body { background: #fff; color: #000; font-size: 10pt; }
  .topbar, .hero, #setup, #card-section, .section-nav, .site-footer, .result-actions,
  .btn, .icon-btn, .toast, .modal, .history-actions, .verify-cta { display: none !important; }
  #history-view, #about-view { display: none !important; }
  .results { max-width: none; margin: 0; }
  .result-hero { color: #000; background: #fff; border: 1px solid #999; box-shadow: none; }
  .result-hero .eyebrow, .result-hero .meta b, .confidence-block b { color: #000; }
  .result-title h2 { color: #000 !important; }
  .result-hero .meta, .confidence-block span, .confidence-block small { color: #444 !important; }
  .analysis-section { border: 0; box-shadow: none; padding: 6px 0; margin: 0 0 10px; break-inside: avoid; }
  .section-num { color: #777; }
  .final-mark { color: #000; background: #fff; border-color: #999; }
  .scroll-x { overflow: visible; }
  .scroll-x .data-table { min-width: 0; font-size: 8pt; }
  .horse-table { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  * { scroll-behavior: auto !important; animation: none !important; transition: none !important; }
}

.provider-test-result {
  margin-top: 10px; padding: 9px 12px; border-radius: 8px;
  background: var(--green-soft); color: #2f5a3e; font-size: 11px; white-space: pre-wrap;
}
.provider-test-result.ng { background: var(--red-2); color: #7c3632; }

/* ---------- simplified setup / menus ---------- */
.head-sub { margin-top: 6px; font-size: 12px; color: var(--muted); max-width: 54ch; line-height: 1.6; }
.primary-fields { grid-template-columns: 1.1fr 1.1fr .8fr 1fr; }
.setup-cta { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; margin-top: 18px; }
.setup-cta .btn { min-height: 48px; padding: 0 26px; font-size: 13px; }
.setup-cta .hint { margin: 0; }
.advanced-settings { margin-top: 18px; border-top: 1px solid var(--line); padding-top: 14px; }
.advanced-settings > summary { list-style: none; display: flex; align-items: baseline; gap: 10px; cursor: pointer; color: var(--muted); }
.advanced-settings > summary::-webkit-details-marker { display: none; }
.advanced-settings > summary::before { content: "＋"; color: var(--turf-3); font-weight: 700; }
.advanced-settings[open] > summary::before { content: "−"; }
.advanced-settings > summary span { font-size: 12px; font-weight: 700; color: var(--ink-2); }
.advanced-settings > summary small { font-size: 10.5px; }
.advanced-body { padding-top: 16px; }
.advanced-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }

.more-tools { position: relative; }
.more-tools > summary { list-style: none; cursor: pointer; }
.more-tools > summary::-webkit-details-marker { display: none; }
.more-tools[open] > summary { border-color: var(--turf-3); color: var(--turf-2); }
.more-tools-menu {
  position: absolute; right: 0; top: calc(100% + 6px); z-index: 30;
  min-width: 178px; padding: 7px; border: 1px solid var(--line); border-radius: 11px;
  background: var(--paper); box-shadow: 0 12px 30px rgba(13, 49, 34, .16);
  display: flex; flex-direction: column; gap: 5px;
}
.more-tools-menu .btn { width: 100%; justify-content: flex-start; text-align: left; }
.more-tools-menu .switch { padding: 7px 10px; }
.more-tools.compact .more-tools-menu { min-width: 160px; }

@media (max-width: 820px) {
  .primary-fields { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .setup-cta { align-items: stretch; }
  .setup-cta .btn { width: 100%; }
  .setup-cta .hint { font-size: 10.5px; }
  .more-tools-menu { right: auto; left: 0; }
}

/* ---------- softer, more readable visual refresh ---------- */
:root {
  --cream: #f7f2e8;
  --paper: #fffefa;
  --paper-2: #fbf8f0;
  --line: #e4ddce;
  --line-2: #efe9dc;
  --muted: #69766d;
  --turf: #164c36;
  --turf-2: #1e694b;
  --turf-3: #3b8d68;
  --green-soft: #edf3e4;
  --shadow: 0 20px 48px rgba(23, 35, 29, .07);
  --shadow-sm: 0 8px 22px rgba(23, 35, 29, .05);
  --radius: 22px;
  --font-display: "Zen Kaku Gothic New", "Yu Gothic", "Hiragino Kaku Gothic ProN", sans-serif;
}

body { font-size: 15.5px; line-height: 1.75; }
h1, h2, h3 { font-weight: 700; letter-spacing: -.018em; }

.hero {
  background:
    radial-gradient(720px 320px at 86% 2%, rgba(215, 232, 163, .78), transparent 68%),
    radial-gradient(640px 320px at 4% 100%, rgba(59, 141, 104, .10), transparent 64%),
    linear-gradient(180deg, #eef4e4 0%, #f7f2e8 86%);
  color: var(--ink);
  padding: 66px 0 122px;
  border-bottom: 1px solid rgba(22, 76, 54, .06);
}
.hero::before {
  content: "CHINEN EYE";
  font-size: 220px;
  top: 14px;
  right: -34px;
  -webkit-text-stroke: 1px rgba(22, 76, 54, .055);
}
.hero::after {
  background-image: radial-gradient(circle at 1px 1px, rgba(22, 76, 54, .10) 1px, transparent 0);
  background-size: 24px 24px;
  opacity: .28;
  mask-image: linear-gradient(to bottom, rgba(0,0,0,.55), transparent 78%);
}
.hero .eyebrow {
  display: inline-flex;
  align-items: center;
  padding: 5px 10px;
  border: 1px solid rgba(22, 76, 54, .12);
  border-radius: 999px;
  background: rgba(255, 253, 247, .62);
  color: var(--turf-2);
  letter-spacing: .14em;
}
.hero h1 {
  color: var(--turf);
  font-size: clamp(38px, 4.4vw, 58px);
  line-height: 1.26;
  letter-spacing: -.03em;
}
.hero h1 em {
  color: var(--turf-2);
  background: linear-gradient(transparent 65%, rgba(215, 232, 163, .85) 65%);
  -webkit-box-decoration-break: clone;
  box-decoration-break: clone;
  padding: 0 2px;
}
.hero .lead {
  color: #4e6054;
  font-size: 15.5px;
  line-height: 1.95;
}
.hero-tags span {
  background: rgba(255, 253, 247, .82);
  border-color: #d6e1c5;
  color: var(--turf);
  box-shadow: 0 2px 6px rgba(23, 35, 29, .04);
}
.hero-weather {
  background: rgba(255, 253, 247, .94);
  border-color: #d6e1c5;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
}
.hw-label { color: var(--turf-3); }
.hero-weather strong { color: var(--turf); font-family: var(--font-body); font-weight: 700; }
.hero-weather span:last-child { color: var(--muted); }
.track-art { filter: drop-shadow(0 18px 28px rgba(22, 76, 54, .12)); }

.card { border-color: #e5dece; border-radius: 24px; box-shadow: var(--shadow); }
.setup { padding: clamp(22px, 3.2vw, 38px); }
.section-kicker {
  display: inline-flex;
  align-items: center;
  padding: 4px 9px;
  border-radius: 999px;
  background: var(--green-soft);
  color: var(--turf-2);
  letter-spacing: .12em;
  font-size: 9.5px;
}
.card-head h2 { font-size: clamp(22px, 2.3vw, 28px); }
.field > span { font-size: 11.5px; letter-spacing: .025em; color: #5b6a60; }
.field input, .field select {
  height: 48px;
  border-color: #e2dac9;
  border-radius: 14px;
  background: #fffef9;
}
.field input:focus, .field select:focus, textarea:focus { border-color: var(--turf-3); box-shadow: 0 0 0 4px rgba(59, 141, 104, .10); }
.btn { letter-spacing: .015em; }
.btn.primary {
  background: linear-gradient(135deg, var(--turf-2), var(--turf));
  border-color: var(--turf);
  box-shadow: 0 8px 18px rgba(22, 76, 54, .18);
}
.btn.primary:hover { background: linear-gradient(135deg, #237a57, var(--turf-2)); }
.setup-cta .btn { min-height: 50px; }

.result-hero {
  background:
    radial-gradient(520px 230px at 92% 0%, rgba(120, 180, 140, .34), transparent 60%),
    linear-gradient(135deg, #143f2e, #1c5a41);
  border-radius: 24px;
}
.section-nav a {
  font-size: 10.5px;
  padding: 7px 12px;
  background: rgba(255, 254, 250, .92);
  color: #5f6d63;
}
.section-nav a:hover { background: #fff; }
.analysis-section { border-color: #e7e0d1; border-radius: 20px; }
.section-head { align-items: center; gap: 12px; }
.section-num {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 700;
  color: var(--turf-2);
  background: var(--green-soft);
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  padding: 0;
}
.section-head h2 { font-size: clamp(20px, 2.2vw, 25px); }
.muted { font-size: 12.5px; line-height: 1.75; }

@media (max-width: 560px) {
  .hero { padding-top: 48px; padding-bottom: 102px; }
  .hero::before { font-size: 120px; top: 20px; }
  .hero h1 { font-size: 35px; }
  .hero .lead { font-size: 14px; }
  .setup { border-radius: 22px; }
}

/* readability pass */
.section-nav a { font-size: 11.5px; padding: 8px 13px; color: #4f5e54; }
.section-head p { font-size: 12px; }
.source-list span { font-size: 11px; padding: 5px 10px; }
.live-status small { font-size: 10.5px; }
.live-meta span { font-size: 10px; }
.live-meta b { font-size: 12px; }
.confidence-block span { font-size: 10px; letter-spacing: .12em; }
.hero-weather span:last-child { font-size: 12px; }

/* ---------- conclusion-first summary ---------- */
.conclusion-card {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(300px, .85fr);
  gap: 20px 26px;
  margin-top: 18px;
  padding: clamp(20px, 3vw, 30px);
  border: 1px solid #d9e4cd;
  border-radius: 24px;
  background:
    radial-gradient(420px 220px at 100% 0%, rgba(215, 232, 163, .32), transparent 65%),
    linear-gradient(135deg, #fffefa, #f2f7ea);
  box-shadow: var(--shadow-sm);
}
.conclusion-main { min-width: 0; }
.conclusion-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.conclusion-label {
  padding: 5px 12px; border-radius: 999px; background: var(--turf); color: var(--paper);
  font-size: 11px; font-weight: 700; letter-spacing: .12em;
}
.confidence-pill {
  padding: 5px 10px; border-radius: 999px; border: 1px solid #cfdec2; background: #fff;
  color: var(--turf-2); font-size: 11px; font-weight: 700;
}
.conclusion-warning {
  padding: 5px 10px; border-radius: 999px; background: var(--red-2); color: var(--red);
  font-size: 10.5px; font-weight: 700;
}
.conclusion-text {
  font-size: clamp(17px, 2vw, 21px); font-weight: 700; line-height: 1.6;
  color: var(--turf); letter-spacing: -.02em;
}
.conclusion-marks { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.conclusion-mark {
  display: inline-flex; align-items: center; gap: 7px; padding: 5px 11px 5px 5px;
  background: #fff; border: 1px solid #dfe7d5; border-radius: 999px; font-size: 12px;
}
.conclusion-mark > span:last-child { white-space: nowrap; }
.conclusion-mark b { font-size: 13px; }
.conclusion-side {
  align-self: start; padding: 16px; border: 1px solid #e1e8d8; border-radius: 18px;
  background: rgba(255, 255, 255, .76);
}
.conclusion-metrics { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 16px; }
.conclusion-metrics span { display: block; font-size: 10px; color: var(--muted); letter-spacing: .04em; }
.conclusion-metrics b { display: block; margin-top: 1px; font-size: 20px; line-height: 1.25; color: var(--turf); font-variant-numeric: tabular-nums; }
.conclusion-bet-list { margin-top: 14px; border-top: 1px solid #e6ecde; padding-top: 8px; }
.conclusion-bet-row {
  display: grid; grid-template-columns: 58px minmax(0, 1fr) auto; gap: 8px; align-items: center;
  padding: 7px 0; border-bottom: 1px solid #edf1e7; font-size: 12px;
}
.conclusion-bet-row:last-child { border-bottom: 0; }
.conclusion-bet-row b { font-size: 13px; letter-spacing: .02em; }
.conclusion-bet-row > span:last-child { font-weight: 700; color: var(--turf); }
.conclusion-more { display: block; margin-top: 6px; font-size: 10.5px; color: var(--muted); text-align: right; }
.conclusion-empty { display: flex; flex-direction: column; gap: 5px; }
.conclusion-empty b { color: var(--red); font-size: 13px; }
.conclusion-empty span { color: var(--muted); font-size: 11.5px; line-height: 1.6; }
.conclusion-actions {
  grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center;
  gap: 8px; flex-wrap: wrap; padding-top: 2px;
}

@media (max-width: 820px) {
  .conclusion-card { grid-template-columns: 1fr; gap: 14px; }
  .conclusion-actions { justify-content: stretch; }
  .conclusion-actions .btn { flex: 1 1 auto; }
}
@media (max-width: 560px) {
  .result-right { display: none; }
  .conclusion-card { padding: 18px; border-radius: 20px; }
  .conclusion-text { font-size: 17px; }
  .conclusion-mark { font-size: 11.5px; }
  .conclusion-actions { flex-direction: column-reverse; }
  .conclusion-actions .btn { width: 100%; }
}

@media (max-width: 560px) {
  .result-hero { padding: 16px 18px; border-radius: 20px; }
  .result-title h2 { font-size: 22px; margin: 4px 0 6px; }
  .result-title .meta { gap: 5px 9px; font-size: 10.5px; }
  .result-actions { margin-top: 8px; }
  .result-actions [data-action="print"], .result-actions .muted { display: none; }
  .result-actions .btn { min-height: 32px; font-size: 10.5px; }
  .conclusion-card { margin-top: 12px; }
}

.quick-dates, .quick-budgets { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
.quick-dates > span, .quick-budgets > span { font-size: 10px; color: var(--muted); margin-right: 2px; letter-spacing: .04em; }
.quick-chip {
  min-height: 34px; padding: 0 12px; border: 1px solid #dfe7d4; border-radius: 999px;
  background: #fff; color: #536459; font-size: 11px; font-weight: 700; transition: .15s;
}
.quick-chip:hover { border-color: var(--turf-3); color: var(--turf-2); }
.quick-chip.active { background: var(--green-soft); border-color: #bdd3ab; color: var(--turf); }
.conclusion-link {
  display: inline-flex; margin-top: 10px; color: var(--turf-2);
  font-size: 11px; font-weight: 700; text-decoration: none;
}
.conclusion-link:hover { text-decoration: underline; }
.conclusion-note { margin-top: 12px; color: var(--muted); font-size: 11.5px; line-height: 1.7; }
@media (max-width: 560px) {
  .hero-tags { display: none; }
}

/* ---------- four outlook scenarios ---------- */
.pace-strip { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 16px; }
.pace-strip span {
  display: inline-flex; align-items: baseline; gap: 7px; padding: 7px 11px;
  border: 1px solid #e1e8d7; border-radius: 999px; background: #fff;
  color: var(--muted); font-size: 11px;
}
.pace-strip b { color: var(--turf-2); font-size: 11.5px; }
.outlook-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.outlook-card {
  display: flex; flex-direction: column; min-width: 0;
  padding: 16px; border: 1px solid #e4ddce; border-radius: 18px; background: #fffefa;
}
.outlook-card.firm { background: #f4f9ef; border-color: #d6e5c8; }
.outlook-card.middle { background: #f4f7fa; border-color: #d6e2ea; }
.outlook-card.long { background: #fbf7ec; border-color: #eadfc7; }
.outlook-card.wild { background: #fbf1f0; border-color: #ead5d2; }
.outlook-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.outlook-label {
  padding: 4px 9px; border-radius: 999px; font-size: 11px; font-weight: 700;
  background: rgba(255,255,255,.8); color: var(--turf-2); border: 1px solid rgba(22,76,54,.12);
}
.outlook-card.middle .outlook-label { color: var(--blue); border-color: #c9d9e5; }
.outlook-card.long .outlook-label { color: #8a6a25; border-color: #e4d3a8; }
.outlook-card.wild .outlook-label { color: var(--red); border-color: #e6c3bf; }
.outlook-head b { font-size: 24px; line-height: 1; color: var(--turf); font-variant-numeric: tabular-nums; }
.outlook-head small { font-size: 11px; margin-left: 1px; }
.outlook-summary { margin-top: 10px; font-size: 13px; font-weight: 700; line-height: 1.55; color: var(--ink); }
.outlook-fit { margin-top: 8px; font-size: 10.5px; line-height: 1.55; color: var(--muted); }
.outlook-fit span { display: inline-block; min-width: 38px; margin-right: 4px; color: var(--turf-2); font-weight: 700; }
.outlook-evidence { list-style: none; margin: 10px 0 0; padding: 10px 0 0; border-top: 1px solid rgba(22,76,54,.08); }
.outlook-evidence li { position: relative; padding-left: 14px; margin-top: 5px; font-size: 10.5px; line-height: 1.55; color: #53645a; }
.outlook-evidence li::before { content: "·"; position: absolute; left: 2px; top: -1px; color: var(--turf-3); font-weight: 700; }
@media (max-width: 1080px) { .outlook-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 560px) { .outlook-grid { grid-template-columns: 1fr; } }
.outlook-evidence-label { margin-top: 10px; font-size: 9.5px; font-weight: 700; letter-spacing: .12em; color: var(--turf-2); }
