:root {
  --chart-population: #c5ed99;
  --chart-births: #79cbd6;
  --chart-deaths: #edac99;
  --chart-net: #e5c577;
}
body[data-theme="light"] {
  --chart-population: #326626;
  --chart-births: #246f87;
  --chart-deaths: #a44539;
  --chart-net: #856115;
}
.history-preview {
  display: flex;
  gap: 8px;
  padding: 0;
  min-height: 30px;
  border: 0;
}
.history-preview svg {
  width: 12px;
  height: 12px;
  color: var(--faint);
}
.footer-actions {
  display: flex;
  gap: 22px;
  align-items: center;
}
.footer-actions svg {
  width: 12px;
  height: 12px;
}
.history-panel {
  flex-shrink: 0;
  margin: 0 0 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}
.history-panel-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 3px 9px;
  min-height: 36px;
}
.history-panel-heading > div {
  display: flex;
  gap: 4px;
}
.history-panel-heading button {
  border: 0;
  min-height: 28px;
  font-size: 11px;
}
.history-panel-heading strong {
  font-weight: 500;
}
.history-panel-heading .icon-button {
  width: 28px;
  height: 28px;
  padding: 5px;
}
#history-toggle {
  padding: 4px 2px;
  gap: 8px;
}
#history-toggle > svg {
  color: var(--accent);
  width: 15px;
}
#history-panel-range {
  font: 9px var(--mono);
  color: var(--faint);
  margin-left: 8px;
}
#history-panel-body {
  padding: 0 12px 9px;
  border-top: 1px solid var(--border);
}
.history-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 6px 12px;
  padding: 7px 0 5px;
}
.history-series,
.history-view-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}
.history-toolbar button,
.history-toolbar select {
  min-height: 25px;
  padding: 4px 7px;
  font-size: 9px;
}
.history-series button {
  gap: 5px;
  color: var(--muted);
  border-color: transparent;
  opacity: 0.6;
}
.history-series button[aria-pressed="true"] {
  color: var(--text);
  border-color: var(--border);
  background: var(--raised);
  opacity: 1;
}
.history-series i {
  display: inline-block;
  width: 12px;
  height: 2px;
  background: var(--series-color);
}
.history-series [data-series="births"] i {
  background: repeating-linear-gradient(
    90deg,
    var(--series-color) 0 5px,
    transparent 5px 7px
  );
}
.history-series [data-series="deaths"] i {
  background: repeating-linear-gradient(
    90deg,
    var(--series-color) 0 2px,
    transparent 2px 4px
  );
}
.history-series [data-series="net"] i {
  height: 3px;
}
.history-view-controls .icon-button {
  width: 25px;
  height: 25px;
  padding: 4px;
}
.history-view-controls svg {
  width: 13px;
  height: 13px;
}
.history-view-controls [data-follow][aria-pressed="true"] {
  border-color: #59754a;
  color: var(--accent);
  background: var(--accent-dark);
}
.history-fit {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 9px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
.history-fit input[type="checkbox"] {
  width: 13px;
  height: 13px;
}
.history-plot {
  position: relative;
  height: 145px;
  border: 1px solid var(--border);
  border-radius: 5px;
  overflow: hidden;
  background: var(--stage);
}
.history-plot canvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: crosshair;
  outline-offset: -3px;
}
.history-empty {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  color: var(--muted);
  background: var(--stage);
  padding: 6px 10px;
  text-align: center;
  pointer-events: none;
  max-width: 85%;
}
.history-readout {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 14px;
  min-height: 27px;
  color: var(--muted);
  font: 9px var(--mono);
}
.history-readout > strong {
  color: var(--text);
  font-weight: 500;
  min-width: 70px;
}
.history-readout b {
  color: var(--text);
  font-weight: 500;
}
.history-readout [data-inspect-births] {
  color: var(--chart-births);
}
.history-readout [data-inspect-deaths] {
  color: var(--chart-deaths);
}
.history-readout [data-inspect-net] {
  color: var(--chart-net);
}
.history-readout button {
  min-height: 20px;
  padding: 2px 5px;
  font-size: 9px;
  margin-left: auto;
}
.history-scrubber {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 16px;
  color: var(--faint);
  font: 8px var(--mono);
}
.history-scrubber input {
  width: 100%;
  height: 10px;
  flex: 1;
  min-width: 0;
}
.history-scrubber input:disabled {
  opacity: 0.35;
  cursor: default;
}
.history-scrubber span {
  white-space: nowrap;
}
.history-summary {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}
.history-summary > div {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 4px 8px;
}
.history-summary span {
  font: 8px var(--mono);
  color: var(--faint);
  letter-spacing: 0.6px;
}
.history-summary strong {
  font: 13px var(--mono);
  color: var(--text);
}
.history-summary small {
  font: 8px var(--mono);
  color: var(--faint);
}
.history-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 7px;
}
.history-bottom > span {
  color: var(--faint);
  font-size: 8px;
  line-height: 1.6;
}
.history-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}
.history-actions button {
  font-size: 11px;
}
.history-actions svg {
  width: 14px;
  height: 14px;
}
.history-dialog {
  width: min(1100px, calc(100vw - 28px));
}
.history-dialog .dialog-heading {
  margin-bottom: 12px;
}
.history-experiment {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
}
#history-experiment-name {
  font-size: 12px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#history-experiment-rule {
  color: var(--muted);
  font: 10px var(--mono);
  white-space: nowrap;
}
#history-live-status {
  margin-left: auto;
  color: var(--muted);
  font: 10px var(--mono);
  white-space: nowrap;
}
#history-live-status.active {
  color: var(--accent);
}
.history-dialog .history-toolbar {
  gap: 10px;
  padding: 6px 0 12px;
}
.history-dialog .history-toolbar button,
.history-dialog .history-toolbar select {
  min-height: 30px;
  font-size: 10px;
}
.history-dialog .history-view-controls .icon-button {
  width: 30px;
  height: 30px;
}
.history-dialog .history-plot {
  height: clamp(230px, 38vh, 380px);
}
.history-dialog .history-readout {
  min-height: 39px;
  font-size: 11px;
  gap: 6px 22px;
}
.history-dialog .history-summary {
  padding-top: 16px;
  margin: 10px 0 20px;
}
.history-dialog .history-summary > div {
  display: grid;
  gap: 6px;
}
.history-dialog .history-summary span {
  font-size: 9px;
}
.history-dialog .history-summary strong {
  font-size: 23px;
}
.history-dialog .history-summary small {
  font-size: 9px;
}
.history-dialog .history-explanation {
  margin-bottom: 0;
}
@media (max-width: 1150px) {
  .history-toolbar {
    gap: 4px;
  }
  .history-summary small {
    display: none;
  }
  .history-dialog .history-summary small {
    display: block;
  }
}
@media (max-width: 850px) {
  .history-panel {
    margin-bottom: 8px;
  }
  .history-panel-heading {
    padding: 3px 7px;
  }
  #history-panel-range {
    margin-left: 0;
  }
}
@media (max-width: 570px) {
  .workspace-footer > span {
    display: none;
  }
  .footer-actions {
    width: 100%;
    justify-content: space-between;
    gap: 10px;
  }
  .workspace-footer .footer-actions button {
    font-size: 9px;
  }
  .history-dialog {
    padding: 16px;
    max-height: calc(100dvh - 20px);
  }
  .history-dialog .dialog-heading h2 {
    font-size: 21px;
  }
  .history-dialog .eyebrow {
    font-size: 7px;
  }
  .history-experiment {
    gap: 7px;
  }
  #history-experiment-name {
    font-size: 11px;
  }
  #history-experiment-rule,
  #history-live-status {
    font-size: 9px;
  }
  .history-dialog .history-toolbar {
    gap: 8px;
    padding-bottom: 10px;
  }
  .history-series {
    width: 100%;
    justify-content: space-between;
    gap: 2px;
  }
  .history-dialog .history-series button {
    font-size: 9px;
    padding: 5px 6px;
    min-height: 31px;
  }
  .history-series i {
    width: 9px;
  }
  .history-view-controls {
    gap: 4px;
  }
  .history-dialog .history-toolbar select {
    max-width: 108px;
    padding: 5px;
  }
  .history-dialog .history-view-controls button {
    font-size: 9px;
    padding: 5px;
  }
  .history-fit {
    font-size: 9px;
  }
  .history-dialog .history-plot {
    height: 225px;
  }
  .history-dialog .history-readout {
    font-size: 9px;
    min-height: 47px;
    gap: 6px 10px;
    padding: 6px 0;
  }
  .history-readout > strong {
    min-width: 65px;
  }
  .history-dialog .history-summary {
    gap: 8px;
    margin: 8px 0 12px;
    padding-top: 12px;
  }
  .history-dialog .history-summary span {
    font-size: 7px;
    letter-spacing: 0;
  }
  .history-dialog .history-summary strong {
    font-size: 18px;
  }
  .history-dialog .history-summary small {
    font-size: 8px;
    line-height: 1.5;
  }
  .history-dialog .history-bottom {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .history-actions {
    justify-content: space-between;
    gap: 5px;
  }
  .history-actions button {
    font-size: 10px;
    padding: 6px 9px;
  }
  #history-panel-range {
    font-size: 8px;
  }
}
