:root {
  color-scheme: light;
  --page: #f9f9f7;
  --surface: #fcfcfb;
  --surface-2: #f3f2ee;
  --text-primary: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #898781;
  --grid: #e1e0d9;
  --baseline: #c3c2b7;
  --border: rgba(11, 11, 11, 0.10);
  --series-1: #2a78d6;   /* blue: 社会保障・年金 */
  --series-1-wash: rgba(42, 120, 214, 0.10);
  --series-2: #eb6834;   /* orange: 医療・高齢化率 */
  --series-neutral: #b9b8b1; /* other budget items */
  --series-neutral-text: #6f6e69;
  --good: #0ca30c;
  --max-width: 1040px;
}

@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --page: #0d0d0d;
    --surface: #1a1a19;
    --surface-2: #232320;
    --text-primary: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #898781;
    --grid: #2c2c2a;
    --baseline: #383835;
    --border: rgba(255, 255, 255, 0.10);
    --series-1: #3987e5;
    --series-1-wash: rgba(57, 135, 229, 0.14);
    --series-2: #d95926;
    --series-neutral: #4a4a46;
    --series-neutral-text: #a9a8a2;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

.wrap {
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 20px;
}

header.hero {
  padding: 32px 0 16px;
  border-bottom: 1px solid var(--border);
}

header.hero .eyebrow {
  display: none;
}

header.hero h1 {
  font-size: 28px;
  margin: 0 0 20px;
  letter-spacing: -0.01em;
}

header.hero p.lead {
  color: var(--text-secondary);
  font-size: 17px;
  max-width: 640px;
  margin: 0 0 4px;
}

header.hero .updated {
  color: var(--text-muted);
  font-size: 13px;
  margin-top: 16px;
}

.live-status {
  display: inline-block;
  margin-left: 10px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11.5px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.live-status--live { color: var(--good); border-color: currentColor; }
.live-status--fallback { color: var(--text-muted); }
.live-status--partial { color: var(--series-2); border-color: currentColor; }

.live-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 500;
  vertical-align: middle;
  background: var(--surface-2);
  border: 1px solid var(--border);
}

.live-badge--live { color: var(--good); border-color: currentColor; }
.live-badge--fallback { color: var(--text-muted); }

nav.toc {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  margin-top: 24px;
  font-size: 14px;
}

nav.toc a {
  color: var(--text-secondary);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}

nav.toc a:hover {
  color: var(--series-1);
  border-bottom-color: var(--series-1);
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  margin: 28px 0 0;
}

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

.stat-tile {
  background: var(--surface);
  padding: 18px 16px;
}

.stat-tile .label {
  color: var(--text-secondary);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat-tile .value {
  font-size: clamp(22px, 3vw, 28px);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.stat-tile .delta {
  font-size: 13px;
  color: var(--good);
  margin-top: 4px;
}

section {
  padding: 48px 0;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 16px;
}

section:last-of-type { border-bottom: none; }

section h2 {
  font-size: 22px;
  margin: 0 0 6px;
  letter-spacing: -0.005em;
}

section .section-note {
  color: var(--text-secondary);
  font-size: 15px;
  max-width: 680px;
  margin: 0 0 24px;
}

.chart-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px 20px 12px;
  position: relative;
}

.chart-card .chart-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.chart-card .chart-sub {
  font-size: 12.5px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.chart-card svg {
  display: block;
  width: 100%;
  height: auto;
  overflow: visible;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  font-size: 12.5px;
  color: var(--text-secondary);
  margin-top: 10px;
}

.legend .item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  flex: none;
}

.table-toggle {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-secondary);
  font-size: 12.5px;
  border-radius: 6px;
  padding: 5px 10px;
  cursor: pointer;
  margin-top: 12px;
}

.table-toggle:hover { color: var(--text-primary); }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 12px;
  display: none;
}

.data-table.show { display: table; }

.data-table th, .data-table td {
  text-align: right;
  padding: 6px 8px;
  border-bottom: 1px solid var(--grid);
  font-variant-numeric: tabular-nums;
}

.data-table th:first-child, .data-table td:first-child {
  text-align: left;
  font-variant-numeric: normal;
}

.tooltip {
  position: absolute;
  pointer-events: none;
  background: var(--text-primary);
  color: var(--page);
  font-size: 12px;
  padding: 6px 9px;
  border-radius: 6px;
  line-height: 1.5;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, -100%);
  transition: opacity 0.08s ease;
  z-index: 10;
}

.tooltip.show { opacity: 1; }

.mark { cursor: pointer; }

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

@media (max-width: 780px) {
  .two-col { grid-template-columns: 1fr; }
}

.prose p { color: var(--text-secondary); }
.prose ul { color: var(--text-secondary); padding-left: 20px; }
.prose li { margin-bottom: 8px; }

.callout {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px 18px;
  font-size: 14.5px;
  color: var(--text-secondary);
  margin: 16px 0;
}

.callout strong { color: var(--text-primary); }

.callout code {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.92em;
}

.pillars {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin: 20px 0;
}

@media (max-width: 780px) {
  .pillars { grid-template-columns: repeat(2, 1fr); }
}

.pillar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  font-size: 13.5px;
  color: var(--text-secondary);
}

.pillar .n {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--series-1-wash);
  color: var(--series-1);
  font-weight: 700;
  font-size: 12px;
  margin-bottom: 8px;
}

footer {
  padding: 40px 0 60px;
  color: var(--text-muted);
  font-size: 12.5px;
}

footer .sources {
  list-style: none;
  padding: 0;
  margin: 12px 0;
  display: grid;
  gap: 6px;
}

footer a { color: var(--text-secondary); }

footer .disclaimer {
  margin-top: 18px;
  padding-top: 18px;
  border-top: 1px solid var(--border);
}

mark.search-highlight {
  background-color: #ffeb3b;
  color: inherit;
  padding: 2px 4px;
  border-radius: 2px;
  transition: background-color 0.2s ease;
}

@media (prefers-color-scheme: dark) {
  mark.search-highlight {
    background-color: #665c00;
  }
}

/* Hide content sections */
.stat-grid {
  display: none !important;
}

.updated {
  display: none !important;
}

nav.toc {
  display: none !important;
}

section {
  display: none !important;
}

footer {
  display: none !important;
}

p.lead {
  display: none !important;
}
