/* event-forms: mobile first, 16px gutters, light and dark. */
:root {
  --bg: #ffffff;
  --fg: #1d1d1f;
  --muted: #555;
  --line: #c8c8cc;
  --card: #f5f5f7;
  --accent: #7413dc; /* Scouts purple */
  --accent-fg: #ffffff;
  --focus: #ffb81c;
  --error: #b00020;
  --ok: #1a7f37;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #161618;
    --fg: #ececee;
    --muted: #a8a8ad;
    --line: #48484d;
    --card: #222225;
    --accent: #b37cf0;
    --accent-fg: #111;
    --error: #ff8a8a;
    --ok: #6fd28b;
  }
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow-x: hidden;
}
.wrap { max-width: 42rem; margin: 0 auto; padding: 16px; }
h1 { font-size: 1.6rem; line-height: 1.2; margin: 0.2rem 0 0.6rem; }
h2 { font-size: 1.2rem; margin: 0 0 0.6rem; }
.group { margin: 0; color: var(--muted); font-weight: 600; }
a { color: var(--accent); }
small, .hint { color: var(--muted); }
.hint { margin: 0 0 0.3rem; font-size: 0.95rem; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

.step { border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px 16px; margin: 0 0 16px; min-width: 0; }
.step legend, .step h2 { font-weight: 700; font-size: 1.1rem; padding: 0 4px; }
.n {
  display: inline-block; min-width: 1.6em; height: 1.6em; line-height: 1.6em; text-align: center;
  border-radius: 50%; background: var(--accent); color: var(--accent-fg); font-size: 0.9rem; margin-right: 4px;
}

.choice {
  display: flex; gap: 12px; align-items: flex-start; padding: 12px; margin: 8px 0 0;
  border: 1px solid var(--line); border-radius: 10px; background: var(--card); cursor: pointer; min-height: 48px;
}
.choice:has(input:checked) { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.choice input, .check input { width: 22px; height: 22px; margin: 2px 0 0; flex: none; accent-color: var(--accent); }
.check { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0 0; min-height: 44px; cursor: pointer; }

.field { margin: 14px 0 0; }
.field > label { display: block; font-weight: 600; margin-bottom: 4px; }
input[type="text"], input:not([type]), input[type="tel"], input[type="email"], input[type="date"], textarea {
  display: block; width: 100%; max-width: 100%; font: inherit; font-size: 16px; color: var(--fg);
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; min-height: 48px;
}
input.short { max-width: 14rem; }
input[type="date"] { appearance: none; -webkit-appearance: none; }
textarea { resize: vertical; min-height: 6.5rem; }
input[type="file"] { font: inherit; max-width: 100%; min-height: 48px; }
input:focus-visible, textarea:focus-visible, button:focus-visible, a:focus-visible, .choice:has(input:focus-visible) {
  outline: 3px solid var(--focus); outline-offset: 2px;
}
input[aria-invalid="true"], textarea[aria-invalid="true"] { border-color: var(--error); }
.count { text-align: right; margin-top: 2px; }

button, .button {
  display: inline-block; font: inherit; font-weight: 600; font-size: 1rem; min-height: 48px; padding: 10px 18px;
  border-radius: 10px; border: 1px solid var(--accent); background: var(--accent); color: var(--accent-fg);
  cursor: pointer; text-decoration: none; text-align: center; max-width: 100%;
}
button.secondary, .button.secondary { background: transparent; color: var(--accent); }
button:disabled { opacity: 0.6; cursor: wait; }

.fixed { background: var(--card); border-radius: 8px; padding: 8px 12px; margin: 8px 0 0; }
.fixed p { margin: 0.2rem 0; }
.fixed dl { margin: 0.2rem 0; display: grid; grid-template-columns: auto 1fr; gap: 2px 12px; }
.fixed dt { color: var(--muted); }
.fixed dd { margin: 0; font-weight: 600; overflow-wrap: anywhere; }

/* the signature pad stays paper-white in dark mode: ink is dark */
.pad-wrap { border: 2px dashed var(--line); border-radius: 10px; background: #fff; touch-action: none; }
#pad { display: block; width: 100%; height: 180px; touch-action: none; cursor: crosshair; }
.sig-preview { margin: 12px 0 0; }
.sig-preview img { display: block; max-width: 100%; max-height: 160px; background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 6px; }
.sig-preview figcaption { color: var(--muted); font-size: 0.95rem; margin-top: 4px; }
.typed-show { font: italic 1.8rem/1.3 "Times New Roman", Times, serif; min-height: 2.4rem; margin: 10px 0 0; overflow-wrap: anywhere; }
.links { padding-left: 1.2rem; }
.links li { margin: 6px 0; }

#preview-frame { display: block; width: 100%; height: 70vh; min-height: 420px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
#message { margin-top: 10px; }
#message .error, .alert { color: var(--error); font-weight: 600; }
#message .ok { color: var(--ok); font-weight: 600; }
.privacy { font-size: 0.95rem; color: var(--muted); border-top: 1px solid var(--line); padding-top: 12px; margin-top: 24px; }
.privacy h2 { font-size: 1rem; color: var(--fg); }

/* admin */
.admin .bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 8px 0 12px; }
.admin select { font: inherit; font-size: 16px; min-height: 44px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: var(--bg); color: var(--fg); }
.admin .wide { max-width: 72rem; }
.admin table.subs { width: 100%; border-collapse: collapse; }
.admin .subs th, .admin .subs td { text-align: left; vertical-align: top; padding: 8px; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.admin .subs th { font-size: 0.9rem; color: var(--muted); overflow-wrap: normal; }
.admin .subs tr.downloaded td { color: var(--muted); }
.admin .subs td.actions { white-space: nowrap; }
.admin .subs td.actions > * { margin: 0 6px 6px 0; }
.admin .subs tr.confirm-row td { border-bottom: 0; }
/* a phone: each form becomes a card, each cell labelled */
@media (max-width: 760px) {
  .admin .subs thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .admin .subs, .admin .subs tbody, .admin .subs tr, .admin .subs td { display: block; width: 100%; }
  .admin .subs tr:not(.confirm-row) { border: 1px solid var(--line); border-radius: 10px; background: var(--card); padding: 6px 4px; margin: 0 0 10px; }
  .admin .subs td { border: 0; padding: 3px 8px; }
  .admin .subs td[data-label]:not([data-label=""])::before { content: attr(data-label) ": "; color: var(--muted); }
  .admin .subs td:empty { display: none; }
}
.admin .confirm { border: 2px solid var(--error); border-radius: 10px; padding: 10px 12px; margin-top: 8px; }
.admin button.danger { background: var(--error); border-color: var(--error); color: #fff; }
