:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --surface: #fcfcfb;
  --surface-2: #f1ede5;
  --border: #e3ddd2;
  --text: #1f1d1a;
  --text-2: #57534c;
  --text-3: #7a756c;
  --accent: #2a78d6;
  --accent-ink: #1c5cab;
  --principal: #2a78d6;
  --gain: #eb6834;
  --error-bg: #fdecea;
  --error-ink: #9b2c22;
  --shadow: 0 1px 2px rgba(31, 29, 26, 0.06), 0 4px 16px rgba(31, 29, 26, 0.05);
  --radius: 14px;
  --font: 'Noto Sans JP', system-ui, -apple-system, 'Hiragino Sans', sans-serif;
  --font-round: 'Zen Maru Gothic', var(--font);
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #121211;
    --surface: #1a1a19;
    --surface-2: #232321;
    --border: #34332f;
    --text: #f4f3ef;
    --text-2: #c3c2b7;
    --text-3: #9a988e;
    --accent: #3987e5;
    --accent-ink: #86b6ef;
    --principal: #3987e5;
    --gain: #d95926;
    --error-bg: #3a1d1a;
    --error-ink: #f4b4ab;
    --shadow: none;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #121211;
  --surface: #1a1a19;
  --surface-2: #232321;
  --border: #34332f;
  --text: #f4f3ef;
  --text-2: #c3c2b7;
  --text-3: #9a988e;
  --accent: #3987e5;
  --accent-ink: #86b6ef;
  --principal: #3987e5;
  --gain: #d95926;
  --error-bg: #3a1d1a;
  --error-ink: #f4b4ab;
  --shadow: none;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.7;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1; width: 100%; max-width: 1040px; margin: 0 auto; padding: 24px 16px 48px; }
a { color: var(--accent-ink); }
h1, h2 { font-family: var(--font-round); font-weight: 700; line-height: 1.4; }

/* ---------- ヘッダー・フッター */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 12px 16px; border-bottom: 1px solid var(--border); background: var(--surface);
}
.brand { font-family: var(--font-round); font-weight: 700; color: var(--text); text-decoration: none; }
.site-footer { padding: 20px 16px; text-align: center; font-size: 13px; color: var(--text-3); border-top: 1px solid var(--border); }
.site-footer a { color: var(--text-2); }

/* ---------- ボタン */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  min-height: 48px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent;
  font: 700 15px/1 var(--font); text-decoration: none; cursor: pointer; white-space: nowrap;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-plain { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, .overlay:focus-visible {
  outline: 3px solid var(--accent); outline-offset: 2px;
}

/* ---------- カード（エラー画面） */
.login-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 24px; box-shadow: var(--shadow);
}
.card-title { margin: 0 0 16px; font-size: 20px; }
.narrow { max-width: 560px; }
.prose h1 { font-size: 26px; }
.prose h2 { font-size: 18px; margin-top: 28px; }

/* ---------- フォーム部品 */
input[type="number"], select {
  min-height: 48px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--text); font: 500 16px var(--font);
}
.hint { margin: 6px 0 0; font-size: 13px; color: var(--text-3); line-height: 1.5; }
.notice { margin: 0 0 16px; padding: 12px 14px; border-radius: 10px; background: var(--surface-2); font-size: 14px; }
.notice-error { background: var(--error-bg); color: var(--error-ink); }

/* ---------- シミュレーター */
.page-title { font-size: clamp(22px, 4vw, 28px); margin: 0 0 20px; }
.panel {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow); margin-bottom: 20px;
}
.inputs { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px 20px; }
.inputs #form-errors { grid-column: 1 / -1; margin: 0; }
.field-label { display: block; font-weight: 700; font-size: 14px; margin-bottom: 6px; }
.field select, .field input { width: 100%; }
.age-row { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.unit-input { display: flex; align-items: center; gap: 8px; }
.unit-input input { flex: 1; min-width: 0; text-align: right; font-variant-numeric: tabular-nums; }
.unit-input span { color: var(--text-2); font-weight: 500; }

.result { margin: 8px 0 24px; }
.result-lead { margin: 0; color: var(--text-2); font-weight: 500; }
.result-hero { margin: 0 0 16px; font-family: var(--font-round); font-size: clamp(22px, 4vw, 30px); font-weight: 700; line-height: 1.4; }
.result-hero strong { font-size: 1.5em; color: var(--text); font-variant-numeric: tabular-nums; }
.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 0 0 12px; }
.stat { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px 16px; }
.stat dt { font-size: 13px; color: var(--text-2); }
.stat dd { margin: 2px 0 0; font-size: 22px; font-weight: 700; font-variant-numeric: tabular-nums; }
.result-notes { margin: 0; padding-left: 1.2em; color: var(--text-2); font-size: 14px; }

