/* celscan.nielsveck.com — tokens and type follow DESIGN.md in the repo root. */
@font-face {
  font-family: "Inter"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/static/fonts/inter-latin-wght-normal.woff2) format("woff2");
}
@font-face {
  font-family: "Fraunces"; font-style: normal; font-display: swap; font-weight: 100 900;
  src: url(/static/fonts/fraunces-latin-opsz-normal.woff2) format("woff2");
}

:root {
  --bg: #FAF7F2; --bg-raised: #FFFFFF; --ink: #1B1917; --ink-soft: #5E5852;
  --line: #E6DFD5; --accent: #B4531F; --accent-ink: #FFFFFF; --warn: #9A3412;
  --viewer: #2A2826;
  --mono: ui-monospace, "JetBrains Mono", "SFMono-Regular", Consolas, monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #151311; --bg-raised: #1D1A17; --ink: #EFEAE3; --ink-soft: #A79F95;
    --line: #2C2823; --accent: #E08A5A; --accent-ink: #151311; --warn: #F0A274;
    --viewer: #0E0D0C;
  }
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 400 16px/1.6 "Inter", system-ui, sans-serif;
}
@media (min-width: 768px) { body { font-size: 17px; } }
a { color: inherit; text-decoration-color: var(--accent); text-underline-offset: 3px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { max-width: 1680px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 768px) { .wrap { padding: 0 32px; } }

.top { padding: 24px 0 8px; }
.top-row { display: flex; justify-content: space-between; align-items: center; gap: 16px; margin-bottom: 4px; }
.top-row .pills { flex-wrap: nowrap; }
.kicker, .foot, kbd { font-family: var(--mono); font-size: 13px; letter-spacing: .06em; color: var(--ink-soft); }
.kicker { margin: 0 0 4px; text-transform: uppercase; }
.kicker a { text-decoration: none; }
h1, h2 { font-family: "Fraunces", Georgia, serif; font-weight: 560; letter-spacing: -0.02em; line-height: 1.1; }
h1 { font-size: clamp(2rem, 5vw, 3rem); margin: 0; }
h2 { font-size: 1.25rem; margin: 0 0 12px; }
h3 {
  font-family: var(--mono); font-size: 13px; font-weight: 400; letter-spacing: .06em;
  text-transform: uppercase; color: var(--ink-soft); margin: 24px 0 4px;
}
h2 + h3 { margin-top: 8px; }
.lead { color: var(--ink-soft); margin: 8px 0 0; max-width: 68ch; }

/* Phone: image first, then settings, then result. Wide: three columns. */
.layout {
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px;
  padding-top: 16px; padding-bottom: 32px;
}
.col-beeld, .col-inst, .col-res { min-width: 0; }
@media (min-width: 1100px) {
  .layout { grid-template-columns: 300px minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
  .col-inst { grid-column: 1; grid-row: 1; }
  .col-beeld { grid-column: 2; grid-row: 1; position: sticky; top: 16px; }
  .col-res { grid-column: 3; grid-row: 1; }
}
.card {
  background: var(--bg-raised); border: 1px solid var(--line); border-radius: 10px;
  padding: 20px 16px; margin: 0;
}
@media (min-width: 768px) { .card { padding: 24px; } }

/* Controls */
label, .veldnaam { display: block; margin: 14px 0 6px; font-weight: 500; font-size: .95em; }
h3 + label, h3 + .veldnaam { margin-top: 8px; }
input, select {
  font: inherit; color: var(--ink); background: var(--bg);
  border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; min-height: 44px; width: 100%;
}
input:focus, select:focus { border-color: var(--accent); outline: none; }
input[type="range"] { padding: 0; border: 0; background: transparent; accent-color: var(--accent); flex: 1 1 auto; }
input[type="checkbox"] { width: 22px; height: 22px; min-height: 0; accent-color: var(--accent); margin: 0; flex: none; }
.rij { display: flex; align-items: center; gap: 8px; }
.rij input[type="number"], .rij input:not([type]) { flex: 1 1 auto; min-width: 0; }
.rij output { min-width: 3.5ch; text-align: right; font-variant-numeric: tabular-nums; }
.eenheid { color: var(--ink-soft); font-size: .9em; min-width: 3.5ch; }
.vink { display: flex; gap: 10px; align-items: center; font-weight: 400; min-height: 44px; margin-top: 10px; }
.knoppen { flex-wrap: wrap; margin-top: 12px; }
.knoppen.onder { margin-top: 24px; }
.hint { font-size: .88em; color: var(--ink-soft); margin: 6px 0 0; }
.hint.warn { color: var(--warn); }

.knop {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  font: 600 15px/1 "Inter", system-ui, sans-serif; min-height: 44px; padding: 0 18px;
  border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--ink);
  cursor: pointer; transition: border-color .15s, background-color .15s; position: relative; margin: 0;
}
.knop:hover { border-color: var(--ink-soft); }
.knop.primair { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.knop.primair:hover { filter: brightness(.95); }
.knop[disabled] { opacity: .5; cursor: default; }
.knop kbd, .pill kbd { font-size: 11px; color: inherit; opacity: .7; letter-spacing: 0; }
.knop input[type="file"] { position: absolute; inset: 0; opacity: 0; cursor: pointer; min-height: 0; padding: 0; }
.knop:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (hover: none) { kbd { display: none; } }

.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill {
  font: 500 14px/1 "Inter", system-ui, sans-serif; color: var(--ink); background: transparent;
  border: 1px solid var(--line); border-radius: 999px; min-height: 44px; padding: 0 16px;
  cursor: pointer; transition: border-color .15s, background-color .15s;
}
.pill:hover { border-color: var(--ink-soft); }
.pill[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.pill.klein { min-height: 36px; padding: 0 12px; font-size: 13px; }

/* Image column */
.werkbalk { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.modi { margin-bottom: 8px; }
.viewer {
  position: relative; height: 62vh; min-height: 320px; background: var(--viewer);
  border-radius: 10px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
}
@media (min-width: 1100px) { .viewer { height: calc(100vh - 200px); min-height: 480px; } }
.viewer.tekenen { cursor: crosshair; }
.viewer.slepen { cursor: grab; }
.viewer.slepen:active { cursor: grabbing; }
.stapel { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.stapel canvas { position: absolute; left: 0; top: 0; }
/* ingezoomd: pixels scherp, uitgezoomd: vloeiend */
.stapel.scherp canvas { image-rendering: pixelated; }
#tekenlaag { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; overflow: visible; }
.leeg {
  position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 24px;
  color: #CFC8BF; font-size: .95em;
}
.viewer-knoppen { position: absolute; right: 8px; bottom: 8px; display: flex; gap: 6px; }
.viewer-knoppen .pill { background: rgb(20 18 16 / .7); color: #EFEAE3; border-color: rgb(255 255 255 / .2); }
.viewer-knoppen .pill[aria-pressed="true"] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.status { margin: 8px 0 0; min-height: 1.6em; font-size: .95em; }
.status.err { color: var(--warn); }
.vraag {
  margin-top: 8px; padding: 12px; border: 1px solid var(--accent); border-radius: 10px; background: var(--bg-raised);
}
.vraag label { margin-top: 0; }
.vraag .rij { flex-wrap: wrap; }
.vraag input { max-width: 14ch; }
.col-inst .vraag input { max-width: none; }

/* Result */
.tab { margin-top: 12px; }
table.samen { width: 100%; border-collapse: collapse; font-size: .93em; }
table.samen th { text-align: left; font-family: var(--mono); font-size: 12px; font-weight: 400; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); padding: 14px 0 4px; }
table.samen td { padding: 5px 0; border-bottom: 1px solid var(--line); vertical-align: top; }
table.samen td + td { text-align: right; font-weight: 600; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
.legenda { display: flex; flex-wrap: wrap; gap: 4px 14px; margin: 12px 0 0; padding: 0; list-style: none; font-size: .88em; color: var(--ink-soft); }
.legenda i { display: inline-block; width: 12px; height: 12px; border-radius: 3px; margin-right: 6px; vertical-align: -1px; }
.grafiek { width: 100%; height: auto; display: block; }
.grafiek text { fill: var(--ink-soft); font: 11px var(--mono); }
.grafiek .as { stroke: var(--line); }
.grafiek .staaf { fill: var(--accent); }
.grafiek .gem { stroke: var(--ink); stroke-width: 1.5; }
.grafiek .med { stroke: var(--ink); stroke-width: 1.5; stroke-dasharray: 4 3; }

.foot { padding-bottom: 32px; letter-spacing: .02em; max-width: 100ch; }

@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
