:root {
  --page: #0d0d0d;
  --surface-1: #1a1a19;
  --text-primary: #ffffff;
  --text-secondary: #c3c2b7;
  --text-muted: #898781;
  --gridline: #2c2c2a;
  --baseline: #383835;
  --border: rgba(255, 255, 255, 0.10);
  --series-1: #3987e5; /* contributions - blue */
  --series-2: #199e70; /* interest - aqua */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--page);
  color: var(--text-primary);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
}

.app {
  max-width: 1080px;
  margin: 0 auto;
  padding: 32px 24px 64px;
}

.app-header h1 {
  font-size: 28px;
  margin: 0 0 4px;
}

.back-link {
  display: inline-block;
  color: var(--text-secondary);
  font-size: 13px;
  text-decoration: none;
  margin-bottom: 10px;
}

.back-link:hover {
  color: var(--series-1);
}

.subtitle {
  color: var(--text-secondary);
  margin: 0 0 28px;
  font-size: 15px;
}

.layout {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

@media (min-width: 760px) {
  .freedom-layout.revealed {
    display: grid;
    grid-template-columns: 420px 420px;
    grid-template-areas:
      "form stats"
      "form explain";
    align-items: start;
    gap: 20px;
    max-width: 860px;
    margin: 0 auto;
  }

  .freedom-layout.revealed .inputs-card {
    grid-area: form;
    margin: 0;
  }

  .freedom-layout.revealed #results {
    display: contents;
  }

  .freedom-layout.revealed .stat-tiles {
    grid-area: stats;
    align-self: stretch;
  }

  .freedom-layout.revealed .chart-card {
    grid-area: explain;
  }
}

.freedom-layout .stat-tiles {
  grid-template-columns: 1fr;
}

.freedom-layout .stat-tile {
  text-align: center;
  align-items: center;
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text-primary);
}

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

.inputs-card {
  max-width: 420px;
  width: 100%;
  margin: 0 auto;
}

.field {
  display: block;
  margin-bottom: 16px;
}

.field-label {
  display: block;
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.field-input {
  display: flex;
  align-items: center;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--page);
  padding: 0 10px;
}

.field-input input,
.field-input select {
  border: none;
  background: transparent;
  font-size: 15px;
  color: var(--text-primary);
  padding: 9px 4px;
  width: 100%;
  font-family: inherit;
}

.field-input select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  padding-right: 22px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23898781' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 4px center;
}

.field-input input:focus,
.field-input select:focus {
  outline: none;
}

.field-input:focus-within {
  border-color: var(--series-1);
}

.field-input .prefix,
.field-input .suffix {
  color: var(--text-muted);
  font-size: 14px;
}

.stepper {
  display: flex;
  flex-direction: column;
  margin: 0 -6px 0 2px;
}

.stepper-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 8px;
  line-height: 1;
  padding: 3px 6px;
  cursor: pointer;
}

.stepper-btn:hover {
  color: var(--series-1);
}

.field-hint {
  font-size: 12px;
  color: var(--text-muted);
  margin: -10px 0 0;
}

.compound-btn {
  width: 100%;
  margin-top: 4px;
  background: var(--series-1);
  border: none;
  color: #fff;
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.compound-btn:hover {
  filter: brightness(1.08);
}

.compound-btn:active {
  filter: brightness(0.95);
}

.freedom-btn {
  display: block;
  text-align: center;
  text-decoration: none;
  box-sizing: border-box;
}

.freedom-card {
  text-align: center;
}

.freedom-copy {
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.5;
  margin: 8px 0 18px;
}

.reveal-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin-top: 9px;
  margin-bottom: 18px;
  cursor: pointer;
}

.reveal-zone.revealed {
  cursor: default;
}

