/* © 2026 Artivicolab. All rights reserved. ProxForm — proprietary software. See LICENSE. */
/* ProxForm — base styles. Light + dark via [data-theme]. */

:root {
  --bg: #fff8e7;
  --surface: #ffffff;
  --surface-2: #fff1c4;
  --border: #1a1a1a;
  --text: #0f0f0f;
  /* No gray anywhere — secondary text is the same ink as body text.
     Hierarchy comes from weight/size/placement, not from washed-out gray. */
  --muted: #0f0f0f;
  --primary: #e30613;
  --primary-ink: #ffffff;
  --primary-hover: #b8040f;
  --primary-dark: #8a0309;
  --primary-light: #ff2d3a;
  --accent: #fcd116;
  --stitch: #fcd116;
  --danger: #8a0309;
  --shadow: 2px 2px 0 rgba(15, 15, 15, 0.95);
  --radius: 6px;
}

/* Dark mode is intentionally black-and-white for the UI — no pink/coral.
   The only colour is the yellow accent on filled elements (badges, flow
   cards, the onboarding hint, the GDPR pitch card). "Primary" is therefore
   a bright cream, so links / emphasis / buttons read as clean white-on-
   black instead of vibrating red. */
html[data-theme="dark"] {
  --bg: #14110a;
  --surface: #1f1a10;
  --surface-2: #2a221a;
  --border: #4d4636;          /* neutral warm-gray frame, no yellow glare */
  --text: #f4ecd6;
  --muted: #f4ecd6;           /* same as text — no gray, dark mode is B&W */
  --primary: #f6efda;         /* emphasis = bright cream, not red */
  --primary-ink: #14110a;     /* dark text on the cream "primary" buttons */
  --primary-hover: #ffffff;
  --primary-dark: #cabf9f;
  --primary-light: #ffffff;
  --accent: #e8c34a;          /* the one colour kept — yellow fills */
  --stitch: #e8c34a;
  --danger: #d9745f;          /* restrained terracotta, destructive only */
  --shadow: 2px 2px 0 rgba(232, 195, 74, 0.28);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

/* Sticky footer: body fills the viewport, main grows, footer hugs the bottom
   so a short page doesn't leave the footer floating mid-screen. */
body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}
body > main { flex: 1 0 auto; }
body > .footer { flex-shrink: 0; margin-top: auto; }

/* Custom scrollbar — pop-art red thumb on a cream track with a black ink
   border. Firefox uses the two CSS properties; Chromium/Safari uses the
   ::-webkit pseudo-elements. */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--primary) var(--surface-2);
}
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track {
  background: var(--surface-2);
  border-left: 1.5px solid #0f0f0f;
}
::-webkit-scrollbar-thumb {
  background: var(--primary);
  border: 2px solid #0f0f0f;
  border-radius: 999px;
  background-image: radial-gradient(circle, rgba(0, 0, 0, 0.18) 1.1px, transparent 1.4px);
  background-size: 6px 6px;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--primary-hover); }
::-webkit-scrollbar-thumb:active { background-color: var(--primary-dark); }
::-webkit-scrollbar-corner { background: var(--surface-2); }
html[data-theme="dark"] ::-webkit-scrollbar-track {
  border-left-color: var(--accent);
}
html[data-theme="dark"] ::-webkit-scrollbar-thumb {
  border-color: var(--accent);
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5em; }
h1 { font-size: 1.7rem; }
h2 { font-size: 1.3rem; }
h3 { font-size: 1.05rem; }

p { margin: 0 0 1em; }

.muted { color: var(--muted); }
.hidden { display: none !important; }
.error { color: var(--danger); }
.req { color: var(--danger); }

/* ── Topbar ─────────────────────────────────────────────────────────── */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  font-weight: 700;
  font-size: 1.15rem;
  color: var(--text);
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 26px;
  height: 26px;
  display: block;
  flex-shrink: 0;
}

.topbar-actions { display: flex; align-items: center; gap: 0.75rem; }

.topnav {
  display: flex; align-items: center; gap: 0.5rem;
  margin-left: 1.25rem; flex: 1;
}
.topnav a {
  color: var(--text);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.4rem 0.7rem;
  border-radius: 8px;
}
.topnav a:hover { background: var(--surface-2); text-decoration: none; color: var(--primary); }
.topnav a:target,
.topnav a.active { color: var(--primary); }

/* Hamburger button — injected by theme.js, only shown on mobile. */
.nav-toggle {
  display: none;
  background: var(--surface);
  border: 2px solid var(--ink, #111);
  border-radius: 8px;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0.3rem 0.6rem;
  cursor: pointer;
  color: var(--text);
}

@media (max-width: 640px) {
  /* Anchor the dropdown to the bar. The bar itself stays a clean single
     row: brand on the left, then net-status + theme, hamburger far right. */
  .topbar { position: relative; }
  .brand { margin-right: auto; }            /* push the rest to the right */
  .topbar-actions { order: 4; }
  .nav-toggle {
    display: inline-flex;
    align-items: center;
    order: 5;                               /* hamburger is the rightmost item */
    margin-left: 0.6rem;
  }

  /* Nav is an absolute dropdown PANEL that drops below the bar and overlays
     the page content — it does NOT push the bar's layout around (that was
     the bug: flex-wrap made it render inline). */
  .topnav {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border-bottom: 2px solid var(--ink, #111);
    box-shadow: 0 10px 22px rgba(0, 0, 0, 0.14);
    margin: 0;
    padding: 0 1.25rem;        /* rows handle their own vertical padding */
    gap: 0;
    z-index: 300;
  }
  .topbar.nav-open .topnav { display: flex; }
  /* Flat, edge-to-edge rows — no per-item rounding, no chip look. A hairline
     divider sits between rows (not around them) and the active route gets a
     left accent bar instead of a box outline. */
  .topnav a {
    padding: 0.95rem 0.4rem;
    border-radius: 0;
    border: 0;
    border-left: 3px solid transparent;
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text);
  }
  .topnav a + a { border-top: 1px solid var(--border); }
  .topnav a:hover { background: var(--surface-2); }
  .topnav a:target,
  .topnav a.active {
    color: var(--primary);
    border-left-color: var(--primary);
    background: var(--surface-2);
  }

  /* De-clutter the action cluster on a phone — the conn-status pill and
     the redundant "Build a form" text button just crowd the bar; the nav
     dropdown already has Build. Net-status + theme stay (quick glances). */
  .topbar-actions .conn-status,
  .topbar-actions .text-btn { display: none; }
}

.conn-status {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
}

.net-status {
  font-size: 0.8rem;
  padding: 0.2rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  cursor: help;
  white-space: nowrap;
}
.net-status.net-checking { color: var(--muted); }
.net-status.net-ok       { color: var(--primary); border-color: var(--primary); }
.net-status.net-limited  { color: #b07a00; border-color: #d6a64a; background: #fff7e0; }
.net-status.net-blocked,
.net-status.net-unsupported { color: var(--danger); border-color: var(--danger); background: #fde6e6; }
html[data-theme="dark"] .net-status.net-limited  { background: #3a2e10; color: #f0c97a; border-color: #6b5524; }
html[data-theme="dark"] .net-status.net-blocked,
html[data-theme="dark"] .net-status.net-unsupported { background: #3a1818; }

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
  width: 2rem; height: 2rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 0.95rem;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:disabled { opacity: 0.3; cursor: default; }

.text-btn {
  color: var(--text);
  padding: 0.4rem 0.75rem;
  border-radius: 8px;
  font-weight: 500;
}
.text-btn:hover { background: var(--surface-2); text-decoration: none; }

/* ── Buttons ────────────────────────────────────────────────────────── */

button, a.primary, a.secondary {
  font: inherit;
  cursor: pointer;
}

/* Pop-art button: flat red, thick black ink border, hard-offset comic shadow.
   Halftone dots scatter across the surface; yellow accent line just inside. */
.primary {
  position: relative;
  background-color: var(--primary);
  background-image:
    radial-gradient(circle, rgba(0, 0, 0, 0.18) 1.1px, transparent 1.4px);
  background-size: 8px 8px;
  color: var(--primary-ink);
  border: 2.5px solid #0f0f0f;
  border-radius: var(--radius);
  padding: 0.7rem 1.2rem;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  display: inline-block;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.55);
  box-shadow: 3px 3px 0 #0f0f0f;
  transition: transform 80ms ease, box-shadow 80ms ease, background-color 120ms ease;
}
/* Yellow comic-accent line just inside the ink border. */
.primary::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 1.5px solid var(--accent);
  border-radius: calc(var(--radius) - 2px);
  pointer-events: none;
}
.primary:hover {
  background-color: var(--primary-hover);
  transform: translate(-1px, -1px);
  box-shadow: 4px 4px 0 #0f0f0f;
  text-decoration: none;
}
.primary:active {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0 #0f0f0f;
}
.primary:disabled {
  opacity: 0.55;
  cursor: default;
  box-shadow: 2px 2px 0 #0f0f0f;
  transform: none;
}
.primary:disabled::after { opacity: 0.3; }
html[data-theme="dark"] .primary {
  border-color: var(--accent);
  text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.7);
  box-shadow: 3px 3px 0 var(--accent);
}
html[data-theme="dark"] .primary:hover  { box-shadow: 4px 4px 0 var(--accent); }
html[data-theme="dark"] .primary:active { box-shadow: 1px 1px 0 var(--accent); }
html[data-theme="dark"] .primary:disabled { box-shadow: 2px 2px 0 var(--accent); }

/* Animated arrow inside primary buttons — nudges right continuously, speeds
   up on hover. */
@keyframes pf-arrow-nudge {
  0%, 100% { transform: translateX(0); }
  50%      { transform: translateX(5px); }
}
.primary .arrow {
  display: inline-block;
  margin-left: 0.25em;
  animation: pf-arrow-nudge 1.4s ease-in-out infinite;
  will-change: transform;
}
.primary:hover .arrow { animation-duration: 0.6s; }
.primary:disabled .arrow { animation: none; }
@media (prefers-reduced-motion: reduce) {
  .primary .arrow { animation: none; }
}

.secondary {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.55rem 0.9rem;
  font-weight: 500;
}
.secondary:hover { background: var(--bg); }
.secondary:disabled { opacity: 0.5; cursor: default; }

.chip {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  font-size: 0.9rem;
}
.chip:hover { border-color: var(--primary); color: var(--primary); }
.chip-section {
  background: var(--surface-2);
  font-weight: 600;
}

/* ── App pages ───────────────────────────────────────────────────────── */

body.app-page .app-main {
  max-width: 760px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
}
body.app-page.builder-page .app-main {
  max-width: none !important;
  width: 96vw;
  width: min(96vw, 2400px);
  margin-left: auto;
  margin-right: auto;
}
/* Portal (dashboard) and Forms-list also use the wide layout — the
   submissions + active-sessions grids need the room or every card wraps
   onto two lines. Import view stays at the default narrow width since its
   docs read better as a single column. */
body.app-page.received-page .app-main,
body.app-page.forms-page .app-main {
  max-width: none !important;
  width: 96vw;
  width: min(96vw, 1800px);
  margin-left: auto;
  margin-right: auto;
}

/* Builder side-by-side: editor on the left, live preview on the right.
   Stacks below 980px so the preview moves under the editor on narrow screens. */
.builder-layout {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: minmax(0, 1fr);
}
@media (min-width: 980px) {
  .builder-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .builder-preview { position: sticky; top: 1rem; max-height: calc(100vh - 2rem); overflow: auto; }
}
.builder-preview {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.25rem;
}
.preview-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 0.6rem; margin-bottom: 0.75rem;
  border-bottom: 1px solid var(--border); padding-bottom: 0.5rem;
}
.preview-head h2 { margin: 0; font-size: 1rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--muted); }
.preview-head-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.preview-head-actions .secondary { padding: 0.3rem 0.65rem; font-size: 0.85rem; }
@media print { .preview-head-actions { display: none !important; } }
.preview-frame { padding: 0; }
.preview-title { margin: 0 0 0.25rem; font-size: 1.25rem; }
.preview-desc  { margin: 0 0 0.75rem; }
.preview-empty { border: 1px dashed var(--border); border-radius: var(--radius); padding: 1.25rem; text-align: center; color: var(--muted); }
.preview-empty .empty { margin: 0; }

