:root {
  --bg: #F5F1E8;
  --bg-soft: #EDE7D8;
  --bg-card: #FFFFFF;
  --fg: #1A1A1A;
  --muted: #5C5C5C;
  --accent: #8B4513;
  --rule: rgba(26, 26, 26, 0.12);
  --rule-strong: rgba(26, 26, 26, 0.22);
  --critical: #B23A3A;
  --important: #B07A1F;
  --clarification: #5C5C5C;
  --ok: #2F6B3F;
  --err: #B23A3A;
  --max: 1100px;
  --max-form: 1080px;
  --max-readable: 72ch;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }

body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
  font-size: 16px;
  line-height: 1.6;
  font-weight: 400;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

a {
  color: var(--fg);
  text-decoration: none;
  border-bottom: 1px solid currentColor;
  padding-bottom: 1px;
  transition: color .2s ease;
}
a:hover { color: var(--accent); }

h1, h2, h3, h4 {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-weight: 500;
  letter-spacing: -0.005em;
  line-height: 1.15;
}

p { color: var(--muted); }

/* Header (shared with rest of site) */
header.site-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.6rem 2.5rem;
  max-width: var(--max);
  margin: 0 auto;
  width: 100%;
}
.brand {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  border: none;
}
.logo-mark { width: 28px; height: 28px; flex-shrink: 0; }
.logo-word {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--fg);
}
.session-bar {
  display: flex;
  align-items: center;
  gap: 1.2rem;
  font-size: 0.88rem;
  color: var(--muted);
}
.session-bar .session-email { color: var(--fg); font-weight: 500; }
.session-bar a { border: none; color: var(--muted); }
.session-bar a:hover { color: var(--accent); }

@media (max-width: 720px) {
  header.site-header { padding: 1.2rem 1.2rem; flex-wrap: wrap; gap: 0.8rem; }
  .session-bar { font-size: 0.82rem; gap: 0.8rem; }
}

/* Main layout */
main {
  flex: 1;
  width: 100%;
  max-width: var(--max-form);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Auth card (register / login / invalid-invite states) */
.auth-card {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  padding: 2.6rem 2.4rem;
  margin: 1.5rem auto;
  max-width: 520px;
}
.auth-card-wide { max-width: 680px; }
.auth-card-note {
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--muted);
  background: var(--bg);
  border-left: 3px solid var(--accent);
  padding: 0.9rem 1.1rem;
  margin: 0 0 1.6rem 0;
}
.auth-card .eyebrow {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.9rem;
}
.auth-card h1 {
  font-size: clamp(1.7rem, 3vw, 2.1rem);
  margin-bottom: 0.6rem;
}
.auth-card .lead {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--muted);
  margin-bottom: 1.8rem;
}
.auth-card .invite-meta {
  font-size: 0.86rem;
  color: var(--muted);
  background: var(--bg);
  border: 1px solid var(--rule);
  padding: 0.8rem 1rem;
  margin-bottom: 1.5rem;
}
.auth-card .invite-meta strong { color: var(--fg); }
.auth-card .switch-link {
  margin-top: 1.4rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--rule);
  font-size: 0.88rem;
  color: var(--muted);
  text-align: center;
}
.auth-card .switch-link a { color: var(--fg); }

/* Form fields */
.field { display: block; margin-bottom: 1rem; }
.field label {
  display: block;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}
@media (max-width: 560px) {
  .field-row { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="tel"],
select,
textarea {
  width: 100%;
  padding: 0.75rem 0.9rem;
  font: inherit;
  color: var(--fg);
  background: var(--bg-card);
  border: 1px solid var(--rule-strong);
  border-radius: 0;
  transition: border-color .15s ease, background .15s ease;
}
input[readonly] { background: var(--bg-soft); color: var(--muted); }
textarea { resize: vertical; min-height: 5rem; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.85rem 1.4rem;
  background: var(--fg);
  color: var(--bg);
  border: none;
  font-family: 'Inter', sans-serif;
  font-weight: 500;
  font-size: 0.92rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: background .2s ease, transform .15s ease, opacity .2s ease;
}
.btn:hover:not([disabled]) { background: var(--accent); transform: translateY(-1px); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn-block { width: 100%; }
.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--rule-strong);
}
.btn-secondary:hover:not([disabled]) {
  background: var(--fg);
  color: var(--bg);
  border-color: var(--fg);
}

/* Status / messages */
.msg {
  margin-top: 1rem;
  padding: 0.7rem 0.9rem;
  font-size: 0.88rem;
  border: 1px solid var(--rule-strong);
}
.msg.err { color: var(--err); border-color: var(--err); background: rgba(178, 58, 58, 0.06); }
.msg.ok  { color: var(--ok); border-color: var(--ok); background: rgba(47, 107, 63, 0.06); }
.msg.info { color: var(--muted); }
.hidden { display: none !important; }

