:root {
  --recovery-bg: #f1eadc;
  --recovery-paper: #fffdf7;
  --recovery-ink: #241b14;
  --recovery-muted: #67594d;
  --recovery-line: rgba(61, 43, 27, 0.16);
  --recovery-leaf: #526d2b;
  --recovery-leaf-dark: #33491d;
  --recovery-clay: #9a5c37;
  --recovery-gold: #c99c45;
  --recovery-red: #984a3b;
  --recovery-shadow: 0 22px 60px rgba(65, 42, 19, 0.11);
  --recovery-radius: 24px;
  --recovery-display: 'Fraunces', Georgia, serif;
  --recovery-body: 'Manrope', system-ui, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  background:
    radial-gradient(circle at 92% 2%, rgba(201, 156, 69, 0.22), transparent 25rem),
    radial-gradient(circle at 0% 35%, rgba(82, 109, 43, 0.13), transparent 28rem),
    var(--recovery-bg);
  color: var(--recovery-ink);
  font-family: var(--recovery-body);
  line-height: 1.6;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: '';
  opacity: 0.045;
  mix-blend-mode: multiply;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 180 180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}

a {
  color: var(--recovery-leaf-dark);
}

button,
input,
textarea {
  font: inherit;
}

button,
label,
input[type='radio'],
input[type='checkbox'] {
  cursor: pointer;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
textarea:focus-visible {
  outline: 3px solid rgba(201, 156, 69, 0.95);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.recovery-container {
  width: min(1040px, calc(100% - 40px));
  margin: 0 auto;
}

.recovery-header {
  padding: 24px 0;
  border-bottom: 1px solid rgba(61, 43, 27, 0.08);
}

.header-row,
.footer-row,
.progress-row,
.record-controls,
.step-actions,
.safety-card-heading,
.recovery-intro,
.save-banner {
  display: flex;
  align-items: center;
}

.header-row,
.footer-row {
  justify-content: space-between;
  gap: 18px;
}

.wordmark {
  color: var(--recovery-ink);
  font-family: var(--recovery-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  text-decoration: none;
}

.back-link,
.footer-row {
  font-size: 0.88rem;
  font-weight: 800;
}

.recovery-intro {
  align-items: end;
  justify-content: space-between;
  gap: 48px;
  padding: 72px 0 42px;
}

.recovery-intro > div {
  max-width: 610px;
}

.eyebrow {
  margin: 0 0 12px;
  color: var(--recovery-leaf);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1,
h2,
h3 {
  line-height: 1.05;
  letter-spacing: -0.035em;
}

h1,
h2 {
  font-family: var(--recovery-display);
}

h1 {
  max-width: 9ch;
  margin-bottom: 18px;
  font-size: clamp(3.2rem, 8vw, 6.4rem);
  font-weight: 500;
}

h2 {
  margin-bottom: 14px;
  font-size: clamp(1.9rem, 4vw, 3.2rem);
  font-weight: 500;
}

h3 {
  font-size: 1.12rem;
}

.intro-lead,
.step-heading > p:last-child,
.section-heading > p:last-child {
  max-width: 62ch;
  margin-bottom: 0;
  color: var(--recovery-muted);
  font-size: 1.02rem;
}

.privacy-card,
.safety-card,
.flow-step,
.records-panel,
.route-note,
.noscript-card {
  border: 1px solid var(--recovery-line);
  border-radius: var(--recovery-radius);
  background: rgba(255, 253, 247, 0.82);
  box-shadow: 0 14px 38px rgba(65, 42, 19, 0.06);
}

.privacy-card {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  width: min(100%, 330px);
  padding: 18px;
  transform: rotate(1.2deg);
  background: rgba(255, 252, 241, 0.9);
}

.privacy-card p,
.privacy-card strong {
  display: block;
}

.privacy-card p {
  margin: 6px 0 0;
  color: var(--recovery-muted);
  font-size: 0.86rem;
  line-height: 1.5;
}

.privacy-mark,
.status-mark {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  color: white;
  background: var(--recovery-leaf);
  font-size: 1.2rem;
  font-weight: 800;
}

.safety-card {
  display: grid;
  grid-template-columns: minmax(220px, 0.75fr) 1.25fr;
  gap: 30px;
  margin-bottom: 24px;
  padding: 26px 30px;
  color: white;
  background: linear-gradient(132deg, #2b1c13, #503521 58%, #67482a);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: var(--recovery-shadow);
}

.safety-card .eyebrow {
  color: #e8ca87;
}

.safety-card h2,
.safety-card p {
  color: white;
}

.safety-card-heading {
  align-items: flex-start;
}

.safety-card-heading h2 {
  margin-bottom: 0;
  font-size: clamp(1.55rem, 3vw, 2.35rem);
}

.safety-copy p {
  margin-bottom: 10px;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.93rem;
}

.safety-copy p:last-child {
  margin-bottom: 0;
}

.progress-row {
  justify-content: space-between;
  gap: 16px;
  margin: 38px 0 12px;
  color: var(--recovery-muted);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.step-kicker {
  color: var(--recovery-leaf);
}

.flow-step {
  padding: clamp(24px, 5vw, 50px);
  box-shadow: var(--recovery-shadow);
}

.step-heading {
  max-width: 700px;
  margin-bottom: 32px;
}

.step-heading h2 {
  margin-bottom: 12px;
}

.choice-fieldset,
.safety-check {
  min-width: 0;
  margin: 0 0 26px;
  padding: 0;
  border: 0;
}

.choice-fieldset legend,
.safety-check legend {
  margin-bottom: 12px;
  color: var(--recovery-ink);
  font-size: 1.08rem;
  font-weight: 800;
}

.choice-card,
.check-row,
.action-choice,
.follow-up-choice {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  margin: 10px 0;
  padding: 16px 18px;
  border: 1px solid var(--recovery-line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.choice-card:hover,
.check-row:hover,
.action-choice:hover,
.follow-up-choice:hover {
  border-color: rgba(82, 109, 43, 0.6);
  background: rgba(239, 246, 225, 0.8);
  transform: translateY(-1px);
}

.choice-card input,
.check-row input,
.action-choice input,
.follow-up-choice input {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  margin: 2px 0 0;
  accent-color: var(--recovery-leaf);
}

.choice-card span,
.check-row span,
.action-choice span,
.follow-up-choice span {
  display: grid;
  gap: 3px;
}

.choice-card strong,
.check-row strong,
.action-choice strong,
.follow-up-choice strong {
  line-height: 1.35;
}

.choice-card small,
.check-row small,
.action-choice small,
.follow-up-choice small {
  color: var(--recovery-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.choice-card.compact {
  display: inline-flex;
  width: calc(33.333% - 9px);
  vertical-align: top;
}

.safety-check {
  padding: 20px;
  border: 1px solid rgba(154, 92, 55, 0.22);
  border-radius: 18px;
  background: rgba(250, 243, 225, 0.8);
}

.warning-check {
  border-color: rgba(154, 74, 59, 0.3);
  background: rgba(255, 246, 239, 0.88);
}

.field-error {
  margin: 8px 0 0;
  color: var(--recovery-red);
  font-size: 0.88rem;
  font-weight: 800;
}

[aria-invalid='true'] {
  outline: 2px solid var(--recovery-red);
  outline-offset: 2px;
}

.error-summary {
  margin: 24px 0 0;
  padding: 18px 22px;
  border-left: 5px solid var(--recovery-red);
  border-radius: 12px;
  background: #fff5ef;
  color: var(--recovery-red);
}

.error-summary h2 {
  margin-bottom: 8px;
  font-family: var(--recovery-body);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
}

.error-summary ul {
  margin: 0;
  padding-left: 20px;
}

.step-actions {
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.btn {
  display: inline-flex;
  min-height: 50px;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  border: 1px solid transparent;
  border-radius: 999px;
  font-weight: 800;
  text-decoration: none;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn:hover {
  transform: translateY(-2px);
}

.btn-primary {
  color: white;
  background: linear-gradient(135deg, var(--recovery-leaf), var(--recovery-leaf-dark));
  box-shadow: 0 12px 24px rgba(82, 109, 43, 0.22);
}

.btn-secondary,
.btn-quiet {
  border-color: var(--recovery-line);
  color: var(--recovery-ink);
  background: rgba(255, 255, 255, 0.45);
}

.btn-quiet {
  border-color: transparent;
  color: var(--recovery-muted);
}

.btn-danger {
  border-color: rgba(154, 74, 59, 0.24);
  color: var(--recovery-red);
  background: #fff5ef;
}

.dynamic-fields {
  display: grid;
  gap: 16px;
}

.dynamic-fields fieldset {
  min-width: 0;
  margin: 0;
  padding: 18px;
  border: 1px solid var(--recovery-line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.52);
}

.dynamic-fields legend {
  max-width: 60ch;
  padding: 0 6px;
  font-weight: 800;
}

.action-choice,
.follow-up-choice {
  margin: 8px 0;
}

.action-guidance,
.action-safety,
.follow-up-guidance {
  margin: 9px 0 0;
  color: var(--recovery-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.action-safety {
  color: var(--recovery-red);
}

.confirmation-card {
  margin-bottom: 28px;
  padding: 22px;
  border: 1px solid rgba(82, 109, 43, 0.2);
  border-radius: 18px;
  background: rgba(239, 246, 225, 0.72);
}

.confirmation-card h3 {
  margin-bottom: 8px;
}

.confirmation-card p {
  margin-bottom: 10px;
  color: var(--recovery-muted);
  font-size: 0.9rem;
}

.confirmation-card p:last-child {
  margin-bottom: 0;
}

.note-field {
  display: grid;
  gap: 10px;
  margin-top: 26px;
}

.note-field span {
  display: grid;
  gap: 3px;
}

.note-field small {
  color: var(--recovery-muted);
}

textarea {
  width: 100%;
  resize: vertical;
  padding: 14px;
  border: 1px solid var(--recovery-line);
  border-radius: 14px;
  color: var(--recovery-ink);
  background: rgba(255, 255, 255, 0.72);
}

.escalation-card {
  margin-top: 24px;
  padding: 28px 30px;
  border: 2px solid rgba(154, 74, 59, 0.34);
  border-radius: var(--recovery-radius);
  background: #fff5ef;
}

.escalation-card .eyebrow,
.escalation-card h2 {
  color: var(--recovery-red);
}

.escalation-card p:not(.eyebrow) {
  max-width: 70ch;
  color: #67443b;
}

.save-banner {
  align-items: flex-start;
  gap: 14px;
  margin-top: 24px;
  padding: 20px 22px;
  border: 1px solid rgba(82, 109, 43, 0.22);
  border-radius: 18px;
  background: rgba(239, 246, 225, 0.86);
}

.save-banner strong,
.save-banner p {
  display: block;
}

.save-banner p {
  margin: 5px 0 0;
  color: var(--recovery-muted);
  font-size: 0.9rem;
}

.records-panel {
  margin: 24px 0 0;
  padding: clamp(24px, 5vw, 42px);
}

.compact-heading {
  margin-bottom: 24px;
}

.compact-heading h2 {
  margin-bottom: 8px;
}

.storage-status {
  margin: 0 0 18px;
  color: var(--recovery-muted);
  font-size: 0.9rem;
}

.storage-status.storage-blocked {
  padding: 12px 14px;
  border-radius: 12px;
  color: #754735;
  background: #fff5e2;
}

.record-controls {
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 24px;
}

.record-controls .btn {
  min-height: 44px;
  padding: 0 15px;
  font-size: 0.86rem;
}

#import-file {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  clip-path: inset(50%);
}

.saved-records {
  display: grid;
  gap: 18px;
}

.empty-records {
  margin: 0;
  padding: 20px;
  border: 1px dashed var(--recovery-line);
  border-radius: 16px;
  color: var(--recovery-muted);
}

.record-card {
  padding: 24px;
  border: 1px solid var(--recovery-line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.62);
}

.record-card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.record-card-header h3 {
  margin-bottom: 5px;
}

.record-card-header p,
.record-meta,
.record-note,
.record-follow-up p {
  margin-bottom: 0;
  color: var(--recovery-muted);
  font-size: 0.88rem;
}

.record-meta {
  text-align: right;
}

.record-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.record-block {
  padding-top: 14px;
  border-top: 1px solid var(--recovery-line);
}

.record-block h4 {
  margin: 0 0 6px;
  font-size: 0.82rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.record-block p,
.record-block ul {
  margin: 0;
  color: var(--recovery-muted);
  font-size: 0.9rem;
}

.record-block ul {
  padding-left: 18px;
}

.record-note {
  margin-top: 16px;
  padding: 14px;
  border-radius: 12px;
  white-space: pre-wrap;
  background: rgba(250, 243, 225, 0.72);
}

.record-follow-up {
  margin-top: 20px;
  padding-top: 18px;
  border-top: 1px solid var(--recovery-line);
}

.record-follow-up h4 {
  margin-bottom: 5px;
}

.follow-up-form {
  display: grid;
  grid-template-columns: 0.7fr 1fr;
  gap: 12px;
  margin-top: 14px;
}

.follow-up-form label {
  display: grid;
  gap: 5px;
  color: var(--recovery-muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.follow-up-form input,
.follow-up-form select {
  width: 100%;
  min-height: 44px;
  padding: 0 10px;
  border: 1px solid var(--recovery-line);
  border-radius: 10px;
  color: var(--recovery-ink);
  background: white;
}

.follow-up-form textarea {
  grid-column: 1 / -1;
}

.follow-up-form button {
  grid-column: 1 / -1;
  justify-self: start;
  min-height: 42px;
}

.route-note,
.noscript-card {
  margin: 24px 0;
  padding: 18px 22px;
}

.route-note p,
.noscript-card p {
  margin: 0;
  color: var(--recovery-muted);
  font-size: 0.88rem;
}

.print-area {
  display: none;
}

.print-card {
  padding: 28px;
  border: 1px solid #b7ab9b;
  border-radius: 2px;
}

.print-card h1,
.print-card h2,
.print-card h3 {
  max-width: none;
  margin-bottom: 8px;
  font-family: var(--recovery-display);
}

.print-card h1 {
  font-size: 2.2rem;
}

.print-card h2 {
  font-size: 1.45rem;
}

.print-card h3 {
  font-family: var(--recovery-body);
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.print-card p,
.print-card li {
  font-size: 0.9rem;
}

.recovery-footer {
  padding: 36px 0 50px;
}

.footer-row {
  color: var(--recovery-muted);
}

@media (max-width: 760px) {
  .recovery-intro {
    align-items: stretch;
    flex-direction: column;
    gap: 28px;
    padding-top: 48px;
  }

  .privacy-card {
    align-self: flex-end;
  }

  .safety-card {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .choice-card.compact {
    display: flex;
    width: 100%;
  }

  .record-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .recovery-container {
    width: min(100% - 24px, 1040px);
  }

  h1 {
    font-size: 3.35rem;
  }

  .recovery-header {
    padding: 18px 0;
  }

  .back-link {
    font-size: 0.78rem;
  }

  .safety-card,
  .flow-step,
  .records-panel,
  .escalation-card {
    padding: 22px 18px;
  }

  .record-card-header,
  .footer-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .record-meta {
    text-align: left;
  }

  .follow-up-form {
    grid-template-columns: 1fr;
  }
}

@media print {
  @page {
    margin: 16mm;
  }

  body {
    min-width: 0;
    background: white;
    color: #111;
    font-family: Georgia, serif;
  }

  body::before,
  .no-print,
  .recovery-header,
  .recovery-footer,
  .recovery-intro,
  .safety-card,
  .progress-row,
  #recovery-form,
  #unsafe-escalation,
  #save-confirmation,
  #records-panel,
  .route-note,
  .noscript-card,
  #error-summary {
    display: none !important;
  }

  #recovery-app {
    width: 100%;
    margin: 0;
  }

  #print-area,
  #print-area[hidden] {
    display: block !important;
  }

  .print-area {
    color: #111;
  }

  .print-card {
    display: block;
    border-color: #777;
    box-shadow: none;
    page-break-inside: avoid;
  }

  .print-card + .print-card {
    margin-top: 16mm;
  }

  a {
    color: #111;
    text-decoration: none;
  }
}

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