:root {
  --bg: #F6F3ED; --bg-card: #FDFBF6; --bg-input: #FFFFFF;
  --ink: #1C1A17; --ink-soft: #4A453E; --ink-mute: #8A847A;
  --rule: #E0D9CC; --rule-soft: #EDE7DA;
  --accent: #B44B1C; --accent-soft: #E8DCC9; --accent-bg: #FBF1E3;
  --sage: #6B7A5A; --sage-soft: #E3E6DB; --gold: #A47E3B;
  --f-sans: 'Zen Kaku Gothic New', system-ui, sans-serif;
  --f-serif: 'Zen Old Mincho', serif;
  --f-mono: 'Zen Kaku Gothic New', system-ui, sans-serif;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--f-sans); font-weight: 500;
  color: var(--ink); background: var(--bg);
  line-height: 1.75;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
.hero-amount-value, .result-amount-monthly, .breakdown-value, .breakdown-row.formula,
.sim-input-wrap input, .sim-inline-note strong, .result-amount-yearly strong,
.tl-when, .source-url, .last-updated, .callout-strong, .amount-table-value {
  font-variant-numeric: tabular-nums;
}

/* ========== ナビ ========== */
.topnav {
  border-bottom: 1px solid var(--rule);
  background: rgba(246, 243, 237, 0.88);
  position: sticky; top: 0; z-index: 50;
  backdrop-filter: blur(8px);
}
.topnav-inner {
  max-width: 720px; margin: 0 auto; padding: 14px 20px;
  display: flex; align-items: center; justify-content: space-between;
}
.logo {
  font-family: var(--f-serif); font-weight: 700;
  font-size: 17px; letter-spacing: 0.02em;
  color: var(--ink); text-decoration: none;
  white-space: nowrap;
}
.logo span { color: var(--accent); }
/* 制度ページではタブと重複するので非表示 (homepageでは nav-meta を使う) */
.breadcrumb { display: none; }
.nav-meta {
  font-size: 11px; color: var(--ink-mute);
  letter-spacing: 0.08em; font-weight: 700;
}

/* ヘッダーのスクロール挙動。タブを持つページ(=制度ページ)でのみ有効。
   - 上から30px超: ロゴバーを折りたたむ(常に小さく)
   - 下スクロール (100px超): 上部タブ(.tabs)のみ隠す。サブタブは常に表示
   - 上スクロール: 上部タブを再表示
   - ページ最上部: フル表示 */
.topnav:has(.tabs) .topnav-inner {
  transition: max-height 0.25s ease, padding 0.2s ease, opacity 0.15s ease;
  max-height: 60px;
  overflow: hidden;
}
body.scrolled .topnav:has(.tabs) .topnav-inner {
  max-height: 0;
  padding-top: 0; padding-bottom: 0;
  opacity: 0;
}
.topnav:has(.tabs) .tabs {
  transition: max-height 0.25s ease, padding 0.2s ease, opacity 0.15s ease;
  max-height: 80px;
  overflow: hidden;
}
body.header-hidden .topnav:has(.tabs) .tabs {
  max-height: 0;
  padding-top: 0; padding-bottom: 0;
  opacity: 0;
  border-bottom-width: 0;
}
.tabs {
  max-width: 720px; margin: 0 auto; padding: 8px 20px 0;
  display: flex; gap: 4px;
  border-bottom: 1px solid var(--rule);
}
.tab {
  flex: 1; padding: 14px 6px;
  background: none; border: none;
  border-bottom: 3px solid transparent;
  font-family: var(--f-sans); font-weight: 700; font-size: 13px;
  color: var(--ink-mute); cursor: pointer; transition: all .2s;
  letter-spacing: 0.04em;
}
.tab.active { color: var(--ink); border-bottom-color: var(--accent); }
.tab .tab-icon { display: block; font-size: 20px; margin-bottom: 4px; }
.sub-tabs {
  max-width: 720px; margin: 0 auto; padding: 14px 20px;
  display: flex; gap: 6px; overflow-x: auto;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
}
.sub-tabs::-webkit-scrollbar { display: none; }
.sub-tab {
  flex-shrink: 0; padding: 8px 14px;
  border: 1px solid var(--rule); background: var(--bg-card);
  border-radius: 999px;
  font-size: 13px; font-weight: 500; color: var(--ink-soft);
  cursor: pointer; white-space: nowrap; transition: all .15s;
}
.sub-tab.active { background: var(--ink); color: var(--bg-card); border-color: var(--ink); }

/* ========== メイン ========== */
main { max-width: 720px; margin: 0 auto; padding: 0 20px 80px; }

