:root {
  --wine-950: #24101d;
  --wine-900: #331526;
  --wine-800: #4a1832;
  --wine-700: #6d2850;
  --gold: #dcae3c;
  --gold-soft: #f5dda0;
  --olive: #4f643d;
  --olive-soft: #edf1e8;
  --blue: #294c5a;
  --paper: #f6f2eb;
  --cloud: #fffcf8;
  --white: #ffffff;
  --ink: #241d21;
  --muted: #6f6269;
  --line: #ded5cf;
  --danger: #9f2f45;
  --display: "Newsreader", Georgia, serif;
  --body: "Manrope", Arial, sans-serif;
  --shadow: 0 18px 56px rgba(51, 21, 38, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: clip;
}

body {
  min-height: 100vh;
  margin: 0;
  overflow-x: clip;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--body);
  font-size: 16px;
  line-height: 1.55;
}

body,
button,
input,
select,
textarea {
  letter-spacing: 0;
}

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

button,
a,
input,
select,
textarea {
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: -80px;
  left: 16px;
  padding: 10px 14px;
  background: var(--white);
  color: var(--wine-900);
  font-weight: 700;
}

.skip-link:focus {
  top: 12px;
}

.quiz-header {
  min-height: 76px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  padding: 12px max(22px, calc((100vw - 1320px) / 2));
  border-bottom: 1px solid rgba(51, 21, 38, 0.12);
  background: rgba(255, 252, 248, 0.95);
}

.quiz-brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--wine-900);
  font-weight: 700;
  text-decoration: none;
}

.quiz-brand img {
  width: 44px;
  height: 44px;
  object-fit: contain;
}

.quiz-header-step {
  display: flex;
  align-items: baseline;
  gap: 10px;
  color: var(--muted);
  font-size: 12px;
}

.quiz-header-step strong {
  color: var(--wine-800);
  font-size: 13px;
}

.quiz-shell {
  width: min(100% - 40px, 1320px);
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
  gap: 0;
  margin: 28px auto 126px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.quiz-context {
  min-width: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  background: var(--wine-900);
  color: var(--white);
}

.quiz-context-media {
  position: relative;
  min-height: 510px;
  overflow: hidden;
}

.quiz-context-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.quiz-context-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(25, 11, 20, 0.08) 12%, rgba(36, 16, 29, 0.88) 100%);
}

.quiz-context-copy {
  position: absolute;
  z-index: 1;
  right: 28px;
  bottom: 30px;
  left: 28px;
}

