:root {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --text: #1d1d1b;
  --muted: #6b6b66;
  --border: #dddcd6;
  --accent: #7a2fd0;
  --accent-soft: #e6ecfa;
  --error: #b42318;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151516;
    --surface: #1f1f20;
    --text: #ececea;
    --muted: #a3a39d;
    --border: #3a3a37;
    --accent: #a400cd;
    --accent-soft: #40264a;
    --error: #ff7b6e;
  }
}
* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
main { max-width: 1100px; margin: 0 auto; padding: 24px 16px 48px; }
h1 { font-size: 1.5rem; margin: 0 0 4px; }
h2 { font-size: 1.05rem; margin: 0 0 12px; }
/* Matches the rest of the site's cool-header convention (bold, accent-
   colored headers) using this page's own --accent instead of the main
   site's hardcoded neon green, since this page runs its own light/dark
   design system rather than the main site's stylesheet. */
.cool-header { color: var(--accent); font-weight: 700; }
p.lead { color: var(--muted); margin: 0 0 20px; }
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}
.controls { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 4px; }
.field .label { font-size: 0.8rem; color: var(--muted); }
.field input[type="number"] {
  font: inherit;
  width: 120px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
}
.hint { color: var(--muted); font-size: 0.85rem; margin-top: 10px; }
.error-text { color: var(--error); font-size: 0.85rem; margin-top: 10px; min-height: 1.3em; }
.array-layout { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 360px); gap: 24px; align-items: start; }
@media (max-width: 760px) { .array-layout { grid-template-columns: minmax(0, 1fr); } }
.segmented { display: inline-flex; border: 1px solid var(--border); border-radius: 8px; overflow: hidden; margin-bottom: 16px; flex-wrap: wrap; }
.segmented label { padding: 6px 14px; cursor: pointer; font-size: 0.9rem; border-right: 1px solid var(--border); }
.segmented label:last-child { border-right: 0; }
.segmented input { position: absolute; opacity: 0; pointer-events: none; }
.segmented label:has(input:checked) { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.segmented label:has(input:focus-visible) { outline: 2px solid var(--accent); outline-offset: -2px; }
.source-fields { margin-top: 12px; }
.source-fields[hidden] { display: none; }
.summary { display: flex; flex-wrap: wrap; gap: 4px 16px; margin-top: 12px; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.summary span { color: var(--muted); }
.layout-figure { position: relative; }
.layout-figure img { min-height: 200px; }
.layout-figure.pending img { opacity: 0.5; }
#preview { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; border: 1px solid var(--border); border-radius: 6px; background: #fff; display: none; }
#preview.visible { display: block; }
button, .button {
  font: inherit;
  padding: 8px 20px;
  border: 0;
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.button.secondary { background: var(--accent-soft); color: var(--accent); padding: 6px 14px; font-size: 0.9rem; }
.button[aria-disabled="true"] { opacity: 0.45; pointer-events: none; }
button:disabled { opacity: 0.45; cursor: not-allowed; }
progress { width: 100%; height: 8px; margin-top: 12px; accent-color: var(--accent); }
#status { margin-top: 6px; color: var(--muted); font-size: 0.9rem; }
#status.error { color: var(--error); }
#log { margin: 8px 0 0; padding: 0; list-style: none; font: 0.8rem/1.5 ui-monospace, monospace; color: var(--muted); max-height: 140px; overflow-y: auto; }
#results { display: none; }
#results.visible { display: block; }
.stats { display: flex; flex-wrap: wrap; gap: 24px; margin-bottom: 12px; }
.stat .label { color: var(--muted); font-size: 0.8rem; }
.stat .value { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; }
figure { margin: 0; }
.steering-figure { margin-top: 16px; }
figure img { width: 100%; height: auto; display: block; border-radius: 6px; background: #fff; }
figcaption { color: var(--muted); font-size: 0.85rem; margin-top: 6px; }
a { color: var(--accent); }
code { font-size: 0.85em; }
