/* ============================================================
   Memolio — Web Intake
   Warm watercolour heritage system. Tokens lifted from the
   production site (memolio.io). Vanilla CSS, mobile-first.
   ============================================================ */

:root {
  /* Colour tokens (production) */
  --paper:           #F9F3E8;
  --warm-white:      #FFFDF8;
  --paper-dark:      #EFE6D5;
  --terracotta:      #C17B5D;
  --terracotta-dark: #A65D3F;
  --forest-green:    #5B7C65;
  --deep-brown:      #5C4934;
  --soft-brown:      #8B7355;
  --text-primary:    #3D3225;
  --text-secondary:  #6B5D4D;

  --watercolor-blue:  rgba(156, 192, 196, 0.30);
  --watercolor-peach: rgba(222, 184, 162, 0.32);
  --watercolor-sage:  rgba(156, 175, 136, 0.28);

  --line:        rgba(139, 115, 85, 0.22);
  --line-strong: rgba(139, 115, 85, 0.34);
  --shadow-warm:        rgba(139, 115, 85, 0.18);
  --shadow-warm-strong: rgba(139, 115, 85, 0.30);
  --invalid: #C15353;

  /* Type */
  --serif-display: 'Cormorant Garamond', Georgia, serif;
  --serif-body:    'Lora', Georgia, serif;
  --hand:          'Caveat', 'Lora', cursive;
  --ui:            'Quicksand', system-ui, sans-serif;

  --radius-card: 18px;
  --radius-field: 12px;
  --radius-pill: 30px;
  --maxw: 660px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--serif-body);
  background-color: var(--paper);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Paper grain overlay — same recipe as the site */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  opacity: 0.10;
  pointer-events: none;
  z-index: 9000;
  mix-blend-mode: multiply;
}

/* ---------- App shell ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app__header {
  position: sticky;
  top: 0;
  z-index: 60;
  background: rgba(249, 243, 232, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--line);
}

.brandbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 14px 20px 10px;
}
.brandbar__logo { height: 26px; width: auto; display: block; }
.brandbar__save {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-family: var(--hand);
  font-size: 1.18rem;
  color: var(--forest-green);
  opacity: 0;
  transform: translateY(-2px);
  transition: opacity .4s ease, transform .4s ease;
  white-space: nowrap;
}
.brandbar__save.show { opacity: 1; transform: none; }
.brandbar__save svg { width: 16px; height: 16px; }

/* ---------- Chip bar ---------- */
.chips-wrap { position: relative; }
.chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scroll-behavior: smooth;
  scrollbar-width: none;
  padding: 4px 20px 14px;
  max-width: var(--maxw);
  margin: 0 auto;
}
.chips::-webkit-scrollbar { display: none; }
/* edge fades that hint horizontal scroll */
.chips-wrap::before,
.chips-wrap::after {
  content: '';
  position: absolute;
  top: 0; bottom: 14px;
  width: 26px;
  pointer-events: none;
  z-index: 2;
}
.chips-wrap::before { left: 0;  background: linear-gradient(90deg, var(--paper), transparent); }
.chips-wrap::after  { right: 0; background: linear-gradient(270deg, var(--paper), transparent); }

.chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 8px 15px;
  border-radius: var(--radius-pill);
  border: 1.5px solid var(--paper-dark);
  background: var(--paper-dark);
  color: var(--text-secondary);
  font-family: var(--ui);
  font-size: 0.86rem;
  font-weight: 600;
  letter-spacing: 0.005em;
  cursor: pointer;
  white-space: nowrap;
  transition: background .2s, border-color .2s, color .2s, transform .15s;
}
.chip:hover { transform: translateY(-1px); }
.chip__idx {
  font-variant-numeric: tabular-nums;
  opacity: 0.6;
  font-size: 0.8rem;
}
.chip__tick {
  display: none;
  width: 15px; height: 15px;
  color: var(--forest-green);
}
/* states */
.chip[data-state="progress"] {
  background: var(--warm-white);
  border-color: var(--terracotta);
  color: var(--terracotta-dark);
}
.chip[data-state="complete"] {
  background: rgba(91,124,101,0.10);
  border-color: rgba(91,124,101,0.45);
  color: var(--forest-green);
}
.chip[data-state="complete"] .chip__tick { display: block; }
.chip[data-state="complete"] .chip__idx { display: none; }
.chip.is-active {
  background: var(--terracotta);
  border-color: var(--terracotta);
  color: var(--warm-white);
  box-shadow: 0 4px 12px rgba(193,123,93,0.32);
}
.chip.is-active .chip__idx { opacity: .85; color: inherit; }
.chip.is-active .chip__tick { color: var(--warm-white); }

/* ---------- Section body ---------- */
.main { flex: 1 0 auto; }
.section {
  max-width: var(--maxw);
  margin: 0 auto;
  padding: 8px 20px 40px;
  animation: sectionIn .45s ease;
}
@keyframes sectionIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

