:root { color-scheme: light dark; font-family: system-ui, sans-serif; }
* { box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body { margin: 0; background: Canvas; color: CanvasText; }
main { height: 100dvh; max-width: 1200px; margin: auto; padding: 12px; display: grid; grid-template-rows: auto auto auto auto auto minmax(0, 1fr); gap: 8px; }
h1, p { margin: 0; }
h1 { font-size: clamp(1.3rem, 4vw, 2rem); }
.controls { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: end; }
label { display: grid; gap: 3px; font-weight: 600; }
.check { display: flex; align-items: center; gap: 6px; padding-bottom: 8px; }
input, button { font: inherit; }
input[type="number"] { width: 6rem; }
button, #download { border: 0; border-radius: 8px; padding: 8px 12px; background: #2563eb; color: white; cursor: pointer; text-decoration: none; width: fit-content; }
button:disabled { opacity: .55; cursor: wait; }
#status { min-height: 1.4em; }
.workspace { min-height: 0; overflow: hidden; display: grid; grid-template-columns: minmax(0, 1fr) minmax(240px, 340px); gap: 12px; }
.workspace:has(#legendBox[hidden]) { grid-template-columns: minmax(0, 1fr); }
.workspace > * { min-width: 0; }
#pattern { display: block; min-height: 0; max-width: 100%; max-height: 100%; width: auto; height: auto; justify-self: center; align-self: center; background: white; image-rendering: pixelated; }
#legendBox { min-height: 0; overflow: auto; border: 1px solid color-mix(in srgb, CanvasText 18%, transparent); border-radius: 8px; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 5px 7px; border-bottom: 1px solid color-mix(in srgb, CanvasText 18%, transparent); text-align: left; }
th { position: sticky; top: 0; background: Canvas; }
.swatch { display: inline-block; width: 1.4em; height: 1.4em; border: 1px solid #888; vertical-align: middle; }
@media (max-width: 760px) {
  main { padding: 8px; gap: 6px; }
  .workspace { grid-template: minmax(0, 1fr) minmax(90px, 32%) / 1fr; }
  .workspace:has(#legendBox[hidden]) { grid-template: minmax(0, 1fr) / 1fr; }
  .controls { font-size: .9rem; }
}
