/* Layout: survey-sheet. Masthead + topic tabs, then a drawing "stage" with a
   control panel pinned beside it, like a plan sheet with its legend column. */
:root {
  --bg: #eceeeb;
  --surface: #f7f8f6;
  --ink: #1b2125;
  --muted: #5d666b;
  --line: #cfd4d2;
  --stage: #dfe3e1;
  --ground: #cdd3cb;
  --photo: #2a56c6;
  --sketch: #0e7c64;
  --select: #2a56c6;
  --focus: #2a56c6;
  --danger: #b3261e;

  --heat-0: #f3e3a0;
  --heat-1: #f0b256;
  --heat-2: #e07033;
  --heat-3: #b8322a;
  --heat-4: #6e1423;

  --font-display: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-body: "Schibsted Grotesk", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;

  --step--1: 0.8125rem;
  --step-0: 0.9375rem;
  --step-1: 1.125rem;
  --step-2: 1.5rem;
  --step-3: clamp(1.9rem, 1.3rem + 2.6vw, 3.1rem);

  --radius: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121618;
    --surface: #1a1f22;
    --ink: #e5e9e9;
    --muted: #98a2a6;
    --line: #2d3539;
    --stage: #1d2326;
    --ground: #2a312f;
    --photo: #7397f3;
    --sketch: #3cc19f;
    --select: #7397f3;
    --focus: #7397f3;
    --danger: #f2b8b5;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121618;
  --surface: #1a1f22;
  --ink: #e5e9e9;
  --muted: #98a2a6;
  --line: #2d3539;
  --stage: #1d2326;
  --ground: #2a312f;
  --photo: #7397f3;
  --sketch: #3cc19f;
  --select: #7397f3;
  --focus: #7397f3;
  --danger: #f2b8b5;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: var(--step-0);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
img { max-width: 100%; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.page {
  max-width: 1440px;
  margin: 0 auto;
  padding-inline: clamp(16px, 3vw, 40px);
  padding-block: clamp(20px, 3vw, 36px) 48px;
  display: grid;
  gap: 28px;
}

/* Masthead */
.masthead {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: end;
  gap: 24px 48px;
  padding-bottom: 24px;
  border-bottom: 1px solid var(--ink);
}
.masthead__id { min-width: 0; max-width: 46rem; }
.eyebrow, .label {
  font-family: var(--font-mono);
  font-size: var(--step--1);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0;
}
h1 {
  font-family: var(--font-display);
  font-size: var(--step-3);
  font-weight: 700;
  line-height: 1.02;
  letter-spacing: -0.02em;
  margin: 10px 0 12px;
  text-wrap: balance;
}
h1 .arrow { font-weight: 400; color: var(--muted); }
.lede { margin: 0; color: var(--muted); max-width: 60ch; }
.facts {
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 4px 28px;
  margin: 0;
}
.facts div { display: grid; gap: 2px; }
.facts dt { font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.facts dd { margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; }

/* Topic tabs */
.topics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
}
.topic {
  display: flex;
  gap: 12px;
  align-items: baseline;
  padding: 12px 16px;
  text-decoration: none;
  color: inherit;
  border-right: 1px solid var(--line);
  min-width: 0;
}
.topic:last-child { border-right: 0; }
.topic__no { font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); }
.topic__name { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topic.is-active { background: var(--ink); color: var(--bg); }
.topic.is-active .topic__no { color: inherit; opacity: 0.7; }
.topic.is-pending .topic__name { color: var(--muted); font-weight: 400; }
a.topic:not(.is-active):hover { background: var(--surface); }
.topic__wip, .wip-tag {
  font-family: var(--font-mono); font-size: 0.68rem; font-weight: 500; letter-spacing: 0.06em; text-transform: uppercase;
  border: 1px solid currentColor; border-radius: 3px; padding: 0 5px; margin-left: auto; opacity: 0.75; align-self: center;
}
.wip-tag { margin-left: 8px; vertical-align: 0.3em; color: var(--muted); }

/* Section */
.topic-body { display: grid; gap: 20px; }
.topic-body[hidden] { display: none; }

/* Topic 04: the blob diagram mounts in its own shadow root (js/blob-diagram.js) */
.blob-host {
  position: relative; height: min(900px, calc(100vh - 32px)); min-height: 620px;
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; background: var(--bg);
}
.blob-loading { position: absolute; inset: 0; margin: 0; display: flex; gap: 10px; align-items: center; justify-content: center; color: var(--muted); }
@media (max-width: 860px) { .blob-host { height: auto; min-height: 0; } .blob-loading { position: static; padding: 40px 16px; } }
/* Topic 03: the commuter simulation (js/commuters.js) reuses the host frame; it stacks into a scrolling page below 900 px */
@media (max-width: 900px) { .commuter-host { height: auto; min-height: 0; } .commuter-host .blob-loading { position: static; padding: 40px 16px; } }
.section-head { display: flex; flex-wrap: wrap; gap: 8px 40px; align-items: baseline; }
.section-head h2 { font-size: var(--step-2); margin: 0; letter-spacing: -0.01em; }
.section-head p { margin: 0; color: var(--muted); max-width: 70ch; flex: 1 1 28rem; }

/* Viewer */
.viewer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--surface);
  min-height: 640px;
}
.stage {
  position: relative;
  background: var(--stage);
  min-height: 420px;
}
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.stage__loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 12px;
  font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted);
  background: var(--stage);
}
.spinner {
  width: 18px; height: 18px; border-radius: 50%;
  border: 2px solid var(--line); border-top-color: var(--ink);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.stage__tag {
  position: absolute; left: 16px; top: 14px;
  font-family: var(--font-mono); font-size: var(--step--1);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 4px;
  padding: 4px 8px;
  pointer-events: none;
}
.stage__cam { position: absolute; right: 12px; bottom: 12px; display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  font: inherit; font-size: var(--step--1);
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; cursor: pointer;
}
.chip:hover { border-color: var(--ink); }
.chip.is-on { background: var(--ink); color: var(--surface); border-color: var(--ink); }
.tooltip {
  position: absolute; pointer-events: none;
  background: var(--ink); color: var(--bg);
  font-size: var(--step--1); padding: 4px 8px; border-radius: 4px;
  transform: translate(12px, -50%);
  white-space: nowrap;
}

/* Panel */
.panel {
  border-left: 1px solid var(--line);
  display: flex; flex-direction: column;
  max-height: 760px;
  overflow-y: auto;
  min-width: 0;
}
.block { border: 0; margin: 0; padding: 16px 18px; border-bottom: 1px solid var(--line); min-width: 0; }
.block:last-child { border-bottom: 0; }
fieldset.block { display: grid; gap: 8px; }
legend.label { padding: 0; float: left; width: 100%; margin-bottom: 8px; }
p.label { margin-bottom: 10px; }

.segmented { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.segmented button {
  font: inherit; font-weight: 600; font-size: var(--step--1);
  background: transparent; color: var(--ink); border: 0; border-right: 1px solid var(--line);
  padding: 8px 6px; cursor: pointer; display: grid; gap: 1px; text-align: center; line-height: 1.25;
}
.segmented button:last-child { border-right: 0; }
.segmented small { font-family: var(--font-mono); font-weight: 400; color: var(--muted); font-size: 0.75rem; }
.segmented button[aria-checked="true"] { background: var(--ink); color: var(--surface); }
.segmented button[aria-checked="true"] small { color: inherit; opacity: 0.75; }

.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle input { margin: 0; accent-color: var(--ink); }
.glyph { width: 12px; height: 12px; flex: none; }
.glyph--photo { border-radius: 50%; background: var(--photo); }
.glyph--sketch { background: var(--sketch); transform: rotate(45deg) scale(0.85); }
.glyph--heat { border-radius: 2px; background: linear-gradient(90deg, var(--heat-0), var(--heat-2), var(--heat-4)); }

.heat { display: grid; gap: 6px; margin-top: 6px; padding-left: 22px; }
.select-row { display: flex; align-items: center; gap: 8px; font-size: var(--step--1); color: var(--muted); }
.select-row select { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 3px 6px; }
.ramp { height: 10px; border-radius: 2px; background: linear-gradient(90deg, var(--heat-0), var(--heat-1), var(--heat-2), var(--heat-3), var(--heat-4)); }
.ramp__scale { display: flex; justify-content: space-between; font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); font-variant-numeric: tabular-nums; }
.hint { margin: 0; font-size: var(--step--1); color: var(--muted); }

.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat { display: grid; gap: 0; }
.stat b { font-family: var(--font-mono); font-size: var(--step-1); font-weight: 500; font-variant-numeric: tabular-nums; }
.stat span { font-size: 0.75rem; color: var(--muted); }

.detail h3 { margin: 0 0 4px; font-size: var(--step-1); line-height: 1.3; }
.detail .meta { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); margin: 0 0 10px; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.detail p { margin: 0 0 10px; }
.detail figure { margin: 0 0 10px; }
.detail figure img { display: block; width: 100%; border-radius: 4px; }
.placeholder {
  aspect-ratio: 4 / 3; max-width: 100%;
  border: 1px solid var(--line); border-radius: 4px;
  background: repeating-linear-gradient(135deg, transparent 0 9px, var(--line) 9px 10px);
  display: flex; align-items: center; justify-content: center;
  font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted);
}
.placeholder span { background: var(--surface); padding: 4px 8px; border-radius: 3px; }
.kv { display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; margin: 0 0 12px; font-size: var(--step--1); }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-family: var(--font-mono); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; padding: 0; list-style: none; }
.chips button { font-family: var(--font-mono); font-size: 0.75rem; background: transparent; color: var(--ink); border: 1px solid var(--line); border-radius: 3px; padding: 2px 6px; cursor: pointer; }
.chips button:hover { border-color: var(--select); color: var(--select); }
.btn {
  font: inherit; font-size: var(--step--1); font-weight: 600;
  background: var(--ink); color: var(--surface); border: 0; border-radius: 4px;
  padding: 7px 12px; cursor: pointer;
}
.snippet { width: 100%; min-height: 9rem; margin-top: 8px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--ink); background: var(--bg); border: 1px solid var(--line); border-radius: 4px; padding: 8px; resize: vertical; }

