:root {
  --ink: #2b211b;
  --muted: #7a6d63;
  --line: #e6ddd4;
  --bg: #f6f1ec;
  --card: #fff;
  --accent: #7a5236;   /* bronze from the logo; 6.9:1 against white */
  --accent-ink: #fff;
  --gold: #b08a6a;
  --focus: #2b5fd9;
  --error: #b42318;
  --ok: #157f3c;
  --radius: 14px;
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans Hebrew", Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html { -webkit-tap-highlight-color: transparent; } /* replaced by our own :active states */
body { margin: 0; padding: 0 0 env(safe-area-inset-bottom); line-height: 1.5; }
main { max-width: 760px; margin: 0 auto; padding: 0 14px 40px; }
body.admin main { max-width: 1000px; }

.brand { text-align: center; padding: 22px 12px 10px; }
/* The logo is on white; multiply drops the white into the cream page background. */
.logo-img { display: block; width: min(210px, 58vw); height: auto; margin: 0 auto; mix-blend-mode: multiply; }
.logo-img.small { width: 150px; }
.tagline { font-size: 14px; color: var(--muted); letter-spacing: 0.08em; margin-top: 4px; }

h1 { font-size: 21px; line-height: 1.3; letter-spacing: -0.01em; margin: 0 0 6px; text-align: center; font-weight: 600; color: var(--accent); }
h2 { font-size: 17px; margin: 0 0 12px; padding-bottom: 8px; border-bottom: 1px solid var(--gold); color: var(--ink); }
.card h2:not(:first-child) { margin-top: 22px; }
.intro { color: var(--muted); text-align: center; margin: 0 0 18px; font-size: 15px; }
.prompt { color: var(--muted); margin: -4px 0 10px; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; }
.warn { background: #fff4e5; border: 1px solid #f5c37a; border-radius: 10px; padding: 10px 12px; font-size: 14px; }
.loading { text-align: center; color: var(--muted); padding: 40px 0; }
.error-box { background: #fdecea; border: 1px solid #f1b0aa; color: var(--error); border-radius: var(--radius); padding: 16px; text-align: center; }

.card { background: var(--card); border-radius: var(--radius); padding: 18px 16px; margin: 0 0 14px; box-shadow: 0 1px 3px rgb(90 60 40 / 8%); }
.card.narrow { max-width: 460px; margin: 0 auto 14px; }

.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 4px; grid-column: span 2; }
.field.half { grid-column: span 1; }
@media (min-width: 560px) { .grid .field:not(.wide) { grid-column: span 1; } }
label { font-size: 15px; }
.req { color: var(--error); }
input[type=text], input[type=tel], input[type=email], input[type=date], input[type=number], input[type=password], input[type=search], input:not([type]) {
  font: inherit; font-size: 16px; /* 16px stops iOS from zooming in */
  padding: 10px 12px; border: 1px solid #c9c9d1; border-radius: 10px; background: #fff; color: var(--ink); width: 100%; min-height: 44px;
}
.date-input { text-align: right; letter-spacing: 0.04em; font-variant-numeric: tabular-nums; }
.date-input::placeholder { letter-spacing: 0.1em; color: #b5a99f; }
input:focus-visible, button:focus-visible, .seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: 1px; }
input[aria-invalid=true] { border-color: var(--error); background: #fff8f7; }
.field-error { color: var(--error); font-size: 13px; min-height: 0; }
.field-error:empty { display: none; }

.items { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 12px; }
.items .wide, .items .field { grid-column: 1 / -1; }
.items-yesno { grid-template-columns: 1fr; }
@media (min-width: 560px) { .items-yesno { grid-template-columns: 1fr 1fr; } }

.check-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 6px; margin-inline: -6px; border-radius: 10px; cursor: pointer; min-height: 44px; }
.check-row input[type=checkbox] { width: 22px; height: 22px; margin: 1px 0 0; flex: none; accent-color: var(--accent); }
.check.none { border-bottom: 1px solid var(--line); padding-bottom: 4px; margin-bottom: 2px; }
.check.none span { font-weight: 600; }
.card.invalid { box-shadow: 0 0 0 2px var(--error); }
.section-error { margin-top: 6px; }
.check .detail { margin: 0 32px 6px 0; width: calc(100% - 32px); }

.yesno { border: 0; margin: 0; padding: 6px 0; display: flex; align-items: center; justify-content: space-between; gap: 10px; border-bottom: 1px solid #f0f0f3; }
.yesno legend { float: right; padding: 0; font-size: 15px; }
.yesno.invalid legend { color: var(--error); font-weight: 600; }
.yesno.invalid .seg { outline: 2px solid var(--error); border-radius: 12px; }
.seg { display: inline-flex; gap: 6px; flex: none; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; }
.seg span { display: inline-block; min-width: 58px; text-align: center; padding: 8px 12px; border: 1px solid #c9c9d1; border-radius: 10px; font-size: 15px; }
.seg input:checked + span { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.declaration { background: #faf6f2; border-radius: 10px; padding: 12px; margin: 0 0 6px; font-size: 15px; }
.consent span { font-size: 14px; }
.sig-head { display: flex; justify-content: space-between; align-items: center; margin-top: 10px; font-weight: 600; }
.sig-box { position: relative; border: 2px dashed var(--gold); border-radius: 12px; background: #fff; }
.sig-canvas { display: block; width: 100%; height: 190px; touch-action: none; cursor: crosshair; }
.sig-line { position: absolute; bottom: 8px; right: 0; left: 0; text-align: center; color: #a5a5ae; font-size: 13px; pointer-events: none; }

button { font: inherit; cursor: pointer; }
button.primary { display: block; width: 100%; min-height: 50px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-size: 17px; font-weight: 600; margin-top: 10px; }
button.primary:disabled { opacity: 0.6; cursor: progress; }
button.link { background: none; border: 0; color: var(--accent); text-decoration: underline; text-underline-offset: 3px; padding: 6px 8px; font-size: 15px; }
button.small { border: 1px solid #c9c9d1; background: #fff; border-radius: 8px; padding: 6px 10px; font-size: 14px; white-space: nowrap; }
.status { color: var(--error); margin: 10px 0 0; font-size: 15px; text-align: center; }
.status:empty { display: none; }
.hp { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }

.done { text-align: center; padding: 34px 18px; }
.done-mark { width: 64px; height: 64px; line-height: 64px; margin: 0 auto 12px; border-radius: 50%; background: #f3eae2; color: var(--accent); font-size: 34px; }

/* admin */
.toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 10px; }
.toolbar h1 { margin: 0; text-align: right; }
.toolbar-actions { display: flex; gap: 4px; flex-wrap: wrap; justify-content: center; }
.search-row { display: flex; gap: 12px; align-items: center; margin-bottom: 10px; }
.search-row input { flex: 1; }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 15px; }
th, td { text-align: right; padding: 9px 8px; border-bottom: 1px solid #ececf0; }
th { font-size: 13px; color: var(--muted); font-weight: 600; }
td.num { white-space: nowrap; font-variant-numeric: tabular-nums; }
td.empty { text-align: center; color: var(--muted); padding: 24px; }
.qr { width: 220px; margin: 8px auto; }
.qr svg { width: 100%; height: auto; display: block; }
.qr-dialog { border: 0; border-radius: var(--radius); padding: 24px; text-align: center; max-width: 92vw; }
.qr-dialog .qr { width: 300px; }
code { background: #f1f1f4; padding: 2px 6px; border-radius: 6px; word-break: break-all; }

@media print {
  body > *:not(dialog) { display: none !important; }
  .qr-dialog { position: static; box-shadow: none; }
  .qr-dialog button { display: none; }
}

/* Press feedback the moment a finger lands (not on release), short and without overshoot. */
button.primary, button.small, .check-row, .seg span { transition: transform 120ms ease-out, background-color 120ms ease-out; }
button.primary:active:not(:disabled) { transform: scale(0.98); background: #684530; }
button.small:active, .check-row:active { background: #f5eee8; }
button.link:active { opacity: 0.6; }
.seg label:active span { transform: scale(0.95); }

/* Completion: the check mark settles in once (critically damped, no bounce). */
.done-mark { animation: settle 380ms cubic-bezier(0.2, 0.8, 0.2, 1) both; }
@keyframes settle { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
@media (prefers-contrast: more) {
  :root { --muted: #4f453e; --line: #8f8379; --gold: #6f5440; }
  input[type=text], input[type=tel], input[type=email], input[type=number], input[type=password], input[type=search], .seg span { border-color: #5c5148; }
  .sig-box { border-style: solid; }
}
