:root {
  --ink: #1d2c3f;
  --muted: #5f6f7e;
  --paper: #fffdf7;
  --surface: #ffffff;
  --line: #dce4e5;
  --teal: #1c7c78;
  --teal-dark: #125e5b;
  --teal-soft: #dff3ef;
  --coral: #e86452;
  --coral-dark: #b94336;
  --coral-soft: #fff0ec;
  --gold: #f5c85b;
  --gold-soft: #fff6d8;
  --blue-soft: #eaf2ff;
  --shadow: 0 22px 60px rgba(34, 63, 79, 0.15);
  --radius-large: 32px;
  --radius-medium: 20px;
  font-family: Inter, ui-rounded, "SF Pro Rounded", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: #f5f2e8;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #f5f2e8;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 15% 5%, rgba(245, 200, 91, 0.27), transparent 27rem),
    radial-gradient(circle at 88% 90%, rgba(28, 124, 120, 0.18), transparent 30rem),
    linear-gradient(155deg, #fbf9f2 0%, #f4f1e7 55%, #eef5f1 100%);
}

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

button {
  font: inherit;
}

.page-glow {
  position: fixed;
  width: 24rem;
  height: 24rem;
  border-radius: 50%;
  filter: blur(2px);
  pointer-events: none;
  z-index: 0;
}

.page-glow-one {
  top: -13rem;
  right: -8rem;
  background: rgba(232, 100, 82, 0.11);
}

.page-glow-two {
  bottom: -15rem;
  left: -8rem;
  background: rgba(28, 124, 120, 0.12);
}

.loading-mark {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
}

.loading-mark span {
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  background: var(--teal);
  animation: loading-bob 850ms ease-in-out infinite alternate;
}

.loading-mark span:nth-child(2) {
  animation-delay: 140ms;
}

.loading-mark span:nth-child(3) {
  animation-delay: 280ms;
}

@keyframes loading-bob {
  to {
    transform: translateY(-0.45rem);
    opacity: 0.45;
  }
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(960px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 40px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

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

.brand-mark {
  display: grid;
  width: 52px;
  height: 52px;
  place-items: center;
  border: 2px solid rgba(29, 44, 63, 0.12);
  border-radius: 18px 18px 22px 14px;
  background: var(--gold-soft);
  box-shadow: 0 9px 18px rgba(128, 97, 26, 0.12);
  transform: rotate(-3deg);
}

.brand-face {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: -0.12em;
  transform: rotate(3deg);
}

.brand strong {
  display: block;
  font-size: 1.22rem;
  letter-spacing: -0.02em;
}

.brand small {
  display: block;
  max-width: 330px;
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.badge {
  padding: 8px 11px;
  border: 1px solid rgba(28, 124, 120, 0.15);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.67);
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 750;
}

.badge-warm {
  border-color: rgba(232, 100, 82, 0.15);
  color: #93392e;
}

.progress-track {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  margin: 30px 0 22px;
  padding: 0 24px;
  list-style: none;
}

.session-path {
  min-height: 1.25rem;
  margin: -10px 0 18px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 760;
  text-align: center;
}

.progress-track::before {
  position: absolute;
  top: 17px;
  right: 13%;
  left: 13%;
  height: 2px;
  background: var(--line);
  content: "";
}

.progress-track li {
  position: relative;
  display: grid;
  place-items: center;
  gap: 6px;
  color: #85919c;
  font-size: 0.76rem;
  font-weight: 720;
  text-align: center;
}

.progress-dot {
  position: relative;
  z-index: 1;
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: #75838e;
  font-size: 0.82rem;
  transition: 180ms ease;
}

.progress-track li.is-complete .progress-dot,
.progress-track li.is-active .progress-dot {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.progress-track li.is-complete,
.progress-track li.is-active {
  color: var(--teal-dark);
}

.progress-track li.is-active .progress-dot {
  box-shadow: 0 0 0 6px rgba(28, 124, 120, 0.12);
  transform: scale(1.05);
}

main {
  position: relative;
}

.safety-panel {
  position: sticky;
  top: 12px;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(120px, 0.65fr) minmax(190px, 1.35fr);
  gap: 10px;
  width: min(620px, calc(100% - 28px));
  margin: 0 auto -26px;
  padding: 8px;
  border: 1px solid rgba(29, 44, 63, 0.08);
  border-radius: 18px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: 0 10px 26px rgba(34, 63, 79, 0.13);
  backdrop-filter: blur(10px);
}

.safety-button {
  min-height: 50px;
  border: 2px solid transparent;
  border-radius: 13px;
  cursor: pointer;
  font-weight: 820;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.safety-button span:first-child {
  margin-right: 7px;
}

.safety-button:hover {
  transform: translateY(-1px);
}

.safety-button:active {
  transform: translateY(1px);
}

.safety-button-stop {
  border-color: #f1b8af;
  background: var(--coral-soft);
  color: var(--coral-dark);
}

.safety-button-grown-up {
  border-color: #99d6cf;
  background: var(--teal-soft);
  color: var(--teal-dark);
}

.flow-card {
  position: relative;
  min-height: 430px;
  padding: 60px clamp(24px, 7vw, 72px) 32px;
  overflow: hidden;
  border: 1px solid rgba(29, 44, 63, 0.08);
  border-radius: var(--radius-large);
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  text-align: center;
  outline: none;
}

.flow-card:focus-visible {
  box-shadow: var(--shadow), 0 0 0 5px rgba(28, 124, 120, 0.17);
}

.card-accent {
  position: absolute;
  top: -86px;
  right: -76px;
  width: 230px;
  height: 230px;
  border-radius: 42% 58% 52% 48%;
  background: var(--gold-soft);
  transform: rotate(24deg);
}

.state-icon {
  position: relative;
  display: grid;
  width: 68px;
  height: 68px;
  margin: 0 auto 12px;
  place-items: center;
  border-radius: 26px 26px 30px 20px;
  background: var(--blue-soft);
  color: var(--ink);
  font-size: 2rem;
  font-weight: 900;
  box-shadow: inset 0 0 0 2px rgba(29, 44, 63, 0.05);
}

body[data-state^="tap_"] .state-icon {
  background: var(--gold-soft);
  color: #7f5b0b;
  animation: tap-pulse 1.8s ease-in-out infinite;
}

body[data-state="adult_support"] .flow-card {
  border-color: rgba(232, 100, 82, 0.28);
  background: #fffbf9;
}

body[data-state="adult_support"] .card-accent {
  background: var(--coral-soft);
}

body[data-state="adult_support"] .state-icon {
  background: var(--coral-soft);
}

body[data-emotion="mad_hot"] .card-accent {
  background: #ffe6d9;
}

body[data-emotion="mad_hot"] .state-icon {
  background: #fff0e8;
  color: #934026;
}

body[data-emotion="sad_heavy"] .card-accent {
  background: #e8edff;
}

body[data-emotion="sad_heavy"] .state-icon {
  background: #eef1ff;
  color: #45568f;
}

body[data-mode="teen"] .flow-card {
  border-radius: 24px;
}

body[data-state="adult_support"] .card-accent,
body[data-state="adult_support"] .state-icon {
  background: var(--coral-soft);
  color: var(--coral-dark);
}

body[data-state^="complete_"] .state-icon {
  background: var(--teal-soft);
  color: var(--teal-dark);
}

@keyframes tap-pulse {
  50% {
    transform: scale(1.04) rotate(1deg);
    box-shadow: inset 0 0 0 2px rgba(29, 44, 63, 0.05), 0 0 0 10px rgba(245, 200, 91, 0.12);
  }
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--teal-dark);
  font-size: 0.76rem;
  font-weight: 850;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.flow-card h1 {
  max-width: 650px;
  margin: 0 auto;
  font-size: clamp(1.9rem, 4.6vw, 2.9rem);
  line-height: 1.03;
  letter-spacing: -0.045em;
}

.state-body {
  max-width: 650px;
  margin: 14px auto 0;
  color: #425465;
  font-size: clamp(1.06rem, 2.5vw, 1.28rem);
  line-height: 1.58;
}

body[data-state^="tap_"] .state-body {
  max-width: 700px;
  color: var(--ink);
  font-size: clamp(1.3rem, 3.5vw, 1.85rem);
  font-weight: 720;
  line-height: 1.36;
}

.helper {
  max-width: 620px;
  margin: 12px auto 0;
  padding: 10px 16px;
  border-radius: 14px;
  background: #f4f7f7;
  color: var(--muted);
  font-size: 0.91rem;
  line-height: 1.45;
}

.helper:empty {
  display: none;
}

.recovery-message {
  max-width: 620px;
  margin: 18px auto 0;
  padding: 13px 16px;
  border: 1px solid #e9ca75;
  border-radius: 14px;
  background: var(--gold-soft);
  color: #664a0c;
  font-weight: 720;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  max-width: 650px;
  margin: 22px auto 0;
}

.choice-button {
  min-height: 64px;
  padding: 14px 18px;
  border: 2px solid #cad7d9;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 1.02rem;
  font-weight: 820;
  line-height: 1.25;
  box-shadow: 0 7px 16px rgba(34, 63, 79, 0.07);
  transition: 130ms ease;
}

.choice-button:hover {
  border-color: var(--teal);
  transform: translateY(-2px);
  box-shadow: 0 10px 20px rgba(34, 63, 79, 0.11);
}

.choice-button:active {
  transform: translateY(1px);
}

.choice-button.is-primary {
  border-color: var(--teal);
  background: var(--teal);
  color: white;
}

.choice-button.is-primary:hover {
  border-color: var(--teal-dark);
  background: var(--teal-dark);
}

.choice-button.is-alert {
  border-color: #f0b5ac;
  background: var(--coral-soft);
  color: var(--coral-dark);
}

.choice-button.is-quiet {
  background: #f7f9f8;
  color: #50616e;
}

.choice-button.is-full {
  grid-column: 1 / -1;
}

button:focus-visible,
a:focus-visible {
  outline: 4px solid rgba(28, 124, 120, 0.25);
  outline-offset: 3px;
}

.app-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 16px 8px 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.app-footer p {
  margin: 0;
}

@media (max-width: 720px) {
  .app-shell {
    width: min(100% - 20px, 600px);
    padding-top: 18px;
  }

  .app-header {
    align-items: flex-start;
  }

  .badges {
    display: none;
  }

  .brand small {
    max-width: 230px;
  }

  .progress-track {
    margin-top: 23px;
    padding: 0;
  }

  .progress-track::before {
    right: 12%;
    left: 12%;
  }

  .progress-track li > span:last-child {
    max-width: 58px;
    font-size: 0.68rem;
  }

  .safety-panel {
    top: 8px;
    width: calc(100% - 16px);
    grid-template-columns: 0.72fr 1.28fr;
    margin-bottom: -23px;
  }

  .safety-button {
    min-height: 48px;
    padding: 8px 7px;
    font-size: 0.86rem;
  }

  .flow-card {
    min-height: 520px;
    padding: 70px 20px 30px;
    border-radius: 26px;
  }

  .state-icon {
    width: 68px;
    height: 68px;
    border-radius: 23px 23px 27px 18px;
  }

  .options {
    gap: 10px;
  }

  .choice-button {
    min-height: 62px;
    padding: 12px 10px;
    border-radius: 16px;
    font-size: 0.94rem;
  }

  .app-footer {
    display: grid;
    gap: 7px;
    text-align: center;
  }
}

@media (max-width: 420px) {
  .brand-mark {
    width: 46px;
    height: 46px;
  }

  .brand small {
    display: none;
  }

  .progress-track li > span:last-child {
    display: none;
  }

  .progress-track {
    margin-bottom: 15px;
  }

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

  .choice-button.is-full {
    grid-column: auto;
  }
}

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

@media (prefers-contrast: more) {
  :root {
    --line: #7b878c;
  }

  .flow-card,
  .choice-button,
  .safety-panel {
    border-color: currentColor;
  }
}

.sound-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 2px solid #d9e2ec;
  border-radius: 999px;
  background: #ffffff;
  cursor: pointer;
  font-size: 1.05rem;
  line-height: 1;
  padding: 0;
  flex: 0 0 auto;
}

.sound-toggle:hover {
  border-color: #9fb3c8;
}

.sound-toggle[aria-pressed="false"] {
  opacity: 0.55;
}
