:root {
  --bg: #fbfaf7;
  --surface: #ffffff;
  --ink: #1b1c1a;
  --muted: #6b7280;
  --line: #e8e6df;
  --green: #15803d;
  --green-700: #166534;
  --green-50: #ecfdf3;
  --user: #16a34a;
  --warn: #b45309;
  --radius: 16px;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* The hidden attribute must always win, even on elements whose class sets a
   display value (e.g. .paywall's display: grid would otherwise override it). */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
}

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

button { font-family: inherit; cursor: pointer; }

.primary {
  background: var(--green);
  color: #fff;
  border: 0;
  border-radius: 12px;
  padding: 14px 18px;
  font-size: 16px;
  font-weight: 600;
  width: 100%;
  transition: background 0.15s ease, transform 0.05s ease;
}
.primary:hover { background: var(--green-700); }
.primary:active { transform: translateY(1px); }
.primary:disabled { background: #9ca3af; cursor: not-allowed; }

/* ============ Auth page ============ */
.auth-body {
  display: grid;
  place-items: center;
  padding: 24px;
  min-height: 100dvh;
}
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 32px 26px;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand .logo { font-size: 34px; }
.brand h1 { margin: 0; font-size: 28px; letter-spacing: -0.02em; }
.tag { color: var(--muted); margin: 8px 0 12px; line-height: 1.4; }
.auth-lead { color: var(--ink); font-size: 14px; line-height: 1.5; margin: 0 0 20px; }
.auth-lead b { color: var(--ink); }
.auth-card label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  margin-bottom: 6px;
}
.auth-card input {
  width: 100%;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  font-size: 16px;
  margin-bottom: 14px;
  background: #fff;
}
.auth-card input:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-50);
}
.fineprint { color: var(--muted); font-size: 13px; line-height: 1.5; margin-top: 18px; }
.status { margin-top: 16px; padding: 12px 14px; border-radius: 12px; font-size: 14px; line-height: 1.45; }
.status.ok { background: var(--green-50); color: var(--green-700); }
.status.warn { background: #fff7ed; color: var(--warn); }
.devlink { display: inline-block; margin-top: 8px; font-weight: 700; color: var(--green-700); }

/* Signup consent + disclaimers */
.auth-card label.consent {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  font-size: 13px;
  font-weight: 400;
  color: var(--ink);
  line-height: 1.45;
  margin: 2px 0 16px;
  text-align: left;
  cursor: pointer;
}
.consent input[type="checkbox"] {
  width: auto;
  margin: 2px 0 0;
  padding: 0;
  flex: 0 0 auto;
}
.consent a { color: var(--green-700); }
.disclaimer { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin-top: 10px; }
.auth-footer { text-align: center; margin-top: 16px; font-size: 13px; }
.auth-footer a { color: var(--muted); text-decoration: none; }
.auth-footer a:hover { text-decoration: underline; }
.welcome-disclaimer { color: var(--muted); font-size: 12px; line-height: 1.5; margin: 0 0 20px; }

/* Legal pages (privacy / terms) */
.legal-body { background: var(--bg); color: var(--ink); }
.legal {
  max-width: 720px;
  margin: 0 auto;
  padding: 28px 22px calc(40px + var(--safe-bottom));
  line-height: 1.6;
}
.legal h1 { font-size: 26px; letter-spacing: -0.02em; margin: 8px 0 4px; }
.legal h2 { font-size: 18px; margin: 26px 0 6px; }
.legal p, .legal li { color: var(--ink); font-size: 15px; }
.legal ul { padding-left: 20px; margin: 6px 0; }
.legal li { margin: 4px 0; }
.legal a { color: var(--green-700); }
.legal-updated { color: var(--muted); font-size: 13px; margin: 0 0 18px; }
.legal-back { font-size: 14px; margin: 10px 0; }

/* ============ App layout ============ */
.app-body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}
.topbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  padding-top: calc(12px + env(safe-area-inset-top, 0px));
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 5;
}
.brand-sm { font-weight: 700; font-size: 18px; display: flex; align-items: center; gap: 6px; }
.brand-sm .logo { font-size: 20px; }
.totals-chip {
  margin-left: auto;
  background: var(--green-50);
  color: var(--green-700);
  border: 1px solid #d1fae0;
  border-radius: 999px;
  padding: 6px 12px;
  font-weight: 700;
  font-size: 14px;
}
.icon-btn {
  background: transparent;
  border: 0;
  font-size: 22px;
  line-height: 1;
  padding: 4px 8px;
  color: var(--muted);
  border-radius: 8px;
}
.icon-btn:hover { background: #f3f4f6; }

/* Notification bell + unread badge */
.bell-btn { position: relative; }
.bell-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  box-sizing: border-box;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 10px;
  font-weight: 800;
  line-height: 17px;
  text-align: center;
}

