/* REIN — calm, spacious, clinical-adjacent. Cream + burnt-orange + charcoal (Infuse IG). */

:root {
  /* Matched to @theketaminelounge IG — warm cream + burnt-orange/rust + charcoal */
  --sage: #c0561f; /* primary (burnt orange) — buttons, accents, wordmark */
  --sage-deep: #9c4317; /* darker rust — hover */
  --sage-soft: #f7ecdf; /* soft cream tint — agree box */
  --gold: #c0561f; /* accent (same rust family) */
  --gold-deep: #9c4317;
  --ink: #211d19; /* charcoal — text + headings */
  --ink-soft: #6f655b; /* warm muted gray */
  --bg: #f4ecdd; /* warm cream paper */
  --card: #fffdf9; /* near-white warm card */
  --line: #e7dcc8; /* warm tan border */
  --user-bubble: #f1e6d3; /* soft tan — patient bubble */
  --rein-bubble: #fffdf9;
  --danger: #a82f25; /* clear red — distinct from brand orange, for crisis */
  --radius: 18px;
  --shadow: 0 10px 40px rgba(80, 50, 25, 0.1);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Manrope", ui-sans-serif, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

.screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---- brand ---- */
.brand { display: flex; flex-direction: column; gap: 2px; }
.brand .wordmark {
  font-family: "Archivo Black", sans-serif;
  font-weight: 400; letter-spacing: 0.06em; color: var(--sage); font-size: 22px;
  text-transform: uppercase;
}
.brand .tagline { font-size: 13px; color: var(--ink-soft); letter-spacing: 0.04em; }
.brand .role { font-size: 13px; color: var(--ink-soft); letter-spacing: 0.02em; }
.brand.small .wordmark { font-size: 17px; letter-spacing: 0.05em; }

/* ---- buttons ---- */
.primary {
  background: var(--sage); color: #fff; border: none; border-radius: 999px;
  padding: 13px 26px; font-size: 15px; font-weight: 600; cursor: pointer;
  transition: background 0.2s, opacity 0.2s;
}
.primary:hover { background: var(--sage-deep); }
.primary:disabled { opacity: 0.45; cursor: not-allowed; }
.ghost {
  background: transparent; border: 1px solid var(--line); color: var(--ink-soft);
  border-radius: 999px; padding: 9px 16px; font-size: 13px; cursor: pointer;
}
.ghost:hover { border-color: var(--sage); color: var(--sage-deep); }
.ghost:disabled { opacity: 0.4; cursor: not-allowed; }
.ghost.subtle { border-color: transparent; }

/* Static crisis affordance (not floating) */
.crisis-trigger {
  background: #fff; color: var(--danger); border: 1px solid #e8cfcb;
  border-radius: 999px; padding: 9px 18px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.crisis-trigger:hover { background: #fbf3f2; border-color: var(--danger); }
.crisis-bar {
  padding: 4px 22px 20px; background: var(--bg);
  display: flex; justify-content: center;
}
.crisis-bar .crisis-trigger { width: 100%; max-width: 340px; }
.crisis-link-consent { display: block; margin: 20px auto 0; }

/* ---- welcome ---- */
.welcome { align-items: center; justify-content: center; padding: 32px 24px; text-align: center; }
.welcome-inner { max-width: 460px; display: flex; flex-direction: column; align-items: center; }
.welcome-eyebrow {
  font-size: 14px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-soft);
  margin-bottom: 8px;
}
.welcome-wordmark {
  font-family: "Archivo Black", sans-serif; text-transform: uppercase;
  letter-spacing: 0.06em; color: var(--sage); font-size: 52px; line-height: 1;
}
.welcome-acronym {
  margin-top: 12px; font-size: 11.5px; font-weight: 600; letter-spacing: 0.14em;
  text-transform: uppercase; color: var(--sage);
}
.welcome-role {
  font-size: 15px; letter-spacing: 0.04em; color: var(--ink-soft); margin-top: 8px;
}
.welcome-sub { color: var(--ink); font-size: 17px; line-height: 1.6; margin: 22px 0 8px; }
.welcome-tagline { color: var(--sage); font-size: 16px; font-style: italic; font-weight: 600; margin: 0 0 22px; }
.welcome-note { color: var(--ink-soft); font-size: 14px; line-height: 1.6; margin: 0 auto 30px; max-width: 410px; }
.welcome .primary { padding: 15px 44px; font-size: 16px; }

/* ---- consent ---- */
.consent { align-items: center; justify-content: center; padding: 32px 20px; }
.consent .card {
  background: var(--card); max-width: 560px; width: 100%; border-radius: var(--radius);
  padding: 40px; box-shadow: var(--shadow); border: 1px solid var(--line);
}
.consent .brand { margin-bottom: 28px; }
.consent h1 { font-family: "Archivo Black", sans-serif; font-size: 26px; margin: 0 0 12px; font-weight: 400; letter-spacing: 0; }
.lede { color: var(--ink-soft); margin: 0 0 20px; line-height: 1.55; }
.consent-points { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 14px; }
.consent-points li {
  line-height: 1.5; font-size: 14.5px; color: var(--ink-soft);
  padding-left: 20px; position: relative;
}
.consent-points li::before {
  content: ""; position: absolute; left: 0; top: 9px;
  width: 7px; height: 7px; border-radius: 50%; background: var(--gold);
}
.consent-points strong { color: var(--ink); font-weight: 600; }

.agree {
  display: flex; gap: 12px; align-items: flex-start; background: var(--sage-soft);
  padding: 16px; border-radius: 12px; margin-bottom: 24px; font-size: 14px; line-height: 1.5;
  cursor: pointer;
}
.agree input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--sage); flex-shrink: 0; }
.consent .primary { width: 100%; }