/* Form hero */
.form-hero {
  padding: 1.8rem 0 2.4rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 2.4rem;
}
.form-hero .eyebrow {
  display: block;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 0.9rem;
}
.form-hero h1 {
  font-size: clamp(2.1rem, 4vw, 3rem);
  margin-bottom: 0.7rem;
}
.form-hero .subtitle {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: clamp(1.1rem, 1.8vw, 1.35rem);
  color: var(--muted);
  margin-bottom: 1.6rem;
}
.form-hero .vision {
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  padding: 1.3rem 1.6rem;
  margin: 0 0 1.6rem 0;
}
.form-hero .vision p {
  font-size: 0.98rem;
  color: var(--fg);
  line-height: 1.65;
  margin: 0;
}
.form-hero .vision p + p { margin-top: 0.7rem; }
.form-hero .intro {
  font-size: 0.97rem;
  color: var(--muted);
  line-height: 1.65;
}
.form-hero .footnote {
  font-size: 0.82rem;
  color: var(--muted);
  font-style: italic;
  margin-top: 1.4rem;
}

/* Profile fieldset */
.profile-card {
  background: var(--bg-soft);
  border: 1px solid var(--rule);
  padding: 1.6rem 1.6rem 1rem;
  margin-bottom: 2rem;
}
.profile-card h2 {
  font-size: 1.2rem;
  font-family: 'Inter', sans-serif;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--fg);
  margin-bottom: 1rem;
}

/* Question section */
details.section {
  background: var(--bg-card);
  border: 1px solid var(--rule);
  margin-bottom: 1.1rem;
}
details.section[open] { border-color: var(--rule-strong); }
details.section > summary {
  list-style: none;
  cursor: pointer;
  padding: 1.3rem 1.8rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  user-select: none;
  transition: background .15s ease;
}
details.section > summary:hover { background: var(--bg-soft); }
details.section > summary::-webkit-details-marker { display: none; }
details.section > summary .sec-title {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-size: 1.55rem;
  font-weight: 500;
  color: var(--fg);
  flex: 1;
  display: flex;
  align-items: baseline;
  gap: 0.7rem;
}
details.section > summary .sec-title .sec-num {
  color: var(--accent);
  font-family: 'Inter', sans-serif;
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}
details.section > summary .sec-meta {
  font-size: 0.78rem;
  color: var(--muted);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}
details.section > summary .sec-toggle {
  width: 14px; height: 14px;
  border-right: 1.5px solid var(--muted);
  border-bottom: 1.5px solid var(--muted);
  transform: rotate(45deg);
  transition: transform .2s ease;
  flex-shrink: 0;
}
details.section[open] > summary .sec-toggle {
  transform: rotate(-135deg);
}
.sec-body {
  padding: 0 1.8rem 1.6rem;
  border-top: 1px solid var(--rule);
}
.sec-intro {
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1.05rem;
  color: var(--muted);
  padding: 1.2rem 0 0.4rem;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 1.4rem;
}

/* Question block */
.question {
  padding: 1.4rem 0;
  border-bottom: 1px dashed var(--rule);
}
.question:last-child { border-bottom: none; }
.q-head {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  margin-bottom: 1rem;
}
.q-id {
  font-family: 'Inter', sans-serif;
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.06em;
  white-space: nowrap;
  padding: 0.2rem 0.5rem;
  border: 1px solid currentColor;
  flex-shrink: 0;
  margin-top: 0.1rem;
}
.q-text {
  font-size: 1.02rem;
  color: var(--fg);
  flex: 1;
  line-height: 1.55;
}
.priority {
  display: inline-block;
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  padding: 0.18rem 0.5rem;
  border: 1px solid currentColor;
  white-space: nowrap;
  margin-top: 0.1rem;
}
.priority.critical { color: var(--critical); }
.priority.important { color: var(--important); }
.priority.clarification { color: var(--clarification); }

.q-fields {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 1rem;
}
.q-fields label {
  display: block;
  font-size: 0.76rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 0.4rem;
}
/* Single-field forms get full-width textareas. */
.q-fields.single-field {
  grid-template-columns: 1fr;
}
.q-fields textarea {
  font-size: 0.96rem;
  line-height: 1.55;
}

