:root {
  --bg: #0b0b0f;
  --bg2: #121218;
  --card: #18181f;
  --card-hover: #1e1e28;
  --text: #f2f2f5;
  --hint: #8b8b9a;
  --btn: #6c5ce7;
  --btn-hover: #7f71ef;
  --btn-text: #fff;
  --danger: #ff6b7a;
  --border: #2a2a36;
  --accent: #a78bfa;
  --sidebar-w: 72px;
  --sidebar-exp: 240px;
  --profile-w: 300px;
  --radius: 14px;
  /* Mobile browser chrome: JS sets --app-height from visualViewport; CSS falls back to dvh */
  --app-height: 100vh;
  --app-height: 100dvh;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --mobile-nav-h: 58px;
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  height: 100%;
  height: var(--app-height);
  max-height: var(--app-height);
}
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  min-height: var(--app-height);
  overflow: hidden;
}
.hidden { display: none !important; }

/* —— Landing (logged out) —— */
.view-login {
  min-height: var(--app-height);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  background:
    radial-gradient(ellipse 90% 60% at 80% 10%, color-mix(in srgb, var(--btn) 22%, transparent), transparent 55%),
    radial-gradient(ellipse 70% 50% at 10% 90%, color-mix(in srgb, #a855f7 14%, transparent), transparent 50%),
    var(--bg);
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
}
.landing {
  min-height: calc(var(--app-height) - var(--safe-top) - var(--safe-bottom));
  max-width: 1100px;
  margin: 0 auto;
  padding: 20px 24px 28px;
  display: flex;
  flex-direction: column;
}
.landing-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 0 20px;
}
.landing-top-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.landing-mark {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--btn) 40%, transparent);
}
.landing-brand {
  font-size: 1.05rem;
  letter-spacing: 0.01em;
}
/* Landing language switcher (top-right globe) */
.landing-lang {
  position: relative;
  flex-shrink: 0;
}
.landing-lang-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--border, #333) 80%, transparent);
  background: color-mix(in srgb, var(--panel, #16161c) 88%, transparent);
  color: var(--text);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.landing-lang-btn:hover,
.landing-lang-btn[aria-expanded="true"] {
  border-color: color-mix(in srgb, var(--btn, #7c5cff) 55%, transparent);
  background: color-mix(in srgb, var(--btn, #7c5cff) 12%, transparent);
}
.landing-lang-icon {
  flex-shrink: 0;
  opacity: 0.92;
}
.landing-lang-code {
  text-transform: uppercase;
  min-width: 1.5em;
}
.landing-lang-caret {
  font-size: 0.65rem;
  opacity: 0.7;
}
.landing-lang-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  min-width: 11.5rem;
  max-height: min(70vh, 22rem);
  overflow: auto;
  padding: 6px;
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--border, #333) 90%, transparent);
  background: color-mix(in srgb, var(--panel, #121218) 96%, #000);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  z-index: 200;
}
.landing-lang-menu.hidden {
  display: none;
}
.landing-lang-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: 0.92rem;
  text-align: left;
  cursor: pointer;
}
.landing-lang-item:hover {
  background: color-mix(in srgb, var(--btn, #7c5cff) 14%, transparent);
}
.landing-lang-item.active {
  background: color-mix(in srgb, var(--btn, #7c5cff) 22%, transparent);
  font-weight: 600;
}
.landing-lang-item .code {
  font-size: 0.72rem;
  opacity: 0.65;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
/* Divider between stable languages and beta (ru/ja/vi/ta/te) */
.landing-lang-beta,
.lang-beta-break {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 2px 4px;
  padding: 2px 6px;
  pointer-events: none;
  user-select: none;
}
.lang-beta-break {
  flex: 1 0 100%;
  margin: 8px 0 4px;
  padding: 0;
}
.landing-lang-beta::before,
.landing-lang-beta::after,
.lang-beta-break::before,
.lang-beta-break::after {
  content: "";
  flex: 1;
  height: 1px;
  background: color-mix(in srgb, var(--border, #333) 85%, transparent);
  opacity: 0.9;
}
.lang-beta-label {
  font-size: 0.62rem;
  font-weight: 650;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--hint, #888);
  opacity: 0.85;
  white-space: nowrap;
}
.landing-hero {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 0.85fr);
  gap: 40px 48px;
  align-items: center;
  padding: 12px 0 32px;
}
.landing-kicker {
  margin: 0 0 12px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent);
}
.landing-copy h1 {
  margin: 0 0 16px;
  font-size: clamp(1.85rem, 4vw, 2.65rem);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.landing-lead {
  margin: 0 0 20px;
  font-size: 1.05rem;
  line-height: 1.55;
  color: color-mix(in srgb, var(--text) 88%, var(--hint));
  max-width: 34em;
}
.landing-perks {
  margin: 0 0 28px;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.landing-perks li {
  position: relative;
  padding-left: 1.4em;
  color: var(--hint);
  font-size: 0.95rem;
  line-height: 1.4;
}
.landing-perks li::before {
  content: "✦";
  position: absolute;
  left: 0;
  color: var(--accent);
  font-size: 0.75rem;
  top: 0.2em;
}
.landing-cta {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 18px 18px 16px;
  background: color-mix(in srgb, var(--card) 88%, transparent);
  border: 1px solid var(--border);
  border-radius: 16px;
  max-width: 360px;
  backdrop-filter: blur(8px);
}
.login-widget {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
}
.landing-status { min-height: 1.2em; margin: 0; font-size: 0.88rem; }
.landing-fine { margin: 4px 0 0; line-height: 1.35; }
.landing-visual {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 320px;
}
.landing-orb {
  position: absolute;
  width: min(420px, 90%);
  aspect-ratio: 1;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--btn) 35%, transparent), transparent 55%),
    radial-gradient(circle at 70% 70%, color-mix(in srgb, #a855f7 25%, transparent), transparent 50%);
  filter: blur(2px);
  animation: landingPulse 8s ease-in-out infinite;
}
.landing-hero-img {
  position: relative;
  width: min(280px, 70%);
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 28px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.45),
    0 0 0 1px color-mix(in srgb, var(--btn) 30%, transparent);
}
@keyframes landingPulse {
  0%, 100% { transform: scale(1); opacity: 0.85; }
  50% { transform: scale(1.04); opacity: 1; }
}
.landing-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--border) 80%, transparent);
  font-size: 0.78rem;
  color: var(--hint);
}
.landing-foot-links { display: flex; gap: 14px; }
.muted { color: var(--hint); }
.small { font-size: 0.8rem; }

@media (max-width: 800px) {
  .landing-hero {
    grid-template-columns: 1fr;
    gap: 28px;
    padding-top: 8px;
  }
  .landing-visual {
    order: -1;
    min-height: 220px;
  }
  .landing-hero-img { width: min(200px, 55%); }
  .landing-cta { max-width: none; width: 100%; }
}

/* Guest legal overlay */
.landing-legal {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.landing-legal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
}
.landing-legal-sheet {
  position: relative;
  width: min(640px, 100%);
  max-height: min(80vh, 720px);
  overflow: auto;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 18px 18px 22px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
}
.landing-legal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.landing-legal-head h2 { margin: 0; font-size: 1.2rem; }
.landing-legal-head .icon-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: transparent;
  color: var(--hint);
  font-size: 1.4rem;
  cursor: pointer;
  border-radius: 10px;
}
.landing-legal-head .icon-btn:hover { color: var(--text); background: var(--bg); }
.landing-legal-body { max-width: none; }

/* SEO crawlable block on landing (quiet visual, real text for bots) */
.landing-seo {
  margin: 28px 0 8px;
  max-width: 36rem;
  padding: 0 2px;
}
.landing-seo-title {
  margin: 0 0 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
  opacity: 0.88;
}
.landing-seo-text {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: var(--hint);
}

/* Guest viewing #/privacy or #/terms without login */
body.guest-legal-mode {
  overflow: auto !important;
}
body.guest-legal-mode .sidebar {
  display: none !important;
}
body.guest-legal-mode .shell-main {
  width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
body.guest-legal-mode .main {
  max-width: 800px;
  margin: 0 auto;
  padding: 28px 20px 48px;
  overflow: auto;
  flex: 1;
  width: 100%;
}
body.guest-legal-mode .site-footer {
  display: flex;
}
body.guest-legal-mode .onboardBanner,
body.guest-legal-mode #onboardBanner {
  display: none !important;
}
body.guest-legal-mode .guest-legal-back {
  display: inline-flex !important;
  margin-bottom: 8px;
}
.guest-legal-back[hidden] {
  display: none !important;
}
.page-head-legal {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

/* —— Shell + auto-hide sidebar —— */
.shell {
  display: flex;
  height: var(--app-height);
  max-height: var(--app-height);
  width: 100%;
  overflow: hidden;
}
.sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 12px 8px;
  gap: 8px;
  transition: width 0.34s cubic-bezier(0.22, 0.61, 0.36, 1);
  z-index: 40;
  overflow: hidden;
}
.sidebar:hover,
.sidebar:focus-within {
  width: var(--sidebar-exp);
}
.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 8px 16px;
  min-height: 48px;
}
.brand-mark {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--btn), #a855f7);
  font-size: 1.1rem;
}
.brand-text {
  font-weight: 700;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.28s ease 0.04s;
}
.sidebar:hover .brand-text,
.sidebar:focus-within .brand-text {
  opacity: 1;
}
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}
.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: none;
  background: transparent;
  color: var(--text);
  border-radius: 12px;
  padding: 12px 10px;
  font: inherit;
  cursor: pointer;
  text-align: left;
  min-height: 48px;
}
.nav-item:hover { background: color-mix(in srgb, var(--btn) 18%, transparent); }
.nav-item.active {
  background: color-mix(in srgb, var(--btn) 28%, transparent);
  color: #fff;
}
.nav-item.logout { color: var(--hint); }
.nav-icon {
  width: 28px;
  flex-shrink: 0;
  text-align: center;
  font-size: 1.15rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.nav-icon-svg svg {
  width: 22px;
  height: 22px;
  display: block;
}
/* Support: quieter mark so Chat stays the primary conversation icon */
.nav-icon-subtle {
  opacity: 0.72;
}
.nav-item:hover .nav-icon-subtle,
.nav-item.active .nav-icon-subtle {
  opacity: 1;
}
.nav-label {
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.28s ease 0.04s;
  font-size: 0.95rem;
}
.sidebar:hover .nav-label,
.sidebar:focus-within .nav-label {
  opacity: 1;
}
.sidebar-foot {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sidebar-mgmt {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
/* Desktop: More toggle / sheet chrome hidden */
.mobile-more-toggle { display: none; }
.mobile-more-grab,
.mobile-more-title { display: none; }
.mobile-more-backdrop { display: none; }
.user-chip {
  font-size: 0.75rem;
  padding: 4px 10px;
  white-space: nowrap;
  opacity: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: opacity 0.28s ease 0.04s;
}
.sidebar:hover .user-chip,
.sidebar:focus-within .user-chip {
  opacity: 1;
}

.main {
  flex: 1;
  min-width: 0;
  overflow: auto;
  padding: 20px 24px 32px;
  background:
    radial-gradient(ellipse 80% 50% at 20% -10%, color-mix(in srgb, var(--btn) 18%, transparent), transparent),
    var(--bg);
}
.main:has(.page-chats-workspace:not(.hidden)),
.main:has(.page-companions-workspace:not(.hidden)) {
  padding: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* —— Pages —— */
.page-head { margin-bottom: 18px; }
.page-head.compact { margin-bottom: 8px; padding: 0 4px; }
.page-head h2 { margin: 0 0 4px; font-size: 1.45rem; }
.page-head.compact h2 { font-size: 1.05rem; margin: 0; }
.page-head .muted { margin: 0; }

.banner {
  background: color-mix(in srgb, var(--btn) 16%, var(--card));
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  margin: 12px 16px 0;
}
.banner p { margin: 0 0 10px; }

/* —— Website setup wizard (language → consent → interest → look) —— */
.setup-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(16px, var(--safe-top)) max(16px, var(--safe-right))
    max(16px, var(--safe-bottom)) max(16px, var(--safe-left));
  overflow: auto;
}
.setup-overlay.hidden {
  display: none !important;
}
.setup-overlay-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% 0%, color-mix(in srgb, var(--btn) 28%, transparent), transparent 55%),
    color-mix(in srgb, var(--bg) 82%, #000);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.setup-card {
  position: relative;
  z-index: 1;
  width: min(440px, 100%);
  margin: auto;
  padding: 28px 24px 22px;
  border-radius: 20px;
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--border) 90%, var(--btn));
  box-shadow:
    0 0 0 1px color-mix(in srgb, var(--btn) 12%, transparent),
    0 24px 64px rgba(0, 0, 0, 0.55);
  animation: setupCardIn 0.35s ease-out;
}
@keyframes setupCardIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.setup-step h2 {
  margin: 0 0 10px;
  font-size: 1.35rem;
  letter-spacing: -0.02em;
  line-height: 1.25;
}
.setup-kicker {
  margin: 0 0 8px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
}
.setup-lead {
  margin: 0 0 18px;
  line-height: 1.5;
  font-size: 0.95rem;
}
.setup-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 8px;
}
.setup-lang-chips {
  margin: 0 0 20px;
}
.setup-lang-chips .chip {
  min-width: calc(50% - 4px);
  justify-content: center;
}
.setup-terms {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: left;
  max-height: min(28vh, 200px);
  overflow: auto;
}
.setup-terms-h {
  margin: 0 0 8px;
  font-size: 0.9rem;
}
.setup-look-row {
  margin: 4px 0 16px;
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.setup-look-row textarea {
  flex: 1;
  min-height: 100px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  resize: vertical;
}
.setup-status {
  margin: 14px 0 0;
  min-height: 1.2em;
  font-size: 0.88rem;
  text-align: center;
}
.setup-status.err {
  color: var(--danger);
}
.setup-status.ok {
  color: #6ee7a8;
}
body.setup-active .sidebar,
body.setup-active .site-footer {
  pointer-events: none;
  user-select: none;
  opacity: 0.35;
}
body.setup-active .main > .page {
  pointer-events: none;
  user-select: none;
  opacity: 0.2;
  filter: blur(2px);
}

.global-status { min-height: 0; margin: 4px 16px; }
.empty { padding: 24px 12px; text-align: center; font-size: 0.85rem; }

/* —— Chat workspace (list | chat | profile) —— */
.page-chats-workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  margin: 0;
  padding: 0 !important;
}
.chat-workspace {
  display: grid;
  grid-template-columns: minmax(200px, 28%) minmax(0, 1fr) minmax(220px, 280px);
  flex: 1;
  min-height: 0;
  height: 100%;
  border-top: 1px solid var(--border);
}

.chat-list-pane {
  border-right: 1px solid var(--border);
  background: var(--bg2);
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding: 12px 8px;
  overflow: hidden;
}
.chats-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  max-width: none;
  padding-right: 2px;
}
/* Compact rows — ~half previous height */
.chat-row {
  display: flex;
  gap: 8px;
  align-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 6px 8px;
  cursor: pointer;
  text-align: left;
  color: inherit;
  font: inherit;
  width: 100%;
  transition: background 0.12s, border-color 0.12s;
  min-height: 0;
}
.chat-row:hover {
  background: var(--card);
  border-color: var(--border);
}
.chat-row.active {
  background: color-mix(in srgb, var(--btn) 18%, var(--card));
  border-color: color-mix(in srgb, var(--btn) 35%, var(--border));
}
.chat-row img,
.chat-row .chat-row-photo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: #1a1a24;
  flex-shrink: 0;
}
.chat-row-body { flex: 1; min-width: 0; }
.chat-row-top {
  display: flex;
  justify-content: space-between;
  gap: 6px;
  align-items: baseline;
  margin-bottom: 1px;
}
.chat-row-top strong { font-size: 0.88rem; font-weight: 600; }
.chat-row-top time { font-size: 0.68rem; color: var(--hint); white-space: nowrap; }
.chat-preview {
  font-size: 0.72rem;
  color: var(--hint);
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.25;
}
.chat-preview .role { color: var(--accent); font-weight: 600; }