/* ========== ヒーロー ========== */
.hero { padding: 36px 0 28px; position: relative; }
.hero-meta {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 4px 12px; background: var(--accent-bg);
  border: 1px solid var(--accent-soft); border-radius: 999px;
  font-size: 11px; font-weight: 700; color: var(--accent);
  letter-spacing: 0.1em; margin-bottom: 20px;
  margin-right: 6px;
}

/* 所得制限バッジの色バリエーション */
.hero-meta-income-none {
  background: var(--sage-soft); border-color: #C9D2BE; color: var(--sage);
}
.hero-meta-income-yes {
  background: #F0E7D9; border-color: #E2D5BC; color: var(--gold);
}
.hero-meta-income-tied {
  background: var(--rule-soft); border-color: var(--rule); color: var(--ink-soft);
}
.hero-title {
  font-family: var(--f-serif); font-weight: 700;
  font-size: 32px; line-height: 1.45;
  letter-spacing: 0.01em; color: var(--ink); margin-bottom: 18px;
}
.hero-title em {
  font-style: normal;
  background: linear-gradient(180deg, transparent 62%, var(--accent-bg) 62%);
  padding: 0 2px;
}
.hero-official {
  display: flex; gap: 10px; padding: 14px 16px;
  background: var(--bg-card); border: 1px solid var(--rule);
  border-radius: 8px; margin-bottom: 18px;
  font-size: 13px; color: var(--ink-soft);
}
.hero-official-label {
  flex-shrink: 0; font-size: 11px; font-weight: 700;
  color: var(--ink-mute); letter-spacing: 0.08em; line-height: 1.7;
}
.hero-intro {
  font-size: 15px; color: var(--ink-soft);
  line-height: 1.85; margin-bottom: 28px;
}
.hero-intro mark {
  background: var(--sage-soft); padding: 0 3px; border-radius: 2px;
  font-weight: 700; color: var(--ink);
}
.hero-amount-card {
  background: var(--ink); color: var(--bg-card);
  border-radius: 14px; padding: 28px 24px;
  position: relative; overflow: hidden;
}
.hero-amount-card::before {
  content: ''; position: absolute;
  top: -40px; right: -40px;
  width: 180px; height: 180px;
  background: radial-gradient(circle, var(--accent) 0%, transparent 70%);
  opacity: 0.4;
}
.hero-amount-label {
  font-size: 11px; font-weight: 700; letter-spacing: 0.15em;
  opacity: 0.7; margin-bottom: 10px;
}
.hero-amount-value {
  font-family: var(--f-mono); font-weight: 700; font-size: 36px;
  line-height: 1.1; letter-spacing: -0.02em; margin-bottom: 6px;
}
.hero-amount-value small {
  font-size: 18px; font-weight: 500; opacity: 0.8; margin-left: 4px;
}
.hero-amount-note {
  font-size: 12px; opacity: 0.65; line-height: 1.7; margin-top: 12px;
}

/* multi-amount table */
.amount-table {
  display: flex; flex-direction: column; gap: 10px;
  position: relative; z-index: 1;
}
.amount-table-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding-bottom: 10px;
  border-bottom: 1px solid rgba(253, 251, 246, 0.12);
}
.amount-table-row:last-child { border-bottom: none; padding-bottom: 0; }
.amount-table-row.featured .amount-table-value { color: #FFD9B0; }
.amount-table-label { font-size: 13px; opacity: 0.85; }
.amount-table-value {
  font-family: var(--f-mono); font-weight: 700; font-size: 22px;
  letter-spacing: -0.01em;
}
.amount-table-value small {
  font-size: 12px; font-weight: 500; opacity: 0.8; margin-left: 2px;
}

/* callout */
.callout {
  margin-top: 18px; padding: 14px 16px;
  background: var(--accent-bg); border: 1px solid var(--accent-soft);
  border-radius: 10px;
  font-size: 13px; color: var(--ink-soft); line-height: 1.7;
  display: flex; gap: 12px; align-items: flex-start;
}
.callout-icon {
  flex-shrink: 0; width: 28px; height: 28px;
  border-radius: 50%; background: var(--accent); color: var(--bg-card);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-serif); font-size: 14px; font-weight: 700;
}
.callout-strong { color: var(--accent); font-weight: 700; }

/* ========== セクション共通 ========== */
section { padding: 36px 0; border-top: 1px solid var(--rule); }
.section-label {
  font-size: 11px; font-weight: 700; color: var(--ink-mute);
  letter-spacing: 0.18em; margin-bottom: 8px;
}
.section-title {
  font-family: var(--f-serif); font-weight: 700; font-size: 22px;
  line-height: 1.5; margin-bottom: 6px;
}
.section-sub { font-size: 13px; color: var(--ink-mute); margin-bottom: 24px; }

