:root {
  --cream: #f7efe3;
  --paper: #fffdf7;
  --green: #203a32;
  --green-soft: #66756d;
  --sage: #dfe9e2;
  --sage-strong: #8fa284;
  --yellow: #f5c36b;
  --coral: #f27861;
  --coral-panel: #dfa08e;
  --line: rgba(32, 58, 50, 0.14);
  --muted-line: #e7dece;
  --shadow: 0 18px 48px rgba(41, 36, 27, 0.1);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  background: var(--cream);
  color: var(--green);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

a {
  color: inherit;
}

.hidden {
  display: none !important;
}

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

.app-shell {
  min-height: 100vh;
}

.brand {
  display: inline-block;
  text-decoration: none;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  color: var(--green);
  font-family: Inter, "Avenir Next", Avenir, "Segoe UI", Arial, sans-serif;
  font-size: clamp(1.55rem, 2.1vw, 2rem);
  font-weight: 900;
  line-height: 1;
}

.logo-l,
.logo-word {
  display: inline-block;
}

.logo-o {
  position: relative;
  display: inline-grid;
  width: 0.9em;
  height: 0.9em;
  margin: 0 -0.02em 0 -0.01em;
  place-items: center;
  border: 0.15em solid var(--green);
  border-right-color: transparent;
  border-radius: 999px;
  transform: translateY(0.03em) rotate(-28deg);
  animation: logo-ring-load 1.6s cubic-bezier(.2,.8,.2,1) both, logo-ring-turn 8s linear 1.8s infinite;
}

.logo-o span {
  display: block;
  width: 0.28em;
  height: 0.28em;
  border: 1px solid rgba(32, 58, 50, 0.3);
  border-radius: 999px;
  background: var(--coral);
  box-shadow: 0 0 0 0 rgba(242, 120, 97, 0.22);
  transform: rotate(28deg) scale(0.35);
  opacity: 0;
  animation: logo-seed-arrive 0.52s cubic-bezier(.2,1.5,.4,1) 0.55s both, logo-seed-grow 3.4s ease-in-out 1.25s infinite;
}

.setup-brand .logo-mark {
  font-size: clamp(1.8rem, 3.2vw, 2.45rem);
}

@keyframes logo-ring-load {
  from {
    clip-path: inset(0 70% 0 0);
    opacity: 0.4;
  }
  to {
    clip-path: inset(0);
    opacity: 1;
  }
}

@keyframes logo-ring-turn {
  to {
    transform: translateY(0.03em) rotate(332deg);
  }
}

@keyframes logo-seed-arrive {
  to {
    opacity: 1;
    transform: rotate(28deg) scale(1);
  }
}

@keyframes logo-seed-grow {
  0%, 72%, 100% {
    box-shadow: 0 0 0 0 rgba(242, 120, 97, 0.22);
    transform: rotate(28deg) scale(1);
  }
  86% {
    box-shadow: 0 0 0 0.28em rgba(242, 120, 97, 0);
    transform: rotate(28deg) scale(1.55);
  }
}

@media (prefers-reduced-motion: reduce) {
  .logo-o,
  .logo-o span {
    animation: none;
    clip-path: none;
    opacity: 1;
  }

  .logo-o span {
    transform: rotate(28deg) scale(1);
  }
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--green-soft);
  font-size: 0.75rem;
  font-weight: 900;
  text-transform: uppercase;
}

.setup-journey {
  display: grid;
  min-height: 100vh;
  padding: 28px;
  place-items: center;
  background:
    linear-gradient(rgba(247, 239, 227, 0.72), rgba(247, 239, 227, 0.92)),
    radial-gradient(circle at 22% 28%, rgba(242, 120, 97, 0.22), transparent 24rem),
    radial-gradient(circle at 84% 76%, rgba(143, 162, 132, 0.24), transparent 22rem);
}

.setup-brand {
  position: fixed;
  top: 30px;
  left: 30px;
}

.setup-screen {
  width: min(470px, 100%);
  border: 1px solid var(--line);
  border-radius: 26px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: var(--shadow);
  padding: clamp(22px, 4vw, 36px);
}

.setup-screen:has(.setup-step.active .setup-calibration) {
  width: min(760px, 100%);
}

