:root {
  color-scheme: light;
  --bg: #f6f8f4;
  --panel: #ffffff;
  --ink: #171a18;
  --muted: #626b66;
  --line: #d9dfd8;
  --soft-line: #ebefe9;
  --meter-bg: #edf2ed;
  --chart-bg: #fbfcfb;
  --grid-line: #e4e9e2;
  --focus: rgba(36, 93, 181, 0.24);
  --nav-bg: rgba(255, 255, 255, 0.68);
  --heat-empty: #ebedf0;
  --top-glow: linear-gradient(180deg, rgba(255, 255, 255, 0.74), rgba(255, 255, 255, 0));
  --green: #1f883d;
  --green-dark: #166534;
  --red: #b42318;
  --amber: #a16207;
  --blue: #245db5;
  --teal: #147d73;
  --shadow: 0 16px 40px rgba(25, 31, 28, 0.08);
  --radius: 8px;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #101411;
  --panel: #171d19;
  --ink: #f0f5ef;
  --muted: #a8b3ad;
  --line: #303a34;
  --soft-line: #232c27;
  --meter-bg: #202a24;
  --chart-bg: #121713;
  --grid-line: #27302b;
  --focus: rgba(88, 166, 255, 0.3);
  --nav-bg: rgba(23, 29, 25, 0.76);
  --heat-empty: #252b28;
  --top-glow: linear-gradient(180deg, rgba(126, 231, 135, 0.05), rgba(255, 255, 255, 0));
  --green: #3fb950;
  --green-dark: #7ee787;
  --red: #ff7b72;
  --amber: #d29922;
  --blue: #58a6ff;
  --teal: #56d4c6;
  --shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    var(--top-glow) 0 0 / 100% 280px no-repeat,
    var(--bg);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

a {
  color: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 20px 0 14px;
}

.brand,
.top-links {
  display: flex;
  align-items: center;
  gap: 10px;
}

.brand {
  color: var(--ink);
  font-weight: 800;
  text-decoration: none;
}

.brand-mark {
  display: inline-grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--green-dark);
  font-size: 0.82rem;
  letter-spacing: 0;
}

.top-links a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--nav-bg);
  color: var(--muted);
  font-size: 0.92rem;
  text-decoration: none;
}

.top-links a:focus-visible,
input:focus-visible,
.theme-toggle:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.theme-toggle {
  display: inline-grid;
  width: 38px;
  min-height: 36px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--nav-bg);
  color: var(--muted);
  cursor: pointer;
}

.theme-toggle:hover,
.top-links a:hover {
  color: var(--ink);
}

.theme-toggle svg {
  display: block;
  fill: currentColor;
}

.theme-icon-sun {
  display: none;
}

:root[data-theme="dark"] .theme-icon-moon {
  display: none;
}

:root[data-theme="dark"] .theme-icon-sun {
  display: block;
}

.shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto 44px;
}

.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 390px);
  gap: 18px;
  align-items: start;
  padding-top: 16px;
}

.hero-copy,
.target-panel,
.stat-card,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.hero-copy {
  min-height: 300px;
  padding: clamp(24px, 4vw, 44px);
}

.eyebrow,
.stat-label {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  overflow-wrap: break-word;
}

h1 {
  max-width: 760px;
  margin: 10px 0 20px;
  font-size: clamp(2.5rem, 7vw, 5.9rem);
  line-height: 0.94;
  letter-spacing: 0;
}

h2 {
  margin: 0;
  font-size: clamp(1.05rem, 2vw, 1.35rem);
  letter-spacing: 0;
}

.answer-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 12px 18px;
  margin-bottom: 30px;
}

.answer {
  margin: 0;
  color: var(--red);
  font-size: clamp(2.8rem, 9vw, 7.6rem);
  font-weight: 900;
  line-height: 0.86;
  letter-spacing: 0;
}

.answer.yes {
  color: var(--green-dark);
}

.answer.loading {
  color: var(--blue);
  font-size: clamp(2rem, 7vw, 5.2rem);
}

.answer-detail {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  font-size: clamp(1rem, 2vw, 1.22rem);
  line-height: 1.5;
}

.person {
  display: flex;
  align-items: center;
  gap: 12px;
}

.avatar {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--soft-line);
}

.person-name {
  margin: 0;
  font-weight: 800;
}

.muted {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
  line-height: 1.45;
}