/* Center conversation */
.chat-center-pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: var(--bg);
}
.chat-empty-state {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--hint);
}
.chat-empty-state.compact { min-height: 120px; flex: 0; padding: 24px; }
.chat-active {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* Right profile — scroll body, pin owner actions to bottom of pane */
.chat-profile-pane {
  border-left: 1px solid var(--border);
  background: var(--bg2);
  overflow: hidden;
  min-height: 0;
  min-width: 220px;
  display: flex;
  flex-direction: column;
}
.chat-profile {
  padding: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}
.chat-profile .profile-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 14px 14px 12px;
}
/* Never collapse the gallery block */
.chat-profile .profile-slideshow {
  display: block !important;
}

/* —— Companions workspace (grid | profile) —— */
.page-companions-workspace {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  margin: 0;
  padding: 0 !important;
}
.companions-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 280px);
  flex: 1;
  min-height: 0;
  height: 100%;
}
.companions-main {
  min-width: 0;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 24px 32px;
}
.companions-profile-pane {
  border-left: 1px solid var(--border);
  background: var(--bg2);
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* —— Companions toolbar (filter + search) —— */
.companions-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px 16px;
  margin: 0 0 16px;
  max-width: none;
}
.companions-filters { flex-wrap: wrap; }
.companions-search-wrap {
  flex: 1;
  min-width: min(100%, 220px);
  max-width: 360px;
}
.companions-search {
  width: 100%;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  padding: 9px 14px 9px 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%238b8b9a' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='7' cy='7' r='5'/%3E%3Cpath d='M11 11l3.5 3.5'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px 50%;
}
.companions-search::placeholder { color: var(--hint); }
.companions-search:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--btn) 55%, var(--border));
}

