:root {
  color-scheme: light;
  --paper: #f2ece1;
  --surface: #fffaf2;
  --surface-strong: #ffffff;
  --ink: #28261f;
  --muted: #706b60;
  --line: #d8cdbb;
  --line-strong: #bfae96;
  --accent: #984d35;
  --accent-deep: #743725;
  --accent-soft: #f2ddd2;
  --moss: #45695b;
  --moss-soft: #dbe8e1;
  --danger: #8d2f2f;
  --danger-soft: #f7dfdc;
  --shadow: 0 22px 70px rgba(64, 50, 32, 0.1);
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --sans: "Avenir Next", Avenir, "Helvetica Neue", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  background: var(--paper);
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(152, 77, 53, 0.025) 1px, transparent 1px),
    var(--paper);
  background-size: 100% 48px;
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.55;
}

button,
textarea,
input {
  font: inherit;
}

button,
a,
textarea,
input {
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

button:focus-visible,
a:focus-visible,
textarea:focus-visible,
input:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(152, 77, 53, 0.35);
  outline-offset: 3px;
}

[hidden] {
  display: none !important;
}

.app-shell {
  width: min(100%, 780px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) clamp(18px, 5vw, 44px)
    max(28px, env(safe-area-inset-bottom));
}

.topbar,
.quest-toolbar,
footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar {
  min-height: 64px;
  margin-bottom: clamp(42px, 8vw, 76px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-family: var(--serif);
  font-size: 18px;
  letter-spacing: 0.01em;
}

.brand small {
  margin-top: -2px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.brand-mark i {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--accent);
}

.brand-mark i:first-child {
  transform: translateX(-8px);
}

.brand-mark i:last-child {
  transform: translateX(8px);
}

.quiet-button,
.back-button,
.text-button,
.secondary-button,
.primary-button,
.dialog-close {
  min-height: 44px;
  border: 0;
  cursor: pointer;
}

.quiet-button,
.back-button,
.text-button {
  padding: 8px 2px;
  background: transparent;
  color: var(--muted);
  font-weight: 650;
}

.quiet-button:hover,
.back-button:hover,
.text-button:hover {
  color: var(--accent-deep);
}

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

h1,
h2 {
  font-family: var(--serif);
  font-weight: 500;
  line-height: 1.06;
  text-wrap: balance;
}

h1 {
  max-width: 620px;
  margin-bottom: 18px;
  font-size: clamp(42px, 10vw, 72px);
  letter-spacing: -0.045em;
}

h2 {
  margin-bottom: 16px;
  font-size: clamp(32px, 6vw, 48px);
  letter-spacing: -0.035em;
}

.eyebrow {
  margin-bottom: 11px;
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.lede,
.step-intro {
  max-width: 610px;
  color: var(--muted);
  font-size: clamp(17px, 3vw, 20px);
  text-wrap: pretty;
}

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

.day-progress {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 24px;
  padding: 18px 0;
  border-block: 1px solid var(--line);
}

.progress-count,
.progress-label {
  display: block;
}

.progress-count {
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1;
}

.progress-label {
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.progress-track {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #ded4c4;
}

.progress-track span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--moss);
  transition: width 300ms ease;
}

.gate-trail {
  position: relative;
  margin: 30px 0 34px;
}

.gate-trail::before {
  position: absolute;
  inset: 34px auto 34px 21px;
  width: 1px;
  background: var(--line);
  content: "";
}

.gate-row {
  position: relative;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 15px;
  width: 100%;
  min-height: 88px;
  padding: 8px 4px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}

.gate-row:hover .gate-name,
.gate-row.current .gate-name {
  color: var(--accent-deep);
}

.gate-node {
  z-index: 1;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  background: var(--paper);
  color: var(--muted);
  font-family: var(--serif);
}

.gate-row.current .gate-node {
  border-color: var(--accent);
  box-shadow: 0 0 0 5px var(--accent-soft);
  color: var(--accent-deep);
}

.gate-row.complete .gate-node {
  border-color: var(--moss);
  background: var(--moss);
  color: white;
}

.gate-copy span {
  display: block;
}

.gate-name {
  font-family: var(--serif);
  font-size: 22px;
  transition: color 150ms ease;
}

.gate-meta,
.gate-status {
  color: var(--muted);
  font-size: 13px;
}

.gate-status {
  font-weight: 700;
  text-align: right;
}

.primary-button,
.secondary-button {
  border-radius: 12px;
  font-weight: 750;
  transition: transform 150ms ease, background 150ms ease, border-color 150ms ease;
}

.primary-button {
  padding: 14px 22px;
  background: var(--ink);
  color: white;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-deep);
  transform: translateY(-1px);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.4;
}

