@font-face {
  font-family: 'Fraunces';
  src: url('fonts/Fraunces.ttf') format('truetype');
  font-weight: 300 900;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #edf2e9;
  --surface: #f7faf2;
  --panel: #e7e9db;
  --ink: #243b30;
  --muted: #4e5d4f;
  --line: #a8ad99;
  --accent: #295c43;
  --on-accent: #fcf7e6;
  --track: #bfc5ab;
  --map: #e9e9db;
  --plot-current: #5a6556;
  --plot-trees: #296241;
  --plot-canopy: #9a4f28;
  --focus: #985127;
  --selected: #d7e1cc;
  --canvas-shadow: #667780;
  --canvas-path: #e3c173;
  --canvas-covered: #33715c;
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #182721;
  --surface: #24332c;
  --panel: #26392f;
  --ink: #f5edda;
  --muted: #c0caba;
  --line: #65796a;
  --accent: #a8d3ab;
  --on-accent: #183021;
  --track: #4d6558;
  --map: #293934;
  --plot-current: #b3b9a6;
  --plot-trees: #9bd3a2;
  --plot-canopy: #e4ab77;
  --focus: #e8b183;
  --selected: #364d3e;
  --canvas-shadow: #0d181d;
  --canvas-path: #bea575;
  --canvas-covered: #66d1ae;
}