.setup-progress {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
}

.setup-progress span {
  height: 7px;
  flex: 1;
  border-radius: 999px;
  background: rgba(32, 58, 50, 0.12);
}

.setup-progress span.active {
  background: var(--coral);
}

.setup-step {
  display: none;
}

.setup-step.active {
  display: grid;
  gap: 18px;
}

.setup-step h1 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 8vw, 3.6rem);
  line-height: 1;
}

.setup-step p {
  margin: 0;
  color: var(--green-soft);
  font-size: 1rem;
  line-height: 1.55;
}

label {
  display: grid;
  gap: 8px;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 800;
}

input[type="date"],
input[type="text"] {
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--muted-line);
  border-radius: 12px;
  background: #fffefb;
  color: var(--green);
  padding: 0 14px;
}

.setup-actions {
  display: flex;
  gap: 10px;
}

.primary-action,
.ghost-action {
  min-height: 52px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 900;
  padding: 0 18px;
}

.primary-action {
  width: 100%;
  border: 0;
  background: var(--green);
  color: var(--paper);
}

.ghost-action {
  border: 1px solid var(--line);
  background: rgba(255, 253, 247, 0.8);
  color: var(--green);
}

.form-error {
  margin: 16px 0 0;
  border-radius: 12px;
  background: #fff1ea;
  color: #934431;
  font-weight: 800;
  padding: 12px;
}

.story-app {
  display: grid;
  height: 100vh;
  min-height: 780px;
  grid-template-rows: 86px minmax(0, 1fr);
  overflow: hidden;
  background: var(--cream);
}

.app-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--muted-line);
  padding: 0 36px;
}

.top-status {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--green-soft);
  font-size: 1.08rem;
}

.profile-menu-trigger {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  border: 0;
  border-radius: 999px;
  background: var(--green);
  color: var(--paper);
  cursor: pointer;
  font-weight: 900;
}

.profile-menu-trigger span {
  display: block;
}

.profile-menu {
  position: absolute;
  top: calc(100% + 12px);
  right: 0;
  z-index: 20;
  display: grid;
  width: 210px;
  overflow: hidden;
  border: 1px solid var(--muted-line);
  border-radius: 14px;
  background: var(--paper);
  box-shadow: var(--shadow);
  padding: 6px;
}

.profile-menu button {
  min-height: 44px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--green);
  cursor: pointer;
  font: inherit;
  font-size: 0.92rem;
  font-weight: 850;
  padding: 0 12px;
  text-align: left;
}

.profile-menu button:hover,
.profile-menu button:focus-visible {
  background: rgba(143, 162, 132, 0.16);
  outline: none;
}

.profile-menu button[data-reset-profile] {
  color: #a94635;
}

.app-layout {
  display: grid;
  min-height: 0;
  grid-template-columns: minmax(0, 1fr);
}

.workspace {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0 clamp(24px, 5vw, 76px) 32px;
}

.workspace-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 20px;
  margin-bottom: 26px;
}

.workspace-header p {
  margin: 22px 0 0;
  color: var(--green-soft);
  font-size: 1.16rem;
  font-weight: 800;
}

.workspace-header span {
  min-width: 182px;
  border: 1px solid var(--muted-line);
  border-top: 0;
  border-radius: 0 0 16px 16px;
  background: var(--paper);
  color: var(--green);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.12rem;
  font-weight: 900;
  padding: 14px 20px;
  text-align: center;
}

.progress-card {
  display: grid;
  gap: 12px;
  border: 1px solid var(--muted-line);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 1px 0 rgba(32, 58, 50, 0.04);
  padding: 20px 24px 18px;
}

.progress-card-top,
.progress-labels {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  color: var(--green-soft);
  font-size: 0.88rem;
  font-weight: 900;
}

.progress-scrubber {
  position: relative;
  min-height: 22px;
  display: grid;
  align-items: center;
}

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

.progress-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--coral), #f5b16e);
}

.time-scrubber {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 22px;
  margin: 0;
  appearance: none;
  background: transparent;
  cursor: ew-resize;
}

.time-scrubber::-webkit-slider-runnable-track {
  height: 22px;
  background: transparent;
}