.step { margin-bottom: 2rem; }
.actions { margin-top: 1.5rem; display: flex; gap: 0.75rem; flex-wrap: wrap; }

label { display: block; margin-bottom: 0.9rem; }
label > span {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.3rem;
  color: var(--muted);
}

input[type="text"], input[type="number"], input[type="date"], textarea, select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
}
/* Native <select> chrome (gray box + OS arrows) doesn't match the theme.
   Strip it and draw our own caret so it reads like every other input. */
select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  padding-right: 2.2rem;
  cursor: pointer;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text) 50%),
    linear-gradient(135deg, var(--text) 50%, transparent 50%);
  background-position:
    calc(100% - 1.05rem) 1.05rem,
    calc(100% - 0.75rem) 1.05rem;
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
}
select::-ms-expand { display: none; }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.25);
}
textarea { resize: vertical; }

.readonly-field input, .readonly-field textarea {
  background: var(--surface-2);
}

.copy-row {
  display: flex;
  gap: 0.5rem;
}
.copy-row input { flex: 1; }

/* ── Dashboard (forms library + received submissions) ──────────────── */

.dash-section-title {
  margin: 1.75rem 0 0.4rem;
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  scroll-margin-top: 4.5rem;   /* keeps the heading clear of the sticky topbar when jumped to */
}
html { scroll-behavior: smooth; }
.muted.small { font-size: 0.85rem; margin: 0 0 0.4rem; }

.submission-card { border-left: 3px solid var(--primary); }
.submission-card .sub-id {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.78rem;
  color: var(--muted);
  margin-top: 0.1rem;
}


.dash-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; flex-wrap: wrap; margin-bottom: 0.5rem;
}
.dash-head h1 { margin: 0; }
.dash-head-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

.forms-list {
  display: grid; gap: 0.85rem; margin-top: 1.25rem;
  align-items: start;   /* cards hug content; never stretch to fill the track */
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
}
/* Submissions render oldest-first as a vertical log — first-come-first-
   serve queue ordering, easier to scan for hospital staff watching tickets
   land in real time than a side-by-side grid. */
#submissions-list {
  grid-template-columns: 1fr;
  gap: 0.55rem;
}
#submissions-list .form-card.submission-card {
  /* Tighter padding — every card should fit on one row on wide screens. */
  padding: 0.7rem 1rem;
}
/* Cards must hug their content height — grid items default to align:stretch,
   which was blowing each card up to fill the tall list track and spraying a
   huge void between the name and the buttons. */
#submissions-list { align-items: start; }
#submissions-list .form-card.submission-card {
  align-self: start;
  height: auto;
  min-height: 0;
}
#submissions-list .form-card .row {
  margin-top: 0;
  justify-content: flex-start;
}

/* Single clean row: name+meta on the left, action buttons on the right,
   space-between, NO wrap on desktop (stacks only at ≤720px). info must not
   flex-grow past the actions or it pushes them onto a second line. */
.submission-card .sub-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.2rem;
  flex-wrap: nowrap;
}
.submission-card .sub-card-info {
  flex: 1 1 auto;
  min-width: 0;
}
.submission-card .sub-card-actions {
  flex: 0 0 auto;
  margin: 0;
}

/* Patient name as the hero — big enough to read from across the room
   without leaning in. Meta line under it carries elapsed/ticket/form/date
   in one compact row. */
.submission-card .sub-hero-name {
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.1;
  margin: 0;
  color: var(--text);
  letter-spacing: -0.4px;
  word-break: break-word;
}
.submission-card .sub-hero-sub {
  margin-top: 0.15rem;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.35;
}
.submission-card .sub-hero-sub .elapsed {
  font-size: 0.9rem;
  padding: 0 0.4rem;
}
/* Old h3 + old meta lines are gone — the hero handles everything. */
.submission-card > h3,
.submission-card .sub-meta-line { display: none; }

@media (max-width: 720px) {
  .submission-card .sub-card-row { flex-direction: column; align-items: stretch; gap: 0.5rem; }
  .submission-card .sub-card-actions { flex-wrap: wrap; }
}

/* Name shield: replace the patient name with asterisks via ::before so no
   bytes of the real string ever land in the rendered DOM until the card is
   hovered or unlocked. Reveal on hover (peek-without-state) OR when the
   card has .revealed (Show-name click). Anonymous submissions render the
   ticket directly and skip the shield. */
.shielded-name {
  user-select: none;
  cursor: pointer;
  letter-spacing: 0.15em;
}
.shielded-name::before { content: '*********'; }
.submission-card:hover .shielded-name,
.submission-card.revealed .shielded-name {
  user-select: text;
  cursor: auto;
  letter-spacing: -0.4px;
}
.submission-card:hover .shielded-name::before,
.submission-card.revealed .shielded-name::before { content: attr(data-real); }
/* Elapsed-time badges — loud so hospital staff can scan the column for
   anything stale at a glance. Color comes from the theme accent so it
   reads as a primary signal, not a date. */
.elapsed {
  display: inline-block;
  font-weight: 700;
  font-size: 0.95rem;
  /* Always dark text — the badge is always on a yellow ground in both
     themes, so var(--text) (cream in dark) would be unreadable. */
  color: #1a1500;
  background: var(--accent, #fcd116);
  border: 2px solid #1a1500;
  border-radius: 6px;
  padding: 0.05rem 0.45rem;
  margin-right: 0.25rem;
}
.form-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 0.35rem;
}
.form-card h3 { margin: 0; font-size: 1.05rem; }
.form-card .meta { font-size: 0.82rem; color: var(--muted); }
.form-card .row { display: flex; gap: 0.4rem; margin-top: 0.55rem; flex-wrap: wrap; }
.form-card .row .primary,
.form-card .row .secondary { padding: 0.35rem 0.75rem; font-size: 0.85rem; }

.empty-state {
  padding: 2rem; text-align: center; color: var(--muted);
  border: 1px dashed var(--border); border-radius: var(--radius);
}

.back-link {
  display: inline-block; color: var(--muted); font-size: 0.88rem;
  margin-bottom: 0.5rem;
}
.back-link:hover { color: var(--primary); text-decoration: none; }

/* Heading row that pairs the page H1 with the save-state pill. */
.step-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}
.step-head h1 { margin-bottom: 0.25em; }

.save-indicator {
  position: relative;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.2rem 0.75rem;
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  border: 1.5px solid #0f0f0f;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
  user-select: none;
  transition: background-color 140ms ease, color 140ms ease;
}
.save-indicator.save-clean   { background: var(--accent); color: #0f0f0f; }
.save-indicator.save-pending { background: var(--surface-2); color: var(--muted); }
.save-indicator.save-error   { background: rgba(227, 6, 19, 0.15); color: var(--danger); border-color: var(--danger); }

/* Texting-style three-dot bounce while a save is dirty/in-flight. */
.save-dots {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.save-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.4;
  animation: pf-save-bounce 1.1s ease-in-out infinite;
}
.save-dots span:nth-child(2) { animation-delay: 0.15s; }
.save-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes pf-save-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: 0.35; }
  30%           { transform: translateY(-3px); opacity: 1; }
}

/* Metallic shield-shine sweep on the "Saved" state — runs once every few
   seconds across the pill to signal the draft is locked in. */
.save-indicator.save-clean::before {
  content: "";
  position: absolute;
  top: -2px; bottom: -2px;
  left: -45%;
  width: 35%;
  background: linear-gradient(105deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.55) 50%,
    rgba(255, 255, 255, 0) 100%);
  transform: skewX(-20deg);
  animation: pf-save-shine 3.8s ease-in-out infinite;
  pointer-events: none;
}
@keyframes pf-save-shine {
  0%   { left: -45%; opacity: 0; }
  8%   { opacity: 1; }
  42%  { left: 115%; opacity: 1; }
  43%  { opacity: 0; }
  100% { left: 115%; opacity: 0; }
}

html[data-theme="dark"] .save-indicator { border-color: var(--accent); }
html[data-theme="dark"] .save-indicator.save-clean { color: #0f0f0f; }
html[data-theme="dark"] .save-indicator.save-clean::before {
  background: linear-gradient(105deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.7) 50%,
    rgba(255, 255, 255, 0) 100%);
}

@media (prefers-reduced-motion: reduce) {
  .save-dots span { animation: none; opacity: 1; }
  .save-indicator.save-clean::before { animation: none; opacity: 0; }
}

/* ── Builder jumbotron ──────────────────────────────────────────────────
   Pop-art explainer at the top of the editor. Collapses to a single bar. */
.builder-jumbo {
  position: relative;
  margin: 0.75rem 0 1.5rem;
  background:
    radial-gradient(circle, rgba(15, 15, 15, 0.06) 1px, transparent 1.4px) 0 0 / 10px 10px,
    var(--surface);
  border: 2.5px solid #0f0f0f;
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 #0f0f0f;
  overflow: hidden;
}
html[data-theme="dark"] .builder-jumbo {
  border-color: var(--accent);
  box-shadow: 4px 4px 0 var(--accent);
}
.builder-jumbo::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 10px;
  background:
    repeating-linear-gradient(90deg,
      var(--primary) 0 16px,
      #0f0f0f 16px 19px,
      var(--accent) 19px 35px,
      #0f0f0f 35px 38px);
  border-bottom: 2px solid #0f0f0f;
}
html[data-theme="dark"] .builder-jumbo::before { border-bottom-color: var(--accent); }

.builder-jumbo-head {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 1.05rem 1rem 0.85rem;
  cursor: pointer;
  user-select: none;
}
.builder-jumbo.collapsed .builder-jumbo-head { padding-bottom: 1rem; }
.builder-jumbo-tag {
  display: inline-block;
  background: var(--accent);
  color: #0f0f0f;
  border: 1.5px solid #0f0f0f;
  border-radius: 999px;
  padding: 0.18rem 0.65rem;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
  flex-shrink: 0;
}
.builder-jumbo-headline {
  flex: 1;
  min-width: 0;
  margin: 0;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.005em;
  line-height: 1.3;
}
.builder-jumbo-head .icon-btn {
  border-width: 1.5px;
  font-size: 1rem;
  flex-shrink: 0;
  transition: transform 140ms ease;
}
.builder-jumbo.collapsed .builder-jumbo-head .icon-btn { transform: rotate(-90deg); }

.builder-jumbo-body {
  padding: 0 1.1rem 1.2rem;
}
.builder-jumbo.collapsed .builder-jumbo-body { display: none; }