.section__head {
  position: relative;
  padding: 30px 6px 22px;
  text-align: center;
  overflow: hidden;
}
/* soft watercolour wash behind each section header */
.section__head::before {
  content: '';
  position: absolute;
  top: -40px; left: 50%;
  width: 360px; height: 220px;
  transform: translateX(-50%);
  background:
    radial-gradient(60px 50px at 30% 45%, var(--watercolor-peach), transparent 70%),
    radial-gradient(70px 55px at 64% 40%, var(--watercolor-sage), transparent 72%),
    radial-gradient(55px 45px at 50% 62%, var(--watercolor-blue), transparent 70%);
  filter: blur(8px);
  opacity: 0.7;
  pointer-events: none;
  z-index: 0;
}
.section__eyebrow {
  position: relative;
  font-family: var(--ui);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--soft-brown);
  margin-bottom: 8px;
}
.section__title {
  position: relative;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: clamp(2rem, 7vw, 2.7rem);
  line-height: 1.08;
  color: var(--deep-brown);
  letter-spacing: 0.005em;
}
.section__intro {
  position: relative;
  margin: 12px auto 0;
  max-width: 46ch;
  color: var(--text-secondary);
  font-size: 1.04rem;
}
.section__intro .hand {
  font-family: var(--hand);
  font-size: 1.32rem;
  color: var(--terracotta-dark);
  display: block;
  margin-top: 6px;
}

/* ---------- Question block ---------- */
.qlist { display: flex; flex-direction: column; gap: 22px; }
.q {
  display: flex;
  flex-direction: column;
  gap: 9px;
}
.q__label {
  font-family: var(--ui);
  font-weight: 600;
  font-size: 1rem;
  color: var(--deep-brown);
  line-height: 1.35;
}
.q__req { color: var(--terracotta); margin-left: 2px; }
.q__opt {
  font-family: var(--ui);
  font-weight: 500;
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-left: 6px;
  opacity: 0.8;
}
.q__help {
  font-size: 0.92rem;
  color: var(--text-secondary);
  margin-top: -3px;
  line-height: 1.45;
}

/* ---------- Text / email / year inputs ---------- */
.field {
  font-family: var(--serif-body);
  font-size: 1.04rem;
  color: var(--text-primary);
  background: var(--warm-white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
  padding: 13px 15px;
  width: 100%;
  transition: border-color .2s, background .2s, box-shadow .2s;
}
.field::placeholder { color: rgba(107,93,77,0.5); }
.field:focus {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(193,123,93,0.14);
}
.field.is-invalid { border-color: var(--invalid); background: rgba(193,83,83,0.04); }
.field--year { max-width: 160px; }
.field--age  { max-width: 220px; }

.row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 460px) { .row-2 { grid-template-columns: 1fr; } }

/* ---------- Choice pills (gender etc.) ---------- */
.pills {
  display: flex;
  gap: 7px;
  background: var(--paper-dark);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
  padding: 5px;
}
.pill {
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 11px 12px;
  font-family: var(--ui);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-secondary);
  border-radius: 9px;
  cursor: pointer;
  text-align: center;
  white-space: nowrap;
  transition: background .18s, color .18s, box-shadow .18s;
}
.pill:hover { color: var(--deep-brown); }
.pill[aria-checked="true"] {
  background: var(--terracotta);
  color: var(--warm-white);
  box-shadow: 0 2px 8px rgba(193,123,93,0.32);
}

/* count selector (1 / 2 / 3) */
.count { max-width: 280px; }
.count .pill[aria-checked="true"] { background: var(--forest-green); box-shadow: 0 2px 8px rgba(91,124,101,0.32); }

/* ---------- Select (dropdown choice, e.g. ethnicity) ---------- */
.select-wrap { position: relative; }
.select-wrap::after {
  content: '';
  position: absolute;
  right: 16px; top: 50%;
  width: 9px; height: 9px;
  border-right: 2px solid var(--soft-brown);
  border-bottom: 2px solid var(--soft-brown);
  transform: translateY(-65%) rotate(45deg);
  pointer-events: none;
}
select.field {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 40px;
  cursor: pointer;
}
select.field:invalid, select.field.placeholder { color: rgba(107,93,77,0.5); }

/* ---------- Yes / No toggle ---------- */
.yesno { display: flex; gap: 12px; }
.yesno .pill {
  flex: 0 1 130px;
  border: 1.5px solid var(--line);
  background: var(--warm-white);
  border-radius: var(--radius-field);
  padding: 13px 16px;
}
.yesno .pill[aria-checked="true"] {
  background: var(--forest-green);
  border-color: var(--forest-green);
  color: var(--warm-white);
}