.freedom-label {
  display: block;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.reveal-value {
  display: block;
  width: 100%;
  text-align: center;
  font-size: 34px;
  font-weight: 600;
  font-variant-numeric: proportional-nums;
  color: var(--text-muted);
}

.reveal-zone.revealed .reveal-value {
  font-size: 52px;
  font-weight: 800;
  background: linear-gradient(135deg, var(--series-2), #f5c542);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  color: var(--text-primary);
  filter: drop-shadow(0 0 18px rgba(27, 175, 122, 0.35));
  animation: reveal-pop 0.4s ease;
}

.reveal-hint {
  font-size: 12px;
  color: var(--text-muted);
  animation: reveal-pulse 1.6s ease-in-out infinite;
}

@keyframes reveal-pop {
  0% { transform: scale(0.85); opacity: 0; }
  60% { transform: scale(1.06); opacity: 1; }
  100% { transform: scale(1); }
}

@keyframes reveal-pulse {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.results {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.results[hidden] {
  display: none;
}

.stat-tiles {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

@media (max-width: 560px) {
  .stat-tiles { grid-template-columns: 1fr; }
}

.stat-tile {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.stat-tile[hidden] {
  display: none;
}

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

.stat-value {
  font-size: 22px;
  font-weight: 600;
  font-variant-numeric: proportional-nums;
}

.stat-tile.hero .stat-value {
  font-size: 34px;
  color: var(--text-primary);
}

.stat-value-edit {
  display: flex;
  align-items: baseline;
  gap: 3px;
}

.stat-value-edit .prefix {
  color: var(--text-muted);
  font-size: 22px;
}

.stat-value-input {
  border: none;
  background: transparent;
  color: var(--text-primary);
  font-family: inherit;
  padding: 0;
  width: 2ch;
  text-align: center;
}

.stat-value-input:focus {
  outline: none;
}

.chart-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}

.chart-header .card-title { margin: 0; }

.legend {
  list-style: none;
  display: flex;
  gap: 16px;
  margin: 0;
  padding: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

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

.legend-swatch,
.tooltip-key {
  width: 10px;
  height: 10px;
  border-radius: 2px;
  display: inline-block;
}

.legend-swatch[data-series="1"],
.tooltip-key[data-series="1"] { background: var(--series-1); }
.legend-swatch[data-series="2"],
.tooltip-key[data-series="2"] { background: var(--series-2); }

.chart-wrap {
  position: relative;
}

#chart {
  width: 100%;
  aspect-ratio: 800 / 480;
  height: auto;
  display: block;
}

.gridline { stroke: var(--gridline); stroke-width: 1; shape-rendering: crispEdges; }
.axis-line { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; }
.axis-label { fill: var(--text-muted); font-size: 11px; }
.area-1 { fill: var(--series-1); fill-opacity: 0.12; }
.area-2 { fill: var(--series-2); fill-opacity: 0.12; }
.line-1 { stroke: var(--series-1); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.line-2 { stroke: var(--series-2); stroke-width: 2; fill: none; stroke-linejoin: round; stroke-linecap: round; }
.crosshair { stroke: var(--baseline); stroke-width: 1; shape-rendering: crispEdges; pointer-events: none; }
.dot-ring { fill: var(--surface-1); pointer-events: none; }
.dot-1 { fill: var(--series-1); pointer-events: none; }
.dot-2 { fill: var(--series-2); pointer-events: none; }
.marker-1 { fill: var(--surface-1); stroke: var(--series-1); stroke-width: 1.5; pointer-events: none; }
.marker-2 { fill: var(--surface-1); stroke: var(--series-2); stroke-width: 1.5; pointer-events: none; }

.point-panel {
  margin-top: 14px;
  background: var(--page);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 13px;
}

.point-year {
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-primary);
}

.tooltip-row {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 0;
}

.tooltip-label {
  color: var(--text-secondary);
  flex: 1;
}

.tooltip-value {
  font-weight: 600;
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
}

.tooltip-total {
  border-top: 1px solid var(--gridline);
  margin-top: 4px;
  padding-top: 6px;
}

.quote {
  margin: 18px 0 0;
  padding: 14px 0 0;
  border-top: 1px solid var(--gridline);
  text-align: center;
}

.quote p {
  margin: 0 0 6px;
  font-size: 15px;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.5;
}

.quote cite {
  font-size: 13px;
  font-style: normal;
  color: var(--text-muted);
}

.table-toggle {
  margin-top: 14px;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 13px;
  cursor: pointer;
  font-family: inherit;
}

.table-toggle:hover {
  border-color: var(--series-1);
}

.table-wrap {
  margin-top: 14px;
  max-height: 320px;
  overflow-y: auto;
  border: 1px solid var(--border);
  border-radius: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--baseline) transparent;
}

.table-wrap::-webkit-scrollbar {
  width: 9px;
}

.table-wrap::-webkit-scrollbar-track {
  background: transparent;
}

.table-wrap::-webkit-scrollbar-thumb {
  background: var(--baseline);
  border-radius: 5px;
  border: 2px solid var(--surface-1);
}

.table-wrap::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: right;
  padding: 8px 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

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

thead th {
  position: sticky;
  top: 0;
  background: var(--surface-1);
  color: var(--text-secondary);
  font-weight: 600;
  border-bottom: 1px solid var(--gridline);
}

tbody tr:nth-child(even) {
  background: rgba(128,128,128,0.04);
}