.secondary-button {
  padding: 11px 15px;
  border: 1px solid var(--line-strong);
  background: transparent;
}

.secondary-button:hover {
  border-color: var(--accent);
  color: var(--accent-deep);
}

.wide {
  width: 100%;
  min-height: 54px;
}

.principle-note {
  margin-top: 22px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 14px;
}

.principle-note strong {
  color: var(--ink);
}

.quest-toolbar {
  margin-bottom: 24px;
}

.quest-toolbar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.stepper {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 0 0 22px;
  padding: 0;
  list-style: none;
}

.stepper li {
  min-width: 0;
  padding-top: 9px;
  border-top: 2px solid var(--line);
  color: var(--muted);
  font-size: 11px;
  font-weight: 750;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.stepper li span {
  display: none;
}

.stepper li.active,
.stepper li.done {
  border-color: var(--accent);
  color: var(--accent-deep);
}

.stepper li.done {
  border-color: var(--moss);
  color: var(--moss);
}

.quest-card {
  padding: clamp(24px, 6vw, 52px);
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.realm-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  margin: 24px 0 30px;
}

.realm-button {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
}

.realm-button:hover,
.realm-button.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-deep);
}

.source-transmission {
  margin: 28px 0;
  padding: 24px 0;
  border-block: 1px solid var(--line-strong);
}

.source-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 16px;
}

.source-heading .eyebrow {
  margin: 0;
}

.source-heading h3 {
  max-width: 32rem;
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(19px, 4vw, 24px);
  font-weight: 500;
  line-height: 1.2;
  text-align: right;
}

.source-transmission blockquote {
  margin: 0 0 16px;
  padding: 0;
  border: 0;
  color: var(--ink);
  font-family: var(--serif);
  font-size: clamp(20px, 4.5vw, 29px);
  line-height: 1.35;
}

.source-transmission a {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  color: var(--accent-deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-underline-offset: 3px;
}

.source-context {
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.45;
  margin: -0.25rem 0 1.1rem;
}

.source-context a {
  color: var(--accent-deep);
  font-weight: 750;
  text-underline-offset: 3px;
}

@media (max-width: 580px) {
  .source-heading {
    display: block;
  }

  .source-heading h3 {
    margin-top: 8px;
    text-align: left;
  }
}

.prompt-block {
  display: grid;
  grid-template-columns: 35px 1fr;
  gap: 13px;
  margin: 0 0 28px;
  padding: 20px 0;
  border-block: 1px solid var(--line);
}

.prompt-block p {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(20px, 4vw, 27px);
  line-height: 1.25;
}

.prompt-number {
  color: var(--accent);
  font-family: var(--serif);
  font-size: 20px;
}

.field-label {
  display: block;
  margin: 24px 0 9px;
  font-size: 14px;
  font-weight: 750;
}

.field-label output {
  float: right;
  color: var(--accent-deep);
}

textarea {
  display: block;
  width: 100%;
  min-height: 116px;
  resize: vertical;
  padding: 15px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface-strong);
  color: var(--ink);
  line-height: 1.5;
}

textarea::placeholder {
  color: #9a9387;
}

.field-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 10px 0 24px;
}

.field-hint,
.privacy-note {
  color: var(--muted);
  font-size: 12px;
}

.safety-panel {
  margin: 18px 0;
  padding: 18px;
  border: 1px solid #d6a9a3;
  border-radius: 12px;
  background: var(--danger-soft);
  color: #5c2828;
}

.safety-panel p {
  margin: 7px 0 0;
}

.safety-panel a {
  color: inherit;
  font-weight: 750;
}

.old-pattern {
  margin: 22px 0;
  color: var(--muted);
}

.old-pattern summary {
  min-height: 44px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 750;
  line-height: 44px;
}

.old-pattern p {
  padding: 12px 15px;
  border-left: 2px solid var(--line-strong);
}

.belief-list {
  display: grid;
  gap: 11px;
  margin: 24px 0;
}

.belief-option {
  display: grid;
  grid-template-columns: 20px 1fr;
  gap: 12px;
  width: 100%;
  min-height: 72px;
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-strong);
  text-align: left;
  cursor: pointer;
}