.time-scrubber::-webkit-slider-thumb {
  width: 22px;
  height: 22px;
  margin-top: 0;
  appearance: none;
  border: 4px solid var(--paper);
  border-radius: 999px;
  background: var(--coral);
  box-shadow: 0 2px 8px rgba(32, 58, 50, 0.18);
}

.time-scrubber::-moz-range-track {
  height: 22px;
  background: transparent;
}

.time-scrubber::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border: 4px solid var(--paper);
  border-radius: 999px;
  background: var(--coral);
  box-shadow: 0 2px 8px rgba(32, 58, 50, 0.18);
}

.time-scrubber:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 5px;
}

.day-history {
  margin: 22px 0;
  min-width: 0;
}

.day-rail {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  padding: 2px 0 8px;
  scrollbar-color: var(--coral) rgba(32, 58, 50, 0.12);
}

.day-chip {
  flex: 0 0 82px;
  min-height: 50px;
  scroll-snap-align: center;
  border: 1px solid var(--muted-line);
  border-radius: 13px;
  background: rgba(255, 253, 247, 0.78);
  color: var(--green-soft);
  cursor: pointer;
  padding: 8px 10px;
  text-align: left;
}

.day-chip span {
  display: block;
  color: var(--green);
  font-weight: 900;
}

.day-chip small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.day-chip.active {
  border-color: transparent;
  background: var(--green);
  color: var(--paper);
}

.day-chip.active span {
  color: var(--paper);
}

.tabs,
.mode-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  background: #e8e1d4;
  padding: 5px;
}

.tabs button,
.mode-toggle button {
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--green-soft);
  cursor: pointer;
  font-weight: 900;
  padding: 0 22px;
}

.tabs button.active,
.mode-toggle button.active {
  background: var(--paper);
  color: var(--green);
  box-shadow: 0 1px 5px rgba(32, 58, 50, 0.08);
}

.perspective-tabs {
  margin-bottom: 22px;
}

.page-panels {
  min-height: 0;
  overflow: hidden;
}

.app-panel {
  display: none;
  height: 100%;
  min-height: 0;
  overflow: auto;
  padding-bottom: 6px;
}

.app-panel.active {
  display: block;
}

.app-panel[data-page-panel="story"].active {
  display: grid;
  align-content: start;
  grid-auto-rows: max-content;
  gap: 18px;
}

.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.72fr);
  gap: 20px;
}

.science-card,
.care-today-card,
.support-card,
.detail-page,
.calibration-tool {
  border: 1px solid var(--muted-line);
  border-radius: 24px;
  box-shadow: 0 1px 0 rgba(32, 58, 50, 0.04);
}

.science-card {
  min-height: clamp(440px, 58vh, 680px);
  overflow: hidden;
  background: var(--coral-panel);
  padding: clamp(20px, 3vw, 38px);
}

.science-card-body {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(0, 1fr);
  gap: clamp(22px, 4vw, 58px);
  align-items: center;
  min-height: clamp(348px, 48vh, 570px);
}

.science-card h1 {
  margin: 10px 0 18px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.5rem, 4.6vw, 4.6rem);
  line-height: 0.98;
}

.science-card p {
  margin: 0;
  color: rgba(32, 58, 50, 0.88);
  font-size: 1.05rem;
  line-height: 1.5;
}

.baby-art {
  display: grid;
  min-width: 0;
  min-height: clamp(300px, 44vh, 540px);
  max-height: none;
  place-items: center;
  overflow: auto;
  overscroll-behavior: contain;
}

.baby-art img {
  width: min(92%, 460px);
  max-height: min(520px, 46vh);
  height: auto;
  object-fit: contain;
  filter: drop-shadow(0 24px 28px rgba(116, 63, 45, 0.16));
  transform: scale(var(--illustration-scale, 1));
  transition: width 220ms ease, transform 220ms ease, opacity 180ms ease;
  transform-origin: center;
}

.baby-art.actual {
  justify-content: start;
  align-content: start;
  align-items: start;
  justify-items: center;
  max-width: 100%;
  overflow: auto;
  padding: 12px;
}