/* —— Companions grid —— */
.companions-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 14px;
}
.comp-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  cursor: pointer;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.comp-card:hover {
  border-color: color-mix(in srgb, var(--btn) 40%, var(--border));
}
.comp-card.selected {
  border-color: color-mix(in srgb, var(--btn) 65%, var(--border));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--btn) 35%, transparent);
}
.comp-card img,
.comp-card .comp-card-img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  background: #222;
}
.comp-meta { padding: 10px 12px 8px; flex: 1; }
.comp-name-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}
.comp-meta .name {
  font-weight: 600;
  font-size: 0.98rem;
  line-height: 1.25;
  min-width: 0;
  flex: 1;
}
.comp-card-icons {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
  margin-top: -2px;
}
.comp-card-icons .icon-btn {
  width: 30px;
  height: 30px;
  border: none;
  background: transparent;
  color: var(--hint);
  border-radius: 8px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.comp-card-icons .icon-btn svg {
  width: 16px;
  height: 16px;
  display: block;
}
.comp-card-icons .icon-btn:hover {
  color: var(--text);
  background: color-mix(in srgb, var(--btn) 16%, transparent);
}
.comp-card-icons .icon-btn.danger:hover {
  color: #ff8a8a;
  background: color-mix(in srgb, #e55 14%, transparent);
}
.profile-owner-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin: 0;
  padding: 10px 14px 14px;
  border-top: 1px solid var(--border);
  background: color-mix(in srgb, var(--bg2) 92%, var(--panel, #16161c));
  /* Stay pinned under scrollable profile content */
  position: sticky;
  bottom: 0;
  z-index: 2;
}
.profile-owner-actions.hidden {
  display: none !important;
}
.profile-owner-actions .btn {
  flex: 1 1 auto;
  min-width: 7rem;
}
.profile-owner-actions .owner-icon-row {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
}
.profile-owner-actions .icon-btn {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.profile-owner-actions .icon-btn svg {
  width: 17px;
  height: 17px;
}
.profile-owner-actions .icon-btn:hover {
  background: color-mix(in srgb, var(--btn) 14%, transparent);
}
.profile-owner-actions .icon-btn.danger:hover {
  color: #ff8a8a;
  background: color-mix(in srgb, #e55 14%, transparent);
}
.comp-meta .blurb {
  font-size: 0.78rem;
  color: var(--hint);
  margin-top: 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.pill {
  display: inline-block;
  font-size: 0.65rem;
  padding: 2px 6px;
  border-radius: 6px;
  background: color-mix(in srgb, var(--btn) 35%, transparent);
  margin-bottom: 4px;
  margin-right: 4px;
}
.comp-actions {
  display: flex;
  gap: 6px;
  padding: 0 10px 12px;
}
.comp-actions .btn { flex: 1; padding: 8px 6px; font-size: 0.85rem; }

@media (max-width: 900px) {
  .companions-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
  }
  .companions-profile-pane {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 42vh;
  }
}

/* —— Chat conversation pane —— */
.chatroom-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  background: var(--bg2);
  flex-shrink: 0;
}
.chatroom-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.chatroom-title strong { display: block; font-size: 0.98rem; }
.chatroom-title .muted {
  margin: 1px 0 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 36vw;
}
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #1a1a24;
  flex-shrink: 0;
}
.chat-row-photo {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  object-fit: cover;
  background: #1a1a24;
  flex-shrink: 0;
}
.chat-thread {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.chat-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 0;
  scroll-behavior: auto;
}
/* Jump-to-latest when user has scrolled up */
.chat-jump-down {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  z-index: 5;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--card) 92%, var(--btn));
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.12s;
}
.chat-jump-down:hover {
  background: color-mix(in srgb, var(--btn) 40%, var(--card));
  transform: translateX(-50%) translateY(-1px);
}
.chat-jump-down.hidden {
  display: none !important;
}
.bubble {
  max-width: min(78%, 480px);
  padding: 8px 12px;
  border-radius: 14px;
  font-size: 0.92rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}
.bubble.assistant {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom-left-radius: 5px;
}
.bubble.user {
  align-self: flex-end;
  background: color-mix(in srgb, var(--btn) 55%, #2a2050);
  border-bottom-right-radius: 5px;
}
.bubble.system {
  align-self: center;
  font-size: 0.78rem;
  color: var(--hint);
  background: transparent;
  max-width: 90%;
}
.chat-compose {
  display: flex;
  gap: 8px;
  padding: 10px 12px 12px;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  align-items: flex-end;
  flex-shrink: 0;
  /* Keep above iOS home indicator / browser chrome on desktop too (no-op if 0) */
  padding-bottom: max(12px, var(--safe-bottom));
  padding-left: max(12px, var(--safe-left));
  padding-right: max(12px, var(--safe-right));
}
.chat-compose textarea {
  flex: 1;
  resize: none;
  min-height: 40px;
  max-height: 120px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}
.chat-compose textarea:focus {
  outline: none;
  border-color: color-mix(in srgb, var(--btn) 60%, var(--border));
}

/* Profile slideshow — sticky so long bios don't push the gallery out of view */
.profile-slideshow {
  position: sticky;
  top: 0;
  z-index: 2;
  width: 100%;
  min-height: 180px;
  margin-bottom: 12px;
  border-radius: 12px;
  overflow: hidden;
  cursor: zoom-in;
  background: #111;
  user-select: none;
  flex-shrink: 0;
}
.profile-photo {
  width: 100%;
  min-height: 180px;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  background: #1a1a24;
  margin: 0;
}
.slide-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 40px;
  border: none;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
}
.profile-slideshow:hover .slide-nav { opacity: 1; }
.slide-nav:hover { background: rgba(0, 0, 0, 0.7); }
.slide-nav.prev { left: 6px; }
.slide-nav.next { right: 6px; }
.slide-nav.hidden { display: none; }
.slide-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  display: flex;
  justify-content: center;
  gap: 5px;
  pointer-events: none;
  z-index: 2;
}
.slide-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
}
.slide-dot.active { background: #fff; }
.slide-hint {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0, 0, 0, 0.45);
  padding: 2px 8px;
  border-radius: 6px;
  opacity: 0;
  transition: opacity 0.15s;
  pointer-events: none;
}
.profile-slideshow:hover .slide-hint { opacity: 1; }

