/* ============================================================
   Joyfans — dark luxury theme
   ============================================================ */

:root {
  color-scheme: dark;
  --bg: #0a0910;
  --bg-raised: #121019;
  --surface: rgba(255, 255, 255, 0.04);
  --surface-strong: rgba(255, 255, 255, 0.07);
  --border: rgba(255, 255, 255, 0.09);
  --border-strong: rgba(255, 255, 255, 0.16);
  --text: #f3eef5;
  --text-dim: #a89fb3;
  --text-faint: #6f6680;
  --rose: #fb4d6d;
  --rose-soft: #ff7d92;
  --gold: #d8b08c;
  --accent-grad: linear-gradient(135deg, #fb4d6d 0%, #d4496e 55%, #b03a8c 100%);
  --glow: 0 0 40px rgba(251, 77, 109, 0.25);
  --radius: 18px;
  --radius-sm: 12px;
  --font-display: "Fraunces", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.55;
  min-height: 100%;
}

.bg-glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 85% -10%, rgba(176, 58, 140, 0.18), transparent 60%),
    radial-gradient(800px 500px at -10% 20%, rgba(251, 77, 109, 0.12), transparent 60%),
    radial-gradient(700px 600px at 50% 110%, rgba(216, 176, 140, 0.07), transparent 60%);
}

.hidden { display: none !important; }

.app-toast {
  position: fixed;
  top: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 220;
  max-width: min(92vw, 520px);
  padding: 12px 18px;
  border: 1px solid rgba(52, 211, 153, 0.42);
  border-radius: 12px;
  background: rgba(18, 16, 25, 0.96);
  color: #8ce8c1;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
  font-size: 13.5px;
  text-align: center;
}

.app-toast.error {
  color: #ff9aac;
  border-color: rgba(255, 128, 149, 0.42);
}
.small { font-size: 12.5px; color: var(--text-dim); }

/* ---------- shell ---------- */

.app-shell {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-shell.browse-mode .chat-view { display: none; }
.app-shell.chat-mode .browse-view { display: none; }

/* ---------- topbar ---------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 0 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 11px;
  background: var(--accent-grad);
  box-shadow: var(--glow);
  position: relative;
}

.brand-mark::after {
  content: "";
  position: absolute;
  inset: 0;
  margin: auto;
  width: 12px;
  height: 12px;
  background: rgba(255, 255, 255, 0.92);
  clip-path: path("M6 11 C 2 8, 0 5.5, 0 3.5 C 0 1.5, 1.6 0, 3.3 0 C 4.4 0, 5.5 0.7, 6 1.7 C 6.5 0.7, 7.6 0, 8.7 0 C 10.4 0, 12 1.5, 12 3.5 C 12 5.5, 10 8, 6 11 Z");
}

.brand-name {
  font-family: var(--font-display);
  font-size: 19px;
  font-weight: 500;
  letter-spacing: 0.01em;
}

.brand-name em {
  font-style: italic;
  color: var(--gold);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  position: relative;
}

/* age pill */

.age-check { cursor: pointer; user-select: none; }
.age-check input { position: absolute; opacity: 0; pointer-events: none; }

.age-pill {
  display: inline-flex;
  align-items: center;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  color: var(--text-dim);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.04em;
  transition: all 0.2s ease;
}

.age-check input:checked + .age-pill {
  background: var(--accent-grad);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--glow);
}

.age-check input:focus-visible + .age-pill {
  outline: 2px solid var(--rose-soft);
  outline-offset: 2px;
}

/* ---------- buttons ---------- */

.btn-primary {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: 600;
  color: #fff;
  background: var(--accent-grad);
  border: none;
  border-radius: 999px;
  padding: 10px 22px;
  cursor: pointer;
  box-shadow: var(--glow);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

.btn-primary:hover { transform: translateY(-1px); filter: brightness(1.08); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.55; cursor: default; transform: none; }
.btn-primary.wide { width: 100%; padding: 12px 22px; }

.btn-ghost {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-ghost:hover { background: var(--surface-strong); border-color: var(--border-strong); }
.btn-ghost:disabled { opacity: 0.5; cursor: default; }

.btn-danger {
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  color: #fff;
  background: rgba(220, 38, 38, 0.18);
  border: 1px solid rgba(220, 38, 38, 0.45);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.btn-danger:hover { background: rgba(220, 38, 38, 0.32); border-color: rgba(220, 38, 38, 0.65); }
.btn-danger:disabled { opacity: 0.5; cursor: default; }
.btn-danger.wide { width: 100%; }

/* ---------- account chip + popover ---------- */

.account-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 16px 5px 6px;
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.account-chip:hover { border-color: var(--border-strong); background: var(--surface-strong); }

.account-initial {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent-grad);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
}

.account-popover {
  position: absolute;
  top: calc(100% + 10px);
  right: 0;
  min-width: 260px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  z-index: 50;
}

.account-popover strong { font-size: 14.5px; }
.account-email { font-size: 12.5px; color: var(--text-dim); word-break: break-all; }
.account-email-status { font-size: 11.5px; color: #69dcae; }

.account-id-row {
  font-size: 11.5px;
  color: var(--text-faint);
  display: flex;
  gap: 6px;
  align-items: center;
  margin-bottom: 6px;
}

.nickname-picker {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 4px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.nickname-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-dim);
}

.nickname-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.nickname-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.nickname-chip.active {
  border-color: rgba(251, 77, 109, 0.55);
  background: rgba(251, 77, 109, 0.16);
}

.nickname-custom {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 13px;
}

.nickname-status {
  min-height: 14px;
  font-size: 11.5px;
  color: #69dcae;
}

.account-diamond-row {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  font-size: 12.5px;
  font-weight: 700;
  color: #8fd3ff;
  background: rgba(94, 178, 255, 0.1);
  border: 1px solid rgba(94, 178, 255, 0.25);
  border-radius: 999px;
  padding: 5px 12px;
  margin: 2px 0 4px;
}

.account-id-row code {
  font-size: 11px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 7px;
  color: var(--gold);
}

/* ---------- browse view ---------- */

.browse-hero { padding: 26px 0 6px; }

.browse-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(30px, 4.5vw, 44px);
  font-weight: 500;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.browse-hero p { margin: 0; color: var(--text-dim); font-size: 15px; }

.character-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 9px;
  padding: 22px 0 26px;
}

.filter-chip {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-dim);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 18px;
  cursor: pointer;
  transition: all 0.18s ease;
}

.filter-chip:hover { color: var(--text); border-color: var(--border-strong); }

.filter-chip.active {
  color: #fff;
  background: var(--accent-grad);
  border-color: transparent;
  box-shadow: var(--glow);
}

.character-roster {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 22px;
}

/* ---------- site footer (legal + info links) ---------- */

.site-footer {
  margin-top: 40px;
  padding: 28px 0 40px;
  border-top: 1px solid var(--border);
  text-align: center;
}

.site-footer-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px 22px;
  margin-bottom: 14px;
}

.site-footer-links a {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
}

.site-footer-links a:hover { color: var(--rose-soft, var(--rose)); }

/* Crawlable directory of public pages (companions, guides, comparisons) */
.site-directory {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  align-items: start;
  gap: 18px 32px;
  max-width: 880px;
  margin: 0 auto 22px;
  text-align: left;
}
.site-directory h2 {
  margin: 0 0 6px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.site-directory p {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin: 0;
  font-size: 13px;
  line-height: 1.6;
}
.site-directory a { color: var(--text-dim); text-decoration: none; }
.site-directory a:hover { color: var(--rose-soft, var(--rose)); }

.site-footer-copy {
  margin: 0;
  color: var(--text-faint);
  font-size: 12.5px;
  line-height: 1.6;
}

/* ---------- character cards ---------- */

.character-card {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--bg-raised);
  transform: translateY(0);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.character-card:hover,
.character-card:focus-visible {
  transform: translateY(-5px);
  border-color: rgba(251, 77, 109, 0.5);
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.55), var(--glow);
  outline: none;
}