.builder-jumbo-lede {
  margin: 0 0 1rem;
  font-size: 0.98rem;
  color: var(--text);
  max-width: 70ch;
}
.builder-jumbo-lede em {
  font-style: normal;
  font-weight: 700;
  color: var(--primary-ink);
  background: var(--primary);
  border: 1.5px solid #0f0f0f;
  padding: 0 0.3em;
  border-radius: 4px;
}

.builder-jumbo-steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}
.builder-jumbo-steps li {
  position: relative;
  background: var(--surface);
  border: 1.5px solid #0f0f0f;
  border-radius: calc(var(--radius) - 2px);
  padding: 0.85rem 0.9rem 0.75rem;
  box-shadow: 2px 2px 0 #0f0f0f;
}
html[data-theme="dark"] .builder-jumbo-steps li {
  border-color: var(--accent);
  box-shadow: 2px 2px 0 var(--accent);
}
.builder-jumbo-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  background: var(--primary);
  color: var(--primary-ink);
  border: 1.5px solid #0f0f0f;
  border-radius: 999px;
  font-weight: 900;
  font-size: 0.92rem;
  margin-bottom: 0.5rem;
  box-shadow: 2px 2px 0 var(--accent);
}
html[data-theme="dark"] .builder-jumbo-num { border-color: var(--accent); }
.builder-jumbo-steps h3 {
  margin: 0 0 0.25rem;
  font-size: 0.95rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: var(--text);
}
.builder-jumbo-steps p {
  margin: 0;
  font-size: 0.86rem;
  line-height: 1.45;
  color: var(--muted);
}

/* ── Import dialog ──────────────────────────────────────────────────── */

.dialog {
  width: min(720px, 92vw);
  max-height: 90vh;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 1.25rem 1.4rem;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.25);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.45); }
.dialog h2 { margin: 0 0 0.25rem; }
.dialog .file-row { display: flex; flex-direction: column; gap: 0.35rem; }
.dialog .file-row input[type="file"] { padding: 0.4rem 0; border: none; background: transparent; }
.dialog textarea { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 0.88rem; }
.dialog .actions { margin-top: 1rem; }

