:root {
  color-scheme: light;
  background: #e7edef;
  color: #1d342f;
  font: 16px/1.45 "Segoe UI", system-ui, sans-serif;
  --ink: #1d342f;
  --water: #163f4b;
  --pale: #f6faf8;
  --rim: #cbdad7;
  --accent: #ffd487;
  --gutter: clamp(12px, 2vw, 30px);
}
* { box-sizing: border-box; }
body { margin: 0; }
button, input, select { font: inherit; }
button, input:not([type=checkbox]), select { min-height: 42px; min-width: 0; }
button, select, input[type=number] { border: 1px solid #adc6bf; border-radius: 9px; padding: .38rem .7rem; color: inherit; background: #fff; }
button { cursor: pointer; font-weight: 650; }
button:hover { background: #e2eeeb; }
button:disabled { opacity: .55; cursor: default; }
button:focus-visible, select:focus-visible, input:focus-visible, a:focus-visible, summary:focus-visible { outline: 2px solid #14777b; outline-offset: 3px; }
button.primary { background: var(--accent); color: #26362b; border-color: transparent; min-width: 100px; }
button.primary:hover { background: #ffe4af; }
h1, h2, p { margin: 0; }
h2 { font-size: 1.11rem; }
.masthead {
  display: flex; align-items: center; justify-content: space-between; gap: .7rem;
  padding: .8rem var(--gutter); min-height: 75px;
  background: #f1f7f5; border-bottom: 1px solid #c7dad5;
}
.brand { display: flex; align-items: center; gap: .68rem; }
.brand h1 { font: 600 clamp(1.45rem, 3.2vw, 2.15rem)/1.07 Georgia, serif; letter-spacing: -.035em; }
.mark {
  display: grid; place-items: center; flex: none; width: 38px; height: 38px;
  border-radius: 50%; background: #285b55; color: #f6d498; font-size: 1.28rem;
}
#share { background: transparent; }
#share:hover { background: #deebe6; }
main { padding: 1.1rem var(--gutter) 1.8rem; }
.workspace {
  display: grid; grid-template-columns: minmax(0, 1fr) clamp(228px, 24vw, 292px);
  grid-template-areas: "scene settings" "analysis settings";
  gap: 1rem; align-items: start;
}
.panel { min-width: 0; }
.scene {
  grid-area: scene; overflow: hidden; color: #e9f5f2;
  border-radius: 16px; background: var(--water);
  box-shadow: 0 10px 24px #183d4227;
}
.bar, .actions, .legend {
  display: flex; align-items: center; flex-wrap: wrap; gap: .5rem .65rem;
  padding: .68rem .85rem;
}
.bar { justify-content: space-between; }
.conditions { display: flex; flex-wrap: wrap; gap: .15rem .75rem; font-size: .875rem; color: #d0e8e7; }
#weather { color: #ffe3a8; }
canvas { display: block; width: 100%; height: auto; }
#map { background: #376d78; cursor: grab; touch-action: none; }
#map.dragging { cursor: grabbing; }
.actions button, .actions select {
  color: #f2f9fa; border-color: #95b8c061; background: #234e57; border-radius: 8px;
}
.actions button:hover, .actions select:hover { background: #336470; }
.actions button.primary { color: #2b3529; background: var(--accent); border-color: transparent; }
.actions button.primary:hover { background: #ffe4af; }
.actions button[aria-pressed="true"] { background: #d2ebe3; color: #163832; }
.actions button:focus-visible, .actions select:focus-visible, .actions input:focus-visible { outline-color: #ffe3a8; }
.camera { background: #103843; }
.camera button, .camera label { font-size: .91rem; }
.camera label, .speed { display: flex; align-items: center; gap: .45rem; }
.speed { margin-left: auto; }
.playback { border-top: 1px solid #87aeb92b; }
.legend { padding-top: .4rem; padding-bottom: .8rem; color: #d7ece7; gap: .4rem 1.15rem; }
.swatch { display: inline-block; width: .68rem; height: .68rem; border-radius: 50%; margin-right: .35rem; }
.zoom-control input[type="range"] { width: clamp(70px, 8vw, 130px); accent-color: #ffd487; }
.zoom-control output { min-width: 3em; font-size: .87rem; }
.settings {
  grid-area: settings; display: grid; gap: .75rem; padding: 1rem;
  border: 1px solid var(--rim); border-top: 4px solid #478779;
  border-radius: 5px 5px 15px 15px; background: var(--pale);
}
.settings h2 { margin-bottom: .2rem; font: 600 1.35rem/1.12 Georgia, serif; }
.settings label { display: grid; gap: .3rem; }
.settings label:has(select), .settings label:has([name=seed]) { font-weight: 630; }
fieldset { display: grid; gap: .38rem; margin: 0; padding: .55rem; min-width: 0; border: 1px solid var(--rim); border-radius: 9px; }
.settings fieldset label, .settings .toggle { display: flex; justify-content: space-between; align-items: center; }
fieldset input { width: 4.35rem; flex: none; }
.settings .toggle { justify-content: flex-start; min-height: 38px; }
input[type=checkbox] { accent-color: #2d7364; width: 1.15rem; height: 1.15rem; }
.settings button[type=submit] { background: #d9ebe5; }
.settings button[type=submit]:hover { background: #c6e2d8; }
.analysis { grid-area: analysis; overflow: hidden; border-radius: 11px; background: #234441; color: #eaf4ef; }
.analysis select { background: #2f554f; color: #f3fbf7; border-color: #80aca075; }
#climate-note, .footnote, #status { color: #3c5551; font-size: .88rem; }
#summary { padding: .35rem .85rem .85rem; color: #d0e4dc; }
#status:empty { display: none; }
.footnote { margin-top: .75rem; max-width: 72ch; }
.footnote a { color: #196b64; }
.footnote summary { cursor: pointer; }
@media (max-width: 750px) {
  .workspace { grid-template-columns: minmax(0, 1fr); grid-template-areas: "scene" "settings" "analysis"; }
  .speed { margin-left: 0; }
  .conditions { width: 100%; }
}
@media (max-width: 430px) {
  .masthead button { font-size: .8rem; }
  .brand { gap: .4rem; }
  .mark { width: 30px; height: 30px; font-size: 1rem; }
  .bar, .actions, .legend { padding-inline: .62rem; }
  .actions button { font-size: .87rem; }
}

/* Dark field-station surfaces and responsive masthead. */
:root {
  color-scheme: dark;
  background: #101b20;
  color: #e9f3ef;
  --ink: #e9f3ef;
  --water: #152e37;
  --pale: #19292d;
  --rim: #344b50;
}
html { min-width: 0; }
body { min-width: 0; }
.masthead {
  position: sticky; top: 0; z-index: 5;
  min-height: 68px; padding-block: .8rem;
  padding-top: max(.8rem, env(safe-area-inset-top));
  background: #14232a; border-bottom-color: #344951;
  flex-wrap: wrap;
}
.brand { min-width: 0; }
.brand h1 { line-height: 1.2; overflow-wrap: anywhere; }
.mark { background: #24464a; }
#share { flex: 0 1 auto; max-width: 100%; border-color: #587575; }
#share:hover { background: #243b41; }
button, select, input[type=number] { background: #22363a; border-color: #4d686c; color: #eef8f4; }
button:hover { background: #2d454a; }
.settings { border-top-color: #629d8f; }
.settings button[type=submit] { background: #285049; border-color: #476d64; }
.settings button[type=submit]:hover { background: #34635a; }
#climate-note, .footnote, #status { color: #b6cbc8; }
.footnote a { color: #a3dfca; }
.workspace { grid-template-areas: "scene sidebar" "analysis sidebar"; }
.sidebar { grid-area: sidebar; display: grid; gap: 1rem; min-width: 0; }
.sidebar .settings { grid-area: auto; }
.camera-help { padding: .45rem .85rem .1rem; background: #103843; color: #b6cfce; font-size: .8rem; }
.legend a { margin-left: auto; color: #b4e4d5; font-size: .88rem; text-underline-offset: .2em; }
.analysis { background: #1a3034; border: 1px solid var(--rim); padding-bottom: .85rem; }
.analysis .bar, .journal h2 { padding-bottom: .75rem; }
.analysis h2, .journal h2 { font: 600 1.35rem/1.2 Georgia, serif; }
.analysis select, .journal select { background: #223b3e; }
#summary { display: flex; flex-wrap: wrap; gap: .3rem 1.15rem; font-variant-numeric: tabular-nums; }
.population-table { width: calc(100% - 1.7rem); margin: .65rem auto 0; border-collapse: collapse; font-size: .89rem; font-variant-numeric: tabular-nums; }
.population-table caption { text-align: left; padding-bottom: .42rem; font-weight: 650; }
.population-table td, .population-table th { padding: .36rem .35rem; border-top: 1px solid #365053; text-align: right; }
.population-table th:first-child { text-align: left; padding-left: 0; }
.population-table tbody th { color: #c1d4cf; font-weight: 450; }
.journal { padding: 1rem; background: #19292d; border: 1px solid var(--rim); border-radius: 12px; scroll-margin-top: 86px; }
.journal label { color: #c1d4cf; font-size: .88rem; margin-right: .36rem; }
.journal select { max-width: 100%; }
#event-list { margin-top: .7rem; max-height: 22rem; overflow-y: auto; scrollbar-color: #557771 transparent; }
.event-day { border-top: 1px solid var(--rim); padding: .57rem 0; }
.event-day h3 { margin: 0 0 .29rem; font-size: .81rem; font-weight: 650; color: #bacdc9; font-variant-numeric: tabular-nums; }
.event-day ul { list-style: none; margin: 0; padding: 0; }
.event-day li { position: relative; padding: .12rem .12rem .13rem .82rem; font-size: .9rem; }
.event-day li::before { content: ""; position: absolute; left: 0; top: .63rem; width: .34rem; height: .34rem; border-radius: 50%; background: #9db6bd; }
.event-day .birth::before { background: #9bd39c; }
.event-day .death::before { background: #d9aa88; }
.event-day .extinction { color: #f4c8ab; font-weight: 650; }
.event-day .extinction::before { background: #f4b28e; }
.journal-nav { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .45rem; }
.journal-nav button { font-size: .84rem; min-height: 36px; }
.journal-nav:has(button:disabled):not(:has(button:not([hidden]):enabled)) { display: none; }
.journal-empty { color: #b6cbc8; font-size: .88rem; }
@media (max-width: 750px) {
  .workspace { grid-template-areas: "scene" "settings" "analysis" "journal"; }
  .sidebar { display: contents; }
  .sidebar .settings { grid-area: settings; }
  .journal { grid-area: journal; }
}
@media (max-width: 430px) {
  .population-table { font-size: .8rem; }
  .population-table td, .population-table th { padding-inline: .2rem; }
  .camera-help { padding-inline: .62rem; }
}
@media (max-width: 390px) {
  .masthead { gap: .45rem; }
  .brand h1 { font-size: 1.42rem; }
  #share { min-height: 38px; }
}