/* ========== シミュレーター ========== */
.sim {
  background: var(--bg-card); border: 1px solid var(--rule);
  border-radius: 14px; padding: 24px 22px;
}
.sim-field { margin-bottom: 22px; }
.sim-field:last-of-type { margin-bottom: 0; }
.sim-label {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 13px; font-weight: 700; color: var(--ink); margin-bottom: 10px;
}
.sim-hint { font-size: 11px; font-weight: 500; color: var(--ink-mute); }
.chip-row { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  flex: 1; min-width: 60px; padding: 11px 4px;
  border: 1px solid var(--rule); background: var(--bg-input);
  border-radius: 10px;
  font-family: var(--f-sans); font-size: 14px; font-weight: 600;
  color: var(--ink-soft); cursor: pointer; transition: all .15s;
}
.chip:hover { border-color: var(--ink-soft); }
.chip.active { background: var(--ink); color: var(--bg-card); border-color: var(--ink); }
.sim-input-wrap { position: relative; display: flex; align-items: center; }
.sim-input-wrap input {
  width: 100%; padding: 14px 48px 14px 16px;
  border: 1px solid var(--rule); background: var(--bg-input);
  border-radius: 10px;
  font-family: var(--f-mono); font-size: 17px; font-weight: 700;
  color: var(--ink); letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
}
.sim-input-wrap input:focus {
  outline: none; border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-bg);
}
.sim-input-unit {
  position: absolute; right: 16px;
  font-size: 13px; color: var(--ink-mute); pointer-events: none;
}
select.sim-select {
  width: 100%; padding: 14px 16px;
  border: 1px solid var(--rule); background: var(--bg-input);
  border-radius: 10px;
  font-family: var(--f-sans); font-size: 15px; font-weight: 600;
  color: var(--ink); cursor: pointer; appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%234A453E' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center;
}
.sim-inline-note {
  margin-top: 8px; font-size: 12px; color: var(--ink-mute); line-height: 1.6;
}
.sim-inline-note strong { color: var(--ink-soft); }