.baby-art.actual img {
  width: auto;
  max-width: none;
  max-height: none;
  transform: none;
}

.baby-art[data-stage="early"]:not(.actual) {
  overflow: hidden;
}

.early-stage-visual {
  position: relative;
  display: grid;
  width: min(74%, 360px);
  aspect-ratio: 1;
  place-items: center;
}

.early-stage-visual::before,
.early-stage-visual::after {
  position: absolute;
  content: "";
  border-radius: 999px;
}

.early-stage-visual::before {
  inset: 18%;
  border: 1px solid rgba(255, 253, 247, 0.34);
  box-shadow:
    0 0 0 42px rgba(255, 253, 247, 0.08),
    inset 0 0 58px rgba(255, 253, 247, 0.2);
}

.early-stage-visual::after {
  width: 38%;
  height: 22%;
  background:
    radial-gradient(circle at 28% 46%, rgba(255, 240, 224, 0.95) 0 18%, transparent 20%),
    linear-gradient(135deg, #f8a078, #e8705a 58%, #c65446);
  filter: drop-shadow(0 18px 22px rgba(116, 63, 45, 0.16));
  transform: rotate(-18deg) scale(var(--early-scale, 1));
  transition: transform 220ms ease;
}

.early-stage-visual span {
  width: 11%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: #7f3944;
  opacity: 0.62;
  transform: translate(-40%, 10%) scale(var(--early-scale, 1));
  transition: transform 220ms ease;
  z-index: 1;
}

.care-today-card {
  display: grid;
  min-height: 368px;
  align-content: space-between;
  background: var(--green);
  color: var(--paper);
  padding: 34px;
}

.care-today-top {
  display: flex;
  justify-content: space-between;
  gap: 18px;
}

.care-today-card .eyebrow {
  color: rgba(255, 253, 247, 0.72);
}

.care-today-card .eyebrow span {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--coral);
  margin-right: 8px;
}

.care-today-card h2 {
  margin: 28px 0 16px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.35rem, 3.6vw, 4.1rem);
  line-height: 0.98;
}

.care-today-card p {
  margin: 0;
  color: rgba(255, 253, 247, 0.76);
  font-size: 1.06rem;
  line-height: 1.55;
}

.daily-dots {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 28px;
}

.daily-dots button {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255, 253, 247, 0.28);
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 253, 247, 0.72);
  cursor: pointer;
}

.daily-dots button.active {
  border-color: var(--coral);
  background: var(--coral);
  color: var(--paper);
  font-weight: 900;
}

.support-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 0.82fr);
  gap: 20px;
  margin-top: 20px;
}

.support-card {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 20px;
  background: var(--paper);
  padding: 28px;
}

.support-card.partner-support {
  background: var(--sage);
}

.support-icon {
  display: grid;
  width: 48px;
  height: 48px;
  place-items: center;
  border-radius: 999px;
  background: #f9f4ea;
  font-size: 1.8rem;
}

.support-card h2,
.detail-page h2,
.calibration h2,
.medical-links h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.65rem, 3vw, 2.7rem);
  line-height: 1.08;
}

.support-card a {
  display: inline-block;
  margin-top: 22px;
  color: #bd523f;
  font-weight: 900;
  text-decoration: none;
}

.detail-page {
  background: var(--paper);
  padding: 30px;
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(132px, 1fr));
  gap: 10px;
  margin-top: 22px;
}

.week-pill {
  display: grid;
  gap: 5px;
  min-height: 78px;
  border: 1px solid var(--muted-line);
  border-radius: 14px;
  background: rgba(255, 253, 247, 0.82);
  color: var(--green);
  cursor: pointer;
  padding: 12px;
  text-align: left;
}

.week-pill.active {
  border-color: transparent;
  background: var(--green);
  color: var(--paper);
}

.week-pill span {
  font-weight: 900;
}

