@font-face {
  font-family: Baskervville;
  src: url("./material/baskervville.woff2") format("woff2");
  font-display: swap;
}

@font-face {
  font-family: "DM Sans";
  src: url("./material/dm-sans.woff2") format("woff2");
  font-weight: 100 1000;
  font-display: swap;
}

:root {
  color-scheme: light;
  --bg: #f8f2e9;
  --paper: #fffcf6;
  --ink: #163025;
  --muted: #4c5f51;
  --accent: #96482f;
  --green: #23432f;
  --line: #dcd0bd;
  --soft: #f3e8d9;
  --sage: #e8eee1;
  --pad: clamp(1rem, 4vw, 2rem);
  --measure: 47rem;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 4.5rem; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 1rem/1.6 "DM Sans", system-ui, sans-serif; }
img, svg { display: block; max-width: 100%; }
img { height: auto; }
button, input, textarea, select { font: inherit; color: inherit; }
h1, h2, h3 { font-family: Baskervville, Georgia, serif; font-weight: 400; line-height: 1.14; text-wrap: balance; }
h1, h2, h3, h4, p, figure, ol, ul, dl, fieldset { margin: 0; }
h1 { font-size: clamp(2.55rem, 9.5vw, 5rem); letter-spacing: -.035em; }
h2 { font-size: clamp(1.9rem, 6.5vw, 3.1rem); letter-spacing: -.018em; }
h3 { font-size: clamp(1.45rem, 4.8vw, 2rem); }
h4 { font-size: 1.05rem; line-height: 1.35; }
a { color: inherit; text-decoration-thickness: .07em; text-underline-offset: .19em; }
a, summary, button { -webkit-tap-highlight-color: #23432f25; }
summary, button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
:target { scroll-margin-block: .5rem; }
p, h1, h2, h3, h4, dt, dd, a { overflow-wrap: break-word; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.shell { width: min(100%, var(--measure)); margin-inline: auto; padding-inline: var(--pad); }
.skip-link {
  position: fixed;
  left: .75rem;
  top: .75rem;
  z-index: 10;
  transform: translateY(-180%);
  background: var(--paper);
  padding: .65rem 1rem;
  border-radius: .5rem;
}
.skip-link:focus { transform: none; }
.site-bar {
  position: sticky;
  top: 0;
  z-index: 5;
  padding-top: env(safe-area-inset-top);
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.site-bar nav { display: flex; align-items: center; justify-content: space-between; gap: .65rem; min-height: 3.5rem; }
.site-bar a { display: inline-flex; align-items: center; gap: .35rem; min-height: 2.75rem; font-size: .85rem; font-weight: 650; }
.site-bar svg { flex: none; }
.site-bar a:last-child { flex: none; }

.hero { padding-block: clamp(1.7rem, 5vw, 3.8rem) 1.8rem; }
.eyebrow { color: var(--accent); font: 750 .72rem/1.35 "DM Sans", sans-serif; letter-spacing: .095em; text-transform: uppercase; }
.hero h1 { margin-block: .48rem .6rem; }
.hero-subtitle { color: var(--muted); }
.hero-actions { display: flex; align-items: center; gap: .55rem 1.15rem; flex-wrap: wrap; margin-block: 1.15rem 1.45rem; }
.button, .text-link, .grounding-controls a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  min-height: 2.75rem;
  font-weight: 700;
}
.button, .grounding-controls a {
  padding: .52rem .95rem;
  background: var(--green);
  border: 1px solid var(--green);
  border-radius: 1.7rem;
  color: #fffdf8;
  text-decoration: none;
  line-height: 1.3;
}
.button:hover, .grounding-controls a:hover { background: var(--ink); }
.hero-cards { display: grid; gap: .55rem; list-style: none; padding: 0; }
.hero-cards a {
  display: grid;
  grid-template-columns: min(35%, 8.5rem) 1fr auto;
  align-items: center;
  gap: .72rem;
  min-height: 3.5rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: .8rem;
  text-decoration: none;
  font-weight: 650;
  line-height: 1.25;
  padding: .28rem .65rem .28rem .28rem;
}
.hero-cards a:hover { border-color: var(--green); }
.hero-cards .art img { width: 100%; aspect-ratio: 1.85; object-fit: cover; border-radius: .55rem; }
.hero-cards a > span:last-child { color: var(--accent); }

.chapter-index { padding-block: 1.4rem 1.6rem; border-top: 1px solid var(--line); }
.chapter-index h2 { margin-bottom: .75rem; }
.chapter-index h3 { margin-block: 1.1rem .45rem; }
.chapter-index ol { list-style: none; padding: 0; }
.chapter-index li + li { border-top: 1px solid var(--line); }
.chapter-index li a {
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: .55rem;
  min-height: 2.95rem;
  padding: .45rem .35rem;
  text-decoration: none;
  line-height: 1.35;
}
.chapter-index li a:hover { background: var(--paper); }
.chapter-index .number { color: var(--accent); font-size: .8rem; font-variant-numeric: tabular-nums; font-weight: 700; }
.chapter-index .extra a { grid-template-columns: 1fr auto; }

.chapter, .supplement { padding-block: 1.5rem 1.85rem; border-top: 1px solid var(--line); }
.chapter > header, .supplement > h2 { margin-bottom: .95rem; }
.chapter > header .eyebrow { margin-bottom: .38rem; }
.box { background: var(--paper); border: 1px solid var(--line); border-radius: 1.05rem; padding: clamp(.85rem, 3vw, 1.5rem); min-width: 0; }
.box > * + * { margin-top: .8rem; }
.box > .eyebrow + h3 { margin-top: .3rem; }
.app-view { margin-top: .8rem; background: var(--sage); border-color: #ced7c5; }
.app-view > h3:first-child, .app-view > h2:first-child { margin-top: 0; }
.app-view h2 { font-size: clamp(1.6rem, 5vw, 2.25rem); }
.app-view ul, .app-view ol, .supplement ul, .supplement ol { padding-inline-start: 1.35em; }
.app-view li + li, .supplement li + li { margin-top: .27rem; }
.chapter-navigation { display: flex; justify-content: space-between; align-items: start; flex-wrap: wrap; gap: .25rem 1rem; margin-top: .45rem; }
.chapter-navigation a, footer a { display: inline-flex; align-items: center; min-height: 2.75rem; }
.art img, .reader-illustration img { width: 100%; aspect-ratio: 2.25; object-fit: cover; border-radius: .68rem; }
.art figcaption, .reader-illustration figcaption { margin-top: .36rem; color: var(--muted); line-height: 1.4; font-size: .9rem; }

.cards { display: grid; gap: .52rem; }
.cards > div, .chips > li, .steps > li { background: var(--soft); border: 1px solid #e5d9c8; border-radius: .66rem; padding: .65rem .72rem; }
.cards dt { font-weight: 750; line-height: 1.3; }
.cards dd { margin: .18rem 0 0; }
.cards.sequence > div { border-inline-start: .2rem solid #b66d4b; }
.cards.ladder > div { display: grid; grid-template-columns: 3rem 1fr; gap: .55rem; align-items: baseline; }
.cards.ladder dd { margin: 0; }
.cards.ladder dt { color: var(--accent); }
.chips { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 9rem), 1fr)); gap: .45rem; padding: 0; list-style: none; }
.chips li { align-content: center; font-weight: 620; line-height: 1.35; }
.note { padding: .7rem .8rem; background: var(--sage); border-inline-start: 3px solid #829379; border-radius: .3rem .65rem .65rem .3rem; }
.note p + p { margin-top: .25rem; }
.steps { display: grid; gap: .48rem; list-style-position: inside; padding: 0; }
.steps li::marker { color: var(--accent); font-weight: 750; }
.loop li + li { position: relative; }
.loop li + li::before {
  content: "↓";
  position: absolute;
  color: var(--accent);
  right: 1rem;
  top: -.9rem;
  font-weight: 750;
}
.senses > li { background: var(--sage); border-color: #d8dfd1; }

fieldset { min-inline-size: 0; border: 0; padding: 0; }
fieldset legend { padding: 0; font-weight: 750; }
.question { border: 1px solid var(--line); border-radius: .75rem; padding: .75rem; }
.question legend { padding-inline: .25rem; color: var(--accent); font-size: .88rem; }
.choices, .rating { display: grid; gap: .45rem; margin-top: .55rem; }
.choices { grid-template-columns: repeat(2, 1fr); }
.rating { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.choices label, .rating label, .checklist label { cursor: pointer; }
.choices label, .rating label { position: relative; }
.choices input, .rating input { position: absolute; inline-size: 100%; block-size: 100%; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
.choices span, .rating span {
  width: 100%;
  display: grid;
  place-items: center;
  min-height: 2.75rem;
  background: var(--paper);
  border: 1px solid #898e7a;
  border-radius: .58rem;
  font-weight: 700;
}
.choices input:checked + span, .rating input:checked + span { background: var(--green); color: white; border-color: var(--green); }
.choices input:focus-visible + span, .rating input:focus-visible + span { outline: 3px solid var(--accent); outline-offset: 2px; }
.scale-endpoints { display: flex; justify-content: space-between; gap: .4rem; margin-top: .3rem; color: var(--muted); font-size: .8rem; }
.body-map { display: grid; grid-template-columns: minmax(4rem, .6fr) minmax(0, 1fr); align-items: center; gap: .6rem; }
.body-map svg { width: 100%; max-height: 13rem; }
.checklist label { display: flex; align-items: center; gap: .4rem; min-height: 2.75rem; line-height: 1.28; }
.checklist input { flex: none; width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--green); }

.box details { background: var(--paper); border: 1px solid var(--line); border-radius: .7rem; padding-inline: .75rem; }
.box details + details { margin-top: .45rem; }
.box summary { min-height: 2.75rem; padding-block: .65rem; font-weight: 700; line-height: 1.35; }
.box details[open] { padding-bottom: .7rem; }
.box details > :not(summary) + :not(summary),
.box :is(.story-worksheet, .medical-help, .panic-card) > * + * { margin-top: .6rem; }
.story-field { display: grid; gap: .25rem; font-weight: 650; }
.story-field + .story-field { margin-top: .7rem; }
.story-field textarea {
  width: 100%;
  min-height: 4rem;
  padding: .52rem .64rem;
  background: var(--paper);
  border: 1px solid #a49d8d;
  border-radius: .52rem;
  resize: vertical;
  font-weight: 400;
  line-height: 1.45;
}
.story-field textarea::placeholder { color: var(--muted); opacity: 1; }
.anxiety-diary-day[open] > div { margin-top: .35rem; }
.grounding-steps, .grounding-senses { list-style: none; }
.grounding-steps li { display: flex; gap: .7rem; }
.grounding-steps li > span { display: grid; place-items: center; align-self: start; flex: 0 0 2rem; aspect-ratio: 1; border-radius: 50%; background: var(--green); color: white; font-weight: 700; }
.grounding-controls { display: flex; gap: .65rem; flex-wrap: wrap; }
.grounding-controls button { min-height: 2.75rem; padding: .45rem .85rem; border: 1px solid var(--line); border-radius: 1.7rem; opacity: .65; }
.grounding-senses li { padding: .55rem .65rem; border-radius: .45rem; background: var(--sage); }
.breath-card { padding: .75rem; background: var(--sage); border-radius: .65rem; }
.breath-card svg { margin: .65rem auto; }
.box [hidden] { display: none; }
.box :is(input, textarea, select) { max-width: 100%; }
.supplement .box a { font-weight: 650; }
.supplement .box :is(.lesson-label, .eyebrow) { font-size: .76rem; }
.footer { border-top: 1px solid var(--line); padding-block: 1rem max(1rem, env(safe-area-inset-bottom)); }
.footer .shell { display: flex; justify-content: space-between; gap: .35rem 1rem; flex-wrap: wrap; }

@media (min-width: 36rem) {
  .compare { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .rating { grid-template-columns: repeat(10, minmax(0, 1fr)); }
  .hero-cards { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .hero-cards a { grid-template-columns: 1fr auto; padding: .35rem .35rem .55rem; gap: .55rem; }
  .hero-cards .art { grid-column: 1 / -1; }
  .hero-cards a > span:not(:last-child) { padding-inline-start: .25rem; }
  .hero-cards a > span:last-child { padding-inline-end: .25rem; }
}
@media (max-width: 22rem) {
  .body-map { grid-template-columns: 1fr; }
  .body-map svg { max-height: 8rem; }
}

.box :is(.factor-reflection, .avoidance-message, .iceberg-surface, dl:not(.cards), .thought-steps) {
  background: var(--paper);
  border-radius: .65rem;
  padding: .7rem .8rem;
}
.box :is(.factor-reflection, .avoidance-message, .iceberg-surface) > * + * { margin-top: .3rem; }
.box dl:not(.cards) dt, .preview-label { font-weight: 700; }
.box dl:not(.cards) dd { margin: .12rem 0 .5rem; }
.box dl:not(.cards) dd:last-child { margin-bottom: 0; }
.preview-note, .story-hint { color: var(--muted); font-size: .9rem; }
blockquote.story-hint { margin-inline: 0; padding-inline-start: .6rem; border-inline-start: 2px solid #829379; }
.checklist label > span > strong, .checklist label > span > span { display: block; }
.checklist label > span > span { color: var(--muted); font-size: .9rem; }
.checkrow {
  display: flex;
  align-items: center;
  gap: .55rem;
  min-height: 2.75rem;
  padding: .45rem .6rem;
  border: 1px solid #ced7c5;
  border-radius: .55rem;
  background: var(--paper);
  cursor: pointer;
}
.checkrow input { flex: none; width: 1.1rem; height: 1.1rem; margin: 0; accent-color: var(--green); }
.checkrow + .checkrow { margin-top: .4rem; }
.rating-list, .coping-links { display: grid; gap: .45rem; }
.rating-list label {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .6rem;
  background: var(--paper);
  border: 1px solid #ced7c5;
  border-radius: .55rem;
  padding: .35rem .6rem;
  line-height: 1.3;
}
.rating-list select {
  min-height: 2.75rem;
  padding-inline: .45rem;
  border: 1px solid #898e7a;
  border-radius: .42rem;
  background: var(--paper);
}
.coping-links { grid-template-columns: repeat(auto-fit, minmax(min(100%, 10.5rem), 1fr)); }
.coping-links > * { padding: .45rem .6rem; min-height: 2.75rem; border-radius: .5rem; background: var(--paper); display: flex; align-items: center; }
.coping-links a { font-weight: 700; }
.supplement .anxiety-flow-steps { display: grid; gap: .45rem; list-style-position: inside; padding-inline: 0; }
.anxiety-flow-steps li { background: var(--sage); border-radius: .55rem; padding: .55rem .7rem; }
.anxiety-flow-steps strong { font-weight: 750; }

.resume, .chapter-completion {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: .55rem .9rem;
}
.resume {
  justify-content: space-between;
  margin-top: 1rem;
  padding: .7rem .8rem;
  background: var(--sage);
  border: 1px solid #ced7c5;
  border-radius: .8rem;
  line-height: 1.35;
}
.resume-copy { flex: 1 1 9rem; }
.resume-copy p:first-child { font-size: .85rem; color: var(--muted); }
.resume-copy p:last-child { margin-top: .15rem; font-weight: 700; }
.resume a { white-space: nowrap; }
.chapter-completion { margin-top: .9rem; }
.chapter-completion-status { color: var(--green); font-size: .9rem; font-weight: 700; }
.chapter-count { color: var(--muted); font-size: .93rem; }
.chapter-check {
  display: grid;
  place-items: center;
  width: 1.5rem;
  height: 1.5rem;
  color: var(--green);
  background: var(--sage);
  border-radius: 50%;
}
.button-secondary { color: var(--green); background: transparent; }
.button-secondary:hover { color: var(--green); background: var(--sage); }
[hidden]:is(.resume, .chapter-completion, .chapter-check, .chapter-arrow, [data-done-label], .chapter-count) {
  display: none;
}

.body-map [data-body-point] { fill: #f9f4e9; stroke: var(--green); }
.body-map [data-body-point].selected { fill: #a45136; stroke: #fffaf3; r: 8; }
.body-map .checklist label { padding-block: .25rem; }
body .box .trap-list { display: grid; gap: .5rem; padding-inline: 0; list-style: none; }
.box .trap-list > li { margin: 0; }
.trap-body > * + * { margin-top: .5rem; }
.trap-choice { display: flex; align-items: center; min-height: 2.75rem; gap: .55rem; }
.trap-choice input { flex: none; inline-size: 1.15rem; block-size: 1.15rem; accent-color: var(--green); }
.factor-grid, .next-step-options { display: grid; gap: .5rem; }
.box :is(.factor-grid, .next-step-options) details + details { margin-top: 0; }
.next-step-options details[open] { border-color: var(--green); }
.next-step-options details:target { border-color: var(--accent); }
.next-step-options summary { font-size: 1rem; }
.avoidance-return { display: flex; align-items: center; gap: .5rem; padding: .6rem .7rem; background: var(--sage); border-radius: .55rem; font-weight: 650; }
.avoidance-return span { font-size: 1.4rem; line-height: 1; }
.app-view .avoidance-cycle {
  display: grid;
  gap: .55rem;
  list-style-position: inside;
  padding-inline-start: 0;
  margin: .65rem 0;
}
.avoidance-cycle li { padding: .6rem .7rem; background: var(--paper); border-radius: .55rem; }
.avoidance-cycle li span { display: block; }
.app-view article.story-worksheet { border-top: 1px solid #c4cdbd; margin-top: 1.3rem; padding-top: 1rem; }
.story-field :is(input, select) { width: 100%; min-height: 2.75rem; padding: .5rem; border: 1px solid #898e7a; border-radius: .45rem; background: var(--paper); }
.ladder-rungs, .ladder-fields, .gratitude-form, .story-comparison { display: grid; gap: .65rem; }
.ladder-rung { padding: .55rem; border: 1px solid var(--line); border-radius: .6rem; }
.ladder-rung legend { padding-inline: .35rem; }
.grounding-controls { margin-top: .8rem; }
.grounding-controls button { cursor: pointer; color: var(--green); background: var(--paper); opacity: 1; }
.grounding-controls button:disabled { opacity: .55; cursor: default; }
.grounding-step[hidden], .gratitude-form[hidden] { display: none !important; }
.box .grounding-steps { padding-inline: 0; }
.grounding-steps li > span.grounding-number { display: grid; flex: 0 0 2.75rem; aspect-ratio: auto; min-height: 3.2rem; border-radius: .65rem; padding: .2rem; }
.grounding-number svg { width: 1.15rem; margin-bottom: .2rem; }
.grounding-a11y { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
.grounding-step h4 { scroll-margin-top: 5.25rem; }
.breath-card { display: grid; gap: .45rem; align-content: start; }
.breath-card svg { width: min(100%, 11rem); aspect-ratio: 1; }
.breath-card polyline { fill: none; stroke: var(--green); stroke-width: 2; stroke-linejoin: round; }
.breath-origin { fill: none; stroke: var(--green); stroke-width: 2; }
.breath-dot { fill: var(--accent); transition: transform 0ms linear; }
.breath-key, .breath-phase { font-weight: 700; }
.breath-toggle { min-height: 2.75rem; padding: .45rem; color: var(--green); background: var(--paper); border: 1px solid var(--green); border-radius: .65rem; cursor: pointer; }
.storage-status:empty, .breath-phase:empty { margin: 0; }
.storage-status { font-weight: 650; color: var(--accent); }
@media (min-width: 38rem) {
  .story-comparison { grid-template-columns: 1fr 1fr; }
  .ladder-fields { grid-template-columns: 1fr minmax(8rem, .5fr); }
}
@media (prefers-reduced-motion: reduce) {
  .breath-dot { transition: none; }
}
