/* One hand-written stylesheet. Colours are custom properties; the practice accent comes from /practice.css.
   System font stack, no web fonts, no third-party requests. Light and dark follow prefers-color-scheme. */
:root {
  color-scheme: light dark;
  --bg: #ffffff;
  --surface: #f2f5f8;
  --text: #14181f;
  --muted: #3b4452;
  --border: #59626f;
  --border-soft: #c3cad4;
  --accent: #0b5c8e;
  --on-accent: #ffffff;
  --focus: #0b5c8e;
  --error: #b3261e;
  --error-bg: #fdeceb;
  --tint: color-mix(in srgb, var(--accent) 12%, var(--bg));
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #10151c;
    --surface: #1a212b;
    --text: #eef1f5;
    --muted: #c3cad4;
    --border: #8b95a3;
    --border-soft: #3a4452;
    --accent: #8cc8f0;
    --on-accent: #10151c;
    --focus: #8cc8f0;
    --error: #ff9b94;
    --error-bg: #3a1f1e;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 18px/1.5 var(--font);
  overflow-wrap: anywhere;
}
[hidden] { display: none !important; }
img, canvas { max-width: 100%; }

.wrap { max-width: 640px; margin: 0 auto; padding: 0 16px; }
main { padding-top: 16px; padding-bottom: 48px; }
main:focus { outline: none; }
h1 { font-size: 28px; line-height: 1.25; margin: 16px 0 16px; }
h2 { font-size: 22px; line-height: 1.3; margin: 0 0 8px; }
p { margin: 0 0 16px; }
a { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }

.skip-link { position: absolute; left: -9999px; top: 8px; background: var(--bg); padding: 12px 16px; z-index: 10; }
.skip-link:focus { left: 16px; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}
.site-header { border-bottom: 1px solid var(--border-soft); padding: 12px 0; }
.site-header .wrap { display: flex; align-items: center; gap: 12px; }
.practice-name { font-size: 20px; font-weight: 700; }
.logo { height: 48px; width: auto; flex: 0 0 auto; }
.noscript { margin: 16px; padding: 12px 16px; border: 2px solid var(--error); border-radius: 8px; }

