/* こどもNISA 学年別シミュレーター。スマホ幅（390px）を先に作り、広い画面では中央に寄せるだけ。
   文字と背景の色の差は 4.5:1 以上、文字は 13px 以上、押す場所は 44px 以上。 */
:root {
  color-scheme: light;
  --bg: #f7f5ef;
  --panel: #ffffff;
  --ink: #1e2a2c;
  --muted: #4a5658;
  --line: #d6d2c6;
  --accent: #1c6a4e;
  --accent-ink: #ffffff;
  --accent-soft: #e5f1eb;
  --hl: #fff0c2;
  --hl-line: #b07a00;
  --warn: #8a3a12;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-size: 16px;
  line-height: 1.7;
}
.wrap { max-width: 560px; margin: 0 auto; padding: 16px; }
body { padding-bottom: 96px; } /* 帯の高さが分かったら app.js が置きかえる */
h1 { font-size: 24px; line-height: 1.35; margin: 8px 0 12px; letter-spacing: 0.02em; }
h2 { font-size: 18px; margin: 0 0 12px; }
.lead { margin: 0 0 8px; }
.privacy { margin: 0 0 16px; font-size: 14px; color: var(--muted); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 16px; margin: 0 0 16px; }
fieldset { border: 0; padding: 0; margin: 0 0 20px; min-width: 0; }
fieldset:last-child { margin-bottom: 0; }
legend { font-weight: 700; font-size: 17px; padding: 0; margin: 0 0 10px; display: flex; align-items: center; gap: 8px; }
.step { display: inline-flex; align-items: center; justify-content: center; flex: none; width: 1.6em; height: 1.6em; border-radius: 50%; background: var(--accent); color: var(--accent-ink); font-size: 14px; }

