@font-face {
  font-family: 'Azeret Mono';
  font-weight: 600;
  font-display: swap;
  src: url(fonts/azeret-mono-600-latin.woff2) format('woff2');
}

:root {
  color-scheme: light dark;
  --ground: #F4F3F0;
  --surface: #FFFFFF;
  --ink: #17171A;
  --secondary: #5A5A60;
  --hairline: #D9D8D3;
  --accent: #9A4A00;
  /* The view is always dark, whatever the theme. */
  --space: #000000;
  --on-space: #ECECEE;
  --focus-on-space: #FFB866;
}

@media (prefers-color-scheme: dark) {
  :root {
    --ground: #101013;
    --surface: #1B1B20;
    --ink: #ECECEE;
    --secondary: #A4A4AC;
    --hairline: #30303A;
    --accent: #FFB866;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 1rem/1.5 system-ui, sans-serif;
  accent-color: var(--accent);
}

main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 20rem;
  height: 100dvh;
}

.stage {
  position: relative;
  background: var(--space);
  min-height: 0;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: grab;
}
canvas:active { cursor: grabbing; }
canvas:focus-visible {
  outline: 2px solid var(--focus-on-space);
  outline-offset: -4px;
}
/* The canvas paints over its own outline's surroundings, so the ring is drawn
   above it, edged in black to show on the bright disk too. */
.stage:has(> canvas:focus-visible)::after {
  content: '';
  position: absolute;
  inset: 4px;
  border: 2px solid var(--focus-on-space);
  box-shadow: 0 0 0 2px var(--space), inset 0 0 0 2px var(--space);
  pointer-events: none;
}

.status {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 16px;
  padding: 24px;
  color: var(--on-space);
  text-align: center;
  pointer-events: none;
}
.status:empty { display: none; }
.status p { margin: 0; max-width: 40ch; }
.status button, .status pre { pointer-events: auto; }
.status pre {
  max-width: min(60ch, 100%);
  max-height: 40vh;
  overflow: auto;
  margin: 0;
  white-space: pre-wrap;
  text-align: left;
  user-select: all;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 24px;
  padding: 24px;
  overflow-y: auto;
  border-left: 1px solid var(--hairline);
}
.panel > * { margin: 0; }

h1 { font-size: 1.5rem; line-height: 1.25; }

fieldset {
  display: grid;
  gap: 16px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.field {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 12px;
}
.field label { white-space: nowrap; }
.field output { color: var(--secondary); font-variant-numeric: tabular-nums; text-align: end; }
.field input { grid-column: 1 / -1; width: 100%; margin: 0; }

.actions { display: flex; flex-wrap: wrap; gap: 8px; }

button { font: inherit; }

dl {
  display: grid;
  gap: 8px;
  padding: 16px 0;
  border-block: 1px solid var(--hairline);
}
dl div { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 0 12px; }
dl div[hidden] { display: none; }
dt { color: var(--secondary); }
dd { margin: 0; font-variant-numeric: tabular-nums; }

.hint { color: var(--secondary); }

footer { margin-top: auto; color: var(--secondary); }
.lockup { display: block; overflow: visible; }

@media (pointer: coarse) {
  button, input[type='range'] { min-height: 44px; }
  button { min-width: 44px; padding-inline: 16px; }
}

@media (max-width: 720px) {
  main { grid-template-columns: minmax(0, 1fr); height: auto; }
  .stage { height: 60dvh; min-height: 280px; }
  .panel { overflow: visible; border-left: 0; }
}
