:root {
  color-scheme: light;
  --ink: #17221e;
  --muted: #78847e;
  --green: #174934;
  --green-dark: #102820;
  --lime: #c7ed76;
  --paper: #f4f6f1;
  --line: #e4e9e1;
  --white: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Yu Gothic UI", Meiryo, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; padding-top: env(safe-area-inset-top); padding-bottom: env(safe-area-inset-bottom); background: var(--paper); color: var(--ink); }
.topbar { height: 76px; padding: 0 max(24px, calc((100vw - 1080px) / 2)); background: var(--green-dark); color: white; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 11px; color: inherit; text-decoration: none; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 12px; background: var(--lime); color: var(--green-dark); font-size: 22px; font-weight: 900; font-style: italic; }
.brand strong, .brand small { display: block; letter-spacing: .1em; }
.brand strong { font-size: 12px; }
.brand small { margin-top: 3px; color: #9eb2a5; font-size: 9px; }
.privacy-pill { display: flex; align-items: center; gap: 8px; border: 1px solid #426252; border-radius: 30px; padding: 8px 12px; color: #e8f3e9; font-size: 11px; }
.privacy-pill span { width: 7px; height: 7px; border-radius: 50%; background: var(--lime); box-shadow: 0 0 8px #c7ed7680; }
.page-shell { width: min(100% - 40px, 760px); margin: 0 auto; padding: 54px 0 34px; }
.intro { margin: 0 0 30px; }
.eyebrow { margin: 0 0 9px; color: #73857a; font-size: 10px; font-weight: 800; letter-spacing: .16em; }
h1, h2, p { margin-top: 0; }
.intro h1 { margin-bottom: 13px; font-size: clamp(34px, 6vw, 50px); line-height: 1.22; letter-spacing: -.05em; font-weight: 780; }
.intro h1 span { color: var(--green); }
.intro-copy { max-width: 550px; margin-bottom: 0; color: #657169; font-size: 14px; line-height: 1.8; }
.panel { border: 1px solid var(--line); border-radius: 19px; background: var(--white); box-shadow: 0 8px 28px #16352308; }
.data-card { padding: 22px 24px 18px; margin-bottom: 19px; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.compact-heading { margin-bottom: 10px; }
.section-heading .eyebrow { margin-bottom: 4px; }
.section-heading h2 { margin: 0; font-size: 20px; letter-spacing: -.03em; }
.lock-mark { color: #779181; font-size: 20px; }
.data-explainer { margin-bottom: 16px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.data-imports { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.file-picker { min-width: 0; display: flex; align-items: center; gap: 10px; padding: 12px; border: 1px dashed #cbd8cc; border-radius: 12px; cursor: pointer; transition: border-color .15s, background .15s; }
.file-picker:hover { border-color: var(--green); background: #f7faf5; }
.file-picker input { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }
.file-picker:focus-within { outline: 3px solid #17493430; }
.file-icon { display: grid; place-items: center; flex: 0 0 30px; width: 30px; height: 30px; border-radius: 9px; background: #edf4ed; color: var(--green); font-size: 20px; }
.file-copy { min-width: 0; }
.file-copy strong, .file-copy small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-copy strong { font-size: 11px; }
.file-copy small { margin-top: 4px; color: var(--muted); font-size: 10px; }
.inline-message { margin: 11px 0 0; color: #69766d; font-size: 11px; line-height: 1.6; }
.inline-message.error { color: #a33e35; }
.help-details { margin-top: 12px; border-top: 1px solid #edf0ec; padding-top: 10px; color: #66736a; font-size: 11px; line-height: 1.7; }
.help-details summary, .calculation-details summary { cursor: pointer; color: var(--green); font-weight: 700; }
.help-details ol { padding-left: 19px; margin: 9px 0; }
.help-details p { margin: 0; }
code { border-radius: 4px; padding: 2px 4px; background: #f0f3ef; color: #334c3d; font-size: .95em; }
.calculator { padding: 25px 26px 26px; }
.step-label { color: #8b9990; font-size: 10px; font-weight: 700; letter-spacing: .08em; }
fieldset { min-width: 0; margin: 0; padding: 0; border: 0; }
legend { margin: 0 0 12px; font-size: 12px; font-weight: 750; }
.form-grid { display: grid; gap: 15px; }
.three-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.two-columns { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.race-fields { margin-top: 22px; }
.field { min-width: 0; display: flex; flex-direction: column; gap: 7px; color: #56635a; font-size: 11px; font-weight: 700; }
.field select, .field input { width: 100%; min-width: 0; height: 46px; appearance: none; border: 1px solid #dfe6df; border-radius: 10px; outline: none; background: white; color: var(--ink); font: inherit; font-size: 15px; font-weight: 600; }
.field select { padding: 0 34px 0 12px; background-image: linear-gradient(45deg, transparent 50%, #6c7a70 50%), linear-gradient(135deg, #6c7a70 50%, transparent 50%); background-position: calc(100% - 16px) 19px, calc(100% - 11px) 19px; background-size: 5px 5px, 5px 5px; background-repeat: no-repeat; }
.field input { padding: 0 10px 0 12px; }
.field select:focus, .field input:focus { border-color: #5a8b6c; box-shadow: 0 0 0 3px #17493416; }
.field select:disabled { color: #9ca69f; background-color: #f7f8f6; }
.input-unit { position: relative; display: flex; align-items: center; }
.input-unit input { padding-right: 46px; }
.input-unit em { position: absolute; right: 12px; color: #849087; font-size: 11px; font-style: normal; font-weight: 600; }
.going-control { display: flex; min-width: 0; align-items: center; gap: 8px; }
.going-control .input-unit { flex: 1; min-width: 0; }
.sign-toggle { display: flex; flex: 0 0 auto; gap: 3px; padding: 3px; border: 1px solid #dfe6df; border-radius: 11px; background: #f3f6f2; }
.sign-option { width: 35px; height: 38px; border: 0; border-radius: 8px; background: transparent; color: #758179; cursor: pointer; font: inherit; font-size: 17px; font-weight: 750; }
.sign-option.is-selected { background: var(--green); color: white; box-shadow: 0 1px 3px #1028202e; }
.sign-option:focus-visible { outline: 3px solid #17493450; outline-offset: 2px; }
.field small { color: #8a958d; font-size: 10px; font-weight: 400; }
.jra-fetch-panel { display: grid; grid-template-columns: minmax(0, auto) 1fr; align-items: center; gap: 7px 12px; margin-top: 14px; }
.jra-search-fields { grid-column: 1 / -1; display: grid; grid-template-columns: 1.35fr 1fr 1fr; gap: 10px; margin-bottom: 3px; }
.jra-fetch-button { min-height: 42px; padding: 0 14px; border: 1px solid #cbd8cc; border-radius: 10px; background: #f5f8f2; color: var(--green); cursor: pointer; font: inherit; font-size: 12px; font-weight: 750; }
.jra-fetch-button:hover { border-color: var(--green); background: #edf4e9; }
.jra-fetch-button:disabled { opacity: .6; cursor: wait; }
.jra-fetch-button:focus-visible { outline: 3px solid #17493450; outline-offset: 2px; }
.jra-fetch-status { min-height: 1em; margin: 0; color: #66736a; font-size: 11px; line-height: 1.5; }
.jra-fetch-status.error { color: #a33e35; }
.jra-winner { grid-column: 1 / -1; margin: 0; padding: 9px 12px; border-radius: 9px; background: #f0f5e8; color: #66736a; font-size: 12px; }
.jra-winner strong { margin-left: 5px; color: var(--green); font-size: 14px; }
.calculate-button { width: 100%; min-height: 54px; display: flex; align-items: center; justify-content: space-between; margin-top: 24px; padding: 0 19px; border: 0; border-radius: 12px; background: var(--green); color: white; cursor: pointer; font: inherit; font-size: 14px; font-weight: 750; transition: background .15s, transform .15s; }
.calculate-button:hover { background: #103b28; }
.calculate-button:active { transform: translateY(1px); }
.calculate-button span:last-child { font-size: 20px; font-weight: 500; }
.form-error { margin: 14px 0 -9px; color: #a33e35; font-size: 12px; line-height: 1.6; }
.result-card { overflow: hidden; margin-top: 19px; padding: 24px 27px 20px; border-radius: 19px; background: var(--green-dark); color: white; box-shadow: 0 12px 30px #0f2c1d22; }
.result-topline { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.result-card .eyebrow { color: #a2b9a8; }
.result-course { color: #c9d9cd; font-size: 11px; text-align: right; }
.result-card h2 { margin: 13px 0 0; color: #d9e4da; font-size: 12px; font-weight: 600; }
.result-index { margin: -2px 0 0; color: var(--lime); font-size: clamp(58px, 15vw, 80px); line-height: 1.16; letter-spacing: -.065em; font-weight: 750; font-variant-numeric: tabular-nums; }
.result-caption { margin: 0 0 18px; color: #a4b8aa; font-size: 10px; }
.calculation-details { border-top: 1px solid #ffffff26; padding-top: 14px; color: #d4e0d7; font-size: 11px; }
.calculation-details summary { color: #d7e7d8; }
.calculation-details dl { display: grid; grid-template-columns: 1fr auto; gap: 9px 14px; margin: 14px 0 0; font-variant-numeric: tabular-nums; }
.calculation-details dt { color: #afc2b4; }
.calculation-details dd { margin: 0; color: #fff; text-align: right; }
.page-footer { padding: 26px 0 0; color: #758179; text-align: center; }
.page-footer p { margin: 0 0 8px; font-size: 10px; }
.page-footer p span { color: var(--green); }
.page-footer small { color: #a1aaa3; font-size: 8px; letter-spacing: .14em; }
[hidden] { display: none !important; }

@media (max-width: 600px) {
  .topbar { height: 64px; padding: 0 17px; }
  .brand-mark { width: 34px; height: 34px; border-radius: 10px; }
  .privacy-pill { padding: 7px 9px; font-size: 10px; }
  .page-shell { width: min(100% - 28px, 500px); padding-top: 32px; }
  .intro { margin-bottom: 22px; }
  .intro h1 { font-size: 37px; }
  .intro-copy { font-size: 12px; }
  .data-card { padding: 18px 16px 15px; border-radius: 16px; }
  .data-explainer { font-size: 11px; }
  .data-imports { grid-template-columns: 1fr; gap: 8px; }
  .file-picker { padding: 10px 11px; }
  .calculator { padding: 21px 17px 18px; border-radius: 16px; }
  .three-columns { grid-template-columns: 1fr 1fr; }
  .three-columns .field:first-child { grid-column: 1 / -1; }
  .two-columns { grid-template-columns: 1fr 1fr; gap: 17px 11px; }
  .race-fields .going-adjustment-field { grid-column: 1 / -1; }
  .race-fields { margin-top: 20px; }
  .field select, .field input { height: 48px; }
  .jra-fetch-panel { grid-template-columns: 1fr; gap: 8px; }
  .jra-search-fields { grid-template-columns: 1fr 1fr; gap: 9px; }
  .jra-search-fields .field:first-child { grid-column: 1 / -1; }
  .jra-fetch-button { width: 100%; min-height: 48px; }
  .calculate-button { min-height: 56px; margin-top: 22px; }
  .result-card { padding: 20px 19px 18px; border-radius: 16px; }
  .page-footer { padding-top: 22px; }
}

@media (max-width: 360px) {
  .two-columns { grid-template-columns: 1fr; }
  .intro h1 { font-size: 33px; }
  .result-index { font-size: 58px; }
}