.chat-profile h3 { margin: 0 0 4px; font-size: 1.1rem; }
.profile-blurb { margin: 8px 0 6px; font-size: 0.88rem; line-height: 1.4; }
.profile-body {
  font-size: 0.8rem;
  line-height: 1.4;
  white-space: pre-wrap;
  /* Full text scrolls with .profile-scroll; no inner max-height clip */
  max-height: none;
  overflow: visible;
  margin-bottom: 4px;
}

/* Fullscreen lightbox */
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 12px;
  padding: 48px 64px 56px;
}
.lightbox img {
  max-width: 100%;
  max-height: calc(100vh - 100px);
  object-fit: contain;
  border-radius: 4px;
  user-select: none;
}
.lightbox-close {
  position: absolute;
  top: 12px;
  right: 16px;
  width: 44px;
  height: 44px;
  border: none;
  background: transparent;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
}
.lightbox-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 52px;
  height: 64px;
  border: none;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
}
.lightbox-nav:hover { background: rgba(255, 255, 255, 0.16); }
.lightbox-nav.prev { left: 12px; }
.lightbox-nav.next { right: 12px; }
.lightbox-meta {
  position: absolute;
  bottom: 16px;
  left: 0;
  right: 0;
  text-align: center;
  color: #ddd;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  pointer-events: none;
}
/* Same dot style as profile card (override absolute positioning from .slide-dots). */
.lightbox-dots {
  position: static;
  left: auto;
  right: auto;
  bottom: auto;
  display: flex;
  justify-content: center;
  gap: 7px;
  pointer-events: none;
  z-index: auto;
}
.lightbox-dots .slide-dot {
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.35);
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.25);
}
.lightbox-dots .slide-dot.active {
  background: #fff;
  transform: scale(1.15);
}
.lightbox-hint {
  opacity: 0.65;
  font-size: 0.78rem;
}

/* —— Forms / settings —— */
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 16px;
  max-width: 520px;
}
.create-form label {
  display: block;
  margin-bottom: 12px;
  font-size: 0.85rem;
  color: var(--hint);
}
.create-form input,
.create-form select,
.create-form textarea,
.settings-block textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}
.settings-block { margin: 16px 0; }
.settings-block .label {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--hint);
}
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid color-mix(in srgb, var(--hint) 35%, transparent);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 0.9rem;
  cursor: pointer;
  font: inherit;
}
.chip.active {
  background: var(--btn);
  border-color: transparent;
  color: var(--btn-text);
}
.actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 12px; }
.actions.col { flex-direction: column; align-items: stretch; max-width: 280px; }

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--text);
  border-radius: 10px;
  padding: 10px 14px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.btn.primary { background: var(--btn); border-color: transparent; color: var(--btn-text); }