/* ========== 結果 ========== */
.result {
  margin-top: 28px;
  background: linear-gradient(180deg, var(--accent-bg) 0%, var(--bg-card) 100%);
  border: 1px solid var(--accent-soft); border-radius: 14px;
  padding: 30px 24px 24px; position: relative;
}
.result-intro {
  font-family: var(--f-serif); font-size: 17px; font-weight: 500;
  color: var(--ink-soft); margin-bottom: 4px; letter-spacing: 0.01em;
}
.result-amount { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.result-amount-monthly {
  font-family: var(--f-mono); font-weight: 700; font-size: 44px;
  color: var(--accent); letter-spacing: -0.02em; line-height: 1;
}
.result-amount-monthly small {
  font-size: 18px; font-weight: 600; color: var(--ink); margin-left: 2px;
}
.result-amount-yearly {
  font-size: 13px; color: var(--ink-soft); margin-top: 8px; font-weight: 500;
}
.result-amount-yearly strong {
  font-family: var(--f-mono); font-weight: 700; color: var(--ink); font-size: 14px;
}
.result-amount.disabled .result-amount-monthly { color: var(--ink-mute); font-size: 28px; }

/* ========== 計算内訳 ========== */
.breakdown {
  margin-top: 22px; padding-top: 18px;
  border-top: 1px dashed var(--accent-soft);
}
.breakdown-title {
  font-size: 11px; font-weight: 700; color: var(--accent);
  letter-spacing: 0.15em; margin-bottom: 14px;
}
.breakdown-row {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 8px 0; font-size: 13px; color: var(--ink-soft);
}
.breakdown-row.subtract .breakdown-value::before {
  content: '−'; margin-right: 4px; color: var(--ink-mute);
}
.breakdown-row.formula {
  margin-top: 10px; padding: 14px 16px;
  background: var(--bg-card); border-radius: 8px;
  border: 1px solid var(--accent-soft);
  font-family: var(--f-mono); font-size: 14px; font-weight: 700; color: var(--ink);
}
.breakdown-row.formula::before {
  content: '='; color: var(--accent); font-weight: 700; margin-right: 10px;
}
.breakdown-value {
  font-family: var(--f-mono); font-weight: 600; color: var(--ink);
}
.breakdown-desc {
  display: block; font-size: 11px; color: var(--ink-mute);
  font-weight: 500; font-family: var(--f-sans); margin-top: 2px;
}
.breakdown-row.muted .breakdown-value { color: var(--ink-mute); }
.breakdown-row.bonus { color: var(--accent); }
.breakdown-row.bonus .breakdown-value { color: var(--accent); }

/* ========== 注意書き ========== */
.disclaimer {
  margin-top: 18px; padding: 12px 14px;
  background: var(--bg-card); border-left: 3px solid var(--gold);
  border-radius: 4px; font-size: 12px; color: var(--ink-soft); line-height: 1.7;
}

/* ========== タイムライン ========== */
.timeline { position: relative; padding-left: 28px; margin-top: 8px; }
.timeline::before {
  content: ''; position: absolute;
  left: 7px; top: 8px; bottom: 8px; width: 1px; background: var(--rule);
}
.tl-item { position: relative; padding-bottom: 22px; }
.tl-item:last-child { padding-bottom: 0; }
.tl-item::before {
  content: ''; position: absolute;
  left: -28px; top: 6px; width: 15px; height: 15px;
  border-radius: 50%; background: var(--bg);
  border: 2px solid var(--rule);
}
.tl-item.key::before { border-color: var(--accent); background: var(--accent); }
.tl-item.done::before { border-color: var(--sage); background: var(--sage); }
.tl-when {
  font-family: var(--f-mono); font-size: 11px; font-weight: 700;
  color: var(--accent); letter-spacing: 0.08em; margin-bottom: 2px;
}
.tl-item.done .tl-when { color: var(--sage); }
.tl-item:not(.key):not(.done) .tl-when { color: var(--ink-mute); }
.tl-title { font-size: 14px; font-weight: 700; color: var(--ink); margin-bottom: 2px; }
.tl-desc { font-size: 12px; color: var(--ink-soft); line-height: 1.65; }

/* ========== 用語解説/FAQ ========== */
.glossary-item {
  border: 1px solid var(--rule); border-radius: 10px;
  margin-bottom: 10px; background: var(--bg-card);
  overflow: hidden; transition: border-color .15s;
}
.glossary-item[open] { border-color: var(--ink-soft); }
.glossary-item summary {
  padding: 16px 18px; cursor: pointer;
  font-size: 14px; font-weight: 700; color: var(--ink);
  list-style: none; display: flex;
  justify-content: space-between; align-items: center; gap: 12px;
}
.glossary-item summary::-webkit-details-marker { display: none; }
.glossary-item summary::after {
  content: '+'; font-family: var(--f-mono);
  font-size: 18px; font-weight: 400; color: var(--ink-mute);
  transition: transform .2s; flex-shrink: 0;
}
.glossary-item[open] summary::after { transform: rotate(45deg); }
.glossary-body {
  padding: 0 18px 18px; font-size: 13px;
  color: var(--ink-soft); line-height: 1.85;
}
.glossary-body p + p { margin-top: 8px; }
.glossary-body strong {
  color: var(--ink); background: var(--sage-soft); padding: 0 3px;
}
.glossary-source {
  margin-top: 10px; padding-top: 10px;
  border-top: 1px dashed var(--rule);
  font-size: 11px; color: var(--ink-mute);
}
.glossary-source a {
  color: var(--ink-soft); text-decoration: underline;
  text-decoration-color: var(--rule); text-underline-offset: 3px;
}
.glossary-source a:hover { color: var(--accent); }

/* ========== 原典リンク ========== */
.sources-grid { display: grid; gap: 10px; }
.source-link {
  display: flex; align-items: flex-start; gap: 14px;
  padding: 14px 16px; background: var(--bg-card);
  border: 1px solid var(--rule); border-radius: 10px;
  text-decoration: none; color: var(--ink); transition: all .15s;
}
.source-link:hover { border-color: var(--ink); transform: translateY(-1px); }
.source-icon {
  flex-shrink: 0; width: 38px; height: 38px;
  border-radius: 8px; background: var(--accent-bg); color: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--f-mono); font-size: 10px; font-weight: 700;
  letter-spacing: 0.05em;
}
.source-label {
  font-size: 11px; color: var(--ink-mute); font-weight: 600;
  letter-spacing: 0.08em; margin-bottom: 2px;
}
.source-title { font-size: 13px; font-weight: 700; line-height: 1.5; }
.source-url {
  font-family: var(--f-mono); font-size: 10px; color: var(--ink-mute);
  margin-top: 3px; overflow: hidden;
  text-overflow: ellipsis; white-space: nowrap;
}

/* ========== フッター ========== */
footer {
  margin-top: 60px; padding: 30px 20px;
  border-top: 1px solid var(--rule);
  text-align: center; font-size: 11px;
  color: var(--ink-mute); line-height: 1.9;
}
.last-updated {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; background: var(--sage-soft);
  border-radius: 999px; font-family: var(--f-mono);
  font-size: 10px; font-weight: 700; color: var(--sage);
  letter-spacing: 0.06em; margin-bottom: 12px;
}
.last-updated::before {
  content: ''; width: 6px; height: 6px;
  border-radius: 50%; background: var(--sage);
}