/* Starter templates picker — pop-art cards with industry tag chip. */
.templates-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 0.5rem;
}
.template-card {
  background: var(--surface);
  border: 2px solid #0f0f0f;
  border-radius: var(--radius);
  padding: 0.85rem 0.95rem 1rem;
  box-shadow: 3px 3px 0 #0f0f0f;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
html[data-theme="dark"] .template-card {
  border-color: var(--accent);
  box-shadow: 3px 3px 0 var(--accent);
}
.template-tag {
  display: inline-block;
  align-self: flex-start;
  background: var(--accent);
  color: #0f0f0f;
  border: 1.5px solid #0f0f0f;
  border-radius: 999px;
  padding: 0.12rem 0.55rem;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.template-name {
  margin: 0.1rem 0 0;
  font-size: 1.02rem;
  font-weight: 800;
  line-height: 1.25;
}
.template-summary {
  margin: 0;
  font-size: 0.88rem;
  color: var(--text);
  line-height: 1.4;
  flex: 1;
}
.template-meta {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}
.template-card .primary {
  align-self: stretch;
  margin-top: 0.4rem;
  padding: 0.55rem 0.9rem;
  font-size: 0.85rem;
  letter-spacing: 0.04em;
}

.import-help {
  margin: 0.5rem 0 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem 0.75rem;
  background: var(--surface-2);
}
.import-help summary { cursor: pointer; font-weight: 500; padding: 0.2rem 0; }
.import-help pre {
  margin: 0.5rem 0;
  padding: 0.7rem 0.85rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.82rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.import-help .small { font-size: 0.82rem; margin: 0.25rem 0 0; }
.import-help code {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 0.82rem;
}

/* Import-docs page (/import.html) — code blocks, type cards, inline code. */
body.app-page.import-page .app-main {
  max-width: none !important;
  width: 96vw;
  width: min(96vw, 2400px);
  margin-left: auto;
  margin-right: auto;
}
body.import-page h2 { margin-top: 2.2rem; }
body.import-page h3 { margin-top: 1.6rem; }
body.import-page h4 { margin: 0 0 0.4em; font-size: 0.95rem; }

/* The paste-and-import area at the top of /import.html. Pop-art panel so it
   reads as the primary action; docs scroll below it in two columns. */
.import-area-top {
  background: var(--surface);
  border: 2.5px solid #0f0f0f;
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 #0f0f0f;
  padding: 1rem 1.1rem 1.1rem;
  margin: 0.5rem 0 2rem;
}
html[data-theme="dark"] .import-area-top {
  border-color: var(--accent);
  box-shadow: 4px 4px 0 var(--accent);
}
.import-area-top label { display: block; margin-bottom: 0.6rem; }
.import-area-top textarea {
  width: 100%;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.88rem;
  padding: 0.55rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  resize: vertical;
  box-sizing: border-box;
}
.import-area-top .file-row { display: flex; flex-direction: column; gap: 0.35rem; }
.import-area-top .file-row input[type="file"] {
  padding: 0.4rem 0; border: none; background: transparent;
}
.import-area-top .actions { margin-top: 0.75rem; display: flex; gap: 0.6rem; flex-wrap: wrap; }

/* Validate-only result panel — green-light pop-art card with stats and an
   optional pretty-printed JSON drawer. Shown after a successful parse. */
.import-result {
  margin-top: 0.85rem;
  padding: 0.8rem 0.95rem;
  background: var(--surface-2);
  border: 2px solid #0f0f0f;
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 #0f0f0f;
  font-size: 0.9rem;
}
html[data-theme="dark"] .import-result {
  border-color: var(--accent);
  box-shadow: 3px 3px 0 var(--accent);
}
.import-result-head {
  display: flex; align-items: center; gap: 0.55rem; flex-wrap: wrap;
  margin-bottom: 0.5rem;
}
.import-result .ok-badge {
  background: var(--accent); color: #0f0f0f;
  border: 1.5px solid #0f0f0f;
  border-radius: 4px;
  padding: 1px 8px;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.import-result-stats {
  display: flex; flex-wrap: wrap; gap: 0.4rem 0.7rem;
  color: var(--muted);
}
.import-result-stats .kv strong { color: var(--fg, inherit); margin-right: 0.2em; }
.import-result-stats .kv-sep { opacity: 0.5; }
.import-result-pretty { margin-top: 0.7rem; }
.import-result-pretty summary {
  cursor: pointer; font-weight: 600; padding: 0.15rem 0;
  color: var(--muted);
}
.import-result-pretty pre {
  margin: 0.4rem 0 0;
  padding: 0.7rem 0.85rem;
  max-height: 360px;
  overflow: auto;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.82rem;
  line-height: 1.45;
}

/* Two-column docs. Every card lives in the same CSS multi-column flow so
   they pack tight top-to-bottom in each column with no empty rows. */
.docs-cols {
  columns: 1;
  column-gap: 1.25rem;
  margin-top: 1.5rem;
}
@media (min-width: 980px) { .docs-cols { columns: 2; } }

.docs-card {
  display: block;
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem 1.1rem;
  box-shadow: 2px 2px 0 var(--border);
  margin: 0 0 1.25rem;
  break-inside: avoid;
  -webkit-column-break-inside: avoid;
  page-break-inside: avoid;
}
html[data-theme="dark"] .docs-card { box-shadow: 2px 2px 0 var(--accent); }
.docs-card > :first-child { margin-top: 0; }
.docs-card > :last-child  { margin-bottom: 0; }
.docs-card h2 { margin-top: 0; font-size: 1.25rem; }
.docs-card h3 { margin-top: 0; font-size: 1.05rem; }
.docs-card pre.import-doc { margin: 0.5rem 0 0.6rem; }
.docs-card ul.why-list { margin-bottom: 0.4rem; }
body.import-page p code,
body.import-page li code {
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 0.86em;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
pre.import-doc {
  margin: 0.5rem 0 1rem;
  padding: 0.85rem 1rem;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 3px 3px 0 var(--border);
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.5;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
pre.import-doc code {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  white-space: pre;
}
.import-types {
  display: grid;
  gap: 0.75rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 0.75rem;
}
.import-type {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
}
.import-type p { font-size: 0.9rem; color: var(--muted); margin: 0 0 0.5rem; }
.import-type pre.import-doc {
  margin: 0;
  box-shadow: none;
  border-width: 1px;
}
html[data-theme="dark"] pre.import-doc { box-shadow: 3px 3px 0 var(--accent); }

/* ── Form builder ───────────────────────────────────────────────────── */

.builder-layout { display: grid; gap: 1.5rem; align-items: start; }
@media (min-width: 980px) {
  .builder-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 2rem; }
  .builder-preview {
    position: sticky;
    top: 1rem;
    max-height: calc(100vh - 2rem);
    overflow-y: auto;
  }
}

.builder-preview .preview-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 0.6rem;
}
.builder-preview h2 { margin: 0; }
.preview-head-actions { display: flex; align-items: center; gap: 0.6rem; }
.preview-head-actions .secondary { padding: 0.3rem 0.65rem; font-size: 0.82rem; }
.builder-preview .preview-tag,
.builder-preview .preview-head .muted {
  font-size: 0.78rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* No box here — the outer .builder-preview card is the only frame. This
   used to add a 3rd nested rectangle (card > frame > patient-form >
   empty-box). Now it's just a content area. Test-mode re-adds a border
   because the attention outline is the whole point of test mode. */
.preview-frame, .preview-card {
  position: relative;
  padding: 0;
}

/* Test-fill mode — inputs become interactive so the clinician can rehearse.
   A yellow banner across the top makes it impossible to confuse with the
   real form, and the frame gets an attention border. */
.preview-frame.test-mode {
  border: 2px solid var(--accent);
  border-radius: var(--radius);
  box-shadow: 4px 4px 0 var(--accent);
  padding: 2.6rem 1rem 1rem;
}
.preview-frame.test-mode::before {
  content: "🧪 TEST MODE — answers stay on this device, never transmitted";
  position: absolute;
  top: 0; left: 0; right: 0;
  background: var(--accent);
  color: #0f0f0f;
  border-bottom: 2px solid #0f0f0f;
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.35rem 0.85rem;
  text-align: center;
}
.preview-frame.test-mode .intake-cell input:not([type="radio"]):not([type="checkbox"]),
.preview-frame.test-mode .intake-cell textarea {
  width: 100%;
  display: block;
  box-sizing: border-box;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.4rem 0.55rem;
  font: inherit;
}
.preview-frame.test-mode .intake-cell input[type="radio"],
.preview-frame.test-mode .intake-cell input[type="checkbox"] {
  width: auto;
  display: inline-block;
  margin-right: 0.35rem;
}
.preview-frame.test-mode .intake-cell textarea { min-height: 5em; resize: vertical; }
.preview-frame.test-mode .intake-cell input:focus,
.preview-frame.test-mode .intake-cell textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(227, 6, 19, 0.20);
}

/* Live validation feedback. `:user-invalid` triggers only after the user has
   interacted (typed, blurred, or attempted submit), so untouched required
   fields don't pop red on first load. Applies to both the test-fill preview
   and the patient's live form on fill.html. */
.preview-frame.test-mode .intake-cell input:user-invalid,
.preview-frame.test-mode .intake-cell textarea:user-invalid,
.patient-form:not(.preview-form) .intake-cell input:user-invalid,
.patient-form:not(.preview-form) .intake-cell textarea:user-invalid {
  border-color: var(--danger) !important;
  background: rgba(227, 6, 19, 0.06) !important;
  box-shadow: 0 0 0 2px rgba(227, 6, 19, 0.12) !important;
}
.preview-frame.test-mode .intake-cell input:user-invalid:focus,
.preview-frame.test-mode .intake-cell textarea:user-invalid:focus,
.patient-form:not(.preview-form) .intake-cell input:user-invalid:focus,
.patient-form:not(.preview-form) .intake-cell textarea:user-invalid:focus {
  box-shadow: 0 0 0 3px rgba(227, 6, 19, 0.25) !important;
}
.secondary.active {
  background: var(--accent);
  border-color: #0f0f0f;
  font-weight: 700;
}
.preview-title  { margin: 0 0 0.25rem; font-size: 1.1rem; }
.preview-desc   { margin: 0 0 0.85rem; }
.preview-form   { margin-top: 0; }
.preview-form .empty,
.preview-empty .empty {
  margin: 0;
  padding: 1.25rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
  color: var(--muted);
}
.preview-form .intake-cell input:not([type="radio"]):not([type="checkbox"]),
.preview-form .intake-cell textarea {
  width: 100%;
  display: block;
  box-sizing: border-box;
  background: transparent;
  border: none;
  border-bottom: 1px dotted var(--border);
  border-radius: 0;
  padding: 0.15rem 0;
  cursor: not-allowed;
  font-size: 0.92rem;
}
.preview-form input:disabled,
.preview-form textarea:disabled { opacity: 1; color: var(--text); }

/* Paper-clean intake look — both on screen (preview) and on print.
   Specificity bumped (.patient-form.preview-form) so it beats the base
   .patient-form rule that comes later in the file. */
.patient-form.preview-form, .printing-preview .patient-form {
  background: #ffffff;
  color: #15201c;
  border-radius: 0;
  border-color: #555;
  box-shadow: none;
}
/* Inside the builder preview pane the outer .builder-preview card is the
   only frame — strip the rendered form's own border/background/shadow so
   it isn't yet another box-in-a-box. The real fill page + submission view
   keep their paper-sheet border (they have no .builder-preview ancestor). */
.builder-preview .patient-form {
  border: 0;
  background: transparent;
  box-shadow: none;
  padding: 0;
}
.builder-preview .preview-empty {
  border: 1px dashed var(--border);
  background: transparent;
}
.preview-form .intake-section,
.printing-preview .intake-section {
  background: #eaeaea;
  color: #15201c;
  border-color: #555;
  padding: 0.4rem 0.65rem;
  font-size: 0.9rem;
  text-transform: none;
  letter-spacing: 0;
}
.preview-form .intake-row,
.printing-preview .intake-row { border-color: #555; }
.preview-form .intake-cell,
.printing-preview .intake-cell {
  padding: 0.45rem 0.65rem;
  border-color: #555;
}
.preview-form .intake-cell.half + .intake-cell.half,
.printing-preview .intake-cell.half + .intake-cell.half { border-left-color: #555; }
.preview-form .intake-label,
.printing-preview .intake-label {
  font-size: 0.82rem;
  font-weight: 500;
  color: #15201c;
  margin-bottom: 0.2rem;
}
.preview-form .choices.inline label,
.printing-preview .choices.inline label { font-size: 0.88rem; }

.intake-hint {
  font-size: 0.82rem;
  color: var(--muted);
  margin: -0.1rem 0 0.35rem;
  line-height: 1.4;
}
.preview-form .intake-hint,
.printing-preview .intake-hint { color: #4a4030; }

.form-meta { margin-bottom: 1.5rem; }

.fields-list .empty {
  color: var(--muted);
  padding: 1.5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  text-align: center;
}

.field-edit {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  margin-bottom: 0.85rem;
  box-shadow: var(--shadow);
}
.field-edit.is-section {
  background: var(--surface-2);
  border-style: dashed;
}
.field-edit.is-section .field-type { color: var(--text); }

.field-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.25rem;
  margin-top: 0.5rem;
}

.field-edit-head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin: -0.4rem -0.5rem 0.4rem;
  padding: 0.4rem 0.5rem;
  border-radius: calc(var(--radius) - 2px);
  cursor: pointer;
  user-select: none;
  transition: background-color 120ms ease;
}
.field-edit-head:hover { background: var(--surface-2); }
.field-edit.collapsed .field-edit-head { margin-bottom: -0.4rem; }
.field-edit.collapsed .field-edit-body { display: none; }

/* Toolbar above the field list — holds the reorder-lock toggle (and future
   field-list-scope buttons). Sticky right-align so it sits at the edge. */
.fields-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin: 0.2rem 0 0.5rem;
}
.fields-toolbar-left { display: flex; gap: 0.4rem; }
.fields-toolbar .chip:disabled { opacity: 0.4; cursor: default; }
.fields-toolbar .chip:disabled:hover { border-color: var(--border); color: var(--text); }

.fields-toolbar-search {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}
.fields-toolbar-search input {
  flex: 1;
  min-width: 0;
  padding: 0.35rem 0.7rem;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font: inherit;
  font-size: 0.85rem;
}
.fields-toolbar-search input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(227, 6, 19, 0.18);
}
.fields-toolbar-search .small { font-size: 0.72rem; white-space: nowrap; }

.field-edit.filtered-out { display: none !important; }

/* Conditional-logic editor block — show/hide a field based on another's answer. */
.field-conditional {
  margin: 0.4rem 0 0.7rem;
  padding: 0.55rem 0.7rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.field-conditional-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.85rem;
  align-items: flex-end;
  margin-top: 0.5rem;
}
.field-conditional-row .sub.inline > select,
.field-conditional-row .sub.inline > input { min-width: 8rem; }
.field-conditional-row .sub.inline.grow > input,
.field-conditional-row .sub.inline.grow > select { flex: 1; }

/* Hide a cell whose conditional rule isn't met. Also kills its row's flex
   contribution so the layout collapses cleanly. */
.intake-cell.hidden-cond,
.paper-cell.hidden-cond { display: none !important; }
/* If an entire row's contents are hidden, hide the row too. */
.intake-row:has(> .intake-cell:not(.hidden-cond)) { display: flex; }
.intake-row:not(:has(> .intake-cell:not(.hidden-cond))) { display: none !important; }
.lock-chip {
  cursor: pointer;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  font-size: 0.78rem;
  user-select: none;
}
.lock-chip.locked {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.lock-chip.unlocked {
  background: var(--accent);
  color: #0f0f0f;
  border-color: #0f0f0f;
  box-shadow: 2px 2px 0 #0f0f0f;
}
.lock-chip:hover { border-color: var(--primary); color: var(--primary); }
.lock-chip.unlocked:hover { color: #0f0f0f; border-color: #0f0f0f; }

/* Drag handle to grab a row and reorder it via drag-and-drop. The button
   itself is the only draggable element; the row body is the drop target. */
.field-drag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  font-size: 1.05rem;
  font-weight: 800;
  letter-spacing: -0.15em;
  line-height: 1;
  color: var(--muted);
  background: transparent;
  border: 1.5px dashed var(--border);
  border-radius: 6px;
  cursor: grab;
  flex-shrink: 0;
  transition: background-color 120ms ease, color 120ms ease, border-color 120ms ease;
}
.field-drag:hover {
  color: var(--text);
  border-style: solid;
  background: var(--surface-2);
}
.field-drag:active { cursor: grabbing; }

/* When reorder is locked, the handles are visible but visibly inactive so
   users can see the affordance exists without being able to act on it. */
body.reorder-locked .field-drag {
  cursor: not-allowed;
  opacity: 0.35;
}
body.reorder-locked .field-drag:hover {
  background: transparent;
  border-style: dashed;
  color: var(--muted);
}

.field-edit.dragging { opacity: 0.4; }
.field-edit.drop-above { box-shadow: 0 -3px 0 0 var(--accent) inset, 0 -3px 0 0 var(--accent); }
.field-edit.drop-above { border-top: 3px solid var(--accent) !important; }
.field-edit.drop-below { border-bottom: 3px solid var(--accent) !important; }

.field-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  transition: transform 140ms ease, background-color 120ms ease;
  flex-shrink: 0;
}
.field-edit-head:hover .field-toggle {
  background: var(--accent);
  border-color: #0f0f0f;
}
.field-edit.collapsed .field-toggle { transform: rotate(-90deg); }

.field-type {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}

.field-summary {
  flex: 1;
  min-width: 0;
  font-size: 0.92rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 0.4rem;
}
.field-edit:not(.collapsed) .field-summary { display: none; }

.field-edit-actions {
  display: flex;
  gap: 0.3rem;
  margin-left: auto;
  flex-shrink: 0;
}

/* Brief highlight when the user jumps from preview → editor. */
@keyframes pf-field-flash {
  0%   { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
  100% { box-shadow: 0 0 0 0 transparent, var(--shadow); }
}
.field-edit.flash { animation: pf-field-flash 1.3s ease-out; }

/* Preview cells are clickable — show a soft hover hint so users know to try. */
.preview-clickable { cursor: pointer; transition: outline-color 100ms ease; }
.preview-form .preview-clickable:hover,
.preview-form .preview-clickable:focus-visible {
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  border-radius: 4px;
}
.preview-form .preview-clickable:focus-visible { outline-style: solid; }

.sub { margin-bottom: 0.7rem; }
.sub > span {
  font-size: 0.8rem;
  font-weight: 500;
}
.sub.inline {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}
.sub.inline > span {
  display: inline;
  margin: 0;
}
.sub.inline > input[type="number"] { width: 6rem; }
.sub.inline.grow { flex: 1 1 100%; }
.sub.inline.grow > input { flex: 1; }

.field-validation {
  margin: 0.4rem 0 0.7rem;
  padding: 0.55rem 0.7rem;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius);
  background: var(--surface-2);
}
.field-validation .sub-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.4rem;
  color: var(--muted);
}
.field-validation-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  align-items: center;
}

.add-field {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 1.5rem 0;
  padding: 0.85rem;
  background: var(--surface-2);
  border-radius: var(--radius);
}

/* ── Live answers (clinician side) + patient form ───────────────────── */

.live-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.session-code {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.85rem;
  background: var(--surface-2);
  border: 1px solid var(--border);
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  color: var(--text);
}

/* Intake-form layout: bordered cells, section bands, half-width pairing.
   Used by both the patient form (fill.html) and the clinician's live view. */

.patient-form, .answers-live {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: var(--radius);
  background: var(--surface);
  overflow: hidden;
}

.intake-section {
  background: var(--surface-2);
  border-top: 1px solid var(--border);
  padding: 0.55rem 0.85rem;
  font-weight: 600;
  font-size: 0.95rem;
  color: var(--text);
}
/* First section keeps its top border so the form's top edge is visible.
   The wrapper (.patient-form) intentionally has border-top: none — the
   first child's border acts as the wrapper's top edge. */
.intake-section-desc {
  font-weight: 400;
  font-size: 0.85rem;
  color: var(--muted);
  margin-top: 0.2rem;
  line-height: 1.4;
}
.preview-form .intake-section-desc,
.printing-preview .intake-section-desc { color: #4a4030; }

.intake-row {
  display: flex;
  border-top: 1px solid var(--border);
}
.intake-row:first-child { border-top: none; }

.intake-cell {
  padding: 0.6rem 0.85rem;
  min-width: 0;
}
.intake-cell.full    { flex: 1 1 100%;    }
.intake-cell.half    { flex: 1 1 50%;     }
.intake-cell.third   { flex: 1 1 33.333%; min-width: 0; }
.intake-cell.quarter { flex: 1 1 25%;     min-width: 0; }
/* A lone partial-width cell (no siblings to share the row) expands to fill
   it so the input doesn't sit in a tiny box with empty space next to it. */
.intake-cell.half:only-child,
.intake-cell.third:only-child,
.intake-cell.quarter:only-child { flex: 1 1 100%; }
.intake-cell.half    + .intake-cell.half,
.intake-cell.third   + .intake-cell.third,
.intake-cell.quarter + .intake-cell.quarter { border-left: 1px solid var(--border); }

.intake-label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 0.3rem;
}
.intake-num {
  display: inline-block;
  min-width: 1.5em;
  color: var(--primary);
  font-weight: 800;
}

/* Pagebreak divider — shown in non-paginated contexts (clinician's live
   answers, builder preview). The patient view splits on these instead. */
.intake-pagebreak {
  background: repeating-linear-gradient(
    90deg,
    var(--accent) 0 14px,
    #0f0f0f 14px 17px,
    var(--primary) 17px 31px,
    #0f0f0f 31px 34px
  );
  color: #0f0f0f;
  border-top: 2px solid #0f0f0f;
  border-bottom: 2px solid #0f0f0f;
  padding: 0.45rem 0.85rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 0.78rem;
  text-shadow: 0 0 4px rgba(255, 248, 231, 0.85);
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
.intake-pagebreak-label {
  margin-left: 0.5rem;
  background: var(--surface);
  border: 1.5px solid #0f0f0f;
  border-radius: 4px;
  padding: 0.05rem 0.4rem;
  text-shadow: none;
}

.field-edit.is-pagebreak { background: var(--surface-2); border-style: dashed; }
.field-edit.is-pagebreak .field-type { color: var(--primary); }

/* File / photo upload field — patient view and answer rendering. */
.intake-cell input[type="file"] {
  display: block;
  width: 100%;
  font: inherit;
  padding: 0.4rem 0;
}
.file-preview {
  margin-top: 0.5rem;
  font-size: 0.85rem;
  color: var(--muted);
}
.file-preview img {
  max-width: 220px;
  max-height: 220px;
  border: 1.5px solid #0f0f0f;
  border-radius: 4px;
  box-shadow: 2px 2px 0 #0f0f0f;
  display: block;
}
.file-link {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}
.file-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border: 1.5px solid #0f0f0f;
  border-radius: 4px;
  box-shadow: 2px 2px 0 #0f0f0f;
}
.file-meta { color: var(--muted); font-size: 0.85rem; }
html[data-theme="dark"] .file-preview img,
html[data-theme="dark"] .file-thumb { border-color: var(--accent); box-shadow: 2px 2px 0 var(--accent); }

/* Signature pad — bordered canvas with a baseline guide. touch-action:none
   so a finger drag draws on the canvas instead of scrolling the page. */
.signature-pad { display: block; width: 100%; }
.signature-pad canvas {
  display: block;
  width: 100%;
  height: 140px;
  background:
    linear-gradient(to bottom, transparent calc(100% - 28px), rgba(0, 0, 0, 0.12) calc(100% - 28px), rgba(0, 0, 0, 0.12) calc(100% - 27px), transparent calc(100% - 27px)),
    var(--surface);
  border: 2px solid #0f0f0f;
  border-radius: 6px;
  cursor: crosshair;
  touch-action: none;
}
.signature-pad[data-disabled="1"] canvas { cursor: not-allowed; }
.signature-pad-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 0.3rem;
  gap: 0.6rem;
}
.signature-hint { font-size: 0.78rem; }
.signature-clear { padding: 0.3rem 0.7rem; font-size: 0.8rem; }
html[data-theme="dark"] .signature-pad canvas { border-color: var(--accent); }

