:root {
  --bg: #f6f6f3; --panel: #ffffff; --ink: #1d1d1b; --muted: #6b6b66; --line: #d9d9d3;
  --on: #2f6fdb; --on-ink: #ffffff; --off: #e9e9e4; --off-hover: #d6d6cf; --off-ink: #a3a39c; --sel: #f2a33a;
  --view: #15171c;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #111214; --panel: #1a1c20; --ink: #e8e8e4; --muted: #9a9a94; --line: #2c2f35;
    --on: #3d7ef0; --off: #23262b; --off-hover: #33373e; --off-ink: #5c5f66;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
    --bg: #111214; --panel: #1a1c20; --ink: #e8e8e4; --muted: #9a9a94; --line: #2c2f35;
    --on: #3d7ef0; --off: #23262b; --off-hover: #33373e; --off-ink: #5c5f66;
}
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
header { padding: 12px 16px 4px; display: flex; flex-wrap: wrap; gap: 8px 16px; align-items: baseline; justify-content: space-between; }
.theme { display: inline-flex; border: 1px solid var(--line); border-radius: 7px; padding: 2px; background: var(--panel); }
.theme button { font: inherit; font-size: 12px; color: var(--muted); background: transparent; border: 0; border-radius: 5px;
  padding: 3px 10px; cursor: pointer; }
.theme button:hover { color: var(--ink); }
.theme button[aria-pressed="true"] { background: var(--on); color: var(--on-ink); }
.theme button:focus-visible { outline: 2px solid var(--sel); outline-offset: 1px; }
h1 { font-size: 18px; margin: 0; font-weight: 600; }
.eyebrow { margin: 0 0 2px; font-size: 12px; }
.eyebrow a { color: var(--muted); text-decoration: none; }
.eyebrow a:hover { text-decoration: underline; }
main { display: grid; grid-template-columns: minmax(0, 560px) minmax(0, 1fr); gap: 16px; padding: 8px 16px; }
@media (max-width: 900px) { main { grid-template-columns: minmax(0, 1fr); } }
#table { display: grid; grid-template-columns: repeat(18, minmax(0, 1fr)); gap: 2px; }
.cell { aspect-ratio: 1; border: 0; border-radius: 3px; padding: 0; font: inherit; font-size: 11px;
  background: var(--off); color: var(--off-ink); cursor: default; }
.cell.on { background: var(--on); color: var(--on-ink); cursor: pointer; font-weight: 600; }
.cell.on:hover { filter: brightness(1.15); }
.cell:not(.on) { cursor: help; }
.cell:not(.on):hover { background: var(--off-hover); color: var(--ink); }
.cell.sel { outline: 2px solid var(--sel); outline-offset: 1px; }
.cell { position: relative; }
.cell.non { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
.cell.non:hover { background: var(--off); }
.cell[class*="edge-"]::after { content: ""; position: absolute; inset: -2px; border: 0 solid var(--muted); pointer-events: none; }
.cell.edge-t::after { border-top-width: 2px; }
.cell.edge-r::after { border-right-width: 2px; }
.cell.edge-b::after { border-bottom-width: 2px; }
.cell.edge-l::after { border-left-width: 2px; }
.gap { grid-column: 1 / -1; height: 6px; }
#legend { margin: 8px 0; color: var(--muted); font-size: 12px; display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.key { display: inline-block; width: 12px; height: 12px; border-radius: 2px; margin-left: 8px; }
.cell.dft { box-shadow: inset 0 -3px 0 var(--sel); }
.key.dft { background: var(--on); box-shadow: inset 0 -4px 0 var(--sel); }
.key.on { background: var(--on); } .key.off { background: var(--off); border: 1px solid var(--line); }
.cell.on.only { background: var(--panel); color: var(--on); box-shadow: inset 0 0 0 2px var(--on); }
.key.only { background: var(--panel); box-shadow: inset 0 0 0 2px var(--on); }
.key.non { background: transparent; box-shadow: inset 0 0 0 1px var(--line); }
#info { background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
#info h2 { margin: 0 0 6px; font-size: 16px; }
#info dl { display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; margin: 0; }
#info dt { color: var(--muted); } #info dd { margin: 0; font-variant-numeric: tabular-nums; }
#info .caveat { margin: 8px 0 0; color: var(--muted); font-size: 13px; }
#info .err { color: #d33; }
#right { min-width: 0; }
#view { width: 100%; aspect-ratio: 4 / 3; display: block; border-radius: 6px; background: var(--view);
  touch-action: none; cursor: grab; }
#view:active { cursor: grabbing; }
#controls { margin-top: 8px; display: grid; gap: 10px; }
#bands { display: flex; flex-wrap: wrap; gap: 4px 14px; min-height: 1.6em; }
#settings { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 8px 16px; align-items: end; }
#settings .field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
#settings .field .name { color: var(--muted); font-size: 12px; }
#settings select, #settings input[type=range] { width: 100%; max-width: 100%; }
input[type=range] { -webkit-appearance: none; appearance: none; height: 18px; background: transparent; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: var(--muted); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 2px; background: var(--muted); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 14px; height: 14px; margin-top: -5px;
  border-radius: 50%; background: var(--on); border: 0; }
input[type=range]::-moz-range-thumb { width: 14px; height: 14px; border-radius: 50%; background: var(--on); border: 0; }
input[type=range]:focus-visible { outline: 2px solid var(--on); outline-offset: 2px; }
#settings .field.view { grid-column: 1 / -1; flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 18px; }
#settings .field.view label { display: inline-flex; align-items: center; gap: 5px; white-space: nowrap; }
#settings .field.view button { white-space: nowrap; }
#centre-box.off, #faces-box.off, #cell-box.off, #model-box.off, #method-box.off, #mesh-box.off { opacity: 0.5; }
#bands label { display: inline-flex; gap: 4px; align-items: center; }
.swatch { width: 12px; height: 12px; border-radius: 2px; display: inline-block; }
#timing { color: var(--muted); font-size: 12px; }
.hint { color: var(--muted); font-size: 12px; margin: 4px 0 0; }
footer { padding: 12px 16px 20px; margin-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 12px;
  display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px 24px; }
footer h3 { margin: 0 0 4px; font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--ink); }
footer p, footer ul { margin: 0; }
footer p + p { margin-top: 4px; }
footer ul { padding-left: 1.1em; }
footer li { margin: 2px 0; }
footer a { color: inherit; }
.katex { font-size: 1.08em; }
#glossary { margin-top: 10px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; font-size: 13px; }
#glossary summary { cursor: pointer; color: var(--muted); }
#glossary table { border-collapse: collapse; width: 100%; margin-top: 8px; }
#glossary th, #glossary td { text-align: left; vertical-align: top; padding: 3px 8px 3px 0; border-top: 1px solid var(--line); }
#glossary thead th { color: var(--muted); font-weight: 400; border-top: 0; }
#glossary tbody th { white-space: nowrap; }
abbr[title] { text-decoration: underline dotted; cursor: help; }
.licenses-main { display: block; max-width: 900px; }
.licenses-main table { border-collapse: collapse; margin-bottom: 24px; }
.licenses-main th, .licenses-main td { text-align: left; padding: 4px 12px 4px 0; border-top: 1px solid var(--line); vertical-align: top; }
.licenses-main h2 { font-size: 15px; margin: 24px 0 6px; }
.licenses-main pre { white-space: pre-wrap; font-size: 12px; background: var(--panel); border: 1px solid var(--line); border-radius: 6px; padding: 10px; overflow-x: auto; }