/* ---------- Long text + dictation ---------- */
.dictation { position: relative; }
.dictation__area {
  font-family: var(--serif-body);
  font-size: 1.04rem;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--warm-white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-field);
  padding: 14px 15px 46px;
  width: 100%;
  min-height: 120px;
  resize: vertical;
  transition: border-color .2s, box-shadow .2s;
}
.dictation__area::placeholder { color: rgba(107,93,77,0.5); }
.dictation__area:focus {
  outline: none;
  border-color: var(--terracotta);
  box-shadow: 0 0 0 3px rgba(193,123,93,0.14);
}
.dictation.is-invalid .dictation__area { border-color: var(--invalid); }

/* mic button (resting) */
.mic {
  position: absolute;
  right: 10px; bottom: 10px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 13px 0 11px;
  border: 1.5px solid var(--line);
  background: var(--paper);
  color: var(--terracotta-dark);
  border-radius: var(--radius-pill);
  font-family: var(--ui);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, border-color .2s, transform .15s;
}
.mic:hover { background: var(--warm-white); border-color: var(--terracotta); transform: translateY(-1px); }
.mic svg { width: 16px; height: 16px; }

/* state machine on the wrapper */
.dictation__rec, .dictation__trans { display: none; }
.dictation[data-mic="recording"] .mic,
.dictation[data-mic="transcribing"] .mic { display: none; }
.dictation[data-mic="recording"] .dictation__rec { display: flex; }
.dictation[data-mic="transcribing"] .dictation__trans { display: flex; }

/* recording bar */
.dictation__rec {
  position: absolute;
  left: 10px; right: 10px; bottom: 10px;
  align-items: center;
  gap: 11px;
  padding: 8px 10px 8px 13px;
  background: var(--warm-white);
  border: 1.5px solid var(--terracotta);
  border-radius: var(--radius-pill);
  box-shadow: 0 6px 18px rgba(193,123,93,0.18);
}
.rec-dot {
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--terracotta);
  flex: 0 0 auto;
  animation: recPulse 1.1s ease-in-out infinite;
}
@keyframes recPulse {
  0%,100% { opacity: 1; transform: scale(1); box-shadow: 0 0 0 0 rgba(193,123,93,0.4); }
  50%     { opacity: .55; transform: scale(.78); box-shadow: 0 0 0 7px rgba(193,123,93,0); }
}
.rec-label { font-family: var(--ui); font-weight: 600; font-size: 0.9rem; color: var(--deep-brown); }
.rec-wave { display: flex; align-items: center; gap: 3px; flex: 1; height: 22px; overflow: hidden; }
.rec-wave span {
  flex: 1;
  max-width: 4px;
  background: var(--terracotta);
  border-radius: 2px;
  opacity: 0.65;
  animation: wave 1s ease-in-out infinite;
}
.rec-wave span:nth-child(2n)  { animation-delay: .15s; }
.rec-wave span:nth-child(3n)  { animation-delay: .3s; }
.rec-wave span:nth-child(4n)  { animation-delay: .45s; }
@keyframes wave { 0%,100% { height: 6px; } 50% { height: 20px; } }
.rec-stop {
  flex: 0 0 auto;
  display: inline-flex; align-items: center; gap: 6px;
  height: 32px; padding: 0 14px;
  border: none;
  background: var(--terracotta);
  color: var(--warm-white);
  border-radius: var(--radius-pill);
  font-family: var(--ui); font-weight: 700; font-size: 0.82rem;
  cursor: pointer;
}
.rec-stop .sq { width: 9px; height: 9px; border-radius: 2px; background: currentColor; display: inline-block; }

