/* 金額の数字だけに使う明朝 (Shippori Mincho B1 Bold から数字と「万・億・円・人」などだけを抜き出した 6KB の字体。SIL OFL 1.1)
   ほかの文字は unicode-range から外れるので、端末の明朝で表示される */
@font-face {
  font-family: "TsumitateFigures";
  src: url("fonts/figures-700.woff2") format("woff2");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
  unicode-range: U+0020, U+0025, U+0028-0029, U+002B-002E, U+0030-0039, U+007E, U+2212, U+301C, U+FF08-FF09, U+4E07, U+5104, U+5186, U+4EBA, U+5E74, U+6708, U+6B73, U+500D, U+672A, U+6E80, U+4EE5, U+4E0A, U+7D04;
}

/* 通帳と和文帳簿を下敷きにした配色: 薄い青磁の紙、墨、良い結果は朱、元本割れは藍、真ん中は山吹 */
:root {
  --paper: #ECEFEA;
  --surface: #FAFBF8;
  --ink: #1F2833;
  --muted: #56606B;
  --rule: #D3D8D0;
  --field: #FFFFFF;
  --pos: #B0392A;          /* 朱 */
  --neg: #2B4E85;          /* 藍 */
  --accent: #9A6810;       /* 山吹 (真ん中) */
  --mid-dot: #C9D0C8;
  --band: rgba(43, 78, 133, 0.13);
  --band-strong: rgba(43, 78, 133, 0.30);
  --focus: #2B4E85;
  --error: #9C2F22;
  --font-ui: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", "Yu Gothic", Meiryo, "Noto Sans JP", sans-serif;
  --font-figure: "TsumitateFigures", "Hiragino Mincho ProN", "Yu Mincho", "Noto Serif JP", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --paper: #182029;
    --surface: #1F2832;
    --ink: #E3E7E2;
    --muted: #A3ADB6;
    --rule: #33404C;
    --field: #17202A;
    --pos: #E0705F;
    --neg: #7FA3DB;
    --accent: #D9A64A;
    --mid-dot: #46535E;
    --band: rgba(127, 163, 219, 0.14);
    --band-strong: rgba(127, 163, 219, 0.32);
    --focus: #7FA3DB;
    --error: #F08A7A;
    color-scheme: dark;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: calc(env(safe-area-inset-top, 0px) + 72px); }
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 16px;
  line-height: 1.7;
  font-variant-numeric: tabular-nums;
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
button, input, select { font: inherit; color: inherit; }
a { color: var(--neg); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

/* ---------- ヘッダー ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: calc(env(safe-area-inset-top, 0px) + 12px) 24px 12px;
  background: var(--paper);
  border-bottom: 1px solid var(--rule);
}
.topbar h1 { margin: 0; font-size: 18px; font-weight: 700; letter-spacing: 0.04em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar h1 a { color: inherit; text-decoration: none; }
.topbar-link { font-size: 14px; white-space: nowrap; }

.tabs { display: none; }
.banner {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 16px;
  margin: 16px 24px 0; padding: 10px 16px;
  background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: 6px;
  font-size: 14px;
}
.banner p { margin: 0; }

/* ---------- ボタン ---------- */
.btn {
  border: 1px solid var(--rule); background: var(--surface);
  padding: 10px 18px; border-radius: 6px; cursor: pointer; white-space: nowrap;
}
.btn:hover { border-color: var(--muted); }
.btn.primary { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }
.btn.primary:hover { opacity: 0.9; }
.btn.small { padding: 6px 12px; font-size: 14px; }
.btn:disabled { opacity: 0.6; cursor: progress; }
.link { background: none; border: 0; padding: 4px 0; color: var(--neg); cursor: pointer; font-size: 14px; text-decoration: underline; text-underline-offset: 3px; }
.link.danger { color: var(--muted); }
.icon {
  flex: none; width: 36px; height: 36px; border: 1px solid transparent; border-radius: 6px;
  background: none; color: var(--muted); font-size: 20px; line-height: 1; cursor: pointer;
}
.icon:hover { border-color: var(--rule); color: var(--ink); }
.add {
  display: block; width: 100%; margin-top: 8px; padding: 10px;
  background: none; border: 1px dashed var(--rule); border-radius: 6px; color: var(--neg); cursor: pointer; font-size: 15px;
}
.add::before { content: "＋ "; }
.add:hover { border-color: var(--neg); }

/* ---------- レイアウト ---------- */
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 420px) minmax(0, 1fr);
  gap: 32px;
  max-width: 1280px;
  margin: 0 auto;
  padding: 24px 24px 48px;
  align-items: start;
}