.records { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.records button {
  width: 100%; display: grid; grid-template-columns: 12px auto minmax(0, 1fr) auto; gap: 10px; align-items: center;
  font: inherit; font-size: var(--step--1); text-align: left; color: var(--ink);
  background: transparent; border: 0; border-radius: 4px; padding: 6px 6px; cursor: pointer;
}
.records button:hover, .records button[aria-current="true"] { background: var(--bg); }
.records .rid { font-family: var(--font-mono); color: var(--muted); }
.records .rtitle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.records .rcount { font-family: var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.records .empty { color: var(--muted); font-size: var(--step--1); padding: 4px 0; }

.sample-note { margin: 0; font-size: var(--step--1); color: var(--muted); }
.section-head--spaced { margin-top: 28px; }

/* Site context viewer */
.viewer--context .stage { background: var(--stage); }
.labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.stop-label {
  position: absolute; transform: translate(-50%, calc(-100% - 10px));
  background: var(--surface); color: var(--ink); border: 1px solid var(--ink);
  font-size: 0.72rem; line-height: 1.25; padding: 2px 6px; border-radius: 3px; white-space: nowrap;
}
.stop-label b { font-family: var(--font-mono); font-weight: 500; }
.stop-label--site { background: var(--ink); color: var(--surface); }
.north { position: absolute; right: 16px; top: 14px; width: 46px; height: 46px; overflow: visible; }
.north__ring { fill: var(--surface); stroke: var(--line); }
.north__arrow { fill: var(--ink); }
.north__n { font-family: var(--font-mono); font-size: 9px; fill: var(--ink); }
.chips-row { display: flex; flex-wrap: wrap; gap: 6px; }
.select-row input[type="date"] { font: inherit; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 2px 6px; }
.time-row { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 10px; align-items: center; }
.time-row input[type="range"] { width: 100%; accent-color: var(--ink); }
.time-row output { font-family: var(--font-mono); font-variant-numeric: tabular-nums; min-width: 3.2em; text-align: right; }
.play {
  width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--ink);
  background: var(--surface); color: var(--ink); cursor: pointer; font-size: 0.7rem; line-height: 1;
}
.play[aria-pressed="true"] { background: var(--ink); color: var(--surface); }
.kv--sun { margin: 4px 0 0; grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr); }
.glyph--line { height: 4px; border-radius: 2px; background: linear-gradient(90deg, #d20010 0 33%, #6db463 33% 66%, #2d6e8c 66%); }
.glyph--box { background: var(--surface); border: 1.5px solid var(--ink); }
.glyph--contour { border-radius: 50%; border: 1.5px solid var(--muted); box-shadow: inset 0 0 0 2.5px var(--surface), inset 0 0 0 4px var(--muted); }
.glyph--tree { border-radius: 50%; background: var(--muted); }
.glyph--fence { height: 8px; background: repeating-linear-gradient(90deg, var(--ink) 0 2px, var(--muted) 2px 7px); }
.glyph--bench { height: 7px; border-top: 2px solid var(--ink); border-left: 2px solid var(--ink); border-right: 2px solid var(--ink); }
.glyph--person { width: 8px; height: 12px; border-radius: 4px 4px 2px 2px; background: radial-gradient(circle at 50% 22%, var(--ink) 0 2.5px, transparent 3px), linear-gradient(var(--ink), var(--ink)) 50% 100% / 6px 6px no-repeat; }
.glyph--sun { border-radius: 50%; border: 1.5px dashed var(--ink); }
.lines, .stops { list-style: none; margin: 0; padding: 0; display: grid; gap: 2px; }
.lines li {
  display: grid; grid-template-columns: 2.6em minmax(0, 1fr); gap: 10px; align-items: center;
  padding: 4px 6px; border-radius: 4px; font-size: var(--step--1); cursor: default;
}
.lines li:hover, .lines li.is-hot { background: var(--bg); }
.line-badge {
  font-family: var(--font-mono); font-weight: 500; font-size: 0.75rem; text-align: center;
  color: #fff; border-radius: 3px; padding: 1px 0; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25);
}
.line-ends { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.stops li { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; padding: 4px 6px; font-size: var(--step--1); }
.stops .dist { font-family: var(--font-mono); color: var(--muted); font-variant-numeric: tabular-nums; }
.stops .on { grid-column: 1 / -1; color: var(--muted); font-size: 0.75rem; }
code { font-family: var(--font-mono); font-size: 0.92em; }

.howto { border-top: 1px solid var(--line); padding-top: 12px; }
.howto summary { cursor: pointer; font-weight: 600; }
.howto__body { max-width: 72ch; }
.howto__body p { color: var(--muted); }
.howto pre { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 4px; padding: 12px 14px; font-size: var(--step--1); line-height: 1.45; }

.foot { border-top: 1px solid var(--line); padding-top: 14px; font-size: var(--step--1); color: var(--muted); }
.foot p { margin: 0; }

@media (max-width: 960px) {
  .viewer { grid-template-columns: 1fr; min-height: 0; }
  .stage { height: 62vh; min-height: 360px; }
  .panel { border-left: 0; border-top: 1px solid var(--line); max-height: none; }
  .topics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .topic:nth-child(2) { border-right: 0; }
  .topic:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
}
@media (max-width: 480px) {
  .facts { grid-template-columns: repeat(2, auto); }
}
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
}

.stage__tag--level { top: 50px; }

/* Gallery of survey photos and sketches (js/survey.js) */
.gallery-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; margin: 14px 0 12px; }
.gallery-bar .chip { display: inline-flex; align-items: center; gap: 7px; }
.gallery-bar .chip .glyph { width: 9px; height: 9px; }
.gallery-count { margin: 0 0 0 auto; font-family: var(--font-mono); font-size: var(--step--1); color: var(--muted); font-variant-numeric: tabular-nums; }
.gallery { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 210px), 1fr)); gap: 14px; }
.gallery__empty { grid-column: 1 / -1; color: var(--muted); font-size: var(--step--1); padding: 18px 0; }
.card {
  width: 100%; height: 100%; display: grid; grid-template-rows: auto auto auto 1fr; gap: 4px; align-content: start;
  font: inherit; text-align: left; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 8px 10px; cursor: pointer;
}
.card:hover { border-color: var(--ink); }
.card:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.card[aria-current="true"] { border-color: var(--select); box-shadow: 0 0 0 1px var(--select); }
.card__img { display: block; aspect-ratio: 4 / 3; border-radius: 4px; overflow: hidden; background: var(--bg); margin-bottom: 4px; }
.card__img img { display: block; width: 100%; height: 100%; object-fit: cover; }
.card__img.placeholder { border: 0; display: flex; align-items: center; justify-content: center; background: repeating-linear-gradient(135deg, var(--bg) 0 9px, var(--line) 9px 10px); }
.gallery__wait { background: var(--surface); padding: 3px 7px; border-radius: 3px; font-family: var(--font-mono); font-size: 0.72rem; color: var(--muted); text-align: center; max-width: 90%; overflow-wrap: anywhere; }
.card__meta { display: flex; align-items: center; gap: 8px; font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); }
.card__meta .glyph { width: 9px; height: 9px; }
.card__meta .rid { color: var(--ink); }
.card__title { font-weight: 600; font-size: var(--step--1); line-height: 1.35; }
.card__sub { font-size: 0.75rem; color: var(--muted); }

