/* ---------- our private chat ---------- */
/* Pinned to the screen: only the message list scrolls, never the page (keeps the top bar and
   the typing box in place, also when a phone keyboard opens). */
.chat-page { position: fixed; inset: 0; display: flex; flex-direction: column; overflow: hidden; }
.chat-page .topbar { flex: none; }
.chat-page .gate { flex: 1; overflow: auto; }

.ct-page {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: 12px 12px 0;
}
.ct-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
}
.ct-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), #f79bbb);
  color: #fff;
  font-weight: 700;
  font-size: 1.2rem;
}
.ct-avatar.blue { background: linear-gradient(135deg, var(--blue-500), var(--blue-200)); }
.ct-who h1 { margin: 0; color: var(--navy); font-size: 1.1rem; }
.ct-status { min-height: 1.2em; margin: 0; color: var(--muted); font-size: 0.82rem; font-weight: 600; }
.ct-status.online { color: #2f8a5a; }
.ct-status.online::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 6px; border-radius: 50%; background: #3fb97a; }
.ct-status.typing { color: var(--rose-deep); }

.ct-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 4px 8px; overscroll-behavior: contain; }
.ct-more {
  display: block;
  margin: 0 auto 10px;
  padding: 6px 14px;
  border: 1px solid var(--card-border);
  border-radius: 999px;
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 700;
  cursor: pointer;
}
.ct-list { display: flex; flex-direction: column; gap: 2px; margin: 0; padding: 0; list-style: none; }
.ct-day {
  align-self: center;
  margin: 14px 0 8px;
  padding: 3px 12px;
  border-radius: 999px;
  background: rgba(47, 74, 128, 0.08);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 700;
}
.ct-msg { display: flex; flex-direction: column; max-width: min(78%, 520px); margin-top: 8px; animation: pop 0.2s ease-out; }
.ct-msg.joined { margin-top: 2px; }
.ct-msg.mine { align-self: flex-end; align-items: flex-end; }
.ct-msg.theirs { align-self: flex-start; align-items: flex-start; }
.ct-bubble {
  padding: 9px 14px;
  border-radius: 20px;
  font-size: 0.98rem;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.mine .ct-bubble { background: linear-gradient(135deg, var(--rose), #d9548a); color: #fff; border-bottom-right-radius: 6px; cursor: pointer; }
.theirs .ct-bubble { background: #fff; color: var(--ink); border: 1px solid var(--card-border); border-bottom-left-radius: 6px; }
.mine.joined .ct-bubble { border-top-right-radius: 8px; }
.theirs.joined .ct-bubble { border-top-left-radius: 8px; }
.ct-bubble:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }
.sending .ct-bubble { opacity: 0.65; }
.failed .ct-bubble { background: #fff; color: var(--rose-deep); border: 1.5px dashed var(--rose); }
.ct-meta { margin: 3px 6px 0; color: var(--muted); font-size: 0.72rem; }
.failed .ct-meta { color: var(--rose-deep); font-weight: 700; }
.ct-actions { margin-top: 4px; }
.ct-actions button {
  padding: 4px 12px;
  border: 1px solid var(--pink-200);
  border-radius: 999px;
  background: #fff;
  color: var(--rose-deep);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
}
.ct-empty { margin: auto; padding: 40px 20px; text-align: center; color: var(--muted); }
.ct-empty-art { margin: 0; font-size: 2.4rem; }

.ct-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin: 0 0 12px;
  padding: 8px 8px 8px 16px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border: 1px solid var(--card-border);
  border-radius: 26px;
  background: #fff;
  box-shadow: var(--shadow);
}
.ct-composer textarea {
  flex: 1;
  min-height: 40px;
  max-height: 160px;
  padding: 9px 0;
  border: 0;
  background: none;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
  resize: none;
  outline: none;
}
.ct-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--rose), var(--blue-500));
  cursor: pointer;
  transition: transform 0.15s ease, opacity 0.2s ease;
}
.ct-send svg { width: 20px; height: 20px; fill: #fff; margin-left: 2px; }
.ct-send:disabled { opacity: 0.35; cursor: default; }
.ct-send:not(:disabled):active { transform: scale(0.92); }
.ct-send:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

@keyframes pop { from { opacity: 0; translate: 0 6px; } }

/* ---------- guest chat ---------- */
.gb-page { max-width: 720px; margin: 0 auto; padding: 36px 16px 48px; }
.gb-mod {
  margin: 20px 0 0;
  padding: 10px 14px;
  border: 1px solid rgba(111, 174, 138, 0.35);
  border-radius: 14px;
  background: rgba(226, 244, 233, 0.85);
  color: #2f5d45;
  font-size: 0.88rem;
}
.gb-card {
  margin-top: 22px;
  max-height: min(60vh, 560px);
  overflow-y: auto;
  padding: 6px 16px;
  border: 1px solid var(--card-border);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.85);
  box-shadow: var(--shadow);
}
.gb-list { margin: 0; padding: 0; list-style: none; }
.gb-msg { display: flex; gap: 12px; padding: 14px 0; border-bottom: 1px dashed var(--pink-200); animation: pop 0.25s ease-out; }
.gb-msg:last-child { border-bottom: 0; }
.gb-msg.us { margin: 6px -8px; padding: 12px 8px; border: 0; border-radius: 16px; background: linear-gradient(135deg, var(--bg-soft), var(--blue-100)); }
.gb-msg.hidden-msg { opacity: 0.5; }
.gb-avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--rose);
  color: #fff;
  font-weight: 700;
}
.us .gb-avatar { background: #fff; }
.gb-main { min-width: 0; flex: 1; }
.gb-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 8px; margin: 0; color: var(--navy); }
.gb-head time { color: var(--muted); font-size: 0.78rem; }
.gb-badge { padding: 1px 8px; border-radius: 999px; background: var(--rose); color: #fff; font-size: 0.7rem; font-weight: 700; }
.gb-tag { padding: 1px 8px; border-radius: 999px; background: rgba(47, 74, 128, 0.12); color: var(--navy); font-size: 0.7rem; font-weight: 700; }
.gb-body { margin: 3px 0 0; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.gb-tools { display: flex; gap: 14px; margin-top: 4px; }
.gb-empty { margin: 0; padding: 28px 0; text-align: center; color: var(--muted); }

.gb-form {
  display: grid;
  gap: 10px;
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--card-border);
  border-radius: 24px;
  background: #fff;
  box-shadow: var(--shadow);
}
.gb-form input, .gb-form textarea {
  width: 100%;
  padding: 11px 14px;
  border: 1.5px solid var(--pink-200);
  border-radius: 14px;
  background: #fffafc;
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  resize: none;
}
.gb-form input:focus, .gb-form textarea:focus { outline: none; border-color: var(--rose); box-shadow: 0 0 0 4px rgba(232, 98, 143, 0.15); }
.gb-form-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.gb-count { color: var(--muted); font-size: 0.8rem; }
.gb-form-foot .field-error { flex: 1; margin: 0; }
.gb-form-foot .btn { margin-left: auto; }
.gb-form-foot .btn:disabled { opacity: 0.6; cursor: wait; }
.gb-note { margin: 10px 0 0; text-align: center; color: var(--muted); font-size: 0.8rem; }

@media (max-width: 560px) {
  .ct-page { padding: 8px 8px 0; }
  .ct-head { padding: 10px 12px; border-radius: 16px; }
  .ct-msg { max-width: 85%; }
  .ct-composer { margin-bottom: 8px; }
  .gb-page { padding-top: 24px; }
}