.chips { display: grid; gap: 8px; margin: 0 0 10px; }
.chips-3 { grid-template-columns: repeat(auto-fit, minmax(76px, 1fr)); }
.chips-4 { grid-template-columns: repeat(auto-fit, minmax(64px, 1fr)); }
.chip { position: relative; display: block; }
.chip input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; }
.chip span {
  display: flex; align-items: center; justify-content: center; text-align: center;
  min-height: 48px; padding: 6px 2px; border: 1.5px solid var(--line); border-radius: 10px;
  background: var(--panel); color: var(--ink); font-size: 15px; font-weight: 600; line-height: 1.3; cursor: pointer; word-break: keep-all; overflow-wrap: anywhere;
}
.chip input:checked + span { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.chip input:focus-visible + span { outline: 3px solid var(--hl-line); outline-offset: 2px; }

.check { display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 4px 0; cursor: pointer; }
.check input { width: 24px; height: 24px; margin: 0; accent-color: var(--accent); flex: none; }
.check input:disabled + span { color: var(--muted); }
.field-label { display: block; font-weight: 600; margin: 4px 0 6px; }
.select, .text {
  display: block; width: 100%; min-height: 48px; padding: 8px 12px; font-size: 16px; color: var(--ink);
  background: var(--panel); border: 1.5px solid var(--line); border-radius: 10px;
}
.select:focus-visible, .text:focus-visible { outline: 3px solid var(--hl-line); outline-offset: 1px; }
.hint { font-size: 14px; color: var(--muted); margin: 6px 0 0; }
.error { color: var(--warn); font-size: 14px; margin: 6px 0 0; min-height: 0; }
.error:empty { display: none; }

.result { border: 2px solid var(--accent); }
.who { margin: 0 0 8px; font-size: 14px; color: var(--muted); }
.big { margin: 0 0 12px; padding: 12px; border-radius: 10px; background: var(--accent-soft); display: flex; flex-direction: column; }
.big-label { font-size: 14px; color: var(--ink); }
.big-num { font-size: 32px; font-weight: 800; color: var(--accent); line-height: 1.25; }
.big-sub { font-size: 15px; }
.facts { list-style: none; margin: 0; padding: 0; }
.facts li { margin: 0; }
.facts li:not(.sub) { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 0 12px; padding: 10px 0 2px; border-top: 1px solid var(--line); }
.facts li:first-child { border-top: 0; }
.facts .k { font-size: 15px; }
.facts .v { font-size: 20px; font-weight: 800; margin-left: auto; }
.facts li.sub { font-size: 14px; color: var(--muted); padding: 0 0 8px; }
.cond { font-size: 14px; margin: 10px 0 0; padding: 10px 12px; border-left: 4px solid var(--hl-line); background: #fff8e3; }

.table-wrap { margin-top: 12px; overflow-x: auto; max-width: 100%; }
.table-wrap:focus-visible { outline: 3px solid var(--hl-line); outline-offset: 2px; }
.quick { width: 100%; border-collapse: collapse; font-size: 14px; }
.quick th, .quick td { text-align: left; padding: 8px 6px; border-bottom: 1px solid var(--line); vertical-align: top; }
.quick thead th { font-size: 13px; color: var(--muted); font-weight: 600; }
.quick tbody th { font-weight: 600; }
.quick td { min-width: 6em; }
.quick .main { display: block; }
.quick .early { display: block; font-size: 13px; color: var(--muted); }
.quick tr.is-current th, .quick tr.is-current td { background: var(--hl); }
.quick tr.is-current th { box-shadow: inset 4px 0 0 var(--hl-line); }
.quick tr.is-current .early { color: var(--ink); }
.quick .cur-val { font-weight: 800; }
.badge { display: inline-block; margin-left: 6px; padding: 0 6px; border-radius: 6px; background: var(--ink); color: #ffffff; font-size: 13px; font-weight: 600; line-height: 1.6; }

.notes ul { margin: 0 0 12px; padding-left: 1.2em; }
.notes .must li { font-weight: 700; }
.notes .how li { font-size: 14px; color: var(--muted); margin-bottom: 4px; }
.sources { margin: 8px 0 0; padding-left: 1.2em; font-size: 13px; }
.sources li { margin-bottom: 8px; }
.src-head { display: block; font-weight: 600; }
.src-body { display: block; color: var(--muted); overflow-wrap: anywhere; }
[hidden] { display: none !important; }

/* JavaScript が動かないとき・数字を読み込めなかったときは、数字が抜けた文や動かない入力を出さない */
html:not(.js) .needs-js, html.load-failed .needs-js { display: none !important; }
.noscript { font-weight: 700; color: var(--warn); }
/* 読み込みに失敗したときの案内。正常なら app.js が html に ready を付けて消す。
   画面が出る前の一瞬に見えないよう、1.5秒たってから見せる（数字が読めないと分かったときはすぐ見せる） */
.load-error {
  position: fixed; left: 16px; right: 16px; top: 16px; z-index: 20; margin: 0;
  padding: 16px; border-radius: 12px; border: 2px solid var(--warn); background: #ffffff;
  font-weight: 700; color: var(--warn); visibility: hidden; animation: appear-late 0s linear 1.5s forwards;
}
@keyframes appear-late { to { visibility: visible; } }
html.ready .load-error { display: none; }
html.load-failed .load-error { animation: none; visibility: visible; }

.mini { margin: 4px 0 0; font-weight: 700; color: var(--accent); }
.mini:empty { display: none; }
.calc-note { font-size: 13px; color: var(--muted); margin-top: 2px; }
.assume { font-size: 14px; color: var(--muted); margin: 12px 0 0; }
.decide { font-weight: 700; margin: 12px 0 0; }
.end-notes { margin: 8px 0 0; padding-left: 1.2em; font-size: 14px; }

/* 画面の下に固定する要約の帯（押す場所ではないので、下の要素の操作を邪魔しない） */
.summary {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; pointer-events: none;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--accent); color: var(--accent-ink); font-weight: 700; font-size: 16px; line-height: 1.4; text-align: center;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.15);
}
.summary:empty, .summary.is-away { display: none; }

/* 画面の外にある欄は、見えるまでレイアウトを後回しにする（最初の処理を軽くするため） */
.later { content-visibility: auto; contain-intrinsic-size: auto 800px; }