/* Feedback form (rendered inside the sheet) */
.fb { display: flex; flex-direction: column; gap: 12px; }
.fb-intro { color: var(--muted); font-size: 14px; line-height: 1.5; margin: 0; }
.fb-text {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  font: inherit;
  font-size: 15px;
  resize: vertical;
  min-height: 96px;
  color: var(--ink);
  background: var(--surface);
}
.fb-text:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-50); }
.fb-tools { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.fb-hint { color: var(--muted); font-size: 12.5px; }
.fb-thumbs { display: flex; flex-wrap: wrap; gap: 8px; }
.fb-thumb { position: relative; width: 72px; height: 72px; }
.fb-thumb img {
  width: 72px; height: 72px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line);
}
.fb-thumb-x {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; line-height: 18px;
  border-radius: 999px; border: 0; cursor: pointer;
  background: #1b1c1a; color: #fff; font-size: 11px; padding: 0;
}
.fb-actions { display: flex; align-items: center; gap: 12px; }
.fb-status { color: var(--muted); font-size: 13px; }
.fb-thanks { color: var(--green-700); font-size: 15px; line-height: 1.5; text-align: center; padding: 18px 0; }

/* "What's new" announcement list (rendered inside the sheet) */
.ann-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.ann-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.ann-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 4px; }
.ann-title { font-weight: 700; font-size: 15px; color: var(--ink); }
.ann-date { color: var(--muted); font-size: 12px; white-space: nowrap; }
.ann-body { color: var(--ink); font-size: 14px; line-height: 1.5; }
.ann-body p { margin: 0 0 6px; }
.ann-body p:last-child { margin-bottom: 0; }
.ann-see-all {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--green);
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.ann-see-all:hover { background: var(--green-50); }
.ann-all-head { font-weight: 700; font-size: 14px; color: var(--muted); margin-bottom: 12px; }

.menu {
  position: absolute;
  top: 56px;
  right: 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
  width: 240px;
  z-index: 10;
  overflow: hidden;
  padding: 6px;
}
.menu-account { padding: 12px 12px 10px; border-bottom: 1px solid var(--line); margin-bottom: 6px; }
.menu-account .email { font-weight: 600; font-size: 14px; word-break: break-all; }
.menu-account .sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.menu-action {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: 0;
  padding: 11px 12px;
  border-radius: 10px;
  font-size: 15px;
  color: var(--ink);
}
.menu-action:hover { background: #f3f4f6; }
.menu-action.danger { color: #b91c1c; }

/* ============ Chat ============ */
.chat {
  flex: 1;
  overflow-y: auto;
  padding: 18px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}
.welcome {
  margin: auto;
  text-align: center;
  max-width: 440px;
  padding: 24px 8px;
}
.welcome h2 { font-size: 24px; margin: 0 0 8px; letter-spacing: -0.02em; }
.welcome p { color: var(--muted); line-height: 1.55; margin: 0 0 20px; }
.welcome-note { color: var(--muted); font-size: 12.5px; line-height: 1.5; margin: 0 0 20px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; }

/* "New session" divider (memory window reset) */
.session-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 8px 6px 2px;
  color: var(--muted);
  font-size: 11.5px;
}
.session-divider::before, .session-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}
.session-divider span { white-space: nowrap; }
.chip {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 9px 14px;
  font-size: 14px;
  color: var(--ink);
  transition: border-color 0.15s, background 0.15s;
}
.chip:hover { border-color: var(--green); background: var(--green-50); }

