:root {
  color-scheme: light;
  --paper: #f7f5f2;
  --surface: #fffdfb;
  --ink: #282622;
  --muted: #716d66;
  --faint: #969087;
  --line: #ded9d1;
  --field: #efebe5;
  --accent: #c15f3c;
  --accent-dark: #9e472c;
  --accent-soft: #f5e4dc;
  --danger: #9d2c23;
  --success: #376a54;
  --shadow: 0 18px 50px rgba(62, 50, 42, 0.07);
  --serif: "Iowan Old Style", "Palatino Linotype", "Noto Serif SC", "Songti SC", Georgia, serif;
  --sans: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Noto Sans SC", Arial, sans-serif;
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--paper); scroll-behavior: smooth; }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

button, input, textarea, select { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

a { color: inherit; text-underline-offset: 0.2em; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
  background: color-mix(in srgb, var(--paper) 94%, transparent);
  backdrop-filter: blur(14px);
}

.header-inner {
  display: flex;
  width: min(100% - 32px, 860px);
  min-height: 64px;
  margin: 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.wordmark {
  font-family: var(--serif);
  font-size: 1rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  text-decoration: none;
}

.language-switch { display: flex; align-items: center; gap: 8px; color: var(--faint); font-size: 0.875rem; }
.language-switch button {
  min-width: 40px;
  min-height: 40px;
  padding: 6px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.language-switch button[aria-pressed="true"] { color: var(--accent-dark); font-weight: 700; }
.language-switch button:focus-visible,
.text-button:focus-visible,
.button:focus-visible,
summary:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in srgb, var(--accent) 35%, transparent);
  outline-offset: 3px;
}

.survey-shell {
  width: min(100% - 32px, 760px);
  margin: 0 auto;
  padding: clamp(34px, 7vw, 72px) 0 calc(72px + env(safe-area-inset-bottom));
}

.survey-panel {
  padding: clamp(28px, 6vw, 58px);
  background: var(--surface);
  border-radius: 22px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.09em;
  text-transform: uppercase;
}

h1, h2, h3 { font-family: var(--serif); font-weight: 620; letter-spacing: -0.025em; text-wrap: balance; }
h1 { margin: 0; font-size: clamp(2rem, 7vw, 3.35rem); line-height: 1.08; }
h2 { margin: 0; font-size: clamp(1.65rem, 5vw, 2.35rem); line-height: 1.18; }
h3 { margin: 0; font-size: 1.15rem; line-height: 1.35; }
p { margin: 0; }

.intro-copy { margin-top: 24px; color: #4d4943; font-size: 1.03rem; }
.intro-copy p + p { margin-top: 12px; }

.consent-points {
  display: grid;
  margin: 26px 0 0;
  padding: 0;
  list-style: none;
}
.consent-points li {
  position: relative;
  padding: 13px 0 13px 26px;
  color: var(--muted);
  border-top: 1px solid var(--line);
}
.consent-points li::before {
  position: absolute;
  top: 22px;
  left: 3px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  content: "";
}

.consent-check {
  display: flex;
  margin-top: 28px;
  align-items: flex-start;
  gap: 12px;
  font-weight: 650;
  cursor: pointer;
}
.consent-check input { width: 20px; height: 20px; margin: 3px 0 0; accent-color: var(--accent); flex: 0 0 auto; }

.privacy-note, .draft-note, .optional-note {
  color: var(--muted);
  font-size: 0.875rem;
}
.privacy-note { margin-top: 18px; }
.draft-note { margin-top: 14px; }

.button-row {
  display: flex;
  margin-top: 34px;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.button {
  display: inline-flex;
  min-height: 48px;
  padding: 11px 20px;
  border: 0;
  border-radius: 999px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--accent);
  color: #fffaf5;
  font-weight: 720;
  line-height: 1.2;
  text-decoration: none;
  cursor: pointer;
  transition: background-color 150ms ease, transform 150ms ease;
}
.button:hover { background: var(--accent-dark); }
.button:active { transform: translateY(1px); }
.button:disabled { background: #cfc9c0; color: #767169; cursor: not-allowed; transform: none; }
.button-secondary { background: var(--ink); }
.button-secondary:hover { background: #11100e; }
.button-quiet { background: transparent; color: var(--muted); }
.button-quiet:hover { background: var(--field); color: var(--ink); }
.button-danger { background: var(--danger); }
.button-danger:hover { background: #7e211b; }

.text-button {
  min-height: 42px;
  padding: 6px 2px;
  border: 0;
  background: transparent;
  color: var(--muted);
  text-decoration: underline;
  text-decoration-color: var(--line);
  text-underline-offset: 4px;
  cursor: pointer;
}
.text-button:hover { color: var(--accent-dark); text-decoration-color: currentColor; }

.progress-region { margin-bottom: 34px; }
.progress-meta { display: flex; margin-bottom: 10px; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 0.82rem; }
.progress-track { height: 3px; overflow: hidden; background: var(--line); }
.progress-value { height: 100%; background: var(--accent); transition: width 220ms ease; }
.progress-value[data-section="1"] { width: 16.667%; }
.progress-value[data-section="2"] { width: 33.333%; }
.progress-value[data-section="3"] { width: 50%; }
.progress-value[data-section="4"] { width: 66.667%; }
.progress-value[data-section="5"] { width: 83.333%; }
.progress-value[data-section="6"] { width: 100%; }

.section-intro { margin-bottom: 38px; }
.section-intro .optional-note { margin-top: 13px; }

.question { scroll-margin-top: 96px; }
.question + .question { margin-top: 52px; padding-top: 48px; border-top: 1px solid var(--line); }
.question-number { display: block; margin-bottom: 10px; color: var(--accent-dark); font-size: 0.8rem; font-weight: 780; letter-spacing: 0.08em; }
.question h3 { font-size: clamp(1.2rem, 4vw, 1.45rem); }
.prompt { margin-top: 12px; color: var(--muted); font-size: 0.93rem; }

.field { margin-top: 22px; }
.field label { display: block; margin-bottom: 8px; color: #4b4741; font-size: 0.9rem; font-weight: 680; }
input[type="email"], input[type="password"], input[type="text"], textarea {
  width: 100%;
  border: 1px solid transparent;
  border-radius: 12px;
  background: var(--field);
  color: var(--ink);
  transition: border-color 140ms ease, background-color 140ms ease;
}
input[type="email"], input[type="password"], input[type="text"] { min-height: 49px; padding: 10px 13px; }
textarea { min-height: 154px; padding: 13px 14px; line-height: 1.6; resize: vertical; }
input:hover, textarea:hover { background: #ebe6df; }
input:focus, textarea:focus { border-color: var(--accent); background: var(--surface); outline: none; }
::placeholder { color: #9a958d; opacity: 1; }

.relationship-list { margin-top: 25px; }
.relationship-card { border-top: 1px solid var(--line); }
.relationship-card:last-child { border-bottom: 1px solid var(--line); }
.relationship-card summary {
  display: flex;
  min-height: 64px;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  cursor: pointer;
  list-style: none;
}
.relationship-card summary::-webkit-details-marker { display: none; }
.relationship-card summary::after { color: var(--accent-dark); content: "+"; font-size: 1.4rem; font-weight: 350; }
.relationship-card[open] summary::after { content: "−"; }
.relationship-card-body { padding: 0 0 30px; }
.relationship-card-body .field:first-child { margin-top: 4px; }
.relationship-card-body textarea { min-height: 100px; }
.relationship-title { font-weight: 700; }
.relationship-alias { margin-left: auto; overflow: hidden; color: var(--muted); font-size: 0.85rem; font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.relationship-actions { display: flex; margin-top: 20px; justify-content: flex-end; }
.add-person { margin-top: 18px; }

.review-list { margin: 30px 0 0; padding: 0; list-style: none; }
.review-item { display: grid; grid-template-columns: 36px 1fr auto; align-items: center; gap: 12px; padding: 14px 0; border-top: 1px solid var(--line); }
.review-item:last-child { border-bottom: 1px solid var(--line); }
.review-number { color: var(--accent-dark); font-weight: 760; }
.review-state { color: var(--muted); font-size: 0.85rem; }
.review-state.answered { color: var(--success); }
.review-edit { border: 0; background: transparent; color: var(--accent-dark); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }

.submission-error { margin-top: 18px; color: var(--danger); font-weight: 650; }
.success-mark { display: grid; width: 50px; height: 50px; margin-bottom: 28px; border-radius: 50%; place-items: center; background: var(--accent-soft); color: var(--accent-dark); font-size: 1.5rem; }
.reference { margin-top: 28px; padding-top: 20px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.88rem; word-break: break-all; }

.confirm-dialog {
  width: min(calc(100% - 32px), 460px);
  padding: 28px;
  border: 0;
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 24px 80px rgba(35, 28, 24, 0.22);
}
.confirm-dialog::backdrop { background: rgba(39, 32, 28, 0.34); backdrop-filter: blur(3px); }
.confirm-dialog p { margin-top: 12px; color: var(--muted); }
.dialog-actions { display: flex; margin-top: 26px; justify-content: flex-end; gap: 10px; }

.noscript { width: min(100% - 32px, 760px); margin: 24px auto; padding: 18px; background: var(--surface); }
.sr-only { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; margin: -1px !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.hidden { display: none !important; }

/* Administrator */
.admin-body { background: var(--surface); }
.admin-shell { width: min(100% - 32px, 1040px); margin: 0 auto; padding: 44px 0 80px; }
.admin-login { width: min(100%, 440px); margin: 6vh auto 0; }
.admin-login .intro-copy { margin-top: 15px; }
.admin-login form { margin-top: 30px; }
.admin-toolbar { display: flex; align-items: flex-start; justify-content: space-between; gap: 20px; }
.admin-toolbar-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 9px; }
.admin-section { margin-top: 52px; padding-top: 38px; border-top: 1px solid var(--line); }
.admin-section-heading { display: flex; align-items: end; justify-content: space-between; gap: 18px; }
.admin-section-heading p { margin-top: 6px; color: var(--muted); }
.stats-row { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; margin-top: 30px; }
.stat { padding-top: 15px; border-top: 2px solid var(--ink); }
.stat-value { font-family: var(--serif); font-size: clamp(1.8rem, 5vw, 2.6rem); line-height: 1; }
.stat-label { margin-top: 7px; color: var(--muted); font-size: 0.86rem; }
.response-list { margin-top: 22px; }
.response-row { border-top: 1px solid var(--line); }
.response-row:last-child { border-bottom: 1px solid var(--line); }
.response-row summary { display: grid; grid-template-columns: minmax(150px, 1.2fr) minmax(100px, 1fr) auto auto; min-height: 68px; align-items: center; gap: 16px; cursor: pointer; list-style: none; }
.response-row summary::-webkit-details-marker { display: none; }
.response-meta { color: var(--muted); font-size: 0.87rem; }
.response-count { color: var(--success); font-size: 0.87rem; text-align: right; }
.response-toggle { color: var(--accent-dark); font-size: 0.86rem; font-weight: 680; text-align: right; }
.response-detail { padding: 8px 0 34px; }
.response-record-meta { color: var(--muted); font-size: 0.82rem; overflow-wrap: anywhere; }
.answer-block { padding: 22px 0; border-top: 1px solid var(--line); }
.answer-heading { display: flex; align-items: baseline; gap: 12px; }
.answer-number { flex: 0 0 auto; color: var(--accent-dark); font-size: 0.78rem; font-weight: 780; letter-spacing: 0.06em; }
.answer-label { color: var(--ink); font-family: var(--sans); font-size: 0.98rem; font-weight: 720; letter-spacing: -0.01em; line-height: 1.45; }
.answer-value { margin-top: 10px; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.empty-answer { color: var(--faint); font-style: italic; }
.contact-answer { margin-top: 15px; padding-left: 16px; border-left: 2px solid var(--accent-soft); }
.contact-answer dt { margin-top: 8px; color: var(--muted); font-size: 0.82rem; }
.contact-answer dd { margin: 2px 0 0; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere; }
.response-actions { display: flex; margin-top: 10px; padding-top: 24px; border-top: 1px solid var(--line); justify-content: flex-end; }
.response-delete { min-height: 44px; padding-inline: 18px; font-size: 0.9rem; }
.delete-response-reference { margin-top: 18px !important; padding: 12px 14px; border-radius: 10px; background: var(--field); color: var(--ink) !important; font-size: 0.9rem; overflow-wrap: anywhere; }
.pagination { display: flex; margin-top: 24px; align-items: center; justify-content: center; gap: 14px; }
.admin-form-grid { display: grid; grid-template-columns: 1fr 1fr auto; align-items: end; gap: 14px; margin-top: 24px; }
.admin-form-grid .field { margin-top: 0; }
.account-list { margin-top: 24px; }
.account-row { display: grid; grid-template-columns: 1fr auto auto; align-items: center; gap: 16px; min-height: 58px; border-top: 1px solid var(--line); }
.account-row:last-child { border-bottom: 1px solid var(--line); }
.account-role { color: var(--muted); font-size: 0.85rem; text-transform: capitalize; }
.status-message { min-height: 1.6em; margin-top: 14px; color: var(--muted); font-size: 0.9rem; }
.status-message.error { color: var(--danger); }
.status-message.success { color: var(--success); }

@media (max-width: 680px) {
  body { line-height: 1.6; }
  .header-inner, .survey-shell, .admin-shell { width: min(100% - 24px, 760px); }
  .site-header { position: relative; }
  .survey-shell { padding-top: 18px; }
  .survey-panel { padding: 28px 20px 30px; border-radius: 16px; }
  h1 { font-size: 2.25rem; }
  .button-row { align-items: stretch; }
  .button-row .button { flex: 1; }
  .question + .question { margin-top: 42px; padding-top: 38px; }
  .prompt { font-size: 1rem; line-height: 1.72; }
  textarea { min-height: 185px; font-size: 1rem; line-height: 1.7; }
  .relationship-card summary { min-height: 70px; }
  .relationship-card-body { padding-bottom: 34px; }
  .relationship-card-body textarea { min-height: 140px; }
  .response-row summary { grid-template-columns: 1fr auto; padding: 13px 0; }
  .response-row summary > :nth-child(2) { grid-column: 1; grid-row: 2; }
  .response-count { grid-column: 2; grid-row: 2; }
  .response-toggle { grid-column: 2; grid-row: 1; }
  .response-detail { padding: 10px 0 28px; }
  .response-record-meta { display: block; margin-bottom: 14px; padding: 0 2px; font-size: 0.78rem; }
  .answer-block { margin-top: 12px; padding: 18px 16px 20px; border: 0; border-radius: 14px; background: var(--paper); }
  .answer-heading { align-items: flex-start; gap: 10px; }
  .answer-number { padding-top: 3px; }
  .answer-label { font-size: 1rem; line-height: 1.5; }
  .answer-value { margin-top: 12px; font-size: 1rem; line-height: 1.78; }
  .contact-answer { margin-top: 18px; padding: 0 0 4px 13px; }
  .contact-answer + .contact-answer { margin-top: 24px; }
  .contact-answer dt { margin-top: 11px; font-size: 0.85rem; }
  .contact-answer dd { margin-top: 3px; font-size: 1rem; line-height: 1.72; }
  .response-actions { margin-top: 18px; padding-top: 20px; }
  .response-delete { width: 100%; }
  .admin-toolbar { flex-direction: column; }
  .admin-toolbar-actions { justify-content: flex-start; }
  .stats-row { gap: 10px; }
  .stat { padding-top: 11px; }
  .admin-form-grid { grid-template-columns: 1fr; }
  .account-row { grid-template-columns: 1fr auto; padding: 10px 0; }
  .account-role { grid-column: 1; }
  .dialog-actions { flex-direction: column-reverse; }
  .dialog-actions .button { width: 100%; }
}

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