.chart-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.chart-head h2 { margin: 0; font-size: 18px; }
.legend { display: flex; gap: 16px; list-style: none; margin: 0; padding: 0; font-size: 14px; color: var(--text-2); }
.legend li { display: flex; align-items: center; gap: 6px; }
.swatch { display: inline-block; width: 12px; height: 12px; border-radius: 3px; vertical-align: -1px; margin-right: 6px; }
.legend .swatch { margin-right: 0; }
.swatch-principal { background: var(--principal); }
.swatch-gain { background: var(--gain); }

.chart-wrap { position: relative; width: 100%; }
.chart-svg { display: block; width: 100%; height: auto; overflow: visible; font-family: var(--font); }
.gridline { stroke: var(--border); stroke-width: 1; }
.baseline { stroke: var(--text-3); stroke-width: 1; }
.axis-label { fill: var(--text-3); font-size: 12px; font-variant-numeric: tabular-nums; }
.end-label { fill: var(--text-2); font-size: 12px; font-weight: 700; font-variant-numeric: tabular-nums; }
.area-principal { fill: var(--principal); fill-opacity: 0.22; }
.area-gain { fill: var(--gain); fill-opacity: 0.22; }
.line-principal { fill: none; stroke: var(--principal); stroke-width: 2; stroke-linejoin: round; }
.line-gain { fill: none; stroke: var(--gain); stroke-width: 2; stroke-linejoin: round; }
.line-principal-dashed { fill: none; stroke: var(--principal); stroke-width: 2; stroke-dasharray: 4 4; }
.marker-line { stroke: var(--text-3); stroke-width: 1; stroke-dasharray: 3 4; }
.crosshair { stroke: var(--text-2); stroke-width: 1; }
.dot-gain { fill: var(--gain); stroke: var(--surface); stroke-width: 2; }
.dot-principal { fill: var(--principal); stroke: var(--surface); stroke-width: 2; }
.overlay { fill: transparent; cursor: crosshair; touch-action: pan-y; }
.chart-tip {
  position: absolute; pointer-events: none; min-width: 190px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12); font-size: 13px;
}
.tip-title { font-weight: 700; margin-bottom: 4px; }
.tip-row { display: flex; justify-content: space-between; gap: 16px; font-variant-numeric: tabular-nums; color: var(--text-2); }
.tip-total { color: var(--text); font-weight: 700; }

.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 999px; padding: 3px; background: var(--surface-2); }
.segmented button {
  min-height: 36px; padding: 0 14px; border: 0; border-radius: 999px; background: transparent;
  color: var(--text-2); font: 700 14px var(--font); cursor: pointer;
}
.segmented button[aria-pressed="true"] { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0,0,0,0.1); }

.table-wrap { max-height: 560px; overflow: auto; border: 1px solid var(--border); border-radius: 10px; }
.num-table { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.num-table th, .num-table td { padding: 8px 12px; text-align: right; white-space: nowrap; border-bottom: 1px solid var(--border); }
.num-table th:first-child, .num-table td:first-child, .num-table th:nth-child(2), .num-table td:nth-child(2) { text-align: left; }
.num-table thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-2); font-size: 13px; z-index: 1; }
.sim-table td:nth-child(3) { font-weight: 700; }
.num-table tr.year-end td { border-bottom-color: var(--text-3); }

.notes h2 { font-size: 16px; margin: 8px 0; }
.notes ul { margin: 0; padding-left: 1.2em; color: var(--text-2); font-size: 14px; }

