:root {
  color-scheme: light;
  --page: #f4f1ea;
  --page-quiet: #e9f1ef;
  --surface: #fffaf2;
  --surface-soft: #f7ead8;
  --ink: #17201b;
  --muted: #526158;
  --line: #b9c7bf;
  --accent: #176f5f;
  --accent-strong: #0f5146;
  --accent-soft: #d9ebe5;
  --warm: #a85f3d;
  --cool: #586f9b;
  --focus: #8b3d00;
  --shadow: 0 24px 70px rgb(45 52 47 / 14%);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  font-size: 18px;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    linear-gradient(135deg, var(--page) 0%, var(--page-quiet) 48%, #f1e4d6 100%);
  color: var(--ink);
  font-family:
    "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.55;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 3.1rem;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 150ms ease,
    background-color 150ms ease,
    box-shadow 150ms ease,
    border-color 150ms ease;
}

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

button:active {
  transform: translateY(0);
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
.skip-link:focus-visible {
  outline: 4px solid var(--focus);
  outline-offset: 3px;
}

.skip-link {
  position: fixed;
  top: 1rem;
  left: 1rem;
  z-index: 10;
  transform: translateY(-6rem);
  background: var(--ink);
  color: white;
  padding: 0.65rem 0.9rem;
  border-radius: 8px;
}

.skip-link:focus {
  transform: translateY(0);
}

.workspace-shell {
  width: min(100%, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  padding: clamp(1rem, 4vw, 3rem);
  display: grid;
  align-items: center;
}

.screen {
  position: relative;
  width: 100%;
  opacity: 1;
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.screen[hidden] {
  display: none;
}

[hidden] {
  display: none !important;
}

.workspace-card {
  position: relative;
  overflow: hidden;
  border: 1px solid rgb(23 32 27 / 10%);
  border-radius: 8px;
  background: rgb(255 250 242 / 90%);
  box-shadow: var(--shadow);
}

.welcome-card {
  min-height: min(76vh, 720px);
  padding: clamp(1.25rem, 5vw, 4rem);
  display: grid;
  align-content: center;
}

.story-card {
  padding: clamp(1rem, 3vw, 2rem);
}

.ambient-panel {
  position: absolute;
  inset: auto 2rem 2rem auto;
  width: min(36vw, 290px);
  aspect-ratio: 1;
  opacity: 0.75;
  pointer-events: none;
}

.ambient-panel span {
  position: absolute;
  display: block;
  border-radius: 8px;
  background: var(--accent-soft);
}

.ambient-panel span:nth-child(1) {
  inset: 12% 10% 52% 4%;
  background: #dce8fb;
}

.ambient-panel span:nth-child(2) {
  inset: 38% 5% 28% 28%;
  background: #f1dcc9;
}

.ambient-panel span:nth-child(3) {
  inset: 61% 28% 7% 10%;
  background: #d8e9dd;
}

.progress {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 1rem;
}

.welcome-card > .progress {
  position: absolute;
  top: clamp(1rem, 3vw, 2rem);
  right: clamp(1rem, 3vw, 2rem);
  left: clamp(1rem, 3vw, 2rem);
}

.progress-dots {
  display: inline-flex;
  gap: 0.5rem;
}

.dot {
  width: 0.72rem;
  height: 0.72rem;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background: transparent;
}

.dot-active {
  background: var(--accent);
}

.calm-mark {
  width: 5.8rem;
  height: 5.8rem;
  margin-bottom: 1.7rem;
  border-radius: 8px;
  background: var(--accent-soft);
  display: grid;
  place-items: center;
}

.calm-mark svg {
  width: 78%;
  height: 78%;
  fill: none;
}

.calm-mark path {
  stroke: var(--accent-strong);
  stroke-width: 5;
  stroke-linecap: round;
}

.calm-mark circle {
  fill: var(--warm);
}

.welcome-copy,
.story-heading {
  position: relative;
  max-width: 740px;
  z-index: 1;
}

.eyebrow {
  margin: 0 0 0.8rem;
  color: var(--accent-strong);
  font-weight: 800;
}

h1 {
  margin: 0 0 1rem;
  font-size: clamp(2.55rem, 7vw, 5.3rem);
  line-height: 1.02;
  letter-spacing: 0;
}

.story-heading h1 {
  font-size: clamp(2rem, 4.8vw, 3.7rem);
}

p {
  margin: 0;
}

.lead,
.story-heading p {
  max-width: 720px;
  color: var(--ink);
  font-size: clamp(1.25rem, 2.6vw, 1.65rem);
}

.supporting-text {
  max-width: 580px;
  margin-top: 1rem;
  color: var(--muted);
  font-size: 1.05rem;
}

.welcome-actions,
.restore-actions,
.story-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.welcome-actions {
  position: relative;
  z-index: 1;
  margin-top: 2rem;
  align-items: center;
}

.primary-action,
.secondary-action,
.text-action,
.back-action {
  padding: 0.86rem 1.15rem;
  font-weight: 800;
}

.primary-action {
  background: var(--accent);
  color: white;
  box-shadow: 0 12px 30px rgb(23 111 95 / 20%);
}

.primary-action:hover {
  background: var(--accent-strong);
}

.primary-action.compact {
  min-width: 7rem;
}

.secondary-action {
  background: var(--accent-soft);
  color: var(--ink);
}

.secondary-action:hover {
  background: #c8e2d9;
}

.text-action,
.back-action {
  background: transparent;
  color: var(--accent-strong);
  border: 2px solid transparent;
}

.text-action:hover,
.back-action:hover {
  border-color: var(--line);
  background: rgb(255 255 255 / 45%);
}

.how-it-works {
  position: relative;
  z-index: 1;
  max-width: 620px;
  margin-top: 1.25rem;
  padding: 1rem;
  border-left: 4px solid var(--warm);
  background: rgb(255 255 255 / 46%);
  color: var(--muted);
}

.story-topbar {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 1rem;
  align-items: center;
  margin-bottom: 1.2rem;
}

.story-topbar .progress {
  justify-self: end;
}

.story-heading {
  margin-bottom: 1.3rem;
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 0.75rem;
  margin: 0 0 1.2rem;
}

.topic-option {
  min-height: 3.4rem;
  padding: 0.85rem 1rem;
  border: 2px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  text-align: left;
  font-weight: 800;
}

.topic-option:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.topic-option[aria-pressed="true"],
.topic-selected {
  border-color: var(--accent-strong);
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 24px rgb(23 111 95 / 16%);
}

.notes-input {
  min-height: 9rem;
}

.children-list {
  display: grid;
  gap: 0.9rem;
  margin-bottom: 0.9rem;
}

.child-row {
  display: grid;
  gap: 0.45rem;
}

input {
  width: 100%;
  min-height: 3.1rem;
  padding: 0.75rem 0.9rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
}

input::placeholder {
  color: #718078;
}

.inline-action {
  width: fit-content;
  margin: 0 0 1.2rem;
}

.review-sections {
  display: grid;
  gap: 0.65rem;
}

.review-input {
  min-height: 8rem;
}

.small-review-input {
  min-height: 5rem;
}

.pilot-notice {
  margin-top: 1rem;
  padding: 1rem;
  border: 2px solid var(--accent);
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 800;
}

.restore-banner {
  margin: 0 0 1rem;
  padding: 1rem;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  border: 1px solid rgb(168 95 61 / 35%);
  border-radius: 8px;
  background: #fff4e8;
}

.restore-banner p {
  margin-top: 0.25rem;
  color: var(--muted);
}

.story-label {
  display: block;
  margin-bottom: 0.55rem;
  font-weight: 800;
}

textarea {
  display: block;
  width: 100%;
  min-height: min(52vh, 36rem);
  resize: vertical;
  padding: 1.05rem;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink);
  font-size: 1.12rem;
  line-height: 1.7;
  box-shadow: inset 0 1px 0 rgb(255 255 255 / 70%);
}

textarea::placeholder {
  color: #718078;
}

.story-footer {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 1rem;
  align-items: center;
  margin-top: 0.9rem;
}

.save-status {
  min-height: 1.8rem;
  color: var(--muted);
}

.save-status.saving {
  color: var(--cool);
}

.save-status.saved,
.save-status.restored {
  color: var(--accent-strong);
}

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

@media (max-width: 768px) {
  html {
    font-size: 17px;
  }

  .workspace-shell {
    align-items: start;
    padding: 0.85rem;
  }

  .welcome-card {
    min-height: calc(100vh - 1.7rem);
    padding: 5.7rem 1rem 1.15rem;
  }

  .story-card {
    min-height: calc(100vh - 1.7rem);
    padding: 0.95rem;
  }

  .ambient-panel {
    width: 9rem;
    right: 1rem;
    bottom: 1rem;
  }

  .welcome-card > .progress {
    align-items: flex-start;
    flex-direction: column;
  }

  .story-topbar,
  .story-footer,
  .restore-banner {
    grid-template-columns: 1fr;
  }

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

  .story-topbar .progress {
    justify-self: stretch;
  }

  .welcome-actions,
  .story-actions,
  .restore-actions {
    flex-direction: column;
  }

  .welcome-actions button,
  .story-actions button,
  .restore-actions button,
  .topic-option,
  .inline-action,
  .primary-action,
  .text-action,
  .secondary-action {
    width: 100%;
  }

  textarea {
    min-height: 48vh;
    font-size: 1.05rem;
  }
}

@media (max-width: 390px) {
  html {
    font-size: 16.5px;
  }

  h1 {
    font-size: 2.35rem;
  }

  .story-heading h1 {
    font-size: 2rem;
  }

  .lead,
  .story-heading p {
    font-size: 1.12rem;
  }

  textarea {
    min-height: 50vh;
  }
}