#print-container .paper-pagebreak {
  break-before: page;
  page-break-before: always;
  height: 0;
}

/* Patient-view page navigation (Prev / Next / page counter). */
.page-actions { display: flex; align-items: center; gap: 0.85rem; flex-wrap: wrap; }
.page-nav { display: flex; align-items: center; gap: 0.6rem; }

.intake-cell input[type="text"],
.intake-cell input[type="number"],
.intake-cell input[type="date"],
.intake-cell textarea {
  width: 100%;
  padding: 0.45rem 0.55rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  font: inherit;
}
.intake-answer {
  min-height: 1.4em;
  word-break: break-word;
}

.choices { display: flex; flex-direction: column; gap: 0.4rem; }
.choices.inline { flex-direction: row; flex-wrap: wrap; gap: 0.35rem 0.85rem; }
.choices label {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0;
  font-weight: normal;
}
.choices label > span { display: inline; margin: 0; font-weight: normal; }
.choices input[type="radio"], .choices input[type="checkbox"] { width: auto; }

@media (max-width: 560px) {
  .intake-row { flex-direction: column; }
  .intake-cell.half    + .intake-cell.half,
  .intake-cell.third   + .intake-cell.third,
  .intake-cell.quarter + .intake-cell.quarter { border-left: none; border-top: 1px solid var(--border); }
}

/* ── Toast ──────────────────────────────────────────────────────────── */

.toast {
  position: fixed;
  bottom: 1.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: var(--bg);
  padding: 0.6rem 1rem;
  border-radius: 999px;
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  z-index: 100;
}

/* ── Home page ─────────────────────────────────────────────────────── */

/* Home page background:
   - ::before is a fixed grid of squares, parallaxed via --bg-shift (set by bg.js
     at 0.35× scroll speed) so it drifts slower than the content.
   - ::after is a fixed soft spotlight that brightens the center so foreground
     text stays readable while the grid remains visible at the edges. */
body.home-page {
  background-color: var(--bg);
  isolation: isolate;
}
/* Pop-art halftone dots. Parallaxed via --bg-shift so they drift slower
   than the page. */
body.home-page::before {
  content: "";
  position: fixed;
  inset: -4px;
  z-index: -2;
  pointer-events: none;
  background-image:
    radial-gradient(circle, rgba(15, 15, 15, 0.09) 1.4px, transparent 1.9px);
  background-size: 14px 14px;
  background-position: 0 calc(var(--bg-shift, 0px) * -1);
  will-change: background-position;
}
html[data-theme="dark"] body.home-page::before {
  background-image:
    radial-gradient(circle, rgba(252, 209, 22, 0.08) 1.4px, transparent 1.9px);
}

/* Mirror layer — sits between the halftone dots and the content. A diagonal
   sheen reads like glass catching light; the radial wash brightens the center
   so the foreground text stays the focus. */
/* Mascot illustrations — bounded so the ~300-400KB PNGs never render
   huge. Centered, no layout shift (width/height attrs set in HTML). */
.mascot-img {
  display: block;
  height: auto;
  max-width: 100%;
}
.mascot-404 {
  width: min(280px, 60vw);
  margin: 0 auto 1.25rem;
}
.mascot-empty {
  width: min(160px, 40vw);
  margin: 0 auto 0.75rem;
}

/* Google Analytics consent banner (js/analytics.js) — landing page only.
   GA does not load until Accept is clicked. Pop-art bottom bar. */
