/* 先取り貯金と、残る額の計算 — スマートフォンを先に。外のフォントは使わない（朝の道具と同じ作り）。 */
:root {
  --ink: #1f2328;
  --muted: #4a525c;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #c9cfd6;
  --accent: #0b5cad;
  --accent-ink: #ffffff;
  --err: #b3261e;
  --focus: #ffbf47;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Noto Sans CJK JP", "Noto Sans JP", "Yu Gothic UI", "Yu Gothic", Meiryo, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
  color: var(--ink);
  background: var(--bg);
}
a { color: var(--accent); }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; box-shadow: 0 0 0 5px var(--ink); }
.skip { position: absolute; left: -9999px; top: 0; background: var(--panel); padding: .5rem 1rem; z-index: 10; }
.skip:focus { left: .5rem; top: .5rem; }

.site-header, main, .site-footer { max-width: 48rem; margin: 0 auto; padding: 0 1rem; }
.site-header { padding-top: 1.25rem; }
h1 { font-size: 1.45rem; line-height: 1.4; margin: 0 0 .5rem; }
h2 { font-size: 1.2rem; margin: 0 0 .75rem; }
h3 { font-size: 1rem; margin: 0 0 .5rem; }
.lead { margin: 0 0 1rem; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: .75rem; padding: 1rem; margin: 0 0 1rem; }
.notice-panel p { margin: 0 0 .5rem; }
.notice-panel p:last-child { margin-bottom: 0; }
.hint { color: var(--muted); font-size: .95rem; margin: .25rem 0 .75rem; }

.field { margin: 0 0 1rem; }
.field > label, fieldset.group > label, fieldset.group > legend { display: block; font-weight: 700; margin-bottom: .25rem; }
fieldset.group { border: 0; padding: 0; }
fieldset.group > legend { padding: 0; }
.radios { display: flex; flex-wrap: wrap; gap: .25rem 1.25rem; margin-bottom: .5rem; }
.field.check { display: flex; gap: .5rem; align-items: center; margin: 0; }
.field.check > label { display: inline; margin: 0; font-weight: 400; }
input, select, button { font: inherit; color: inherit; }
input[type="text"], select {
  min-height: 2.75rem; padding: .4rem .6rem; border: 1px solid #6b737d; border-radius: .5rem; background: #fff; width: 100%;
}
input[type="radio"] { width: 1.3rem; height: 1.3rem; accent-color: var(--accent); }
.yen-wrap { display: flex; align-items: center; gap: .4rem; }
.yen-wrap input { max-width: 14rem; }
[aria-invalid="true"] { border-color: var(--err); border-width: 2px; }
.err { color: var(--err); font-weight: 700; margin: .25rem 0 0; font-size: .95rem; }

details.opt { border: 1px solid var(--line); border-radius: .6rem; padding: .5rem .75rem; margin: 0 0 1rem; background: #fbfcfd; }
details.opt > summary { cursor: pointer; font-weight: 700; min-height: 2.75rem; display: flex; align-items: center; }
details.opt[open] > summary { margin-bottom: .5rem; }
.split-grid { display: grid; grid-template-columns: 1fr; gap: .5rem; margin-bottom: .75rem; }
.split-grid label, .row-grid label, .other-wrap label { display: block; font-size: .95rem; font-weight: 700; }
.rows { list-style: none; margin: 0; padding: 0; }
.row { border: 1px solid var(--line); border-radius: .6rem; padding: .75rem; margin: 0 0 .75rem; background: #fff; }
.row-no { font-weight: 700; margin: 0 0 .25rem; }
.row-grid { display: grid; grid-template-columns: 1fr; gap: .5rem; }
.other-wrap { margin-top: .5rem; }
.other-wrap input { max-width: 14rem; }

.btn {
  min-height: 2.75rem; padding: .45rem 1rem; border-radius: .5rem; border: 1px solid var(--accent);
  background: #fff; color: var(--accent); font-weight: 700; cursor: pointer;
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: 1rem 0 0; }
.status { min-height: 1.7em; margin: .75rem 0 0; }

.error-summary { border: 2px solid var(--err); border-radius: .6rem; padding: .75rem 1rem; margin: 0 0 1rem; }
.error-summary h3 { color: var(--err); }
.error-summary ul { margin: 0; padding-left: 1.2rem; }

/* 結果：どの行も同じ大きさ・同じ色（6章の13） */
.results { margin: 0; }
.res { border-bottom: 1px solid var(--line); padding: .5rem 0; }
.res:last-child { border-bottom: 0; }
.res dt { color: var(--muted); font-weight: 700; font-size: 1rem; }
.res dd { margin: 0; color: var(--ink); font-size: 1.6rem; font-weight: 800; line-height: 1.3; font-variant-numeric: tabular-nums; }
.res[hidden] { display: none; }
/* 結果のそばの短い添え書き（「何か月かかるか」の切り上げ） */
.res dd.res-note { color: var(--muted); font-size: .95rem; font-weight: 400; line-height: 1.5; margin-top: .15rem; }

.print-mark { display: none; }
.preview { margin-top: 1rem; }
.preview img { max-width: 100%; height: auto; border: 1px solid var(--line); border-radius: .5rem; }

.site-footer { padding-bottom: 2rem; color: var(--muted); font-size: .95rem; }
.site-footer p { margin: 0 0 .25rem; }

@media (min-width: 40rem) {
  h1 { font-size: 1.8rem; }
  .split-grid { grid-template-columns: 1fr 1fr; }
  .row-grid { grid-template-columns: minmax(0, 1fr) 9rem 12rem; align-items: end; }
}

/* 印刷：結果だけを、A4の1枚に */
@page { size: A4; margin: 12mm; }
@media print {
  body { background: #fff; font-size: 11pt; line-height: 1.45; }
  .skip, .site-header, .notice-panel, .no-print, #main > section:not(.output), .site-footer, .preview { display: none !important; }
  main { max-width: none; padding: 0; }
  .panel { border: 0; padding: 0; margin: 0; }
  .res dd { font-size: 18pt; }
  .res dd.res-note { font-size: 10pt; }
  .print-mark { display: block; text-align: right; font-size: 8pt; color: #4a525c; margin: 2mm 0 0; }
  a { color: inherit; text-decoration: none; }
}
/* 1段落だけのパネル（感想の注意）の余白 */
.panel > p:only-child { margin: 0; }
