:root {
  --bg: #f6f2ea; --panel: #fffdf8; --ink: #2a2520; --muted: #6f665c; --line: #e3dace;
  --accent: #c8741f; --accent-ink: #fff; --warn: #a8461e; --ok: #3c7a4a; --track: #e8dfd2;
  --stage-top: #efe7da; --stage-bot: #e2d6c4;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #17140f; --panel: #201c16; --ink: #efe8dc; --muted: #a59a8b; --line: #342d24;
    --accent: #e8a33d; --accent-ink: #1b150c; --warn: #f08a5d; --ok: #7cc48c; --track: #3a3229;
    --stage-top: #221d16; --stage-bot: #110e0a;
  }
}
:root[data-theme="dark"] {
  --bg: #17140f; --panel: #201c16; --ink: #efe8dc; --muted: #a59a8b; --line: #342d24;
  --accent: #e8a33d; --accent-ink: #1b150c; --warn: #f08a5d; --ok: #7cc48c; --track: #3a3229;
  --stage-top: #221d16; --stage-bot: #110e0a;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif;
  display: grid; grid-template-columns: 1fr 360px; min-height: 100vh;
}
#stage { position: relative; background: linear-gradient(var(--stage-top), var(--stage-bot)); min-height: 60vh; }
#stage canvas { display: block; width: 100%; height: 100%; touch-action: none; }
#busy {
  position: absolute; left: 16px; bottom: 14px; font-size: 13px; color: var(--muted);
  opacity: 0; transition: opacity .2s;
}
#busy.on { opacity: 1; }
#size { position: absolute; right: 16px; bottom: 14px; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
#lightbtn {
  position: absolute; right: 14px; top: 14px; border: 1px solid var(--line); background: var(--panel);
  color: var(--ink); border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer;
}
aside {
  background: var(--panel); border-left: 1px solid var(--line); padding: 22px 20px 28px;
  overflow-y: auto; max-height: 100vh;
}
h1 { font-size: 21px; margin: 0 0 4px; letter-spacing: -.01em; }
.lede { color: var(--muted); margin: 0 0 18px; font-size: 14px; }
h2 { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin: 22px 0 8px; font-weight: 600; }
.row { margin: 10px 0 14px; }
.row label { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 14px; }
.row .val { font-variant-numeric: tabular-nums; color: var(--muted); }
.row details { margin-top: 2px; }
.row summary { font-size: 12px; color: var(--muted); cursor: pointer; list-style: none; display: inline; }
.row summary::-webkit-details-marker { display: none; }
.row summary::before { content: "why this range"; text-decoration: underline dotted; }
.row details[open] summary::before { content: "hide"; }
.row details p { font-size: 12.5px; color: var(--muted); margin: 4px 0 0; }
input[type=range] { width: 100%; accent-color: var(--accent); margin: 6px 0 0; }
.seg { display: flex; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; margin-top: 6px; }
.seg button { flex: 1; border: 0; background: transparent; color: var(--ink); padding: 7px 0; font: inherit; font-size: 14px; cursor: pointer; }
.seg button.on { background: var(--accent); color: var(--accent-ink); }
#status { font-size: 13px; margin: 18px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--track); }
#status .warn { color: var(--warn); }
#status .ok { color: var(--ok); }
#dl {
  width: 100%; margin-top: 14px; padding: 12px; border: 0; border-radius: 10px; background: var(--accent);
  color: var(--accent-ink); font: inherit; font-weight: 600; font-size: 16px; cursor: pointer;
}
#dl[disabled] { opacity: .6; cursor: progress; }
.small { font-size: 12.5px; color: var(--muted); }
.small ul { padding-left: 18px; margin: 6px 0; }
a { color: var(--accent); }
#reset { background: none; border: 0; color: var(--muted); font: inherit; font-size: 13px; text-decoration: underline; cursor: pointer; padding: 0; margin-top: 10px; }
@media (max-width: 820px) {
  body { grid-template-columns: 1fr; }
  #stage { height: 58vh; min-height: 320px; }
  aside { border-left: 0; border-top: 1px solid var(--line); max-height: none; padding: 18px 16px 28px; }
}
/* the two designers, as tabs over the stage */
#tabs { position: absolute; left: 14px; top: 14px; display: flex; gap: 0; border: 1px solid var(--line);
  border-radius: 999px; overflow: hidden; background: var(--panel); z-index: 2; }
#tabs a { padding: 6px 12px; font-size: 13px; color: var(--ink); text-decoration: none; }
#tabs a[aria-current="page"] { background: var(--accent); color: var(--accent-ink); }
.btnrow { display: flex; gap: 8px; margin-top: 10px; }
.btnrow button { flex: 1; border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 8px;
  padding: 8px 0; font: inherit; font-size: 14px; cursor: pointer; }
.stagebtns { position: absolute; right: 14px; top: 14px; display: flex; gap: 8px; }
.stagebtns #lightbtn { position: static; }
.stagebtns button { border: 1px solid var(--line); background: var(--panel); color: var(--ink); border-radius: 999px;
  padding: 6px 12px; font: inherit; font-size: 13px; cursor: pointer; }
#modlist { font-size: 12.5px; color: var(--muted); columns: 2; margin: 8px 0 0; padding: 0; list-style: none; }
#modlist li { break-inside: avoid; font-variant-numeric: tabular-nums; }
#modlist i { display: inline-block; width: 9px; height: 9px; border-radius: 2px; margin-right: 5px; vertical-align: baseline; }