.lightbox {
  width: min(1100px, calc(100vw - 32px)); max-height: calc(100vh - 32px); padding: 0;
  border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--ink);
  display: none; grid-template-columns: minmax(0, 1fr) 300px; overflow: hidden;
}
.lightbox[open] { display: grid; }
.lightbox::backdrop { background: rgba(10, 14, 16, 0.72); }
.lightbox__media { background: var(--stage); display: flex; align-items: center; justify-content: center; min-height: 0; }
.lightbox__media img { display: block; max-width: 100%; max-height: calc(100vh - 34px); object-fit: contain; }
.lightbox__media .placeholder { width: 100%; height: 100%; min-height: 320px; border: 0; border-radius: 0; }
.lightbox__text { padding: 18px 18px 16px; display: flex; flex-direction: column; gap: 6px; overflow-y: auto; }
.lightbox__text h3 { margin: 0; font-size: var(--step-1); line-height: 1.3; text-wrap: balance; }
.lightbox__text .meta { font-family: var(--font-mono); font-size: 0.75rem; color: var(--muted); margin: 0; display: flex; flex-wrap: wrap; gap: 4px 12px; }
.lightbox__text p { margin: 0; }
.lightbox__actions { margin-top: auto; padding-top: 12px; display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
@media (max-width: 760px) {
  .lightbox { grid-template-columns: 1fr; overflow-y: auto; }
  .lightbox__media img { max-height: 60vh; }
  .gallery-count { margin-left: 0; flex-basis: 100%; }
}
/* Editor page (records.js live store): forms, uploads, placing */
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 4px 0 10px; }
.btn.is-on { background: var(--select); }
.btn--quiet { background: transparent; color: var(--ink); border: 1px solid var(--line); }
.btn--quiet.is-on { background: var(--select); color: var(--surface); border-color: var(--select); }
label.btn { display: inline-flex; align-items: center; }
.linkbtn { font: inherit; font-size: var(--step--1); background: none; border: 0; padding: 4px 2px; color: var(--muted); cursor: pointer; text-decoration: underline; text-underline-offset: 2px; }
.danger { color: var(--danger); }
.ed-status { min-height: 1.2em; }
.ed-status.is-error { color: var(--danger); }
.form { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0 0 10px; }
.form--pos { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.form label, .doc label { display: grid; gap: 2px; font-size: 0.75rem; color: var(--muted); min-width: 0; }
.form .wide { grid-column: 1 / -1; }
.form input, .form select, .form textarea, .doc input {
  font: inherit; font-size: var(--step--1); color: var(--ink); background: var(--surface);
  border: 1px solid var(--line); border-radius: 4px; padding: 4px 6px; width: 100%; min-width: 0;
}
.form textarea { resize: vertical; }
.docs { display: grid; gap: 8px; margin: 6px 0 12px; }
.doc { display: grid; grid-template-columns: 64px minmax(0, 1fr) 64px; gap: 4px 8px; align-items: end; }
.doc__img { grid-row: span 2; width: 64px; height: 64px; border-radius: 4px; overflow: hidden; background: var(--bg); }
.doc__img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.doc .linkbtn { grid-column: 2 / -1; justify-self: start; padding: 0; }
.upload { justify-self: start; }
.thumbs { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 10px; }
.thumbs button { padding: 0; border: 1px solid var(--line); border-radius: 3px; background: none; cursor: pointer; width: 54px; height: 54px; overflow: hidden; }
.thumbs img, .thumbs .pdf { width: 100%; height: 100%; object-fit: cover; display: block; }
.pdf { display: flex; align-items: center; justify-content: center; text-align: center; font-family: var(--font-mono); font-size: 0.72rem; color: var(--ink); background: var(--bg); padding: 6px; height: 100%; text-decoration: none; }
.card__img { position: relative; }
.card__tags { position: absolute; left: 6px; top: 6px; display: flex; gap: 4px; flex-wrap: wrap; }
.card__tags span { font-family: var(--font-mono); font-size: 0.68rem; background: var(--ink); color: var(--surface); border-radius: 3px; padding: 1px 6px; }
.gallery.is-drop { outline: 2px dashed var(--select); outline-offset: 6px; border-radius: var(--radius); }
.stage.is-placing canvas { cursor: crosshair; }
.records__head { font-family: var(--font-mono); font-size: 0.75rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); padding: 10px 6px 2px; }
#lb-thumbs .thumbs { margin: 4px 0 0; }