/* ---- session code entry ---- */
.code-entry { margin: 4px 0 2px; }
.code-label { display: block; font-size: 13px; font-weight: 600; color: var(--ink); margin-bottom: 8px; }
.code-input {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px;
  font: inherit; font-size: 18px; letter-spacing: 0.08em; text-transform: uppercase;
  background: #fff; color: var(--ink); outline: none;
}
.code-input:focus { border-color: var(--sage); }
.code-hint { font-size: 12.5px; color: var(--ink-soft); margin: 8px 0 16px; line-height: 1.4; }

/* ---- session countdown ---- */
.countdown {
  font-variant-numeric: tabular-nums; font-weight: 700; font-size: 14px; color: var(--ink-soft);
  background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 12px;
}
.countdown.ending { color: var(--danger); border-color: #e8cfcb; background: #fbf3f2; }

/* ---- chat ---- */
.chat { max-width: 720px; margin: 0 auto; width: 100%; }
.chat-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 22px; border-bottom: 1px solid var(--line); background: var(--bg);
  position: sticky; top: 0; z-index: 10;
}
.header-actions { display: flex; gap: 8px; align-items: center; }
.header-actions .primary { padding: 9px 18px; font-size: 13px; }
.end-session-btn { text-transform: uppercase; letter-spacing: 0.06em; }

.messages {
  flex: 1; overflow-y: auto; padding: 28px 22px; display: flex; flex-direction: column; gap: 16px;
}
.msg {
  max-width: 80%; padding: 14px 18px; border-radius: 16px; line-height: 1.6;
  font-size: 15.5px; white-space: pre-wrap; word-wrap: break-word;
  animation: rise 0.3s ease;
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.from-rein {
  align-self: flex-start; background: var(--rein-bubble); border: 1px solid var(--line);
  border-bottom-left-radius: 5px; color: var(--ink);
}
.from-user {
  align-self: flex-end; background: var(--user-bubble); border-bottom-right-radius: 5px;
  color: var(--ink);
}
.typing { display: flex; gap: 5px; align-items: center; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%; background: var(--sage);
  opacity: 0.5; 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.25; } 30% { opacity: 0.9; } }

