/* MindBridge — calm, steady, low-arousal interface.
   Design intent: nothing jarring. Soft gradients, generous space, one clear
   focal point (the mic), and a safety net that is always visible. */

/* "Tactical Compassion" — warm, light, earthy. Forest green + cream. */
:root {
  --bg-0: #f4f1e8;   /* warm cream paper */
  --bg-1: #eef1e7;
  --bg-2: #e8efe4;
  --teal: #3a5a40;        /* forest green — primary accent (name kept for reuse) */
  --teal-deep: #2c4632;   /* deep pine */
  --sand: #b06a2c;        /* warm ochre highlight */
  --ink: #1f2c25;         /* dark green-black text */
  --ink-soft: #556157;
  --ink-faint: #8b978c;
  --user-bubble: #dde7d5;  /* soft sage — the veteran's bubble */
  --bot-bubble: #ffffff;   /* white companion bubble */
  --danger: #b23a48;
  --danger-deep: #8f2f3b;
  --card: #ffffff;
  --card-line: rgba(31, 44, 37, 0.12);
  --on-accent: #f6f3ea;   /* text/icon on a forest-green fill */
  --radius: 18px;
  --shadow: 0 14px 40px rgba(40, 55, 45, 0.14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, "Georgia", serif;
  --font-mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
}

/* Tactical Compassion typography: serif display headings, mono small-caps labels */
.brand-name, .welcome h1, .crisis-card__title, .res-drawer__title, .bc-h1, .bc-brand { font-family: var(--font-display); letter-spacing: 0; }
.badge, .bc-eyebrow, .bc-section-label, .res-cat, .bc-block__tag, .bc-track__code, .msg__who, .mic__label { font-family: var(--font-mono); }

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  font-family: var(--font);
  color: var(--ink);
  background:
    radial-gradient(1200px 800px at 20% -10%, var(--bg-1), transparent 60%),
    radial-gradient(1000px 700px at 90% 110%, var(--bg-2), transparent 55%),
    linear-gradient(160deg, var(--bg-0), #e7e2d4);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

.skip-link {
  position: absolute; left: -999px; top: 0; z-index: 100;
  background: var(--teal); color: var(--on-accent); padding: 10px 16px; border-radius: 0 0 12px 0;
}
.skip-link:focus { left: 0; }

/* ---------- Top bar ---------- */
.topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px clamp(16px, 4vw, 40px);
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 26px; height: 26px; border-radius: 8px;
  background: conic-gradient(from 140deg, var(--teal), var(--sand), var(--teal-deep), var(--teal));
  box-shadow: 0 0 22px rgba(58, 90, 64, 0.5);
}
.brand-name { font-weight: 650; letter-spacing: 0.2px; font-size: 1.1rem; }
.topbar-right { display: flex; align-items: center; gap: 12px; }

.badge {
  font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em;
  padding: 4px 10px; border-radius: 999px; border: 1px solid var(--card-line);
  color: var(--ink-soft);
}
.badge--demo { background: rgba(244, 228, 193, 0.08); color: var(--sand); }
.badge--live { background: rgba(58, 90, 64, 0.12); color: var(--teal); border-color: rgba(79,209,197,0.4); }

.icon-btn {
  background: var(--card); border: 1px solid var(--card-line); color: var(--ink);
  width: 40px; height: 40px; border-radius: 12px; cursor: pointer; font-size: 1rem;
}
.icon-btn__off { display: none; }
.icon-btn[aria-pressed="true"] .icon-btn__on { display: none; }
.icon-btn[aria-pressed="true"] .icon-btn__off { display: inline; }

/* ---------- Stage ---------- */
.stage {
  flex: 1; display: flex; flex-direction: column;
  width: min(760px, 100%); margin: 0 auto; padding: 0 clamp(14px, 4vw, 24px) 12px;
}

.transcript {
  flex: 1; overflow-y: auto; padding: 8px 2px 16px;
  display: flex; flex-direction: column; gap: 14px; scroll-behavior: smooth;
}

/* Welcome / empty state */
.welcome { text-align: center; margin: auto 0; padding: 24px 8px; }
.welcome h1 { font-size: clamp(1.5rem, 4.5vw, 2.15rem); line-height: 1.2; margin: 8px 0 10px; font-weight: 650; }
.welcome-sub { color: var(--ink-soft); max-width: 46ch; margin: 0 auto 22px; line-height: 1.55; }
.orb-halo {
  width: 120px; height: 120px; margin: 0 auto 6px; border-radius: 50%;
  background: radial-gradient(circle at 50% 45%, rgba(79,209,197,0.5), rgba(79,209,197,0.05) 65%, transparent 72%);
  animation: breathe 6s ease-in-out infinite;
}
@keyframes breathe { 0%,100% { transform: scale(1); opacity: 0.85; } 50% { transform: scale(1.08); opacity: 1; } }

.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip {
  background: var(--card); border: 1px solid var(--card-line); color: var(--ink-soft);
  padding: 10px 14px; border-radius: 999px; cursor: pointer; font-size: 0.9rem;
  transition: border-color 0.2s, color 0.2s, transform 0.1s; font-family: inherit;
}
.chip:hover { border-color: var(--teal); color: var(--ink); transform: translateY(-1px); }

/* Message bubbles */
.msg { display: flex; flex-direction: column; max-width: 84%; animation: rise 0.25s ease; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg--user { align-self: flex-end; align-items: flex-end; }
.msg--bot { align-self: flex-start; align-items: flex-start; }
.msg__who { font-size: 0.72rem; color: var(--ink-faint); margin: 0 6px 4px; }
.bubble { padding: 12px 16px; border-radius: 16px; line-height: 1.5; white-space: pre-wrap; }
.msg--user .bubble { background: var(--user-bubble); border-top-right-radius: 5px; }
.msg--bot .bubble { background: var(--bot-bubble); border: 1px solid var(--card-line); border-top-left-radius: 5px; }
.msg__sources { font-size: 0.72rem; color: var(--ink-faint); margin: 6px 6px 0; }

/* Resource cards under a bot message */
.resources { display: flex; flex-direction: column; gap: 8px; margin: 10px 4px 0; width: 100%; }
.res-card {
  background: var(--card); border: 1px solid var(--card-line); border-radius: 14px;
  padding: 12px 14px; display: flex; flex-direction: column; gap: 3px;
}
.res-card__name { font-weight: 600; font-size: 0.95rem; }
.res-card__desc { color: var(--ink-soft); font-size: 0.85rem; line-height: 1.45; }
.res-card__meta { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 4px; font-size: 0.83rem; }
.res-card__meta a { color: var(--teal); text-decoration: none; }
.res-card__meta a:hover { text-decoration: underline; }
.res-card__addr { color: var(--ink-faint); font-size: 0.8rem; }

/* Typing indicator */
.typing { display: inline-flex; gap: 5px; padding: 14px 16px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-faint); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%,60%,100% { opacity: 0.3; } 30% { opacity: 1; } }

/* Interim speech text */
.interim { text-align: center; color: var(--teal); min-height: 20px; font-style: italic; opacity: 0; transition: opacity 0.2s; }
.interim.show { opacity: 1; }

/* ---------- Mic ---------- */
.mic-wrap { display: flex; justify-content: center; padding: 6px 0 12px; }
.mic {
  position: relative; width: 92px; height: 92px; border-radius: 50%; cursor: pointer;
  border: none; color: var(--on-accent); font-family: inherit;
  background: radial-gradient(circle at 50% 40%, var(--teal), var(--teal-deep));
  box-shadow: 0 10px 34px rgba(58, 90, 64, 0.4);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  transition: transform 0.12s;
}
.mic:hover { transform: translateY(-2px); }
.mic:active { transform: scale(0.97); }
.mic__icon { font-size: 1.5rem; }
.mic__label { font-size: 0.66rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em; }
.mic__ring {
  position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--teal); opacity: 0;
}
.mic.listening { background: radial-gradient(circle at 50% 40%, #ff9d7a, #e0603a); box-shadow: 0 10px 40px rgba(224, 96, 58, 0.5); }
.mic.listening .mic__ring { animation: pulse-ring 1.4s ease-out infinite; opacity: 1; }
@keyframes pulse-ring { 0% { transform: scale(1); opacity: 0.7; } 100% { transform: scale(1.5); opacity: 0; } }
.mic[disabled] { opacity: 0.4; cursor: not-allowed; }

/* ---------- Composer ---------- */
.composer { display: flex; gap: 10px; padding: 4px 0 8px; }
.composer__input {
  flex: 1; background: var(--card); border: 1px solid var(--card-line); color: var(--ink);
  border-radius: 14px; padding: 14px 16px; font-size: 1rem; font-family: inherit;
}
.composer__input::placeholder { color: var(--ink-faint); }
.composer__input:focus { outline: none; border-color: var(--teal); }
.composer__send {
  background: var(--teal); color: var(--on-accent); border: none; border-radius: 14px;
  padding: 0 22px; font-weight: 700; cursor: pointer; font-family: inherit; font-size: 0.95rem;
}
.composer__send:hover { background: #5fe0d4; }

/* ---------- Safety footer ---------- */
.safety-footer {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px;
  padding: 12px 16px; font-size: 0.82rem; color: var(--ink-faint);
  border-top: 1px solid var(--card-line); text-align: center;
}
.safety-footer__cta strong { color: var(--sand); }

/* ---------- Crisis overlay ---------- */
.crisis-overlay {
  position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center;
  background: rgba(6, 12, 16, 0.82); backdrop-filter: blur(6px); padding: 20px;
  animation: fade 0.25s ease;
}
/* The [hidden] attribute must win over display:flex above. */
.crisis-overlay[hidden] { display: none; }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.crisis-card {
  width: min(520px, 100%); background: #fffdf8;
  border: 1px solid rgba(178, 58, 72, 0.35); border-radius: 22px; padding: 26px;
  box-shadow: var(--shadow); border-top: 4px solid var(--danger);
}
.crisis-card__title { margin: 0 0 12px; font-size: 1.4rem; }
.crisis-card__body { color: var(--ink-soft); line-height: 1.6; font-size: 0.95rem; }
.crisis-card__body strong { color: var(--ink); }
.crisis-card__body a { color: var(--teal); }
.crisis-card__actions { display: flex; flex-wrap: wrap; gap: 12px; margin: 20px 0 8px; }
.btn { padding: 14px 20px; border-radius: 14px; font-weight: 700; text-decoration: none; text-align: center; flex: 1; min-width: 160px; }
.btn--primary { background: var(--danger); color: #fff; box-shadow: 0 8px 24px rgba(255, 107, 107, 0.35); }
.btn--ghost { background: transparent; border: 1px solid var(--card-line); color: var(--ink); }
.crisis-card__resources { margin-top: 8px; display: flex; flex-direction: column; gap: 8px; }
.crisis-card__resources .res-card { background: rgba(255,255,255,0.05); }
.crisis-card__close {
  margin-top: 18px; width: 100%; background: transparent; border: 1px solid var(--card-line);
  color: var(--ink-soft); padding: 12px; border-radius: 12px; cursor: pointer; font-family: inherit;
}

/* Clear, high-contrast keyboard focus for every interactive control. */
.chip:focus-visible,
.mic:focus-visible,
.icon-btn:focus-visible,
.btn:focus-visible,
.composer__send:focus-visible,
.crisis-card__close:focus-visible,
.res-card__meta a:focus-visible {
  outline: 3px solid var(--sand);
  outline-offset: 2px;
}
.composer__input:focus-visible {
  outline: none;
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(58, 90, 64, 0.35);
}

/* ---------- Basecamp SF (routine engine) ---------- */
.basecamp-view {
  position: fixed; inset: 0; z-index: 69; overflow-y: auto;
  background-color: #f4f1e8; /* opaque cream base so the app behind never bleeds through */
  background-image:
    radial-gradient(900px 600px at 85% -10%, rgba(58,90,64,0.10), transparent 60%),
    linear-gradient(160deg, #f5f2ea, #e9e4d6);
  animation: fade 0.25s ease;
}
.basecamp-view[hidden] { display: none; }
.bc-wrap { width: min(820px, 100%); margin: 0 auto; padding: 20px clamp(14px, 4vw, 26px) 96px; }
.bc-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.bc-brand { display: flex; align-items: center; gap: 10px; font-weight: 650; }
.bc-brand small { color: var(--ink-faint); font-weight: 400; }
.bc-eyebrow { color: var(--teal); font-size: 0.74rem; letter-spacing: 0.12em; text-transform: uppercase; font-weight: 700; }
.bc-h1 { font-size: clamp(1.4rem, 4vw, 1.9rem); font-weight: 650; margin: 4px 0 4px; }
.bc-sub { color: var(--ink-soft); line-height: 1.5; margin-bottom: 18px; }

/* onboarding track cards */
.bc-tracks { display: grid; gap: 12px; }
.bc-track {
  text-align: left; background: var(--card); border: 1px solid var(--card-line); color: var(--ink);
  border-radius: 16px; padding: 16px 18px; cursor: pointer; font-family: inherit;
  transition: border-color 0.2s, transform 0.1s;
}
.bc-track:hover { border-color: var(--teal); transform: translateY(-1px); }
.bc-track__code { color: var(--teal); font-weight: 700; font-size: 0.8rem; letter-spacing: 0.06em; }
.bc-track__name { font-size: 1.05rem; font-weight: 600; margin: 3px 0; }
.bc-track__focus { color: var(--ink-soft); font-size: 0.9rem; line-height: 1.4; }

/* freedom gauge */
.bc-gauge { background: var(--card); border: 1px solid var(--card-line); border-radius: 16px; padding: 16px 18px; margin-bottom: 16px; }
.bc-gauge__row { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.bc-gauge__phase { font-size: 1.05rem; font-weight: 650; }
.bc-gauge__phase b { color: var(--teal); }
.bc-gauge__pct { color: var(--sand); font-weight: 700; }
.bc-gauge__bar { height: 10px; background: rgba(31,44,37,0.10); border-radius: 999px; margin: 10px 0 6px; overflow: hidden; }
.bc-gauge__fill { height: 100%; background: linear-gradient(90deg, var(--teal-deep), var(--teal)); border-radius: 999px; transition: width 0.6s ease; }
.bc-gauge__hint { color: var(--ink-faint); font-size: 0.82rem; }

/* opord blocks */
.bc-section-label { color: var(--ink-faint); font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.08em; margin: 6px 2px 10px; }
.bc-block {
  display: flex; gap: 14px; background: var(--card); border: 1px solid var(--card-line);
  border-radius: 14px; padding: 13px 15px; margin-bottom: 10px; align-items: flex-start;
}
.bc-block__time { color: var(--ink); font-weight: 700; font-variant-numeric: tabular-nums; min-width: 52px; }
.bc-block__body { flex: 1; }
.bc-block__title { font-weight: 600; }
.bc-block__tag { font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--teal); font-weight: 700; }
.bc-block__detail { color: var(--ink-soft); font-size: 0.9rem; margin-top: 3px; line-height: 1.4; }
.bc-block__confirm {
  background: var(--teal); color: var(--on-accent); border: none; border-radius: 10px; padding: 8px 14px;
  font-weight: 700; cursor: pointer; font-family: inherit; font-size: 0.82rem; white-space: nowrap;
}
.bc-block__confirm:hover { background: #5fe0d4; }
.bc-block.done { opacity: 0.55; }
.bc-block.done .bc-block__confirm { background: transparent; border: 1px solid var(--card-line); color: var(--ink-soft); cursor: default; }
.bc-block.locked { opacity: 0.5; }
.bc-block.locked .bc-block__confirm { background: transparent; border: 1px solid var(--card-line); color: var(--ink-faint); cursor: not-allowed; }
.bc-block--asymmetric { border-color: rgba(244,228,193,0.3); }
.bc-block--civic { border-color: rgba(79,209,197,0.4); }
.bc-menu { margin-top: 10px; display: grid; gap: 8px; }
.bc-menu__opt { text-align: left; background: rgba(31,44,37,0.03); border: 1px solid var(--card-line); color: var(--ink); border-radius: 10px; padding: 9px 12px; cursor: pointer; font-family: inherit; }
.bc-menu__opt:hover { border-color: var(--teal); }
.bc-menu__opt b { display: block; font-size: 0.9rem; }
.bc-menu__opt span { color: var(--ink-soft); font-size: 0.82rem; }
.bc-menu__opt.chosen { border-color: var(--teal); background: rgba(79,209,197,0.08); }

.bc-actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 14px 0; }
.bc-btn { background: var(--teal); color: var(--on-accent); border: none; border-radius: 12px; padding: 12px 18px; font-weight: 700; cursor: pointer; font-family: inherit; }
.bc-btn--ghost { background: transparent; border: 1px solid var(--card-line); color: var(--ink); }

/* sitrep modal */
.bc-sitrep { position: fixed; inset: 0; z-index: 72; display: flex; align-items: center; justify-content: center; background: rgba(6,12,16,0.82); backdrop-filter: blur(6px); padding: 20px; animation: fade 0.2s ease; }
.bc-sitrep[hidden] { display: none; }
.bc-sitrep__card { width: min(500px,100%); max-height: 90vh; overflow-y: auto; background: #fffdf8; border: 1px solid var(--card-line); border-radius: 20px; padding: 22px; box-shadow: var(--shadow); }
.bc-field { margin: 12px 0; }
.bc-field__label { font-weight: 600; font-size: 0.9rem; margin-bottom: 7px; }
.bc-field__opts { display: flex; gap: 7px; flex-wrap: wrap; }
.bc-chip { background: var(--card); border: 1px solid var(--card-line); color: var(--ink-soft); border-radius: 999px; padding: 7px 12px; cursor: pointer; font-family: inherit; font-size: 0.82rem; }
.bc-chip.sel { border-color: var(--teal); color: var(--ink); background: rgba(79,209,197,0.1); }
.bc-sitrep textarea { width: 100%; background: var(--card); border: 1px solid var(--card-line); color: var(--ink); border-radius: 12px; padding: 12px; font-family: inherit; font-size: 0.95rem; resize: vertical; min-height: 70px; }
.bc-sitrep__reply { background: var(--bot-bubble); border: 1px solid var(--card-line); border-radius: 12px; padding: 13px 15px; margin-top: 12px; line-height: 1.5; }

/* bottom tab nav */
.bc-nav { position: fixed; left: 50%; transform: translateX(-50%); bottom: 0; width: min(820px, 100%); display: flex; background: rgba(250, 248, 242, 0.95); backdrop-filter: blur(8px); border-top: 1px solid var(--card-line); z-index: 3; }
.bc-nav[hidden] { display: none; }
.bc-nav__tab { flex: 1; background: transparent; border: none; padding: 9px 4px 13px; cursor: pointer; font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.05em; text-transform: uppercase; color: var(--ink-faint); display: flex; flex-direction: column; align-items: center; gap: 3px; }
.bc-nav__ico { font-size: 1.1rem; }
.bc-nav__tab.active { color: var(--teal); }

/* mission cards */
.bc-mission { background: var(--card); border: 1px solid var(--card-line); border-radius: 16px; overflow: hidden; margin-bottom: 12px; box-shadow: var(--shadow); }
.bc-mission__banner { height: 84px; display: flex; align-items: flex-end; padding: 10px 14px; color: #fff; font-family: var(--font-mono); font-size: 0.64rem; letter-spacing: 0.06em; text-transform: uppercase; text-shadow: 0 1px 3px rgba(0,0,0,0.4); }
.bc-mission__body { padding: 14px 16px; }
.bc-mission__title { font-size: 1.1rem; font-weight: 650; font-family: var(--font-display); }
.bc-mission__loc { color: var(--ink-soft); font-size: 0.78rem; font-family: var(--font-mono); }
.bc-mission__desc { color: var(--ink-soft); font-size: 0.9rem; line-height: 1.45; margin: 8px 0; }
.bc-mission__meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.bc-mission__lead { font-size: 0.8rem; color: var(--ink-soft); }
.bc-mission__lead b { color: var(--ink); }
.bc-mission__btn { background: var(--teal); color: var(--on-accent); border: none; border-radius: 10px; padding: 9px 16px; font-weight: 700; cursor: pointer; font-family: inherit; font-size: 0.83rem; }
.bc-mission__btn.waitlist { background: transparent; border: 1px solid var(--card-line); color: var(--ink-soft); cursor: default; }
.bc-mission__btn.joined { background: var(--teal-deep); }

/* reintegration track stepper */
.bc-stepper { display: flex; align-items: flex-start; gap: 4px; margin: 14px 0 6px; }
.bc-step { flex: 1; text-align: center; }
.bc-step__dot { width: 28px; height: 28px; border-radius: 50%; margin: 0 auto 6px; background: rgba(31,44,37,0.1); color: var(--ink-faint); display: flex; align-items: center; justify-content: center; font-family: var(--font-mono); font-size: 0.8rem; font-weight: 700; }
.bc-step.done .bc-step__dot { background: var(--teal); color: var(--on-accent); }
.bc-step.active .bc-step__dot { background: var(--teal); color: var(--on-accent); box-shadow: 0 0 0 4px rgba(58,90,64,0.18); }
.bc-step__label { font-size: 0.62rem; font-family: var(--font-mono); text-transform: uppercase; color: var(--ink-faint); line-height: 1.2; }
.bc-step.active .bc-step__label { color: var(--ink); }

/* habit-stability ring */
.bc-ring { display: flex; align-items: center; gap: 18px; margin: 6px 0 4px; }
.bc-ring__circle { width: 92px; height: 92px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-weight: 700; font-size: 1.3rem; color: var(--teal); flex-shrink: 0; }
.bc-ring__label { color: var(--ink-soft); font-size: 0.9rem; }

/* stand-down terminology map */
.bc-termrow { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--card-line); }
.bc-termrow:last-child { border-bottom: none; }
.bc-termrow__from { font-family: var(--font-mono); font-size: 0.78rem; color: var(--ink-faint); min-width: 120px; }
.bc-termrow__arrow { color: var(--teal); }
.bc-termrow__to { font-weight: 600; }

/* ---------- Resources drawer ---------- */
.pill-btn {
  background: rgba(58, 90, 64, 0.1); border: 1px solid var(--card-line); color: var(--ink-soft);
  padding: 7px 14px; border-radius: 999px; cursor: pointer; font-family: inherit; font-size: 0.85rem;
  transition: border-color 0.2s, color 0.2s;
}
.pill-btn:hover { border-color: var(--teal); color: var(--ink); }
.res-drawer {
  position: fixed; inset: 0; z-index: 65; display: flex; justify-content: flex-end;
  background: rgba(6, 12, 16, 0.7); backdrop-filter: blur(4px); animation: fade 0.25s ease;
}
.res-drawer[hidden] { display: none; }
.res-drawer__panel {
  width: min(460px, 100%); height: 100%; background: #fbfaf3;
  border-left: 1px solid var(--card-line); padding: 22px 22px 40px; overflow-y: auto;
  box-shadow: -20px 0 60px rgba(40, 55, 45, 0.18);
}
.res-drawer__head { display: flex; align-items: center; justify-content: space-between; }
.res-drawer__title { font-size: 1.3rem; font-weight: 650; color: var(--ink); }
.res-drawer__sub { color: var(--ink-soft); font-size: 0.9rem; margin: 6px 0 8px; line-height: 1.4; }
.res-cat { color: var(--teal); font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.09em; font-weight: 700; margin: 18px 0 8px; }
.res-drawer .res-card { margin-bottom: 8px; }
.res-close { background: transparent; border: 1px solid var(--card-line); color: var(--ink-soft); width: 36px; height: 36px; border-radius: 10px; cursor: pointer; font-size: 1rem; }
.res-close:hover { border-color: var(--teal); color: var(--ink); }

/* ---------- Grounding breath exercise ---------- */
.breathe-trigger {
  display: inline-flex; align-items: center; gap: 8px; margin: 10px auto 0;
  background: rgba(58, 90, 64, 0.08); border: 1px solid var(--card-line); color: var(--ink-soft);
  padding: 9px 16px; border-radius: 999px; cursor: pointer; font-family: inherit; font-size: 0.85rem;
  transition: border-color 0.2s, color 0.2s;
}
.breathe-trigger:hover { border-color: var(--teal); color: var(--ink); }
.breathe-overlay {
  position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 30px; padding: 24px;
  background: radial-gradient(circle at 50% 42%, #eef2e8, #dde5d4 72%); animation: fade 0.4s ease;
}
.breathe-overlay[hidden] { display: none; }
.breathe-circle {
  width: 190px; height: 190px; border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(58, 90, 64, 0.55), rgba(58, 90, 64, 0.06) 70%);
  border: 2px solid rgba(58, 90, 64, 0.45);
  display: flex; align-items: center; justify-content: center; text-align: center;
  animation: breathe-cycle 16s ease-in-out infinite;
}
@keyframes breathe-cycle {
  0% { transform: scale(1); } 25% { transform: scale(1.45); }
  50% { transform: scale(1.45); } 75% { transform: scale(1); } 100% { transform: scale(1); }
}
.breathe-phase { font-size: 1.45rem; font-weight: 650; color: var(--ink); }
.breathe-hint { color: var(--ink-soft); font-size: 0.95rem; max-width: 30ch; text-align: center; }
.breathe-done {
  background: transparent; border: 1px solid var(--card-line); color: var(--ink-soft);
  padding: 12px 26px; border-radius: 14px; cursor: pointer; font-family: inherit;
}
.breathe-done:hover { border-color: var(--teal); color: var(--ink); }

/* ---------- Wind-Down (guided evening routine) ---------- */
.winddown-overlay {
  position: fixed; inset: 0; z-index: 73; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 20px; padding: 30px; text-align: center;
  background: radial-gradient(circle at 50% 38%, #eef2e8, #dde5d4 72%); animation: fade 0.35s ease; overflow-y: auto;
}
.winddown-overlay[hidden] { display: none; }
.wd-dots { display: flex; gap: 6px; margin-bottom: 4px; }
.wd-dot { width: 7px; height: 7px; border-radius: 50%; background: rgba(31, 44, 37, 0.16); }
.wd-dot.on { background: var(--teal); }
.wd-title { font-family: var(--font-display); font-size: 1.7rem; font-weight: 650; color: var(--ink); }
.wd-body { color: var(--ink-soft); max-width: 34ch; line-height: 1.55; }
.wd-list { list-style: none; padding: 0; margin: 0; text-align: left; max-width: 36ch; display: grid; gap: 9px; }
.wd-list li { background: var(--card); border: 1px solid var(--card-line); border-radius: 12px; padding: 11px 14px; color: var(--ink); font-size: 0.95rem; }
.wd-chips { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.wd-chip { background: var(--card); border: 1px solid var(--card-line); color: var(--ink-soft); border-radius: 999px; padding: 8px 15px; cursor: pointer; font-family: inherit; }
.wd-chip.sel { border-color: var(--teal); color: var(--ink); background: rgba(58, 90, 64, 0.08); }
.wd-cta { background: var(--teal); color: var(--on-accent); border: none; border-radius: 14px; padding: 12px 26px; font-weight: 700; cursor: pointer; font-family: inherit; }
.wd-cta:hover { background: var(--teal-deep); }
.wd-skip { background: transparent; border: none; color: var(--ink-faint); cursor: pointer; font-family: inherit; font-size: 0.85rem; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