.target-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 26px;
}

.target-head,
.target-foot,
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.target-count {
  display: block;
  min-width: 0;
  font-size: clamp(2.4rem, 4vw, 3.2rem);
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  white-space: nowrap;
}

.meter {
  width: 100%;
  height: 18px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--meter-bg);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--green), var(--teal));
  transition: width 320ms ease;
}

.target-foot span:first-child {
  font-size: 2rem;
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
}

.target-foot span:last-child {
  max-width: 180px;
  color: var(--muted);
  text-align: right;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 14px;
  margin-top: 14px;
}

.stat-card {
  min-width: 0;
  min-height: 154px;
  overflow: hidden;
  padding: 20px;
}

.stat-card.small {
  display: grid;
  grid-template-rows: auto 1fr;
  align-items: end;
  min-height: 128px;
}

.stat-value,
.compact-value {
  margin: 12px 0 0;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  letter-spacing: 0;
  max-width: 100%;
  overflow-wrap: normal;
  white-space: nowrap;
}

.stat-value {
  font-size: clamp(2rem, 3.8vw, 3.15rem);
}

.compact-value {
  font-size: clamp(1.55rem, 4vw, 2.42rem);
}

.stat-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.35;
}

.work-area {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(270px, 340px);
  gap: 14px;
  margin-top: 14px;
}

.panel {
  padding: 20px;
}

.trajectory-panel {
  min-width: 0;
}

.legend {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px 14px;
  color: var(--muted);
  font-size: 0.85rem;
}

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

.legend i {
  display: block;
  width: 18px;
  height: 3px;
  border-radius: 999px;
}

.legend-actual {
  background: var(--green);
}

.legend-projected {
  background: var(--blue);
}

.legend-target {
  background: var(--amber);
}

.chart {
  display: block;
  width: 100%;
  height: 320px;
  margin-top: 18px;
  border: 1px solid var(--soft-line);
  border-radius: var(--radius);
  background: var(--chart-bg);
}

.controls-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.range-form {
  display: grid;
  gap: 12px;
}

.range-form label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

input[type="date"] {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--chart-bg);
  color: var(--ink);
  font: inherit;
  letter-spacing: 0;
  padding: 8px 10px;
}

.compare-stack {
  display: grid;
  gap: 18px;
  padding-top: 4px;
}

.heatmap-panel {
  margin-top: 14px;
  overflow: hidden;
}

.status-badge {
  display: inline-flex;
  min-height: 30px;
  align-items: center;
  white-space: nowrap;
  border: 1px solid rgba(20, 125, 115, 0.28);
  border-radius: 999px;
  background: rgba(20, 125, 115, 0.08);
  color: var(--teal);
  font-size: 0.82rem;
  font-weight: 800;
  padding: 5px 10px;
}

.heatmap {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(10px, 1fr);
  grid-template-rows: repeat(7, 12px);
  gap: 4px;
  width: 100%;
  min-height: 108px;
  margin-top: 18px;
  overflow-x: auto;
  padding-bottom: 10px;
}

.day {
  width: 100%;
  min-width: 10px;
  height: 12px;
  border: 1px solid rgba(27, 31, 36, 0.06);
  border-radius: 3px;
  background: var(--heat-empty);
}

.breakdown-grid {
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
}

.breakdown-grid .stat-value {
  align-self: end;
  margin-top: 14px;
  font-size: clamp(1.9rem, 2.5vw, 2.25rem);
}

@media (max-width: 960px) {
  .hero-grid,
  .work-area {
    grid-template-columns: 1fr;
  }

  .stats-grid,
  .breakdown-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .target-foot span:last-child {
    text-align: left;
  }
}

@media (max-width: 640px) {
  .site-header {
    align-items: stretch;
    flex-direction: column;
  }

  .top-links {
    display: grid;
    grid-template-columns: 1fr 1fr 42px;
  }

  .top-links a {
    text-align: center;
  }

  .shell,
  .site-header {
    width: min(100% - 24px, 1180px);
  }

  .hero-copy,
  .target-panel,
  .panel,
  .stat-card {
    padding: 16px;
  }

  .target-head,
  .target-foot,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .legend {
    justify-content: flex-start;
  }

  .stats-grid,
  .breakdown-grid {
    grid-template-columns: 1fr;
  }

  .stat-card,
  .stat-card.small {
    min-height: 112px;
  }
}