/* transcribing bar */
.dictation__trans {
  position: absolute;
  left: 10px; right: 10px; bottom: 10px;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: var(--paper);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-pill);
  cursor: pointer;
}
.spinner {
  width: 16px; height: 16px;
  border: 2px solid rgba(193,123,93,0.3);
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  flex: 0 0 auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.trans-label { font-family: var(--ui); font-weight: 600; font-size: 0.9rem; color: var(--soft-brown); }
.trans-hint { margin-left: auto; font-family: var(--hand); font-size: 1.05rem; color: var(--terracotta); }

.soft-nudge {
  display: none;
  align-items: center; gap: 7px;
  font-family: var(--hand);
  font-size: 1.08rem;
  color: var(--terracotta-dark);
  margin-top: 2px;
}
.soft-nudge.show { display: flex; }
.soft-nudge svg { width: 15px; height: 15px; flex: 0 0 auto; }

/* ---------- Photo upload ---------- */
.photo-head { margin-bottom: 9px; }
.photo-head__t { font-family: var(--ui); font-weight: 600; font-size: 1rem; color: var(--deep-brown); line-height: 1.35; }
.photo-head__s { font-size: 0.88rem; color: var(--text-secondary); margin-top: 3px; line-height: 1.45; }

.photo {
  display: flex;
  align-items: center;
  gap: 11px;
  border: 1.5px dashed var(--line-strong);
  border-radius: 12px;
  background: var(--paper);
  padding: 13px 16px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
}
.photo:hover, .photo.is-drag { border-color: var(--terracotta); background: var(--warm-white); }
.photo__icon { flex: 0 0 auto; display: inline-flex; }
.photo__icon svg { width: 24px; height: 24px; color: var(--terracotta); opacity: .75; display: block; }
.photo__cta { font-family: var(--ui); font-weight: 600; font-size: 0.92rem; color: var(--deep-brown); }
.photo input[type=file] { display: none; }

.photo-filled { display: none; }
.photo-card[data-filled="true"] .photo { display: none; }
.photo-card[data-filled="true"] .photo-filled { display: block; }

.photo-preview {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  background: var(--warm-white);
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 12px;
}
.photo-thumb {
  position: relative;
  flex: 0 0 96px;
  width: 96px; height: 96px;
  border-radius: 9px;
  overflow: hidden;
  background: var(--paper-dark);
  border: 3px solid var(--warm-white);
  box-shadow: 0 5px 14px var(--shadow-warm);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.photo-thumb.placeholder::after {
  content: 'photo';
  position: absolute; inset: 0;
  display: grid; place-items: center;
  font-family: ui-monospace, monospace;
  font-size: 0.7rem; color: var(--soft-brown);
  background: repeating-linear-gradient(45deg, var(--paper-dark), var(--paper-dark) 7px, var(--paper) 7px, var(--paper) 14px);
}
.photo-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 9px; }
.photo-replace {
  align-self: flex-start;
  font-family: var(--ui); font-weight: 600; font-size: 0.78rem;
  color: var(--terracotta-dark);
  background: none; border: none; cursor: pointer;
  text-decoration: underline; padding: 0;
}
.photo-remove {
  position: absolute; top: 5px; right: 5px;
  width: 24px; height: 24px;
  border: none; border-radius: 50%;
  background: rgba(60,50,37,0.62);
  color: #fff; font-size: 14px; line-height: 1;
  cursor: pointer; backdrop-filter: blur(3px);
  display: grid; place-items: center;
}
.mini-label {
  font-family: var(--ui); font-weight: 600; font-size: 0.82rem;
  color: var(--deep-brown); margin-bottom: 4px; display: block;
}
.field--mini { padding: 9px 12px; font-size: 0.96rem; }

/* ---------- Consent ticks ---------- */
.consent-block {
  background: var(--warm-white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-card);
  padding: 8px 6px;
  margin-top: 4px;
}
.tick {
  display: flex;
  gap: 13px;
  align-items: flex-start;
  padding: 14px;
  cursor: pointer;
  border-radius: 12px;
  transition: background .15s;
}
.tick + .tick { border-top: 1px solid var(--line); }
.tick:hover { background: var(--paper); }
.tick__box {
  flex: 0 0 auto;
  width: 26px; height: 26px;
  border: 2px solid var(--line-strong);
  border-radius: 8px;
  background: var(--paper);
  display: grid; place-items: center;
  transition: background .15s, border-color .15s;
  margin-top: 1px;
}
.tick__box svg { width: 15px; height: 15px; color: var(--warm-white); opacity: 0; transform: scale(.6); transition: .15s; }
.tick[aria-checked="true"] .tick__box { background: var(--forest-green); border-color: var(--forest-green); }
.tick[aria-checked="true"] .tick__box svg { opacity: 1; transform: none; }
.tick__text { flex: 1; }
.tick__title { display: block; font-family: var(--ui); font-weight: 600; font-size: 0.96rem; color: var(--text-primary); line-height: 1.4; }
.tick__req, .tick__opt {
  display: inline-block; vertical-align: middle; margin-left: 8px;
  text-transform: uppercase; letter-spacing: 0.04em; font-size: 0.62rem; font-weight: 700;
  padding: 2px 8px; border-radius: var(--radius-pill); line-height: 1.5;
}
.tick__req { color: var(--terracotta-dark); background: rgba(193, 123, 93, 0.13); }
.tick__opt { color: var(--text-secondary); background: var(--paper-dark); }
.tick__sub { display: block; font-size: 0.86rem; color: var(--text-secondary); margin-top: 5px; line-height: 1.45; }
.consent-block.is-invalid { border-color: var(--invalid); }

/* ---------- Repeater (grandchildren) ---------- */
.repeater { display: flex; flex-direction: column; gap: 16px; }
.child-card {
  background: var(--warm-white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-card);
  padding: 18px;
  box-shadow: 0 6px 20px var(--shadow-warm);
  animation: sectionIn .35s ease;
}
.child-card__head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.child-card__name {
  font-family: var(--serif-display);
  font-size: 1.4rem; font-weight: 600; color: var(--deep-brown);
}
.child-card__num {
  display: inline-grid; place-items: center;
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--forest-green); color: var(--warm-white);
  font-family: var(--ui); font-weight: 700; font-size: 0.9rem;
  margin-right: 9px;
}
.child-card__rm {
  border: none; background: none; cursor: pointer;
  color: var(--text-secondary); font-family: var(--ui); font-weight: 600; font-size: 0.82rem;
  display: inline-flex; align-items: center; gap: 5px;
}
.child-card__rm:hover { color: var(--invalid); }
.child-body { display: flex; flex-direction: column; gap: 16px; }

