:root {
  --burgundy: #660e1f;
  --burgundy-dark: #470914;
  --cream: #f5efe7;
  --paper: #fffdf9;
  --charcoal: #1b1715;
  --muted: #766d68;
  --soft-gold: #c6a785;
  --line: #ded4ca;
  --shadow: 0 24px 70px rgba(63, 34, 30, .11);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--charcoal);
  background:
    radial-gradient(circle at 15% 10%, rgba(198, 167, 133, .16), transparent 30rem),
    var(--cream);
  font-family: "DM Sans", system-ui, sans-serif;
  transition: background-color .45s ease, color .45s ease;
}

body.here-again-stage {
  --burgundy: #ad783e;
  --burgundy-dark: #82562c;
  --soft-gold: #cfb08b;
  --cream: #f8f3ec;
  --paper: #fffefa;
  --line: #e3d5c5;
}

body.companion-stage {
  --burgundy: #660e1f;
  --burgundy-dark: #470914;
  --soft-gold: #c6a785;
  --cream: #f5efe7;
  --paper: #fffdf9;
  --line: #ded4ca;
}

button, textarea { font: inherit; }
button { font: inherit; }

.shell { width: min(1080px, calc(100% - 32px)); margin: 0 auto; }

.brand {
  min-height: 86px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 13px;
  color: var(--charcoal);
  text-decoration: none;
  font-size: .72rem;
  font-weight: 600;
  letter-spacing: .16em;
}

.mark {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  color: white;
  background: var(--burgundy);
  border-radius: 50%;
  font-family: "Libre Franklin", sans-serif;
  letter-spacing: -.08em;
}

.quiet-button {
  border: 0;
  color: var(--muted);
  background: transparent;
  cursor: pointer;
}

.card {
  min-height: 660px;
  margin: 18px 0 24px;
  padding: clamp(34px, 7vw, 86px);
  background: rgba(255, 253, 249, .94);
  border: 1px solid rgba(198, 167, 133, .45);
  border-radius: 28px;
  box-shadow: var(--shadow);
}

.eyebrow {
  margin: 0 0 18px;
  color: var(--burgundy);
  font-size: .74rem;
  font-weight: 600;
  letter-spacing: .17em;
  text-transform: uppercase;
}

h1, h2 {
  max-width: 780px;
  margin: 0;
  font-family: "Libre Franklin", sans-serif;
  font-weight: 500;
  letter-spacing: -.045em;
  line-height: 1.04;
}

h1 { font-size: clamp(2.4rem, 6vw, 5.4rem); }
h2 { font-size: clamp(2rem, 4.5vw, 4rem); }

.lead {
  max-width: 690px;
  margin: 28px 0 0;
  color: #4f4743;
  font-size: clamp(1.05rem, 2vw, 1.26rem);
  line-height: 1.7;
}

.lead p { margin: 0 0 13px; }
.helper { max-width: 650px; margin: 18px 0 0; color: var(--muted); line-height: 1.55; }