.msg { display: flex; flex-direction: column; max-width: 86%; }
.msg.user { align-self: flex-end; align-items: flex-end; }
.msg.bot { align-self: flex-start; align-items: flex-start; }
.bubble {
  padding: 11px 14px;
  border-radius: 18px;
  line-height: 1.5;
  font-size: 15.5px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg.user .bubble {
  background: var(--user);
  color: #fff;
  border-bottom-right-radius: 6px;
}
.msg.bot .bubble {
  background: var(--surface);
  border: 1px solid var(--line);
  border-bottom-left-radius: 6px;
}
.bubble p { margin: 0 0 8px; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul { margin: 6px 0; padding-left: 20px; }
.bubble li { margin: 2px 0; }
.meta { font-size: 11px; color: var(--muted); margin-top: 4px; padding: 0 6px; }
.msg-time { font-size: 10.5px; color: #b3b1a9; margin-top: 3px; padding: 0 6px; }

/* Save-this-reply action under bot messages */
.msg-actions { margin-top: 4px; padding: 0 6px; }
.msg-save {
  background: none; border: none; color: var(--muted); font-size: 12px;
  cursor: pointer; padding: 2px 6px; border-radius: 6px;
}
.msg-save:hover { color: var(--green); background: var(--green-50); }
.msg-save:disabled { color: var(--green); background: none; cursor: default; }

/* Quick-add preset sheet */
.qp-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }

/* Saved replies sheet */
.saved-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.saved-item { border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px; background: var(--surface); }
.saved-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 6px; }
.saved-date { color: var(--muted); font-size: 12px; }
.saved-del { background: none; border: none; cursor: pointer; font-size: 15px; line-height: 1; padding: 2px 4px; opacity: 0.7; }
.saved-del:hover { opacity: 1; }
.saved-text { color: var(--ink); font-size: 14px; line-height: 1.5; }
.saved-text p { margin: 0 0 6px; }
.saved-text p:last-child { margin-bottom: 0; }
.saved-text ul { margin: 6px 0; padding-left: 20px; }

.typing { display: flex; gap: 4px; align-items: center; }
.typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #c7c7c2; display: inline-block;
  animation: blink 1.3s infinite both;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

/* ============ Composer ============ */
.composer {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  padding: 10px 12px calc(10px + var(--safe-bottom));
  background: var(--surface);
  border-top: 1px solid var(--line);
}
.attach-btn {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--surface);
  font-size: 20px;
  line-height: 1;
  color: var(--muted);
  cursor: pointer;
}
.attach-btn:hover { background: #f3f4f6; }
.attach-btn.has-image { border-color: var(--green); background: var(--green-50); }
.img-preview { width: 100%; display: flex; }
.img-chip { position: relative; width: 56px; height: 56px; }
.img-chip img {
  width: 56px; height: 56px; object-fit: cover;
  border-radius: 10px; border: 1px solid var(--line);
}
.img-chip button {
  position: absolute; top: -6px; right: -6px;
  width: 20px; height: 20px; line-height: 18px;
  border-radius: 999px; border: 0; cursor: pointer;
  background: #1b1c1a; color: #fff; font-size: 11px; padding: 0;
}
.msg-img {
  display: block;
  max-width: min(220px, 60vw);
  max-height: 220px;
  border-radius: 12px;
}
.msg-img + .bubble-text { display: block; margin-top: 6px; }
.composer textarea {
  flex: 1;
  min-width: 0; /* allow shrinking inside the wrap-enabled composer so Send stays inline */
  resize: none;
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 11px 14px;
  font-size: 16px;
  line-height: 1.4;
  max-height: 140px;
  font-family: inherit;
  background: #fff;
}
.composer textarea:focus {
  outline: none;
  border-color: var(--green);
  box-shadow: 0 0 0 3px var(--green-50);
}
.send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--green);
  color: #fff;
  font-size: 18px;
  line-height: 1;
}
.send:hover { background: var(--green-700); }
.send:disabled { background: #9ca3af; }

/* ============ Paywall ============ */
.paywall {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 18, 0.45);
  display: grid;
  place-items: center;
  padding: 24px;
  z-index: 50;
  backdrop-filter: blur(3px);
}
.paywall-card {
  background: var(--surface);
  border-radius: 22px;
  padding: 30px 26px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: var(--shadow);
}
.paywall-card h2 { margin: 0 0 8px; font-size: 22px; }
.paywall-card p { color: var(--muted); line-height: 1.5; margin: 0 0 18px; }
.paywall-card .muted { font-size: 13px; margin-top: 12px; }

/* ============ Goal progress bar (under topbar) ============ */
.goal-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
}
.goal-bar .gb-label { font-weight: 700; color: var(--ink); white-space: nowrap; }
.goal-bar .gb-track { flex: 1; height: 8px; border-radius: 999px; background: var(--line); overflow: hidden; }
.goal-bar .gb-fill { display: block; height: 100%; background: var(--green); border-radius: 999px; transition: width 0.3s ease; }
.goal-bar .gb-fill.over { background: var(--warn); }
.goal-bar .gb-right { white-space: nowrap; }