.character-card.active { border-color: var(--rose); }

.card-portrait {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 64px;
  color: var(--text-faint);
  background: linear-gradient(160deg, #221c2e, #14101d);
}

.card-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
  transition: transform 0.45s ease;
}

.character-card:hover .card-portrait img,
.character-card:focus-visible .card-portrait img { transform: scale(1.05); }

.card-scrim {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(10, 9, 16, 0) 38%, rgba(10, 9, 16, 0.45) 62%, rgba(10, 9, 16, 0.92) 100%);
  pointer-events: none;
}

.card-header {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  justify-content: flex-end;
}

.card-archetype {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #ffe9ee;
  background: rgba(10, 9, 16, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 5px 11px;
}

.card-details {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 14px 16px 15px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.card-topline {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.card-topline strong {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 500;
  color: #fff;
}

.card-topline small { font-size: 14px; color: var(--gold); font-weight: 600; }

.card-tagline {
  font-size: 12.5px;
  color: rgba(243, 238, 245, 0.82);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card-tags { display: flex; gap: 6px; }

.card-tags span {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: capitalize;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  padding: 3px 9px;
}

/* ---------- chat view ---------- */

.chat-view {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 22px;
  flex: 1;
  min-height: 0;
}

.chat-sidebar {
  display: flex;
  flex-direction: column;
  gap: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  max-height: calc(100vh - 110px);
  padding-right: 2px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.panel h2 {
  margin: 0 0 10px;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-faint);
}

/* profile card */

.profile-panel {
  padding: 0;
  overflow: hidden;
  position: relative;
  aspect-ratio: 4 / 5;
  flex-shrink: 0;
}

.profile-portrait {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 64px;
  color: var(--text-faint);
  background: linear-gradient(160deg, #221c2e, #14101d);
}

.profile-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
}

.profile-overlay {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 40px 18px 16px;
  background: linear-gradient(180deg, rgba(10, 9, 16, 0) 0%, rgba(10, 9, 16, 0.78) 55%, rgba(10, 9, 16, 0.95) 100%);
}

.profile-overlay strong {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 500;
}

.profile-overlay p { margin: 2px 0 10px; font-size: 13px; color: var(--text-dim); }

.character-meta { display: flex; flex-wrap: wrap; gap: 6px; }

.character-meta span {
  font-size: 11px;
  font-weight: 600;
  color: var(--gold);
  background: rgba(216, 176, 140, 0.12);
  border: 1px solid rgba(216, 176, 140, 0.25);
  border-radius: 999px;
  padding: 3px 10px;
}

/* status grid */

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  text-align: center;
}

.status-grid > div { display: flex; flex-direction: column; gap: 3px; }

.status-grid span {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.status-grid strong { font-size: 12px; letter-spacing: 0.02em; color: var(--rose-soft); overflow-wrap: anywhere; }

#proactiveText { margin: 10px 0 0; }

.sidebar-danger-panel {
  border-color: rgba(220, 38, 38, 0.2);
  background: rgba(220, 38, 38, 0.04);
  margin-top: auto; /* push to bottom of sidebar */
}

/* chat column */

.chat {
  display: flex;
  flex-direction: column;
  min-height: 0;
  max-height: calc(100vh - 110px);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  overflow: hidden;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: rgba(10, 9, 16, 0.35);
}

.back-button {
  padding: 7px 9px;
  display: inline-flex;
  align-items: center;
}

.chat-avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  border: 2px solid rgba(251, 77, 109, 0.55);
  background: linear-gradient(160deg, #221c2e, #14101d);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  color: var(--text-faint);
}

.chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
}

.chat-header-text { display: flex; flex-direction: column; min-width: 0; }
.chat-header-text .chat-meta-desc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-text strong { font-family: var(--font-display); font-size: 17px; font-weight: 500; }
.chat-header-text span { font-size: 12px; color: var(--text-dim); display: flex; align-items: center; gap: 6px; }

.chat-header-wallet {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 9px;
}

.info-button {
  display: none; /* shown on mobile only */
  align-items: center;
  justify-content: center;
  padding: 7px 9px;
}

.info-backdrop {
  position: fixed;
  inset: 0;
  z-index: 85;
  background: rgba(5, 4, 9, 0.6);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

@keyframes drawer-in {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

.diamond-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13.5px;
  font-weight: 700;
  color: #8fd3ff;
  background: rgba(94, 178, 255, 0.1);
  border: 1px solid rgba(94, 178, 255, 0.3);
  border-radius: 999px;
  padding: 6px 13px;
}

.checkin-btn {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: #0a0910;
  background: linear-gradient(135deg, #ffd98a, #d8b08c);
  border: none;
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  box-shadow: 0 0 24px rgba(216, 176, 140, 0.35);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.checkin-btn:hover { transform: translateY(-1px); filter: brightness(1.05); }
.checkin-btn:disabled { opacity: 0.6; cursor: default; transform: none; }

.online-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 8px rgba(74, 222, 128, 0.8);
  display: inline-block;
}

/* messages */

.messages {
  flex: 1;
  min-height: 200px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.message {
  max-width: 72%;
  padding: 11px 15px;
  border-radius: 18px;
  font-size: 14.5px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  animation: msg-in 0.25s ease both;
}

@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.message.user {
  align-self: flex-end;
  background: var(--accent-grad);
  color: #fff;
  border-bottom-right-radius: 6px;
  box-shadow: 0 6px 22px rgba(251, 77, 109, 0.25);
}

.message.character {
  align-self: flex-start;
  background: var(--surface-strong);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 6px;
}

.message.notice {
  align-self: center;
  max-width: 84%;
  text-align: center;
  font-size: 12.5px;
  color: var(--text-dim);
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed var(--border-strong);
  border-radius: 999px;
  padding: 8px 18px;
}

.notice-link,
.get-diamonds-link {
  color: var(--rose-soft);
  font-weight: 600;
  text-decoration: none;
}
.notice-link:hover,
.get-diamonds-link:hover { text-decoration: underline; }
.get-diamonds-link { align-self: flex-start; font-size: 12.5px; margin: -2px 0 4px 2px; }
.btc-buy-link { background: none; border: 0; padding: 0; cursor: pointer; font-family: inherit; }
.btc-status { margin: 12px 0 0; min-height: 1em; text-align: center; }
.gift-item:disabled { opacity: 0.5; cursor: wait; transform: none; }

/* confirm modal */

.confirm-modal {
  max-width: 340px;
  text-align: center;
}

.confirm-modal h2 { font-size: 20px; margin: 0 0 8px; }
.confirm-modal .small { margin: 0 0 22px; }

.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.confirm-actions .btn-ghost { flex: 1; }
.confirm-actions .btn-danger { flex: 1; }

/* voice replay button on character bubbles */

.message.character {
  position: relative;
  padding-right: 38px;
}

.msg-voice {
  position: absolute;
  right: 8px;
  bottom: 8px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.message.character:hover .msg-voice,
.msg-voice:focus-visible { opacity: 1; }
.msg-voice:hover { color: var(--rose-soft); border-color: rgba(251, 77, 109, 0.5); }

@media (hover: none), (pointer: coarse) {
  .msg-voice { opacity: 1; }
}
.msg-voice:disabled { opacity: 0.4; cursor: default; }

/* typing indicator */

.message.typing {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: 14px 17px;
}

.message.typing i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-dim);
  animation: typing-bounce 1.2s infinite ease-in-out;
}

.message.typing i:nth-child(2) { animation-delay: 0.15s; }
.message.typing i:nth-child(3) { animation-delay: 0.3s; }

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* composer */

.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--border);
  background: rgba(10, 9, 16, 0.35);
}

.composer input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 12px 20px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer input::placeholder { color: var(--text-faint); }

.composer input:focus {
  border-color: rgba(251, 77, 109, 0.55);
  box-shadow: 0 0 0 3px rgba(251, 77, 109, 0.15);
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  border: none;
  background: var(--accent-grad);
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--glow);
  transition: transform 0.15s ease, filter 0.15s ease;
  flex-shrink: 0;
}

.send-btn:hover { transform: scale(1.06); filter: brightness(1.08); }
.send-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* mic button */

.mic-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-dim);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.mic-btn:hover { color: var(--text); border-color: var(--border-strong); }
.mic-btn.listening {
  color: var(--rose);
  border-color: var(--rose);
  background: rgba(251, 77, 109, 0.12);
  box-shadow: 0 0 0 4px rgba(251, 77, 109, 0.15);
  animation: mic-pulse 1.2s infinite ease-in-out;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 4px rgba(251, 77, 109, 0.15); }
  50% { box-shadow: 0 0 0 8px rgba(251, 77, 109, 0.08); }
}