.ga-consent {
  position: fixed;
  left: 1rem;
  right: 1rem;
  bottom: 1rem;
  z-index: 1000;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem 1rem;
  background: var(--surface);
  color: var(--text);
  border: 3px solid var(--ink, #111);
  border-radius: 14px;
  box-shadow: 6px 6px 0 var(--ink, #111);
  padding: 0.9rem 1.1rem;
}
.ga-consent-text { margin: 0; flex: 1 1 280px; font-size: 0.9rem; line-height: 1.45; }
.ga-consent-text a { color: var(--primary); font-weight: 700; text-decoration: underline; }
.ga-consent-actions { display: flex; gap: 0.5rem; flex: 0 0 auto; }
.ga-consent button {
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 0.5rem 1rem;
  border: 2.5px solid var(--ink, #111);
  border-radius: 8px;
  box-shadow: 2px 2px 0 var(--ink, #111);
}
.ga-consent .ga-decline { background: var(--surface-2); color: var(--text); }
.ga-consent .ga-accept  { background: var(--accent); color: #1a1500; }
.ga-consent button:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink, #111); }
@media (max-width: 560px) {
  .ga-consent { flex-direction: column; align-items: stretch; }
  .ga-consent-actions { justify-content: flex-end; }
}

/* First-run onboarding hint on the Portal — only rendered when the clinic
   has no saved forms. Pop-art callout so a brand-new user isn't staring
   at an empty dashboard wondering what to do. */
.onboarding-hint {
  background: var(--accent, #fcd116);
  color: var(--ink, #111);
  border: 3px solid var(--ink, #111);
  border-radius: 14px;
  box-shadow: 6px 6px 0 var(--ink, #111);
  padding: 1.1rem 1.4rem;
  margin: 0 0 1rem;
}
.onboarding-hint h3 { margin: 0 0 0.5rem; font-size: 1.1rem; font-weight: 800; }
.onboarding-hint p  { margin: 0.35rem 0; }
.onboarding-hint ol { margin: 0.5rem 0 0.5rem 1.2rem; padding: 0; }
.onboarding-hint li { margin: 0.25rem 0; }
.onboarding-hint a  { color: var(--ink, #111); text-decoration: underline; font-weight: 700; }
.onboarding-hint .small { font-size: 0.88rem; }

/* ── Privacy shield (js/shield.js) ──────────────────────────────────── */

.sub-shield-picker {
  margin: 0.5rem 0 0.75rem;
  font-size: 0.85rem;
}
.prox-shield-picker {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.6rem;
  border: 2px solid var(--ink, #111);
  border-radius: 8px;
  background: var(--surface-2, #fcf7e0);
  box-shadow: 2px 2px 0 var(--ink, #111);
}
.prox-shield-picker select {
  font: inherit;
  border: 1px solid var(--ink, #111);
  border-radius: 5px;
  padding: 0.15rem 0.35rem;
  background: var(--surface, #fff);
  color: var(--text, #111);
}

/* Shielded container: answer text is swapped out for '***' in JS; labels
   stay readable but dimmed so the form structure remains visible. The
   overlay sits on top and captures the unshield click. */
.prox-shielded { position: relative; }
.prox-shielded .intake-label { color: var(--muted, #666); }
.prox-shielded .prox-mask {
  font-weight: 700;
  letter-spacing: 0.25em;
  color: var(--muted, #777);
  user-select: none;
}

.prox-shield-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(17, 17, 17, 0.35);
  backdrop-filter: blur(2px);
  cursor: pointer;
  z-index: 1;
  border-radius: var(--radius, 10px);
}
.prox-shield-card {
  background: var(--surface, #fff);
  border: 3px solid var(--ink, #111);
  border-radius: 14px;
  box-shadow: 6px 6px 0 var(--ink, #111);
  padding: 1.1rem 1.5rem;
  max-width: 360px;
  text-align: center;
}
.prox-shield-card h2  { margin: 0.25rem 0 0.35rem; font-size: 1.05rem; }
.prox-shield-card p   { margin: 0; color: var(--muted, #666); font-size: 0.9rem; }
.prox-shield-icon     { font-size: 1.8rem; }

/* Floating "still viewing?" banner — fixed bottom-right so it doesn't
   cover anything important. Auto-shield engages when the countdown hits 0. */
.prox-shield-warn {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 1000;
  pointer-events: auto;
}
.prox-shield-warn-inner {
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: var(--accent, #fcd116);
  color: var(--text, #111);
  border: 3px solid var(--ink, #111);
  border-radius: 12px;
  box-shadow: 5px 5px 0 var(--ink, #111);
  padding: 0.7rem 0.95rem;
  font-size: 0.92rem;
}
.prox-shield-warn-inner button.primary {
  font-family: inherit;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  border: 2px solid var(--ink, #111);
  border-radius: 7px;
  background: var(--danger, #e30613);
  color: #fff;
  cursor: pointer;
  box-shadow: 2px 2px 0 var(--ink, #111);
}
.prox-shield-count {
  display: inline-block;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

/* End-shift button — secondary chrome but red text/accent so it reads as
   destructive without screaming for attention. */
.secondary.danger {
  color: var(--danger, #e30613);
  border-color: var(--danger, #e30613);
}
.secondary.danger:hover { background: var(--danger, #e30613); color: #fff; }

/* ── Themed confirm dialog (js/dialog.js) ───────────────────────────── */

dialog.prox-confirm {
  border: 3px solid var(--ink, #111);
  border-radius: 14px;
  padding: 1.25rem 1.4rem 1.1rem;
  background: var(--surface, #fff);
  color: var(--text, #111);
  box-shadow: 6px 6px 0 var(--ink, #111);
  max-width: 460px;
  width: calc(100vw - 2rem);
  font-family: inherit;
}
dialog.prox-confirm::backdrop {
  background: rgba(17, 17, 17, 0.55);
}
dialog.prox-confirm .prox-confirm-title {
  margin: 0 0 0.5rem;
  font-size: 1.15rem;
  font-weight: 700;
}
dialog.prox-confirm .prox-confirm-message {
  margin: 0 0 1.1rem;
  line-height: 1.5;
  color: var(--text, #111);
}
dialog.prox-confirm .prox-confirm-actions {
  display: flex;
  gap: 0.6rem;
  justify-content: flex-end;
}
dialog.prox-confirm button {
  font-family: inherit;
  font-weight: 700;
  padding: 0.55rem 1rem;
  border: 2.5px solid var(--ink, #111);
  border-radius: 8px;
  box-shadow: 3px 3px 0 var(--ink, #111);
  background: var(--surface-2, #fcf7e0);
  color: var(--text, #111);
  cursor: pointer;
  transition: transform 0.05s ease, box-shadow 0.05s ease;
}
dialog.prox-confirm button:hover  { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink, #111); }
dialog.prox-confirm button:active { transform: translate(2px, 2px);   box-shadow: 1px 1px 0 var(--ink, #111); }
dialog.prox-confirm button.primary {
  background: var(--accent, #fcd116);
}
dialog.prox-confirm button.primary.danger {
  background: var(--danger, #e30613);
  color: #fff;
}

/* In the SPA shell .bg-mirror sits permanently in app.html so the home/gdpr
   routes can show it without injection plumbing. Hide it everywhere else. */
body:not(.home-page) .bg-mirror { display: none; }
.bg-mirror {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background:
    linear-gradient(135deg,
      rgba(252, 209, 22, 0.20) 0%,
      rgba(255, 255, 255, 0.08) 35%,
      rgba(255, 255, 255, 0.04) 65%,
      rgba(252, 209, 22, 0.18) 100%),
    radial-gradient(ellipse 70% 65% at 50% 45%,
      rgba(255, 248, 231, 0.65) 0%,
      rgba(255, 248, 231, 0.22) 50%,
      rgba(255, 248, 231, 0.00) 85%);
}
html[data-theme="dark"] .bg-mirror {
  background:
    linear-gradient(135deg,
      rgba(252, 209, 22, 0.12) 0%,
      rgba(255, 255, 255, 0.02) 35%,
      rgba(255, 255, 255, 0.01) 65%,
      rgba(252, 209, 22, 0.10) 100%),
    radial-gradient(ellipse 70% 65% at 50% 45%,
      rgba(20, 17, 10, 0.65) 0%,
      rgba(20, 17, 10, 0.22) 50%,
      rgba(20, 17, 10, 0.00) 85%);
}
/* Home page layout — a comfortable 1400px column on desktop, full-bleed on
   mobile, with the hero and CTA bands stretching edge-to-edge for visual
   rhythm. The container width is sized for landing-page reading + showing
   off cards: not so narrow it feels squeezed (the old 980px), not so wide
   it looks like a spreadsheet. Sections inside main flow vertically with
   strong padding rhythm; alternating subtle tints break visual monotony
   without resorting to a separate band element per section. */
body.home-page main {
  width: 100% !important;
  max-width: min(95vw, 1500px) !important;
  margin: 0 auto !important;
  padding: 0 clamp(1.25rem, 3vw, 2.5rem) 0 !important;
  box-sizing: border-box;
}

/* Section rhythm — generous vertical padding so each topic gets room to
   breathe instead of cramming. Every other section gets a subtle tint
   (with negative margin trick) so they alternate across the page. */
body.home-page main > section {
  padding: 4rem 0;
  border-top: none;
}
body.home-page main > section.hero { padding-top: 5rem; }
body.home-page main > section + section { border-top: 1px solid var(--border); }

/* Hero — centered text block, bigger headline, more breathing room. */
.home-page .hero {
  text-align: center;
}
.home-page .hero h1 {
  font-size: clamp(2.4rem, 6vw, 4.4rem);
  line-height: 1.05;
  letter-spacing: -0.02em;
  margin: 0.4rem auto 0.8rem;
  max-width: 1100px;
}
.home-page .hero .lede {
  max-width: 760px;
  margin: 0 auto 1.5rem;
  font-size: clamp(1.05rem, 1.4vw, 1.25rem);
}
.home-page .hero-cta { margin-top: 2rem; }

/* Trust strip under the hero — five small chips that summarize the value
   prop in one scannable line. Wraps to two rows on narrow screens. */
.home-page .trust-strip {
  list-style: none;
  padding: 0;
  margin: 2.5rem auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
  max-width: 1100px;
}
.home-page .trust-strip li {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  background: var(--surface);
  border: 2px solid var(--ink, #111);
  border-radius: 999px;
  padding: 0.45rem 0.95rem 0.45rem 0.75rem;
  font-size: 0.92rem;
  font-weight: 600;
  box-shadow: 2px 2px 0 var(--ink, #111);
}
.home-page .trust-strip .trust-mark { font-size: 1.05rem; }

/* Section headings — consistent, slightly oversized for landing-page feel. */
.home-page main > section > h2 {
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  letter-spacing: -0.015em;
  margin-bottom: 0.6rem;
  text-align: center;
}
.home-page main > section > .why-lede {
  text-align: center;
  margin-left: auto;
  margin-right: auto;
  max-width: 800px;
  margin-bottom: 2rem;
}
.home-page .faq details { max-width: 900px; margin-left: auto; margin-right: auto; }
.home-page .why-list    { max-width: 1100px; margin-left: auto; margin-right: auto; }

/* GDPR stats banner — replaces the old 4-card pillar grid. One horizontal
   row of bold numbers separated by hairline dividers, with a single
   descriptive sentence below. Reads "0 / 0 / 0 / 100%" in one glance
   instead of asking the eye to scan through four narrow body-text cards. */
.home-page .stats-banner {
  display: flex;
  align-items: center;
  justify-content: space-around;
  gap: clamp(0.5rem, 2vw, 2rem);
  padding: 2rem 1rem;
  background: var(--surface);
  border: 3px solid var(--ink, #111);
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--ink, #111);
  flex-wrap: wrap;
}
.home-page .stat {
  text-align: center;
  flex: 1 1 130px;
  min-width: 130px;
}
.home-page .stat-num {
  font-size: clamp(2.6rem, 5vw, 4rem);
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -0.03em;
}
.home-page .stat-num .pct { font-size: 0.45em; vertical-align: super; margin-left: 0.05em; }
.home-page .stat-label {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 0.85rem;
  margin-top: 0.4rem;
  color: var(--text);
}
.home-page .stat-sep {
  width: 1px;
  height: 56px;
  background: var(--border);
}
@media (max-width: 720px) {
  .home-page .stat-sep { display: none; }
}
.home-page .pillar-tagline {
  text-align: center;
  max-width: 880px;
  margin: 1.5rem auto 0;
  font-size: 1.05rem;
  color: var(--muted);
  line-height: 1.55;
}

/* Card-grid sizing — every grid auto-fits with a sensible minimum so
   they fill the container at any width. On a 1500px container the tile
   grid lands 5 across, who-grid 4-5 across, how-steps 3 across. */
.home-page .who-grid {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 0.5rem;
}
.home-page .flow-cards {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
  margin-top: 1.4rem;
}
.home-page .how-steps {
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 1.25rem;
}

/* Two-card pitch — the entire selling proposition in one section. Left
   card frames "like paper" (warm/cream), right card frames "GDPR-proof"
   (red/accent). They stand alone, taller than other cards on the page,
   so this is visually the loudest section after the hero. */
.home-page .pitch-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.25rem;
}
@media (max-width: 900px) {
  .home-page .pitch-grid { grid-template-columns: 1fr; }
}
.home-page .pitch-card {
  border: 3px solid var(--ink, #111);
  border-radius: 18px;
  box-shadow: 6px 6px 0 var(--ink, #111);
  padding: 2rem 2.2rem;
  display: flex;
  flex-direction: column;
  gap: 0.8rem;
}
.home-page .pitch-card.pitch-paper {
  background: var(--surface-2, #fcf7e0);
  color: var(--text);
}
/* Deep brand red, not the bright #e30613 — white body text on #e30613 is
   only ~3.9:1 (fails WCAG AA 4.5:1). #8a0309 takes white to ~10:1 and
   still reads as the brand. The aside is full-opacity white (the old 85%
   alpha dropped it below AA too). */
.home-page .pitch-card.pitch-gdpr {
  background: #8a0309;
  color: #fff;
}
.home-page .pitch-card.pitch-gdpr .pitch-aside { color: #fff; }
/* Dark mode: --primary is cream, so the red→white card would vanish.
   Recolour it as the yellow pop card with dark text instead. */
html[data-theme="dark"] .home-page .pitch-card.pitch-gdpr {
  background: var(--accent);
  color: #1a1500;
}
html[data-theme="dark"] .home-page .pitch-card.pitch-gdpr .pitch-aside { color: #1a1500; }
html[data-theme="dark"] .home-page .pitch-card.pitch-gdpr .pitch-tag {
  background: #1a1500;
  color: var(--accent);
  border-color: #1a1500;
}
.home-page .pitch-tag {
  display: inline-block;
  align-self: flex-start;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.2rem 0.7rem;
  border: 2px solid currentColor;
  border-radius: 999px;
}
.home-page .pitch-card.pitch-paper .pitch-tag { background: var(--accent, #fcd116); color: var(--ink, #111); border-color: var(--ink, #111); }
.home-page .pitch-card.pitch-gdpr  .pitch-tag { background: #fff; color: #8a0309; border-color: #fff; }
.home-page .pitch-card h2 {
  margin: 0;
  font-size: clamp(1.6rem, 2.5vw, 2.1rem);
  line-height: 1.15;
  letter-spacing: -0.02em;
  text-align: left;
}
.home-page .pitch-card p {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.55;
}
.home-page .pitch-card .pitch-aside {
  font-size: 0.92rem;
  font-style: italic;
  color: var(--muted);
}
.home-page .pitch-card em { font-style: italic; font-weight: 700; }

@media (max-width: 640px) {
  body.home-page main > section { padding: 2.5rem 0; }
}

/* Who tag — pill stays on one line. Long labels (Hospitality & Luxury
   Retail, Wellness/Fitness/Personal Care) shrink their font instead of
   wrapping ugly. */
.home-page .who-tag {
  white-space: nowrap;
  font-size: 0.72rem;
  padding: 0.15rem 0.7rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* CTA band at the bottom — visually distinct so the final call-to-action
   doesn't blur into the FAQ above it. */
.home-page .cta {
  text-align: center;
  background: linear-gradient(180deg, transparent 0%, rgba(252, 209, 22, 0.08) 100%);
  border-radius: 16px;
  margin-top: 1.5rem;
}
.home-page .cta h2 { margin-bottom: 0.5rem; }
.home-page .cta p  { color: var(--muted); margin-bottom: 1.5rem; }

.visually-hidden {
  position: absolute !important; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

.hero {
  padding: 4rem 0 2.5rem;
  text-align: center;
  position: relative;
}
.gdpr-badge {
  display: inline-flex; align-items: center; gap: 0.6rem;
  padding: 0.4rem 0.7rem 0.4rem 0.4rem;
  border: 1px solid var(--primary);
  background: rgba(227, 6, 19, 0.10);
  color: var(--primary);
  border-radius: 999px;
  font-size: 0.85rem;
  margin-bottom: 1.25rem;
}
.gdpr-badge-mark {
  background: var(--primary); color: var(--primary-ink);
  font-weight: 800; letter-spacing: 0.05em;
  padding: 0.18rem 0.55rem; border-radius: 999px; font-size: 0.78rem;
}
.gdpr-badge-text { font-weight: 600; }
.hero h1 {
  font-size: clamp(2.2rem, 5.6vw, 3.6rem);
  margin-bottom: 0.4em;
  letter-spacing: -0.02em;
}
.hero h1 em { color: var(--primary); font-style: italic; }
.lede {
  font-size: 1.18rem;
  color: var(--text);
  max-width: 680px;
  margin: 0 auto 1.5rem;
}
.lede strong { color: var(--primary); }
.hero-cta { margin: 1.5rem 0 0.5rem; }
.primary.big { padding: 0.95rem 1.6rem; font-size: 1.05rem; border-radius: 10px; }
.micro { font-size: 0.85rem; color: var(--muted); }

/* Four "0 / 100%" pillars driving the GDPR-by-architecture pitch. */
.gdpr-pillars { padding: 1rem 0 2.5rem; }
.pillar-grid {
  display: grid; gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
}
.pillar {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1rem 1rem;
  text-align: center;
  box-shadow: var(--shadow);
  transition: transform 120ms ease, box-shadow 120ms ease, border-color 120ms ease;
}
.pillar::before {
  content: "";
  position: absolute;
  top: 0; left: 1rem; right: 1rem;
  height: 3px;
  background: linear-gradient(90deg, var(--primary-light), var(--primary), var(--primary-dark));
  border-radius: 0 0 3px 3px;
}
.pillar:hover {
  transform: translateY(-2px);
  border-color: var(--primary-light);
  box-shadow: 0 4px 14px rgba(20, 30, 60, 0.10);
}
.pillar-num {
  font-size: clamp(2.4rem, 5vw, 3.2rem);
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  letter-spacing: -0.02em;
}
.pillar-num .pct { font-size: 0.55em; vertical-align: super; margin-left: 0.05em; }
.pillar-label {
  font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em;
  font-size: 0.85rem; margin: 0.35rem 0 0.5rem;
}
.pillar p { font-size: 0.9rem; color: var(--muted); margin: 0; }

.how, .who, .why, .cta, .faq {
  padding: 2.5rem 0;
  border-top: 1px solid var(--border);
}
.who-grid {
  display: grid;
  gap: 0.85rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  margin-top: 1.25rem;
}

/* ── "What it does" feature showcase ────────────────────────────────── */

.features { padding: 2.5rem 0; border-top: 1px solid var(--border); }
.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 1rem;
  margin-top: 1.4rem;
}
.feature-card {
  background: var(--surface);
  border: 2px solid var(--ink, #111);
  border-radius: var(--radius);
  padding: 1.25rem 1.3rem 1.1rem;
  box-shadow: 4px 4px 0 var(--ink, #111);
}
.feature-card h3 {
  margin: 0 0 0.55rem;
  font-size: 1.15rem;
  display: flex;
  align-items: baseline;
  gap: 0.55rem;
}
.feature-card h3 .feature-num {
  display: inline-block;
  background: var(--accent, #fcd116);
  color: var(--ink, #111);
  font-weight: 800;
  font-size: 0.85rem;
  padding: 0.1rem 0.55rem;
  border-radius: 6px;
  border: 2px solid var(--ink, #111);
  min-width: 1.3rem;
  text-align: center;
}
.feature-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}
.feature-card ul li {
  position: relative;
  padding-left: 1.1rem;
  font-size: 0.92rem;
  color: var(--text);
  line-height: 1.4;
}
.feature-card ul li::before {
  content: "▸";
  position: absolute;
  left: 0;
  top: 0;
  color: var(--primary, #e30613);
  font-weight: 700;
}
.feature-card strong { color: var(--primary, #e30613); }

/* Headline-style cards used at the bottom of the feature section to
   surface the hospital-flow features (queue, shield, end-shift). */
.flow-cards {
  display: grid;
  gap: 0.95rem;
  margin-top: 1.4rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}
.flow-card {
  background: var(--accent, #fcd116);
  color: var(--ink, #111);
  border: 2px solid var(--ink, #111);
  border-radius: 12px;
  padding: 1rem 1.15rem;
  box-shadow: 4px 4px 0 var(--ink, #111);
}
.flow-card h4 {
  margin: 0 0 0.3rem;
  font-size: 1.05rem;
  font-weight: 800;
}
.flow-card p { margin: 0; font-size: 0.92rem; line-height: 1.4; }
.who-card {
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.1rem;
  box-shadow: 3px 3px 0 var(--border);
}
.who-tag {
  display: inline-block;
  background: var(--accent);
  color: #0f0f0f;
  border: 1.5px solid #0f0f0f;
  border-radius: 999px;
  padding: 0.15rem 0.65rem;
  font-size: 0.78rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 0.6rem;
}
.who-card p { margin: 0; font-size: 0.94rem; color: var(--text); }
html[data-theme="dark"] .who-card {
  box-shadow: 3px 3px 0 var(--accent);
}
.muted-h2 { color: var(--muted); font-weight: 400; font-size: 0.7em; }
.why-lede { font-size: 1.05rem; max-width: 700px; margin-bottom: 1.25rem; }

.faq details {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 1rem;
  margin-bottom: 0.5rem;
}
.faq details[open] { border-color: var(--primary); }
.faq summary { cursor: pointer; font-weight: 600; }
.faq summary::marker { color: var(--primary); }
.faq details > p { margin: 0.6rem 0 0; color: var(--muted); }
.how-steps {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 1.25rem;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
}
.how-steps li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.2rem;
}
.how-steps h3 { margin-bottom: 0.4em; color: var(--primary); }

.why-list {
  list-style: none;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}
.why-list li {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.9rem 1rem;
}

.cta { text-align: center; }

/* Pop-art footer: red ink top stripe with comic dots, oversized tagline, and
   nav links styled as chip-buttons with hard-offset shadows. */
.footer {
  position: relative;
  margin-top: 3rem;
  padding: 2.6rem 1.25rem 1.6rem;
  color: var(--text);
  font-size: 0.95rem;
  background: var(--surface);
  border-top: 3px solid #0f0f0f;
  background-image:
    radial-gradient(circle, rgba(15, 15, 15, 0.07) 1px, transparent 1.5px);
  background-size: 12px 12px;
  background-position: 0 0;
}
.footer::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 14px;
  background:
    repeating-linear-gradient(90deg,
      var(--primary) 0 18px,
      #0f0f0f 18px 22px,
      var(--accent) 22px 40px,
      #0f0f0f 40px 44px);
  border-bottom: 3px solid #0f0f0f;
}
.footer-inner {
  max-width: 980px;
  margin: 0 auto;
  display: grid;
  gap: 1.25rem;
  padding-top: 0.5rem;
}
.footer-tagline {
  margin: 0;
  font-size: 1.15rem;
  line-height: 1.4;
  font-weight: 600;
  color: var(--text);
  max-width: 720px;
}
.footer-tagline strong {
  color: var(--text);
  background: var(--accent);
  padding: 0 0.3em;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  border: 1.5px solid #0f0f0f;
  box-shadow: 2px 2px 0 #0f0f0f;
  display: inline-block;
  margin-right: 0.15em;
}
.footer-tagline em {
  color: var(--primary-ink);
  background: var(--primary);
  font-style: normal;
  font-weight: 800;
  padding: 0 0.3em;
  border: 1.5px solid #0f0f0f;
  box-shadow: 2px 2px 0 #0f0f0f;
  display: inline-block;
}

.footer-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem 0.6rem;
  align-items: center;
}
.footer-nav a, .footer-nav .link-btn {
  display: inline-block;
  color: var(--text);
  background: var(--surface);
  border: 2px solid #0f0f0f;
  border-radius: var(--radius);
  padding: 0.35rem 0.75rem;
  font-weight: 700;
  font-size: 0.88rem;
  text-decoration: none;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  box-shadow: 2px 2px 0 #0f0f0f;
  transition: transform 80ms ease, box-shadow 80ms ease, background-color 120ms ease;
}
.footer-nav a:hover, .footer-nav .link-btn:hover {
  background: var(--accent);
  transform: translate(-1px, -1px);
  box-shadow: 3px 3px 0 #0f0f0f;
  text-decoration: none;
}
.footer-nav a:active, .footer-nav .link-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 1px 1px 0 #0f0f0f;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font: inherit;
  color: var(--text);
}

.footer-attribution {
  margin: 0;
  font-size: 0.82rem;
  color: var(--muted);
  border-top: 1.5px dashed #0f0f0f;
  padding-top: 1rem;
}
.footer-attribution a {
  color: var(--text);
  background: var(--accent);
  font-weight: 800;
  padding: 0.05rem 0.4rem;
  border: 1.5px solid #0f0f0f;
  border-radius: 4px;
  text-decoration: none;
}
.footer-attribution a:hover { background: var(--primary); color: var(--primary-ink); }

html[data-theme="dark"] .footer {
  border-top-color: var(--accent);
  background-image:
    radial-gradient(circle, rgba(252, 209, 22, 0.07) 1px, transparent 1.5px);
}
html[data-theme="dark"] .footer::before { border-bottom-color: var(--accent); }
/* Dark footer = ONE yellow pop ("PRIVATE BY DESIGN.") + flat white text.
   The old layout stacked a yellow box next to a cream box next to a yellow
   chip — three competing highlights. Now: strong stays the single yellow
   block; em is plain bold cream text; the Artivicolab attribution is a
   simple underlined link, not a chip. */
html[data-theme="dark"] .footer-tagline strong {
  background: var(--accent);
  color: #1a1500;
  border-color: #1a1500;
  box-shadow: 2px 2px 0 #1a1500;
}
html[data-theme="dark"] .footer-tagline em {
  background: none;
  color: var(--text);
  border: 0;
  box-shadow: none;
  padding: 0;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
html[data-theme="dark"] .footer-nav a,
html[data-theme="dark"] .footer-nav .link-btn {
  border-color: var(--accent);
  box-shadow: 2px 2px 0 var(--accent);
}
html[data-theme="dark"] .footer-nav a:hover,
html[data-theme="dark"] .footer-nav .link-btn:hover {
  background: var(--accent);
  color: #1a1500;
  box-shadow: 3px 3px 0 var(--accent);
}
html[data-theme="dark"] .footer-nav a:active,
html[data-theme="dark"] .footer-nav .link-btn:active { box-shadow: 1px 1px 0 var(--accent); }
html[data-theme="dark"] .footer-attribution { border-top-color: var(--accent); }
html[data-theme="dark"] .footer-attribution a {
  background: none;
  color: var(--text);
  border: 0;
  box-shadow: none;
  padding: 0;
  text-decoration: underline;
  text-decoration-color: var(--accent);
  text-underline-offset: 3px;
}
html[data-theme="dark"] .footer-attribution a:hover {
  background: none;
  color: var(--accent);
}

@media print { .footer { display: none !important; } }

/* ── Paper-print rendering ───────────────────────────────────────────
   Static, no-real-inputs version of a form, generated at print time.
   These styles intentionally live outside @media print so the container
   renders identically on screen if you ever debug it. */
#print-container {
  width: 100%;
  color: #000;
  font: 12pt/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
#print-container .paper-title {
  margin: 0 0 0.2rem;
  font-size: 18pt;
  font-weight: 700;
  letter-spacing: -0.01em;
}
#print-container .paper-desc {
  margin: 0 0 1rem;
  font-size: 10.5pt;
  color: #444;
}
#print-container .paper-form {
  width: 100%;
  border: 1px solid #555;
  border-top: none;
}
#print-container .paper-section {
  background: #eaeaea;
  border-top: 1px solid #555;
  padding: 0.45rem 0.7rem;
  font-weight: 700;
  font-size: 10.5pt;
  -webkit-print-color-adjust: exact;
  print-color-adjust: exact;
}
#print-container .paper-section-desc {
  font-weight: 400;
  font-size: 9.5pt;
  color: #444;
  margin-top: 0.15rem;
}
#print-container .paper-row {
  display: flex;
  border-top: 1px solid #555;
}
#print-container .paper-cell {
  padding: 0.5rem 0.7rem 0.65rem;
}
#print-container .paper-cell.full    { flex: 1 1 100%;    }
#print-container .paper-cell.half    { flex: 1 1 50%;     }
#print-container .paper-cell.third   { flex: 1 1 33.333%; min-width: 0; }
#print-container .paper-cell.quarter { flex: 1 1 25%;     min-width: 0; }
#print-container .paper-cell.half:only-child,
#print-container .paper-cell.third:only-child,
#print-container .paper-cell.quarter:only-child { flex: 1 1 100%; }
#print-container .paper-cell.half    + .paper-cell.half,
#print-container .paper-cell.third   + .paper-cell.third,
#print-container .paper-cell.quarter + .paper-cell.quarter { border-left: 1px solid #555; }
#print-container .paper-label {
  font-size: 10pt;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
#print-container .paper-label .req { color: #b03030; }
#print-container .paper-hint {
  font-size: 9pt;
  color: #555;
  margin: -0.3rem 0 0.5rem;
}
#print-container .paper-line {
  border-bottom: 1px solid #777;
  height: 1.6em;
  margin-bottom: 0.35rem;
}
#print-container .paper-line.filled {
  height: auto;
  padding: 0.1rem 0;
  font-weight: 500;
}
#print-container .paper-block.filled {
  border: 1px solid #777;
  padding: 0.4rem 0.55rem;
  min-height: 4.2em;
  white-space: pre-wrap;
}
#print-container .paper-date {
  letter-spacing: 0.04em;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 10pt;
  color: #555;
}
#print-container .paper-date span {
  display: inline-block;
  border-bottom: 1px solid #777;
  padding: 0 0.25em;
  margin: 0 0.15em;
}
#print-container .paper-choices {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  margin-top: 0.1rem;
}
#print-container .paper-choice {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 10.5pt;
}
#print-container .paper-box {
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  border: 1px solid #444;
  border-radius: 2px;
  flex-shrink: 0;
  position: relative;
}
#print-container .paper-box.checked::after {
  content: "✓";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95em;
  font-weight: 800;
  color: #000;
}

/* ── Print ─────────────────────────────────────────────────────────── */

@media print {
  /* @page margin:0 + body padding lets us draw to the paper edges and is
     the most reliable way to suppress the browser's auto-inserted header
     (date / page title at top) and footer (URL / page number at bottom).
     Some browsers still honor the user's "Headers and footers" dialog box;
     this at least pulls them out of the printable area. */
  @page { size: A4 portrait; margin: 0; }

  html, body {
    background: #fff !important;
    color: #000 !important;
    width: 100% !important;
    max-width: none !important;
    margin: 0 !important;
  }
  body {
    display: block !important;
    min-height: 0 !important;
    padding: 14mm !important;
  }
  body::before, body::after, .bg-mirror { display: none !important; }
  .topbar, .actions, .toast, .session-code, .net-status, .conn-status { display: none !important; }
  .patient-form, .answers-live { border-color: #555; box-shadow: none; }
  .intake-row, .intake-section { border-color: #555; }
  .intake-cell.half + .intake-cell.half { border-left-color: #555; }
  .intake-section { -webkit-print-color-adjust: exact; print-color-adjust: exact; background: #eaeaea !important; }

  /* JS builds a #print-container at body level with a static paper-style
     form (no real inputs). Hide everything else and show only that. The
     paper-* element styles live outside @media print at the top of this
     section so the same rules apply on screen for debugging. */
  body.printing-preview > * { display: none !important; }
  body.printing-preview > #print-container { display: block !important; }
}

/* ── Dashboard: sender + active sessions ─────────────────────────────── */

.dash-section { margin-bottom: 2rem; }
.dash-section h2 { margin-top: 0; }
.dash-section h2 .small { font-size: 0.8rem; font-weight: normal; }

.dash-sender {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.1rem;
  background: var(--surface-2);
  margin-top: 0.75rem;
}
.dash-sender-row {
  display: grid;
  grid-template-columns: minmax(220px, 1.4fr) minmax(180px, 1.4fr) auto;
  gap: 0.75rem;
  align-items: end;
}
.dash-sender-field span {
  display: block;
  font-size: 0.85rem;
  margin-bottom: 0.25rem;
  color: var(--muted);
}
.dash-sender-field select,
.dash-sender-field input {
  width: 100%;
  box-sizing: border-box;
}
@media (max-width: 720px) {
  .dash-sender-row { grid-template-columns: 1fr; }
}

.active-sessions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.active-sessions .empty {
  padding: 1rem 1.1rem;
  border: 1px dashed var(--border);
  border-radius: 10px;
  margin: 0;
}

.session-card {
  border: 1px solid var(--border);
  border-left: 4px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  overflow: hidden;
}
.session-card.state-waiting       { border-left-color: #d3a317; }
.session-card.state-connecting    { border-left-color: #4a90e2; }
.session-card.state-connected     { border-left-color: #2f9e44; }
.session-card.state-disconnected  { border-left-color: #c0392b; }
.session-card.state-submitted     { border-left-color: #5b6ee1; }
.session-card.state-closed        { border-left-color: #999; opacity: 0.65; }
.session-card.state-dormant       { border-left-color: #8b6c2c; background: rgba(211,163,23,0.06); }

.session-card-head {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1.4fr) minmax(0, 1.6fr) auto auto auto;
  gap: 0.6rem;
  align-items: center;
  padding: 0.55rem 0.85rem;
  font-size: 0.9rem;
}
/* Matches the builder's .field-toggle: a boxed caret that rotates -90°
   when collapsed, yellow on hover. Glyph is always ▾; CSS handles the
   direction via [aria-expanded]. */
.session-card-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  color: var(--text);
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 140ms ease, background-color 120ms ease, border-color 120ms ease;
}
.session-card-toggle[aria-expanded="false"] { transform: rotate(-90deg); }
.session-card-head:hover .session-card-toggle,
.session-card-toggle:hover {
  background: var(--accent);
  border-color: #0f0f0f;
}
.session-card-id {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
  color: var(--muted);
}
.session-card-label {
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-card-title {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.session-card-sas {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.8rem;
}
.session-card-time {
  font-variant-numeric: tabular-nums;
  color: var(--muted);
  font-size: 0.85rem;
}
.session-card-state {
  font-size: 0.8rem;
  padding: 0.15rem 0.5rem;
  border-radius: 999px;
  background: rgba(0,0,0,0.05);
  white-space: nowrap;
}
.session-card.state-connected    .session-card-state { background: rgba(47,158,68,0.15);  color: #1f7a30; }
.session-card.state-waiting      .session-card-state { background: rgba(211,163,23,0.18); color: #8a6800; }
.session-card.state-connecting   .session-card-state { background: rgba(74,144,226,0.18); color: #1e5a9e; }
.session-card.state-disconnected .session-card-state { background: rgba(192,57,43,0.15);  color: #9c2a1f; }
.session-card.state-submitted    .session-card-state { background: rgba(91,110,225,0.18); color: #3a48ad; }
.session-card.state-dormant      .session-card-state { background: rgba(139,108,44,0.18); color: #6b5219; }

/* Dark mode: the light tint + dark-ink pills are unreadable on a dark
   card. The card's coloured left-border already signals state, so the
   pill just needs to be legible — translucent dark chip, cream text. */
html[data-theme="dark"] .session-card-state {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}
html[data-theme="dark"] .session-card.state-connected    .session-card-state,
html[data-theme="dark"] .session-card.state-waiting      .session-card-state,
html[data-theme="dark"] .session-card.state-connecting   .session-card-state,
html[data-theme="dark"] .session-card.state-disconnected .session-card-state,
html[data-theme="dark"] .session-card.state-submitted    .session-card-state,
html[data-theme="dark"] .session-card.state-dormant      .session-card-state {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.session-card-body {
  padding: 0.75rem 0.85rem 1rem;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
/* `display: flex` above beats the UA [hidden]{display:none}, so the body
   never actually collapsed. Force it. */
.session-card-body[hidden] { display: none !important; }
.session-card-body .readonly-field { margin: 0; }
.session-card-body .copy-row { display: flex; gap: 0.4rem; }
.session-card-body .copy-row input { flex: 1; min-width: 0; }
.session-card-body textarea { width: 100%; box-sizing: border-box; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85rem; }

.card-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.card-preview {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0.6rem;
  background: var(--surface-2);
  max-height: 360px;
  overflow: auto;
}
.card-preview .patient-form { border: 0; padding: 0; box-shadow: none; }

@media (max-width: 720px) {
  /* Drop the 7-col grid entirely on mobile — it never aligned cleanly.
     Simple flex-wrap: toggle + id + state on line 1, then the big label,
     then title + time. Each piece on its own row, left-aligned. */
  .session-card-head {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.5rem;
    padding: 0.7rem 0.85rem;
  }
  .session-card-toggle { order: 1; flex: 0 0 auto; }
  .session-card-id     { order: 2; flex: 0 0 auto; }
  .session-card-state  { order: 3; flex: 0 0 auto; margin-left: auto; }
  .session-card-label  {
    order: 4;
    flex: 1 0 100%;
    font-size: 1.05rem;
    font-weight: 800;
    white-space: normal;          /* allow the ticket/name to wrap */
  }
  .session-card-title  {
    order: 5;
    flex: 1 1 auto;
    white-space: normal;
  }
  .session-card-sas    { order: 6; flex: 0 0 auto; }
  .session-card-time   { order: 7; flex: 0 0 auto; margin-left: auto; }
}

