:root {
  --paper: #f4f3ed;
  --paper-deep: #e9e8e0;
  --ink: #14231d;
  --muted: #5f6964;
  --line: #c9cdc6;
  --forest: #163d2d;
  --forest-light: #dce7df;
  --white: #fff;
  --yes: 40 150 92;
  --no: 210 63 62;
  --serif: "Source Serif 4", Georgia, serif;
  --sans: "Source Sans 3", Arial, sans-serif;
  --mono: "IBM Plex Mono", monospace;
}

* { box-sizing: border-box; }
html, body { min-width: 320px; min-height: 100%; margin: 0; }
body { background: var(--paper); color: var(--ink); font-family: var(--sans); letter-spacing: 0; }
button, input { font: inherit; letter-spacing: 0; }
button { cursor: pointer; }
.study-app { min-height: 100svh; }
.screen { display: none; min-height: 100svh; }
.screen.is-active { display: flex; }
.study-kicker { margin: 0 0 18px; color: var(--forest); font-family: var(--mono); font-size: 0.7rem; font-weight: 500; letter-spacing: 0; text-transform: uppercase; }

.access-screen, .setup-screen, .completion-screen { flex-direction: column; padding: max(24px, env(safe-area-inset-top)) clamp(22px, 5vw, 72px) max(20px, env(safe-area-inset-bottom)); background: linear-gradient(90deg, transparent 0 74%, rgba(20,35,29,0.035) 74% 100%), var(--paper); }
.study-brand, .compact-header { display: flex; align-items: center; justify-content: space-between; min-height: 54px; }
.study-brand { justify-content: flex-start; }
.study-brand div { display: grid; gap: 1px; }
.study-brand strong { font-family: var(--serif); font-size: 1rem; font-weight: 600; }
.study-brand span { color: var(--muted); font-size: 0.7rem; }
.access-layout, .setup-layout { display: grid; grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr); gap: clamp(48px, 8vw, 130px); align-items: center; width: min(1180px, 100%); margin: auto; padding: 64px 0; }
.access-intro h1, .setup-copy h1, .completion-content h1 { max-width: 760px; margin: 0; font-family: var(--serif); font-size: clamp(3.6rem, 7.4vw, 7.6rem); font-weight: 500; line-height: 0.94; }
.access-intro h1 { line-height: 1.02; }
.access-lede { max-width: 630px; margin: 30px 0; color: var(--muted); font-family: var(--serif); font-size: clamp(1.15rem, 1.7vw, 1.5rem); line-height: 1.45; }
.study-facts { display: grid; grid-template-columns: repeat(3, 1fr); max-width: 650px; margin: 38px 0 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.study-facts div { min-height: 84px; padding: 17px 16px 16px 0; border-right: 1px solid var(--line); }
.study-facts div + div { padding-left: 16px; }
.study-facts div:last-child { border-right: 0; }
.study-facts dt, .completion-summary dt { color: var(--muted); font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; }
.study-facts dd, .completion-summary dd { margin: 8px 0 0; font-size: 0.92rem; font-weight: 600; }

.code-panel, .gift-panel { position: relative; display: grid; gap: 15px; padding: clamp(28px, 4vw, 48px); border-top: 4px solid var(--forest); background: var(--white); box-shadow: 0 18px 60px rgba(20,35,29,0.08); }
.gift-delivery-note { display: grid; gap: 5px; padding: 16px 0; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.gift-delivery-note strong { font-size: 0.82rem; }
.gift-delivery-note span { color: var(--muted); font-size: 0.75rem; line-height: 1.5; }
.panel-number { position: absolute; top: 20px; right: 24px; color: #98a19c; font-family: var(--mono); font-size: 0.72rem; }
.code-panel h2, .gift-panel h2 { margin: 0; padding-right: 36px; font-family: var(--serif); font-size: clamp(2rem, 3vw, 2.7rem); font-weight: 600; line-height: 1; }
.code-panel > p:not(.study-kicker):not(.form-message), .gift-panel > p:not(.study-kicker):not(.form-message) { margin: 0 0 8px; color: var(--muted); font-size: 0.88rem; line-height: 1.5; }
.code-panel label, .gift-panel > label:not(.consent-line), .gift-methods legend { color: var(--muted); font-family: var(--mono); font-size: 0.65rem; font-weight: 500; text-transform: uppercase; }
.code-panel input, .gift-panel > input { width: 100%; min-height: 58px; padding: 0 15px; border: 1px solid #9ba39e; border-radius: 0; outline: 0; background: #fbfbf8; color: var(--ink); }
.code-panel input { font-family: var(--mono); font-size: 1.4rem; text-align: center; text-transform: uppercase; }
.code-panel input:focus, .gift-panel > input:focus { border-color: var(--forest); box-shadow: inset 0 0 0 1px var(--forest); }
.primary-action { display: flex; align-items: center; justify-content: space-between; min-height: 56px; padding: 0 18px; border: 1px solid var(--forest); border-radius: 0; background: var(--forest); color: var(--white); font-weight: 600; }
.primary-action:hover { background: #0e3022; }
.primary-action:disabled { cursor: wait; opacity: 0.62; }
.form-message { min-height: 18px; margin: 0; color: var(--muted); font-size: 0.72rem; }
.form-message.is-error { color: #9c2629; }
.study-footer { display: flex; justify-content: space-between; padding-top: 18px; border-top: 1px solid var(--line); color: var(--muted); font-family: var(--mono); font-size: 0.62rem; text-transform: uppercase; }

.compact-header { width: 100%; border-bottom: 1px solid var(--line); }
.compact-brand { display: flex; align-items: center; font-family: var(--serif); font-weight: 600; }
.protocol-label { color: var(--muted); font-family: var(--mono); font-size: 0.65rem; }
.setup-copy h1 { font-size: clamp(3.3rem, 6vw, 6.3rem); }
.protocol-steps { display: grid; gap: 0; max-width: 680px; margin: 42px 0 30px; padding: 0; list-style: none; border-top: 1px solid var(--ink); }
.protocol-steps li { display: grid; grid-template-columns: 50px 1fr; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.protocol-steps li > span { font-family: var(--mono); font-size: 0.68rem; }
.protocol-steps strong { font-family: var(--serif); font-size: 1.12rem; }
.protocol-steps p { margin: 5px 0 0; color: var(--muted); font-size: 0.86rem; }
.study-disclosure { max-width: 650px; color: var(--muted); font-size: 0.74rem; line-height: 1.55; }
.gift-methods { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 0; padding: 0; border: 0; }
.gift-methods legend { grid-column: 1 / -1; margin-bottom: 4px; }
.gift-methods label { position: relative; }
.gift-methods input { position: absolute; opacity: 0; }
.gift-methods span { display: grid; min-height: 44px; place-items: center; border: 1px solid var(--line); background: var(--paper); font-size: 0.78rem; font-weight: 600; }
.gift-methods input:checked + span { border-color: var(--forest); background: var(--forest-light); box-shadow: inset 0 -3px 0 var(--forest); }
.consent-line { display: grid; grid-template-columns: 17px 1fr; gap: 10px; align-items: start; color: var(--muted); font-size: 0.7rem; line-height: 1.35; }
.consent-line input { width: 16px; height: 16px; margin: 1px 0 0; accent-color: var(--forest); }

.swipe-screen { align-items: center; justify-content: center; overflow: hidden; background: #07100c; }
.swipe-stage { --swipe-rgb: var(--yes); --swipe-strength: 0; position: relative; width: min(100%, 440px); height: 100svh; min-height: 620px; overflow: hidden; background: #07100c; box-shadow: 0 24px 90px rgba(0,0,0,0.38); }
.swipe-stage::after { content: attr(data-swipe-label); position: absolute; top: 20%; left: 50%; z-index: 20; min-width: 112px; padding: 10px 18px; border: 2px solid rgb(var(--swipe-rgb)); background: rgba(4,11,8,0.48); color: var(--white); font-family: var(--mono); font-size: 1.5rem; text-align: center; opacity: clamp(0, calc((var(--swipe-strength) - 0.06) * 2.8), 1); transform: translateX(-50%); pointer-events: none; }
.swipe-stage::before { content: ""; position: absolute; inset: 0; z-index: 12; border: 2px solid rgb(var(--swipe-rgb)); box-shadow: inset 0 0 28px rgb(var(--swipe-rgb) / 0.22); opacity: calc(var(--swipe-strength) * 0.55); pointer-events: none; }
.swipe-header { position: absolute; inset: 0 0 auto; z-index: 10; display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: max(16px, env(safe-area-inset-top)) 16px 74px; color: var(--white); background: linear-gradient(rgba(4,11,8,0.88), rgba(4,11,8,0)); pointer-events: none; transition: opacity 160ms ease; }
.swipe-identity { display: flex; align-items: center; gap: 10px; min-width: 0; }
.study-mark { display: grid; width: 34px; height: 34px; flex: 0 0 auto; place-items: center; border: 1px solid rgba(255,255,255,0.45); font-family: var(--mono); font-size: 0.58rem; }
.swipe-identity div { display: grid; min-width: 0; }
.swipe-identity span:not(.study-mark) { color: rgba(255,255,255,0.68); font-family: var(--mono); font-size: 0.55rem; text-transform: uppercase; }
.swipe-identity strong { overflow: hidden; font-family: var(--serif); font-size: 1rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.progress-readout { display: grid; text-align: right; }
.progress-readout span:first-child { font-family: var(--mono); font-size: 0.86rem; }
.progress-readout span:last-child { color: rgba(255,255,255,0.62); font-size: 0.58rem; text-transform: uppercase; }
.progress-track { grid-column: 1 / -1; height: 2px; overflow: hidden; background: rgba(255,255,255,0.27); }
.progress-track span { display: block; width: 0; height: 100%; background: var(--white); transition: width 180ms ease; }
.card-deck { position: absolute; inset: 0; }
.ring-card { --swipe-rgb: var(--yes); --swipe-strength: 0; position: absolute; inset: 0; overflow: hidden; opacity: 0; visibility: hidden; background: #07100c; touch-action: none; transform-origin: 50% 95%; transition: transform 180ms ease, opacity 120ms ease; user-select: none; }
.ring-card.top-card.is-ready { opacity: 1; visibility: visible; }
.ring-card.is-dragging { transition: none; }
.ring-card.next-card { opacity: 0; visibility: hidden; }
.ring-card img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; object-position: var(--photo-position, center); filter: saturate(1.04) contrast(1.03); pointer-events: none; -webkit-user-drag: none; }
.ring-card::after { content: ""; position: absolute; inset: 0; z-index: 4; background: rgb(var(--swipe-rgb) / 0.1); opacity: calc(var(--swipe-strength) * 0.58); pointer-events: none; }
.card-label { position: absolute; inset: auto 0 0; z-index: 6; padding: 150px 19px 126px; color: var(--white); background: linear-gradient(transparent, rgba(3,8,5,0.84)); transition: opacity 160ms ease; }
.card-label h2 { margin: 0; font-family: var(--serif); font-size: 1.72rem; font-weight: 500; line-height: 1; }
.card-label p { margin: 8px 0 0; color: rgba(255,255,255,0.78); font-size: 0.68rem; text-transform: uppercase; }
.swipe-stage.labels-hidden .card-label, .swipe-stage.labels-hidden .swipe-header, .swipe-stage.labels-hidden .swipe-help { opacity: 0; }
.swipe-help { position: absolute; right: 0; bottom: 98px; left: 0; z-index: 8; display: flex; justify-content: space-between; padding: 0 20px; color: rgba(255,255,255,0.68); font-family: var(--mono); font-size: 0.58rem; text-transform: uppercase; transition: opacity 160ms ease; pointer-events: none; }
.swipe-controls { position: absolute; right: 0; bottom: max(18px, env(safe-area-inset-bottom)); left: 0; z-index: 9; display: flex; justify-content: center; gap: 20px; }
.response-button { display: grid; width: 62px; height: 62px; place-items: center; border: 1px solid rgba(255,255,255,0.86); border-radius: 50%; background: rgba(4,11,8,0.48); color: var(--white); box-shadow: 0 5px 20px rgba(0,0,0,0.24); backdrop-filter: blur(8px); }
.response-button span { font-size: 1.9rem; line-height: 1; }
.response-button:hover { background: rgba(4,11,8,0.72); }
.response-button:disabled { opacity: 0.4; }
.empty-card { display: grid; height: 100%; place-items: center; padding: 40px; background: var(--paper); color: var(--ink); text-align: center; }
.empty-card p { color: var(--muted); }

.completion-screen { position: relative; }
.completion-brand { width: 100%; }
.completion-content { width: min(860px, 100%); margin: auto; padding: 70px 0; }
.completion-index { display: block; margin-bottom: 42px; padding-bottom: 12px; border-bottom: 1px solid var(--ink); font-family: var(--mono); font-size: 0.66rem; text-transform: uppercase; }
.completion-check { display: grid; width: 56px; height: 56px; margin-bottom: 26px; place-items: center; border: 1px solid var(--forest); border-radius: 50%; color: var(--forest); font-size: 1.4rem; }
.completion-content h1 { max-width: 780px; font-size: clamp(3.7rem, 7vw, 7rem); }
.completion-content > p:not(.study-kicker):not(.completion-note) { max-width: 650px; margin: 28px 0 36px; color: var(--muted); font-family: var(--serif); font-size: 1.3rem; line-height: 1.45; }
.completion-summary { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0; border-top: 1px solid var(--ink); border-bottom: 1px solid var(--line); }
.completion-summary div { padding: 18px 12px 18px 0; border-right: 1px solid var(--line); }
.completion-summary div + div { padding-left: 16px; }
.completion-summary div:last-child { border-right: 0; }
.completion-note { margin-top: 20px; color: var(--muted); font-size: 0.72rem; }
.toast { position: fixed; right: 18px; bottom: 18px; z-index: 80; max-width: min(360px, calc(100vw - 36px)); padding: 12px 15px; background: var(--ink); color: var(--white); font-size: 0.76rem; opacity: 0; transform: translateY(12px); transition: opacity 160ms ease, transform 160ms ease; pointer-events: none; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 820px) {
  .access-screen, .setup-screen, .completion-screen { padding-inline: 20px; background: var(--paper); }
  .access-layout, .setup-layout { grid-template-columns: 1fr; gap: 40px; padding: 50px 0; }
  .access-layout .code-panel { order: -1; }
  .access-intro h1, .setup-copy h1 { font-size: clamp(3.5rem, 15vw, 5.5rem); }
  .access-lede { font-size: 1.1rem; }
  .code-panel, .gift-panel { padding: 28px 22px; }
  .study-footer { gap: 12px; }
}

@media (max-width: 480px) {
  .study-brand span { display: none; }
  .study-facts { grid-template-columns: 1fr; }
  .study-facts div, .study-facts div + div { min-height: 58px; padding: 11px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .study-facts div:last-child { border-bottom: 0; }
  .study-footer { font-size: 0.52rem; }
  .swipe-stage { width: 100%; box-shadow: none; }
  .completion-summary { grid-template-columns: 1fr; }
  .completion-summary div, .completion-summary div + div { padding: 13px 0; border-right: 0; border-bottom: 1px solid var(--line); }
  .completion-summary div:last-child { border-bottom: 0; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: 0.01ms !important; }
}