.btn.primary:hover { background: var(--btn-hover); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 6px 10px; font-size: 0.85rem; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:hover:not(:disabled) { filter: brightness(1.06); }

.status { min-height: 1.2em; font-size: 0.9rem; color: var(--hint); margin: 8px 0; }
.status.err { color: var(--danger); }

/* —— Mobile / tablet —— */
@media (max-width: 1100px) {
  .chat-workspace {
    grid-template-columns: minmax(180px, 32%) minmax(0, 1fr) minmax(200px, 240px);
  }
}
@media (max-width: 900px) {
  .chat-workspace {
    grid-template-columns: minmax(160px, 38%) minmax(0, 1fr);
  }
  .chat-profile-pane { display: none; }
  .companions-workspace {
    grid-template-columns: 1fr;
  }
  .companions-profile-pane {
    border-left: none;
    border-top: 1px solid var(--border);
    max-height: 40vh;
  }
}

/* Phones + narrow mobile browsers */
@media (max-width: 768px) {
  html, body {
    height: var(--app-height);
    max-height: var(--app-height);
    overflow: hidden;
    /* Prevent iOS from scrolling the document when the keyboard opens */
    overscroll-behavior: none;
    touch-action: pan-y;
  }
  body {
    overflow: hidden;
    position: fixed;
    inset: 0;
    width: 100%;
  }

  .shell {
    flex-direction: column;
    height: var(--app-height);
    max-height: var(--app-height);
    overflow: hidden;
    padding-top: var(--safe-top);
    /* Shell fills the fixed body — no page scroll */
    position: absolute;
    inset: 0;
    width: 100%;
  }

  /* Content first; nav docks to bottom (thumb zone, always visible) */
  .shell-main {
    order: 1;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    width: 100%;
  }
  .sidebar {
    order: 2;
    width: 100% !important;
    max-width: 100%;
    height: calc(var(--mobile-nav-h) + var(--safe-bottom));
    min-height: calc(var(--mobile-nav-h) + var(--safe-bottom));
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: stretch;
    justify-content: flex-start;
    gap: 2px;
    border-right: none;
    border-bottom: none;
    border-top: 1px solid var(--border);
    padding: 4px 4px calc(4px + var(--safe-bottom));
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    background: var(--bg2);
    z-index: 60;
    flex-shrink: 0;
  }
  .sidebar::-webkit-scrollbar { display: none; }
  .sidebar-brand {
    display: none; /* free space for nav icons */
  }
  .sidebar-nav {
    flex-direction: row;
    flex-wrap: nowrap;
    flex: 1 1 auto;
    gap: 2px;
    min-width: 0;
    justify-content: space-around;
  }
  .sidebar-foot {
    flex-direction: row;
    flex-wrap: nowrap;
    flex: 0 0 auto;
    border-top: none;
    border-left: 1px solid var(--border);
    padding: 0 0 0 4px;
    gap: 2px;
    align-items: stretch;
  }
  .user-chip { display: none !important; }

  /* Primary bar: Chat / Companions / Create + More only */
  .mobile-more-toggle {
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 52px;
    max-width: 72px;
    min-height: 48px;
    padding: 4px 6px;
    border-radius: 10px;
  }
  .mobile-more-toggle .nav-icon {
    font-size: 1.35rem;
    line-height: 1;
    letter-spacing: 0.05em;
  }

  /* Management set slides up as a bottom sheet */
  .sidebar-mgmt {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: min(72vh, 420px);
    padding: 8px 12px calc(16px + var(--safe-bottom));
    background: var(--bg2);
    border: 1px solid var(--border);
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    transform: translateY(110%);
    transition: transform 0.3s cubic-bezier(0.22, 0.61, 0.36, 1);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    pointer-events: none;
  }
  body.mobile-more-open .sidebar-mgmt {
    transform: translateY(0);
    pointer-events: auto;
  }
  .mobile-more-grab {
    display: block;
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: color-mix(in srgb, var(--hint) 45%, transparent);
    margin: 4px auto 8px;
  }
  .mobile-more-title {
    display: block;
    margin: 0 4px 8px;
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--hint);
    letter-spacing: 0.02em;
    text-transform: uppercase;
  }
  .sidebar-mgmt .nav-item {
    flex-direction: row;
    justify-content: flex-start;
    gap: 12px;
    min-width: 0;
    max-width: none;
    width: 100%;
    min-height: 48px;
    padding: 12px 14px;
    border-radius: 12px;
    text-align: left;
  }
  .sidebar-mgmt .nav-label {
    display: block !important;
    opacity: 1 !important;
    font-size: 0.95rem;
    max-width: none;
    overflow: visible;
  }
  .sidebar-mgmt .nav-icon {
    width: 28px;
    font-size: 1.15rem;
    text-align: center;
  }
  .sidebar-mgmt .nav-item.logout {
    margin-top: 6px;
    border-top: 1px solid var(--border);
    border-radius: 0 0 12px 12px;
    color: var(--hint);
  }

  .mobile-more-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 85;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    -webkit-tap-highlight-color: transparent;
  }
  body.mobile-more-open .mobile-more-backdrop {
    opacity: 1;
    pointer-events: auto;
  }
  body.mobile-more-open {
    /* sheet open: still lock page scroll */
    overflow: hidden;
  }

  .nav-item {
    flex-direction: column;
    justify-content: center;
    gap: 2px;
    min-width: 52px;
    max-width: 72px;
    min-height: 48px;
    padding: 4px 6px;
    border-radius: 10px;
  }
  .nav-icon { width: 22px; font-size: 1.05rem; }
  .nav-icon-svg svg { width: 20px; height: 20px; }
  .nav-label {
    display: block !important;
    opacity: 1 !important;
    font-size: 0.62rem;
    line-height: 1.1;
    white-space: nowrap;
    max-width: 4.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-item.logout .nav-label { font-size: 0.58rem; }

  .main {
    padding: 12px 12px calc(12px + var(--safe-bottom));
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
  .main:has(.page-chats-workspace:not(.hidden)),
  .main:has(.page-companions-workspace:not(.hidden)) {
    padding: 0;
    overflow: hidden;
    display: flex;
    flex-direction: column;
  }

  .page-chats-workspace,
  .page-companions-workspace {
    flex: 1;
    min-height: 0;
    height: 100%;
    max-height: 100%;
  }

  .chat-workspace {
    grid-template-columns: 1fr;
    height: 100%;
    min-height: 0;
    max-height: 100%;
  }

  /* Conversation list when idle */
  .chat-list-pane {
    max-height: none;
    height: 100%;
    min-height: 0;
    border-right: none;
    border-bottom: none;
  }

  /* Open chat: hide list so compose fits above browser chrome + bottom nav */
  .chat-workspace:has(#chatActive:not(.hidden)) .chat-list-pane {
    display: none;
  }
  .chat-center-pane {
    min-height: 0;
    height: 100%;
    max-height: 100%;
  }
  .chat-active {
    height: 100%;
    min-height: 0;
    max-height: 100%;
  }
  .chat-thread {
    flex: 1;
    min-height: 0;
  }
  .chat-messages {
    padding: 12px 12px 8px;
  }
  .chat-compose {
    padding: 8px 10px;
    padding-bottom: max(8px, var(--safe-bottom));
    /* Bottom nav is in flow below shell-main — no extra offset needed */
  }
  .chat-compose textarea {
    font-size: 16px; /* avoid iOS zoom on focus */
    min-height: 44px;
  }
  .chat-compose .btn {
    min-height: 44px;
    padding: 10px 14px;
  }

  /* Companions: stack; keep profile usable */
  .companions-workspace {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    height: 100%;
  }
  .companions-main {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 12px 12px 16px;
  }
  .companions-profile-pane {
    max-height: min(42vh, 340px);
    border-top: 1px solid var(--border);
  }

  .site-footer {
    display: none; /* use Terms in bottom nav; frees vertical space */
  }

  .bubble { max-width: 88%; }
  .lightbox {
    padding: 40px 12px calc(48px + var(--safe-bottom));
  }
  .lightbox-nav { width: 40px; height: 48px; font-size: 1.5rem; }
  .lightbox-meta {
    bottom: max(12px, var(--safe-bottom));
  }

  .page-head h2 { font-size: 1.25rem; }
  .create-wizard-2col,
  .settings-layout {
    grid-template-columns: 1fr;
  }
}

/* —— Chat list (comfortable — ~2× the ultra-tiny size) —— */
.chat-list-pane { padding: 10px 8px; }
.page-head.compact h2 { font-size: 1.05rem; }
.chats-list { gap: 4px; }
.chat-row {
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  min-height: 0;
}
.chat-row img {
  width: 48px;
  height: 48px;
  border-radius: 10px;
}
.chat-row-top strong { font-size: 0.92rem; font-weight: 600; }
.chat-row-top time { font-size: 0.72rem; }
.chat-preview {
  font-size: 0.78rem;
  line-height: 1.3;
  -webkit-line-clamp: 2;
}
.chatroom-head {
  justify-content: space-between;
}
.chatroom-head .icon-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--hint) 30%, transparent);
  background: transparent;
  color: var(--hint);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.chatroom-head .icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.chatroom-head .icon-btn:hover {
  color: #ff8a8a;
  border-color: color-mix(in srgb, #e55 50%, transparent);
}
.chatroom-head .icon-btn.danger:hover {
  color: #ff8a8a;
}
.btn.danger {
  background: transparent;
  border-color: color-mix(in srgb, #e55 55%, var(--hint));
  color: #ff8a8a;
}
.btn.danger:hover { background: color-mix(in srgb, #e55 18%, transparent); }
.btn.block { width: 100%; display: flex; }
.create-form-actions {
  display: flex;
  gap: 10px;
  align-items: stretch;
  margin-top: 4px;
}
.create-form-actions #btnCreateBack {
  flex: 0 0 auto;
  min-width: 5.5rem;
  align-self: stretch;
}
.create-form-actions #btnCreateBack[hidden] {
  display: none !important;
}
.create-form-actions #btnPreview {
  flex: 1;
  width: auto;
  min-width: 0;
}

/* Settings (miniapp parity) */
.settings-panel { max-width: 520px; }
.settings-card p { margin: 0.35em 0; font-size: 0.95rem; }
.settings-gender-block { margin: 16px 0; }
.settings-photo-label {
  margin: 0 0 8px;
  font-size: 0.85rem;
  color: var(--hint);
}
.col-actions { flex-direction: column; align-items: stretch; max-width: 320px; gap: 8px; margin: 12px 0; }
.col-actions .btn { width: 100%; }
.tip { margin-top: 8px; font-size: 0.8rem; color: var(--hint); }
.settings-photo-wrap {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--hint) 22%, transparent);
}
.settings-photo {
  width: 100%;
  max-width: 220px;
  aspect-ratio: 2 / 3;
  object-fit: contain;
  object-position: center top;
  border-radius: 12px;
  background: #111;
  display: block;
  margin: 0 auto 10px;
  border: 1px solid color-mix(in srgb, var(--hint) 25%, transparent);
}
.settings-look-text {
  font-size: 0.85rem;
  margin: 8px 0 10px;
  line-height: 1.4;
  white-space: pre-wrap;
}
.settings-look-editor { margin-top: 10px; }
.look-edit-row textarea { min-height: 72px; }