@media (max-width: 800px) {
  .inputs { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 480px) {
  .inputs { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr; }
  .stat { display: flex; justify-content: space-between; align-items: baseline; }
  .panel { padding: 16px; }
}

.chart-empty { margin: 0; padding: 48px 0; text-align: center; color: var(--text-3); }
.num-table th:first-child, .num-table td:first-child { position: sticky; left: 0; background: var(--surface); z-index: 1; }
.num-table thead th:first-child { background: var(--surface-2); z-index: 2; }

/* ---------- サイドバー（2026/10/02） */
.shell { flex: 1; display: grid; grid-template-columns: 220px minmax(0, 1fr); width: 100%; max-width: 1280px; margin: 0 auto; }
.shell-main { min-width: 0; display: flex; flex-direction: column; }
.sidebar { padding: 24px 12px; border-right: 1px solid var(--border); }
.sidebar ul { list-style: none; margin: 0; padding: 0; position: sticky; top: 16px; display: grid; gap: 4px; }
.sidebar a {
  display: block; padding: 10px 12px; border-radius: 10px; color: var(--text-2);
  text-decoration: none; font-weight: 700; font-size: 14px;
}
.sidebar a:hover { background: var(--surface-2); color: var(--text); }
.sidebar a[aria-current="page"] { background: var(--surface); color: var(--accent-ink); box-shadow: var(--shadow); border: 1px solid var(--border); }
@media (max-width: 800px) {
  .shell { grid-template-columns: 1fr; }
  .sidebar { padding: 8px 16px; border-right: 0; border-bottom: 1px solid var(--border); overflow-x: auto; }
  .sidebar ul { position: static; display: flex; gap: 8px; }
  .sidebar a { white-space: nowrap; padding: 8px 12px; }
}

/* ---------- 比較表 */
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lead-panel h2 { margin: 0 0 8px; font-size: 18px; }
.lead-panel ul { margin: 0; padding-left: 1.2em; color: var(--text-2); font-size: 15px; }
.section-title { font-size: 20px; margin: 28px 0 12px; }
.compare-wrap { max-height: none; margin-bottom: 8px; }
.compare-table { border-collapse: collapse; font-size: 14px; min-width: 1100px; width: 100%; }
.compare-table th, .compare-table td { padding: 10px 12px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; line-height: 1.6; }
.compare-table thead th { position: sticky; top: 0; background: var(--surface-2); color: var(--text-2); font-size: 13px; z-index: 1; min-width: 120px; }
.compare-table tbody th { position: sticky; left: 0; background: var(--surface); white-space: nowrap; z-index: 1; font-weight: 700; }
.compare-table thead th:first-child { left: 0; z-index: 2; }
.compare-table td.none { color: var(--text-3); }
.compare-table td { background: var(--surface); }
.section-note { margin: -4px 0 12px; color: var(--text-2); font-size: 14px; }
.page-sub { margin: -12px 0 20px; color: var(--text-2); }
.compare-table a.co { display: flex; align-items: center; gap: 10px; }
.compare-table a.co img { width: 36px; height: 36px; border-radius: 8px; flex: none; background: #fff; box-shadow: 0 0 0 1px var(--border); object-fit: contain; }

/* ---------- タブの比較表（参考: money-kotsu.net。2026/10/02） */
.tabs { margin-bottom: 8px; }
.tabs .ti { position: absolute; opacity: 0; pointer-events: none; }
.tab-labels { display: grid; grid-template-columns: repeat(auto-fit, minmax(0, 1fr)); gap: 4px; }
.tab-labels label {
  text-align: center; padding: 12px 8px; font-weight: 700; font-size: 14px; cursor: pointer;
  background: var(--surface-2); color: var(--text-2); border-radius: 10px 10px 0 0; border: 1px solid var(--border); border-bottom: 0;
}
.tab-panel { display: none; }
.ti1:checked ~ .tp1, .ti2:checked ~ .tp2, .ti3:checked ~ .tp3, .ti4:checked ~ .tp4 { display: block; }
.ti1:checked ~ .tab-labels .tl1, .ti2:checked ~ .tab-labels .tl2, .ti3:checked ~ .tab-labels .tl3, .ti4:checked ~ .tab-labels .tl4 {
  background: var(--text); color: var(--surface);
}
.ti:focus-visible ~ .tab-labels label { outline: 2px solid var(--accent); }
.tab-panel .compare-wrap { border-radius: 0 0 10px 10px; }
.mk-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.mk-table thead th { background: #3a3835; color: #fff; font-size: 13px; padding: 10px 8px; text-align: center; position: sticky; top: 0; z-index: 1; }
.mk-table thead th:first-child { left: 0; z-index: 2; }
.mk-table td { text-align: center; vertical-align: middle; padding: 12px 8px; border-bottom: 1px solid var(--border); background: var(--surface); min-width: 96px; }
.mk-table tbody th { position: sticky; left: 0; z-index: 1; background: var(--surface); text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--border); min-width: 150px; }
.mk-table a.co { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 13px; }
.mk-table a.co img { width: 36px; height: 36px; border-radius: 8px; flex: none; background: #fff; box-shadow: 0 0 0 1px var(--border); }
.mk { display: block; font-size: 30px; line-height: 1.1; font-weight: 700; }
.mk-o { color: #d93a3a; } .mk-d { color: #e8a317; } .mk-x { color: #5b6573; } .mk-n { color: var(--text-3); font-size: 22px; }
.mk-text { display: block; font-size: 12px; color: var(--text-2); margin-top: 2px; line-height: 1.4; }
.mk-legend { font-size: 12px; color: var(--text-3); margin: 8px 0 0; }
.co-cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; }
.co-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow); display: flex; flex-direction: column; }
.co-card header { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.co-card header img { width: 48px; height: 48px; border-radius: 10px; box-shadow: 0 0 0 1px var(--border); background: #fff; }
.co-card h3 { margin: 0; font-size: 17px; font-family: var(--font-round); }
.co-card dl { margin: 0 0 12px; flex: 1; }
.co-card dl div { display: grid; grid-template-columns: 7.5em 1fr; gap: 8px; padding: 8px 0; border-top: 1px dashed var(--border); font-size: 13px; }
.co-card dt { color: var(--text-3); font-weight: 700; }
.co-card dd { margin: 0; color: var(--text); }
.co-btn { width: 100%; }
@media (max-width: 480px) {
  .mk-table td { min-width: 76px; padding: 10px 4px; }
  .mk-table tbody th { min-width: 118px; padding: 8px; }
  .mk-table a.co img { width: 28px; height: 28px; }
  .tab-labels label { font-size: 13px; padding: 10px 4px; }
}
.mk-supp { display: block; margin-top: 4px; font-size: 11px; line-height: 1.4; color: var(--accent-ink); background: var(--surface-2); border-radius: 6px; padding: 2px 6px; }

/* ---------- テーマ別の資料（2026/10/21） */
.guide-list { list-style: none; margin: 16px 0 0; padding: 0; display: grid; gap: 16px; }
.guide-card {
  display: grid; grid-template-columns: 150px minmax(0, 1fr); grid-template-rows: auto 1fr; gap: 0 20px; align-items: start;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 18px; box-shadow: var(--shadow);
}
.guide-cover { grid-row: 1 / span 2; }
.guide-cover img { display: block; width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); }
.guide-no { margin: 0 0 4px; font-size: 13px; font-weight: 700; color: var(--accent-ink); }
.guide-title { margin: 0 0 8px; font-size: 18px; line-height: 1.5; }
.guide-intro { margin: 0 0 14px; font-size: 15px; line-height: 1.8; color: var(--text-2); }
.guide-actions { grid-column: 2; display: flex; flex-wrap: wrap; gap: 10px; margin-top: -6px; }
@media (max-width: 480px) {
  .guide-card { grid-template-columns: 96px minmax(0, 1fr); gap: 12px 14px; padding: 14px; }
  .guide-cover { grid-row: auto; }
  .guide-title { font-size: 16px; }
  .guide-intro { font-size: 14px; }
  .guide-actions { grid-column: 1 / -1; margin-top: 0; }
  .guide-actions .btn { flex: 1 1 100%; }
}
.nav-line-only[hidden] { display: none !important; }
