:root {
  color-scheme: dark;
  --background: #0b1220;
  --panel: #141f30;
  --inset: #101a2a;
  --border: #2c3e55;
  --text: #eff4ff;
  --muted: #b3c3d8;
  --accent: #a4cbff;
  --green: #6ce3ac;
  --red: #ff9e96;
  --amber: #ffd196;
  font-family: system-ui, -apple-system, "Noto Sans JP", sans-serif;
  font-synthesis: none;
  background: var(--background);
  color: var(--text);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 15px; line-height: 1.55; }
button, input, select { font: inherit; }
button, input, select, .file-action { min-height: 46px; border-radius: 10px; }
button, .file-action { cursor: pointer; }
:focus-visible { outline: 3px solid #c7e2ff; outline-offset: 3px; }
button:disabled, input:disabled, select:disabled, .backup-actions:has(input:disabled) .file-action { opacity: .55; cursor: default; }
.app-header { background: #101a2a; border-bottom: 1px solid var(--border); padding-top: env(safe-area-inset-top); }
.header-inner { max-width: 720px; margin: auto; padding: 11px 16px; display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.brand { font-weight: 850; letter-spacing: .04em; font-size: 16px; }
.brand span { color: var(--accent); }
.version, .hint, footer { color: var(--muted); font-size: 13px; }
main { max-width: 720px; padding: 12px 12px calc(28px + env(safe-area-inset-bottom)); margin: auto; }
.panel { background: var(--panel); border: 1px solid var(--border); border-radius: 15px; padding: 14px; margin-bottom: 12px; min-width: 0; }
h1, h2 { font-size: 18px; margin: 0 0 10px; line-height: 1.35; }
h3 { font-size: 15px; margin: 14px 0 6px; }
p { margin: 8px 0; }
.fields, .actions, .backup-actions { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 8px; }
.fields label { display: block; min-width: 0; color: var(--muted); font-size: 13px; }
.fields small { margin-left: 2px; }
input, select { display: block; width: 100%; min-width: 0; padding: 7px 8px; color: var(--text); background: var(--inset); border: 1px solid var(--border); }
.fields :is(input, select) { margin-top: 4px; font-size: 16px; }
.comparison-fields > label:last-child { grid-column: 1 / -1; }
.budget-field { display: grid; grid-template-columns: minmax(0, 1fr) minmax(7em, 10em); align-items: center; gap: 8px; margin: 8px 0; }
.budget-field label { font-size: 14px; font-weight: 650; }
.budget-field select { font-size: 16px; }
button, .file-action { display: block; width: 100%; padding: 8px 6px; border: 1px solid transparent; background: #9bc6ff; color: #102039; font-weight: 750; font-size: 14px; }
.actions { margin-top: 9px; }
.comparison-link { display: inline-block; color: var(--accent); padding: 10px 0 3px; font-size: 13px; }
button.secondary, .file-action { background: #24364d; border-color: #405775; color: var(--text); }
.notice { background: var(--inset); border: 1px solid var(--border); padding: 9px; border-radius: 9px; white-space: pre-line; font-size: 13px; color: var(--muted); overflow-wrap: anywhere; }
.race-grid, .metrics { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.race-button { display: grid; gap: 1px; text-align: left; min-height: 62px; padding: 5px 7px; font-weight: 650; background: var(--inset); border-color: var(--border); color: var(--text); }
.race-button[aria-pressed="true"] { border-color: var(--accent); background: #233c5c; box-shadow: inset 0 0 0 1px var(--accent); }
.race-button strong { font-size: 15px; }
.race-button small { font-size: 11px; color: var(--muted); overflow-wrap: anywhere; }
#readyRaces { margin: 14px 0; }
#readyRaces h2 { margin-bottom: 4px; font-size: 15px; }
.tag { display: inline-block; border: 1px solid var(--border); border-radius: 100px; background: var(--inset); padding: 4px 7px; font-size: 12px; color: var(--muted); text-align: center; line-height: 1.25; flex: 0 0 auto; }
.tag.good, .positive { color: var(--green); }
.tag.warn, .caution { color: var(--amber); }
.tag.bad, .negative { color: var(--red); }
.section-line { display: flex; align-items: start; justify-content: space-between; gap: 7px; }
.section-line :is(h2,h3,h4) { min-width: 0; margin: 0; overflow-wrap: anywhere; }
.source-list { display: grid; gap: 3px; margin: 8px 0 10px; font-size: 13px; }
.source-list div { display: grid; grid-template-columns: minmax(0, 6.6em) minmax(0, 1fr); gap: 4px; padding: 4px 7px; border-bottom: 1px solid var(--border); }
.source-list dd { margin: 0; color: var(--muted); overflow-wrap: anywhere; }
.result-peek { background: var(--inset); padding: 8px; border-radius: 8px; color: var(--accent); font-size: 14px; }
.metric { padding: 7px; border-radius: 9px; background: var(--inset); overflow-wrap: anywhere; }
.metric span { display: block; color: var(--muted); font-size: 11px; }
.metric strong { display: block; font-variant-numeric: tabular-nums; font-size: 17px; }
.settlement { padding: 9px; margin: 8px 0; border-radius: 9px; border: 1px solid var(--border); background: #172940; }
.settlement p { margin: 4px 0 7px; overflow-wrap: anywhere; }
.table-frame { overflow: auto; margin-bottom: 7px; }
table { width: 100%; border-collapse: collapse; font-size: 13px; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 6px 3px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
th:not(:first-child), td:not(:first-child) { text-align: right; }
td:first-child { color: var(--accent); font-weight: 750; }
#forecastComparison th[scope="row"], #statsTable th[scope="row"] { width: 43%; }
#forecastComparison td, #statsTable td { padding-left: 7px; font-weight: 650; }
.pending-panel { margin: 10px 0 14px; padding: 9px; border: 1px solid var(--border); border-radius: 10px; background: var(--inset); }
#pendingStatus { white-space: pre-line; overflow-wrap: anywhere; }
#pendingStatus:empty { margin: 0; }
#pendingDetails { margin-top: 7px; padding-bottom: 0; }
.pending-list { margin: 0; padding: 0; list-style: none; }
.pending-list li { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 5px 9px; padding: 7px 0; }
.pending-list li + li { border-top: 1px solid var(--border); }
.pending-list strong { font-size: 13px; }
.pending-states { display: flex; flex-wrap: wrap; gap: 4px; }
details { border-top: 1px solid var(--border); padding: 7px 0; }
summary { cursor: pointer; padding: 6px 0; font-weight: 650; }
.boat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.boat { padding: 6px; border-radius: 8px; background: var(--inset); overflow-wrap: anywhere; }
.boat small { display: block; color: var(--muted); }
.history-item { border: 1px solid var(--border); border-radius: 10px; padding: 9px; margin: 7px 0; }
.history-item h3 { margin: 0; }
.history-item p { font-size: 13px; margin: 5px 0; overflow-wrap: anywhere; }
.history-item details { padding-bottom: 0; }
#showMoreHistory { margin-bottom: 8px; }
.file-action { display: flex; align-items: center; justify-content: center; text-align: center; }
.backup-actions:has(input:focus-visible) .file-action { outline: 3px solid #c7e2ff; outline-offset: 3px; }
.visually-hidden { position: absolute; overflow: hidden; width: 1px; height: 1px; padding: 0; margin: -1px; clip-path: inset(50%); border: 0; }
.backup-link { display: inline-block; color: var(--accent); margin-top: 7px; padding: 7px 0; }
footer { padding: 0 2px; }
@media (min-width: 570px) {
  .panel { padding: 17px; }
  .comparison-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .comparison-fields > label:last-child { grid-column: auto; }
  .race-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .boat-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}

.pair-trial { margin-block: 16px 12px; padding-top: 12px; border-top: 1px solid var(--border); }
#pairTrialTable th[scope="row"] { width: 32%; }
#pairTrialTable th, #pairTrialTable td { overflow-wrap: anywhere; }
#forecastPairTrial { margin-block: 8px 12px; }
