/* Vida by Afshan: blush paper, mauve wordmark, rose-gold mark.
   Token names are shared with review.html, so keep them. */
:root {
  --bg: #fbf4f1;            /* blush paper */
  --bg-deep: #f6e7e2;       /* chat backdrop */
  --panel: #ffffff;
  --ink: #2b1d21;
  --muted: #7a6468;
  --line: #ecdcd6;
  --accent: #6e3a44;        /* mauve, from the wordmark */
  --accent-ink: #ffffff;
  --accent-soft: #f5e4e0;
  --rose: #b9735f;          /* rose gold, from the mark */
  --rose-soft: #f8e6df;
  --glow: rgba(201, 138, 120, 0.45);
  --user: #6e3a44;
  --user-ink: #ffffff;
  --crisis: #b42a22;
  --crisis-soft: #fbe9e7;
  --warn-soft: #f8e6df;
  --ok: #1f7a4d;
  --font-display: "Cormorant Garamond", Georgia, "Times New Roman", serif;
  --font-body: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color-scheme: light;   /* always light, even when the device is in dark mode */
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; font: 16px/1.5 var(--font-body); background: var(--bg); color: var(--ink); }
button { font: inherit; cursor: pointer; border-radius: 999px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 8px 16px; }
button:hover { border-color: var(--rose); }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
button:disabled { opacity: .5; cursor: default; }
:focus-visible { outline: 3px solid var(--rose); outline-offset: 2px; }

.app { max-width: 780px; margin: 0 auto; height: 100dvh; display: flex; flex-direction: column; background: var(--bg-deep); border-inline: 1px solid var(--line); }

/* header */
header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; background: var(--panel); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.brand { display: flex; align-items: center; gap: 10px; }
.brand img { width: 40px; height: 38px; }
.brand h1 { margin: 0; font-family: var(--font-display); font-weight: 500; font-size: 26px; letter-spacing: .22em; color: var(--accent); line-height: 1; }
.brand .sub { display: block; font-family: var(--font-display); font-size: 14px; letter-spacing: .16em; color: var(--muted); margin-top: 2px; }
header .actions { display: flex; gap: 6px; flex-wrap: wrap; }
header .actions button { padding: 6px 12px; font-size: 13px; background: transparent; }

.banner { font-size: 13px; padding: 8px 18px; background: var(--rose-soft); color: var(--ink); border-bottom: 1px solid var(--line); }

/* conversation */
#log { flex: 1; overflow-y: auto; padding: 20px 18px; display: flex; flex-direction: column; gap: 14px; }
.welcome { align-self: center; text-align: center; display: grid; justify-items: center; gap: 6px; padding: 12px 0 4px; }
.welcome img { width: 72px; height: 68px; }
.welcome p { margin: 0; font-family: var(--font-display); font-style: italic; font-size: 20px; color: var(--rose); }

.msg { max-width: 82%; padding: 11px 15px; border-radius: 20px; white-space: pre-wrap; overflow-wrap: anywhere; box-shadow: 0 6px 18px -14px rgba(110, 58, 68, .5); }
.msg.user { align-self: flex-end; background: var(--user); color: var(--user-ink); border-bottom-right-radius: 6px; }
.msg.assistant { align-self: flex-start; background: var(--panel); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.crisis, .msg.minor { border: 2px solid var(--crisis); background: var(--crisis-soft); }
.msg .who { display: flex; align-items: center; gap: 6px; font-size: 11px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); margin-bottom: 4px; }
.msg .who img { width: 16px; height: 15px; }
.msg.user .who { color: rgba(255, 255, 255, .8); }