/* focus */
a:focus-visible, button:focus-visible, .input:focus, input:focus-visible, select:focus, textarea:focus,
fieldset:focus-visible, .error-summary:focus {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* progress */
.progress-block { margin-bottom: 8px; }
.back-link { display: inline-flex; align-items: center; min-height: 44px; font-size: 18px; }
.step-text { margin: 0 0 8px; font-size: 16px; color: var(--muted); font-weight: 600; }
.step-bar { display: block; width: 100%; height: 12px; border: 0; border-radius: 6px; overflow: hidden;
  appearance: none; background: var(--border-soft); color: var(--accent); }
.step-bar::-webkit-progress-bar { background: var(--border-soft); }
.step-bar::-webkit-progress-value { background: var(--accent); }
.step-bar::-moz-progress-bar { background: var(--accent); }

/* fields */
form { margin: 0; }
fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.field { margin-bottom: 24px; }
.field > label, legend, .sig-typed > label {
  display: block; padding: 0; margin: 0 0 6px; font-size: 18px; font-weight: 600;
}
.req { color: var(--text); }
.legend { font-size: 16px; color: var(--muted); }
.hint { margin: 0 0 8px; font-size: 16px; color: var(--muted); }
.input {
  display: block; width: 100%; min-height: 56px; padding: 10px 14px;
  font: inherit; font-size: 20px; color: var(--text); background: var(--bg);
  border: 2px solid var(--border); border-radius: 8px;
}
textarea.input { min-height: 140px; resize: vertical; }
/* Safari draws a native select (appearance: auto) at its own short height and ignores min-height, so the
   select is drawn here like the other inputs, with its arrow made from two gradients in the text colour
   (a gradient can use a custom property, so the arrow follows light and dark). */
select.input {
  appearance: none; -webkit-appearance: none; padding-right: 44px; text-overflow: ellipsis;
  background-image: linear-gradient(45deg, transparent 50%, var(--text) 50%), linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position: calc(100% - 24px) 50%, calc(100% - 17px) 50%;
  background-size: 7px 7px; background-repeat: no-repeat;
}
/* Forced colours (Windows high contrast) removes backgrounds, so give back the browser's own select there. */
@media (forced-colors: active) { select.input { appearance: auto; -webkit-appearance: menulist; padding-right: 14px; } }
.has-error .input { border-color: var(--error); }
.error-text { display: flex; gap: 8px; align-items: flex-start; margin: 8px 0 0; color: var(--error); font-weight: 600; }
.error-icon {
  flex: none; width: 24px; height: 24px; line-height: 20px; text-align: center; font-weight: 800;
  border: 2px solid var(--error); border-radius: 50%; font-size: 15px;
}
.error-summary { margin: 16px 0 24px; padding: 16px; border: 3px solid var(--error); border-radius: 8px; background: var(--error-bg); }
.error-summary h2 { color: var(--text); }
.error-summary ul { margin: 0; padding-left: 20px; }
.error-summary a { color: var(--text); font-weight: 600; }

/* choices */
.choice-list { display: grid; gap: 10px; }
.choice-list.yesno { grid-template-columns: 1fr 1fr; }
.choice {
  display: flex; align-items: center; gap: 12px; min-height: 56px; padding: 12px 16px; cursor: pointer;
  border: 2px solid var(--border); border-radius: 8px; background: var(--bg); font-size: 18px;
}
.choice input { flex: none; width: 24px; height: 24px; margin: 0; accent-color: var(--accent); }
.choice:has(input:checked) { border-color: var(--accent); background: var(--tint); }
.choice:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.choice input:focus-visible { outline: none; }
.has-error .choice { border-color: var(--error); }

/* "Is this still right?": earlier answers shown as a short list, the boxes tucked away until Change */
.is-confirmed { display: none; }
.confirm-card { margin: 0 0 24px; padding: 16px; border: 2px solid var(--border-soft); border-radius: 8px; }
.confirm-card h2 { margin: 0 0 12px; }
.confirm-list { margin: 0 0 12px; }
.confirm-row { margin: 0 0 10px; }
.confirm-row dt { font-size: 16px; font-weight: 600; color: var(--muted); }
.confirm-row dd { margin: 2px 0 0; font-size: 18px; overflow-wrap: anywhere; }

/* rows: one card per entry */
.row-card { margin: 0 0 12px; padding: 12px 16px 16px; border: 2px solid var(--border-soft); border-radius: 8px; }
.row-card > legend { padding: 0 6px; font-size: 16px; font-weight: 600; color: var(--muted); }
.row-card label { display: block; margin: 12px 0 4px; }
.row-card label:first-of-type { margin-top: 4px; }

/* grid: one condition per row, a chip per person */
.grid-item { margin: 0; padding: 12px 0; border: 0; border-top: 1px solid var(--border-soft); }
.grid-item > legend { float: left; width: 100%; margin: 0 0 8px; padding: 0; font-size: 18px; font-weight: 600; }
.grid-item > legend + * { clear: both; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 8px 14px; cursor: pointer;
  border: 2px solid var(--border); border-radius: 22px; background: var(--bg); font-size: 18px;
}
.chip input { width: 22px; height: 22px; margin: 0; accent-color: var(--accent); }
.chip:has(input:checked) { border-color: var(--accent); background: var(--tint); }
.chip:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.chip input:focus-visible { outline: none; }
[data-row-add] { margin-top: 12px; }
.grid > .field { margin: 0; padding: 4px 0 16px; }
.none-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.none-actions .button { width: auto; flex: 1 1 200px; }
/* "None of these" on: filled button with a check mark, and the chips dimmed and locked */
[data-none-on][aria-pressed="true"] { color: var(--on-accent); background: var(--accent); }
[data-none-on][aria-pressed="true"]::before { content: "\2713\00a0"; }
.chip:has(input:disabled), .choice:has(input:disabled) { opacity: 0.55; cursor: not-allowed; border-style: dashed; }
.chip input:disabled, .choice input:disabled { cursor: not-allowed; }

/* dates */
.date-row { display: flex; gap: 12px; }
.date-part label { display: block; margin: 0 0 4px; font-size: 16px; font-weight: 600; color: var(--muted); }
.date-part .input { text-align: center; padding-left: 8px; padding-right: 8px; }
.date-mm, .date-dd { width: 72px; }
.date-yyyy { width: 104px; }

/* worked-out and static text */
.auto-line { margin: 0; padding: 12px 16px; background: var(--surface); border-radius: 8px; }
.auto-label { font-weight: 600; margin-right: 8px; }
.static-heading { margin-top: 8px; }
.static-text { font-size: 18px; }
.note, .notice { margin: 0 0 16px; padding: 12px 16px; border-left: 4px solid var(--accent); background: var(--tint); border-radius: 4px; }

/* signature */
.sig-canvas {
  display: block; width: 100%; height: 200px; background: #ffffff; border: 2px solid var(--border);
  border-radius: 8px; touch-action: none; cursor: crosshair;
}
.sig-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 12px; }
.sig-actions .button { width: auto; flex: 1 1 160px; }
.sig-name { font-family: "Snell Roundhand", "Segoe Script", "Brush Script MT", cursive; font-size: 28px; font-style: italic; }
.sig-typed .button { margin-top: 12px; }
.signature .hint { margin-top: 8px; }

