* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a0a0f;
  color: #e0e0e8;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  padding: 20px;
  max-width: 1400px;
  margin: 0 auto;
}

/* Header */
.header { margin-bottom: 16px; }
.header h1 {
  font-size: 1.8rem;
  font-weight: 700;
  color: #fff;
  margin-bottom: 4px;
}
.header p {
  font-size: 0.9rem;
  color: #888;
}

/* Stats */
.stats {
  display: flex;
  gap: 24px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}
.stat {
  display: flex;
  flex-direction: column;
}
.stat .value {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
}
.stat .label {
  font-size: 0.75rem;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Controls */
.controls {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
  align-items: center;
}
.mode-btn {
  background: transparent;
  border: 1px solid #444;
  color: #bbb;
  padding: 8px 18px;
  border-radius: 20px;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.mode-btn:hover {
  border-color: #888;
  color: #fff;
  background: rgba(255, 255, 255, 0.05);
}
.mode-btn.active {
  background: #e0e0e0;
  border-color: #e0e0e0;
  color: #111;
}

/* Legend */
.legend {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.75rem;
  color: #888;
  margin-bottom: 12px;
}
.legend-bar {
  width: 200px;
  height: 10px;
  border-radius: 5px;
}
.legend-bar.mode-exposure {
  background: linear-gradient(to right, hsl(120,70%,45%), hsl(60,70%,45%), hsl(0,70%,45%));
}
.legend-bar.mode-pay {
  background: linear-gradient(to right, hsl(0,70%,45%), hsl(60,70%,45%), hsl(120,70%,45%));
}
.legend-bar.mode-education {
  background: linear-gradient(to right, hsl(120,70%,45%), hsl(60,70%,45%), hsl(0,70%,45%));
}
.legend-bar.mode-growth {
  background: linear-gradient(to right, hsl(0,70%,45%), hsl(60,70%,45%), hsl(120,70%,45%));
}

/* Mode description */
.mode-desc {
  font-size: 0.95rem;
  color: #fff;
  margin: 8px 0;
  line-height: 1.5;
}

/* Canvas */
#canvas-wrap {
  width: 100%;
  position: relative;
  border-radius: 8px;
  overflow: hidden;
}
#treemap {
  display: block;
  width: 100%;
}

/* Tooltip */
#tooltip {
  display: none;
  position: fixed;
  background: #1a1a24;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 14px;
  max-width: 320px;
  font-size: 0.85rem;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
}
.tt-title {
  font-weight: 700;
  font-size: 1rem;
  color: #fff;
  margin-bottom: 2px;
}
.tt-category {
  font-size: 0.75rem;
  color: #6366f1;
  margin-bottom: 8px;
}
.tt-divider {
  border-top: 1px solid #333;
  margin: 8px 0;
}
.tt-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
  gap: 16px;
}
.tt-row span { color: #888; white-space: nowrap; }
.tt-row .tt-val { text-align: right; white-space: nowrap; }
.tt-row b { color: #fff; }
.tt-row small { color: #777; margin-left: 4px; font-size: 0.75rem; }
.tt-rationale {
  font-size: 0.8rem;
  color: #aaa;
  line-height: 1.4;
  font-style: italic;
}

/* Insights Section */
.insights {
  margin-top: 32px;
}
.insights h2 {
  font-size: 1.4rem;
  font-weight: 700;
  margin: 0 0 16px 0;
  color: #fff;
}
.insight-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}
.card {
  background: #1a1a24;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: 16px 18px;
  position: relative;
}
.card-num {
  position: absolute;
  top: 14px;
  right: 16px;
  font-size: 1.6rem;
  font-weight: 800;
  color: #2a2a3a;
}
.card h3 {
  font-size: 0.95rem;
  font-weight: 600;
  color: #e0e0e0;
  margin: 0 0 8px 0;
  padding-right: 30px;
}
.card p {
  font-size: 0.82rem;
  color: #999;
  line-height: 1.5;
  margin: 0;
}
.card strong {
  color: #fff;
}

/* Author Section */
.author-section {
  margin-top: 40px;
}
.author-section h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 16px 0;
}
.author-card {
  display: flex;
  align-items: center;
  gap: 20px;
  background: #1a1a24;
  border: 1px solid #2a2a3a;
  border-radius: 10px;
  padding: 20px;
  max-width: 480px;
}
.author-img {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
.author-info {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.author-info h3 {
  font-size: 1rem;
  font-weight: 600;
  color: #fff;
  margin: 0;
}
.author-detail {
  font-size: 0.82rem;
  color: #999;
  margin: 2px 0;
}
.author-detail a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}
.author-detail a:hover {
  color: #fff;
}
.author-sponsored {
  font-size: 0.75rem;
  color: #777;
  margin: 8px 0 0 0;
}
.author-sponsored a {
  color: #777;
  font-weight: 700;
  text-decoration: underline;
}
.author-sponsored a:hover {
  color: #fff;
}

/* Footer */
.footer-title {
  font-size: 1.4rem;
  font-weight: 700;
  color: #fff;
  margin: 0 0 12px 0;
}
.footer {
  margin-top: 40px;
  font-size: 0.72rem;
  color: #777;
  line-height: 1.6;
  max-width: 960px;
}
.footer p {
  margin: 6px 0;
}
.footer a, .mode-desc a, .copyright a {
  color: inherit;
  font-weight: 700;
  text-decoration: underline;
}
.footer a:hover, .mode-desc a:hover, .copyright a:hover {
  color: #fff;
}
.footer strong {
  color: #999;
}
.edu-section {
  margin-top: 12px;
}
.edu-section p {
  margin: 0 0 6px 0;
  font-size: 0.75rem;
  color: #999;
}
.edu-table {
  margin-top: 6px;
  border-collapse: collapse;
  font-size: 0.72rem;
  color: #888;
}
.edu-table td {
  padding: 2px 12px 2px 0;
  border-bottom: 1px solid #222;
}
.edu-table td:first-child {
  font-weight: 700;
  color: #aaa;
  width: 24px;
}
.edu-table td:last-child {
  color: #555;
  font-style: italic;
}

/* Copyright */
.copyright {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid #222;
  font-size: 0.68rem;
  color: #555;
  line-height: 1.5;
}
.copyright p {
  margin: 0;
}

/* Language nav */
.lang-nav {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.lang-nav a {
  color: #777;
  text-decoration: none;
  font-size: 0.85rem;
  padding: 2px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}
.lang-nav a:hover { color: #fff; }
.lang-nav a.active {
  color: #fff;
  background: #2a2a3a;
}

/* Responsive — Tablet */
@media (max-width: 768px) {
  .header h1 { font-size: 1.5rem; }
  .stat .value { font-size: 1.2rem; }
  .insight-cards { grid-template-columns: repeat(2, 1fr); }
  .author-card { max-width: 100%; }
}

/* Responsive — Mobile */
@media (max-width: 600px) {
  body { padding: 12px; }
  .header h1 { font-size: 1.3rem; }
  .stats { gap: 16px; }
  .stat .value { font-size: 1.1rem; }
  .controls { gap: 4px; }
  .mode-btn { padding: 5px 10px; font-size: 0.8rem; }
  .legend-bar { width: 120px; }
  .insight-cards { grid-template-columns: 1fr; }
  .author-card { flex-direction: column; align-items: center; text-align: center; }
}