.belief-option:hover,
.belief-option.selected {
  border-color: var(--accent);
}

.belief-option.selected {
  box-shadow: inset 0 0 0 1px var(--accent);
}

.belief-radio {
  width: 17px;
  height: 17px;
  margin-top: 3px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
}

.belief-option.selected .belief-radio {
  border: 5px solid var(--accent);
}

.belief-option small,
.belief-option strong {
  display: block;
}

.belief-option small {
  margin-bottom: 4px;
  color: var(--accent-deep);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.belief-option strong {
  font-family: var(--serif);
  font-size: 18px;
  font-weight: 500;
  line-height: 1.35;
}

.validation-message {
  min-height: 24px;
  margin: 7px 0 13px;
  color: var(--danger);
  font-size: 13px;
  font-weight: 650;
}

.voice-step {
  text-align: left;
}

.voice-step blockquote {
  margin: 22px 0 12px;
  padding: 0;
  max-width: 560px;
  color: var(--accent-deep);
  font-family: var(--serif);
  font-size: clamp(25px, 5vw, 36px);
  line-height: 1.25;
}

.voice-target {
  color: var(--muted);
  font-size: 14px;
}

.echo-field {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 9px;
  max-width: 530px;
  margin: 25px 0 30px;
}

.echo-stone {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--muted);
  font-family: var(--serif);
  font-size: 13px;
}

.echo-stone.complete {
  border-color: var(--moss);
  background: var(--moss);
  color: white;
  animation: settle 260ms ease both;
}

.voice-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 156px;
  height: 156px;
  margin: 0 auto 12px;
  padding: 20px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent-deep);
  cursor: pointer;
}

.voice-button:hover {
  background: #eed0c0;
}

.voice-button.listening {
  animation: breathe 1.2s ease-in-out infinite;
}

.voice-button strong,
.voice-button small {
  z-index: 1;
  display: block;
}

.voice-button strong {
  font-size: 14px;
}

.voice-button small {
  margin-top: -8px;
  font-size: 10px;
}

.voice-status {
  min-height: 50px;
  margin: 10px auto;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
}

.voice-status.success {
  color: var(--moss);
  font-weight: 750;
}

.voice-status.retry {
  color: var(--accent-deep);
}

.text-button {
  text-decoration: underline;
  text-decoration-color: var(--line-strong);
  text-underline-offset: 4px;
}

.privacy-note {
  max-width: 520px;
  margin: 12px 0 24px;
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent);
}

footer {
  margin-top: 44px;
  padding-top: 20px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
}

.compact {
  min-height: 36px;
  font-size: 12px;
}

dialog {
  width: min(calc(100% - 30px), 560px);
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(40, 38, 31, 0.55);
}

.dialog-card {
  position: relative;
  padding: clamp(24px, 6vw, 40px);
}

.dialog-card h2 {
  font-size: 38px;
}

.dialog-card > p:not(.eyebrow),
.dialog-card li {
  color: var(--muted);
}

.dialog-card ol {
  margin: 22px 0;
  padding-left: 22px;
}

.dialog-card li + li {
  margin-top: 10px;
}

.dialog-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 44px;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font-size: 28px;
}

.toast {
  position: fixed;
  right: 18px;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 18px;
  z-index: 20;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 18px;
  border-radius: 10px;
  background: var(--ink);
  color: white;
  box-shadow: var(--shadow);
  text-align: center;
}

@keyframes settle {
  from {
    transform: scale(0.78);
  }
  to {
    transform: scale(1);
  }
}

@keyframes breathe {
  50% {
    box-shadow: 0 0 0 12px rgba(152, 77, 53, 0.12);
  }
}

@media (max-width: 560px) {
  body {
    background: var(--paper);
  }

  .app-shell {
    padding-inline: 16px;
  }

  .topbar {
    margin-bottom: 40px;
  }

  h1 {
    font-size: 48px;
  }

  .day-progress {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .gate-row {
    grid-template-columns: 44px minmax(0, 1fr);
  }

  .gate-status {
    grid-column: 2;
    text-align: left;
  }

  .quest-card {
    margin-inline: -8px;
    border-radius: 16px;
  }

  .field-actions,
  footer {
    align-items: flex-start;
    flex-direction: column;
  }

  .field-hint {
    order: -1;
  }

  .voice-button {
    width: 144px;
    height: 144px;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
}