* { box-sizing: border-box }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 15px/1.52 Avenir Next, ui-sans-serif, system-ui, sans-serif;
  accent-color: var(--accent);
}
::selection { color: var(--on-accent); background: var(--accent) }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 4px }
h1, h2, p, fieldset { margin: 0 }
h1, h2, legend { font-weight: 600 }
button, input { font: inherit }
button { cursor: pointer }
button:disabled { cursor: default }
a { color: var(--accent); text-underline-offset: 0.2em }
.top, main { width: min(1380px, 100% - 112px); margin-inline: auto }
.top {
  min-height: 70px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--line);
}
.wordmark { display: flex; align-items: center; gap: 11px; font-weight: 680; letter-spacing: -0.02em }
.brand-mark {
  width: 22px;
  height: 22px;
  display: inline-block;
  background: var(--accent);
  border-radius: 50%;
  box-shadow: inset -9px -3px 0 var(--bg), inset -10px -3px 0 var(--accent);
}
.theme, .timeline button, .position-row button {
  min-height: 38px;
  border: 1px solid var(--line);
  color: var(--ink);
  background: var(--surface);
  border-radius: 5px;
  padding: 5px 12px;
  font-size: 13px;
  font-weight: 650;
}
.theme:hover, .timeline button:hover, .position-row button:not(:disabled):hover { background: var(--selected) }
.intro { display: flex; align-items: end; justify-content: space-between; gap: 32px; padding-block: 29px 25px }
.intro h1 {
  font: 500 clamp(2.45rem, 5.05vw, 5rem)/1.02 'Fraunces', Georgia, serif;
  letter-spacing: -0.038em;
  text-wrap: balance;
}
.intro p { max-width: 35ch; padding-bottom: 5px; color: var(--muted) }
.workbench { display: grid; grid-template-columns: minmax(0, 1fr) 312px; gap: 22px }
.board { min-width: 0; border: 1px solid var(--line); background: var(--surface); border-radius: 10px; overflow: hidden }
.board-head {
  min-height: 46px;
  padding: 10px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.board-head h2, .day h2 { font-size: 16px }
.board-head span { font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums }
.scene { position: relative; background: var(--map) }
#yard { display: block; width: 100%; height: clamp(380px, 39vw, 510px) }
#yard.editable { cursor: crosshair }
.map-key {
  position: absolute;
  pointer-events: none;
  inset: auto auto 12px 14px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 9px;
  border-radius: 4px;
  color: var(--ink);
  background: var(--surface);
  font-size: 11px;
  font-weight: 650;
}
.key { display: inline-block; width: 9px; height: 9px; border-radius: 2px }
.map-key .key:not(:first-child) { margin-left: 5px }
.key.shade { background: var(--canvas-shadow) }
.key.walking { background: var(--canvas-path) }
.key.covered { background: var(--canvas-covered) }
.timeline {
  min-height: 70px;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 10px 16px;
  border-top: 1px solid var(--line);
}
.timeline-track { min-width: 0; display: grid; gap: 3px }
.timeline-track label { font-size: 11px; color: var(--muted) }
.timeline input { margin: 0; width: 100%; cursor: ew-resize }
.timeline output { font-size: 20px; font-weight: 700; font-variant-numeric: tabular-nums; min-width: 5ch }
.tick-labels { position: relative; min-height: 14px; font-size: 9px; color: var(--muted) }
.tick-labels span { position: absolute; transform: translateX(-50%) }
.tick-labels span:first-child { left: 0; transform: none }
.tick-labels span:nth-child(2) { left: 28.57% }
.tick-labels span:nth-child(3) { left: 57.14% }
.tick-labels span:nth-child(4) { left: 78.57% }
.tick-labels span:last-child { right: 0; transform: none }
.controls { display: flex; flex-direction: column; min-width: 0; background: var(--panel); border-radius: 10px; border: 1px solid var(--line); padding: 18px 18px 21px }
fieldset { padding: 0; border: 0; min-width: 0 }
legend { padding: 0; font-size: 15px; margin-bottom: 10px }
.scenario { display: grid; gap: 6px }
.scenario label {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 6px 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
  background: var(--surface);
}
.scenario label:has(input:checked) { background: var(--selected); border-color: var(--accent) }
.scenario label:hover { border-color: var(--accent) }
.scenario input { width: 15px; height: 15px; margin: 0 }
.placement { margin-block: 22px }
.position-help { margin-bottom: 11px; color: var(--muted); font-size: 12px }
.placement:disabled .position-help { color: var(--muted) }
.position-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px }
.pad { display: grid; grid-template-columns: repeat(3, 36px); gap: 4px }
.pad button { padding: 0; width: 36px; min-height: 33px; font-size: 17px }
.pad .up { grid-column: 2 }
.pad .left { grid-column: 1 }
.position-row button:disabled { background: transparent; color: var(--muted); border-style: dashed }
.measure { margin-top: auto; border-top: 1px solid var(--line); padding-top: 17px }
.measure h2 { font-size: 15px }
.measure-line { display: flex; justify-content: space-between; align-items: baseline; gap: 8px }
#percentage {
  font: 500 clamp(3rem, 5vw, 4.25rem)/1.2 'Fraunces', Georgia, serif;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.03em;
}
#area { font-size: 12px; color: var(--muted); white-space: nowrap }
.meter { height: 5px; margin-block: 4px 11px; border-radius: 9px; background: var(--track); overflow: hidden }
.meter span { display: block; width: 0; height: 100%; border-radius: inherit; background: var(--accent) }
#comparison { color: var(--muted); font-size: 12px }
.day {
  margin-top: 23px;
  display: grid;
  grid-template-columns: 245px minmax(0, 1fr);
  align-items: center;
  gap: 16px;
  padding-block: 10px;
  border-block: 1px solid var(--line);
}
.day p { color: var(--muted); font-size: 13px; margin-top: 5px }
#chart { display: block; width: 100%; height: 104px; cursor: crosshair }
.series-key { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 9px; font-size: 11px; color: var(--muted) }
.series-key span { display: inline-flex; align-items: center; gap: 4px }
.series-key i { width: 9px; height: 2px; display: inline-block }
.series-key [data-key="current"] { background: var(--plot-current) }
.series-key [data-key="trees"] { background: var(--plot-trees) }
.series-key [data-key="canopy"] { background: var(--plot-canopy) }
footer { padding-block: 14px 24px; color: var(--muted); font-size: 12px }

@media (max-width: 1100px) {
  .top, main { width: calc(100% - 48px) }
  .workbench { grid-template-columns: minmax(0, 1fr) 264px; gap: 16px }
  .controls { padding-inline: 15px }
}
@media (max-width: 780px) {
  .top, main { width: calc(100% - 32px) }
  .top { min-height: 58px }
  .intro { display: grid; align-items: start; gap: 10px; padding-block: 23px 19px }
  .intro p { max-width: 52ch }
  .workbench { grid-template-columns: 1fr }
  #yard { height: clamp(245px, 63vw, 440px) }
  .controls { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 20px }
  .placement { margin: 0 }
  .measure { grid-column: 1 / -1 }
}
@media (max-width: 480px) {
  .top, main { width: calc(100% - 24px) }
  .workbench { gap: 12px }
  .timeline { grid-template-columns: 51px minmax(0, 1fr) auto; gap: 8px; padding-inline: 8px }
  .timeline button { padding-inline: 4px }
  .timeline output { font-size: 16px }
  .controls { gap: 15px; padding: 12px }
  .board-head { padding-inline: 12px }
  .map-key { bottom: 5px; left: 6px }
  .day { grid-template-columns: 1fr; gap: 5px; margin-top: 15px }
}