/* Terms */
.terms-panel { max-width: 560px; }
.terms-list {
  margin: 0;
  padding: 0 0 0 1.15em;
  font-size: 0.9rem;
  color: var(--hint);
  line-height: 1.5;
}
.terms-list li { margin-bottom: 10px; }

/* Create wizard */
.create-wizard { max-width: 560px; }
.field-label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.85rem;
  color: var(--hint);
}
.field-label input {
  display: block;
  width: 100%;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}
.field-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-top: 6px;
}
.field-row input,
.field-row textarea {
  flex: 1;
  margin-top: 0;
  min-width: 0;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
}
.icon-btn {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--hint) 30%, transparent);
  background: transparent;
  color: var(--hint);
  font-size: 1.1rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { color: var(--text); border-color: color-mix(in srgb, var(--btn) 50%, transparent); }
.icon-btn.busy, .field-random.busy { opacity: 0.45; pointer-events: none; }
textarea.is-thinking {
  opacity: 0.85;
  font-style: italic;
  color: var(--muted, #9a9aab);
}

.card-section {
  margin: 12px 0;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--card);
  border: 1px solid color-mix(in srgb, var(--hint) 22%, transparent);
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.section-title { margin: 0; font-size: 1.05rem; font-weight: 650; }
.section-tip { margin: 6px 0 10px; font-size: 0.85rem; color: var(--hint); }

.picker-list { display: flex; flex-direction: column; gap: 6px; }
.picker-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--hint) 28%, transparent);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.picker-label { font-weight: 550; }
.picker-value {
  color: var(--hint);
  font-size: 0.92rem;
  max-width: 55%;
  text-align: right;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.picker-value.has-val { color: var(--text); font-weight: 500; }
.picker-row::after {
  content: "›";
  color: var(--hint);
  font-size: 1.2rem;
  margin-left: 2px;
}

.preset-track {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  padding: 4px 2px 12px;
  margin: 0 -4px;
}
.preset-track::-webkit-scrollbar { display: none; }
.preset-card {
  flex: 0 0 78%;
  max-width: 280px;
  scroll-snap-align: center;
  padding: 14px;
  border-radius: 14px;
  border: 1.5px solid color-mix(in srgb, var(--hint) 30%, transparent);
  background: var(--bg);
  cursor: pointer;
  color: inherit;
  font: inherit;
  text-align: left;
}
.preset-card.selected {
  border-color: var(--btn);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--btn) 40%, transparent);
}
.preset-card h4 { margin: 0 0 6px; font-size: 1.05rem; }
.preset-card .preset-range {
  font-size: 0.72rem;
  color: var(--hint);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.preset-card p {
  margin: 0;
  font-size: 0.88rem;
  color: color-mix(in srgb, var(--text) 88%, var(--hint));
  line-height: 1.35;
}
.preset-caption {
  margin: 0 0 10px;
  font-size: 0.85rem;
  color: var(--hint);
  min-height: 1.2em;
}

.create-preview {
  max-width: 420px;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 16px;
  margin-top: 12px;
}
.create-preview .detail-photo {
  width: 100%;
  max-height: 360px;
  object-fit: cover;
  border-radius: 12px;
  background: #222;
  display: block;
}
.create-preview h3 { margin: 12px 0 6px; }
.create-preview .profile {
  font-size: 0.9rem;
  color: var(--hint);
  line-height: 1.4;
  white-space: pre-wrap;
}

/* Bottom sheet */
.sheet {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}
.sheet-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.sheet-panel {
  position: relative;
  max-height: min(72vh, 560px);
  overflow: auto;
  padding: 8px 14px 18px;
  border-radius: 18px 18px 0 0;
  background: var(--bg2);
  border: 1px solid color-mix(in srgb, var(--hint) 25%, transparent);
  border-bottom: none;
}
.sheet-handle {
  width: 40px;
  height: 4px;
  border-radius: 99px;
  background: color-mix(in srgb, var(--hint) 50%, transparent);
  margin: 4px auto 12px;
}
.sheet-title { margin: 0 0 12px; font-size: 1.1rem; text-align: center; }
.sheet-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
  justify-content: center;
}
.sheet-chip {
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid color-mix(in srgb, var(--hint) 35%, transparent);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.92rem;
  cursor: pointer;
}
.sheet-chip.active {
  border-color: var(--btn);
  background: color-mix(in srgb, var(--btn) 22%, var(--bg));
  font-weight: 600;
}

