:root {
  color-scheme: light;
  --background: #f7f7f3;
  --text: #1f201d;
  --muted: #63665d;
  --green: #285744;
  --line: #d8d8d1;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  font-size: 16px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--background); color: var(--text); line-height: 1.5; padding-inline: env(safe-area-inset-left, 0px) env(safe-area-inset-right, 0px); }
main { width: min(42rem, calc(100% - 2rem)); margin-inline: auto; }
button, input, select, textarea { font: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
h1, h2, p, legend, button { overflow-wrap: anywhere; }
.skip-link { position: fixed; top: max(0.75rem, env(safe-area-inset-top, 0px)); left: 0.75rem; z-index: 5; padding: 0.75rem; background: var(--text); color: white; transform: translateY(-200%); }
.skip-link:focus { transform: none; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 4px; }
.intro { padding-top: max(1.5rem, env(safe-area-inset-top, 0px)); }
h1 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(2.7rem, 8.6vw, 4.5rem); letter-spacing: -0.045em; line-height: 1.02; margin: 0 0 1.5rem; }
h1 > span { color: var(--green); }
.hero { display: grid; grid-template-columns: minmax(0, 0.92fr) minmax(0, 1.08fr); align-items: center; gap: clamp(1rem, 4vw, 2rem); }
.hero-photo { display: block; width: 100%; height: auto; border-radius: 0.3rem; }
.hero-copy { min-width: 0; }
.hero-copy h2 { font-size: clamp(1.2rem, 4.8vw, 2rem); letter-spacing: -0.035em; line-height: 1.15; margin: 0 0 0.65rem; }
.hero-copy p, .hero-copy ul { font-size: clamp(0.9rem, 3.5vw, 1.15rem); line-height: 1.45; margin: 0; }
.hero-copy ul { margin-top: 0.65rem; padding-inline-start: 1.2em; }
.hero-copy .references { color: var(--muted); font-size: clamp(0.8rem, 3.1vw, 1rem); margin-top: 0.8rem; }
.application { padding-top: 1.5rem; min-height: calc(100svh - env(safe-area-inset-top, 0px) - 2rem); scroll-margin-top: calc(env(safe-area-inset-top, 0px) + 0.5rem); }
.step-header { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 2; display: flex; justify-content: space-between; align-items: center; gap: 1rem; padding-block: 0.5rem; background: var(--background); }
.back-button { display: inline-flex; justify-content: center; align-items: center; width: 44px; height: 44px; padding: 0; border: 1px solid var(--line); border-radius: 50%; background: white; color: var(--green); flex-shrink: 0; }
.back-button:disabled { opacity: 0.35; cursor: default; }
#step-count { color: var(--muted); font-size: 0.8rem; }
progress { display: block; width: 100%; height: 4px; border: 0; border-radius: 4px; overflow: hidden; background: var(--line); color: var(--green); margin: 0.4rem 0 1.75rem; appearance: none; }
progress::-webkit-progress-bar { background: var(--line); }
progress::-webkit-progress-value { background: var(--green); }
progress::-moz-progress-bar { background: var(--green); }
.question-title { font-size: clamp(1.5rem, 5.5vw, 2rem); font-weight: 600; line-height: 1.25; letter-spacing: -0.035em; margin: 0 0 1.3rem; }
.question-title:focus:not(:focus-visible) { outline: none; }
.unhinged-options { display: grid; gap: 0.65rem; }
.unhinged-button { display: grid; grid-template-columns: 1.6rem minmax(0, 1fr) 1rem; gap: 0.6rem; align-items: center; min-height: 3.8rem; padding: 0.85rem 1rem; border: 1px solid var(--line); border-radius: 0.4rem; background: white; color: var(--text); text-align: left; font-size: 0.95rem; line-height: 1.4; }
.level-number { color: var(--green); font-size: 0.9rem; font-weight: 600; }
.selection { width: 1rem; height: 1rem; border: 1px solid #8a8e83; border-radius: 50%; }
.unhinged-button[aria-pressed="true"] { border-color: var(--green); background: #e8eee7; }
.unhinged-button[aria-pressed="true"] .selection { background: var(--green); border-color: var(--green); box-shadow: inset 0 0 0 3px #e8eee7; }
select, textarea { display: block; width: 100%; min-height: 3.5rem; border: 1px solid #989e90; border-radius: 0.4rem; background: white; color: var(--text); font-size: 1rem; padding: 0.8rem; }
textarea { resize: vertical; min-height: 14rem; line-height: 1.5; }
.answer-field { position: relative; display: grid; grid-template-rows: minmax(0, 1fr) auto; overflow: hidden; border: 1px solid #989e90; border-radius: 0.4rem; background: white; }
.answer-field textarea { border: 0; border-radius: 0; }
.keyboard-microphone { display: inline-block; width: 1em; height: 1.36em; vertical-align: -0.25em; object-fit: contain; }
.dictation-note { margin: 0; padding: 0.25rem 0.65rem 0.4rem; color: var(--muted); text-align: right; font-size: 0.7rem; line-height: 1.25; }
.continue-button { margin-top: 1.5rem; }

/* Only the two written answers use this visible-viewport panel. The surrounding
   screens, including the under-18 siren, retain their existing layout. */
body.is-writing { overflow: hidden; }
.application.is-writing {
  position: fixed;
  z-index: 3;
  top: var(--writing-viewport-top, 0px);
  left: max(1rem, env(safe-area-inset-left, 0px));
  right: max(1rem, env(safe-area-inset-right, 0px));
  width: auto;
  max-width: 40rem;
  height: var(--writing-viewport-height, 100dvh);
  min-height: 0;
  margin-inline: auto;
  padding-block: max(0.25rem, env(safe-area-inset-top, 0px)) max(0.5rem, env(safe-area-inset-bottom, 0px));
  background: var(--background);
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) auto;
  grid-template-rows: 44px minmax(0, 1fr);
  gap: 0.5rem 0.75rem;
}
.is-writing .step-header { display: contents; }
.is-writing #back-button { grid-column: 1; grid-row: 1; }
.is-writing #step-progress { grid-column: 2; grid-row: 1; align-self: center; margin: 0; }
.is-writing #step-count { grid-column: 3; grid-row: 1; align-self: center; white-space: nowrap; font-size: 0.75rem; }
.is-writing .question-screen {
  grid-column: 1 / -1;
  grid-row: 2;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: 0.25rem;
}
.is-writing .question-screen form {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  height: 100%;
  min-height: 0;
}
.is-writing .question-title {
  flex: none;
  margin: 0;
  font-size: clamp(1.125rem, 4.8vw, 1.35rem);
  line-height: 1.2;
}
.is-writing .answer-field {
  flex: 0 1 8rem;
  min-height: 6rem;
}
.is-writing .answer-field:focus-within { outline: 3px solid var(--green); outline-offset: 2px; }
.is-writing textarea {
  height: 100%;
  min-height: 0;
  padding: 0.5rem 0.75rem;
  border: 0;
  line-height: 1.4;
  resize: none;
  overflow-y: auto;
}
.is-writing textarea:focus-visible { outline: none; }
/* Guidance has a reserved row inside the field; scrolling text cannot overlap it. */
.is-writing .continue-button { flex: none; margin: 0; min-height: 44px; padding: 0.5rem 0.75rem; }
.is-writing .error { flex: none; margin: 0; font-size: 0.8rem; line-height: 1.25; }
.details-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.detail-label { display: flex; align-items: flex-end; min-height: 2.8rem; font-size: 1rem; font-weight: 600; line-height: 1.4; margin-bottom: 0.6rem; }
.field-note { margin: 0.5rem 0 0; color: var(--muted); font-size: 0.8rem; }
fieldset { min-width: 0; border: 0; padding: 0; margin: 1.75rem 0 0; }
legend { width: 100%; padding: 0; font-size: 1.125rem; font-weight: 600; letter-spacing: -0.02em; line-height: 1.4; margin-bottom: 0.85rem; }
.yes-no-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.8rem; }
.choice { position: relative; display: block; cursor: pointer; }
.choice input { position: absolute; top: 50%; left: 1rem; width: 1px; height: 1px; opacity: 0; }
.option { min-height: 3.6rem; display: flex; justify-content: space-between; align-items: center; gap: 0.6rem; padding: 0.8rem 1rem; border: 1px solid var(--line); background: white; border-radius: 0.4rem; font-size: 1rem; line-height: 1.4; }
input:checked + .option { border-color: var(--green); background: #e8eee7; }
input:checked + .option .selection { background: var(--green); border-color: var(--green); box-shadow: inset 0 0 0 3px #e8eee7; }
input:focus-visible + .option { outline: 3px solid var(--green); outline-offset: 3px; }
.error { color: #943b27; font-size: 0.9rem; }
.primary-button { display: flex; width: 100%; justify-content: center; align-items: center; gap: 0.75rem; min-height: 3.5rem; border: 1px solid var(--green); border-radius: 0.4rem; background: var(--green); color: white; padding: 0.9rem 1rem; font-weight: 600; font-size: 1rem; }
.primary-button:active { background: #1e4434; }
.result { padding: 1.75rem 1.2rem; background: #e8eee7; border: 1px solid #c6d1c1; border-radius: 0.5rem; text-align: center; }
.coffee-mark { font-size: 2rem; display: inline-block; margin-bottom: 0.75rem; }
.result h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; font-size: clamp(1.9rem, 7vw, 2.6rem); letter-spacing: -0.03em; line-height: 1.12; margin: 0 0 1rem; }
.result p { font-size: 1rem; margin: 0; }
.result-actions { margin-top: 1.5rem; }
.age-exit { text-align: center; padding: 1.5rem 0.5rem; }
.siren-mark { display: block; font-size: clamp(6rem, 28vw, 9rem); line-height: 1.1; margin-bottom: 1.5rem; }
.age-exit h2 { font-size: clamp(1.75rem, 7vw, 2.5rem); font-weight: 800; line-height: 1.2; margin: 0 0 2rem; color: #a02e24; }
.text-button { min-height: 3rem; padding: 0.75rem; margin-top: 0.4rem; border: 0; background: transparent; color: var(--green); text-decoration: underline; text-underline-offset: 0.2em; }
footer { padding-block: 1.3rem max(2rem, env(safe-area-inset-bottom, 0px)); text-align: center; }
footer p { font-size: 0.75rem; color: var(--muted); margin: 0; }
@media (hover: hover) {
  .unhinged-button:hover, .choice:hover .option { border-color: #7f927e; }
  .primary-button:hover { background: #1e4434; }
}
@media (min-width: 600px) {
  main { padding-inline: 1rem; }
  .hero { grid-template-columns: minmax(0, 0.85fr) minmax(0, 1.15fr); }
  .hero-photo { max-height: 21rem; width: auto; max-width: 100%; }
  .application { padding-top: 2rem; }
}
@media (forced-colors: active) {
  .unhinged-button[aria-pressed="true"], input:checked + .option { border-width: 3px; }
  .unhinged-button[aria-pressed="true"] .selection, input:checked + .option .selection { background: Highlight; }
  progress { border: 1px solid CanvasText; }
}

/* Deliberate, optional contact and photo submission. */
.contact-fields { margin: 1.25rem 0 0; padding: 0; border: 0; text-align: left; }
.contact-fields legend { margin-bottom: 0.75rem; font-weight: 600; }
.contact-fields label { display: block; margin: 0.75rem 0 0.4rem; }
.contact-fields input[type="text"], .contact-fields input[type="tel"], .contact-fields input[type="file"] { width: 100%; min-height: 44px; padding: 0.65rem; border: 1px solid #989e90; border-radius: 0.4rem; font-size: 1rem; background: white; }
.contact-fields input:disabled { opacity: 0.65; }
.contact-fields .contact-consent { display: flex; align-items: flex-start; gap: 0.6rem; font-size: 0.85rem; }
.contact-consent input { flex: none; margin-top: 0.35rem; }
.contact-fields button:disabled { opacity: 0.5; cursor: default; margin-top: 1rem; }
.result p.capture-status { margin-top: 1rem; font-size: 0.85rem; }

.contact-fields .primary-button { margin-top: 1rem; }
.contact-fields input[type="checkbox"] { min-width: 22px; min-height: 22px; }
.capture-status:empty { display: none; }
[aria-busy="true"] { cursor: progress; }