.quiz-context-copy > p,
.living-score-label {
  margin: 0;
  color: var(--gold-soft);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.quiz-context-copy h1 {
  margin: 10px 0 16px;
  font-family: var(--display);
  font-size: 38px;
  font-weight: 600;
  line-height: 1.02;
}

.quiz-context-copy blockquote {
  margin: 0;
  color: rgba(255, 255, 255, 0.78);
  font-family: var(--display);
  font-size: 19px;
  line-height: 1.38;
}

.living-score {
  padding: 26px 28px 30px;
}

.living-score-items {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.living-score-items span {
  max-width: 100%;
  padding: 7px 9px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 5px;
  color: rgba(255, 255, 255, 0.78);
  font-size: 11px;
  overflow-wrap: anywhere;
}

.quiz-workspace {
  position: relative;
  min-width: 0;
  min-height: 720px;
  padding: 62px 72px 70px;
  background: var(--cloud);
}

.quiz-progress {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 5px;
  overflow: hidden;
  background: #eee6df;
}

.quiz-progress div {
  width: 14.2857%;
  height: 100%;
  background: linear-gradient(90deg, var(--wine-700), var(--gold));
  transition: width 350ms ease;
}

.quiz-step {
  max-width: 760px;
  margin: 0 auto;
  animation: step-enter 300ms ease both;
}

.quiz-step[hidden] {
  display: none;
}

@keyframes step-enter {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

.step-heading {
  margin-bottom: 34px;
}

.step-kicker {
  margin: 0 0 8px;
  color: var(--wine-700);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.step-heading h2 {
  max-width: 700px;
  margin: 0;
  color: var(--wine-900);
  font-family: var(--display);
  font-size: 45px;
  font-weight: 600;
  line-height: 1.04;
  text-wrap: balance;
}

.step-heading > p:last-child {
  max-width: 650px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 16px;
}

.field-grid,
.sound-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

.field {
  display: grid;
  gap: 7px;
  color: var(--wine-900);
  font-size: 13px;
  font-weight: 700;
}

.field--wide {
  grid-column: 1 / -1;
}

.phone-input {
  display: grid;
  grid-template-columns: minmax(150px, 0.42fr) minmax(0, 1fr);
  gap: 10px;
}

.field small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.field em {
  color: var(--muted);
  font-size: 11px;
  font-style: normal;
  font-weight: 500;
}

.field input,
.field select,
.field textarea {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font-size: 15px;
  font-weight: 500;
  outline: 0;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

.field input,
.field select {
  min-height: 52px;
  padding: 0 15px;
}

.field textarea {
  min-height: 106px;
  padding: 13px 15px;
  line-height: 1.55;
  resize: vertical;
}

.field input:focus,
.field select:focus,
.field textarea:focus {
  border-color: var(--wine-700);
  box-shadow: 0 0 0 3px rgba(109, 40, 80, 0.1);
}

.field [aria-invalid="true"] {
  border-color: var(--danger);
}

.trust-note {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  margin-top: 22px;
  padding: 16px 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.trust-note::before {
  content: "✓";
  width: 24px;
  height: 24px;
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 50%;
  background: var(--olive-soft);
  color: var(--olive);
  font-size: 13px;
  font-weight: 700;
}

.trust-note strong,
.trust-note span {
  display: block;
}

.trust-note strong {
  color: var(--wine-900);
  font-size: 13px;
}

.trust-note span {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
}

.choice-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 9px;
}

.choice-grid button,
.emotion-grid button {
  min-height: 50px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--white);
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 160ms ease, background-color 160ms ease, color 160ms ease;
}

.choice-grid button:hover,
.emotion-grid button:hover,
.choice-grid button.is-selected,
.emotion-grid button.is-selected {
  border-color: var(--wine-700);
  background: #f9eef5;
  color: var(--wine-800);
}

.choice-grid button.is-selected,
.emotion-grid button.is-selected {
  box-shadow: inset 3px 0 0 var(--wine-700);
}

.emotion-fieldset,
.voice-fieldset {
  margin: 28px 0 0;
  padding: 0;
  border: 0;
}

.emotion-fieldset legend,
.voice-fieldset legend {
  margin-bottom: 10px;
  color: var(--wine-900);
  font-size: 13px;
  font-weight: 700;
}

.emotion-fieldset legend span {
  margin-left: 6px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.emotion-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.emotion-grid button {
  min-height: 42px;
  padding: 8px;
  font-size: 12px;
}

#emotion-count {
  margin: 9px 0 0;
  color: var(--muted);
  font-size: 11px;
}

.story-prompts {
  display: grid;
  gap: 18px;
}

.story-quality {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 12px;
  align-items: center;
  margin-top: 20px;
}

.story-quality > div {
  height: 6px;
  overflow: hidden;
  border-radius: 3px;
  background: #e8e0da;
}

.story-quality > div span {
  width: 0;
  height: 100%;
  display: block;
  background: var(--olive);
  transition: width 220ms ease;
}

.story-quality p {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.story-names {
  margin-top: 28px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.optional-names-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.faith-options {
  display: grid;
  border-top: 1px solid var(--line);
}

.faith-options button {
  width: 100%;
  min-height: 84px;
  display: grid;
  gap: 4px;
  padding: 18px 42px 18px 0;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
  position: relative;
}

.faith-options button::after {
  content: "";
  position: absolute;
  top: 50%;
  right: 4px;
  width: 16px;
  height: 16px;
  transform: translateY(-50%);
  border: 2px solid #b9acb2;
  border-radius: 50%;
}

.faith-options button.is-selected::after {
  border: 5px solid var(--wine-700);
}

.faith-options strong {
  color: var(--wine-900);
  font-size: 15px;
}

.faith-options span {
  color: var(--muted);
  font-size: 12px;
}

.recommended-verse,
.sound-recommendation {
  margin-top: 22px;
  padding: 20px;
  border-left: 4px solid var(--gold);
  border-radius: 0 6px 6px 0;
  background: #fff7e6;
}

.bible-result-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

.bible-result-heading > div {
  min-width: 0;
}

.bible-provider-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
}

.bible-provider-status::before {
  width: 7px;
  height: 7px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--gold);
  content: "";
}

.bible-provider-status.is-validated::before {
  background: var(--olive);
}

.bible-match-explanation {
  max-width: 560px;
  display: block;
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.bible-refresh {
  flex: 0 0 auto;
  padding: 6px 0;
  border: 0;
  background: transparent;
  color: var(--wine-700);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.bible-suggestions {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.bible-suggestion {
  width: 100%;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr);
  gap: 2px 12px;
  padding: 14px;
  border: 1px solid #e5d4ab;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}

.bible-suggestion:hover {
  border-color: var(--gold);
}

.bible-suggestion.is-selected {
  border-color: var(--wine-700);
  box-shadow: inset 0 0 0 1px var(--wine-700);
}

.bible-suggestion-marker {
  width: 18px;
  height: 18px;
  margin-top: 2px;
  border: 2px solid #b9acb2;
  border-radius: 50%;
}

.bible-suggestion.is-selected .bible-suggestion-marker {
  border: 5px solid var(--wine-700);
}

.bible-suggestion-copy {
  min-width: 0;
}

.bible-suggestion strong {
  display: block;
  color: var(--wine-900);
  font-size: 14px;
}

.bible-suggestion blockquote {
  margin: 6px 0;
  color: var(--wine-900);
  font-family: var(--display);
  font-size: 18px;
  line-height: 1.34;
}

.bible-suggestion small {
  display: block;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.45;
}

.bible-history-signal {
  width: fit-content;
  display: inline-flex;
  margin-top: 7px;
  padding: 3px 7px;
  border-radius: 3px;
  background: #edf2e7;
  color: #42533a;
  font-size: 9px;
  font-weight: 700;
  text-transform: uppercase;
}

.bible-suggestion-skeleton {
  height: 84px;
  border: 1px solid #eadfc6;
  border-radius: 6px;
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.45), rgba(245, 221, 160, 0.42), rgba(255, 255, 255, 0.45));
  background-size: 200% 100%;
  animation: bible-loading 1.2s linear infinite;
}

@keyframes bible-loading {
  to { background-position: -200% 0; }
}

.recommended-verse[hidden],
.own-verse[hidden] {
  display: none;
}

.recommended-verse > p,
.sound-recommendation > p {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.recommended-verse strong,
.sound-recommendation strong {
  color: var(--wine-900);
}

.recommended-verse blockquote {
  margin: 10px 0;
  color: var(--wine-900);
  font-family: var(--display);
  font-size: 20px;
  line-height: 1.35;
}

.recommended-verse > span {
  color: var(--muted);
  font-size: 11px;
}

.own-verse {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-top: 22px;
}

.manual-verse-preview {
  grid-column: 1 / -1;
  min-height: 112px;
  padding: 18px;
  border-left: 4px solid var(--gold);
  border-radius: 0 6px 6px 0;
  background: #fff7e6;
}

.manual-verse-preview p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
}

.manual-verse-preview strong {
  color: var(--wine-900);
}

.manual-verse-preview blockquote {
  margin: 8px 0 0;
  color: var(--wine-900);
  font-family: var(--display);
  font-size: 19px;
  line-height: 1.38;
}

.sound-recommendation {
  margin-top: 0;
  margin-bottom: 24px;
}

.segmented-control {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}

.segmented-control button {
  min-height: 48px;
  padding: 8px 10px;
  border: 0;
  border-right: 1px solid var(--line);
  background: var(--white);
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.segmented-control button:last-child {
  border-right: 0;
}

.segmented-control button.is-selected {
  background: var(--wine-800);
  color: var(--white);
}

.review-sections {
  border-top: 1px solid var(--line);
}

.review-row {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr) auto;
  gap: 18px;
  align-items: start;
  padding: 17px 0;
  border-bottom: 1px solid var(--line);
}

.review-row dt {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
}

.review-row dd {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  font-size: 13px;
  overflow-wrap: anywhere;
}

.review-row button {
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  background: transparent;
  color: var(--wine-700);
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
}

.terms-check {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
  align-items: start;
  margin-top: 24px;
  color: var(--muted);
  font-size: 12px;
}

.terms-check input {
  width: 18px;
  height: 18px;
  margin: 0;
  accent-color: var(--wine-700);
}

.terms-check a {
  color: var(--wine-700);
  font-weight: 700;
}

.quiz-status {
  min-height: 22px;
  max-width: 760px;
  margin: 18px auto 0;
  color: var(--danger);
  font-size: 12px;
}

.quiz-status.is-success {
  color: var(--olive);
}

.quiz-actions {
  position: fixed;
  z-index: 100;
  right: 0;
  bottom: 0;
  left: 0;
  padding: 13px 20px calc(13px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: rgba(255, 252, 248, 0.96);
  backdrop-filter: blur(14px);
}

.quiz-actions > div {
  width: min(100%, 760px);
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin: 0 auto;
}

.quiz-actions button {
  min-height: 50px;
  padding: 0 24px;
  border-radius: 6px;
  font-weight: 700;
  cursor: pointer;
}

.action-back {
  border: 1px solid var(--line);
  background: transparent;
  color: var(--wine-800);
}

.action-next {
  min-width: 210px;
  border: 1px solid var(--gold);
  background: var(--gold);
  color: var(--wine-950);
  box-shadow: 0 10px 24px rgba(220, 174, 60, 0.24);
}

.quiz-actions button:disabled {
  cursor: not-allowed;
  opacity: 0.44;
}

.action-next.is-loading::before {
  content: "";
  width: 14px;
  height: 14px;
  display: inline-block;
  margin-right: 8px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (max-width: 1040px) {
  .quiz-shell {
    grid-template-columns: 300px minmax(0, 1fr);
  }

  .quiz-context-copy h1 {
    font-size: 32px;
  }

  .quiz-workspace {
    padding-right: 42px;
    padding-left: 42px;
  }

  .choice-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  body {
    padding-bottom: 82px;
    background: var(--cloud);
  }

  .quiz-header {
    min-height: 66px;
    padding: 8px 16px;
    position: sticky;
    z-index: 80;
    top: 0;
  }

  .quiz-brand span {
    display: none;
  }

  .quiz-brand img {
    width: 40px;
    height: 40px;
  }

  .quiz-header-step span {
    display: none;
  }

  .quiz-shell {
    width: 100%;
    display: block;
    margin: 0;
    overflow: visible;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .quiz-context {
    display: none;
  }

  .quiz-workspace {
    min-height: calc(100vh - 66px);
    padding: 42px 18px 54px;
  }

  .quiz-progress {
    height: 4px;
  }

  .quiz-step {
    max-width: 560px;
  }

  .step-heading {
    margin-bottom: 26px;
  }

  .step-heading h2 {
    font-size: 34px;
    line-height: 1.04;
  }

  .step-heading > p:last-child {
    font-size: 14px;
  }

  .field-grid,
  .sound-grid,
  .own-verse {
    grid-template-columns: 1fr;
  }

  .phone-input {
    grid-template-columns: minmax(128px, 0.44fr) minmax(0, 1fr);
  }

  .bible-result-heading {
    display: grid;
  }

  .bible-refresh {
    justify-self: start;
  }

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

  .choice-grid button {
    min-height: 52px;
    padding: 8px;
    font-size: 12px;
  }

  .emotion-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .emotion-grid button {
    min-height: 42px;
    font-size: 11px;
  }

  .story-quality {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .story-quality > div {
    width: 100%;
  }

  .segmented-control {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .segmented-control button:nth-child(2) {
    border-right: 0;
  }

  .segmented-control button:nth-child(-n + 2) {
    border-bottom: 1px solid var(--line);
  }

  .review-row {
    grid-template-columns: 1fr auto;
    gap: 6px 12px;
  }

  .review-row dt {
    grid-column: 1;
  }

  .review-row dd {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .review-row button {
    grid-column: 2;
    grid-row: 1;
  }

  .quiz-actions {
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }

  .quiz-actions > div {
    gap: 8px;
  }

  .quiz-actions button {
    min-width: 0;
    flex: 1;
    padding: 0 12px;
    font-size: 13px;
  }

  .action-next {
    flex: 1.35;
  }
}

@media (max-width: 390px) {
  .choice-grid,
  .emotion-grid {
    grid-template-columns: 1fr 1fr;
  }

  .step-heading h2 {
    font-size: 31px;
  }
}

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