.week-pill small {
  overflow: hidden;
  color: inherit;
  opacity: 0.76;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.calibration {
  display: grid;
  grid-template-columns: 0.9fr 1.1fr;
  gap: 28px;
  align-items: center;
}

.calibration p,
.medical-links p,
.detail-page p {
  color: var(--green-soft);
  line-height: 1.7;
}

.calibration-tool {
  display: grid;
  gap: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  background: var(--paper);
  padding: 20px;
}

.calibration-tool label {
  min-width: min(100%, 320px);
}

.calibration-tool input[type="range"] {
  width: 100%;
}

.card-outline {
  display: grid;
  max-width: none;
  aspect-ratio: 85.6 / 53.98;
  place-items: center;
  border: 2px dashed var(--sage-strong);
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(143, 162, 132, 0.28), rgba(245, 195, 107, 0.2));
  color: var(--green);
  font-weight: 900;
}

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

.medical-links div {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.medical-links a {
  min-height: 42px;
  border-radius: 12px;
  background: rgba(143, 162, 132, 0.18);
  color: var(--green);
  font-weight: 900;
  padding: 10px 14px;
  text-decoration: none;
}

.bottom-nav {
  position: fixed;
  right: 12px;
  bottom: 12px;
  left: 12px;
  z-index: 10;
  display: none;
  justify-content: space-around;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 253, 247, 0.94);
  box-shadow: var(--shadow);
  padding: 8px;
}

.bottom-nav button {
  flex: 1;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--green-soft);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 900;
}

.bottom-nav button.active {
  background: var(--green);
  color: var(--paper);
}

@media (max-width: 1120px) {
  .story-app {
    min-height: 100vh;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .workspace {
    padding-inline: 18px;
  }
}

@media (max-width: 920px) {
  .story-app {
    height: 100dvh;
    min-height: 100vh;
    overflow: hidden;
    padding-bottom: 76px;
  }

  .app-layout,
  .workspace {
    min-height: 0;
    overflow: hidden;
  }

  .page-panels {
    min-height: 0;
    overflow: hidden;
  }

  .app-panel {
    min-height: 0;
    overflow: auto;
  }

  .dashboard-grid,
  .support-grid,
  .science-card-body,
  .calibration {
    grid-template-columns: 1fr;
  }

  .science-card-body > div:last-child {
    order: -1;
  }

  .bottom-nav {
    display: flex;
  }
}

@media (max-width: 640px) {
  .setup-journey {
    padding: 18px;
  }

  .setup-brand {
    position: static;
    justify-self: start;
    margin-bottom: 18px;
  }

  .setup-screen {
    border-radius: 20px;
  }

  .app-topbar {
    height: 72px;
    padding: 0 16px;
  }

  .top-status {
    font-size: 0.92rem;
  }

  .profile-menu-trigger {
    width: 40px;
    height: 40px;
  }

  .profile-menu {
    right: -2px;
    width: min(210px, calc(100vw - 32px));
  }

  .workspace {
    padding: 0 14px 24px;
  }

  .science-card {
    min-height: 0;
  }

  .science-card-body {
    min-height: 0;
    gap: 18px;
  }

  .science-card h1 {
    font-size: clamp(2.35rem, 12vw, 3.5rem);
  }

  .baby-art {
    min-height: 160px;
    overflow: hidden;
  }

  .baby-art img {
    width: min(72%, 220px);
    max-height: 170px;
  }

  .baby-art.actual {
    min-height: min(340px, 42vh);
    max-height: min(340px, 42vh);
    overflow: auto;
  }

  .baby-art.actual img {
    width: auto;
    max-width: none;
    max-height: none;
  }

  .workspace-header {
    grid-template-columns: 1fr;
    gap: 8px;
    margin-bottom: 16px;
  }

  .workspace-header span {
    width: 100%;
    border: 1px solid var(--muted-line);
    border-radius: 14px;
  }

  .progress-card {
    padding: 16px;
  }

  .progress-labels {
    font-size: 0.76rem;
  }

  .tabs {
    width: 100%;
  }

  .tabs button {
    flex: 1;
    padding: 0 8px;
  }

  .science-card,
  .care-today-card,
  .support-card,
  .detail-page {
    border-radius: 18px;
  }

  .science-card {
    min-height: auto;
    padding: 18px;
  }

  .care-today-card {
    min-height: 360px;
    padding: 24px;
  }

  .daily-dots {
    gap: 8px;
  }

  .daily-dots button {
    width: 38px;
    height: 38px;
  }
}
