:root {
  --ink: #1d211f;
  --muted: #68706b;
  --line: #d9ddd7;
  --paper: #f4f1e9;
  --paper-deep: #eae5d8;
  --white: #fffdf8;
  --mustard: #d4a72c;
  --mustard-soft: #f4e4ae;
  --red: #a13c2b;
  --green: #1d674c;
  --shadow: 0 14px 34px rgba(29, 33, 31, 0.08);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  font-synthesis: none;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; min-width: 320px; background: var(--paper); line-height: 1.6; }
body, button, input, select { color: var(--ink); }
button, input, select { font: inherit; }
button { cursor: pointer; }
img { max-width: 100%; display: block; }
.shell { width: min(1160px, calc(100% - 40px)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }
.skip-link { position: fixed; left: 12px; top: -60px; z-index: 10; padding: 10px 14px; background: var(--ink); color: white; }
.skip-link:focus { top: 12px; }

.site-header { border-bottom: 1px solid rgba(29, 33, 31, 0.12); background: var(--paper); }
.header-inner { min-height: 64px; display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: 0.02em; }
.brand-mark { display: grid; place-items: center; width: 28px; height: 28px; background: var(--mustard); font-size: 0; transform: rotate(-6deg); }
.brand-mark::after { content: ""; width: 10px; height: 10px; border: 2px solid var(--ink); }
.header-note { color: var(--muted); font-size: 0.82rem; }

.hero { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(300px, 0.96fr); gap: 56px; align-items: center; min-height: 460px; padding-block: 64px 72px; }
.eyebrow { margin: 0 0 10px; color: #7b5e12; font-size: 0.72rem; font-weight: 800; letter-spacing: 0.16em; }
h1, h2, h3, p { margin-top: 0; }
h1 { max-width: 630px; margin-bottom: 22px; font-size: clamp(2.4rem, 5.4vw, 4.6rem); line-height: 1.08; letter-spacing: -0.06em; }
.accent-underline { text-decoration: underline; text-decoration-color: var(--mustard); text-decoration-thickness: 0.18em; text-underline-offset: 0.13em; }
.hero-lead { max-width: 540px; margin-bottom: 26px; color: #414a44; font-size: clamp(1rem, 2vw, 1.2rem); }
.example-note { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; width: fit-content; max-width: 100%; padding: 15px 18px; border-left: 5px solid var(--mustard); background: var(--white); box-shadow: 8px 8px 0 var(--paper-deep); }
.example-label { grid-row: span 2; align-self: start; color: #7b5e12; font-size: 0.73rem; font-weight: 800; letter-spacing: 0.08em; }
.example-note strong { font-size: 0.98rem; }
.example-note span:last-child { color: var(--muted); font-size: 0.84rem; }
.hero-art { position: relative; min-height: 300px; background: var(--paper-deep); box-shadow: 18px 18px 0 var(--mustard); overflow: hidden; }
.hero-art img { width: 100%; height: 100%; min-height: 300px; object-fit: cover; mix-blend-mode: multiply; }
.art-caption { position: absolute; right: 14px; bottom: 12px; padding: 4px 8px; background: var(--ink); color: var(--white); font-size: 0.73rem; }

.app-shell, .results-section, .comparison-section, .notes-section { padding-block: 34px 20px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 22px; }
.section-heading h2 { margin-bottom: 0; font-size: clamp(1.65rem, 3vw, 2.35rem); letter-spacing: -0.04em; }
.section-hint { margin: 0 0 4px; color: var(--muted); font-size: 0.9rem; }
.panel { background: var(--white); border: 1px solid var(--line); box-shadow: var(--shadow); }
.settings-panel { padding: 24px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 18px; }
.panel-heading > div { display: flex; align-items: center; gap: 12px; }
.panel-heading h3 { margin: 0; font-size: 1.2rem; }
.panel-heading p { margin: 0; color: var(--muted); font-size: 0.82rem; }
.step-number { color: #7b5e12; font-size: 0.75rem; font-weight: 900; letter-spacing: 0.05em; }
.settings-fields { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(180px, 0.7fr); gap: 20px; }
.field { min-width: 0; }
.field label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; margin-bottom: 7px; font-size: 0.85rem; font-weight: 750; }
.unit { color: var(--muted); font-size: 0.75rem; font-weight: 500; }
input, select { width: 100%; min-height: 48px; padding: 9px 12px; border: 1px solid #aeb7af; border-radius: 2px; background: #fff; font-size: 16px; }
input:focus, select:focus, button:focus-visible, a:focus-visible { outline: 3px solid rgba(212, 167, 44, 0.65); outline-offset: 2px; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: var(--red); background: #fff9f7; }
.field-help { margin: 7px 0 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.field-error, .panel-error, .form-error { min-height: 1.35em; margin: 5px 0 0; color: var(--red); font-size: 0.78rem; }
.panel-error { margin-top: 15px; }

.scenario-section { padding-top: 34px; }
.scenario-heading { margin-bottom: 14px; }
.scenario-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.scenario-card { min-width: 0; margin: 0; padding: 18px; border: 1px solid var(--line); background: rgba(255, 253, 248, 0.72); }
.scenario-card legend { display: flex; align-items: center; gap: 10px; width: 100%; margin-bottom: 17px; padding: 0; font-weight: 800; }
.scenario-id { display: grid; place-items: center; width: 32px; height: 32px; background: var(--mustard); font-weight: 900; }
.scenario-fields { display: grid; gap: 8px; }
.scenario-card .field label { margin-bottom: 4px; }
.scenario-card input { min-height: 44px; padding-block: 7px; }
.scenario-card .field-error { min-height: 1.15em; margin-top: 2px; }
.form-error { margin-top: 10px; font-weight: 700; }

.results-section { padding-top: 56px; }
.notice { margin: 0 0 4px; color: var(--muted); font-size: 0.86rem; }
.notice-warning { color: var(--red); }
.notice-success { color: var(--green); }
.results-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }
.result-card { min-width: 0; padding: 20px; border: 1px solid var(--line); background: var(--white); box-shadow: 8px 8px 0 var(--paper-deep); }
.result-card.is-negative { border-color: #c8887b; }
.result-card-invalid { min-height: 260px; }
.result-card-heading { display: flex; align-items: start; justify-content: space-between; gap: 10px; margin-bottom: 18px; }
.result-card-heading h3 { margin: 0; font-size: 1.15rem; }
.result-card-heading .eyebrow { margin-bottom: 3px; }
.result-badge { flex: 0 0 auto; padding: 3px 7px; background: var(--mustard-soft); color: #72550c; font-size: 0.7rem; font-weight: 800; }
.result-badge.is-invalid { background: #f3d7d0; color: var(--red); }
.result-message { color: var(--muted); }
.metric-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0; }
.metric-card { min-width: 0; padding: 10px; background: #f5f3ec; }
.metric-card dt { color: var(--muted); font-size: 0.72rem; line-height: 1.35; }
.metric-card dd { margin: 3px 0 0; font-size: 1rem; font-weight: 850; overflow-wrap: anywhere; }
.metric-card-primary { grid-column: 1 / -1; background: var(--ink); color: var(--white); }
.metric-card-primary dt { color: #c8d0c9; }
.metric-unavailable { display: block; color: var(--red); font-size: 0.76rem; line-height: 1.35; }
.result-footnote { margin: 16px 0 0; color: var(--muted); font-size: 0.74rem; }

.comparison-section { padding-top: 56px; }
.table-wrap { overflow-x: auto; border: 1px solid var(--line); background: var(--white); }
table { width: 100%; min-width: 660px; border-collapse: collapse; text-align: right; }
th, td { padding: 13px 15px; border-bottom: 1px solid var(--line); white-space: nowrap; }
thead th { background: var(--ink); color: var(--white); font-size: 0.77rem; font-weight: 700; }
tbody th { text-align: left; font-size: 0.88rem; }
tbody td { font-variant-numeric: tabular-nums; font-size: 0.9rem; }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
.table-muted { color: var(--muted); text-align: left; }
.action-panel { display: grid; grid-template-columns: minmax(0, 0.95fr) minmax(0, 1.6fr); gap: 20px; align-items: center; margin-top: 20px; padding: 22px 24px; }
.action-panel h3 { margin: 0 0 3px; font-size: 1.2rem; }
.action-panel p { margin-bottom: 0; color: var(--muted); font-size: 0.84rem; }
.action-buttons { display: flex; flex-wrap: wrap; justify-content: end; gap: 8px; }
.button { min-height: 44px; padding: 8px 13px; border: 1px solid #9ea8a0; border-radius: 2px; background: var(--white); font-size: 0.84rem; font-weight: 750; }
.button:hover { background: var(--paper-deep); }
.button-primary { border-color: var(--ink); background: var(--ink); color: var(--white); }
.button-primary:hover { background: #39403b; }
.button-quiet { color: var(--muted); }
.storage-status { grid-column: 2; min-height: 1.2em; margin-top: 0 !important; }
.storage-status.is-success { color: var(--green); }
.storage-status.is-error { color: var(--red); }

.notes-section { padding-top: 56px; padding-bottom: 72px; }
.notes-card { padding: 28px; background: var(--paper-deep); border-top: 4px solid var(--mustard); }
.notes-card h2 { margin-bottom: 22px; font-size: 1.65rem; }
.notes-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 25px; }
.notes-grid h3 { margin-bottom: 5px; font-size: 0.98rem; }
.notes-grid p { margin: 0; color: #4f5851; font-size: 0.85rem; }
.site-footer { border-top: 1px solid rgba(29, 33, 31, 0.12); padding-block: 22px; color: var(--muted); font-size: 0.78rem; }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; gap: 30px; padding-block: 50px 56px; }
  .hero-art { width: min(100%, 620px); min-height: 240px; box-shadow: 12px 12px 0 var(--mustard); }
  .hero-art img { min-height: 240px; }
  .scenario-grid, .results-grid { grid-template-columns: 1fr; }
  .scenario-card { max-width: none; }
  .result-card { box-shadow: 6px 6px 0 var(--paper-deep); }
  .action-panel { grid-template-columns: 1fr; }
  .action-buttons { justify-content: start; }
  .storage-status { grid-column: auto; }
}

@media (max-width: 560px) {
  .shell { width: min(100% - 24px, 1160px); }
  .header-inner { min-height: 56px; }
  .header-note { display: none; }
  .hero { min-height: 0; padding-block: 38px 46px; }
  h1 { font-size: clamp(2.2rem, 13vw, 3.3rem); }
  .example-note { grid-template-columns: 1fr; gap: 3px; }
  .example-label { grid-row: auto; }
  .hero-art { min-height: 190px; }
  .hero-art img { min-height: 190px; }
  .section-heading { align-items: start; flex-direction: column; gap: 8px; }
  .settings-panel, .action-panel, .notes-card { padding: 18px; }
  .settings-fields { grid-template-columns: 1fr; gap: 12px; }
  .scenario-card { padding: 15px; }
  .metric-grid { gap: 6px; }
  .metric-card { padding: 9px; }
  .metric-card dd { font-size: 0.9rem; }
  .notes-grid { grid-template-columns: 1fr; gap: 17px; }
  .action-buttons { display: grid; grid-template-columns: 1fr 1fr; }
  .action-buttons .button { width: 100%; }
}

@media print {
  :root { background: white; }
  body { background: white; }
  .site-header, .hero-art, .action-panel, .site-footer, .skip-link { display: none !important; }
  .hero { display: block; min-height: 0; padding-block: 20px; }
  .app-shell, .results-section, .comparison-section, .notes-section { padding-block: 12px; }
  .panel, .result-card, .notes-card { box-shadow: none; }
  input, select { border-color: #999; }
}