.progress-wrap { margin: 0 0 42px; }
.progress-labels { display: flex; justify-content: space-between; color: var(--muted); font-size: .78rem; }
.track { height: 3px; margin-top: 12px; overflow: hidden; background: #e9e0d7; border-radius: 4px; }
.track span { display: block; height: 100%; background: var(--burgundy); transition: width .35s ease; }

textarea {
  width: 100%;
  min-height: 190px;
  margin-top: 30px;
  padding: 22px;
  resize: vertical;
  color: var(--charcoal);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 16px;
  outline: none;
  line-height: 1.6;
  transition: border-color .2s, box-shadow .2s;
}

textarea:focus { border-color: var(--soft-gold); box-shadow: 0 0 0 4px rgba(198,167,133,.15); }
textarea[readonly] { color: #5f5652; background: #f7f2ec; }

.saved { min-height: 20px; margin-top: 8px; color: var(--muted); font-size: .78rem; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; margin-top: 34px; }

.primary, .secondary {
  min-height: 50px;
  padding: 0 24px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 600;
}
.primary { color: #fff; background: var(--burgundy); border: 1px solid var(--burgundy); }
.primary:hover { background: var(--burgundy-dark); }
.primary:disabled { opacity: .38; cursor: not-allowed; }
.secondary { color: var(--burgundy); background: transparent; border: 1px solid var(--soft-gold); }

.holding-note {
  display: flex;
  gap: 13px;
  max-width: 650px;
  margin-top: 34px;
  padding: 18px 20px;
  color: #514844;
  background: #f6efe8;
  border-radius: 14px;
  line-height: 1.5;
}
.holding-note::before { content: "✓"; color: var(--burgundy); font-weight: 700; }

.format-tabs { display: inline-flex; gap: 5px; margin-top: 34px; padding: 5px; background: #eee5dc; border-radius: 999px; }
.format-tabs button { padding: 10px 22px; color: var(--muted); background: transparent; border: 0; border-radius: 999px; cursor: pointer; font-weight: 600; }
.format-tabs button.active { color: var(--burgundy); background: var(--paper); box-shadow: 0 2px 12px rgba(50,30,25,.08); }
.lesson-copy { max-width: 710px; margin-top: 32px; color: #4f4743; font-size: 1.08rem; line-height: 1.75; }
.lesson-copy p { margin: 0 0 17px; }
.lesson-copy h3 { margin: 40px 0 16px; color: var(--burgundy); font-family: "Libre Franklin", sans-serif; font-size: 1.45rem; letter-spacing: -.025em; }
.lesson-copy ul, .lesson-copy ol { margin: 0 0 24px; padding-left: 24px; }
.lesson-copy li { margin-bottom: 9px; }
.lesson-copy blockquote { margin: 24px 0; padding: 18px 22px; color: #3f3834; background: #f6efe8; border-left: 3px solid var(--soft-gold); border-radius: 0 12px 12px 0; }
.cover-card { text-align: center; }
.cover-card h1 { max-width: 900px; margin-inline: auto; text-transform: uppercase; font-size: clamp(2.5rem, 6.5vw, 5.8rem); line-height: 1.02; }
.cover-card .eyebrow { text-align: center; }
.cover-subtitle { margin: 28px 0 0; color: var(--burgundy); font-family: "Libre Franklin", sans-serif; font-size: clamp(1.05rem, 2vw, 1.35rem); font-weight: 600; line-height: 1.8; }
.cover-subtitle span { color: #b99a78; }
.cover-lines { display: grid; gap: 18px; max-width: 760px; margin: 34px auto; font-family: Georgia, serif; font-size: clamp(1.1rem, 2.2vw, 1.42rem); line-height: 1.65; }
.cover-lines strong { color: var(--burgundy); }
.cover-image { display: block; width: min(690px, 100%); margin: 36px auto 0; border-radius: 4px; }
.cover-card .actions { justify-content: center; }
.before-copy { margin-top: 28px; }
.field-label { display: block; margin: 26px 0 9px; color: var(--burgundy); font-weight: 600; }
.text-input { width: 100%; min-height: 50px; padding: 13px 15px; color: var(--charcoal); background: #fff; border: 1px solid var(--line); border-radius: 10px; font: inherit; }
.text-input:focus { outline: 2px solid rgba(102, 14, 31, .18); border-color: var(--burgundy); }
.area-list { columns: 2; column-gap: 42px; }
.question-guide { max-width: 700px; margin-top: 22px; padding: 18px 20px; color: #5f554f; background: #faf5ee; border-left: 3px solid var(--soft-gold); border-radius: 0 12px 12px 0; line-height: 1.65; }
.question-guide p { margin: 0; }
.bringing-together .lead strong { color: var(--burgundy); }
.commitment-section { max-width: 760px; margin-top: 38px; padding: 32px; background: #f6efe8; border-radius: 18px; }
.commitment-section h2 { font-size: clamp(1.8rem, 4vw, 3rem); }
.commitment-section > p:not(.eyebrow):not(.commitment-line) { line-height: 1.7; }
.commitment-section label { display: block; margin-top: 26px; color: var(--burgundy); }
.commitment-line { margin: 20px 0 0; color: var(--burgundy); font-weight: 600; }
.commitment-pledge { margin: 24px 0; padding: 22px; color: var(--burgundy); background: #fff; border-left: 3px solid var(--soft-gold); border-radius: 0 12px 12px 0; line-height: 1.65; }
.commitment-pledge p { margin: 0; }
.commitment-pledge p + p { margin-top: 14px; }
.signature-grid { display: grid; grid-template-columns: 1fr 180px; gap: 18px; margin-top: 20px; }
.signature-grid label { margin-top: 0; }
.signature-grid .text-input { margin-top: 8px; }
.commitment-confirmation { min-height: 24px; color: var(--burgundy); font-weight: 600; }
.keepsake-actions { margin-top: 22px; padding-top: 22px; border-top: 1px solid var(--line); }
.keepsake-actions .secondary:disabled { opacity: .4; cursor: not-allowed; }
.keepsake-actions p { margin: 10px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.print-keepsake { display: none; }
.final-card { overflow: hidden; }
.final-lead strong { color: var(--burgundy); }
.final-summary { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; max-width: 900px; margin-top: 42px; }
.final-summary > div { min-height: 180px; padding: 24px; background: #f6efe8; border-top: 3px solid var(--soft-gold); border-radius: 0 0 14px 14px; }
.final-summary span { color: var(--soft-gold); font-family: "Libre Franklin", sans-serif; font-size: 1.45rem; font-weight: 600; }
.final-summary p { margin: 24px 0 0; line-height: 1.65; }
.final-message { max-width: 780px; margin-top: 44px; padding: 34px; color: #2d211a; background: #c9a16f; border: 1px solid rgba(130, 86, 44, .28); border-radius: 20px; }
.final-message h2 { color: #2d211a; font-size: clamp(1.7rem, 3.5vw, 2.8rem); }
.final-message p { margin: 18px 0 0; color: #3f3026; line-height: 1.7; }
.final-reminder { max-width: 700px; margin-top: 30px; padding-left: 20px; border-left: 3px solid var(--soft-gold); }
.final-reminder p { margin: 0; color: #514844; font-family: Georgia, serif; font-size: 1.08rem; font-style: italic; line-height: 1.65; }
.final-actions { margin-top: 38px; }
.audio-card { display: flex; align-items: center; gap: 18px; max-width: 680px; margin-top: 32px; padding: 24px; background: #f6efe8; border: 1px solid var(--line); border-radius: 16px; }
.audio-card p { margin: 5px 0 0; color: var(--muted); }
.audio-card .audio-status { margin-top: 18px; font-size: .9rem; }
.audio-details { width: 100%; }
.audio-card audio { width: 100%; margin-top: 18px; accent-color: var(--burgundy); }
.audio-icon { width: 48px; height: 48px; display: grid; place-items: center; flex: 0 0 auto; color: white; background: var(--burgundy); border-radius: 50%; padding-left: 3px; }

.mirror { max-width: 760px; }
.mirror-section { padding: 28px 0; border-bottom: 1px solid var(--line); }
.mirror-section h3 { margin: 0 0 11px; color: var(--burgundy); font-size: .78rem; letter-spacing: .12em; text-transform: uppercase; }
.mirror-section p { margin: 0; font-size: 1.08rem; line-height: 1.65; }
.bridge { margin-top: 38px; padding: 28px; background: var(--burgundy); color: white; border-radius: 18px; }
.bridge p { margin: 0; line-height: 1.6; }
.bridge p + p { margin-top: 12px; }
.completion { max-width: 760px; margin-top: 38px; padding: 30px; color: var(--charcoal); background: #f6efe8; border-left: 4px solid var(--soft-gold); border-radius: 0 18px 18px 0; }
.completion h3 { margin: 0 0 14px; color: var(--burgundy); font-family: "Libre Franklin", sans-serif; font-size: 1.5rem; }
.completion p { margin: 0; line-height: 1.7; }
.completion p + p { margin-top: 12px; font-weight: 500; }

.privacy-note, .error-message {
  max-width: 700px;
  margin-top: 30px;
  padding: 20px 22px;
  color: #514844;
  background: #f6efe8;
  border: 1px solid var(--line);
  border-radius: 16px;
  line-height: 1.55;
}
.privacy-note p { margin: 7px 0 0; }
.companion-invitation { max-width: 700px; margin-top: 34px; padding: 26px; color: white; background: var(--burgundy); border-radius: 18px; }
.companion-invitation h2 { margin: 0 0 10px; color: white; font-size: clamp(1.5rem, 3vw, 2.25rem); }
.companion-invitation p { margin: 0; color: #f1dfd5; line-height: 1.6; }
.privacy-details { max-width: 700px; margin-top: 22px; color: var(--muted); font-size: .92rem; }
.privacy-details summary { cursor: pointer; color: var(--burgundy); font-weight: 600; }
.privacy-details p { margin: 12px 0 0; line-height: 1.6; }
.error-message { color: var(--burgundy-dark); border-color: rgba(102, 14, 31, .35); }

.centered-card { display: grid; align-content: center; justify-items: center; text-align: center; }
.centered-card .helper { text-align: center; }
.mirror-loader {
  width: 52px;
  height: 52px;
  margin-bottom: 28px;
  border: 3px solid #eadfd5;
  border-top-color: var(--burgundy);
  border-radius: 50%;
  animation: mirror-spin .9s linear infinite;
}
@keyframes mirror-spin { to { transform: rotate(360deg); } }

.thread-card {
  max-width: 760px;
  margin-top: 38px;
  padding: 30px;
  color: white;
  background: var(--burgundy);
  border-radius: 18px;
}
.thread-card .eyebrow { color: #e7cfb7; }
.thread-card > p:last-child { margin: 0; font-size: 1.18rem; line-height: 1.7; }

.accuracy-check {
  max-width: 760px;
  margin-top: 38px;
  padding: 28px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 18px;
}
.accuracy-check.confirmed { background: #f6efe8; }
.accuracy-check.confirmed h3 { margin: 0 0 8px; color: var(--burgundy); }
.accuracy-check.confirmed p { margin: 0; line-height: 1.6; }
.accuracy-actions { display: grid; gap: 10px; }
.accuracy-actions .secondary { min-height: 48px; text-align: left; }
.correction-box { margin-top: 24px; padding-top: 24px; border-top: 1px solid var(--line); }
.correction-box label { display: block; font-weight: 600; }
.correction-box textarea { min-height: 130px; margin: 12px 0 16px; }

@media (prefers-reduced-motion: reduce) {
  .mirror-loader { animation: none; }
}

@media print {
  @page { size: letter; margin: .65in; }
  * { box-shadow: none !important; }
  body, body.here-again-stage, body.companion-stage { color: #211a18; background: #fff; }
  .shell { width: 100%; margin: 0; }
  .brand, footer, #app > .card > :not(.print-keepsake) { display: none !important; }
  #app, #app > .card { display: block; min-height: 0; margin: 0; padding: 0; background: #fff; border: 0; }
  .print-keepsake { display: block !important; color: #211a18; font-family: Georgia, serif; }
  .print-title { margin-bottom: 32px; padding-bottom: 22px; text-align: center; border-bottom: 2px solid #660e1f; }
  .print-title > p:first-child { margin: 0 0 8px; color: #96724f; font-family: "DM Sans", sans-serif; font-size: 9pt; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; }
  .print-title h1 { margin: 0; color: #660e1f; font-size: 28pt; letter-spacing: -.02em; }
  .print-title > p:last-child { margin: 10px 0 0; font-size: 11pt; }
  .print-section, .print-thread { break-inside: avoid; margin: 0 0 18px; }
  .print-section h2, .print-thread h2, .print-personal h2 { margin: 0 0 6px; color: #660e1f; font-family: "DM Sans", sans-serif; font-size: 9pt; font-weight: 600; letter-spacing: .08em; line-height: 1.35; text-transform: uppercase; }
  .print-section p, .print-thread p, .print-personal p { margin: 0; font-size: 11pt; line-height: 1.55; }
  .print-thread { padding: 18px 20px; color: #fff; background: #660e1f !important; border-radius: 8px; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-thread h2 { color: #e8cfb5; }
  .print-commitment { break-inside: avoid; margin-top: 28px; padding: 22px; background: #f6efe8 !important; border-left: 4px solid #c6a785; print-color-adjust: exact; -webkit-print-color-adjust: exact; }
  .print-commitment > p { margin: 0 0 12px; font-size: 11pt; line-height: 1.55; }
  .print-label { color: #660e1f; font-family: "DM Sans", sans-serif; font-size: 9pt !important; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; }
  .print-personal { margin: 20px 0; padding-top: 16px; border-top: 1px solid #d8c9bb; }
  .print-signature { display: flex; justify-content: space-between; gap: 30px; margin-top: 24px; font-size: 10pt; }
  .print-signature span { min-width: 42%; padding-bottom: 5px; border-bottom: 1px solid #7b6e66; }
  .print-footnote { margin: 24px 0 0; color: #71665f; font-size: 8.5pt; line-height: 1.5; text-align: center; }
}

.site-footer { display: flex; justify-content: space-between; align-items: center; gap: 18px; padding: 0 6px 32px; color: var(--muted); font-size: .75rem; }
.footer-links { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 14px; }
.footer-links button, .footer-links a, .legal-small button, .legal-consent button { padding: 0; color: var(--muted); background: transparent; border: 0; cursor: pointer; font: inherit; text-decoration: underline; text-underline-offset: 3px; }
.footer-links button:hover, .footer-links a:hover, .legal-small button:hover, .legal-consent button:hover { color: var(--burgundy); }
.legal-gate { min-height: 600px; }
.legal-consent { display: flex; align-items: flex-start; gap: 13px; max-width: 720px; margin-top: 34px; padding: 20px; background: #f6efe8; border: 1px solid var(--line); border-radius: 14px; line-height: 1.55; }
.legal-consent input { width: 19px; height: 19px; flex: 0 0 auto; margin-top: 2px; accent-color: var(--burgundy); }
.legal-consent button, .legal-small button { color: var(--burgundy); font-weight: 600; }
.legal-small { max-width: 700px; margin: 16px 0 0; color: var(--muted); font-size: .88rem; line-height: 1.5; }
.legal-dialog { width: min(820px, calc(100% - 28px)); max-height: min(88vh, 900px); padding: 0; color: var(--charcoal); background: var(--paper); border: 1px solid var(--line); border-radius: 22px; box-shadow: 0 28px 90px rgba(32, 18, 16, .28); }
.legal-dialog::backdrop { background: rgba(27, 23, 21, .56); backdrop-filter: blur(3px); }
.legal-dialog-inner { position: relative; padding: clamp(30px, 6vw, 64px); }
.legal-close { position: sticky; top: 0; z-index: 2; float: right; width: 42px; height: 42px; display: grid; place-items: center; margin: -12px -12px 8px 18px; color: var(--charcoal); background: var(--cream); border: 1px solid var(--line); border-radius: 50%; cursor: pointer; font-size: 1.6rem; line-height: 1; }
.legal-dialog article { max-width: 690px; }
.legal-dialog h1 { font-size: clamp(2.1rem, 6vw, 4rem); }
.legal-dialog h2 { margin: 34px 0 10px; color: var(--burgundy); font-size: 1.15rem; letter-spacing: -.015em; line-height: 1.3; }
.legal-dialog p { margin: 12px 0 0; line-height: 1.7; }
.legal-dialog a { color: var(--burgundy); }
.crisis-emergency { margin: 28px 0; padding: 20px 22px; color: var(--burgundy-dark); background: #f6efe8; border-left: 4px solid var(--burgundy); border-radius: 0 12px 12px 0; line-height: 1.55; }

@media (max-width: 640px) {
  .shell { width: min(100% - 20px, 1080px); }
  .brand { min-height: 72px; }
  .wordmark span:last-child { display: none; }
  .card { min-height: calc(100vh - 145px); margin-top: 8px; border-radius: 20px; }
  .site-footer { align-items: flex-start; padding: 4px 4px 24px; }
  .site-footer > span { display: none; }
  .footer-links { justify-content: center; width: 100%; gap: 10px 16px; }
  .area-list { columns: 1; }
  .cover-card { padding-inline: 24px; }
  .commitment-section { padding: 24px; }
  .signature-grid { grid-template-columns: 1fr; }
  .final-summary { grid-template-columns: 1fr; }
  .final-summary > div { min-height: 0; }
  .final-message { padding: 26px; }
}
