/* こどもNISA ラボ：見た目
   大人向けはサイトの色（和紙の生成り・墨・土壁の茶・朱）と明朝の見出し。
   こども向けは html.kid で色と文字を替え、丸い文字と大きな押しやすいボタンにする。
   グラフの色：積み立てた元本＝黄土、増えた分＝緑、減った分＝灰。色だけに頼らないよう凡例と表を添える。 */
:root {
  --bg: #f6f1e7;
  --surface: #fffdf8;
  --sunk: #efe8da;
  --ink: #2a2623;
  --muted: #6b6259;
  --line: #ddd3c3;
  --line-strong: #c3b59f;
  --accent: #b23a2b;
  --accent-soft: #f6e4de;
  --on-accent: #ffffff;
  --link: #7a5a3a;
  --ok: #2b6e4b;
  --ok-soft: #e0eee5;
  --ng: #b23a2b;
  --ng-soft: #f7e1dc;
  --tip: #345d8c;
  --s-paid: #c28a35;
  --s-gain: #176f49;
  --s-loss: #cdc3b4;
  --title: "Hiragino Mincho ProN", "ヒラギノ明朝 ProN", "Yu Mincho", "YuMincho", "Noto Serif JP", "Noto Serif CJK JP", serif;
  --body: "Hiragino Sans", "ヒラギノ角ゴシック", "Yu Gothic", "YuGothic", "Noto Sans JP", "Meiryo", sans-serif;
  --radius: 12px;
  /* ../shared/users.css の色 */
  --pu-ink: var(--ink);
  --pu-soft: var(--muted);
  --pu-line: var(--line);
  --pu-accent: var(--accent);
  --pu-hl: var(--accent-soft);
  --pu-bg: var(--surface);
  --pu-card: var(--surface);
  --pu-focus: var(--accent);
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not(.kid) {
    --bg: #1b1916; --surface: #24211d; --sunk: #2d2924; --ink: #ece5da; --muted: #a99d8f;
    --line: #3b352f; --line-strong: #574d43; --accent: #e7795f; --accent-soft: #3a2621; --on-accent: #1b1916; --link: #dcb88e;
    --ok: #7ccb9b; --ok-soft: #1e3328; --ng: #f08c79; --ng-soft: #3b2420; --tip: #8fb5e4;
    --s-paid: #b98434; --s-gain: #3aa274; --s-loss: #574d43;
    color-scheme: dark;
  }
}
html.kid {
  --bg: #fff8e7;
  --surface: #ffffff;
  --sunk: #fdf0d3;
  --ink: #3a2c1c;
  --muted: #6f5c45;
  --line: #eedfc0;
  --line-strong: #dcc69a;
  --accent: #d0431f;
  --accent-soft: #ffe7dc;
  --link: #a8441f;
  --ok: #1d7f45;
  --ok-soft: #dff3e4;
  --ng: #d23c32;
  --ng-soft: #fde3df;
  --tip: #2f6fb5;
  --s-paid: #e09a1a;
  --s-gain: #16824a;
  --s-loss: #d8ccb6;
  --title: "Mochiy Pop One", "Hiragino Maru Gothic ProN", "BIZ UDPGothic", sans-serif;
  --body: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "BIZ UDPGothic", "Meiryo", sans-serif;
  --radius: 18px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 64px; background: var(--bg); }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.85;
  letter-spacing: 0.02em;
  overflow-wrap: break-word;
}
/* こども向けの文は言葉の間に空白を入れているので、そこでだけ折り返す */
html.kid body { font-size: 17px; font-weight: 500; line-height: 1.9; letter-spacing: 0.03em; word-break: keep-all; overflow-wrap: anywhere; -webkit-tap-highlight-color: transparent; }
html.kid .parents { word-break: normal; }
a { color: var(--link); text-underline-offset: 0.2em; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 3px solid color-mix(in srgb, var(--tip) 65%, transparent); outline-offset: 2px; border-radius: 6px; }
main:focus { outline: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.em { font-style: normal; }

/* ---------- 上の帯 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top, 0px);
}
.tb-in { max-width: 48rem; margin: 0 auto; padding: 0 16px; height: 56px; display: flex; align-items: center; gap: 10px; }
.tb-back { flex: none; display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding-right: 4px; color: var(--muted); font-size: 0.88rem; text-decoration: none; white-space: nowrap; }
.tb-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.tb-back:hover { color: var(--ink); }
.user-slot { flex: 0 1 auto; min-width: 0; display: flex; }
body.sub .user-slot { display: none; }
.tb-title { font-family: var(--title); font-weight: 600; font-size: 1.02rem; letter-spacing: 0.06em; color: var(--ink); text-decoration: none; white-space: nowrap; }
html.kid .tb-title { font-weight: 400; }
.tb-prog { margin-left: auto; font-size: 0.78rem; color: var(--muted); white-space: nowrap; }
.mode { flex: none; display: flex; padding: 3px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--surface); }
.mode button { min-height: 34px; padding: 2px 12px; border: 0; border-radius: 999px; background: none; color: var(--muted); font-size: 0.82rem; font-weight: 600; cursor: pointer; }
.mode button[aria-pressed="true"] { background: var(--accent); color: var(--on-accent); }

main { display: block; max-width: 48rem; margin: 0 auto; padding: 24px 16px 56px; }

/* ---------- 目次 ---------- */
.hero { padding: 20px 0 4px; }
.kicker, .ch-head .no { margin: 0; color: var(--accent); font-size: 0.84rem; font-weight: 600; letter-spacing: 0.14em; }
.hero h1 { margin: 0.15em 0 0.35em; font-family: var(--title); font-weight: 600; font-size: clamp(2.1rem, 8vw, 2.9rem); line-height: 1.3; letter-spacing: 0.08em; }
.lead { margin: 0; color: var(--muted); }
html.kid .hero { text-align: center; padding-top: 4px; }
html.kid .hero h1 { font-weight: 400; font-size: clamp(1.9rem, 8vw, 2.6rem); letter-spacing: 0.04em; }
html.kid .lead { color: var(--ink); }
.tree { display: block; width: min(240px, 66%); height: auto; margin: 0 auto 6px; }

.facts { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin: 22px 0 0; padding: 0; list-style: none; }
.facts li { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.facts small { display: block; font-size: 0.74rem; line-height: 1.5; color: var(--muted); }
.facts b { display: block; font-family: var(--title); font-size: 1.16rem; font-weight: 600; line-height: 1.45; }

.sim-link { display: flex; align-items: center; gap: 14px; margin: 14px 0 0; padding: 16px 18px; background: var(--accent); border-radius: var(--radius); color: var(--on-accent); text-decoration: none; transition: filter 0.15s; }
.sim-link:hover { filter: brightness(1.06); }
.sim-link > span:not(.em) { flex: 1; min-width: 0; }
.sim-link b { display: block; font-family: var(--title); font-size: 1.14rem; font-weight: 600; letter-spacing: 0.04em; line-height: 1.5; }
html.kid .sim-link b { font-weight: 400; }
.sim-link small { display: block; margin-top: 2px; font-size: 0.84rem; line-height: 1.6; opacity: 0.92; }
.sim-link .em { font-size: 2.2rem; line-height: 1; }
.chev { flex: none; width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }

.summary { margin: 14px 0 8px; padding: 14px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.meter { display: grid; grid-template-columns: repeat(8, 1fr); gap: 4px; }
.meter i { height: 8px; border-radius: 4px; background: var(--sunk); }
.meter i.part { background: color-mix(in srgb, var(--accent) 38%, var(--sunk)); }
.meter i.full { background: var(--accent); }
.summary p { margin: 8px 0 0; font-size: 0.9rem; color: var(--muted); }
.summary b { font-family: var(--title); font-size: 1.35rem; color: var(--ink); margin: 0 2px; }

.sec { display: flex; align-items: center; gap: 10px; margin: 36px 0 12px; font-family: var(--title); font-weight: 600; font-size: 1.15rem; letter-spacing: 0.1em; }
html.kid .sec { font-weight: 400; }
.sec::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.ch-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.ch-card {
  display: grid;
  grid-template-columns: 2.6rem 1fr auto;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: inherit;
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.ch-card:hover { border-color: var(--line-strong); box-shadow: 0 2px 10px color-mix(in srgb, var(--ink) 7%, transparent); }
.ch-no { display: grid; justify-items: center; line-height: 1; color: var(--accent); }
.ch-no b { font-family: var(--title); font-size: 1.7rem; font-weight: 600; }
.ch-no small { margin-top: 4px; font-size: 0.68rem; color: var(--muted); letter-spacing: 0.1em; }
.ch-no .em { font-size: 2rem; }
.ch-body b { display: block; font-size: 1.02rem; line-height: 1.55; }
.ch-body small { display: block; margin-top: 3px; font-size: 0.83rem; line-height: 1.6; color: var(--muted); }
.st { padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; font-size: 0.76rem; color: var(--muted); white-space: nowrap; }
.st.part { border-color: color-mix(in srgb, var(--accent) 40%, var(--line)); color: var(--accent); }
.st.full { border-color: transparent; background: var(--ok-soft); color: var(--ok); font-weight: 600; }
.st.full::before { content: "✓ "; }

.fine, .parents { margin: 32px 0 0; font-size: 0.8rem; line-height: 1.7; color: var(--muted); }
.refs { margin: 0; padding-left: 1.2em; font-size: 0.85rem; line-height: 1.7; }
.refs li { margin: 0.2em 0; }

/* ---------- 章 ---------- */
.ch-head { padding: 12px 0 18px; border-bottom: 1px solid var(--line); }
.ch-head h1 { margin: 0.2em 0 0.4em; font-family: var(--title); font-weight: 600; font-size: clamp(1.6rem, 6vw, 2.15rem); line-height: 1.45; letter-spacing: 0.04em; }
html.kid .ch-head h1 { font-weight: 400; }
.ch-head .meta { margin: 10px 0 0; font-size: 0.83rem; color: var(--muted); }

.prose h3 { margin: 2.2em 0 0.6em; padding-left: 0.7em; border-left: 3px solid var(--accent); font-family: var(--title); font-weight: 600; font-size: 1.24rem; line-height: 1.5; }
.prose p { margin: 0.8em 0; }
.prose ul, .prose ol { margin: 0.8em 0; padding-left: 1.5em; }
.prose li { margin: 0.35em 0; }
.prose strong { font-weight: 700; background: linear-gradient(transparent 62%, color-mix(in srgb, var(--accent) 20%, transparent) 62%); }
.note { font-size: 0.83rem; color: var(--muted); }
html.kid .prose { font-size: 1.04rem; }
html.kid .prose > p { margin: 1em 0; }

.tbl { margin: 1.1em 0; overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
table { width: 100%; border-collapse: collapse; font-size: 0.88rem; line-height: 1.65; }
th, td { padding: 9px 12px; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
tbody tr:last-child th, tbody tr:last-child td { border-bottom: 0; }
th { background: var(--sunk); color: var(--muted); font-size: 0.8rem; font-weight: 600; }
td.nw { white-space: nowrap; }
td.n, th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }

.callout { margin: 1.4em 0; padding: 14px 16px; background: var(--accent-soft); border-left: 4px solid var(--accent); border-radius: 4px 10px 10px 4px; }
.callout > b { display: block; color: var(--accent); font-size: 0.82rem; letter-spacing: 0.1em; }
.callout p { margin: 0.3em 0 0; }

/* 手順の図 */
.flow { margin: 1.2em 0; padding: 0; list-style: none; counter-reset: step; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; }
.prose .flow { padding: 0; }
.flow li { display: flex; align-items: flex-start; gap: 10px; margin: 0; padding: 10px 14px; border-bottom: 1px solid var(--line); counter-increment: step; font-size: 0.92rem; line-height: 1.7; }
.flow li:last-child { border-bottom: 0; }
.flow li::before { content: counter(step); flex: none; display: grid; place-items: center; width: 1.6rem; height: 1.6rem; margin-top: 0.05rem; border-radius: 50%; background: var(--sunk); font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.flow li > span { flex: 1; min-width: 0; }

/* こども向けの図 */
.duo { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 1.2em 0; }
.duo > div, .cards li { padding: 14px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); text-align: center; }
.duo .em, .cards .em { display: block; font-size: 2.2rem; line-height: 1.3; }
.duo b, .cards b { display: block; font-size: 1.04rem; }
.prose .duo p, .prose .cards p { margin: 0.2em 0 0; font-size: 0.92rem; line-height: 1.7; }
.prose .cards { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 1.2em 0; padding: 0; list-style: none; }
.prose .cards li { margin: 0; }
.prose .path { margin: 1.2em 0; padding: 0; list-style: none; }
.path li { position: relative; display: flex; gap: 12px; align-items: flex-start; margin: 0; padding: 12px 14px; background: var(--surface); border: 2px solid var(--line); border-radius: var(--radius); }
.path li + li { margin-top: 18px; }
.path li + li::before { content: ""; position: absolute; top: -20px; left: 2.1rem; height: 18px; border-left: 3px dotted var(--line-strong); }
.path .em { flex: none; font-size: 1.9rem; line-height: 1.3; }
.path b { display: block; }
.prose .path p { margin: 0.1em 0 0; font-size: 0.94rem; line-height: 1.7; }
.say { margin: 1.4em 0 0; padding: 12px 16px; background: var(--ok-soft); border-radius: var(--radius); font-weight: 800; }
.sim .say { font-weight: 500; font-size: 0.92rem; background: var(--sunk); }

/* ---------- 動く図 ---------- */
.widget { margin: 1.2em 0; padding: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.widget h4 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 0.95rem; }
.widget h4::before { content: "試す"; flex: none; padding: 0 9px; border-radius: 999px; background: var(--accent); color: var(--on-accent); font-size: 0.7rem; letter-spacing: 0.1em; line-height: 1.8; }
html.kid .widget h4::before { content: "やって みよう"; letter-spacing: 0.02em; }
.chips-label { margin: 14px 0 6px; font-size: 0.8rem; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { min-height: 38px; padding: 4px 14px; border: 1px solid var(--line-strong); border-radius: 999px; background: var(--bg); font-size: 0.84rem; line-height: 1.4; cursor: pointer; }
.chip:hover { border-color: var(--accent); }
.chip[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
html.kid .chip { min-height: 44px; font-weight: 500; }
.w-out { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: var(--sunk); font-size: 0.9rem; }
.w-out p { margin: 0; }
.w-out dl { display: grid; grid-template-columns: 9.5rem 1fr; gap: 4px 12px; margin: 0; }
.w-out dt { color: var(--muted); }
.w-out dd { margin: 0; min-width: 0; }
.w-out .w-tip { margin-top: 8px; padding-top: 8px; border-top: 1px solid var(--line-strong); }
.w-year { font-weight: 800; }
.widget .note { margin: 12px 0 0; font-size: 0.78rem; line-height: 1.7; }

.prose .faces { display: grid; grid-template-columns: repeat(6, 1fr); gap: 4px; margin: 0 0 12px; padding: 0; list-style: none; }
.prose .faces li { display: grid; margin: 0; justify-items: center; gap: 2px; padding: 6px 2px; background: var(--sunk); border-radius: 8px; font-size: 0.74rem; line-height: 1.3; text-align: center; }
.faces b { font-size: 0.95rem; }
html.kid .prose .faces { grid-template-columns: repeat(3, 1fr); }
.dice-go { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.w-out + .dice-go { margin-top: 12px; }
.die { display: grid; place-items: center; width: 44px; height: 44px; border: 2px solid var(--ink); border-radius: 10px; background: var(--surface); font-size: 1.3rem; font-weight: 800; }
.dice-plot svg { display: block; width: 100%; height: auto; margin-top: 10px; }
.dice-plot .line { fill: none; stroke: var(--s-gain); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.dice-plot .dot { fill: var(--s-gain); stroke: var(--surface); stroke-width: 2; }
.dice-plot .base { stroke: var(--line-strong); stroke-width: 1; }
.dice-note { margin: 8px 0 0; font-size: 0.9rem; }
.snow { display: grid; place-items: end center; height: 6.2rem; }
.snow .ball { line-height: 1; transition: font-size 0.25s; }
@media (prefers-reduced-motion: reduce) { .snow .ball { transition: none; } }

/* ---------- 入力欄 ---------- */
.field { display: grid; gap: 4px; align-content: start; font-size: 0.84rem; color: var(--muted); }
.field small { font-size: 0.74rem; line-height: 1.5; }
.field b { color: var(--ink); }
.field input[type="number"], .field input[type="date"], .field select {
  width: 100%;
  min-height: 44px;
  padding: 8px 10px;
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: var(--bg);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
}
.field input[type="range"], .k-range { width: 100%; height: 32px; margin: 0; accent-color: var(--accent); }
.unit { position: relative; display: block; }
.unit input { padding-right: 3.2em !important; text-align: right; font-variant-numeric: tabular-nums; }
.unit i { position: absolute; top: 50%; right: 10px; transform: translateY(-50%); font-style: normal; font-size: 0.82rem; color: var(--muted); pointer-events: none; }

/* ---------- 確認問題 ---------- */
.quiz-wrap { margin-top: 3.2rem; }
.quiz-wrap > h2 { margin: 0; font-family: var(--title); font-weight: 600; font-size: 1.4rem; letter-spacing: 0.06em; }
html.kid .quiz-wrap > h2 { font-weight: 400; }
.hint { margin: 0.3em 0 12px; font-size: 0.83rem; color: var(--muted); }
.quiz { margin-top: 16px; padding: 20px; background: var(--surface); border: 1px solid var(--line); border-radius: 14px; scroll-margin-top: 64px; }
.q-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 10px; font-size: 0.83rem; color: var(--muted); }
.dots { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 5px; }
.dots i { width: 10px; height: 10px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--sunk); }
.dots i.now { border-color: var(--accent); background: var(--accent-soft); }
.dots i.ok { border-color: var(--ok); background: var(--ok); }
.dots i.ng { border-color: var(--ng); background: var(--ng); }
.q-text { margin: 0 0 14px; font-size: 1.04rem; font-weight: 600; line-height: 1.75; }
html.kid .q-text { font-size: 1.14rem; font-weight: 800; }
.choices { display: grid; gap: 8px; }
.choice {
  display: grid;
  grid-template-columns: 1.9rem 1fr;
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 11px 14px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.95rem;
  line-height: 1.7;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.12s, background-color 0.12s;
}
html.kid .choice { padding: 13px 14px; border-width: 2px; border-radius: 14px; font-size: 1.05rem; }
.choice:hover:not(:disabled) { border-color: var(--accent); background: var(--surface); }
.choice:disabled { cursor: default; color: var(--ink); }
.choice .t { min-width: 0; }
.choice .k { display: grid; place-items: center; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--sunk); font-size: 0.84rem; font-weight: 700; }
.choice.correct { border-color: var(--ok); background: var(--ok-soft); }
.choice.correct .k { background: var(--ok); color: var(--surface); }
.choice.wrong { border-color: var(--ng); background: var(--ng-soft); }
.choice.wrong .k { background: var(--ng); color: var(--surface); }
.choice.dim { opacity: 0.55; }
.fb-in { margin-top: 14px; padding: 14px 16px; border-radius: 10px; background: var(--sunk); border-left: 4px solid var(--ok); }
.fb-in.ng { border-left-color: var(--ng); }
.fb-in p { margin: 0.3em 0 0; font-size: 0.93rem; }
html.kid .fb-in p { font-size: 1rem; }
.fb-in .verdict { margin: 0; }
.verdict { margin: 0; font-weight: 700; }
.verdict.ok { color: var(--ok); }
.verdict.ng { color: var(--ng); }
.verdict.ok::before { content: "✓ "; }
.verdict.ng::before { content: "✗ "; }
.q-next { display: flex; justify-content: flex-end; margin-top: 14px; }

.result .score { display: flex; align-items: baseline; gap: 4px; margin: 0; font-family: var(--title); line-height: 1.1; }
.result .score b { font-size: 3.2rem; font-weight: 600; color: var(--accent); }
.result .score small { font-size: 1.05rem; color: var(--muted); }
.hanamaru { align-self: center; margin-right: 6px; font-size: 3rem; line-height: 1; }
.msg-line { margin: 6px 0 0; }
.review { display: grid; gap: 8px; margin: 16px 0; padding: 0; list-style: none; }
.review li { padding: 10px 14px; border: 1px solid var(--line); border-left: 4px solid var(--ok); border-radius: 4px 10px 10px 4px; background: var(--bg); font-size: 0.9rem; }
.review li.ng { border-left-color: var(--ng); }
.review p { margin: 0.2em 0; }
.rv-q { font-weight: 600; }
.rv-q .mark { margin-right: 6px; font-weight: 700; color: var(--ok); }
.review li.ng .mark { color: var(--ng); }
.rv-a { color: var(--muted); }
.review details { margin-top: 4px; }
.review summary { cursor: pointer; color: var(--link); font-size: 0.85rem; }
.acts { display: flex; flex-wrap: wrap; gap: 10px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 20px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: var(--surface);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}
.btn:hover { border-color: var(--ink); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { background: color-mix(in srgb, var(--accent) 88%, var(--ink)); }
.btn.small { min-height: 38px; padding: 0 14px; font-size: 0.82rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 2.6rem; }
.pager a { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: 10px; color: var(--ink); text-decoration: none; font-size: 0.9rem; line-height: 1.5; }
.pager a:hover { border-color: var(--line-strong); }
.pager small { display: block; margin-bottom: 2px; color: var(--muted); font-size: 0.76rem; }
.pager .next { grid-column: 2; text-align: right; }

/* ---------- シミュレーター ---------- */
.panel { margin-top: 18px; padding: 4px 18px 18px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.panel fieldset { min-width: 0; margin: 14px 0 0; padding: 0; border: 0; }
.panel fieldset + fieldset { padding-top: 14px; border-top: 1px solid var(--line); }
.panel legend { padding: 0; font-family: var(--title); font-weight: 600; font-size: 1.05rem; letter-spacing: 0.06em; }
.f-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px 14px; margin-top: 8px; }
.f-grid.top { margin-top: 14px; }
.kid-rows { display: grid; gap: 8px; margin: 8px 0; padding: 0; list-style: none; }
.kid-rows li { display: flex; align-items: center; gap: 10px; }
.field.inline { flex: 1; grid-template-columns: 4.2rem 1fr; align-items: center; max-width: 16rem; }

.live {
  position: sticky;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  margin: 16px -18px -18px;
  padding: 10px 18px calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--surface);
  border-top: 1px solid var(--line-strong);
  border-radius: 0 0 var(--radius) var(--radius);
  font-size: 0.82rem;
  color: var(--muted);
}
.live b { margin-right: auto; font-size: 1.22rem; line-height: 1.4; color: var(--ink); }

.answer { margin-top: 18px; }
.headline { padding: 18px 20px; background: var(--surface); border: 1px solid var(--line); border-top: 4px solid var(--s-gain); border-radius: var(--radius); }
.headline.warn { border-top-color: var(--accent); }
.headline p { margin: 0; }
.h-lbl { font-size: 0.86rem; color: var(--muted); }
.h-big { font-size: clamp(2.3rem, 10vw, 3.2rem); font-weight: 700; line-height: 1.25; letter-spacing: 0; }
html.kid .h-big { font-family: var(--title); font-weight: 400; font-size: clamp(1.9rem, 9vw, 2.8rem); }
.headline .h-big + p { margin-top: 4px; font-size: 0.92rem; }
.a-sec { margin: 28px 0 8px; font-family: var(--title); font-weight: 600; font-size: 1.08rem; letter-spacing: 0.06em; }
html.kid .a-sec { font-weight: 400; }
.a-note { margin: 0 0 8px; font-size: 0.84rem; color: var(--muted); }

/* 名前・棒・値の 1 行 */
.hbar { display: grid; grid-template-columns: minmax(0, 10rem) 1fr 6.6rem; gap: 10px; align-items: center; padding: 6px 0; font-size: 0.88rem; line-height: 1.4; }
.h-track { display: flex; gap: 2px; height: 14px; border-radius: 4px; background: color-mix(in srgb, var(--sunk) 60%, transparent); overflow: hidden; }
.h-track i { display: block; min-width: 0; }
.h-track i:last-child { border-radius: 0 4px 4px 0; }
.h-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.h-val small { display: block; font-weight: 400; font-size: 0.74rem; color: var(--muted); }
i.paid, .sw.paid, .key.paid { background: var(--s-paid); }
i.gain, .sw.gain, .key.gain { background: var(--s-gain); }
i.loss, .sw.loss, .key.loss { background: var(--s-loss); }
i.dim { background: var(--line-strong); }
.cmp .hbar { grid-template-columns: minmax(0, 9rem) 1fr 9.6rem; }
.alloc, .cmp { padding: 8px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.btn-row { width: 100%; border: 0; border-radius: 8px; background: none; text-align: left; cursor: pointer; }
.btn-row:hover { background: var(--sunk); }
.btn-row[aria-pressed="true"] { font-weight: 800; }

.kid-results { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.k-card { padding: 14px 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.k-card p { margin: 0; }
.k-who { font-weight: 700; }
.k-who small { display: block; font-weight: 400; font-size: 0.76rem; color: var(--muted); }
.k-big { margin-top: 4px !important; font-size: 1.7rem; font-weight: 700; line-height: 1.3; letter-spacing: 0; }
.k-sub { font-size: 0.82rem; line-height: 1.6; color: var(--muted); }
.goal { height: 8px; margin: 8px 0 4px; border-radius: 4px; background: var(--sunk); overflow: hidden; }
.goal i { display: block; height: 100%; border-radius: 4px; background: var(--s-gain); }

table.rates tr.now th, table.rates tr.now td { background: var(--ok-soft); font-weight: 700; }
.checks { margin: 0; padding-left: 1.2em; font-size: 0.9rem; line-height: 1.75; }
.checks li { margin: 0.3em 0; }

/* こども向けの入力 */
.ask { display: flex; align-items: center; gap: 8px; margin: 18px 0 8px; font-size: 1.1rem; font-weight: 800; }
.ask span { display: grid; place-items: center; flex: none; width: 1.8rem; height: 1.8rem; border-radius: 50%; background: var(--accent); color: var(--on-accent); font-size: 0.95rem; }
.stepper { display: flex; align-items: center; justify-content: center; gap: 12px; }
.stepper button { width: 56px; height: 56px; border: 2px solid var(--line-strong); border-radius: 50%; background: var(--bg); font-size: 1.6rem; font-weight: 800; line-height: 1; cursor: pointer; }
.stepper button:disabled { opacity: 0.4; cursor: not-allowed; }
.stepper output { min-width: 6.2rem; font-family: var(--title); font-size: 1.9rem; text-align: center; }
.k-monthly { display: block; font-family: var(--title); font-size: 1.9rem; text-align: center; }
html.kid .panel .chips { margin-top: 6px; justify-content: center; }
.weather { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.wx { display: grid; justify-items: center; gap: 1px; padding: 10px 4px; border: 2px solid var(--line-strong); border-radius: 14px; background: var(--bg); line-height: 1.4; cursor: pointer; }
.wx .em { font-size: 1.7rem; line-height: 1.2; }
.wx b { font-size: 0.92rem; }
.wx small { font-size: 0.74rem; color: var(--muted); }
.wx[aria-pressed="true"] { border-color: var(--accent); background: var(--accent-soft); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 10px; }
.pair > div { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.pair small { display: block; font-size: 0.82rem; color: var(--muted); }
.pair b { display: block; font-size: 1.14rem; line-height: 1.4; }
.pair .plus { background: var(--ok-soft); }
.pair .minus { background: var(--ng-soft); }
.k-note { margin: 10px 0 0; padding: 10px 14px; border-radius: var(--radius); background: var(--sunk); font-size: 0.92rem; }

/* ---------- グラフ ---------- */
.chart { padding: 12px 14px; margin-top: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.legend { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: 0.8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 6px; }
.sw { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.w-out .legend { margin-bottom: 6px; }
.plot { position: relative; margin-top: 6px; touch-action: pan-y; }
.plot svg { display: block; width: 100%; }
.grid { stroke: var(--line); stroke-width: 1; }
.tick { fill: var(--muted); font-size: 11px; font-family: var(--body); }
.end { fill: var(--ink); font-size: 13px; font-weight: 700; font-family: var(--body); }
.col .paid { fill: var(--s-paid); }
.col .gain { fill: var(--s-gain); }
.col .loss { fill: var(--s-loss); }
.col.on { filter: brightness(1.12); }
.tip { position: absolute; top: 0; z-index: 2; min-width: 8rem; padding: 6px 10px; background: var(--surface); border: 1px solid var(--line-strong); border-radius: 8px; box-shadow: 0 3px 12px color-mix(in srgb, var(--ink) 16%, transparent); font-size: 0.78rem; line-height: 1.55; pointer-events: none; }
.tip p { margin: 0; color: var(--muted); white-space: nowrap; }
.tip b { color: var(--ink); }
.tip .t-head { font-weight: 700; color: var(--ink); }
.tip .key { display: inline-block; width: 12px; height: 2px; margin-right: 6px; vertical-align: middle; }
.as-table { margin-top: 6px; font-size: 0.84rem; }
.as-table summary { cursor: pointer; color: var(--link); }
.as-table .tbl { margin: 6px 0 0; }

.foot { max-width: 48rem; margin: 0 auto; padding: 20px 16px calc(32px + env(safe-area-inset-bottom, 0px)); border-top: 1px solid var(--line); font-size: 0.8rem; color: var(--muted); }

/* ---------- 狭い画面 ---------- */
@media (max-width: 34rem) {
  .tb-title, .tb-prog { display: none; }
  .mode { margin-left: auto; }
  .facts { grid-template-columns: 1fr 1fr; }
  .ch-card { grid-template-columns: 2.2rem 1fr; gap: 6px 12px; }
  .ch-card .st { grid-column: 2; justify-self: start; }
  .kid-results, .f-grid { grid-template-columns: 1fr; }
  .hbar { grid-template-columns: 1fr 6.6rem; gap: 2px 10px; }
  .cmp .hbar { grid-template-columns: 1fr 9.6rem; }
  .hbar .h-name { grid-column: 1 / -1; }
  .w-out dl { grid-template-columns: 1fr; gap: 0; }
  .w-out dd { margin-bottom: 6px; }
  .prose .faces { grid-template-columns: repeat(3, 1fr); }
  .weather { grid-template-columns: 1fr 1fr; }
  th, td { padding: 8px 10px; }
  .quiz { padding: 16px 14px; }
  .choice { padding: 10px 12px; }
  .pager { grid-template-columns: 1fr; }
  .pager .next { grid-column: 1; }
}