/* Save bar */
.save-bar {
  position: sticky;
  bottom: 0;
  background: var(--bg);
  padding: 1rem 0;
  margin-top: 2rem;
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  z-index: 5;
  flex-wrap: wrap;
}
.save-bar-info {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}
.save-bar-actions {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  flex-shrink: 0;
}
.save-progress {
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0.25rem 0.55rem;
  border: 1px solid var(--rule-strong);
  white-space: nowrap;
}
.save-progress.complete { color: var(--ok); border-color: var(--ok); }
.save-status {
  font-size: 0.85rem;
  color: var(--muted);
}
.save-status.ok { color: var(--ok); }
.save-status.err { color: var(--err); }
.save-status.saving { color: var(--accent); }
.save-status.offline { color: var(--important); }
.save-help {
  font-size: 0.78rem;
  color: var(--muted);
  margin-left: auto;
}
.save-help a { color: var(--muted); border-bottom: 1px solid currentColor; }
.save-help a:hover { color: var(--accent); }
@media (max-width: 640px) {
  .save-bar { flex-direction: column; align-items: stretch; }
  .save-bar-actions { justify-content: stretch; }
  .save-bar-actions .btn { flex: 1; }
  .save-help { margin-left: 0; }
}

/* Restored banner */
.restored-banner {
  display: flex;
  align-items: flex-start;
  gap: 0.8rem;
  background: var(--bg-soft);
  border-left: 3px solid var(--accent);
  padding: 0.9rem 1.1rem;
  margin-bottom: 1.6rem;
  font-size: 0.9rem;
  line-height: 1.55;
  color: var(--fg);
}
.restored-banner-text { flex: 1; }
.restored-banner-text strong { color: var(--fg); }
.restored-banner-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
  padding: 0 0.2rem;
}
.restored-banner-close:hover { color: var(--fg); }

/* Section progress pill */
details.section > summary .sec-progress {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  color: var(--muted);
  padding: 0.18rem 0.5rem;
  border: 1px solid var(--rule-strong);
  white-space: nowrap;
  margin-right: 0.7rem;
}
details.section > summary .sec-progress.full {
  color: var(--ok);
  border-color: var(--ok);
}

/* Session-expired modal */
.session-modal {
  position: fixed;
  inset: 0;
  background: rgba(26, 26, 26, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.2rem;
  z-index: 100;
}
.session-modal-card {
  background: var(--bg);
  max-width: 460px;
  width: 100%;
  border: 1px solid var(--rule-strong);
  padding: 2rem 2rem 1.6rem;
}
.session-modal-card h2 {
  font-size: 1.6rem;
  margin: 0.4rem 0 0.8rem;
}
.session-modal-card p {
  font-size: 0.92rem;
  line-height: 1.6;
  margin-bottom: 1.4rem;
  color: var(--muted);
}

/* Print stylesheet — clean printable record of the user's answers. */
@media print {
  body { background: #fff; color: #000; }
  header.site-header,
  footer.site-footer,
  .save-bar,
  .restored-banner,
  .session-modal,
  .session-bar,
  details.section > summary .sec-toggle { display: none !important; }
  main { max-width: none; padding: 0; }
  .form-hero { padding-top: 0; }
  .form-hero .vision { background: transparent; border-left: 2px solid #000; }
  .profile-card { background: transparent; border: 1px solid #999; break-inside: avoid; }
  details.section { border: 1px solid #999; break-inside: avoid; margin-bottom: 0.6rem; }
  details.section > summary { cursor: default; }
  details.section[open] > summary,
  details.section > summary { background: transparent !important; }
  details.section:not([open]) > .sec-body { display: block !important; } /* force open in print */
  .sec-body { padding: 0 1.2rem 1rem; }
  .question { padding: 0.8rem 0; break-inside: avoid; }
  textarea, input[readonly] { border: 1px solid #ccc !important; background: transparent !important; color: #000 !important; }
  textarea { min-height: 0; height: auto; resize: none; }
  a { color: #000; text-decoration: none; border-bottom: none; }
  .q-id { color: #000; }
  .priority { display: none; }
}

footer.site-footer {
  border-top: 1px solid var(--rule);
}
.footer-inner {
  max-width: var(--max);
  margin: 0 auto;
  padding: 1.6rem 2.5rem;
  font-size: 0.85rem;
  color: var(--muted);
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}
@media (max-width: 720px) {
  .footer-inner { padding: 1.2rem 1.2rem; }
}
footer.site-footer a { color: inherit; border: none; }
footer.site-footer a:hover { color: var(--fg); }

/* Loading state */
.loading {
  display: block;
  text-align: center;
  font-family: 'Cormorant Garamond', Georgia, serif;
  font-style: italic;
  font-size: 1.1rem;
  color: var(--muted);
  padding: 3rem 1rem;
}

@media (prefers-reduced-motion: no-preference) {
  .auth-card, .form-hero, .profile-card, details.section { animation: rise .5s ease both; }
  @keyframes rise {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