/* thinking: the Vida mark breathes */
.thinking { align-self: flex-start; display: flex; align-items: center; gap: 12px; padding: 6px 4px; color: var(--muted); font-size: 14px; }
.breath { position: relative; width: 40px; height: 38px; display: grid; place-items: center; }
.breath::before { content: ""; position: absolute; inset: -10px; border-radius: 50%; background: radial-gradient(circle, var(--glow) 0%, transparent 68%); animation: glow 4.8s ease-in-out infinite; }
.breath img { position: relative; width: 100%; height: 100%; animation: breathe 4.8s ease-in-out infinite; }
.thinking .label { font-family: var(--font-display); font-style: italic; font-size: 17px; }
/* in for 2s, hold, out slowly: like the 4-4-6 breathing Vida teaches */
@keyframes breathe {
  0%   { transform: scale(.82); opacity: .6; }
  40%  { transform: scale(1.08); opacity: 1; }
  55%  { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(.82); opacity: .6; }
}
@keyframes glow {
  0%, 100% { transform: scale(.7); opacity: 0; }
  40%, 55% { transform: scale(1.15); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .breath img { animation: fade 3s ease-in-out infinite; }
  .breath::before { animation: none; opacity: .5; }
  @keyframes fade { 0%, 100% { opacity: .55; } 50% { opacity: 1; } }
}

/* composer */
form#composer { display: flex; gap: 10px; align-items: flex-end; padding: 12px 18px 16px; background: var(--panel); border-top: 1px solid var(--line); }
#input { flex: 1; resize: none; font: inherit; padding: 11px 16px; border-radius: 22px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); min-height: 46px; max-height: 160px; }
#input:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 3px var(--glow); }
#send { height: 46px; padding: 0 20px; }

/* human coaching card */
.coach-card { align-self: flex-start; max-width: 82%; padding: 14px 16px; border-radius: 18px; border: 1px solid var(--rose); background: var(--rose-soft); display: flex; flex-direction: column; gap: 6px; }
.coach-card-title { font-family: var(--font-display); font-weight: 700; font-size: 20px; color: var(--accent); }
.coach-card-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 4px; }

/* dialogs */
.modal-back { position: fixed; inset: 0; background: rgba(43, 29, 33, .5); display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 10; }
.modal { background: var(--panel); border-radius: 20px; max-width: 520px; width: 100%; padding: 24px; max-height: 90dvh; overflow-y: auto; }
.modal h2 { margin: 0 0 6px; font-family: var(--font-display); font-weight: 600; font-size: 28px; color: var(--accent); }
.modal .logo { display: block; width: 64px; height: 61px; margin-bottom: 8px; }
.modal label { display: flex; gap: 10px; align-items: flex-start; margin: 12px 0; }
.modal input[type=checkbox] { margin-top: 5px; accent-color: var(--accent); }
.modal .row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 18px; flex-wrap: wrap; }
.mem { display: flex; justify-content: space-between; gap: 8px; padding: 10px 0; border-bottom: 1px solid var(--line); }
.mem .kind { font-size: 12px; color: var(--muted); text-transform: capitalize; }
.hidden { display: none !important; }
.code-wrap { display: grid; gap: 6px; margin: 14px 0 4px; }
.code-label { font-weight: 600; font-size: 14px; }
#c-code, #fb-text { font: inherit; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); width: 100%; }
#fb-text { resize: vertical; margin-top: 10px; }
.form-error { color: var(--crisis); font-size: 14px; margin: 8px 0 0; }
.test-tag { font-weight: 600; color: var(--accent); }
.rate { display: flex; gap: 6px; align-items: center; margin-top: 8px; flex-wrap: wrap; }
.rate button { padding: 2px 10px; font-size: 13px; background: transparent; color: var(--muted); }
.rate button[aria-pressed="true"] { background: var(--accent-soft); color: var(--accent); border-color: var(--accent); }
.rate .why { display: flex; gap: 6px; width: 100%; margin-top: 4px; }
.rate .why input { flex: 1; min-width: 0; font: inherit; font-size: 13px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--line); background: var(--bg); color: var(--ink); }
.rate .thanks { font-size: 12px; color: var(--muted); }
.muted { color: var(--muted); font-size: 14px; }
.typing { align-self: flex-start; color: var(--muted); font-size: 14px; }

@media (max-width: 560px) {
  .app { border-inline: 0; }
  header { padding: 10px 14px; }
  #log { padding: 16px 12px; }
  .msg, .coach-card { max-width: 92%; }
  form#composer { padding: 10px 12px 12px; }
}
