/* 1-bit: only pure black and pure white. Tones come from patterns, never greys. */
:root {
  --k: #000;
  --w: #fff;
  --sans: "Roboto", ui-sans-serif, -apple-system, BlinkMacSystemFont, "Helvetica Neue", Arial, sans-serif;
  /* Two voices: light (300) for reading, heavy (900) for structure. 400/700 only for data and controls. */
  --light: 300;
  --heavy: 900;
  /* 50% checkerboard and sparse-dot dither patterns */
  --dither-50: repeating-conic-gradient(var(--k) 0 25%, var(--w) 0 50%) 0 0 / 2px 2px;
  --dither-dots: radial-gradient(circle, var(--k) 0.8px, transparent 1px) 0 0 / 6px 6px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: var(--sans);
  color: var(--k);
  background: var(--w);
  font-weight: var(--light);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "tnum" 0;
}
b, strong { font-weight: 700; }
::selection { background: var(--k); color: var(--w); }

/* ---------- Top bar + progress ---------- */
.topbar {
  position: sticky; top: 0; z-index: 10;
  display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px 16px;
  padding: 14px clamp(16px, 4vw, 40px) 0;
  background: var(--w);
  border-bottom: 2px solid var(--k);
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.logo { margin-bottom: 5px; width: 48px; height: 48px; flex: none; object-fit: contain; }
.brand h1 { margin: 0; font-size: 20px; font-weight: var(--heavy); letter-spacing: -.02em; line-height: 1.1; }
.brand p { margin: 2px 0 0; font-size: 14px; font-weight: var(--light); }
.actions { display: flex; gap: 8px; flex: none; }

.progress-row {
  grid-column: 1 / -1;
  display: flex; align-items: center; gap: 12px;
  padding: 2px 0 12px;
}
.progress {
  flex: 1; height: 12px;
  border: 2px solid var(--k);
  background: var(--w);
}
.progress-fill {
  height: 100%; width: 0;
  background: var(--k);
  transition: width .3s steps(12, end);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: inherit; font-size: 14px; font-weight: 700;
  padding: 8px 14px; border-radius: 0;
  border: 2px solid var(--k); background: var(--w); color: var(--k);
  cursor: pointer;
}
.btn:hover, .btn.primary { background: var(--k); color: var(--w); }
.btn.primary:hover { background: var(--w); color: var(--k); }
.btn:active { transform: translate(1px, 1px); }
.btn svg { width: 16px; height: 16px; }
.btn.small { padding: 5px 10px; font-size: 13px; font-weight: 400; }
.btn.add { width: 100%; justify-content: center; border-style: dashed; }
.link {
  font-family: inherit; font-size: 14px; font-weight: 400;
  background: none; border: 0; padding: 2px 0; color: var(--k); cursor: pointer;
  text-decoration: underline; text-underline-offset: 3px;
}
.link:hover { background: var(--k); color: var(--w); text-decoration: none; }
:focus-visible { outline: 2px solid var(--k); outline-offset: 2px; }

/* ---------- Layout ---------- */
.view-switch, .view-bar { display: none; }
/* one line on what the site is, under the top bar */
/* One line on what the site is, over the form: inside the form on wide screens,
   above the Edit / Preview switch on narrow ones. */
.intro { margin: 0; text-align: left; display: flex; align-items: center; gap: 10px; }
.intro > span { flex: 1; }
/* Green pixel QR icon: opens the scanner */
.qr-scan { flex: none; display: grid; place-items: center; padding: 3px; margin: -6px -6px -6px 0; border: 0; background: none; color: #0a7a3a; cursor: pointer; }
.qr-scan svg { display: block; }
.import-bar:hover .qr-scan, .qr-scan:hover, .qr-scan:focus-visible { background: #0a7a3a; color: #eaf7ef; outline: none; }
.import-bar { cursor: pointer; }
.import-bar:hover > span { text-decoration: underline; text-underline-offset: 3px; }
.narrow-intro { display: none; }
/* Pages: one per person, over the intro line, once there is more than one */
.people { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: flex-start; }
.people[hidden], .narrow-people { display: none; }
.person { position: relative; display: block; }
.person-pick { display: grid; justify-items: center; gap: 3px; padding: 5px 7px 3px; border: 1px solid transparent; background: none; color: var(--k); font: inherit; font-size: 12px; cursor: pointer; max-width: 96px; }
.person-pick svg { display: block; }
.person-name { max-width: 80px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.person-pick:hover { border-color: var(--k); }
.person-pick.active { border-color: var(--k); font-weight: 700; cursor: default; }
.person-pick:focus-visible { outline: 2px solid var(--k); outline-offset: 1px; }
/* Trash in the page's top right corner */
.person-del { position: absolute; top: -8px; left: calc(50% + 8px); display: grid; place-items: center; padding: 2px; border: 0; background: var(--w); color: var(--k); cursor: pointer; }
.person-del svg { display: block; }
.person-del:hover, .person-del:focus-visible { background: var(--k); color: var(--w); outline: none; }
.layout {
  display: grid;
  grid-template-columns: minmax(340px, 520px) minmax(0, 1fr);
  gap: clamp(16px, 3vw, 40px);
  max-width: 1400px; margin: 0 auto;
  padding: 24px clamp(16px, 4vw, 40px) 64px;
  align-items: start;
}

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.form-tools { display: flex; justify-content: flex-end; }
/* The intro line looks like the Chill note */
.privacy, .intro {
  font-size: 14px; padding: 10px 12px;
  /* The one deliberate colour: reassurance that data stays local. */
  color: #0a7a3a; background: #eaf7ef; border: 2px solid #0a7a3a;
}
.privacy { display: flex; gap: 8px; align-items: center; margin: 0; }

.card { background: var(--w); }
.name-block { background: var(--w); padding: 16px 16px 18px; }
.field { display: grid; gap: 2px; font-size: 13px; font-weight: var(--light); align-content: start; }
/* Activity: a 1-bit dropdown, closed it looks like the blood group select */
.dd { position: relative; }
.dd-btn {
  width: 100%; text-align: left; font: inherit; font-size: 16px; font-weight: 400; color: var(--k); cursor: pointer;
  background: var(--w) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 10px center / 10px;
  border: 2px solid var(--k); border-radius: 0; padding: 8px 30px 8px 8px;
}
.dd-btn:focus-visible, .dd-btn[aria-expanded=true] { outline: none; box-shadow: 0 0 0 2px var(--k); }
.dd-list {
  position: absolute; z-index: 20; left: 0; right: 0; top: 100%; margin: 4px 0 0; padding: 0; list-style: none;
  background: var(--w); border: 2px solid var(--k); box-shadow: 4px 4px 0 var(--k);
}
.dd-list[hidden] { display: none; }
/* Fields that don't apply stay out of the layout */
[hidden] { display: none !important; }
.dd-list li { padding: 8px 10px; font-size: 16px; font-weight: 400; cursor: pointer; }
.dd-list li[aria-selected=true] { font-weight: 700; }
.dd-list li:hover, .dd-list li:focus { outline: none; background: var(--k); color: var(--w); }
/* Typing suggestions under a text field (embassies) */
label:has(> .suggest) { position: relative; }
.suggest { min-width: 260px; max-height: 260px; overflow-y: auto; }
.suggest li.active { background: var(--k); color: var(--w); }
.suggest .sub { display: block; font-size: 12px; font-weight: var(--light); }
.card summary {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 8px 12px;
  padding: 14px 16px 12px; cursor: pointer; list-style: none; user-select: none;
}
/* Section progress: starts under the heading text and runs to the right edge. */
.sec-bar {
  grid-column: 2 / -1; position: relative; height: 4px;
  background: linear-gradient(var(--k), var(--k)) left center / 100% 1px no-repeat;
}
.sec-fill {
  position: absolute; left: 0; top: 0; bottom: 0; width: 0;
  background: var(--k);
  transition: width .3s steps(8, end);
}
.card summary::-webkit-details-marker { display: none; }
.card summary { border: 2px solid transparent; }
.card summary:focus-visible { border-color: var(--k); outline: none; }
.num { font-size: 32px; font-weight: var(--light); font-variant-numeric: tabular-nums; min-width: 1.4em; line-height: 1; }
.title { flex: 1; font-size: 32px; font-weight: var(--heavy); letter-spacing: -.02em; line-height: 1.1; }
.chev {
  position: relative; width: 36px; height: 36px; flex: none;
  border: 2px solid transparent;
}
.chev::before {
  content: ""; position: absolute; left: 50%; top: 50%;
  width: 12px; height: 12px;
  border-right: 3px solid var(--k); border-bottom: 3px solid var(--k);
  transform: translate(-50%, -70%) rotate(45deg);
}
.card[open] .chev::before { transform: translate(-50%, -30%) rotate(-135deg); }
.chev:hover { border-color: var(--k); }
.card-body { padding: 16px 16px 18px; }

.hint { margin: 0 0 14px; font-size: 14px; }
.hint.after { margin: 12px 0 0; }
.grid > .hint { margin: -4px 0 4px; }
.hint a { color: var(--k); font-weight: 700; text-underline-offset: 3px; }
.hint a:hover { background: var(--k); color: var(--w); text-decoration: none; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.span-2 { grid-column: span 2; }
label {
  display: grid; gap: 2px;
  font-size: 13px; font-weight: var(--light);
}
input[type=text], input[type=tel], input[type=email], input[type=url], select, textarea {
  width: 100%; font-family: inherit; font-size: 16px; font-weight: 400; color: var(--k);
  background: var(--w); border: 0; border-bottom: 2px solid var(--k); border-radius: 0;
  padding: 8px 2px;
}
textarea { resize: vertical; min-height: 40px; field-sizing: content; line-height: 1.4; }
@supports (field-sizing: content) { textarea { resize: none; } }
select { appearance: none; border: 2px solid var(--k); padding: 8px 30px 8px 8px; cursor: pointer;
  background: var(--w) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23000' stroke-width='1.6'/%3E%3C/svg%3E") no-repeat right 10px center / 10px; }
input:focus, textarea:focus, select:focus { outline: none; border-bottom-width: 4px; padding-bottom: 6px; }
select:focus { border-width: 2px; box-shadow: 0 0 0 2px var(--k); padding-bottom: 8px; }
::placeholder { color: var(--k); opacity: 1; font-style: italic; font-weight: var(--light); font-size: 14px; }
input:focus::placeholder, textarea:focus::placeholder { color: transparent; }

.choice { border: 0; padding: 0; margin: 0; display: flex; gap: 18px; align-items: center; }
.choice legend { float: left; margin-right: 6px; font-size: 13px; font-weight: var(--light); }
.choice label { display: flex; align-items: center; gap: 6px; font-size: 16px; font-weight: 400; cursor: pointer; }
.choice input {
  appearance: none; width: 16px; height: 16px; margin: 0;
  border: 2px solid var(--k); background: var(--w); cursor: pointer;
}
.choice input:checked { background: var(--k); box-shadow: inset 0 0 0 2px var(--w); }

/* photo picker */
.photo-field { display: flex; align-items: center; gap: 14px; margin-top: 16px; padding: 6px; margin-left: -6px; border: 2px solid transparent; }
.thumb {
  position: relative; overflow: hidden; flex: none;
  display: grid; place-items: center; text-align: center;
  background: var(--dither-dots), var(--w);
  border: 2px solid var(--k);
  font-size: 12px; font-weight: 700; line-height: 1.25;
  padding: 6px;
}
.thumb span { background: var(--w); padding: 3px 4px; }
.thumb small { display: block; margin-top: 2px; font-size: 11px; font-weight: var(--light); }
.thumb.portrait { width: 88px; height: 112px; }
.thumb.wide { width: 156px; height: 104px; }
.thumb img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
.thumb.has-img img { display: block; }
.thumb.has-img span { visibility: hidden; }
/* Photo buttons all the same size: as wide as the widest, one height with or without an icon */
.photo-actions { display: inline-grid; grid-auto-columns: minmax(0, 1fr); gap: 6px; align-self: flex-start; }
.photo-actions .btn { justify-content: flex-start; height: 30px; }
.photo-actions .btn svg { width: 20px; height: 20px; }
.photo-field:not(.has-img) .remove, .photo-field:not(.has-img) .bw-toggle { display: none; }
/* Black&white stays pressed (inverted) while the print-ready black and white is on */
.photo-actions .bw-toggle[aria-pressed=true] { background: var(--k); color: var(--w); }
/* hover (and a tap on phones, where hover sticks) must not make it look switched */
.photo-actions .bw-toggle[aria-pressed=false]:hover { background: var(--w); color: var(--k); box-shadow: inset 0 0 0 1px var(--k); }
.photo-row { display: flex; flex-wrap: wrap; gap: 8px 18px; align-items: flex-end; margin-top: 16px; }
.photo-row .photo-field { flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 0; }
.photo-row .photo-actions { grid-auto-flow: column; }
/* Narrow: the photo buttons stack in a column to the right of the photo */
.photo-row { container-type: inline-size; }
/* While framing, the Resize slider sits on top of that column and the buttons go under it. */
@container (max-width: 520px) {
  .photo-row .photo-field { display: grid; grid-template-columns: auto auto; justify-content: start; align-items: start; gap: 8px 10px; }
  .photo-row .photo-field .thumb { grid-row: 1 / span 2; }
  .photo-row .photo-field .crop-bar, .photo-row .photo-field .photo-actions { grid-column: 2; }
  .photo-row .photo-field .crop-bar { flex-wrap: wrap; }
  .photo-row .photo-field .recent { grid-column: 1 / -1; }
  .photo-row .photo-actions { grid-auto-flow: row; justify-self: start; }
}
.car-grid { margin-top: 16px; }
/* Location tracking: tracker boxes, then the add button, then the other fields */
.trackers .row + .row { margin-top: 10px; }
.trackers + .btn.add { margin-top: 10px; }
.trackers-rest { margin-top: 16px; }
.row .hint { margin: -4px 0 0; }
.photo-row .thumb.wide { height: 124px; width: auto; aspect-ratio: var(--gear-aspect, 4 / 3); }
.photo-row .thumb.portrait { height: 124px; width: auto; aspect-ratio: 35 / 45; }
.photo-field.dragging { border: 2px dashed var(--k); }
/* Recent photos: small thumbnails under the photo box, × to forget one */
.recent { display: flex; flex-wrap: wrap; gap: 6px; }
.recent[hidden] { display: none; }
.recent-item { position: relative; display: block; }
.recent-pick { display: block; padding: 0; border: 1px solid var(--k); background: var(--w); cursor: pointer; }
.recent-pick img { display: block; height: 36px; width: auto; }
.recent-pick:hover, .recent-pick:focus-visible { outline: 2px solid var(--k); outline-offset: 1px; }
.recent-del { position: absolute; top: -6px; right: -6px; width: 16px; height: 16px; padding: 0; border: 1px solid var(--k); border-radius: 50%; background: var(--w); color: var(--k); font: 700 12px/12px Roboto, sans-serif; cursor: pointer; opacity: 0; }
.recent-item:hover .recent-del, .recent-del:focus-visible { opacity: 1; }
@media (pointer: coarse) { .recent-del { opacity: 1; } }
.recent-del:hover { background: var(--k); color: var(--w); }
.suggest li.hist::before { content: "↺ "; font-weight: var(--light); }
.photo-field.dragging .thumb { background: var(--dither-50); }

/* repeaters */
.repeater { display: grid; gap: 10px; margin-bottom: 10px; }
.repeater:empty { display: none; }
/* Space between the fields above a list (e.g. "Embassy of") and the list or its add button */
.grid + .repeater, .grid + .repeater:empty + .btn.add { margin-top: 16px; }
.row {
  position: relative;
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px 44px 14px 12px;
  border: 2px solid var(--k);
}
.row .wide { grid-column: span 2; }
.row .del {
  position: absolute; top: 6px; right: 6px;
  width: 28px; height: 28px; border: 2px solid var(--k);
  background: var(--w); color: var(--k); font-size: 18px; line-height: 1; cursor: pointer;
}
.row .del:hover { background: var(--k); color: var(--w); }

/* Insurance boxes: fold open and closed like the sections */
.fold { border: 2px solid var(--k); }
.fold > summary {
  position: relative; display: flex; align-items: center; gap: 10px;
  padding: 10px 44px 10px 12px; cursor: pointer; list-style: none; user-select: none;
  font-weight: 700;
}
.fold > summary::-webkit-details-marker { display: none; }
.fold > summary:hover { background: var(--k); color: var(--w); }
.fold > summary:hover .mini-chev::before { border-color: var(--w); }
.sum-name { flex: 1; min-width: 0; }
.sum-name a { color: inherit; text-decoration: none; }
.sum-name a:hover { text-decoration: underline; text-underline-offset: 2px; }
.sum-sub { font-weight: var(--light); margin-left: 6px; }
.mini-chev { position: relative; width: 16px; height: 16px; flex: none; }
.mini-chev::before {
  content: ""; position: absolute; left: 50%; top: 50%; width: 7px; height: 7px;
  border-right: 2px solid var(--k); border-bottom: 2px solid var(--k);
  transform: translate(-50%, -70%) rotate(45deg);
}
.fold[open] .mini-chev::before { transform: translate(-50%, -30%) rotate(-135deg); }
/* Expand all / Collapse all: the text, then a small chevron on the right */
.toggle-all { display: inline-flex; align-items: center; gap: 2px; text-decoration: none; }
.toggle-all .toggle-text { text-decoration: underline; text-underline-offset: 3px; }
.toggle-all.all-open .mini-chev::before { transform: translate(-50%, -30%) rotate(-135deg); }
.fold > summary .del { position: absolute; top: 50%; right: 6px; transform: translateY(-50%); width: 28px; height: 28px; border: 2px solid var(--k); background: var(--w); color: var(--k); font-size: 18px; line-height: 1; cursor: pointer; }
.fold > summary .del:hover { background: var(--k); color: var(--w); border-color: var(--w); }
.row-body { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; padding: 4px 12px 14px; }
.row-body .wide { grid-column: span 2; }

.other-info { display: block; padding: 4px 18px 0; }
.countries-box { display: block; padding: 0; }
.countries-box legend { float: none; display: block; margin: 0 0 14px; padding: 0; font-size: 14px; }
/* A–Z down each column, then on to the next */
/* A–Z left to right, row by row */
.countries { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px 14px; }
.countries label { font-size: 15px; }
.countries .other-emergency { display: block; }
.choice .other-emergency input {
  appearance: none; width: 100%; height: auto; border: 0; border-bottom: 2px solid var(--k); padding: 8px 2px; cursor: text;
}
.choice .other-emergency input:focus { border-bottom-width: 4px; padding-bottom: 6px; }

/* ---------- Document preview ---------- */
.preview-wrap { position: sticky; top: 120px; container-type: inline-size; }
.doc {
  background: var(--w); color: var(--k);
  border: 2px solid var(--k);
  box-shadow: 8px 8px 0 var(--k);
  padding: 22px 26px 20px;
  font-size: 12.5px; line-height: 1.35;
  max-width: 820px; margin: 0 8px 8px auto;
}
.doc-head {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border-bottom: 1px solid var(--k); padding-bottom: 1px; margin-bottom: 10px;
}
.doc-title { display: flex; align-items: center; gap: 10px; }
.doc-title h2 { margin: 0; font-size: 11.5px; font-weight: var(--light); line-height: 1.2; }
.status { margin: 0 0 0 auto; font-size: 11.5px; font-weight: var(--light); line-height: 1.2; text-align: right; white-space: nowrap; }

/* Row 1: name + medical (2/5) | photos + glider (3/5) */
.row1 { display: grid; grid-template-columns: 2fr 3fr; gap: 16px; align-items: start; margin-bottom: 4px; }
.row1 .who { min-width: 0; position: relative; }
/* Small label over the name, tucked into the gap under the top rule so nothing moves */
.row1 .name-label { position: absolute; top: -10px; left: 0; margin: 0; font-size: 11.5px; line-height: 12px; font-weight: var(--light); white-space: nowrap; }
.row1 h3 { margin: 0 0 1px; font-size: 26px; font-weight: var(--heavy); line-height: 1.02; letter-spacing: -.03em; overflow-wrap: anywhere; }
.row1 h3 .nick { font-weight: 400; }
.row1 h3 .born { font-size: 12.5px; font-weight: 400; letter-spacing: 0; white-space: nowrap; }
.row1 h3 { margin-top: 9px; margin-bottom: 8px; } /* a little air under the small name label */
.visual { min-width: 0; container-type: inline-size; }
/* Photos keep their own shapes (equipment 4:3, passport 35:45), so nothing is cut off, and
   together they fill the width of the photo column: height = (width - gap) / (4/3 + 35/45). */
.photos { display: flex; gap: 8px; height: calc((100cqw - 8px) / 2.1111); }
.photos .glider { flex: 1; min-width: 0; height: 100%; object-fit: cover; }
.photos .glider.eq { flex: none; width: auto; aspect-ratio: 4 / 3; }
.photos .portrait { width: auto; aspect-ratio: 35 / 45; height: 100%; flex: none; object-fit: cover; }
.photos .noportrait { width: auto; aspect-ratio: 35 / 45; height: 100%; flex: none; border: 1px solid var(--k); box-sizing: border-box; background: var(--dither-dots), var(--w); margin-left: auto; }
.glider-info { margin-top: 5px; }

.kv { display: grid; grid-template-columns: max-content 1fr; gap: 1px 14px; margin: 0; }
.kv dt { font-size: 11.5px; font-weight: var(--light); padding-top: 1px; }
.kv dd { margin: 0; font-weight: 400; overflow-wrap: anywhere; }

/* Medical values inside the details list */
.bg-val { background: var(--k); color: var(--w); font-weight: 700; padding: 0 5px; }
/* Blood group and allergies boxes share one height */
.med-line .bg-val, .med-line .allergy-box { box-sizing: border-box; height: 17px; display: inline-flex; align-items: center; line-height: 1; }
.med-line .allergy-box { padding: 0 6px; }
.med-line { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: 3px 0 0; }
.bg { display: inline-flex; align-items: center; gap: 4px; }
.drop { width: 10px; height: 13px; fill: var(--k); flex: none; }
.allergy-box { display: inline-flex; gap: 6px; align-items: baseline; margin: 0; padding: 1px 6px; border: 1px solid var(--k); font-weight: 700; }
.allergy-box b { font-size: inherit; font-weight: 700; letter-spacing: 0; }

/* Section headings: heavy type, a short thick underline over a hairline that runs to the edge */
.doc .other-note { margin-top: 12px; }
.doc-foot { margin-top: 12px; font-size: 10px; font-weight: var(--light); line-height: 1.5; text-align: left; }
.doc-foot b { font-weight: 700; }
/* The footer: the QR code (all the info, without photos) above the emergency numbers line */
.doc-foot { display: flex; flex-direction: column; gap: 6px; }
.foot-text { padding-top: 4px; border-top: 1px solid var(--k); }
.qr-box { align-self: flex-end; }
.qr-box:empty { display: none; }
.qr { display: block; }
.qr-link { display: block; cursor: default; }
/* Values on the screen sheet can be edited in place */
.doc .ed { cursor: text; }
.doc .ed a { cursor: text; }
.doc .ed:hover { outline: 1px dashed currentColor; outline-offset: 1px; }
.doc .ed.editing { outline: 2px solid var(--k); outline-offset: 2px; background: var(--w); white-space: pre-wrap; }
@media print { .doc .ed { outline: none !important; } }
.qr-cap { margin: 0; font-size: 7px; font-weight: var(--light); line-height: 1.2; text-align: center; }
.doc-foot .sep { margin: 0 2px; }
.doc-section { margin-top: 12px; break-inside: avoid; }
.doc-section h4 {
  margin: 0 0 5px;
  font-size: 13.5px; font-weight: var(--heavy); letter-spacing: -.01em; line-height: 1.2;
  border-bottom: 1px solid var(--k);
}
.doc-section h4 span { display: inline-block; padding-bottom: 2px; border-bottom: 3px solid var(--k); margin-bottom: -1px; }
.cols { display: grid; grid-template-columns: 2fr 3fr; gap: 0 16px; align-items: start; }
.cols > * { min-width: 0; }
.prose { white-space: pre-wrap; margin: 0; overflow-wrap: anywhere; font-weight: 400; }
.prose + .stay { margin-top: 3px; }

.doc table { width: 100%; border-collapse: collapse; }
.doc th { text-align: left; font-size: 11px; font-weight: var(--light); padding: 1px 8px 1px 0; }
.doc td { border-top: 1px dotted var(--k); padding: 2px 8px 2px 0; font-weight: 400; vertical-align: top; overflow-wrap: anywhere; }
.doc td:first-child { font-weight: 700; }
.doc td .rel { font-weight: 400; margin-left: 4px; }
.doc table.ins td { font-weight: 400; font-size: 11.5px; }
/* A part moves to the next line whole; it only breaks inside if it is longer than the line. */
.doc table.ins .part { display: inline-block; max-width: 100%; vertical-align: top; }
.doc table.ins a[href^="tel:"] { white-space: nowrap; }
.doc table.ins .sep { margin: 0 3px; }
.doc table.ins .prov { font-weight: 700; }
.doc table.small td { font-size: 11.5px; overflow-wrap: break-word; }
.doc table.small a[href^="tel:"] { white-space: nowrap; }
.doc a { color: var(--k); text-decoration: none; }
/* Keep a phone number on one line when text wraps */
.doc a[href^="tel:"], .doc a[href*="wa.me/"], .doc .nowrap { white-space: nowrap; overflow-wrap: normal; }
.doc a:hover { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 2px; }
.pill { display: inline-block; padding: 0 6px; border: 1.5px solid var(--k); font-size: 11.5px; font-weight: 700; line-height: 1.3; }
.pill.yes { background: var(--k); color: var(--w); }
.medevac { margin: 4px 0 0; font-size: 11.5px; font-weight: var(--light); }
.doc .small-val { font-size: 11.5px; font-weight: var(--light); }
.medevac b { display: block; font-weight: inherit; }
.medevac .sep { margin: 0 6px; }
.kv .split { display: flex; justify-content: space-between; gap: 8px; }
.kv dd.full { grid-column: 1 / -1; }
.kv .lbl { font-size: 11.5px; font-weight: var(--light); margin-right: 4px; }

.empty-doc { text-align: center; padding: 60px 20px; }
.empty-doc svg { width: 52px; height: 52px; }
.empty-doc p { margin: 10px auto 0; max-width: 28ch; font-size: 17px; font-weight: var(--light); }

/* ---------- Toast ---------- */
.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 0);
  background: var(--k); color: var(--w); border: 2px solid var(--w); outline: 2px solid var(--k);
  padding: 10px 16px; font-size: 14px; font-weight: 400;
  visibility: hidden; z-index: 20;
}
.toast.show { visibility: visible; }

/* Custom alert, 1-bit */
.dialog.camera { max-width: 720px; width: calc(100vw - 32px); }
.dialog.camera video { display: block; width: 100%; max-height: 70vh; background: var(--k); border: 2px solid var(--k); object-fit: contain; }
.dialog.camera video.mirror { transform: scaleX(-1); }
.dialog.camera .dialog-actions { margin-top: 14px; }
.dialog.scan { max-width: 520px; }
.scan-view { position: relative; }
.scan-frame { position: absolute; inset: 18%; border: 3px solid var(--w); box-shadow: 0 0 0 2px var(--k); pointer-events: none; }
.dialog.scan.no-camera .scan-view, .dialog.scan.no-reader .scan-view { display: none; }
.dialog {
  max-width: 380px; width: calc(100% - 32px); padding: 22px 22px 18px;
  background: var(--w); color: var(--k);
  border: 2px solid var(--k); box-shadow: 8px 8px 0 var(--k); border-radius: 0;
}
.dialog::backdrop { background: radial-gradient(circle, #000 0.8px, transparent 1px) 0 0 / 6px 6px, rgba(255,255,255,.75); }
.dialog p { margin: 0 0 18px; font-size: 17px; font-weight: var(--light); line-height: 1.35; }
.dialog .dialog-note { margin-top: -10px; font-size: 13px; }
.dialog kbd { font-family: inherit; font-weight: var(--heavy); border: 1.5px solid var(--k); padding: 0 5px; white-space: nowrap; }
.dialog.legal { max-width: 460px; }
.dialog-x {
  position: absolute; top: 10px; right: 10px; width: 30px; height: 30px; padding: 0;
  border: 2px solid var(--k); background: var(--w); color: var(--k);
  font: 400 20px/1 var(--sans); cursor: pointer;
}
.dialog-x:hover, .dialog-x:focus-visible { background: var(--k); color: var(--w); outline: none; }
.dialog a { color: var(--k); font-weight: 700; text-underline-offset: 3px; }
.dialog a:hover { background: var(--k); color: var(--w); text-decoration: none; }
.dialog.legal h2 { margin: 0 0 6px; font-size: 18px; font-weight: var(--heavy); }
.dialog.legal p, .dialog.legal li { font-size: 14px; }
.dialog.legal ul { margin: 0 0 18px; padding-left: 18px; font-weight: var(--light); line-height: 1.4; }
.dialog.legal li + li { margin-top: 4px; }
/* the snowy mountain above Clear all data and the footer link */
.editor .scene { justify-self: center; margin-top: 18px; }
.site-foot { margin: 6px 0 0; display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 4px 20px; font-size: 13px; }
.site-foot .link { line-height: normal; } /* the Bug? link lines up with the buttons */
#btn-reset { display: inline-flex; align-items: center; gap: 4px; }
.link-icon { width: 16px; height: 16px; flex: none; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }

/* ---------- Responsive ---------- */
@container (max-width: 600px) {
  .doc { padding: 22px 18px; }
  .row1 { grid-template-columns: 1fr; }
  .kv { grid-template-columns: 1fr; gap: 0; }
  .kv dd { margin-bottom: 6px; }
  .cols { grid-template-columns: 1fr; }
}
/* Wide screens: the form and the preview scroll separately under the fixed top bar */
@media screen and (min-width: 981px) {
  html, body { height: 100%; }
  body { display: flex; flex-direction: column; overflow: hidden; }
  .topbar { position: static; flex: none; }
  .layout { flex: 1; min-height: 0; width: 100%; padding-top: 0; padding-bottom: 0; align-items: stretch; }
  .editor, .preview-wrap { min-height: 0; overflow-y: auto; padding: 24px 6px 64px; align-content: start; }
  .preview-wrap { position: static; }
}
@media screen and (max-width: 980px) {
  .layout { grid-template-columns: minmax(0, 1fr); padding-top: 12px; } /* never wider than the screen */
  .wide-intro { display: none; }
  .narrow-intro { display: flex; margin: 14px clamp(16px, 4vw, 40px) 0; }
  .wide-people { display: none; }
  .narrow-people:not([hidden]) { display: flex; margin: 14px clamp(16px, 4vw, 40px) 0; } /* same side margins as the form below */
  .view-switch { display: grid; grid-template-columns: 1fr 1fr; /* both buttons as wide as the wider one */ margin: 8px auto 0; width: max-content; border: 2px solid var(--k); }
  .view-switch button {
    font-family: inherit; font-size: 14px; font-weight: 700;
    border: 0; background: var(--w); color: var(--k); padding: 8px 22px; cursor: pointer;
  }
  .view-switch button.active { background: var(--k); color: var(--w); }
  /* pixel icons either side of the switch: a form for Edit, the page with its photos for Preview */
  .view-bar { display: flex; justify-content: center; align-items: center; gap: 14px; margin-top: 8px; }
  .view-bar .view-switch { margin: 0; }
  .view-icon { display: grid; place-items: center; padding: 4px; border: 0; background: none; color: var(--k); cursor: pointer; }
  .layout[data-view=edit] .preview-wrap { display: none; }
  .layout[data-view=preview] .editor { display: none; }
  .preview-wrap { position: static; }
  .doc { margin: 0 8px 8px 0; }
}
@media screen and (max-width: 620px) {
  .brand { gap: 8px; }
  .brand h1 { font-size: 17px; }
  .logo { width: 32px; height: 32px; }
  .topbar { padding-top: 10px; }
  .grid, .row, .row-body { grid-template-columns: 1fr; }
  .span-2, .row .wide, .row-body .wide { grid-column: auto; }
}

/* ---------- Print ---------- */
@page { size: A4; margin: 10mm 12mm; }
@media print {
  .topbar, .intro, .people, .view-bar, .view-switch, .editor, .toast, .dialog { display: none !important; }
  .layout { display: block; padding: 0; max-width: none; }
  .layout .preview-wrap { display: block !important; position: static; }
  /* 2mm of slack on the right: edges that land exactly on the printable width
     (photo border, date, section lines) can otherwise be clipped when the PDF is rendered. */
  .doc { box-shadow: none; border: 0; padding: 0 2mm 0 0; margin: 0; max-width: none; font-size: 11px; }
  .noportrait { display: none; }
  /* The sheet fills the A4 page (297mm minus the 10mm top and bottom margins, less 1mm of slack
     so rounding never spills onto a second page); the emergency numbers sit at the bottom. */
  .doc { min-height: 276mm; display: flex; flex-direction: column; }
  .doc > * { flex: none; }
  .doc-foot { margin-top: auto; }
  .doc > :nth-last-child(2) { margin-bottom: 12px; } /* keeps a gap above the footer when the page is full */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}

/* A clicked photo box is the paste target. */
.thumb { cursor: pointer; }
.thumb:focus { outline: none; }
.thumb:focus-visible, .thumb:focus { box-shadow: 0 0 0 2px var(--w), 0 0 0 4px var(--k); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.embassy { margin: 0 0 3px; font-weight: 400; }
.demo-note { margin: 0; padding: 10px 12px; border: 2px dashed var(--k); font-size: 14px; font-weight: 700; }
.demo-note a { color: var(--k); margin-left: 6px; font-weight: 400; }

/* Photo framing tool: the whole image shows faintly around the frame; only the framed part is kept. */
.thumb.editing { overflow: visible; z-index: 30; cursor: grab; touch-action: none; }
.thumb.editing:active { cursor: grabbing; }
.thumb.editing > img { visibility: hidden; }
.crop-ghost, .crop-clip { position: absolute; inset: 0; pointer-events: none; }
.crop-clip { overflow: hidden; }
.crop-ghost img, .crop-clip img {
  position: absolute; right: auto; bottom: auto; max-width: none;
  display: block; object-fit: fill;
}
.crop-ghost img { opacity: .3; }
.crop-bar { display: flex; align-items: center; gap: 8px; position: relative; z-index: 31; background: var(--w); }
.crop-size { display: flex; align-items: center; gap: 6px; font-size: 13px; font-weight: var(--light); }
.crop-bar input[type=range] { width: 110px; accent-color: var(--k); }
.thumb.editing { background: var(--w); }
.med-note { margin-top: 2px; font-weight: 400; }

/* Header buttons: shorter copy label on phones */
@media (max-width: 680px) { .long { display: none; } }
/* Narrow phones: no heading, a shorter line */
.narrow-only { display: none; }
@media screen and (max-width: 519px) {
  .brand h1, .wide-only { display: none; }
  .narrow-only { display: inline; white-space: nowrap; }
  /* room for the short line next to the two buttons */
  .topbar { column-gap: 10px; }
  .brand { gap: 6px; }
  .brand p { font-size: 13px; }
  .actions .btn { padding-left: 10px; padding-right: 10px; }
  /* slimmer progress bar, closer to the header */
  .topbar { row-gap: 8px; }
  .progress-row { padding: 0 0 8px; }
  .progress { height: 8px; }
}
@media screen and (max-width: 359px) { .narrow-only { white-space: normal; } }
/* Narrow phones: a small heading takes the big one's place */
@media screen and (max-width: 519px) {
  .brand .mini-head { display: block; margin: 0; font-weight: 700; }
  /* heart and "Takes 5-10 min." sit on the bottom edge of the buttons */
  .topbar { align-items: end; }
  .brand { align-items: flex-end; }
  .brand .logo { margin-bottom: 0; }
  .brand p { line-height: 1.2; }
  /* bigger touch targets for the photo buttons */
  .photo-actions .btn { height: 40px; padding: 0 8px; white-space: nowrap; }
  .brand .mini-head + p { margin-top: 0; }
}
/* Header-less tables: first row needs no top rule */
.doc table:not(:has(thead)) tr:first-child td { border-top: 0; }
