:root {
  --bg: #f4f6f8;
  --card: #fff;
  --text: #1a1a1a;
  --muted: #555;
  --accent: #1a6b4a;
  --accent2: #0b6e99;
  --orange: #ea580c;
  --warn: #b45309;
  --border: #d8dee4;
  --cta-bg: linear-gradient(135deg, #0f5132 0%, #1a6b4a 55%, #0b6e99 100%);
}

* { box-sizing: border-box; }

body {
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  margin: 0;
  padding: 1rem;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

header, footer { max-width: 720px; margin: 0 auto 1rem; }

h1 { margin: 0 0 0.25rem; font-size: 1.45rem; color: var(--accent); }
.sub { color: var(--muted); margin: 0 0 0.75rem; font-size: 0.9rem; }

.path-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  flex-wrap: wrap;
  margin: 0.75rem 0 0.35rem;
  padding: 0.65rem 0.5rem;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}

.path-item {
  flex: 1 1 5.5rem;
  min-width: 5rem;
  text-align: center;
  padding: 0.45rem 0.35rem;
  border-radius: 6px;
  font-size: 0.78rem;
  line-height: 1.35;
}

.path-early { background: #fef3c7; color: #92400e; }
.path-standard { background: #d1fae5; color: #065f46; font-weight: 600; }
.path-late { background: #dbeafe; color: #1e40af; }

.path-label { display: block; font-weight: 700; }
.path-age { display: block; font-size: 0.72rem; opacity: 0.9; }

.path-arrow { color: var(--muted); font-size: 0.85rem; flex: 0 0 auto; }

.path-visual-note {
  margin: 0 0 0.25rem;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

body.has-sticky-cta { padding-bottom: 5.5rem; }

.card {
  max-width: 720px;
  margin: 0 auto 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
}

.card--wide {
  max-width: 960px;
}

@media (min-width: 768px) {
  .card--wide .chart-wrap canvas {
    min-height: 380px;
  }
  .card--wide .chart-wrap--annual canvas {
    min-height: 240px;
  }
}


input, select, button {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  padding: 0.5rem;
  font-size: 1rem;
}

input[type="range"] {
  padding: 0;
  accent-color: var(--orange);
  margin: 0.5rem 0;
}

button {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  margin-top: 0.5rem;
  font-weight: 600;
}

button:disabled { opacity: 0.5; cursor: not-allowed; }

.check { display: flex; align-items: flex-start; gap: 0.5rem; }
.check input { width: auto; margin-top: 0.2rem; }

.disclaimer { font-size: 0.85rem; color: var(--muted); }
.note, .hint { font-size: 0.85rem; color: var(--muted); }

.hidden { display: none; }

.fieldset {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin: 0 0 1rem;
}

.fieldset legend { font-weight: 600; font-size: 0.9rem; padding: 0 0.25rem; }

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

@media (max-width: 520px) {
  .grid-2 { grid-template-columns: 1fr; }
}

.advanced summary {
  cursor: pointer;
  font-size: 0.9rem;
  color: var(--accent2);
  margin-bottom: 0.75rem;
}

/* --- Merit banner --- */
.merit-banner {
  display: flex;
  gap: 0.75rem;
  align-items: flex-start;
  background: linear-gradient(135deg, #ecfdf5 0%, #d1fae5 100%);
  border: 2px solid #6ee7b7;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.merit-banner.merit-muted {
  background: #f0f9ff;
  border-color: #7dd3fc;
}

.merit-icon { font-size: 1.75rem; line-height: 1; }

.merit-banner p { margin: 0.35rem 0 0; font-size: 0.9rem; }

/* --- Stats --- */
.milestone-section { margin-top: 1rem; }

.milestone-title {
  margin: 0 0 0.35rem;
  font-size: 1rem;
  color: var(--accent);
}

.milestone-card .big small {
  display: block;
  font-size: 0.85em;
  margin-top: 0.15rem;
}

.milestone-win { border-color: rgba(26, 107, 74, 0.35); }
.milestone-lose { border-color: rgba(180, 83, 9, 0.35); }

  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
}

.stat-grid.trio { grid-template-columns: repeat(3, 1fr); }

@media (max-width: 600px) {
  .stat-grid, .stat-grid.trio { grid-template-columns: 1fr; }
}

.stat-box {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.75rem;
  background: #fafbfc;
}

.stat-box.stat-highlight {
  border-color: #6ee7b7;
  background: #f0fdf4;
}

.stat-box.stat-orange {
  border-color: #fdba74;
  background: #fff7ed;
}

.stat-box h3 {
  margin: 0 0 0.5rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.stat-box .big {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-box.stat-orange .big { color: var(--orange); }

.stat-box .big small { font-size: 0.65em; font-weight: 500; color: var(--muted); }

.stat-row {
  display: flex;
  justify-content: space-between;
  padding: 0.25rem 0;
  font-size: 0.86rem;
  border-bottom: 1px dashed var(--border);
}

.stat-row:last-child { border-bottom: none; }

.detail-accordion {
  margin-top: 1rem;
  font-size: 0.88rem;
}

.detail-accordion summary {
  cursor: pointer;
  color: var(--muted);
}

/* --- NISA panel --- */
.chart-lead {
  font-size: 0.92rem;
  color: var(--muted);
  margin: 0 0 1rem;
}

.nisa-panel {
  background: #fff7ed;
  border: 1px solid #fed7aa;
  border-radius: 10px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0;
  font-size: 0.92rem;
}

.slider-label strong { color: var(--orange); font-size: 1.1rem; }

.slider-ticks {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

.breakeven-box {
  background: #fef3c7;
  border-left: 4px solid var(--orange);
  padding: 0.75rem 1rem;
  border-radius: 0 8px 8px 0;
  font-size: 0.92rem;
  margin-bottom: 1rem;
  line-height: 1.55;
}

/* --- Advantage hero & timeline --- */
.advantage-hero {
  background: linear-gradient(135deg, #ecfdf5, #f0fdf4);
  border: 2px solid #6ee7b7;
  border-radius: 12px;
  padding: 1.1rem 1.25rem;
  margin-bottom: 1rem;
  text-align: center;
}

.advantage-hero.advantage-neutral {
  background: #f8fafc;
  border-color: #cbd5e1;
}

.advantage-hero.advantage-neutral h3 { color: var(--text); }

.crossover-fact {
  border-color: #fcd34d;
  background: #fffbeb;
}

.crossover-fact .big { color: #92400e; font-size: 1.15rem; }

.section-lead {
  margin: -0.25rem 0 1rem;
  font-size: 0.9rem;
  color: var(--muted);
}

.result-benefit-hero {
  background: linear-gradient(135deg, #eff6ff, #ecfdf5);
  border: 2px solid #93c5fd;
  border-radius: 12px;
  padding: 1rem 1.2rem;
  margin-bottom: 1rem;
  text-align: center;
}

.result-benefit-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent2);
}

.result-benefit-verdict {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1.5;
  color: var(--text);
}

.result-benefit-note {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  line-height: 1.45;
}

/* --- NISA toggle --- */
.nisa-toggle-wrap {
  margin-top: 1.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--border);
}

.nisa-toggle {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  margin: 0;
}

.nisa-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }

.nisa-toggle-ui {
  width: 44px;
  height: 24px;
  background: #cbd5e1;
  border-radius: 999px;
  position: relative;
  flex-shrink: 0;
  transition: background 0.2s;
}

.nisa-toggle-ui::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}

.nisa-toggle input:checked + .nisa-toggle-ui {
  background: var(--orange);
}

.nisa-toggle input:checked + .nisa-toggle-ui::after {
  transform: translateX(20px);
}

.nisa-toggle-text { font-size: 0.92rem; font-weight: 600; }

.nisa-panel-title {
  margin: 0 0 0.75rem;
  font-size: 0.95rem;
  color: var(--orange);
}

tr.row-crossover {
  background: #fff9c4 !important;
  box-shadow: inset 0 0 0 2px #facc15;
}

tr.row-crossover td { font-weight: 600; }

tr.row-boundary td {
  background: #fef3c7;
  color: #92400e;
  font-weight: 700;
  text-align: center !important;
  font-size: 0.85rem;
  padding: 0.55rem;
  border-top: 2px solid #f59e0b;
  border-bottom: 2px solid #f59e0b;
}

.compare-table .col-early { background: rgba(26, 107, 74, 0.06); color: #14532d; }
.compare-table .col-normal { background: rgba(100, 116, 139, 0.08); color: #334155; }
.compare-table th.col-early { background: #dcfce7; }
.compare-table th.col-normal { background: #e2e8f0; }
.compare-table th.th-diff { background: #fffbeb; }
.compare-table th.th-group { font-size: 0.78rem; text-align: center; }
.compare-table td.col-diff { font-weight: 700; font-size: 0.9rem; }
.compare-table td.diff-plus { color: var(--accent); }
.compare-table td.diff-minus { color: #b45309; }
.compare-table td.diff-zero { color: var(--muted); }
.compare-table td.col-age { font-weight: 600; text-align: center; background: #f8fafc; }

.table-detail-extra { margin-top: 0.75rem; }

.advantage-kicker {
  margin: 0 0 0.35rem;
  font-size: 0.82rem;
  color: var(--muted);
}

.advantage-hero h3 {
  margin: 0 0 0.5rem;
  font-size: 1.05rem;
  color: var(--accent);
}

.advantage-main {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 0.35rem;
  margin: 0.25rem 0 0.5rem;
}

.advantage-age {
  font-size: 2.5rem;
  font-weight: 800;
  color: var(--accent);
  line-height: 1;
}

.advantage-until {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--text);
}

.advantage-desc {
  margin: 0;
  font-size: 0.9rem;
  color: var(--muted);
  text-align: left;
}

.timeline-wrap { margin-bottom: 1rem; }

.timeline-bar {
  display: flex;
  height: 2.25rem;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.tl-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 2rem;
  font-size: 0.65rem;
  color: #fff;
  font-weight: 600;
}

.tl-early { background: #1a6b4a; }
.tl-normal { background: #94a3b8; }

.tl-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; padding: 0 2px; }

.timeline-legend {
  display: flex;
  gap: 1rem;
  margin-top: 0.4rem;
  font-size: 0.8rem;
  color: var(--muted);
}

.tl-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.tl-dot.early { background: #1a6b4a; }
.tl-dot.normal { background: #94a3b8; }

.timeline-note {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--orange);
  font-weight: 600;
}

.chart-mode {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.88rem;
}

.chart-mode-label { color: var(--muted); }

.chart-mode-opt {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  cursor: pointer;
}

.chart-mode-opt input { width: auto; margin: 0; }

.end-compare .plus-text { color: var(--accent); }
.end-compare .minus-text { color: var(--warn); }

.winner.early { color: var(--accent); font-weight: 600; }
.winner.normal { color: #64748b; font-weight: 600; }

.chart-wrap { overflow-x: auto; margin: 0.5rem 0; position: relative; }

canvas { max-width: 100%; width: 100%; height: auto; display: block; }

.chart-tooltip {
  position: absolute;
  z-index: 5;
  background: #1e293b;
  color: #fff;
  font-size: 0.92rem;
  line-height: 1.5;
  padding: 0.55rem 0.75rem;
  border-radius: 8px;
  pointer-events: none;
  white-space: nowrap;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

.chart-tooltip .tip-age {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.chart-tooltip .tip-row {
  font-size: 0.9rem;
}

.chart-tooltip .tip-green { color: #86efac; }
.chart-tooltip .tip-gray { color: #cbd5e1; }
.chart-tooltip .tip-orange { color: #fdba74; }

.chart-subtitle {
  margin: 1.25rem 0 0.25rem;
  font-size: 0.95rem;
  color: var(--text);
}

.chart-legend {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
  font-size: 0.82rem;
}

.chart-legend li { display: flex; align-items: center; gap: 0.35rem; }

.dot {
  width: 12px;
  height: 12px;
  border-radius: 2px;
  display: inline-block;
}

.dot-gray { background: #94a3b8; }
.dot-green { background: #1a6b4a; }
.dot-orange { background: #ea580c; }

/* --- Table --- */
.table-scroll { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.84rem;
}

th, td {
  border: 1px solid var(--border);
  padding: 0.4rem 0.5rem;
  text-align: right;
}

th:first-child, td:first-child { text-align: center; }

th { background: #eef2f6; }

td.plus { color: var(--accent); font-weight: 600; }
td.minus { color: var(--warn); }

#insight-list {
  margin: 0;
  padding-left: 1.2rem;
  font-size: 0.92rem;
}

#insight-list li { margin-bottom: 0.55rem; }

/* --- CTA --- */
.cta-card {
  background: var(--cta-bg);
  color: #fff;
  text-align: center;
  border: none;
}

.cta-card h2 {
  font-size: 1.05rem;
  margin: 0.5rem 0 1rem;
  line-height: 1.55;
  font-weight: 600;
}

.cta-lead {
  margin: 0;
  font-size: 0.82rem;
  opacity: 0.9;
}

.cta-card p { font-size: 0.9rem; opacity: 0.95; }

.cta-icon { font-size: 2rem; }

.cta-button {
  display: inline-block;
  background: #fff;
  color: #0f5132;
  font-weight: 700;
  font-size: 1rem;
  padding: 0.85rem 1.5rem;
  border-radius: 999px;
  text-decoration: none;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.2);
  transition: transform 0.15s;
}

.cta-button:hover { transform: scale(1.02); }

.cta-note {
  margin: 0.75rem 0 0;
  font-size: 0.75rem;
  opacity: 0.75;
}

/* --- Sticky CTA (UX-A1) --- */
.cta-sticky {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100;
  padding: 0.65rem 1rem calc(0.65rem + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.97);
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 20px rgba(0, 0, 0, 0.12);
  text-align: center;
}

.cta-sticky.hidden { display: none; }

.cta-sticky-lead {
  margin: 0 0 0.45rem;
  font-size: 0.78rem;
  color: var(--muted);
}

.cta-sticky-button {
  display: block;
  width: 100%;
  max-width: 420px;
  margin: 0 auto;
  padding: 0.85rem 1rem;
  background: var(--cta-bg);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  text-decoration: none;
  border-radius: 999px;
  box-shadow: 0 2px 10px rgba(26, 107, 74, 0.35);
}

.cta-sticky-button:hover { opacity: 0.95; }