/* buttons */
.button {
  display: block; width: 100%; min-height: 56px; padding: 12px 16px; font: inherit; font-size: 20px; font-weight: 600;
  line-height: 1.25; text-align: center; text-decoration: none; cursor: pointer;
  color: var(--on-accent); background: var(--accent); border: 2px solid var(--accent); border-radius: 8px;
}
.button.secondary { color: var(--accent); background: transparent; }
/* a second Back under Continue, so a patient at the bottom of a long screen need not scroll up (owner, 2026-11-25) */
.back-bottom { margin-top: 12px; }

/* review */
.review-group { margin: 0 0 24px; padding: 16px; border: 2px solid var(--border-soft); border-radius: 8px; }
.review-head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; }
.review-head h2 { margin: 0; }
.edit-link { font-weight: 600; white-space: nowrap; }
.review-list { margin: 12px 0 0; }
.review-row { margin: 0 0 12px; }
.review-row dt { font-weight: 600; }
.review-row dd { margin: 0; }
.review-row.missing dd { color: var(--error); font-weight: 600; }

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

/* card capture */
.photo-status { margin: 0 0 12px; color: var(--muted); }
.photo-status.done { color: var(--text); font-weight: 600; }
.photo-status.done::before { content: "\2713\00a0"; }
.camera, .camera-help { margin-top: 24px; padding: 16px; border: 2px solid var(--border); border-radius: 8px; background: var(--surface); }
.camera h2:focus, .camera-help h2:focus { outline: none; }
.camera-instruction { font-weight: 600; }
/* Always landscape (3:2, VIEW_RATIO in camera-capture.js). The video fills it, cut to fit, whichever way the
   camera sends it. The script sets the outline's exact place, these are the same numbers as a fallback. */
.camera-view { position: relative; overflow: hidden; border-radius: 8px; background: #000; aspect-ratio: 3 / 2; }
.camera-video { position: absolute; inset: 0; display: block; width: 100%; height: 100%; object-fit: cover; }
/* The script paints each frame here, over the video (which keeps playing underneath, as iOS needs). */
.camera-screen { position: absolute; inset: 0; display: block; width: 100%; height: 100%; max-width: none; }
.camera-outline {
  position: absolute; left: 10%; width: 80%; top: 12.17%; height: 75.66%;
  border: 3px solid #ffffff; border-radius: 4%/6%;
  box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);   /* dims everything outside the card outline */
}
.camera-hint { min-height: 1.5em; margin: 12px 0; font-weight: 600; }
.camera-actions { display: flex; flex-wrap: wrap; gap: 12px; }
.camera-actions .button { width: auto; flex: 1 1 160px; }
.camera-preview { display: block; width: 100%; margin-bottom: 12px; border-radius: 8px; }
.camera-message:empty { display: none; }
.camera-message { margin-top: 12px; color: var(--error); font-weight: 600; }
.camera-help form { margin-top: 12px; }
.camera-help h3 { font-size: 18px; margin: 24px 0 0; }
.qr-box { display: inline-block; padding: 16px; margin-bottom: 16px; background: #ffffff; border-radius: 8px; }
.qr { display: block; width: 240px; height: 240px; }
@media (prefers-reduced-motion: reduce) { .camera-video { transition: none; } }