/* XOR photo-or-describe switch */
.xor-tabs { display: flex; gap: 7px; background: var(--paper-dark); border-radius: var(--radius-field); padding: 5px; }
.xor-tabs .pill { font-size: 0.88rem; }
.xor-pane { display: none; }
.xor-pane.active { display: block; }

.add-child {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 13px 18px;
  border: 1.5px dashed var(--line-strong);
  border-radius: var(--radius-field);
  background: transparent;
  color: var(--terracotta-dark);
  font-family: var(--ui); font-weight: 600; font-size: 0.95rem;
  cursor: pointer;
  transition: background .2s, border-color .2s;
}
.add-child:hover { background: var(--warm-white); border-color: var(--terracotta); }
.add-child:disabled { opacity: .4; cursor: not-allowed; }

/* memory photo grid */
.memory-grid { display: flex; flex-direction: column; gap: 16px; }
.memory-card {
  background: var(--warm-white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px;
}
.memory-story { margin-top: 13px; }

/* group label / divider inside a section */
.group-head {
  margin-top: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--line);
}
.group-head__t {
  font-family: var(--serif-display);
  font-size: 1.45rem; font-weight: 600; color: var(--deep-brown);
}
.group-head__s { font-size: 0.92rem; color: var(--text-secondary); margin-top: 2px; }

/* conditional reveal */
.reveal { overflow: hidden; }
.reveal[hidden] { display: none; }

/* ---------- Bottom nav ---------- */
.botnav {
  position: sticky;
  bottom: 0;
  z-index: 50;
  background: linear-gradient(180deg, rgba(249,243,232,0), var(--paper) 34%);
  padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
}
.botnav__inner {
  max-width: var(--maxw);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 12px;
}
.btn {
  font-family: var(--ui);
  font-weight: 700;
  font-size: 1rem;
  border-radius: var(--radius-pill);
  cursor: pointer;
  border: none;
  transition: background .2s, transform .15s, box-shadow .2s, opacity .2s;
  display: inline-flex; align-items: center; justify-content: center; gap: 9px;
}
.btn--primary {
  background: var(--terracotta);
  color: var(--warm-white);
  padding: 15px 28px;
  box-shadow: 0 6px 18px rgba(193,123,93,0.35);
  flex: 1;
}
.btn--primary:hover { background: var(--terracotta-dark); transform: translateY(-2px); box-shadow: 0 10px 24px rgba(193,123,93,0.42); }
.btn--ghost {
  background: transparent;
  color: var(--deep-brown);
  border: 1.5px solid var(--line-strong);
  padding: 15px 22px;
}
.btn--ghost:hover { background: var(--warm-white); border-color: var(--soft-brown); }
.btn--green { background: var(--forest-green); color: var(--warm-white); padding: 15px 28px; flex: 1; box-shadow: 0 6px 18px rgba(91,124,101,0.32); }
.btn--green:hover { background: #4d6b56; box-shadow: 0 10px 24px rgba(91,124,101,0.4); }
.btn svg { width: 18px; height: 18px; }
.btn--ghost.hidden { visibility: hidden; }

/* ---------- Welcome screen extras ---------- */
.welcome-hero { text-align: center; padding: 14px 6px 4px; }
.welcome-hero__kicker {
  font-family: var(--hand);
  font-size: 1.5rem; color: var(--terracotta-dark);
}
.welcome-hero__title {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: clamp(2.3rem, 9vw, 3.4rem);
  line-height: 1.04;
  color: var(--deep-brown);
  margin: 4px 0 14px;
}
.welcome-hero__lead { max-width: 44ch; margin: 0 auto; color: var(--text-secondary); font-size: 1.08rem; }
.welcome-reassure {
  display: flex; flex-wrap: wrap; gap: 8px 10px; justify-content: center;
  margin: 22px auto 6px; max-width: 520px;
}
.reassure-chip {
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--warm-white);
  border: 1px solid var(--line);
  border-radius: var(--radius-pill);
  padding: 8px 14px;
  font-family: var(--ui); font-size: 0.82rem; font-weight: 500; color: var(--text-secondary);
}
.reassure-chip svg { width: 15px; height: 15px; color: var(--forest-green); }