/* Confirm modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 150;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
}
.modal-sheet {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 20px 18px 16px;
}
.modal-sheet h3 { margin: 0 0 8px; font-size: 1.1rem; }
.confirm-body { margin: 0 0 16px; font-size: 0.92rem; line-height: 1.4; }
.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.modal-actions .btn.danger {
  background: color-mix(in srgb, #e55 70%, #400);
  border-color: transparent;
  color: #fff;
}

.bubble-text { white-space: pre-wrap; }
.bubble-photo {
  display: block;
  max-width: min(260px, 70vw);
  max-height: 360px;
  width: auto;
  height: auto;
  min-height: 80px;
  border-radius: 12px;
  margin-top: 8px;
  cursor: zoom-in;
  background: #111;
  object-fit: cover;
}
.bubble.user .bubble-photo { margin-left: auto; }
.bubble-photo.is-broken {
  opacity: 0.55;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  margin: 0;
  border: none;
}
.bubble.assistant {
  max-width: min(78%, 520px);
}

/* Lightbox photo actions (Mini App parity) */
.lightbox-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 8px 0 4px;
}
.lightbox-actions .btn {
  min-width: 0;
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
  color: #fff;
}
.lightbox-actions .btn:hover { background: rgba(255,255,255,0.18); }
.lightbox-actions .btn.danger {
  border-color: color-mix(in srgb, #e55 60%, #fff);
  color: #ffb0b0;
}
.lightbox-actions .btn:disabled {
  opacity: 0.35;
  pointer-events: none;
}
.lightbox-meta {
  max-width: 96vw;
  padding: 0 12px;
}
/* Scene generate modal (Mini App parity) */
.scene-modal-sheet {
  max-width: 520px;
  width: min(96vw, 520px);
}
.scene-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.scene-title-row h3 {
  margin: 0;
  flex: 1;
  min-width: 0;
}
.modal-hint { margin: 0 0 12px; font-size: 0.85rem; color: var(--hint); }
.scene-input-row {
  display: flex;
  gap: 8px;
  align-items: flex-start;
}
.scene-input-row textarea,
#sceneInput {
  flex: 1;
  width: 100%;
  min-height: 200px;
  height: 220px;
  margin: 0;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  line-height: 1.45;
  padding: 12px 14px;
  resize: vertical;
}
.scene-random {
  flex-shrink: 0;
  margin-top: 4px;
}
.scene-random.busy {
  opacity: 0.5;
  pointer-events: none;
}
/* Secret mature toggle — no NSFW label */
.secret-toggle {
  flex-shrink: 0;
  border: none;
  background: transparent;
  padding: 4px;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.15s ease;
}
.secret-toggle:hover,
.secret-toggle:focus-visible {
  opacity: 0.85;
  outline: none;
}
.secret-toggle[aria-pressed="true"] { opacity: 1; }
.secret-toggle-track {
  display: block;
  width: 36px;
  height: 20px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--hint) 35%, transparent);
  border: 1px solid color-mix(in srgb, var(--hint) 40%, transparent);
  position: relative;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.secret-toggle[aria-pressed="true"] .secret-toggle-track {
  background: color-mix(in srgb, var(--btn) 55%, #222);
  border-color: color-mix(in srgb, var(--btn) 50%, transparent);
}
.secret-toggle-knob {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text);
  opacity: 0.7;
  transition: transform 0.15s ease, opacity 0.15s ease, background 0.15s ease;
}
.secret-toggle[aria-pressed="true"] .secret-toggle-knob {
  transform: translateX(16px);
  opacity: 1;
  background: #fff;
}

/* —— Brand logo —— */
.brand-logo {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  object-fit: cover;
  flex-shrink: 0;
  background: #111;
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--btn) 35%, transparent);
}
.brand-mark { display: none; } /* replaced by logo image */
.login-logo {
  width: 96px;
  height: 96px;
  border-radius: 24px;
  object-fit: cover;
  display: block;
  margin: 0 auto 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.35);
}

