*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }

:root {
  --bg: #f4f5f8;
  --surface: #ffffff;
  --border: #e3e5ec;
  --text: #161821;
  --muted: #6b7080;
  --accent: #2f7de1;
  --accent-text: #ffffff;
  --ok: #1f9d55;
  --danger: #d64545;
  --alert-bg: #fff4e5;
  --alert-text: #8a4b00;
  --radius: 14px;
  --font: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --border: #2a2d3a;
    --text: #e8eaf1;
    --muted: #9095a6;
    --accent: #4a9eff;
    --ok: #3ddc84;
    --danger: #ff6b6b;
    --alert-bg: #3a2a12;
    --alert-text: #ffcf8a;
  }
}

html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg); color: var(--text); font-family: var(--font); font-size: 16px; line-height: 1.5;
  min-height: 100vh; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
a { color: var(--accent); }

.top { display: flex; align-items: center; gap: 10px; padding: 14px 16px; font-weight: 650; max-width: 720px; width: 100%; margin: 0 auto; }
.top img { border-radius: 7px; }
.top span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.wrap { flex: 1; width: 100%; max-width: 720px; margin: 0 auto; padding: 0 16px 24px; display: flex; flex-direction: column; gap: 14px; }
.foot { text-align: center; padding: 18px 16px 28px; font-size: .85em; color: var(--muted); }
.foot a { color: var(--muted); }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 20px 18px; }
.card.center { text-align: center; }
.card.center .btn { margin-top: 16px; }
h1 { font-size: 1.45em; line-height: 1.25; margin-bottom: 10px; }
h2 { font-size: 1.1em; margin-bottom: 10px; }
p + p { margin-top: 8px; }
.lead { color: var(--muted); }
.muted { color: var(--muted); }
.small { font-size: .85em; margin-top: 10px; }
.ok { color: var(--ok); font-weight: 600; }
.alert { background: var(--alert-bg); color: var(--alert-text); padding: 10px 12px; border-radius: 10px; margin: 10px 0; font-size: .92em; }

.steps { list-style: none; counter-reset: s; margin-top: 16px; display: grid; gap: 12px; }
.steps li { counter-increment: s; display: grid; grid-template-columns: 34px 1fr; column-gap: 12px; }
.steps li::before { content: counter(s); grid-row: span 2; width: 34px; height: 34px; border-radius: 50%; background: var(--accent); color: var(--accent-text); display: grid; place-items: center; font-weight: 700; }
.steps span { color: var(--muted); font-size: .92em; }
.facts { padding-left: 20px; display: grid; gap: 6px; font-size: .93em; }
.prose h2 { margin-top: 20px; }
.prose ul { padding-left: 20px; display: grid; gap: 6px; }

.consent { margin-top: 16px; display: grid; gap: 12px; }
.check { display: grid; grid-template-columns: 24px 1fr; gap: 10px; font-size: .92em; align-items: start; }
.check input { width: 22px; height: 22px; margin-top: 2px; accent-color: var(--accent); }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 0 18px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn.danger { color: var(--danger); border-color: transparent; background: transparent; }
.btn.small { min-height: 38px; font-size: .9em; padding: 0 12px; }
.btn.block { display: flex; width: 100%; }
.btn:disabled { opacity: .5; }
.actions { display: grid; gap: 10px; margin-top: 14px; }

label { display: block; font-size: .88em; color: var(--muted); margin: 14px 0 6px; }
select, input[type=email] {
  width: 100%; min-height: 46px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text); font: inherit;
}
.row { display: flex; gap: 8px; }
.row input { flex: 1; min-width: 0; }

.camera { position: relative; margin-top: 14px; aspect-ratio: 3/4; max-height: 60vh; border-radius: var(--radius); overflow: hidden; background: #000; display: grid; place-items: center; }
.camera video, .camera img { width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1); }
.cam-placeholder { font-size: 54px; opacity: .6; }

.spinner { width: 42px; height: 42px; margin: 6px auto 16px; border: 4px solid var(--border); border-top-color: var(--accent); border-radius: 50%; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.ios-hint { background: var(--bg); border-radius: 10px; padding: 12px 14px; font-size: .92em; }
.ios-hint ol { padding-left: 20px; margin: 8px 0 0; display: grid; gap: 4px; }
.share-icon { display: inline-block; border: 1.5px solid currentColor; border-radius: 4px; padding: 0 3px; font-size: .8em; }

.gallery-head { display: flex; align-items: baseline; justify-content: space-between; padding: 6px 2px 0; }
.gallery-head h2 { margin: 0; }
.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; }
@media (min-width: 560px) { .gallery { grid-template-columns: repeat(4, 1fr); } }
.tile { position: relative; aspect-ratio: 1; border: 0; padding: 0; background: var(--border); border-radius: 6px; overflow: hidden; cursor: pointer; }
.tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tile .new { position: absolute; top: 6px; left: 6px; background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; padding: 1px 7px; border-radius: 99px; }
.empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 30px 16px; background: var(--surface); border: 1px dashed var(--border); border-radius: var(--radius); }

.lightbox { position: fixed; inset: 0; z-index: 10; background: #000; display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top) + 50px) 0 calc(env(safe-area-inset-bottom) + 90px); }
.lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.lb-close { position: absolute; top: calc(env(safe-area-inset-top) + 8px); right: 12px; }
.lb-nav { position: absolute; top: 50%; transform: translateY(-50%); font-size: 40px; }
.lb-nav.prev { left: 4px; } .lb-nav.next { right: 4px; }
.lb-close, .lb-nav { background: none; border: 0; color: #fff; width: 48px; height: 48px; font-size: 26px; cursor: pointer; }
.lb-actions { position: absolute; bottom: calc(env(safe-area-inset-bottom) + 18px); left: 16px; right: 16px; display: flex; gap: 10px; justify-content: center; }
.lb-actions .btn { flex: 1; max-width: 220px; }
.lb-actions .btn:not(.primary) { background: rgba(255,255,255,.12); color: #fff; border-color: transparent; }