.composer {
  display: flex; gap: 10px; align-items: flex-end; padding: 16px 22px 12px;
  border-top: 1px solid var(--line); background: var(--bg);
}
.composer textarea {
  flex: 1; resize: none; border: 1px solid var(--line); border-radius: 16px;
  padding: 13px 16px; font: inherit; font-size: 15.5px; line-height: 1.5;
  background: #fff; color: var(--ink); max-height: 160px; outline: none;
}
.composer textarea:focus { border-color: var(--sage); }
.send { flex-shrink: 0; }
.mic-btn {
  flex-shrink: 0; width: 46px; height: 46px; border-radius: 50%;
  border: 1px solid var(--line); background: #fff; color: var(--sage);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}
.mic-btn:hover { border-color: var(--sage); background: #fff8f2; }
.mic-btn.recording { background: var(--danger); border-color: var(--danger); color: #fff; animation: micpulse 1.3s infinite; }
.mic-btn.busy { opacity: 0.5; cursor: default; }
@keyframes micpulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(168, 47, 37, 0.35); }
  50% { box-shadow: 0 0 0 8px rgba(168, 47, 37, 0); }
}

/* ---- modals ---- */
.modal {
  position: fixed; inset: 0; background: rgba(40, 50, 46, 0.45);
  display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 100;
}
.modal-card {
  background: #fff; border-radius: var(--radius); padding: 32px; max-width: 520px;
  width: 100%; box-shadow: var(--shadow); max-height: 90vh; overflow-y: auto;
}
.modal-card h2 { font-family: "Archivo Black", sans-serif; margin: 0 0 14px; font-size: 20px; font-weight: 400; }

.crisis-card { border-top: 4px solid var(--danger); }
.crisis-intro { color: var(--ink-soft); font-size: 14px; margin: 0 0 18px; }
.crisis-list { list-style: none; padding: 0; margin: 0 0 24px; display: grid; gap: 14px; }
.crisis-list li {
  background: #faf2f1; border-radius: 12px; padding: 14px 16px; line-height: 1.5; font-size: 14.5px;
}
.crisis-list strong { color: var(--danger); }
.crisis-card .primary { width: 100%; }

.summary-note { color: var(--ink-soft); font-size: 14px; line-height: 1.55; margin: 0 0 18px; }
.summary-loading { color: var(--sage-deep); font-size: 14px; padding: 20px 0; }
.summary-text {
  width: 100%; border: 1px solid var(--line); border-radius: 12px; padding: 16px;
  font: inherit; font-size: 15px; line-height: 1.6; resize: vertical; color: var(--ink); outline: none;
}
.summary-text:focus { border-color: var(--sage); }
.share-agree { margin: 18px 0; font-size: 13.5px; }
.summary-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: space-between; align-items: center; margin-top: 20px; }

/* ---- returning sign-in (consent screen) ---- */
.returning { margin-top: 18px; text-align: center; }
.linklike {
  background: none; border: none; color: var(--sage-deep); font: inherit; font-size: 13.5px;
  cursor: pointer; text-decoration: underline; text-underline-offset: 3px;
}
.signin-form { margin-top: 14px; display: flex; flex-direction: column; gap: 10px; text-align: left; }