/* Shell main + footer */
.shell-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.shell-main .main {
  flex: 1;
  min-height: 0;
}
.site-footer {
  flex-shrink: 0;
  border-top: 1px solid var(--border);
  background: var(--bg2);
  padding: 10px 16px 12px;
  font-size: 0.78rem;
  color: var(--hint);
}
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  max-width: 1200px;
}
.footer-start {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  min-width: 0;
}
.footer-copy {
  line-height: 1.35;
}
/* App footer language: fixed menu so it sits above bottom nav / sidebar */
.footer-lang {
  position: relative;
  flex-shrink: 0;
  z-index: 5;
}
.footer-lang-btn {
  padding: 5px 10px;
  font-size: 0.75rem;
}
.footer-lang-menu {
  /* position/size set in JS (fixed) so it is not clipped by .shell-main
     or painted under the mobile bottom nav (z-index 60). */
  position: fixed;
  top: auto;
  right: auto;
  left: auto;
  bottom: auto;
  z-index: 220;
  max-height: min(50vh, 18rem);
}
body.footer-lang-open .sidebar {
  /* keep nav visible but under the language menu */
  z-index: 60;
}
body.footer-lang-open .mobile-more-backdrop,
body.footer-lang-open .sidebar-mgmt {
  z-index: 70;
}
.footer-links { display: flex; gap: 12px; }
a.footer-link {
  text-decoration: none;
  color: inherit;
  background: none;
  border: none;
  font: inherit;
  cursor: pointer;
  padding: 0;
}
.landing-foot-links a.footer-link {
  color: var(--hint);
}
.landing-foot-links a.footer-link:hover {
  color: var(--text);
}
.footer-link {
  appearance: none;
  border: none;
  background: none;
  color: var(--accent, #a78bfa);
  font: inherit;
  font-size: 0.78rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.footer-link:hover { color: var(--text); }

/* Settings two columns */
.settings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(240px, 340px);
  gap: 16px;
  align-items: start;
  max-width: 960px;
}
.settings-col-right {
  position: sticky;
  top: 12px;
}
.settings-panel { max-width: none; }

/* Create two columns */
.create-wizard-2col {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  max-width: 1100px;
}
.create-wizard-2col .create-left,
.create-wizard-2col .create-right {
  min-width: 0;
}
.create-wizard { max-width: none; }

/* Legal / privacy */
.legal-panel {
  max-width: 720px;
  line-height: 1.55;
  font-size: 0.92rem;
  color: color-mix(in srgb, var(--text) 92%, var(--hint));
}
.legal-panel h3 {
  margin: 1.4em 0 0.5em;
  font-size: 1.05rem;
  color: var(--text);
}
.legal-panel h3:first-child { margin-top: 0; }
.legal-panel p { margin: 0 0 0.75em; }
.legal-panel ul {
  margin: 0 0 0.9em;
  padding-left: 1.2em;
}
.legal-panel li { margin-bottom: 0.4em; }

@media (max-width: 900px) {
  .settings-layout,
  .create-wizard-2col {
    grid-template-columns: 1fr;
  }
  .settings-col-right { position: static; }
}
@media (max-width: 640px) {
  .footer-inner { flex-direction: column; align-items: flex-start; }
}

/* Mobile: optional back control when conversation is open (shown via JS) */
.chat-mobile-back {
  display: none;
}
@media (max-width: 768px) {
  .chat-mobile-back {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    margin-right: 4px;
    flex-shrink: 0;
    border: 1px solid color-mix(in srgb, var(--hint) 30%, transparent);
    border-radius: 10px;
    background: transparent;
    color: var(--text);
    font-size: 1.15rem;
    cursor: pointer;
    padding: 0;
  }
  .chat-mobile-back.hidden { display: none !important; }
}

/* Profile photo action icons (Mini App style) */
.profile-icon-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 0 0 12px;
  justify-content: flex-start;
}
.profile-icon-actions .icon-btn {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: 1px solid color-mix(in srgb, var(--hint) 30%, transparent);
  background: transparent;
  color: var(--hint);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.profile-icon-actions .icon-btn svg {
  width: 18px;
  height: 18px;
  display: block;
}
.profile-icon-actions .icon-btn:hover {
  color: var(--text);
  border-color: color-mix(in srgb, var(--btn) 50%, transparent);
}
.profile-icon-actions .icon-btn.danger:hover { color: #ff8a8a; }
.profile-icon-actions .icon-btn:disabled,
.profile-icon-actions .icon-btn.disabled {
  opacity: 0.35;
  pointer-events: none;
}
/* Companions page profile: Chat sits to the right of photo action icons */
.profile-icon-actions .profile-chat-btn {
  margin-left: 4px;
  padding: 7px 14px;
  min-height: 36px;
  flex-shrink: 0;
}

/* Generate modal: space between textarea row and action buttons */
.scene-modal-sheet .modal-actions {
  margin-top: 18px;
}
.scene-input-row {
  margin-bottom: 4px;
}

/* Operation status — bottom right toast */
.global-status {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 180;
  min-height: 0;
  margin: 0;
  max-width: min(360px, calc(100vw - 32px));
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--bg2);
  border: 1px solid var(--border);
  box-shadow: 0 8px 28px rgba(0,0,0,0.35);
  font-size: 0.9rem;
  color: var(--hint);
  pointer-events: none;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.global-status:not(:empty) {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.global-status.err {
  color: var(--danger);
  border-color: color-mix(in srgb, var(--danger) 45%, var(--border));
}
.global-status.ok {
  color: #8fd98f;
  border-color: color-mix(in srgb, #4caf50 40%, var(--border));
}

/* Support page */
.support-panel { max-width: 560px; }
.support-panel textarea {
  display: block;
  width: 100%;
  margin-top: 6px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font: inherit;
  padding: 10px 12px;
  resize: vertical;
  min-height: 120px;
}
.tickets-section {
  margin-top: 22px;
  padding-top: 16px;
  border-top: 1px solid color-mix(in srgb, var(--hint) 22%, transparent);
}
.tickets-heading {
  margin: 0 0 10px;
  font-size: 1rem;
  font-weight: 600;
}
.tickets-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ticket-card {
  background: var(--bg);
  border-radius: 12px;
  border: 1px solid color-mix(in srgb, var(--hint) 22%, transparent);
  padding: 10px 12px;
  text-align: left;
}
.ticket-card.is-closed { opacity: 0.75; }
.ticket-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--hint);
  margin-bottom: 6px;
}
.ticket-status {
  text-transform: capitalize;
  color: color-mix(in srgb, var(--btn) 70%, #fff);
}
.ticket-status.is-closed { color: var(--hint); }
.ticket-body {
  margin: 0;
  font-size: 0.9rem;
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Photo placeholders + smooth ready fade (profile DP, avatars, cards, bubbles) */
.profile-photo,
.avatar,
.chat-row-photo,
.bubble-photo,
.comp-card-img {
  transition: opacity 0.32s ease, filter 0.32s ease;
  background: #1a1a24;
}
/* Keep silhouette visible while loading (no blank flash). */
.profile-photo.is-loading,
.avatar.is-loading,
.chat-row-photo.is-loading,
.bubble-photo.is-loading,
.comp-card-img.is-loading,
.profile-photo.is-placeholder,
.avatar.is-placeholder,
.chat-row-photo.is-placeholder,
.bubble-photo.is-placeholder,
.comp-card-img.is-placeholder {
  opacity: 1;
  filter: none;
}
.profile-photo.is-loading:not(.is-placeholder),
.avatar.is-loading:not(.is-placeholder),
.chat-row-photo.is-loading:not(.is-placeholder),
.bubble-photo.is-loading:not(.is-placeholder),
.comp-card-img.is-loading:not(.is-placeholder) {
  opacity: 0.72;
  filter: saturate(0.85);
}
.profile-photo.is-ready,
.avatar.is-ready,
.chat-row-photo.is-ready,
.bubble-photo.is-ready,
.comp-card-img.is-ready {
  opacity: 1;
  filter: none;
}
/* Soft shimmer over placeholder while waiting for the real photo */
.profile-photo.is-placeholder,
.avatar.is-placeholder,
.chat-row-photo.is-placeholder,
.comp-card-img.is-placeholder,
.bubble-photo.is-placeholder {
  position: relative;
}
@keyframes photo-shimmer {
  0% { background-position: 100% 0; }
  100% { background-position: -100% 0; }
}
.profile-slideshow.is-preloading .profile-photo.is-placeholder,
.comp-card-img.is-placeholder.is-loading,
.avatar.is-placeholder.is-loading,
.chat-row-photo.is-placeholder.is-loading {
  animation: photo-shimmer 1.4s ease-in-out infinite;
  background-image: linear-gradient(
    100deg,
    transparent 30%,
    color-mix(in srgb, var(--btn) 12%, transparent) 50%,
    transparent 70%
  );
  background-size: 200% 100%;
  background-color: #1a1a24;
}
.comp-card-img {
  width: 100%;
  aspect-ratio: 2 / 3;
  object-fit: cover;
  display: block;
  background: #1a1a24;
}
.profile-slideshow.is-preloading::after {
  content: none;
}
/* Failed bubble photos stay collapsed; placeholder still used elsewhere */
.bubble-photo.is-broken.is-placeholder {
  max-height: 360px;
  min-height: 80px;
  opacity: 0.9;
  margin-top: 8px;
  border: none;
  cursor: default;
}
