/* Structure only: the panel grid and the two canvases that fill their boxes.
   Every control renders with browser defaults. The page follows the OS theme. */

:root {
  color-scheme: light dark;
  --page: light-dark(#ffffff, #000000);
  --panel: light-dark(#eeeeee, #111111);
  --gap: 8px;
}

body {
  background-color: var(--page);
  box-sizing: border-box;
  margin: 0;
  padding: var(--gap);
  height: 100dvh;
  display: grid;
  gap: var(--gap);
  grid-template:
    "top top" auto
    "left main" 1fr
    "bottom bottom" 170px
    / 300px 1fr;
}

#top, #left, #main, #bottom {
  background: var(--panel);
  border-radius: 5px;
  min-width: 0;
  min-height: 0;
}
fieldset, [popover] { border-radius: 5px; }
[popover] { max-width: 40em; }

#top { grid-area: top; display: flex; flex-wrap: wrap; align-items: center; gap: var(--gap); padding: 4px var(--gap); }
#left { grid-area: left; overflow: auto; }
#main { grid-area: main; display: flex; }
#bottom { grid-area: bottom; display: flex; }

/* a fieldset fills its panel; the drawing box fills the fieldset */
#main > fieldset, #bottom > fieldset { flex: 1; display: flex; flex-direction: column; min-height: 0; }
#scene, .chart { flex: 1; position: relative; min-height: 0; }

/* canvases sit out of flow, so their pixel size never feeds back into the layout that sizes them */
#scene > canvas, .chart > canvas { position: absolute; inset: 0; }
.chart > canvas { width: 100%; height: 100%; }
.lbl { font: 11px ui-monospace, monospace; white-space: nowrap; }

td, th { text-align: center; padding: 0 6px; }

/* phones: one column, the scene first */
@media (max-width: 720px) {
  body {
    height: auto;
    grid-template:
      "top" auto
      "main" 60vh
      "left" auto
      "bottom" 170px
      / 1fr;
  }
}