/* ---- end-of-session options ---- */
.end-options { display: grid; gap: 18px; margin-top: 20px; }
.end-option {
  border: 1px solid var(--line); border-radius: 14px; padding: 16px 16px 18px;
  background: #fffefb; display: grid; gap: 10px;
}
.end-option-label {
  font-family: "Oswald", sans-serif; font-size: 13px; letter-spacing: 0.08em;
  text-transform: uppercase; color: var(--ink-soft);
}
.end-option-row { display: flex; gap: 10px; flex-wrap: wrap; }
.end-option input[type="email"],
.signin-form input[type="email"] {
  width: 100%; border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px;
  font: inherit; font-size: 14.5px; background: #fff; color: var(--ink); outline: none;
}
.end-option input[type="email"]:focus,
.signin-form input[type="email"]:focus { border-color: var(--sage); }
.share-agree { margin: 0; font-size: 13px; padding: 12px; }
.form-msg { margin: 2px 0 0; font-size: 13px; color: var(--sage-deep); min-height: 16px; line-height: 1.4; }
.idle-card { text-align: center; max-width: 380px; }
.idle-text { color: var(--ink-soft); font-size: 15px; line-height: 1.6; margin: 0 0 22px; }
.idle-card .primary { width: 100%; }
.danger-ghost { color: var(--danger); border-color: #e8cfcb; }
.danger-ghost:hover { background: #faf2f1; border-color: var(--danger); color: var(--danger); }

@media (max-width: 600px) {
  .consent .card { padding: 28px 22px; }
  .msg { max-width: 88%; }
  .header-actions .subtle { display: none; }
}

/* ---- "Add to home screen" pill (welcome) + iOS instructions ---- */
.install-pill {
  margin: 16px auto 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: transparent;
  border: 1.5px solid var(--line);
  color: var(--sage-deep);
  border-radius: 999px;
  padding: 10px 18px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.01em;
  cursor: pointer;
  transition: border-color 0.15s, color 0.15s, background 0.15s;
}
.install-pill:hover { border-color: var(--sage); color: var(--sage); background: var(--sage-soft); }
.install-pill svg { flex: none; }

.install-card { text-align: left; max-width: 420px; }
.install-card h2 { color: var(--ink); }
.install-lede { color: var(--ink-soft); font-size: 15px; line-height: 1.5; margin: 6px 0 18px; }
.install-steps {
  margin: 0 0 24px; padding-left: 22px; color: var(--ink);
  font-size: 15px; line-height: 1.7;
}
.install-steps li { margin-bottom: 10px; }
.install-steps strong { color: var(--sage-deep); }
.share-glyph {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 6px;
  background: var(--sage-soft); color: var(--sage-deep);
  vertical-align: middle; margin: 0 2px;
}

/* ---- Legal pages (Terms / Privacy) ---- */
.legal-page {
  max-width: 760px; margin: 0 auto; padding: 32px 22px 80px;
}
.legal-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding-bottom: 18px; margin-bottom: 8px; border-bottom: 1px solid var(--line);
}
.legal-topbar .wordmark {
  font-family: "Archivo Black", system-ui, sans-serif; font-size: 22px;
  letter-spacing: 0.06em; color: var(--sage);
}
.legal-topbar .role { font-size: 12px; color: var(--ink-soft); letter-spacing: 0.02em; }
.legal-back { font-size: 14px; color: var(--sage-deep); text-decoration: none; font-weight: 600; }
.legal-back:hover { text-decoration: underline; }
.legal-draft {
  background: #fbf3ef; border: 1px solid #e8cfc4; color: var(--sage-deep);
  border-radius: 12px; padding: 12px 16px; font-size: 13px; line-height: 1.5; margin: 18px 0 6px;
}
.legal-page h1 {
  font-family: "Archivo Black", system-ui, sans-serif; color: var(--ink);
  font-size: 30px; margin: 20px 0 4px;
}
.legal-updated { color: var(--ink-soft); font-size: 13px; margin: 0 0 8px; }
.legal-page h2 {
  color: var(--ink); font-size: 18px; margin: 30px 0 8px;
  padding-top: 6px; border-top: 1px solid var(--line);
}
.legal-page p, .legal-page li { color: var(--ink); font-size: 15px; line-height: 1.65; }
.legal-page ul { padding-left: 20px; margin: 8px 0; }
.legal-page li { margin-bottom: 7px; }
.legal-page strong { color: var(--ink); }
.legal-page a { color: var(--sage-deep); }
.legal-footer {
  margin-top: 40px; padding-top: 16px; border-top: 1px solid var(--line);
  color: var(--ink-soft); font-size: 13px; line-height: 1.6;
}
.consent-legal {
  font-size: 13px; color: var(--ink-soft); line-height: 1.5; margin: 2px 0 14px; text-align: center;
}
.consent-legal a { color: var(--sage-deep); font-weight: 600; }