/* ---------- 入力 ---------- */
.plan { min-width: 0; }
.step, .extras { padding: 4px 0 24px; border-bottom: 1px solid var(--rule); margin-bottom: 20px; }
.step h2, .extras h2 { margin: 0 0 6px; font-size: 19px; font-weight: 700; }
.extras h2 small { font-size: 13px; font-weight: 400; color: var(--muted); margin-left: 4px; }
.step-note { margin: 0 0 12px; font-size: 14px; color: var(--muted); }
.summary-note { margin: 14px 0 0; font-size: 14px; }

.rows { display: grid; gap: 10px; }
.row-card { background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 12px; }
.row-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.row-head select { flex: 1; min-width: 0; }
/* ファンド名が切れないように、ファンドの選択は1行使い、金額はその下に置く */
.contrib-row {
  display: grid; grid-template-columns: minmax(0, 1fr) 36px; gap: 8px; align-items: end;
  background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; padding: 10px 10px 10px 12px;
}
.contrib-row .field .lab { font-size: 12px; }
.contrib-row select { grid-column: 1; grid-row: 1; }
.contrib-row .icon { grid-column: 2; grid-row: 1; align-self: center; }
.contrib-row .field { grid-column: 1 / -1; grid-row: 2; }
.contrib-row .icon[hidden] { display: block !important; visibility: hidden; }

.fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin-top: 12px; }
.row-card .fields { margin-top: 0; }
.field { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.field.wide, .check.wide { grid-column: 1 / -1; }
.lab { font-size: 14px; font-weight: 700; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.lab small, .field > small { font-weight: 400; color: var(--muted); font-size: 12px; }
input[type="text"], select {
  width: 100%; min-height: 44px; padding: 8px 10px;
  background: var(--field); border: 1px solid var(--rule); border-radius: 6px;
}
input[type="text"] { text-align: right; }
input::placeholder { color: var(--muted); opacity: 0.8; text-align: left; }
input[type="text"]:hover, select:hover { border-color: var(--muted); }
.input-unit { display: flex; align-items: center; gap: 6px; }
.input-unit > span { flex: none; color: var(--muted); font-size: 14px; min-width: 1.2em; }
.check { display: flex; align-items: center; gap: 10px; margin-top: 4px; cursor: pointer; }
.check input { width: 20px; height: 20px; accent-color: var(--ink); flex: none; }
.check.inline { margin: 0; font-size: 14px; }

/* 条件を足す: 開くと中身、閉じていても右側に今の状態が見える */
.extra { border-top: 1px solid var(--rule); }
.extra:last-child { border-bottom: 1px solid var(--rule); }
.extra summary {
  display: flex; align-items: center; gap: 12px; min-height: 52px; padding: 8px 0;
  list-style: none; cursor: pointer;
}
.extra summary::-webkit-details-marker { display: none; }
.extra summary::after {
  content: ""; flex: none; width: 9px; height: 9px; margin: 0 4px 4px 0;
  border-right: 1.5px solid var(--muted); border-bottom: 1.5px solid var(--muted); transform: rotate(45deg);
}
.extra[open] summary::after { transform: rotate(-135deg); margin-bottom: -4px; }
.extra-name { font-weight: 700; }
.badge { margin-left: auto; font-size: 13px; color: var(--muted); text-align: right; }
.extra-body { padding: 0 0 18px; }
.extra-body.fields { margin-top: 0; }
.extra-body .fields { margin-top: 12px; }
.extra-body .rows + .add { margin-top: 10px; }

.advanced { margin-bottom: 4px; border-bottom: 1px solid var(--rule); padding-bottom: 8px; }
.advanced summary, .more summary, .table-toggle summary, .why summary { cursor: pointer; font-weight: 700; padding: 10px 0; }
.advanced[open] { padding-bottom: 20px; }
.adv-head { font-size: 15px; margin: 16px 0 0; }
.adv-head small { font-weight: 400; color: var(--muted); font-size: 12px; margin-left: 4px; }
.storage-actions { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; margin-bottom: 12px; }
.storage-reset { margin: 4px 0 0; }

/* スマートフォンで条件を変えているあいだの結果の要点 (PC では結果が横に見えているので出さない) */
.livebar { display: none; }

/* 用語の説明ボタン */
.q {
  display: inline-grid; place-items: center; width: 20px; height: 20px; padding: 0; flex: none;
  border: 1px solid var(--muted); border-radius: 50%; background: none; color: var(--muted);
  font-size: 12px; font-weight: 700; line-height: 1; cursor: pointer; vertical-align: 0.1em;
}
.q:hover, .q[aria-expanded="true"] { background: var(--ink); border-color: var(--ink); color: var(--paper); }
.q.q-link {
  display: inline; width: auto; height: auto; border: 0; border-radius: 0; background: none; color: var(--neg);
  font-size: inherit; font-weight: 400; text-decoration: underline dotted; text-underline-offset: 3px; vertical-align: baseline;
}
.q.q-link:hover, .q.q-link[aria-expanded="true"] { background: none; color: var(--ink); }
.term-pop {
  position: fixed; inset: auto; margin: 0; width: min(320px, calc(100vw - 24px));
  padding: 14px 16px; border: 1px solid var(--rule); border-left: 4px solid var(--ink); border-radius: 6px;
  background: var(--surface); color: var(--ink); box-shadow: 0 6px 24px rgba(31, 40, 51, 0.16);
}
.term-pop:not(:popover-open):not(.open) { display: none; }
.term-pop-title { margin: 0 0 4px; font-weight: 700; }
.term-pop-text { margin: 0; font-size: 14px; line-height: 1.7; }

/* ---------- 結果 ---------- */
.results { min-width: 0; }
.progress { height: 3px; background: var(--rule); border-radius: 2px; overflow: hidden; margin-bottom: 12px; }
.progress .bar { height: 100%; width: 0; background: var(--ink); transition: width 0.2s; }
.output { transition: opacity 0.15s; }
.results.is-updating .output { opacity: 0.5; }
.results.is-stale .output { opacity: 0.35; filter: grayscale(1); }
.status {
  margin: 0 0 16px; padding: 10px 14px; border-left: 4px solid var(--error); background: var(--surface);
  color: var(--error); font-weight: 700; font-size: 14px;
}
.status:empty, .status[hidden] { display: none; }
#plan [aria-invalid="true"] { border-color: var(--error); box-shadow: 0 0 0 1px var(--error); }
.field-error { color: var(--error); font-size: 13px; font-weight: 700; }

.cond { margin: 0 0 8px; }
.cond-text { margin: 0; font-size: 15px; font-weight: 700; }
.cond-hint { margin: 4px 0 0; font-size: 14px; color: var(--muted); }
.cond .btn { margin-top: 10px; }

.warnings { margin: 16px 0 0; padding: 10px 16px 10px 32px; border-left: 4px solid var(--accent); background: var(--surface); font-size: 14px; }

.hero { padding: 8px 0 24px; border-bottom: 1px solid var(--rule); }
.hero-when { margin: 0; font-size: 16px; color: var(--muted); }
.hero-figure { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 6px 0 10px; }
.hero-label { display: inline-flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 700; }
.hero-num { font-family: var(--font-figure); font-weight: 700; line-height: 1.05; }
#hero-median { font-size: clamp(44px, 7vw, 68px); letter-spacing: 0.01em; }
.hero-num .unit { font-size: 26px; margin-left: 4px; }
.hero-range { margin: 0 0 8px; font-size: 18px; font-weight: 700; }
.hero-loss { margin: 0 0 8px; font-size: 16px; font-weight: 700; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.hero-loss.has-loss::before {
  content: ""; flex: none; width: 12px; height: 12px; border-radius: 50%; background: var(--neg); margin-right: 2px;
} /* 100人の図の「元本を下回る」と同じ丸。文字の色はリンクと区別するため墨のまま */
.hero-loss a { font-size: 14px; font-weight: 400; }
.hero-principal { margin: 0 0 8px; color: var(--muted); max-width: 46em; }
.hero-source { margin: 0; font-size: 13px; color: var(--muted); max-width: 46em; }
.preset-switch { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 14px 0 8px; }
.preset-switch-label { font-size: 14px; font-weight: 700; margin-right: 4px; }
.preset-switch button {
  min-width: 4.5em; padding: 6px 14px; border: 1px solid var(--rule); border-radius: 999px;
  background: var(--surface); cursor: pointer; font-size: 15px;
}
.preset-switch button:hover { border-color: var(--muted); }
.preset-switch button[aria-checked="true"] { background: var(--ink); color: var(--paper); border-color: var(--ink); font-weight: 700; }

.block { padding: 24px 0; border-bottom: 1px solid var(--rule); }
.block h3 { margin: 0 0 6px; font-size: 18px; }
.note { margin: 0 0 12px; font-size: 14px; color: var(--muted); max-width: 46em; }
.lead-text { margin: 0; max-width: 46em; }

/* 100人の升目: 色に加えて形でも区別する (元本を下回る人は丸) */
.dots-wrap { display: flex; flex-wrap: wrap; gap: 20px 32px; align-items: center; margin: 12px 0; }
.dots { display: grid; grid-template-columns: repeat(10, 22px); gap: 4px; }
.dot { display: inline-block; width: 22px; height: 22px; border-radius: 2px; }
.dot.reach { background: var(--pos); }
.dot.mid { background: var(--mid-dot); }
.dot.loss { background: var(--neg); border-radius: 50%; }
.dots-legend { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.dots-legend li { display: grid; grid-template-columns: 16px 1fr auto; gap: 10px; align-items: center; }
.dots-legend .dot { width: 16px; height: 16px; }
.legend-count { font-family: var(--font-figure); font-size: 22px; font-weight: 700; text-align: right; min-width: 3.5em; }
#target-note { margin-top: 8px; color: var(--ink); }

/* 元本を下回る確率 */
#loss-block:focus { outline: none; }
.loss-figure { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 16px; margin: 8px 0 8px; }
.loss-num { font-family: var(--font-figure); font-size: 48px; font-weight: 700; line-height: 1.1; color: var(--neg); }
.loss-label { flex: 1 1 16em; max-width: 30em; font-size: 15px; }
.loss-short { font-size: 15px; margin-bottom: 4px; }
.sub-head { font-size: 15px; margin: 20px 0 4px; }
.chart-box.short { height: 200px; }
.cmp-loss { font-size: 12px; color: var(--neg); white-space: nowrap; }
.why { margin-top: 16px; border-left: 4px solid var(--neg); background: var(--surface); padding: 0 16px; border-radius: 0 6px 6px 0; }
.why summary { color: var(--neg); }
.why-body { padding-bottom: 12px; font-size: 14px; max-width: 46em; }
.why-body p { margin: 0 0 8px; }

/* 前提ごとの比較: 行を選ぶと上の結果が切り替わる */
.compare { display: grid; gap: 6px; margin-top: 8px; }
.cmp-row {
  display: grid; grid-template-columns: 170px minmax(0, 1fr) 132px; gap: 14px; align-items: center;
  width: 100%; padding: 10px 12px; margin: 0; text-align: left;
  background: none; border: 1px solid transparent; border-radius: 8px; cursor: pointer;
}
.cmp-row:hover { background: var(--surface); border-color: var(--rule); }
.cmp-row.current { background: var(--surface); border: 2px solid var(--ink); padding: 9px 11px; }
.cmp-name { display: flex; flex-direction: column; line-height: 1.35; }
.cmp-label { font-weight: 700; font-size: 15px; }
.cmp-row.current .cmp-label::after { content: "（選択中）"; font-weight: 400; font-size: 12px; color: var(--muted); }
.cmp-rate { font-size: 13px; color: var(--muted); }
.cmp-desc { font-size: 12px; color: var(--muted); }
.cmp-track { position: relative; height: 28px; }
.cmp-track::before { content: ""; position: absolute; left: 0; right: 0; top: 50%; border-top: 1px solid var(--rule); }
.cmp-range { position: absolute; top: 9px; height: 10px; background: var(--band-strong); border-radius: 5px; }
.cmp-row.current .cmp-range { background: var(--neg); opacity: 0.55; }
.cmp-mid { position: absolute; top: 3px; width: 4px; height: 22px; margin-left: -2px; background: var(--accent); border-radius: 1px; }
.cmp-prin { position: absolute; top: -4px; bottom: -4px; border-left: 1.5px dashed var(--ink); opacity: 0.6; }
.cmp-values { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.3; }
.cmp-value { font-family: var(--font-figure); font-weight: 700; font-size: 18px; white-space: nowrap; }
.cmp-sub { font-size: 12px; color: var(--muted); white-space: nowrap; }
.cmp-axis { display: grid; grid-template-columns: 170px minmax(0, 1fr) 132px; gap: 14px; padding: 0 12px; font-size: 12px; color: var(--muted); }
.cmp-axis span:first-child { grid-column: 2; grid-row: 1; justify-self: start; }
.cmp-axis .cmp-axis-prin { grid-column: 2; grid-row: 2; justify-self: start; }
.cmp-axis span:last-child { grid-column: 2; grid-row: 1; justify-self: end; }
.cmp-q { margin: 8px 0 0; display: flex; gap: 16px; flex-wrap: wrap; }

.chart-box { position: relative; height: 340px; margin-top: 8px; }
.table-toggle { margin-top: 12px; }

/* 横にはみ出す表は、端に影を出して続きがあることを示す */
.scroll-x {
  overflow-x: auto; -webkit-overflow-scrolling: touch;
  background:
    linear-gradient(to right, var(--paper) 30%, transparent) left / 24px 100% no-repeat local,
    linear-gradient(to left, var(--paper) 30%, transparent) right / 24px 100% no-repeat local,
    radial-gradient(farthest-side at 0 50%, rgba(31, 40, 51, 0.18), transparent) left / 10px 100% no-repeat scroll,
    radial-gradient(farthest-side at 100% 50%, rgba(31, 40, 51, 0.18), transparent) right / 10px 100% no-repeat scroll;
}
.grid-table, .kv-table { border-collapse: collapse; width: 100%; font-size: 15px; }
.grid-table th, .grid-table td { padding: 8px 12px; border-bottom: 1px solid var(--rule); white-space: nowrap; }
.grid-table thead th { font-size: 13px; color: var(--muted); font-weight: 700; text-align: right; }
.grid-table thead th:first-child, .grid-table tbody th { text-align: left; }
.grid-table td { text-align: right; }
.grid-table tbody th { font-weight: 700; }
.kv-table th, .kv-table td { padding: 10px 12px 10px 0; border-bottom: 1px solid var(--rule); vertical-align: top; text-align: left; }
.kv-table th { width: 13em; font-weight: 700; font-size: 14px; }
.kv-table td { font-size: 14px; }
.more summary { font-size: 17px; }
.more[open] summary { margin-bottom: 8px; }

.keep { border-bottom: 0; }
.keep-row { display: flex; flex-wrap: wrap; gap: 10px 16px; align-items: center; margin: 10px 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); z-index: 40;
  max-width: min(560px, calc(100vw - 32px)); margin: 0; padding: 10px 16px; transform: translate(-50%, 16px);
  background: var(--ink); color: var(--paper); border-radius: 6px; font-size: 14px;
  opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { background: var(--error); color: #fff; }

.footer { max-width: 1280px; margin: 0 auto; padding: 24px 24px 40px; border-top: 1px solid var(--rule); font-size: 13px; color: var(--muted); }
.footer p { margin: 0 0 6px; max-width: 60em; }
.data-date { font-size: 12px; }

/* ---------- 広告 ----------
   結果と見分けがつくよう、枠と「広告」の表示をつけ、結果の数字や図からは区切る。
   表示されたときに下の内容がずれないよう、AdSense の枠は先に高さを取っておく */
.ad-slot {
  margin: 8px 0 24px; padding: 8px 12px 12px;
  border: 1px solid var(--rule); border-radius: 8px; background: var(--surface);
  text-align: center; overflow: hidden;
}
.ad-label { margin: 0 0 6px; font-size: 11px; color: var(--muted); text-align: left; letter-spacing: 0.08em; }
.ad-by { margin: 6px 0 0; font-size: 11px; color: var(--muted); }
.ad-slot.is-static img { max-width: 100%; height: auto; vertical-align: middle; }
.ad-slot.is-adsense { min-height: 280px; }
.ad-slot .adsbygoogle { display: block; }
.ad-slot.is-blocked, .ad-slot:has(ins[data-ad-status="unfilled"]) { display: none; } /* 広告ブロックなどで読み込めなかったときは枠ごと畳む */
.doc-body .ad-slot { margin-top: 40px; }
@media print { .ad-slot { display: none !important; } }

.narrow-only { display: none; }

/* PC: 条件と結果が並んでいるので、条件の要約は出さない (最初の例のときだけ案内を出す) */
@media (min-width: 900px) {
  .plan {
    position: sticky; top: 72px; /* ヘッダーの高さ + 余白 */
    max-height: calc(100vh - 88px); overflow-y: auto; overscroll-behavior: contain;
    padding-right: 12px; scrollbar-gutter: stable;
  }
  .cond { display: none; }
  body.is-example .cond { display: block; padding: 12px 16px; background: var(--surface); border: 1px solid var(--rule); border-left: 4px solid var(--accent); border-radius: 6px; margin-bottom: 16px; }
  body.is-example .cond-text { display: none; }
  body.is-example .cond-hint { margin: 0; color: var(--ink); }
}

/* ---------- スマートフォン: 結果と条件をタブで切り替える ---------- */
@media (max-width: 899px) {
  .topbar { padding-left: 16px; padding-right: 16px; }
  .topbar h1 { font-size: 16px; line-height: 28px; } /* ヘッダーの高さを 53px に揃え、すぐ下にタブを貼り付ける */
  .tabs {
    position: sticky; top: calc(env(safe-area-inset-top, 0px) + 53px); z-index: 15;
    display: grid; grid-template-columns: 1fr 1fr;
    background: var(--paper); border-bottom: 1px solid var(--rule);
  }
  .tabs button {
    padding: 12px; background: none; border: 0; border-bottom: 3px solid transparent;
    font-weight: 700; color: var(--muted); cursor: pointer;
  }
  body[data-tab="results"] #tab-results, body[data-tab="plan"] #tab-plan { color: var(--ink); border-bottom-color: var(--ink); }
  .banner { margin: 12px 16px 0; }
  .layout { grid-template-columns: minmax(0, 1fr); padding: 16px 16px 32px; gap: 0; }
  body[data-tab="plan"] .results, body[data-tab="results"] .plan { display: none; }
  .narrow-only { display: inline-flex; }
  .wide-only { display: none; }
  .cond { padding: 12px 14px; background: var(--surface); border: 1px solid var(--rule); border-radius: 8px; margin-bottom: 12px; }
  body.is-example .cond { border-left: 4px solid var(--accent); }
  .cond { display: flex; align-items: center; gap: 12px; padding: 10px 12px; }
  .cond-text { flex: 1; min-width: 0; font-size: 14px; }
  .cond-hint { display: none; } /* 「自分の数字で試す」ボタンで意図は伝わる */
  .cond .btn { margin-top: 0; flex: none; }
  .hero { padding-bottom: 16px; }
  .preset-switch-label { flex-basis: 100%; }

  .livebar {
    position: sticky; bottom: 0; z-index: 5;
    display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 12px; align-items: center;
    margin: 16px -16px 0; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px));
    background: var(--paper); border-top: 1px solid var(--rule);
  }
  .livebar-text { display: flex; flex-direction: column; margin: 0; min-width: 0; line-height: 1.4; }
  .live-main { font-weight: 700; font-size: 16px; }
  .live-sub { font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .livebar.is-updating .live-main { opacity: 0.5; }
  .livebar.is-error .live-main, .livebar.is-error .live-sub { color: var(--error); white-space: normal; }
  .livebar .btn { padding: 12px 16px; }
  .toast { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
  .footer { padding: 20px 16px 32px; }
}
@media (max-width: 520px) {
  .fields { grid-template-columns: minmax(0, 1fr); }
  .dots { grid-template-columns: repeat(10, 1fr); width: 100%; max-width: 300px; }
  .dot { width: auto; aspect-ratio: 1; height: auto; }
  .dots-legend .dot { width: 16px; height: 16px; aspect-ratio: auto; }
  .cmp-row { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: "name values" "track track"; row-gap: 6px; }
  .cmp-name { grid-area: name; }
  .cmp-values { grid-area: values; }
  .cmp-track { grid-area: track; }
  .cmp-axis { grid-template-columns: minmax(0, 1fr); padding: 0 12px; }
  .cmp-axis span:first-child, .cmp-axis span:last-child, .cmp-axis .cmp-axis-prin { grid-column: 1; }
  .chart-box { height: 280px; }
  .kv-table th { width: 8.5em; }
  .term-pop {
    inset: auto 0 0 0; width: 100%; max-width: none; border-radius: 12px 12px 0 0; border-left: 0; border-top: 4px solid var(--ink);
    padding: 18px 20px calc(20px + env(safe-area-inset-bottom, 0px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .progress .bar, .output, .toast { transition: none; }
  html { scroll-behavior: auto; }
}

/* ---------- 説明ページ ---------- */
.doc-body { max-width: 760px; margin: 0 auto; padding: 32px 24px 48px; }
.doc-body h2 { font-size: 28px; margin: 0 0 16px; }
.doc-body h3 { font-size: 19px; margin: 36px 0 8px; padding-top: 16px; border-top: 1px solid var(--rule); }
.doc-body p, .doc-body li { max-width: 40em; }
.doc-body ol, .doc-body ul { padding-left: 1.4em; }
.doc-body li { margin-bottom: 6px; }
@media (max-width: 899px) { .doc-body { padding: 24px 16px 40px; } }
.doc-body h4 { font-size: 16px; margin: 24px 0 6px; }
.doc-date { color: var(--muted); font-size: 14px; margin-top: -8px; }
.doc-toc { display: flex; flex-wrap: wrap; gap: 6px 18px; margin: 16px 0 8px; font-size: 14px; }
.doc-body section { scroll-margin-top: 80px; }
.doc-body .grid-table td { text-align: right; }
#funds-table td, #funds-table thead th { text-align: left; white-space: normal; }
#returns-table thead th { white-space: normal; min-width: 7em; }
/* 公開前に書き換える箇所 (about.html の運営者欄)。書き換えたら class ごと消す */
.placeholder { background: rgba(154, 104, 16, 0.18); padding: 0 4px; border-radius: 3px; }
