:root {
  color-scheme: light;
  --ink: #000;
  --paper: #fff;
  --dither: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'><rect width='1' height='1' fill='%23000'/><rect x='2' y='2' width='1' height='1' fill='%23000'/></svg>");
  --checker: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'><rect width='2' height='2' fill='%23000'/><rect x='2' y='2' width='2' height='2' fill='%23000'/></svg>");
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
}

body {
  font-family: ui-monospace, "SFMono-Regular", "Cascadia Mono", "Segoe UI Mono", Menlo, Consolas, monospace;
  font-size: 14px;
  line-height: 1.45;
  min-height: 100vh;
  padding-bottom: var(--foot-h, 72px);
}

a {
  color: var(--ink);
}

button,
input,
select {
  font: inherit;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--ink);
  border-radius: 0;
}

button {
  cursor: pointer;
  padding: 8px 12px;
}

button:hover,
button.on {
  background: var(--ink);
  color: var(--paper);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='8' height='6' shape-rendering='crispEdges'><polygon points='0,0 8,0 4,6' fill='%23000'/></svg>");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 24px;
}

input[type="checkbox"] {
  accent-color: #000;
  width: 14px;
  height: 14px;
}

.band {
  height: 10px;
  background-color: var(--paper);
  background-image: var(--checker);
  background-size: 4px 4px;
  image-rendering: pixelated;
}

.band.sparse {
  background-image: var(--dither);
}

header {
  background: var(--ink);
  color: var(--paper);
  padding: 28px 0;
}

header a,
footer a {
  color: var(--paper);
}

header a:focus-visible,
footer a:focus-visible {
  outline: 2px solid var(--paper);
  outline-offset: 3px;
}

.hero-bar {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.hero-copy {
  min-width: 0;
}

.brand {
  flex: 0 0 auto;
  line-height: 0;
}

.brand img {
  display: block;
  height: 40px;
  width: auto;
}

.kicker {
  margin: 0 0 8px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 12px;
}

header h1 {
  margin: 0;
  font-size: 42px;
  line-height: 0.95;
  font-weight: 700;
  letter-spacing: -0.04em;
  max-width: 16ch;
}

.sub {
  margin: 14px 0 0;
  max-width: 46ch;
}

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 0 20px 48px;
}

.tabbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 18px 0;
}

.tabs,
.subtabs {
  display: flex;
  gap: 0;
  margin: 0;
}

.subtabs {
  margin: 0 0 18px;
}

.tabs button,
.subtabs button {
  border-right: none;
}

.tabs button:last-child,
.subtabs button:last-child {
  border-right: 1px solid var(--ink);
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 22px;
  align-items: start;
}

/* Columns sit on the paper. No box around a column of controls or results. */
.panel {
  min-width: 0;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.panel h2:not(:first-child) {
  margin-top: 24px;
}

label {
  display: block;
  margin: 0 0 10px;
}

label span,
.row span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

input,
select {
  width: 100%;
  padding: 7px 8px;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 10px;
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px 0 12px;
}

.check span {
  margin: 0;
  letter-spacing: 0;
  text-transform: none;
  font-size: 13px;
}

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

/* Explanatory notes are serif body copy, not mono prose. */
.hint {
  max-width: 36rem;
  margin: 16px 0 0;
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.5;
  text-wrap: pretty;
}

.mono {
  font-variant-numeric: tabular-nums;
}

.out .hero {
  font-size: 34px;
  line-height: 1;
  letter-spacing: -0.04em;
  margin: 0 0 4px;
}

.out .hero-label {
  margin: 0 0 12px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.warning {
  background: var(--ink);
  color: var(--paper);
  padding: 12px;
  margin: 0 0 12px;
}

.warning p {
  margin: 0;
}

.note {
  max-width: 36rem;
  margin: 0 0 12px;
  font-family: "Newsreader", Georgia, "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.5;
}

dl {
  margin: 0;
}

dl div {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  padding: 4px 0;
}

dt {
  margin: 0;
}

dd {
  margin: 0;
  text-align: right;
}

.ruler {
  position: relative;
  margin: 14px 0 8px;
  border-bottom: 2px solid var(--ink);
  overflow: hidden;
}

.mark {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 0;
}

.mark .lab {
  position: absolute;
  font-size: 11px;
  line-height: 1.15;
  white-space: nowrap;
}

.mark i {
  position: absolute;
  left: 0;
  bottom: 0;
  display: block;
  width: 1px;
  height: 12px;
  margin: 0;
  background: var(--ink);
  font-style: normal;
}

.mark b {
  display: block;
  font-weight: 700;
}

pre {
  margin: 16px 0 0;
  padding: 0;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 220px;
  overflow: auto;
  font: inherit;
  font-size: 12px;
}

.err {
  margin: 0;
  font-weight: 700;
}

footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 4;
  background: var(--ink);
  color: var(--paper);
  font-size: 12px;
}

.foot-bar {
  max-width: 1040px;
  margin: 0 auto;
  padding: 10px 20px calc(12px + env(safe-area-inset-bottom));
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 4px 16px;
}

.foot-bar p {
  margin: 0;
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

@media (max-width: 800px) {
  header h1 {
    font-size: 34px;
    max-width: 100%;
  }

  .brand img {
    height: 32px;
  }

  .layout,
  .grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .panel {
    min-width: 0;
  }

  /* Result tables scroll inside their panel, never the page. */
  .out {
    overflow-x: auto;
  }

  .out .hero {
    font-size: 28px;
  }

  .foot-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
    padding-top: 8px;
    padding-bottom: 8px;
  }

  .foot-bar p {
    white-space: normal;
  }

  /* A pinned footer eats a phone screen. Keep it in flow. */
  body {
    padding-bottom: 0;
  }

  footer {
    position: static;
  }
}

/* Touch screens: 40px targets, and 16px fields so iOS does not zoom. */
@media (pointer: coarse), (max-width: 800px) {
  input:not([type="checkbox"]),
  select {
    font-size: 16px;
    min-height: 40px;
  }

  button {
    min-height: 40px;
  }
}
