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

:root {
  --bg: #080810;
  --surface: #0f0f1a;
  --border: rgba(255,255,255,0.07);
  --text-primary: #eeeef5;
  --text-secondary: #7878a0;
  --text-muted: #44445a;

  --color-steep:    #38bdf8;  /* sky blue — very steep */
  --color-normal:   #60a5fa;  /* blue — normal upward */
  --color-flat:     #fbbf24;  /* amber — flat */
  --color-inverted: #f87171;  /* coral — inverted */

  --recession-fill: rgba(248, 113, 113, 0.07);
  --zero-line: rgba(248, 113, 113, 0.45);

  --font: 'Inter', system-ui, sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px 32px;
}

/* ─── HEADER ─────────────────────────────────────── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 28px 0 16px;
  border-bottom: 1px solid var(--border);
  gap: 16px;
  flex-wrap: wrap;
}

#header-left h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: var(--text-primary);
}

#header-left .subtitle {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 3px;
  font-weight: 400;
}

#header-right {
  display: flex;
  align-items: center;
  gap: 20px;
}

#status-badge {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1.5px;
  padding: 5px 12px;
  border-radius: 4px;
  transition: background 0.4s ease, color 0.4s ease;
}

.status-steep    { background: rgba(56,  189, 248, 0.15); color: var(--color-steep);    border: 1px solid rgba(56,  189, 248, 0.25); }
.status-normal   { background: rgba(96,  165, 250, 0.15); color: var(--color-normal);   border: 1px solid rgba(96,  165, 250, 0.25); }
.status-flat     { background: rgba(251, 191,  36, 0.15); color: var(--color-flat);     border: 1px solid rgba(251, 191,  36, 0.25); }
.status-inverted { background: rgba(248, 113, 113, 0.15); color: var(--color-inverted); border: 1px solid rgba(248, 113, 113, 0.25); }

#spread-display {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 1px;
}

#spread-label {
  font-size: 10px;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

#spread-value {
  font-size: 18px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  transition: color 0.4s ease;
}

/* ─── ANNOTATION BAR ────────────────────────────── */
#annotation-bar {
  min-height: 64px;
  padding: 14px 0 10px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  border-bottom: 1px solid var(--border);
}

#annotation-date {
  flex-shrink: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--text-secondary);
  text-transform: uppercase;
  padding-top: 2px;
  min-width: 80px;
}

#annotation-text {
  font-size: 13px;
  line-height: 1.6;
  color: var(--text-secondary);
  max-width: 780px;
  transition: opacity 0.2s ease;
}

#annotation-text strong {
  color: var(--text-primary);
  font-weight: 600;
}

/* ─── MAIN CHART ─────────────────────────────────── */
#main-chart-container {
  flex: 1;
  min-height: 0;
  position: relative;
}

#main-chart {
  width: 100%;
  display: block;
}

/* D3 chart elements */
.axis text {
  fill: var(--text-muted);
  font-family: var(--font);
  font-size: 11px;
}

.axis path, .axis line {
  stroke: var(--border);
}

.axis.y-axis .domain { display: none; }

.grid-line {
  stroke: rgba(255,255,255,0.04);
  stroke-dasharray: none;
}

.zero-line {
  stroke: var(--zero-line);
  stroke-width: 1;
  stroke-dasharray: 4 3;
}

.curve-area {
  transition: fill 0.4s ease;
}

.curve-line {
  fill: none;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke 0.4s ease;
  filter: drop-shadow(0 0 6px currentColor);
}

.ghost-line {
  fill: none;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0.18;
  pointer-events: none;
}

.maturity-dot {
  stroke-width: 2;
  transition: fill 0.4s ease, stroke 0.4s ease;
}

.maturity-label-top {
  font-size: 10px;
  font-weight: 500;
  fill: var(--text-muted);
  text-anchor: middle;
  pointer-events: none;
}

.rate-label {
  font-size: 11px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  text-anchor: middle;
  pointer-events: none;
  transition: fill 0.4s ease;
}

.tooltip-line {
  stroke: rgba(255,255,255,0.15);
  stroke-width: 1;
  stroke-dasharray: 3 3;
  pointer-events: none;
}

.tooltip-box {
  pointer-events: none;
}

.recession-band {
  fill: var(--recession-fill);
  pointer-events: none;
}

/* ─── CONTROLS ───────────────────────────────────── */
#controls-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 0 8px;
}

#play-btn {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.2s, background 0.2s;
}

#play-btn:hover {
  border-color: rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.05);
}

#play-btn svg {
  width: 13px;
  height: 13px;
}

#slider-wrap {
  flex: 1;
  position: relative;
}

#time-slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 3px;
  border-radius: 2px;
  background: var(--border);
  outline: none;
  cursor: pointer;
}

#time-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
  border: none;
  transition: transform 0.1s;
}

#time-slider::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

#time-slider::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-primary);
  cursor: pointer;
  border: none;
}

#date-display {
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--text-primary);
  min-width: 80px;
  text-align: right;
}

#speed-control {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: var(--text-muted);
}

#speed-select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 4px;
  padding: 3px 6px;
  font-size: 11px;
  font-family: var(--font);
  cursor: pointer;
  outline: none;
}

#speed-select:focus {
  border-color: rgba(255,255,255,0.2);
}

/* ─── TIMELINE CHART ─────────────────────────────── */
#timeline-container {
  margin-top: 4px;
}

#timeline-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 6px;
}

#timeline-chart {
  width: 100%;
  display: block;
}

.spread-line {
  fill: none;
  stroke-width: 1.5;
}

.spread-area-positive {
  opacity: 0.12;
}

.spread-area-negative {
  opacity: 0.18;
}

.timeline-cursor {
  stroke: rgba(255,255,255,0.3);
  stroke-width: 1;
  pointer-events: none;
}

.timeline-cursor-dot {
  pointer-events: none;
}

/* ─── RESPONSIVE ─────────────────────────────────── */
@media (max-width: 700px) {
  #app { padding: 0 16px 24px; }
  #header-left h1 { font-size: 20px; }
  #header-right { gap: 12px; }
  #spread-value { font-size: 15px; }
  #annotation-bar { flex-direction: column; gap: 4px; min-height: auto; }
  #annotation-date { min-width: auto; }
  #speed-control { display: none; }
}