/* ============ Bottom-sheet overlay (log / goals / coach) ============ */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(20, 20, 18, 0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  backdrop-filter: blur(3px);
}
.sheet-card {
  background: var(--surface);
  width: 100%;
  max-width: 560px;
  max-height: 92dvh;
  border-radius: 22px 22px 0 0;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sheet-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}
.sheet-head h2 { margin: 0; font-size: 19px; flex: 1; letter-spacing: -0.01em; }
.sheet-body { padding: 16px 18px calc(20px + var(--safe-bottom)); overflow-y: auto; }

/* Log viewer */
.month-select { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.month-select select {
  flex: 1;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 14px;
  background: #fff;
  font-family: inherit;
  color: var(--ink);
}
.dl-link { display: block; margin: 4px 0; font-size: 13px; font-weight: 700; color: var(--green-700); text-decoration: none; white-space: nowrap; }
.log-day { margin-bottom: 18px; }
.log-day h3 { margin: 0 0 8px; font-size: 15px; }
.log-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.log-table th, .log-table td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log-table th { color: var(--muted); font-weight: 600; font-size: 12px; }
.log-table td.num, .log-table th.num { text-align: right; white-space: nowrap; }
.log-total { margin-top: 6px; font-size: 13px; font-weight: 600; }
.log-del { background: transparent; border: 0; color: #c0392b; font-size: 13px; padding: 2px 5px; border-radius: 6px; opacity: 0.55; }
.log-del:hover { opacity: 1; background: #fef2f2; }
.log-del:disabled { opacity: 0.3; }
.empty { color: var(--muted); text-align: center; padding: 28px 0; line-height: 1.5; }

/* Goals panel */
.goal-row { margin-bottom: 14px; }
.goal-row .gr-head { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 5px; }
.goal-row .gr-track { height: 9px; background: var(--line); border-radius: 999px; overflow: hidden; }
.goal-row .gr-fill { height: 100%; background: var(--green); border-radius: 999px; }
.goal-row .gr-fill.over { background: var(--warn); }
.goal-note { color: var(--muted); font-size: 13px; margin: 2px 0 16px; }
.hint {
  background: var(--green-50);
  color: var(--green-700);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 14px;
  line-height: 1.55;
}
.hint code { background: #fff; border: 1px solid #d1fae0; border-radius: 6px; padding: 1px 5px; font-size: 13px; }

/* Weight panel */
.wt-now { text-align: center; margin-bottom: 14px; }
.wt-big { font-size: 40px; font-weight: 800; letter-spacing: -0.03em; }
.wt-big span { font-size: 18px; font-weight: 600; color: var(--muted); }
.wt-sub { color: var(--muted); font-size: 13px; margin-top: 2px; }
.wt-stats { display: flex; gap: 8px; margin-bottom: 14px; }
.wt-chip {
  flex: 1;
  text-align: center;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 6px;
}
.wt-chip-v { font-size: 17px; font-weight: 700; }
.wt-chip-l { font-size: 11px; color: var(--muted); margin-top: 2px; text-transform: uppercase; letter-spacing: 0.03em; }
.wt-chip.down .wt-chip-v { color: var(--green); }
.wt-chip.up .wt-chip-v { color: var(--warn); }
.wt-hist h3 { margin: 4px 0 8px; font-size: 15px; }
.wt-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 2px;
  border-bottom: 1px solid var(--line);
  font-size: 14px;
}
.wt-row span:first-child { color: var(--muted); }

/* Account panel */
.acct-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 18px 0 6px;
}
.acct-label:first-child { margin-top: 0; }
.acct-row { display: flex; gap: 8px; align-items: center; }
.acct-row input {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 10px;
  font-size: 15px;
  background: #fff;
  font-family: inherit;
}
.acct-row input:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-50); }
.acct-current { font-size: 15px; padding: 1px 0 3px; word-break: break-all; }
.acct-msg { font-size: 13px; color: var(--muted); margin-top: 6px; line-height: 1.45; }
.acct-msg.ok { color: var(--green-700); }
.acct-msg.warn { color: var(--warn); }
.danger-label { color: #b91c1c; }
.acct-danger { color: #b91c1c; border-color: #f1c4c4; }
.acct-danger:hover { background: #fef2f2; }

/* Presets manager + manage chip */
.chip-manage { border-style: dashed; color: var(--muted); }
.preset-row { border: 1px solid var(--line); border-radius: 12px; padding: 10px; margin-bottom: 10px; }
.preset-row .pr-top { display: flex; gap: 8px; align-items: center; }
.preset-row .p-label {
  flex: 1;
  min-width: 0;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  font-size: 14px;
  font-family: inherit;
}
.preset-row .p-label:focus { outline: none; border-color: var(--green); box-shadow: 0 0 0 3px var(--green-50); }
.preset-row .p-del {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: 8px;
  color: #b91c1c;
}
.preset-row .p-del:hover { background: #fef2f2; }
.preset-row .p-macros { display: flex; gap: 6px; margin-top: 8px; }
.preset-row .p-macros input {
  flex: 1;
  min-width: 0;
  padding: 7px 4px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: 13px;
  text-align: center;
  font-family: inherit;
}
.preset-row .p-macros input:focus { outline: none; border-color: var(--green); }

/* Personality picker */
.persona {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 13px 14px;
  margin-bottom: 10px;
  transition: border-color 0.15s, background 0.15s;
}
.persona:hover { border-color: var(--green); }
.persona.active { border-color: var(--green); background: var(--green-50); }
.persona .pi-name { font-weight: 700; font-size: 15px; }
.persona .pi-blurb { color: var(--muted); font-size: 13px; line-height: 1.45; margin-top: 2px; }
.persona .pi-check { margin-left: auto; color: var(--green); font-weight: 700; font-size: 18px; visibility: hidden; }
.persona.active .pi-check { visibility: visible; }

/* ============ Guided tour (coachmarks) ============ */
body.tour-active { overflow: hidden; }
.tour { position: fixed; inset: 0; z-index: 80; }
/* Transparent full-screen layer that makes the page inert during the tour. */
.tour-block { position: fixed; inset: 0; z-index: 80; }
/* On target-less (centered) steps there's no spotlight, so dim here instead. */
.tour-block.dim { background: rgba(20, 20, 18, 0.55); }
/* Spotlight: transparent center over the target, white ring, everything else dimmed. */
.tour-spot {
  position: fixed;
  z-index: 81;
  border-radius: 12px;
  pointer-events: none;
  box-shadow: 0 0 0 3px #fff, 0 0 0 9999px rgba(20, 20, 18, 0.55);
  transition: top 0.2s ease, left 0.2s ease, width 0.2s ease, height 0.2s ease;
}
.tour-card {
  position: fixed;
  z-index: 82;
  width: min(360px, calc(100vw - 32px));
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
  padding: 18px 18px 14px;
}
.tour-step { font-size: 12px; color: var(--muted); font-weight: 600; letter-spacing: 0.03em; }
.tour-card h3 { margin: 4px 0 6px; font-size: 18px; letter-spacing: -0.01em; }
.tour-card p { margin: 0 0 14px; color: var(--ink); line-height: 1.5; font-size: 14.5px; }
.tour-actions { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.tour-nav { display: flex; gap: 8px; }
.tour-skip { background: transparent; border: 0; color: var(--muted); font-size: 13px; padding: 8px 4px; }
.tour-skip:hover { color: var(--ink); }
.tour-btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: 10px;
  padding: 9px 16px;
  font-size: 14px;
  font-weight: 600;
}
.tour-btn:hover { background: #f3f4f6; }
.tour-btn:disabled { opacity: 0.45; cursor: default; }
.tour-btn.tour-primary { background: var(--green); color: #fff; border-color: var(--green); }
.tour-btn.tour-primary:hover { background: var(--green-700); }

@media (min-width: 700px) {
  .sheet { align-items: center; }
  .sheet-card { border-radius: 22px; max-height: 86dvh; }
}

/* ============ Desktop niceties ============ */
@media (min-width: 700px) {
  .chat { padding-left: max(14px, calc((100% - 720px) / 2)); padding-right: max(14px, calc((100% - 720px) / 2)); }
  .composer { padding-left: max(12px, calc((100% - 720px) / 2)); padding-right: max(12px, calc((100% - 720px) / 2)); }
  .topbar { padding-left: max(14px, calc((100% - 720px) / 2)); padding-right: max(14px, calc((100% - 720px) / 2)); }
  .menu { right: max(14px, calc((100% - 720px) / 2)); }
}