/* icon buttons in header */

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.call-button { color: #4ade80; }
.call-button:hover { color: #fff; background: rgba(74, 222, 128, 0.15); border-color: rgba(74, 222, 128, 0.4); }

.gift-button { color: var(--gold); }
.gift-button:hover { color: #fff; background: rgba(216, 176, 140, 0.15); border-color: rgba(216, 176, 140, 0.4); }

/* calling overlay */

.calling-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
}

.calling-bg {
  position: absolute;
  inset: 0;
  background: rgba(5, 4, 9, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

.calling-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  width: min(380px, 94vw);
  padding: 40px 24px 36px;
}

.calling-portrait {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  overflow: hidden;
  border: 3px solid rgba(251, 77, 109, 0.6);
  box-shadow: 0 0 40px rgba(251, 77, 109, 0.3);
  background: linear-gradient(160deg, #221c2e, #14101d);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-size: 48px;
  color: var(--text-faint);
  animation: call-ring 2.5s infinite ease-in-out;
}

.calling-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 12%;
}

@keyframes call-ring {
  0%, 100% { box-shadow: 0 0 40px rgba(251, 77, 109, 0.3); }
  50% { box-shadow: 0 0 60px rgba(251, 77, 109, 0.55); }
}

.calling-name {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 500;
  color: #fff;
}

.calling-status {
  font-size: 13.5px;
  color: var(--text-dim);
  letter-spacing: 0.02em;
}

.calling-transcript {
  width: 100%;
  max-height: 220px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 0 4px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

.call-transcript-line {
  font-size: 13.5px;
  color: var(--text-dim);
  line-height: 1.5;
  padding: 8px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
}

.call-transcript-line.user {
  align-self: flex-end;
  color: var(--text);
  background: rgba(251, 77, 109, 0.1);
  border-color: rgba(251, 77, 109, 0.25);
}

.calling-controls {
  margin-top: 12px;
  display: flex;
  gap: 20px;
  align-items: center;
}

.call-end-btn {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  border: none;
  background: #e53e3e;
  color: #fff;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  box-shadow: 0 8px 24px rgba(229, 62, 62, 0.45);
  transition: transform 0.15s ease, filter 0.15s ease;
}

.call-end-btn:hover { transform: scale(1.06); filter: brightness(1.1); }

/* gift modal */

.gift-modal { max-width: 360px; }

.gift-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.gift-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  padding: 14px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.18s ease;
}

.gift-item:hover {
  border-color: var(--gold);
  background: rgba(216, 176, 140, 0.1);
  transform: translateY(-2px);
}

.gift-emoji { font-size: 32px; line-height: 1; }

.gift-item strong {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text);
}

.gift-cost {
  font-size: 11.5px;
  font-weight: 700;
  color: #8fd3ff;
}

/* ---------- auth modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(5, 4, 9, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--bg-raised);
  border: 1px solid var(--border-strong);
  border-radius: 22px;
  padding: 30px 28px 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6), var(--glow);
  animation: msg-in 0.25s ease both;
}

.modal h2 {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 500;
  margin: 0 0 4px;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 16px;
  background: none;
  border: none;
  color: var(--text-faint);
  font-size: 26px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover { color: var(--text); }

.auth-tabs {
  display: flex;
  gap: 4px;
  margin: 18px 0 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
}

.auth-tab {
  flex: 1;
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  color: var(--text-dim);
  background: none;
  border: none;
  border-radius: 999px;
  padding: 9px 0;
  cursor: pointer;
  transition: all 0.18s ease;
}

.auth-tab.active {
  color: #fff;
  background: var(--accent-grad);
  box-shadow: var(--glow);
}

.auth-form { display: flex; flex-direction: column; gap: 13px; }

.auth-link {
  align-self: flex-start;
  padding: 0;
  border: 0;
  background: none;
  color: #ff8ba0;
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.auth-link:hover { color: #ffb1bf; text-decoration: underline; }

.field { display: flex; flex-direction: column; gap: 6px; }

.field span {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.field input {
  font-family: var(--font-body);
  font-size: 14.5px;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.field input:focus {
  border-color: rgba(251, 77, 109, 0.55);
  box-shadow: 0 0 0 3px rgba(251, 77, 109, 0.15);
}

.auth-error {
  margin: 0;
  min-height: 18px;
  font-size: 13px;
  color: #ff8095;
}

/* Cloudflare Turnstile renders a fixed 300×65 iframe; reserve its space. */
.turnstile-field { min-height: 65px; }
.auth-status {
  margin: 0;
  min-height: 0;
  font-size: 13px;
  line-height: 1.5;
  color: #7ee2ba;
}

.auth-footnote { margin: 16px 0 0; text-align: center; color: var(--text-faint); }

/* Inline-style replacements (CSP: style-src has no 'unsafe-inline') */
.sidebar-danger-panel .btn-danger svg { flex-shrink: 0; }
.panel-hint { margin: 8px 0 0; text-align: center; }
.gift-note { margin: 4px 0 14px; }

/* ---------- AI-initiated photos ---------- */

.message.photo { padding: 0; background: none; border: none; max-width: 300px; }

/* Locked photo: a blurred, teasing card the user taps to unlock */
.photo-locked {
  position: relative;
  display: block;
  width: 240px;
  max-width: 78vw;
  aspect-ratio: 3 / 4;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  color: var(--text);
  font-family: inherit;
  background: linear-gradient(150deg, #241726, #17121f 60%, #1c1524);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.photo-locked:hover { transform: translateY(-2px); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45); }

.photo-blur {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(120px 160px at 40% 30%, rgba(251, 77, 109, 0.35), transparent 70%),
    radial-gradient(140px 180px at 70% 75%, rgba(176, 58, 140, 0.4), transparent 70%),
    repeating-linear-gradient(115deg, rgba(255, 255, 255, 0.05) 0 8px, rgba(255, 255, 255, 0) 8px 18px);
  filter: blur(6px);
}

.photo-lock-body {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-align: center;
  padding: 16px;
}
.photo-lock-body svg { color: var(--rose-soft); opacity: 0.95; }
.photo-lock-body strong { font-size: 14px; font-weight: 600; }
.photo-unlock-cta {
  font-size: 12.5px;
  color: var(--text);
  background: var(--accent-grad);
  padding: 5px 14px;
  border-radius: 999px;
  margin-top: 4px;
  box-shadow: var(--glow);
}

/* Free-unlock label (first N photos per account are on the house) */
.photo-unlock-cta.free {
  background: rgba(52, 211, 153, 0.16);
  color: #6ee7b7;
  box-shadow: none;
  border: 1px solid rgba(52, 211, 153, 0.35);
}

/* Developing state: a silhouette slowly comes into focus while GPU works */
.photo-develop {
  position: relative;
  width: 240px;
  max-width: 78vw;
  aspect-ratio: 3 / 4;
  overflow: hidden;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: #140e14;
}

.photo-develop-shape {
  position: absolute;
  inset: -16%;
  background:
    radial-gradient(ellipse 42% 34% at 50% 26%, rgba(236, 196, 176, 0.95) 0%, rgba(196, 122, 108, 0.7) 46%, transparent 70%),
    radial-gradient(ellipse 58% 48% at 50% 72%, rgba(120, 48, 64, 0.9) 0%, rgba(40, 18, 28, 0.95) 72%);
  filter: blur(30px);
  transform: scale(1.16);
  animation: photo-develop-focus 100s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}

.photo-develop-veil {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(20, 14, 20, 0.18), rgba(20, 14, 20, 0.42));
  animation: photo-develop-veil 100s ease-out forwards;
}

.photo-develop-caption {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 14px;
  text-align: center;
  font-size: 12.5px;
  color: rgba(255, 244, 248, 0.88);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.45);
  animation: photo-develop-caption 8s ease-out forwards;
}

@keyframes photo-develop-focus {
  0% { filter: blur(32px); transform: scale(1.18); opacity: 0.7; }
  100% { filter: blur(8px); transform: scale(1.03); opacity: 1; }
}

@keyframes photo-develop-veil {
  0% { opacity: 0.55; }
  100% { opacity: 0.12; }
}

@keyframes photo-develop-caption {
  0%, 70% { opacity: 1; }
  100% { opacity: 0.35; }
}

.photo-frame {
  position: relative;
  display: block;
  width: 240px;
  max-width: 78vw;
  padding: 0;
  margin: 0;
  border: none;
  background: none;
  cursor: zoom-in;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.photo-frame:focus-visible {
  outline: 2px solid rgba(251, 77, 109, 0.75);
  outline-offset: 3px;
  border-radius: var(--radius-sm);
}

.photo-img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  background: #17121f;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  pointer-events: none;
}

.photo-img-reveal {
  animation: photo-unblur 1.35s ease-out both;
}

@keyframes photo-unblur {
  from {
    filter: blur(22px) saturate(0.75);
    opacity: 0.35;
    transform: scale(1.06);
  }
  to {
    filter: blur(0) saturate(1);
    opacity: 1;
    transform: scale(1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .photo-develop-shape,
  .photo-develop-veil,
  .photo-develop-caption,
  .photo-img-reveal { animation: none; }
  .photo-develop-shape { filter: blur(10px); transform: none; }
}

/* Full-screen photo viewer */
.photo-lightbox {
  position: fixed;
  inset: 0;
  z-index: 210;
  background: rgba(5, 4, 9, 0.94);
  touch-action: none;
  overscroll-behavior: none;
}

.photo-lightbox-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding:
    calc(56px + env(safe-area-inset-top, 0px))
    calc(12px + env(safe-area-inset-right, 0px))
    calc(20px + env(safe-area-inset-bottom, 0px))
    calc(12px + env(safe-area-inset-left, 0px));
}

.photo-lightbox-img {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  border-radius: 8px;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: center center;
  will-change: transform;
}

.photo-lightbox-close {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
  z-index: 2;
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(18, 16, 25, 0.72);
  color: var(--text);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.photo-lightbox-close:hover,
.photo-lightbox-close:focus-visible {
  color: #fff;
  background: rgba(32, 26, 40, 0.9);
  outline: none;
}

.photo-xr-btn {
  position: absolute;
  top: max(10px, env(safe-area-inset-top, 0px));
  left: max(10px, env(safe-area-inset-left, 0px));
  z-index: 2;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  background: rgba(18, 16, 25, 0.72);
  color: var(--text);
  font-family: var(--font-body);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.photo-xr-btn:hover,
.photo-xr-btn:focus-visible {
  color: #fff;
  background: rgba(32, 26, 40, 0.9);
  outline: none;
}

.photo-xr-btn:disabled { opacity: 0.55; cursor: default; }

body.lightbox-open,
html.xr-session,
body.xr-session {
  overflow: hidden;
}

html.xr-session .photo-lightbox { visibility: hidden; }

/* ---------- responsive ---------- */

@media (max-width: 920px) {
  /* 16px inputs stop iOS Safari from auto-zooming on focus */
  .composer input,
  .field input { font-size: 16px; }

  /* Keyboard fix: lock body scroll but let the shell track visual viewport */
  body.chat-locked {
    overflow: hidden;
    overscroll-behavior: none;
  }

  /* Shell is position:fixed and tracks the visual viewport via JS CSS vars.
     When the keyboard opens, --app-height shrinks to the visible area height
     and --vv-top offsets the shell so it sits flush with the visible area.
     This guarantees the composer is always above the keyboard.
     CRITICAL: min-height:0 overrides the desktop min-height:100vh on .app-shell,
     which would otherwise force the shell taller than the keyboard-reduced viewport. */
  .app-shell.chat-mode {
    position: fixed;
    top: var(--vv-top, 0px);
    left: 0;
    right: 0;
    width: 100%;
    min-height: 0;
    height: var(--app-height, 100svh);
    padding-bottom: 0;
    overflow: hidden;
  }

  .app-shell.chat-mode .topbar { padding: 12px 0 10px; }

  .app-shell.chat-mode .chat-view {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    gap: 0;
  }

  /* Side panels live in a slide-over drawer on phones (info button) */
  .app-shell.chat-mode .chat-sidebar { display: none; }

  .app-shell.chat-mode.info-open .chat-sidebar {
    display: flex;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(340px, 88vw);
    max-height: none;
    z-index: 90;
    margin: 0;
    padding: 16px 14px calc(16px + env(safe-area-inset-bottom));
    background: var(--bg-raised);
    border-left: 1px solid var(--border-strong);
    box-shadow: -24px 0 60px rgba(0, 0, 0, 0.55);
    overflow-y: auto;
    animation: drawer-in 0.22s ease both;
  }

  .info-button { display: inline-flex; }

  .app-shell.chat-mode .chat {
    flex: 1;
    min-height: 0;
    height: auto;
    max-height: none;
    margin-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .composer { padding-bottom: calc(14px + env(safe-area-inset-bottom)); }

  .chat-view { grid-template-columns: 1fr; }
}

@media (max-width: 600px) {
  .app-shell { padding: 0 14px 32px; }
  .app-shell.chat-mode { padding: 0 10px; }
  .character-roster { grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 14px; }
  .message { max-width: 86%; }
  .brand-name { font-size: 16px; }
  .account-chip-name { display: none; }
  .chat-header { padding: 10px 12px; }
  .composer { padding: 10px 10px calc(10px + env(safe-area-inset-bottom)); }
  .messages { padding: 16px 12px; }
  .message.photo { max-width: 86vw; }
  .photo-frame,
  .photo-locked,
  .photo-develop {
    width: min(300px, 82vw);
    max-width: 82vw;
  }
  .photo-lightbox-img { border-radius: 0; }
}

/* ---------- Vision Pro / Quest 3 ---------- */

html.xr-headset,
html.xr-headset body {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

html.xr-headset button,
html.xr-headset a,
html.xr-headset .filter-chip,
html.xr-headset .character-card,
html.xr-headset .nickname-chip {
  touch-action: manipulation;
}

html.xr-headset .composer input,
html.xr-headset .field input {
  font-size: 16px;
}

html.xr-headset .icon-button,
html.xr-headset .info-button,
html.xr-headset .back-button,
html.xr-headset .mic-btn,
html.xr-headset .send-btn,
html.xr-headset .photo-lightbox-close {
  min-width: 44px;
  min-height: 44px;
}

html.xr-headset .msg-voice {
  width: 36px;
  height: 36px;
  opacity: 1;
}

html.xr-headset .age-pill,
html.xr-headset .filter-chip {
  min-height: 44px;
  padding: 10px 16px;
}

html.xr-headset .btn-primary,
html.xr-headset .btn-ghost,
html.xr-headset .btn-danger {
  min-height: 44px;
}

html.xr-quest .app-shell {
  max-width: 1120px;
}

html.xr-vision .panel,
html.xr-vision .chat,
html.xr-vision .modal,
html.xr-vision .account-popover,
html.xr-vision .calling-inner {
  background: rgba(18, 16, 25, 0.72);
  backdrop-filter: blur(28px) saturate(1.25);
  -webkit-backdrop-filter: blur(28px) saturate(1.25);
}

html.xr-vision .character-roster {
  perspective: 1400px;
}

html.xr-vision .character-card:hover,
html.xr-vision .character-card:focus-visible {
  transform: translateY(-6px) translateZ(24px);
}

@media (min-width: 1600px) {
  html.xr-vision .app-shell {
    max-width: 1480px;
  }
}

/* ============================================================
   Feed (home timeline), profiles, Messages, docked chat
   ============================================================ */

.topnav { display: flex; gap: 4px; padding: 4px; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); }
.topnav-btn { border: 0; background: none; color: var(--text-dim); font: inherit; font-weight: 600; font-size: 13.5px; padding: 7px 16px; border-radius: 999px; cursor: pointer; }
.topnav-btn:hover { color: var(--text); }
.topnav-btn.active { background: var(--surface-strong); color: var(--text); }
.topnav-btn:focus-visible, .feed-tab:focus-visible, .post-act:focus-visible, .link-btn:focus-visible { outline: 2px solid var(--rose-soft); outline-offset: 2px; }

.app-shell.feed-mode .browse-view,
.app-shell.feed-mode .chat-view { display: none; }
.app-shell.browse-mode .feed-view,
.app-shell.chat-mode .feed-view { display: none; }

.feed-layout { display: grid; grid-template-columns: minmax(0, 620px) 320px; gap: 28px; justify-content: center; align-items: start; }
.feed-main { min-width: 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.feed-tabs { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--border); }
.feed-tab { background: none; border: 0; border-bottom: 3px solid transparent; color: var(--text-dim); font: inherit; font-weight: 600; padding: 14px 0 11px; cursor: pointer; }
.feed-tab:hover { background: var(--surface); }
.feed-tab.active { color: var(--text); border-bottom-color: var(--rose); }

.feed-strip { display: flex; gap: 12px; overflow-x: auto; padding: 14px 16px; border-bottom: 1px solid var(--border); scrollbar-width: none; }
.feed-strip::-webkit-scrollbar { display: none; }
.strip-item { flex: none; width: 64px; display: flex; flex-direction: column; align-items: center; gap: 5px; background: none; border: 0; color: var(--text-dim); font: inherit; font-size: 12px; cursor: pointer; }
.strip-ring { width: 58px; height: 58px; border-radius: 50%; padding: 2px; background: var(--border-strong); }
.strip-ring.followed { background: var(--accent-grad); }
.strip-avatar { display: block; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; object-position: 50% 15%; border: 2px solid var(--bg); }

.post { display: grid; grid-template-columns: 44px minmax(0, 1fr); gap: 12px; padding: 14px 16px 8px; border-bottom: 1px solid var(--border); }
.post-avatar-btn { background: none; border: 0; padding: 0; cursor: pointer; align-self: start; border-radius: 50%; }
.feed-avatar { display: block; width: 44px; height: 44px; border-radius: 50%; object-fit: cover; object-position: 50% 15%; background: var(--surface-strong); }
.feed-avatar.sm { width: 38px; height: 38px; }
.feed-avatar.xs { width: 26px; height: 26px; flex: none; }
.post-main { min-width: 0; }
.post-head { display: flex; align-items: center; gap: 6px; min-width: 0; white-space: nowrap; }
.post-name { background: none; border: 0; padding: 0; color: var(--text); font: inherit; font-weight: 700; cursor: pointer; overflow: hidden; text-overflow: ellipsis; }
.post-name:hover { text-decoration: underline; }
.ai-badge { flex: none; font-size: 9.5px; font-weight: 800; letter-spacing: 0.06em; padding: 1px 5px; border-radius: 5px; color: var(--gold); background: rgba(216, 176, 140, 0.14); border: 1px solid rgba(216, 176, 140, 0.32); vertical-align: middle; }
.post-handle, .post-dot, .post-time { color: var(--text-faint); font-size: 14px; }
.post-handle { margin: 0; overflow: hidden; text-overflow: ellipsis; }
.post-text { margin: 3px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.5; }

.post-media { position: relative; display: block; width: 100%; margin-top: 10px; padding: 0; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; background: #000; cursor: zoom-in; }
.post-img { display: block; width: 100%; max-height: 560px; aspect-ratio: 4 / 5; object-fit: cover; object-position: 50% 20%; }
.post-media.locked { cursor: default; aspect-ratio: 4 / 3; }
.post-locked-art { position: absolute; inset: 0; background: radial-gradient(circle at 30% 30%, rgba(251, 77, 109, 0.35), transparent 55%), radial-gradient(circle at 70% 70%, rgba(176, 58, 140, 0.35), transparent 55%), #16121d; filter: blur(12px); }
.post-lock { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 18px; text-align: center; }
.post-lock strong { font-family: var(--font-display); font-size: 20px; font-weight: 500; }
.post-lock-sub { color: var(--text-dim); font-size: 13px; max-width: 320px; }
.post-lock-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 4px; }
.cf-badge { position: absolute; left: 10px; top: 10px; padding: 3px 10px; border-radius: 999px; background: rgba(10, 9, 16, 0.72); border: 1px solid var(--border-strong); font-size: 12px; font-weight: 600; color: var(--text); }

.post-actions { display: flex; gap: 20px; margin: 6px 0 0 -8px; }
.post-act { display: inline-flex; align-items: center; gap: 5px; background: none; border: 0; padding: 6px 8px; border-radius: 999px; color: var(--text-faint); font: inherit; font-size: 13px; cursor: pointer; }
.post-act.reply:hover { color: #7aa7ff; background: rgba(122, 167, 255, 0.1); }
.post-act.like:hover, .post-act.like.on { color: var(--rose); }
.post-act.like:hover { background: rgba(251, 77, 109, 0.1); }
.post-act.dm { color: var(--gold); font-weight: 600; }
.post-act.dm:hover { background: rgba(216, 176, 140, 0.12); }

/* Joyland kit ad: a post-shaped card, clearly marked, links out */
.post-ad { padding-bottom: 14px; }
.ad-avatar { display: grid; place-items: center; width: 44px; height: 44px; background: var(--accent-grad); color: #fff; font-family: var(--font-display); font-size: 20px; font-style: italic; text-decoration: none; }
.post-ad .post-name { text-decoration: none; }
.post-ad .post-name:hover { text-decoration: underline; }
.ad-badge { padding: 1px 7px; border: 1px solid var(--border-strong); border-radius: 999px; color: var(--text-faint); font-size: 11px; font-weight: 600; letter-spacing: 0.02em; }
.ad-media { cursor: pointer; background: #0b0710; }
.ad-img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 2; object-fit: cover; }
.ad-cta-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.ad-host { color: var(--text-faint); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ad-cta { text-decoration: none; white-space: nowrap; }

.post-thread { display: grid; gap: 8px; margin: 6px 0 4px; padding-top: 8px; border-top: 1px solid var(--border); }
.thread-row { display: flex; gap: 8px; align-items: flex-start; }
.thread-you { flex: none; width: 26px; height: 26px; border-radius: 50%; display: grid; place-items: center; font-size: 9.5px; font-weight: 700; color: var(--text-dim); background: var(--surface-strong); }
.thread-bubble { max-width: 90%; padding: 7px 11px; border-radius: 14px; background: var(--surface-strong); }
.thread-row.user .thread-bubble { background: rgba(251, 77, 109, 0.12); }
.thread-bubble p { margin: 0; font-size: 14px; overflow-wrap: anywhere; }
.typing-dots { display: inline-flex; gap: 4px; padding: 10px 12px; }
.typing-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--text-dim); animation: feed-typing 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: 0.2s; }
.typing-dots i:nth-child(3) { animation-delay: 0.4s; }
@keyframes feed-typing { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }
.thread-note { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding-left: 34px; font-size: 12.5px; color: var(--text-faint); }
.link-btn { background: none; border: 0; padding: 0; color: var(--gold); font: inherit; font-weight: 600; cursor: pointer; }
.link-btn:hover { text-decoration: underline; }
.post-reply { display: flex; gap: 8px; margin: 8px 0 6px; }
.post-reply[hidden] { display: none; }
.post-reply input { flex: 1; min-width: 0; padding: 9px 14px; border-radius: 999px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text); font: inherit; outline: none; }
.post-reply input:focus { border-color: var(--rose-soft); }
.post-reply .btn-primary { padding: 8px 16px; }
.feed-empty { margin: 0; padding: 36px 18px; text-align: center; color: var(--text-faint); }
.feed-more { display: block; margin: 14px auto; }

.feed-rail { position: sticky; top: 16px; display: grid; gap: 16px; }
.rail-card { padding: 12px 0 8px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); }
.rail-card h2 { margin: 0 16px 6px; font-family: var(--font-body); font-size: 16px; font-weight: 700; }
.rail-empty { margin: 6px 16px 10px; color: var(--text-faint); font-size: 13px; }
.rail-foot { margin: 0 6px; color: var(--text-faint); font-size: 12px; line-height: 1.7; }
.rail-foot a { color: var(--text-dim); }
.conversation-row { display: grid; grid-template-columns: 38px minmax(0, 1fr); gap: 10px; align-items: center; width: 100%; padding: 8px 16px; background: none; border: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.conversation-row:hover { background: var(--surface-strong); }
.conversation-main { display: grid; min-width: 0; }
.conversation-top { display: flex; align-items: center; gap: 6px; white-space: nowrap; }
.conversation-time { margin-left: auto; color: var(--text-faint); font-size: 12px; }
.conversation-last { overflow: hidden; color: var(--text-dim); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.stage-chip { font-size: 9.5px; font-weight: 800; letter-spacing: 0.05em; padding: 1px 6px; border-radius: 999px; border: 1px solid currentColor; color: #8f86a0; }
.stage-acquaintance { color: #7aa7ff; }
.stage-friend { color: #34d399; }
.stage-close { color: var(--gold); }
.stage-romantic { color: var(--rose-soft); }
.stage-intimate { color: var(--rose); }
.suggestion-row { display: grid; grid-template-columns: 38px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 8px 16px; }
.suggestion-main { display: grid; min-width: 0; background: none; border: 0; padding: 0; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.suggestion-main span { overflow: hidden; color: var(--text-faint); font-size: 12.5px; text-overflow: ellipsis; white-space: nowrap; }
.follow-btn { padding: 6px 14px; font-size: 13px; }
.messages-modal { max-width: 460px; }
.messages-modal .conversation-row { padding: 10px 4px; }

.profile-bar { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.profile-hero { display: flex; gap: 18px; padding: 18px 16px; border-bottom: 1px solid var(--border); }
.profile-hero-avatar { flex: none; width: 108px; height: 108px; border-radius: 50%; object-fit: cover; object-position: 50% 15%; border: 3px solid var(--bg); box-shadow: 0 0 0 1px var(--border-strong); }
.profile-hero-text { min-width: 0; }
.profile-hero-text h1 { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--font-display); font-size: 26px; font-weight: 500; }
.profile-bio { margin: 8px 0 4px; }
.profile-meta { margin: 0; color: var(--text-dim); font-size: 13.5px; }
.profile-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn-ghost.strong { border-color: var(--text); color: var(--text); }
/* Character profile, Instagram-style: avatar + stats, bio, grid of posts */
.ig-head { display: flex; align-items: center; gap: 22px; padding: 18px 16px 6px; }
.ig-head .profile-hero-avatar { width: 92px; height: 92px; }
.ig-stats { flex: 1; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; text-align: center; }
.ig-stat { display: flex; flex-direction: column; min-width: 0; }
.ig-stat strong { font-size: 18px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ig-stat:last-child strong { font-size: 15.5px; line-height: 1.4; }
.ig-stat span { color: var(--text-dim); font-size: 12.5px; }
.ig-bio { padding: 6px 16px 14px; }
.ig-bio h1 { display: flex; align-items: center; gap: 8px; margin: 0; font-family: var(--font-display); font-size: 21px; font-weight: 500; }
.ig-bio .profile-meta { margin-top: 2px; }
.ig-bio .profile-bio { margin: 6px 0 0; }
.ig-bio .profile-actions { display: grid; grid-template-columns: 1fr 1fr; }
.ig-tabs { display: grid; grid-template-columns: 1fr 1fr; border-top: 1px solid var(--border); }
.ig-tab { display: flex; justify-content: center; padding: 11px 0 10px; border: 0; border-top: 2px solid transparent; margin-top: -1px; background: none; color: var(--text-dim); cursor: pointer; }
.ig-tab.active { border-top-color: var(--text); color: var(--text); }
.ig-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 2px; }
.ig-tile { position: relative; aspect-ratio: 4 / 5; padding: 0; border: 0; overflow: hidden; background: var(--surface-strong); color: var(--text); cursor: pointer; }
.ig-tile img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 20%; display: block; transition: filter 0.15s ease; }
.ig-tile:hover img { filter: brightness(0.88); }
.ig-lock { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; font-size: 12.5px; font-weight: 600; }
.ig-cf { position: absolute; top: 6px; right: 7px; color: #ffd98a; font-size: 13px; text-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); }
.profile-more { display: block; margin: 14px auto 18px; }

.bond { margin: 14px 16px; padding: 12px 14px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.bond-top { display: flex; justify-content: space-between; align-items: center; font-size: 14px; font-weight: 600; }
.bond-bar { position: relative; height: 6px; margin: 10px 0 8px; border-radius: 999px; background: var(--surface-strong); overflow: hidden; }
.bond-bar span { position: absolute; inset: 0 auto 0 0; border-radius: 999px; background: var(--accent-grad); }
.bond-foot { color: var(--text-dim); font-size: 12.5px; }

.chat-post-context { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 10px; margin: 0 14px; padding: 8px 12px; border: 1px solid rgba(216, 176, 140, 0.35); border-radius: 12px; background: rgba(216, 176, 140, 0.06); }
.chat-post-context-label { font-size: 11.5px; font-weight: 700; color: var(--gold); }
.chat-post-context-body { grid-column: 1; overflow: hidden; color: var(--text-dim); font-size: 13px; text-overflow: ellipsis; white-space: nowrap; }
.chat-post-context-clear { grid-column: 2; grid-row: 1 / span 2; align-self: center; background: none; border: 0; color: var(--text-faint); font-size: 20px; cursor: pointer; }
.message.shared-post { display: grid; gap: 4px; border: 1px solid rgba(216, 176, 140, 0.35); background: rgba(216, 176, 140, 0.07); box-shadow: none; color: var(--text); }
.shared-post-label { font-size: 11px; font-weight: 700; color: var(--gold); }
.shared-post-body { color: var(--text-dim); font-size: 13.5px; }

@media (min-width: 1100px) {
  .app-shell.feed-mode.chat-docked .chat-view { display: block; position: fixed; right: 24px; bottom: 0; z-index: 60; width: 400px; height: min(680px, calc(100vh - 32px)); }
  .app-shell.feed-mode.chat-docked .chat-sidebar,
  .app-shell.feed-mode.chat-docked .info-button { display: none; }
  /* 400px panel: the "Asian female, Engineer" line wraps beside the header
     buttons — show the phone's online / typing line instead. */
  .app-shell.feed-mode.chat-docked .chat-header-text .chat-meta-desc { display: none; }
  .app-shell.feed-mode.chat-docked .chat-header-text .chat-meta-status { display: inline; }
  .app-shell.feed-mode.chat-docked .chat-header.is-typing .chat-header-text .chat-meta-status { display: none; }
  .app-shell.feed-mode.chat-docked .chat { height: 100%; max-height: none; border-bottom: 0; border-radius: 18px 18px 0 0; background: var(--bg-raised); box-shadow: 0 -12px 60px rgba(0, 0, 0, 0.6); }
}

@media (max-width: 1099px) {
  .feed-layout { grid-template-columns: minmax(0, 640px); }
  .feed-rail { display: none; }
}

@media (max-width: 600px) {
  .topbar { flex-wrap: wrap; row-gap: 10px; }
  .topnav { order: 3; width: 100%; }
  .topnav-btn { flex: 1; }
  .app-shell.chat-mode .topnav { display: none; }
  .feed-main { margin: 0 -14px; border-left: 0; border-right: 0; border-radius: 0; }
  .profile-hero { flex-direction: column; }
  .profile-hero-avatar { width: 88px; height: 88px; }
}

/* ============================================================
   Chat thread details (all sizes): timestamps, read ticks,
   day chips, grouped bubbles
   ============================================================ */

.messages { gap: 2px; }
.message { margin-top: 10px; }
.message.grouped { margin-top: 2px; }
.message.character { padding-right: 15px; }

.day-chip {
  align-self: center;
  margin: 14px 0 4px;
  padding: 4px 12px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-dim);
  background: var(--surface-strong);
}

/* Time (and ticks / voice) sit in the bubble's bottom-right corner, on the
   last line when it fits, otherwise on a line of their own. */
.msg-meta {
  float: right;
  position: relative;
  top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 2px 0 0 12px;
  font-size: 11px;
  line-height: 1.6;
  white-space: nowrap;
  color: var(--text-faint);
}
.message.user .msg-meta { color: rgba(255, 255, 255, 0.82); }
.msg-ticks { flex: none; color: inherit; }
.conversation-last .msg-ticks { margin-right: 3px; vertical-align: -1px; color: var(--rose-soft); }

.msg-meta .msg-voice {
  position: static;
  width: 18px;
  height: 18px;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  opacity: 1;
}
.msg-meta .msg-voice svg { width: 13px; height: 13px; }

.notice-action {
  margin-top: 8px;
  padding: 7px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--rose);
  color: #fff;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
}

.chat-header-text .chat-meta-status,
.chat-header-text .chat-meta-typing { display: none; }
.chat-header.is-typing .chat-header-text .chat-meta-desc,
.chat-header.is-typing .chat-header-text .chat-meta-status { display: none; }
.chat-header.is-typing .chat-header-text .chat-meta-typing { display: inline; color: var(--rose-soft); }

.messages-head { display: contents; }
.messages-back { display: none; }

/* ============================================================
   Phones: WhatsApp-style full-screen chat and chats list.
   Follows the phone's light / dark setting.
   ============================================================ */

@media (max-width: 920px) {
  .app-shell.chat-mode,
  #messagesModal {
    --wa-bg: #0d0b12;
    --wa-wall: rgba(255, 255, 255, 0.035);
    --wa-bar: #17141f;
    --wa-in: #221e2c;
    --wa-out: #6e2339;
    --wa-text: #f3eef5;
    --wa-sub: #a89fb3;
    --wa-meta: rgba(243, 238, 245, 0.62);
    --wa-field: #221e2c;
    --wa-chip: #221e2c;
    --wa-tick: #ff8aa0;
    --wa-line: rgba(255, 255, 255, 0.08);
    --wa-press: rgba(255, 255, 255, 0.05);
    --wa-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.3);
  }

  /* full-screen chat: no site header, no card frame */
  .app-shell.chat-mode { padding: 0; background: var(--wa-bg); }
  .app-shell.chat-mode .topbar { display: none; }
  .app-shell.chat-mode .chat {
    margin: 0;
    border: 0;
    border-radius: 0;
    color: var(--wa-text);
    background: var(--wa-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

  .app-shell.chat-mode .chat-header {
    position: relative;
    gap: 8px;
    padding: calc(8px + env(safe-area-inset-top)) 4px 8px 2px;
    background: var(--wa-bar);
    border-bottom: 1px solid var(--wa-line);
  }
  .app-shell.chat-mode .back-button,
  .app-shell.chat-mode .chat-header-wallet .btn-ghost {
    border: 0;
    background: none;
    color: var(--wa-text);
    padding: 9px;
  }
  .app-shell.chat-mode .back-button { padding: 9px 2px 9px 6px; }
  .app-shell.chat-mode .back-button svg { width: 22px; height: 22px; }
  .app-shell.chat-mode .chat-avatar { width: 38px; height: 38px; border: 0; }
  .app-shell.chat-mode .chat-header-text { flex: 1; min-width: 0; }
  .app-shell.chat-mode .chat-header-text strong {
    overflow: hidden;
    font-family: var(--font-body);
    font-size: 16.5px;
    font-weight: 600;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--wa-text);
  }
  .app-shell.chat-mode .chat-header-text > span { font-size: 12.5px; color: var(--wa-sub); }
  .app-shell.chat-mode .chat-header-text .online-dot,
  .app-shell.chat-mode .chat-header-text .chat-meta-desc { display: none; }
  .app-shell.chat-mode .chat-header-text .chat-meta-status { display: inline; }
  .app-shell.chat-mode .chat-header.is-typing .chat-header-text .chat-meta-status { display: none; }
  .app-shell.chat-mode .chat-header.is-typing .chat-header-text .chat-meta-typing { color: var(--wa-tick); }
  .app-shell.chat-mode .chat-header-wallet { gap: 0; }
  .app-shell.chat-mode .chat-header-wallet .info-button { order: 3; }
  .app-shell.chat-mode .chat-header-wallet .btn-ghost svg { width: 20px; height: 20px; }

  /* daily check-in floats under the header's right edge, clear of the
     centred day chip */
  .app-shell.chat-mode .checkin-btn {
    position: absolute;
    top: calc(100% + 8px);
    right: 10px;
    z-index: 5;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  }
  .app-shell.chat-mode .checkin-btn:hover { transform: none; }

  /* thread */
  .app-shell.chat-mode .messages {
    padding: 6px 12px 10px;
    background-color: var(--wa-bg);
    background-image: radial-gradient(var(--wa-wall) 1px, transparent 1.5px);
    background-size: 20px 20px;
  }
  .app-shell.chat-mode .day-chip {
    position: sticky;
    top: 6px;
    z-index: 2;
    color: var(--wa-sub);
    background: var(--wa-chip);
    box-shadow: var(--wa-shadow);
  }
  .app-shell.chat-mode .message {
    position: relative;
    max-width: 82%;
    padding: 6px 9px 7px;
    border-radius: 10px;
    font-size: 15px;
    line-height: 1.4;
    color: var(--wa-text);
    box-shadow: var(--wa-shadow);
  }
  .app-shell.chat-mode .message.character { background: var(--wa-in); border: 0; }
  .app-shell.chat-mode .message.user { background: var(--wa-out); }
  .app-shell.chat-mode .message.photo { padding: 0; background: none; box-shadow: none; }

  /* tail on the first bubble of each run */
  .app-shell.chat-mode .message.character:not(.grouped):not(.photo):not(.typing) { border-top-left-radius: 0; }
  .app-shell.chat-mode .message.user:not(.grouped) { border-top-right-radius: 0; }
  .app-shell.chat-mode .message.character:not(.grouped):not(.photo):not(.typing)::before,
  .app-shell.chat-mode .message.user:not(.grouped)::before {
    content: "";
    position: absolute;
    top: 0;
    width: 8px;
    height: 13px;
  }
  .app-shell.chat-mode .message.character:not(.grouped):not(.photo):not(.typing)::before {
    left: -7px;
    background: var(--wa-in);
    clip-path: polygon(0 0, 100% 0, 100% 100%);
  }
  .app-shell.chat-mode .message.user:not(.grouped)::before {
    right: -7px;
    background: var(--wa-out);
    clip-path: polygon(0 0, 100% 0, 0 100%);
  }

  .app-shell.chat-mode .msg-meta,
  .app-shell.chat-mode .message.user .msg-meta { color: var(--wa-meta); }
  .app-shell.chat-mode .msg-ticks { color: var(--wa-tick); }

  .app-shell.chat-mode .message.notice {
    max-width: 88%;
    margin: 10px 0;
    padding: 7px 14px;
    border: 0;
    border-radius: 10px;
    font-size: 13px;
    color: var(--wa-sub);
    background: var(--wa-chip);
    box-shadow: var(--wa-shadow);
  }
  .app-shell.chat-mode .message.shared-post { border: 1px solid rgba(216, 176, 140, 0.45); }
  .app-shell.chat-mode .message.typing { background: var(--wa-in); }
  .app-shell.chat-mode .message.typing i { background: var(--wa-sub); }

  /* composer: rounded field + one round mic/send button */
  .app-shell.chat-mode .composer {
    gap: 6px;
    padding: 6px 8px calc(8px + env(safe-area-inset-bottom));
    background: var(--wa-bg);
    border-top: 0;
  }
  .app-shell.chat-mode .composer input,
  .app-shell.chat-mode .composer input:focus {
    order: 1;
    padding: 12px 18px;
    border: 0;
    border-radius: 24px;
    color: var(--wa-text);
    background: var(--wa-field);
    box-shadow: var(--wa-shadow);
  }
  .app-shell.chat-mode .composer input::placeholder { color: var(--wa-sub); }
  .app-shell.chat-mode .mic-btn,
  .app-shell.chat-mode .send-btn {
    order: 2;
    width: 48px;
    height: 48px;
    border: 0;
    color: #fff;
    background: var(--rose);
    box-shadow: var(--wa-shadow);
  }
  .app-shell.chat-mode .mic-btn svg { width: 22px; height: 22px; }
  .app-shell.chat-mode .mic-btn.listening { color: #fff; background: var(--rose); }
  .app-shell.chat-mode .composer.has-text .mic-btn,
  .app-shell.chat-mode .composer.no-mic .mic-btn,
  .app-shell.chat-mode .composer:not(.has-text):not(.no-mic) .send-btn { display: none; }
  .app-shell.chat-mode .chat-post-context { margin: 0 8px 4px; background: var(--wa-field); }

  /* chats list: full screen, WhatsApp-style rows */
  #messagesModal {
    align-items: stretch;
    padding: 0;
    background: var(--wa-bg);
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  #messagesModal .messages-modal {
    display: flex;
    flex-direction: column;
    max-width: none;
    height: 100%;
    padding: 0;
    border: 0;
    border-radius: 0;
    color: var(--wa-text);
    background: var(--wa-bg);
    box-shadow: none;
    animation: none;
  }
  #messagesModal .modal-close { display: none; }
  #messagesModal .messages-head {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: calc(10px + env(safe-area-inset-top)) 12px 10px 4px;
    background: var(--wa-bar);
    border-bottom: 1px solid var(--wa-line);
  }
  #messagesModal .messages-back {
    display: inline-flex;
    padding: 8px;
    border: 0;
    background: none;
    color: var(--wa-text);
    cursor: pointer;
  }
  #messagesModal h2 {
    margin: 0;
    font-family: var(--font-body);
    font-size: 21px;
    font-weight: 700;
    color: var(--wa-text);
  }
  #messagesModal .conversation-list {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding-bottom: env(safe-area-inset-bottom);
  }
  #messagesModal .conversation-row {
    grid-template-columns: 52px minmax(0, 1fr);
    gap: 14px;
    padding: 0 0 0 14px;
  }
  #messagesModal .conversation-row:active { background: var(--wa-press); }
  #messagesModal .feed-avatar.sm { width: 52px; height: 52px; }
  #messagesModal .conversation-main {
    gap: 3px;
    padding: 13px 14px 13px 0;
    border-bottom: 1px solid var(--wa-line);
  }
  #messagesModal .conversation-top strong { font-size: 16.5px; font-weight: 600; color: var(--wa-text); }
  #messagesModal .conversation-time { font-size: 12px; color: var(--wa-sub); }
  #messagesModal .conversation-last { font-size: 14.5px; color: var(--wa-sub); }
  #messagesModal .conversation-last .msg-ticks { color: var(--wa-tick); }
  #messagesModal .stage-chip { display: none; }
  #messagesModal .rail-empty { margin: 28px 20px; font-size: 14.5px; text-align: center; color: var(--wa-sub); }
}

@media (max-width: 920px) and (prefers-color-scheme: light) {
  .app-shell.chat-mode,
  #messagesModal {
    color-scheme: light;
    --wa-bg: #f4eef0;
    --wa-wall: rgba(120, 60, 80, 0.06);
    --wa-bar: #ffffff;
    --wa-in: #ffffff;
    --wa-out: #ffdce3;
    --wa-text: #1d1a22;
    --wa-sub: #6f6680;
    --wa-meta: rgba(29, 26, 34, 0.5);
    --wa-field: #ffffff;
    --wa-chip: #ffffff;
    --wa-tick: #d23a5a;
    --wa-line: rgba(0, 0, 0, 0.08);
    --wa-press: rgba(0, 0, 0, 0.04);
    --wa-shadow: 0 1px 0.5px rgba(0, 0, 0, 0.13);
  }
}
