:root {
  color-scheme: light;
  --paper: #f5f4ef;
  --surface: #fbfaf6;
  --ink: #222824;
  --muted: #687069;
  --line: #cfd3cc;
  --line-strong: #9fa79f;
  --accent: #245b49;
  --accent-soft: #e2ebe5;
  --danger: #9b2f2f;
  --measure: 1120px;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; color: var(--ink); background: var(--paper); line-height: 1.65; }
button, input { font: inherit; }
a { color: inherit; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.eyebrow, .section-kicker { margin: 0 0 5px; color: var(--accent); font-size: .78rem; font-weight: 780; letter-spacing: .08em; text-transform: uppercase; }
h2 { margin: 0; font-size: clamp(1.2rem, 2vw, 1.48rem); line-height: 1.35; }

.tool-shell { display: grid; grid-template-columns: minmax(0, .92fr) minmax(0, 1.08fr); border: 1px solid var(--line-strong); background: var(--surface); }
.calculator-panel, .motion-panel { min-width: 0; padding: 24px; }
.calculator-panel { border-right: 1px solid var(--line); }
.mode-fieldset { margin: 17px 0 21px; padding: 0; border: 0; }
.mode-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.mode-option { position: relative; display: block; cursor: pointer; }
.mode-option input { position: absolute; opacity: 0; }
.mode-option span { min-height: 50px; display: grid; place-items: center; padding: 7px 8px; border: 1px solid var(--line); background: var(--surface); color: var(--muted); text-align: center; font-size: .86rem; font-weight: 700; line-height: 1.35; }
.mode-option input:checked + span { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.mode-option input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.input-grid { display: grid; gap: 13px; }
.input-row label { display: block; margin-bottom: 5px; font-weight: 700; }
.input-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: stretch; }
.input-wrap input { width: 100%; min-width: 0; border: 1px solid var(--line-strong); padding: 10px 11px; color: var(--ink); background: var(--surface); }
.input-wrap input[aria-invalid="true"] { border-color: var(--danger); background: #fff8f8; }
.unit { min-width: 62px; display: grid; place-items: center; padding: 0 10px; border: 1px solid var(--line-strong); border-left: 0; background: var(--paper); color: var(--muted); font-weight: 700; }
.field-error { min-height: 1.25em; margin: 4px 0 0; color: var(--danger); font-size: .82rem; }
.form-error { margin: 12px 0 0; padding: 8px 10px; border-left: 4px solid var(--danger); background: #f8e9e7; color: #762525; }
.form-actions { display: flex; gap: 8px; margin-top: 17px; }
.button { min-height: 42px; border: 1px solid var(--accent); border-radius: 2px; padding: 8px 15px; cursor: pointer; font-weight: 760; }
.button-primary { background: var(--accent); color: #fff; }
.button-primary:hover { background: #1b4738; }
.button-secondary, .button-small { background: var(--surface); color: var(--accent); }
.button:hover:not(:disabled) { border-color: var(--ink); }
.button:disabled { border-color: var(--line); background: var(--paper); color: #8a918b; cursor: not-allowed; }
.result-box { margin-top: 20px; padding: 15px 16px; border: 1px solid var(--accent); border-left-width: 4px; background: var(--accent-soft); }
.result-label { margin: 0; color: var(--accent); font-size: .8rem; font-weight: 780; }
.result-value { margin-top: 2px; font-size: clamp(1.55rem, 3.4vw, 2.15rem); line-height: 1.28; font-weight: 780; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.result-formula { margin: 5px 0 0; color: #3f4c46; font-size: .9rem; overflow-wrap: anywhere; }

.motion-heading-row { display: flex; justify-content: space-between; align-items: flex-start; gap: 14px; }
.status-badge { flex: 0 0 auto; padding: 3px 8px; border: 1px solid var(--line-strong); background: var(--paper); color: var(--muted); font-size: .75rem; font-weight: 760; }
.status-badge[data-state="ready"], .status-badge[data-state="complete"] { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.status-badge[data-state="playing"] { border-color: var(--accent); color: var(--accent); }
.status-badge[data-state="paused"] { border-color: var(--line-strong); background: var(--paper); color: var(--ink); }
.motion-summary { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin: 15px 0 0; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.motion-summary[hidden] { display: none; }
.motion-summary div { min-width: 0; padding: 9px 11px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.motion-summary dt { color: var(--muted); font-size: .76rem; font-weight: 750; }
.motion-summary dd { margin: 2px 0 0; color: var(--ink); font-size: .88rem; font-weight: 700; overflow-wrap: anywhere; }
.canvas-frame { margin-top: 15px; overflow: hidden; border: 1px solid var(--line-strong); background: var(--paper); }
canvas { display: block; width: 100%; }
.canvas-description { min-height: 3.25em; margin: 11px 0 0; color: #38413b; font-size: .9rem; }
.normalization-note { margin: 7px 0 0; padding-left: 11px; border-left: 3px solid var(--line-strong); color: var(--muted); font-size: .78rem; }
.motion-details { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); margin-top: 10px; border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.motion-details[hidden] { display: none; }
.motion-details section { min-width: 0; padding: 9px 11px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.motion-details h3 { margin: 0; color: var(--muted); font-size: .76rem; }
.motion-details p { margin: 3px 0 0; color: var(--ink); font-size: .84rem; font-weight: 650; overflow-wrap: anywhere; }
.motion-controls { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 13px; }
.button-small { min-height: 38px; padding: 6px 12px; font-size: .87rem; }

.content-section { margin-top: 30px; padding-top: 25px; border-top: 1px solid var(--line-strong); }
.section-heading { margin-bottom: 15px; }
.steps-list { display: grid; grid-template-columns: repeat(4, 1fr); gap: 0; margin: 0; padding: 0; border-block: 1px solid var(--line); list-style: none; counter-reset: steps; }
.steps-list li { position: relative; min-width: 0; padding: 35px 12px 13px; border-right: 1px solid var(--line); background: transparent; counter-increment: steps; font-size: .88rem; overflow-wrap: anywhere; }
.steps-list li:last-child { border-right: 0; }
.steps-list li::before { content: counter(steps, decimal-leading-zero); position: absolute; top: 7px; left: 12px; color: var(--accent); font-size: .75rem; font-weight: 800; }
.proof-guide { margin-top: 18px; border: 1px solid var(--line); }
.proof-guide h3 { margin: 0; padding: 10px 13px; border-bottom: 1px solid var(--line); color: var(--accent); font-size: .92rem; }
.proof-guide ul { display: grid; grid-template-columns: repeat(2, 1fr); margin: 0; padding: 0; list-style: none; }
.proof-guide li { padding: 10px 13px 10px 30px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); color: var(--muted); font-size: .86rem; }
.proof-guide li:nth-child(2n) { border-right: 0; }
.proof-guide li:nth-last-child(-n + 2) { border-bottom: 0; }
.proof-guide li::before { content: '—'; margin-left: -17px; margin-right: 7px; color: var(--accent); }
.formula-list { display: grid; grid-template-columns: repeat(3, 1fr); border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.formula-list div { display: grid; gap: 3px; padding: 12px 13px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.formula-list span { color: var(--muted); }
.method-note { margin: 13px 0 0; color: var(--muted); }
@media (max-width: 900px) {.tool-shell { grid-template-columns: 1fr; }
  .calculator-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .steps-list { grid-template-columns: repeat(2, 1fr); }
  .steps-list li { border-bottom: 1px solid var(--line); }
}
@media (max-width: 700px) {.formula-list { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {.calculator-panel, .motion-panel { padding: 17px 14px; }
  .mode-options { grid-template-columns: 1fr; }
  .mode-option span { min-height: 44px; padding: 6px; font-size: .84rem; }
  .form-actions { display: grid; grid-template-columns: 1fr; }
  .button { width: 100%; }
  .motion-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .motion-controls .button:last-child { grid-column: 1 / -1; }
  .motion-summary, .motion-details { grid-template-columns: 1fr; }
  .proof-guide ul { grid-template-columns: 1fr; }
  .proof-guide li, .proof-guide li:nth-child(2n), .proof-guide li:nth-last-child(-n + 2) { border-right: 0; border-bottom: 1px solid var(--line); }
  .proof-guide li:last-child { border-bottom: 0; }
  .steps-list { grid-template-columns: 1fr; }
  .steps-list li { border-right: 0; }
}
@media (prefers-reduced-motion: reduce) {html { scroll-behavior: auto; }
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