/* resume banner */
.resume-banner {
  display: none;
  align-items: center; gap: 14px;
  max-width: var(--maxw);
  margin: 16px auto 0;
  padding: 14px 18px;
  background: rgba(91,124,101,0.10);
  border: 1px solid rgba(91,124,101,0.4);
  border-radius: 14px;
}
.resume-banner.show { display: flex; }
.resume-banner__ic { flex: 0 0 auto; width: 38px; height: 38px; border-radius: 50%; background: var(--forest-green); color: #fff; display: grid; place-items: center; }
.resume-banner__ic svg { width: 20px; height: 20px; }
.resume-banner__t { flex: 1; }
.resume-banner__t b { font-family: var(--serif-display); font-size: 1.18rem; color: var(--deep-brown); font-weight: 600; }
.resume-banner__t span { display: block; font-size: 0.9rem; color: var(--text-secondary); }
.resume-banner__x { border: none; background: none; cursor: pointer; color: var(--text-secondary); font-size: 1.3rem; padding: 4px; }

/* ---------- Review screen ---------- */
.review-progress {
  display: flex; align-items: center; gap: 12px;
  background: var(--warm-white);
  border: 1.5px solid var(--line);
  border-radius: var(--radius-card);
  padding: 16px 18px;
  margin-bottom: 8px;
}
.review-progress__ring { flex: 0 0 auto; }
.review-progress__t b { font-family: var(--serif-display); font-size: 1.3rem; color: var(--deep-brown); font-weight: 600; display: block; }
.review-progress__t span { font-size: 0.92rem; color: var(--text-secondary); }

.gaps {
  background: rgba(193,123,93,0.08);
  border: 1.5px solid rgba(193,123,93,0.4);
  border-radius: var(--radius-card);
  padding: 18px 20px;
}
.gaps__head { display: flex; align-items: center; gap: 10px; margin-bottom: 6px; }
.gaps__head svg { width: 20px; height: 20px; color: var(--terracotta-dark); flex: 0 0 auto; }
.gaps__head b { font-family: var(--serif-display); font-size: 1.35rem; color: var(--deep-brown); font-weight: 600; }
.gaps__sub { color: var(--text-secondary); font-size: 0.94rem; margin-bottom: 12px; }
.gaps__list { display: flex; flex-direction: column; gap: 8px; }
.gap-link {
  display: flex; align-items: center; gap: 10px;
  background: var(--warm-white);
  border: 1px solid var(--line);
  border-radius: 11px;
  padding: 11px 14px;
  cursor: pointer;
  font-family: var(--ui); font-weight: 600; font-size: 0.92rem; color: var(--deep-brown);
  text-align: left;
}
.gap-link:hover { border-color: var(--terracotta); }
.gap-link .sec { color: var(--text-secondary); font-weight: 500; font-size: 0.8rem; }
.gap-link .arr { margin-left: auto; color: var(--terracotta); }

.review-group { margin-top: 22px; }
.review-group__head {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 8px; border-bottom: 2px solid var(--line);
  margin-bottom: 4px;
}
.review-group__title { font-family: var(--serif-display); font-size: 1.55rem; font-weight: 600; color: var(--deep-brown); }
.review-edit {
  border: none; background: none; cursor: pointer;
  font-family: var(--ui); font-weight: 600; font-size: 0.82rem; color: var(--terracotta-dark);
  display: inline-flex; align-items: center; gap: 5px;
}
.review-edit:hover { text-decoration: underline; }
.review-row {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 8px 18px;
  padding: 11px 2px;
  border-bottom: 1px solid var(--line);
}
@media (max-width: 480px) { .review-row { grid-template-columns: 1fr; gap: 2px; } }
.review-row__k { font-family: var(--ui); font-weight: 600; font-size: 0.86rem; color: var(--text-secondary); }
.review-row__v { color: var(--text-primary); font-size: 1rem; }
.review-row__v.empty { color: var(--terracotta-dark); font-style: italic; opacity: .9; }
.review-row__v .thumb-sm { width: 46px; height: 46px; border-radius: 7px; object-fit: cover; border: 2px solid var(--warm-white); box-shadow: 0 3px 8px var(--shadow-warm); vertical-align: middle; }

/* ---------- Modals / popups ---------- */
.overlay {
  position: fixed; inset: 0;
  background: rgba(60,50,37,0.5);
  backdrop-filter: blur(3px);
  z-index: 200;
  display: none;
  align-items: center; justify-content: center;
  padding: 22px;
}
.overlay.show { display: flex; animation: fade .25s ease; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.modal {
  background: var(--warm-white);
  border-radius: 20px;
  max-width: 440px; width: 100%;
  padding: 34px 30px 28px;
  box-shadow: 0 30px 70px rgba(60,50,37,0.4);
  text-align: center;
  animation: pop .3s cubic-bezier(.2,.8,.3,1.1);
  position: relative;
  max-height: 90vh; overflow-y: auto;
}
@keyframes pop { from { opacity: 0; transform: translateY(14px) scale(.97); } to { opacity: 1; transform: none; } }
.modal__crest {
  width: 60px; height: 60px; margin: 0 auto 16px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: linear-gradient(135deg, rgba(193,123,93,0.18), rgba(193,123,93,0.08));
  color: var(--terracotta-dark);
}
.modal__crest.green { background: linear-gradient(135deg, rgba(91,124,101,0.2), rgba(91,124,101,0.08)); color: var(--forest-green); }
.modal__crest svg { width: 30px; height: 30px; }
.modal__title { font-family: var(--serif-display); font-size: 1.85rem; font-weight: 600; color: var(--deep-brown); line-height: 1.12; }
.modal__body { color: var(--text-secondary); font-size: 1.02rem; margin: 12px 0 6px; line-height: 1.55; }
.modal__note {
  font-family: var(--hand); font-size: 1.18rem; color: var(--terracotta-dark);
  margin: 8px auto 0; max-width: 36ch;
}
.modal__actions { display: flex; flex-direction: column; gap: 10px; margin-top: 22px; }
.modal .btn--primary, .modal .btn--green { flex: none; width: 100%; }
.modal .btn--ghost { width: 100%; }

/* coachmark / tooltip */
.coach {
  position: fixed;
  z-index: 220;
  max-width: 290px;
  background: var(--deep-brown);
  color: var(--paper);
  border-radius: 16px;
  padding: 16px 18px;
  box-shadow: 0 18px 40px rgba(60,50,37,0.45);
  display: none;
  animation: pop .3s ease;
}
.coach.show { display: block; }
.coach__t { font-family: var(--hand); font-size: 1.45rem; color: #fff; line-height: 1.15; }
.coach__b { font-size: 0.92rem; opacity: 0.9; margin-top: 5px; line-height: 1.45; font-family: var(--ui); }
.coach__btn {
  margin-top: 12px;
  background: var(--terracotta);
  color: #fff; border: none; cursor: pointer;
  font-family: var(--ui); font-weight: 700; font-size: 0.85rem;
  padding: 9px 16px; border-radius: var(--radius-pill);
}
.coach__arrow {
  position: absolute;
  width: 16px; height: 16px;
  background: var(--deep-brown);
  transform: rotate(45deg);
}

/* small inline error (failed upload / mic denied) */
.inline-alert {
  display: flex; gap: 11px; align-items: flex-start;
  background: rgba(193,83,83,0.09);
  border: 1px solid rgba(193,83,83,0.35);
  border-left: 3px solid var(--invalid);
  border-radius: 10px;
  padding: 12px 14px;
  margin-top: 10px;
  font-size: 0.92rem;
  color: #7C3030;
  line-height: 1.45;
}
.inline-alert svg { width: 18px; height: 18px; flex: 0 0 auto; color: var(--invalid); margin-top: 1px; }
.inline-alert b { font-family: var(--ui); display: block; color: #6a2626; }
.inline-alert a { color: var(--terracotta-dark); }
.inline-alert .retry { background: none; border: none; color: var(--terracotta-dark); font-family: var(--ui); font-weight: 700; cursor: pointer; text-decoration: underline; padding: 0; font-size: .92rem; }

/* ---------- Success screen ---------- */
.success {
  display: none;
  position: fixed; inset: 0; z-index: 300;
  background: var(--paper);
  flex-direction: column; align-items: center; justify-content: center;
  text-align: center; padding: 30px;
  overflow-y: auto;
}
.success.show { display: flex; }
.success__art {
  width: min(340px, 80vw);
  border-radius: 12px;
  box-shadow: 0 20px 50px var(--shadow-warm-strong);
  border: 5px solid var(--warm-white);
  margin-bottom: 26px;
}
.success__title { font-family: var(--serif-display); font-size: clamp(2.2rem,8vw,3rem); font-weight: 600; color: var(--deep-brown); line-height: 1.08; }
.success__body { color: var(--text-secondary); font-size: 1.1rem; max-width: 40ch; margin: 14px auto 0; }
.success__note { font-family: var(--hand); font-size: 1.4rem; color: var(--terracotta-dark); margin-top: 18px; }

/* submitting state */
.submitting {
  display: none;
  position: fixed; inset: 0; z-index: 290;
  background: rgba(249,243,232,0.96);
  flex-direction: column; align-items: center; justify-content: center; gap: 22px;
  text-align: center; padding: 30px;
}
.submitting.show { display: flex; }
.submitting .big-spin {
  width: 54px; height: 54px;
  border: 4px solid rgba(193,123,93,0.25);
  border-top-color: var(--terracotta);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}
.submitting__t { font-family: var(--serif-display); font-size: 1.9rem; color: var(--deep-brown); font-weight: 600; }
.submitting__s { color: var(--text-secondary); font-family: var(--ui); }

/* ---------- Demo panel (prototype-only affordance) ---------- */
.demo {
  position: fixed;
  right: 14px; bottom: 14px;
  z-index: 400;
  font-family: var(--ui);
}
.demo__toggle {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--deep-brown); color: var(--paper);
  border: none; cursor: pointer;
  padding: 10px 15px; border-radius: var(--radius-pill);
  font-weight: 600; font-size: 0.82rem;
  box-shadow: 0 8px 22px rgba(60,50,37,0.4);
}
.demo__toggle svg { width: 15px; height: 15px; }
.demo__menu {
  display: none;
  position: absolute;
  right: 0; bottom: 52px;
  width: 252px;
  background: var(--warm-white);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: 0 18px 44px rgba(60,50,37,0.3);
  padding: 8px;
}
.demo.open .demo__menu { display: block; }
.demo__label { font-size: 0.68rem; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--soft-brown); padding: 9px 10px 4px; }
.demo__item {
  display: flex; width: 100%; align-items: center; gap: 9px;
  background: none; border: none; cursor: pointer;
  padding: 9px 10px; border-radius: 9px;
  font-family: var(--ui); font-weight: 600; font-size: 0.86rem; color: var(--text-primary);
  text-align: left;
}
.demo__item:hover { background: var(--paper); }
.demo__item svg { width: 15px; height: 15px; color: var(--terracotta); flex: 0 0 auto; }

/* prototype watermark note in showcase only — none here */

/* ---------- Desktop enhancements ---------- */
@media (min-width: 720px) {
  :root { --maxw: 720px; }
  .brandbar { padding: 18px 28px 12px; }
  .brandbar__logo { height: 30px; }
  .chips { padding: 4px 28px 16px; }
  .section { padding: 14px 28px 48px; }
  .section__head { padding: 40px 6px 26px; }
  .botnav__inner { gap: 16px; }
  .btn--primary { flex: 0 1 auto; min-width: 200px; margin-left: auto; }
  .botnav__inner.single .btn--primary { margin-left: auto; }
  .welcome-reassure { margin-top: 28px; }
}
@media (min-width: 720px) {
  /* keep back on the left, next on the right */
  .botnav__inner { justify-content: space-between; }
}

/* ============================================================
   Production additions (not in the prototype)
   ============================================================ */

/* Upload-in-progress spinner on a photo drop zone */
.photo__spin { display: none; }
.photo-card[data-uploading="true"] .photo { position: relative; }
.photo-card[data-uploading="true"] .photo__icon,
.photo-card[data-uploading="true"] .photo__cta { opacity: .35; }
.photo-card[data-uploading="true"] .photo__spin {
  display: inline-flex; position: absolute; inset: 0; align-items: center; justify-content: center;
}
.photo-card[data-uploading="true"] .photo__spin .spinner {
  width: 26px; height: 26px; border: 3px solid var(--line-strong);
  border-top-color: var(--terracotta); border-radius: 50%; animation: spin .8s linear infinite;
}
/* While uploading, keep the drop zone visible (don't flip to filled view yet) */
.photo-card[data-uploading="true"][data-filled="true"] .photo { display: flex; }
.photo-card[data-uploading="true"][data-filled="true"] .photo-filled { display: none; }
@keyframes spin { to { transform: rotate(360deg); } }

/* Gate screen (invalid / locked / no-link) */
.gate {
  max-width: 460px; margin: 8vh auto 0; padding: 0 22px; text-align: center;
}
.gate__crest {
  width: 64px; height: 64px; margin: 0 auto 20px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--paper-dark); color: var(--soft-brown);
}
.gate__crest svg { width: 28px; height: 28px; }
.gate__title { font-family: var(--serif-display); font-weight: 600; font-size: 1.9rem; color: var(--deep-brown); margin-bottom: 12px; }
.gate__body { color: var(--text-secondary); margin-bottom: 24px; }
.gate .btn { display: inline-flex; text-decoration: none; }

/* Submit-error overlay (reuses .overlay/.modal look) */
#submiterror .modal__crest { color: var(--invalid); }

/* ============================================================
   New Baby additions — only what the custom pieces strictly need.
   Everything else reuses the live intake design system above.
   ============================================================ */

/* loved-ones cast cap + gentle inline notes (world menu reuses this) */
.cap-note {
  display: flex; gap: 10px; align-items: flex-start;
  margin-top: 14px; padding: 12px 14px;
  background: var(--warm-white);
  border: 1px dashed var(--line-strong); border-radius: 12px;
  font-family: var(--ui); font-size: .92rem; color: var(--text-secondary);
}
.cap-note svg { width: 16px; height: 16px; flex: 0 0 auto; color: var(--soft-brown); margin-top: 2px; }

/* narrator radio rows — tick rows with a round box */
.tick--radio .tick__box { border-radius: 50%; }

/* world menu — loading row + category tag on each candidate */
.world-loading {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 4px; font-family: var(--ui); font-size: .95rem;
  color: var(--text-secondary);
}
.world-cat {
  display: inline-block; margin-left: 8px; padding: 1px 8px;
  background: var(--paper-dark); border-radius: 99px;
  font-family: var(--ui); font-size: .72rem; font-weight: 700;
  letter-spacing: .04em; text-transform: uppercase;
  color: var(--soft-brown); vertical-align: middle;
}
