:root {
  color-scheme: light;
  --surface-0: #f7f7f5; --surface-1: #ffffff; --border: #e2e2df;
  --text-primary: #191919; --text-secondary: #666666;
  --series-1: #257de0; --series-2: #f47230; --series-3: #00b894; --strand: #3a3a3a;
  --accent: #257de0;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --surface-0: #111111; --surface-1: #191919; --border: #333333;
    --text-primary: #efefef; --text-secondary: #9c9c9c;
    --series-1: #338ced; --series-2: #e76624; --series-3: #00a888; --strand: #d0d0d0;
    --accent: #338ced;
  }
  img { filter: invert(0.92) hue-rotate(180deg); }
}
* { box-sizing: border-box; }
body { margin: 0; font: 15px/1.55 system-ui, -apple-system, "Segoe UI", sans-serif; background: var(--surface-0); color: var(--text-primary); }
header, main, footer { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
header { padding-top: 28px; }
h1 { margin: 0 0 6px; font-size: 28px; }
.lede { color: var(--text-secondary); max-width: 760px; margin: 0 0 18px; }
nav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
nav button { background: none; border: none; padding: 10px 14px; font: inherit; color: var(--text-secondary); cursor: pointer; border-bottom: 2px solid transparent; }
nav button[aria-selected="true"] { color: var(--text-primary); border-bottom-color: var(--accent); font-weight: 600; }
.tab { padding: 20px 0 40px; }
.controls { display: flex; gap: 16px; flex-wrap: wrap; align-items: center; margin-bottom: 12px; }
label { color: var(--text-secondary); font-size: 14px; display: inline-flex; gap: 6px; align-items: center; }
select, button, input { font: inherit; }
select, button { background: var(--surface-1); color: var(--text-primary); border: 1px solid var(--border); border-radius: 6px; padding: 5px 10px; }
button { cursor: pointer; }
button:hover { border-color: var(--accent); }
.gens { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.gens button { min-width: 58px; font-family: ui-monospace, monospace; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 8px; }
.word { font-family: ui-monospace, monospace; font-size: 13px; color: var(--text-secondary); word-break: break-all; }
.braidwrap { overflow-x: auto; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 8px; }
.hint { color: var(--text-secondary); font-size: 13px; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; margin-top: 12px; }
@media (max-width: 800px) { .grid2 { grid-template-columns: 1fr; } }
.card { background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 14px 16px; }
.card h3 { margin: 4px 0 8px; font-size: 15px; }
.bar { display: grid; grid-template-columns: minmax(110px, max-content) 1fr 92px; gap: 8px; align-items: center; font-size: 13px; margin: 3px 0; }
.bar .lab { font-family: ui-monospace, monospace; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar .track { height: 12px; background: var(--border); border-radius: 0 4px 4px 0; position: relative; }
.bar .fill { height: 100%; background: var(--series-1); border-radius: 0 4px 4px 0; }
.bar .val { font-variant-numeric: tabular-nums; color: var(--text-primary); }
.init label { display: flex; font-family: ui-monospace, monospace; font-size: 13px; }
table { border-collapse: collapse; font-variant-numeric: tabular-nums; font-size: 13px; }
td, th { padding: 4px 8px; border-bottom: 1px solid var(--border); text-align: right; }
th { color: var(--text-secondary); font-weight: 500; }
.target { font-size: 14px; }
canvas { width: 100%; height: auto; background: var(--surface-1); }
figure { margin: 0 0 28px; background: var(--surface-1); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
figure img { width: 100%; }
figcaption { color: var(--text-secondary); font-size: 14px; margin-top: 6px; }
.prose { max-width: 760px; }
footer { color: var(--text-secondary); font-size: 13px; padding-bottom: 30px; }
.tally td:first-child { text-align: left; }

#bloch { width: 100%; max-width: 320px; display: block; margin: 0 auto; }
nav .navlink { padding: 10px 14px; color: var(--accent); text-decoration: none; }
nav .navlink:first-of-type { margin-left: auto; }
