/* ── Reset ─────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: #FFFFFF; }
body.dark { background: #000000; }


/* ── Theme Variables ───────────────────────────────────── */
:root {
  --font: -apple-system, "Helvetica Neue", sans-serif;
  --accent: #007AFF;
  --sidebar-w: clamp(300px, 32%, 380px);
  --header-h: 80px;
}
[data-lucide], .lucide {
  stroke-width: 1.5;
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
}
body.light {
  --bg-app:       #FFFFFF;
  --bg-sidebar:   #F5F5F7;
  --bg-input:     #EFEFEF;
  --bg-search:    #E5E5EA;
  --text-primary: #000000;
  --text-second:  #8E8E93;
  --text-time:    #8E8E93;
  --bubble-in:    #E9E9EB;
  --bubble-out:   #007AFF;
  --bubble-in-text:  #000000;
  --bubble-out-text: #FFFFFF;
  --divider:      rgba(0,0,0,0.12);
  --selected:     #CCE4FF;
  --conv-hover:   rgba(0,0,0,0.05);
  --conv-hover-solid: #EBEBED;
  --selected-solid:   #CCE4FF;
  --header-bg:    rgba(255,255,255,0.85);
  --pill-bg:      rgba(255,255,255,0.92);
  --pill-border:  rgba(0,0,0,0.08);
  --avatar-shadow: drop-shadow(0 4px 8px rgba(0,0,0,0.22)) drop-shadow(0 1px 3px rgba(0,0,0,0.14));
  --sidebar-border: rgba(0,0,0,0.15);
  --shadow-header: 0 1px 0 rgba(0,0,0,0.12);
  --modal-bg:     rgba(0,0,0,0.4);
  --modal-card:   #FFFFFF;
}
body.dark {
  --bg-app:       #000000;
  --bg-sidebar:   #1C1C1E;
  --bg-input:     #1C1C1E;
  --bg-search:    #2C2C2E;
  --text-primary: #FFFFFF;
  --text-second:  #8E8E93;
  --text-time:    #636366;
  --bubble-in:    #2C2C2E;
  --bubble-out:   #0A84FF;
  --bubble-in-text:  #FFFFFF;
  --bubble-out-text: #FFFFFF;
  --divider:      rgba(255,255,255,0.16);
  --selected:     #1C3A5C;
  --conv-hover:   rgba(255,255,255,0.06);
  --conv-hover-solid: #2A2A2C;
  --selected-solid:   #1C3A5C;
  --header-bg:    rgba(0,0,0,0.85);
  --pill-bg:      rgba(50,50,52,0.92);
  --pill-border:  rgba(255,255,255,0.12);
  --avatar-shadow: drop-shadow(0 4px 8px rgba(0,0,0,0.6)) drop-shadow(0 1px 3px rgba(0,0,0,0.4));
  --sidebar-border: rgba(255,255,255,0.12);
  --shadow-header: 0 1px 0 rgba(255,255,255,0.08);
  --modal-bg:     rgba(0,0,0,0.7);
  --modal-card:   #1C1C1E;
}

/* ── Liquid Glass utility ──────────────────────────────────── */
.liquid-glass {
  background: rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(160px);
  -webkit-backdrop-filter: blur(200px);
  border: 1px solid rgba(0, 0, 0, 0.08);
  box-shadow:
    inset 0 -1px 0 rgba(255, 255, 255, 0.6),
    inset 0 1px 0 rgba(0, 0, 0, 0.04);
}
body.dark .liquid-glass {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.18);
  box-shadow:
    inset 0 -0.5px 0 rgba(255, 255, 255, 0.22),
    inset 0 1px 0 rgba(0, 0, 0, 0.3);
}

/* ── App Shell ─────────────────────────────────────────── */
#app {
  display: flex;
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  background: var(--bg-app);
  font-family: var(--font);
  opacity: 1;
  box-sizing: border-box;
}

/* ══════════════════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════════════ */
#sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  height: 100%;
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 20;
  transition: transform 0.3s ease;
  padding: 8px 0 8px 8px;
  overflow: visible;
}
#sidebar-inner {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-app);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 3px 0 6px rgba(0,0,0,0.15);
}
body.dark #sidebar-inner {
  box-shadow: 3px 0 12px rgba(255,255,255,0.08);
}
#sidebar-inner::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 120px;
  background: linear-gradient(to bottom, transparent 0%, var(--bg-app) 100%);
  pointer-events: none;
  z-index: 24;
}

/* Sidebar top bar */
#sidebar-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px 8px;
  min-height: 52px;
  position: relative;
  background: var(--bg-sidebar);
  border-bottom: 1px solid var(--divider);
}
#sidebar-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
#sidebar-subtitle-row {
  display: flex;
  align-items: center;
  gap: 4px;
}
#sidebar-subtitle {
  font-size: 11px;
  color: var(--text-second);
  font-weight: 500;
  letter-spacing: 0.01em;
}
#sidebar-info-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: var(--text-second);
  display: flex;
  align-items: center;
  opacity: 0.7;
  transition: opacity 0.15s;
  line-height: 1;
}
#sidebar-info-btn:hover { opacity: 1; }

/* Sidebar bottom zone — absolutely positioned so list scrolls behind */
#sidebar-bottom-zone {
  position: absolute;
  bottom: 0;
  left: 8px;
  right: 0;
  display: flex;
  flex-direction: column;
  pointer-events: none;
  z-index: 25;
}

/* Upsell banner */
#sidebar-upsell {
  display: none;
  flex-direction: column;
  gap: 4px;
  padding: 6px 8px 2px;
  pointer-events: auto;
}
#gopro-btn, #donate-btn {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding: 3px 16px 3px 16px;
  border-radius: 11px;
  border: none;
  color: #fff;
  font-size: 13px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  opacity: 0.85;
  transition: opacity 0.15s;
  white-space: nowrap;
}
#gopro-btn { background: #A52535; }
#donate-btn { background: var(--accent); }
#gopro-btn:hover, #donate-btn:hover { opacity: 1; }

/* Bottom bar */
#sidebar-bottom-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  pointer-events: auto;
  background: transparent;
}

/* Search pill — frosted glass */
#sidebar-search-wrap {
  flex: 1;
}
#sidebar-search-wrap .search-inner {
  position: relative;
  display: flex;
  align-items: center;
  border-radius: 980px;
}
#sidebar-search-wrap #search-input {
  width: 100%;
  padding: 9px 30px 9px 34px;
  border-radius: 980px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  -webkit-appearance: none;
  background: transparent;
}
#sidebar-search-wrap #search-input::placeholder { color: var(--text-second); }
#search-clear-btn {
  position: absolute;
  right: 10px;
  background: none;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-second);
  padding: 0;
  opacity: 0.7;
  flex-shrink: 0;
}
#search-clear-btn:hover { opacity: 1; }
#sidebar-search-wrap .search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-second);
  pointer-events: none;
  display: flex;
  z-index: 1;
}

/* Compose circle — frosted glass */
#new-chat-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  flex-shrink: 0;
  transition: opacity 0.15s;
}
#new-chat-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}
body.dark #new-chat-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
#new-chat-btn svg { width: 18px; height: 18px; }
#new-chat-btn img {
  width: 20px;
  height: 20px;
  display: block;
}

/* Disclaimer popover */
#sidebar-disclaimer-popover {
  display: none;
  position: absolute;
  top: 68px;
  left: 12px;
  right: 12px;
  background: var(--modal-card);
  border-radius: 12px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  border: 1px solid var(--divider);
  padding: 14px 16px;
  z-index: 30;
}
#sidebar-disclaimer-popover.visible {
  display: block;
}
#sidebar-disclaimer-popover p {
  font-size: 13px;
  color: var(--text-second);
  line-height: 1.6;
}
#sidebar-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
}


/* Search */
.search-inner {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-second);
  pointer-events: none;
  display: flex;
}
#search-input {
  width: 100%;
  padding: 7px 12px 7px 34px;
  background: var(--bg-search);
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  -webkit-appearance: none;
}
#search-input::placeholder { color: var(--text-second); }

/* Conversation list */
#conv-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 120px;
  min-height: 0;
}
#conv-list::-webkit-scrollbar { width: 4px;}
#conv-list::-webkit-scrollbar-track { background: transparent; }
#conv-list::-webkit-scrollbar-thumb {
  background: var(--divider);
  border-radius: 3px;
}

.conv-item {
  cursor: pointer;
  position: relative;
  min-height: 64px;
  overflow: hidden;
  -webkit-user-select: none;
  user-select: none;
}
.conv-item::after { display: none; }

.conv-item-inner::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 69px;
  right: 14px;
  height: 1px;
  background: var(--divider);
  pointer-events: none;
  z-index: 3;
}
@media (hover: hover) {
  .conv-item:hover .conv-item-inner { background: var(--conv-hover-solid); }
}
.conv-item.active .conv-item-inner { background: var(--selected-solid); }
.conv-item-inner {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 14px;
  width: 100%;
  min-height: 64px;
  box-sizing: border-box;
  transition: transform 0.2s ease, background 0.2s ease;
  position: relative;
  z-index: 2;
  background: var(--bg-app);
}

/* Mini avatar in conv list */
.conv-avatar {
  width: 44px; height: 44px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: #8E8E93;
}
.conv-avatar img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }

.conv-info {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  column-gap: 6px;
}
.conv-name-line1 {
  grid-column: 1;
  grid-row: 1;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
}
.conv-time {
  grid-column: 2;
  grid-row: 1;
  font-size: 12px;
  color: var(--text-time);
  white-space: nowrap;
  line-height: 1.3;
  align-self: start;
}
.conv-name-line2 {
  grid-column: 1 / 3;
  grid-row: 2;
  min-width: 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
  overflow: hidden;
  white-space: nowrap;
}
.conv-preview {
  grid-column: 1 / 3;
  grid-row: 3;
  font-size: 13px;
  color: var(--text-second);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

#user-email {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 12px;
  color: var(--text-second);
}


/* ══════════════════════════════════════════════════════════
   CHAT PANEL
══════════════════════════════════════════════════════════ */
#chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--bg-app);
  position: relative;
  padding-top: env(safe-area-inset-top, 0px);
}

/* Fixed chat header */
#chat-header {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: transparent;
  z-index: 10;
  gap: 0;
}
/* Mobile back button */
#back-btn {
  display: none;
  position: absolute;
  left: 12px;
  top: calc(50% - 5.5px);
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: #000000;
  padding: 0;
}
body.dark #back-btn {
  color: #ffffff;
}
#back-btn svg { width: 12px; height: 20px; position: relative; left: -1px; top: 1px; }


#profile-btn {
  display: flex;
  position: absolute;
  right: 22px;
  top: calc(50% - 5.5px);
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 11;
  overflow: hidden;
}
#profile-btn img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  display: none;
}
#profile-btn .profile-initials {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
#profile-btn .profile-guest-icon {
  color: var(--text-second);
}



.auth-resolving {
  pointer-events: none;
  opacity: 0.4;
}
.conv-item-cached {
  opacity: 0.5;
  pointer-events: none;
}

#chat-avatar {
  width: 58px; height: 58px;
  flex-shrink: 0;
  border-radius: 50%;
  overflow: hidden;
  background: transparent;
  position: relative;
  z-index: 3;
  margin-top: 8px;
  box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.25);
}
#chat-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

#chat-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 3px 10px 3px 8px;
  border-radius: 20px;
  margin-top: -5px;
  z-index: 1;
}

/* Messages scrollable area — padded so content clears header & input */
#messages {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: calc(var(--header-h) + 0px) 16px calc(56px + 8px + env(safe-area-inset-bottom, 0px));
}
#messages::-webkit-scrollbar { width: 4px; height: 20px;}
#messages::-webkit-scrollbar-track { background: transparent; }
#messages::-webkit-scrollbar-thumb {
  background: var(--divider);
  border-radius: 3px;
}

/* ── Welcome state ─────────────────────────────────────── */
#welcome-state {
  position: absolute;
  top: var(--header-h);
  bottom: 60px; /* input bar height */
  left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
}

#welcome-glow {
  position: absolute;
  width: 380px;
  height: 380px;
  border-radius: 50%;
  background: radial-gradient(ellipse at center,
    rgba(201, 168, 76, 0.20) 0%,
    rgba(201, 168, 76, 0.0) 70%);
  pointer-events: none;
}

#welcome-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0;
  padding: 0 40px;
  z-index: 1;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#welcome-scripture-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  padding-bottom: 20px;
  transition: opacity 0.6s ease;
}

#welcome-scripture-text {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 16px;
  font-style: italic;
  color: var(--text-primary);
  opacity: 0.85;
  line-height: 1.6;
  max-width: 340px;
  white-space: pre-line;
  text-align: center;
  padding-bottom: 0;
}

#welcome-scripture-ref {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #B8922A;
  margin-top: 4px;
}

#welcome-divider {
  width: 36px;
  height: 1px;
  background: rgba(201, 168, 76, 0.5);
  margin-bottom: 20px;
}

#welcome-tagline {
  font-family: Georgia, 'Times New Roman', serif;
  font-size: 17px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

#welcome-sub {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: #8B6914;
}

body.dark #welcome-scripture-ref { color: #C9A84C; }
body.dark #welcome-sub { color: #A07820; }
body.dark #welcome-glow {
  background: radial-gradient(ellipse at center,
    rgba(201, 168, 76, 0.14) 0%,
    rgba(201, 168, 76, 0.0) 70%);
}

/* Top-of-screen gradient overlay — fades messages below header/pill */
#messages-gradient {
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 160px;
  background: linear-gradient(to bottom, #FFFFFF 0%, rgba(255,255,255,0) 100%);
  pointer-events: none;
  z-index: 4;
}
body.dark #messages-gradient {
  background: linear-gradient(to bottom, #000000 0%, rgba(0,0,0,0) 100%);
}

/* Timestamp labels */
.msg-date {
  text-align: center;
  font-size: 12px;
  color: var(--text-time);
  margin: 16px 0 8px;
}

/* Message rows */
.msg-row {
  display: flex;
  align-items: flex-end;
  margin-bottom: 3px;
}
.msg-row.out { justify-content: flex-end; }
.msg-row.in  { justify-content: flex-start; }

/* Message avatars — desktop only (> 768px) */
.msg-avatar {
  width: 28px;
  height: 28px;
  min-width: 28px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  align-self: flex-end;
}
.msg-row.in  .msg-avatar { margin-right: 6px; }
.msg-row.out .msg-avatar { margin-left: 6px; }
.msg-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
}
.msg-avatar-initials {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #4793F6;
  color: #FFFFFF;
  font-size: 11px;
  font-weight: 600;
  font-family: var(--font);
}
.msg-avatar-guest {
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-avatar-guest svg {
  width: 1.5em;
  height: 1.5em;
}
/* Non-last bubbles in a group: spacer only, no visible avatar */
.msg-row.first .msg-avatar,
.msg-row.mid   .msg-avatar { visibility: hidden; }
/* Hide avatars on mobile */
@media (max-width: 768px) {
  .msg-avatar { display: none; }
}

/* iMessage-style bubbles */
.bubble {
  max-width: 80%;
  padding: 9px 13px;
  font-size: 15px;
  line-height: 1.25;
  word-wrap: break-word;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* INCOMING — gray gradient */
.msg-row.in .bubble {
  background: linear-gradient(to bottom, #F0F0F1 0%, #E9E9EA 100%);
  color: var(--bubble-in-text);
  border-radius: 18px 18px 18px 4px;
  position: relative;
}
body.dark .msg-row.in .bubble {
  background: linear-gradient(to bottom, #464649 0%, #262629 100%);
}

/* OUTGOING — blue gradient */
.msg-row.out .bubble {
  background: linear-gradient(to bottom, #6AAEF8 0%, #4793F6 100%);
  color: var(--bubble-out-text);
  border-radius: 18px 18px 4px 18px;
  position: relative;
}
body.dark .msg-row.out .bubble {
  background: linear-gradient(to bottom, #6AAEF8 0%, #4793F6 100%);
}


/* Group-aware radii — top corners are ALWAYS 18px, no exceptions */
/* Only the bottom-left (in) or bottom-right (out) gets 4px, and only on the last bubble in a group */
.msg-row.in.first .bubble  { border-radius: 18px 18px 18px 18px; } /* solo/first: all round */
.msg-row.in.mid .bubble    { border-radius: 18px 18px 18px 18px; } /* mid: all round */
.msg-row.in.last .bubble   { border-radius: 18px 18px 18px 4px;  } /* last: pointer bottom-left only */
/* Outgoing */
.msg-row.out.first .bubble { border-radius: 18px 18px 18px 18px; } /* solo/first: all round */
.msg-row.out.mid .bubble   { border-radius: 18px 18px 18px 18px; } /* mid: all round */
.msg-row.out.last .bubble  { border-radius: 18px 18px 4px 18px;  } /* last: pointer bottom-right only */



/* ── Rename inline input ── */
.conv-rename-input {
  flex: 1;
  min-width: 0;
  background: var(--bg-main);
  border: 2px solid var(--accent);
  border-radius: 8px;
  padding: 8px 12px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  outline: none;
  box-sizing: border-box;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  margin: 4px 0;
}

/* ── Disclaimer modal ── */
#disclaimer-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 8000;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0,0,0,0.45);
}
#disclaimer-modal.visible { display: flex; }
#disclaimer-card {
  background: var(--bg-main, #ffffff);
  border-radius: 20px;
  padding: 32px 28px 28px;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 24px 64px rgba(0,0,0,0.35);
  text-align: center;
  position: relative;
  z-index: 8001;
}
#disclaimer-card h2 {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 14px;
}
#disclaimer-card p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-second);
  margin-bottom: 22px;
}
#disclaimer-card p em {
  color: var(--text-primary);
  font-style: normal;
  font-weight: 500;
}
#disclaimer-accept {
  width: 100%;
  padding: 13px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

/* ══ PAYWALL SCREEN ═════════════════════════════════════════ */

#screen-paywall .auth-screen-body {
  align-items: center;
  text-align: center;
}
#screen-paywall .paywall-benefits {
  width: auto;
  text-align: left;
}
#screen-paywall .auth-screen-heading,
#screen-paywall .auth-screen-subheading,
#screen-paywall .paywall-price {
  text-align: center;
  width: 100%;
}
.paywall-plan-toggle {
  display: flex;
  background: var(--bg-search);
  border-radius: 50px;
  padding: 3px;
  gap: 2px;
  width: 100%;
  margin-bottom: 4px;
}
.paywall-plan-btn {
  flex: 1;
  padding: 8px 0;
  border-radius: 50px;
  border: none;
  background: transparent;
  color: var(--text-second);
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.paywall-plan-btn.active {
  background: var(--bg-app);
  color: var(--text-primary);
  box-shadow: 0 1px 4px rgba(0,0,0,0.12);
}
.paywall-save-badge {
  font-size: 11px;
  font-weight: 700;
  color: #34C759;
  background: rgba(52, 199, 89, 0.12);
  border-radius: 20px;
  padding: 2px 6px;
}

/* Close button */
.paywall-card .auth-back {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--bg-search);
  color: var(--text-second);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s;
}
.paywall-card .auth-back:hover {
  background: var(--bg-input);
}

/* Header */
.paywall-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 8px;
  margin-bottom: 20px;
}
.paywall-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  object-fit: cover;
  box-shadow: 0 4px 12px rgba(0,0,0,0.18);
  margin-bottom: 4px;
}
.paywall-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.25;
  letter-spacing: -0.2px;
}
.paywall-sub {
  font-size: 14px;
  color: var(--text-second);
  line-height: 1.5;
  max-width: 300px;
}

/* Benefits list */
.paywall-benefits {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 20px;
}
.paywall-benefit {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
}
.paywall-benefit::before {
  content: '';
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 122, 255, 0.12);
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='8' viewBox='0 0 10 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 4L3.5 6.5L9 1' stroke='%23007AFF' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  flex-shrink: 0;
}

/* Price line */
.paywall-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 16px;
}

/* Subscribe button */
.paywall-subscribe-btn {
  width: 100%;
  padding: 17px 0;
  border-radius: 50px;
  border: none;
  background: #A52535;
  color: #fff;
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
  margin-bottom: 4px;
}
.paywall-subscribe-btn:hover { opacity: 0.88; }

/* Stripe payment element area */
#paywall-payment-wrap {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}
#paywall-payment-element {
  width: 100%;
}
.paywall-card .auth-btn {
  width: 100%;
  padding: 17px 0;
  border-radius: 50px;
  border: none;
  background: var(--text-primary);
  color: var(--bg-app);
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
}
.paywall-card .auth-btn:disabled {
  background: var(--bg-search);
  color: var(--text-second);
  cursor: default;
}
.paywall-card .auth-btn:not(:disabled):hover { opacity: 0.88; }

/* Divider */
.paywall-divider {
  width: 100%;
  text-align: center;
  font-size: 13px;
  color: var(--text-second);
  position: relative;
  margin: 16px 0 12px;
}
.paywall-divider::before,
.paywall-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 20px);
  height: 1px;
  background: var(--divider);
}
.paywall-divider::before { left: 0; }
.paywall-divider::after  { right: 0; }

/* Donate note + button */
.paywall-donate-note {
  font-size: 13px;
  color: var(--text-second);
  text-align: center;
  line-height: 1.5;
  margin-bottom: 10px;
}
.paywall-donate-btn {
  background: none;
  border: none;
  font-size: 15px;
  font-family: var(--font);
  color: var(--accent);
  font-weight: 600;
  cursor: pointer;
  padding: 4px 0;
  transition: opacity 0.15s;
}
.paywall-donate-btn:hover { opacity: 0.75; }
#paywall-subscribe-btn,
#paywall-subscribe-btn-mobile,
#paywall-confirm-btn,
#paywall-confirm-btn-mobile {
  color: #FFFFFF !important;
}

/* Error text inside paywall */
.paywall-card .donate-error {
  font-size: 13px;
  color: #D0021B;
  text-align: center;
  min-height: 0;
  line-height: 1.4;
}
.paywall-card .donate-error:empty { display: none; }

#donate-submit,
#donate-submit-desktop {
  background: var(--accent);
}

/* ══ SETTINGS SCREEN ════════════════════════════════════════ */
.settings-body {
  padding: 24px 0 32px;
  gap: 0;
}
.settings-section-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-second);
  padding: 20px 20px 6px;
}
.settings-group {
  background: var(--modal-card);
  border-radius: 25px;
  margin: 0;
  overflow: hidden;
  border: 1px solid var(--divider);
}
.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 13px 16px;
  min-height: 44px;
  gap: 12px;
}
.settings-row-tappable {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .settings-row-tappable:hover {
    background: var(--conv-hover);
  }
}
.settings-row-tappable:active {
  background: var(--conv-hover);
}
.settings-row-control {
  padding: 10px 16px;
}
.settings-row-label {
  font-size: 15px;
  color: var(--text-primary);
  font-family: var(--font);
}
.settings-row-value {
  font-size: 15px;
  color: var(--text-second);
  font-family: var(--font);
}
.settings-chevron {
  color: var(--text-second);
  flex-shrink: 0;
}
.settings-divider {
  height: 1px;
  background: var(--divider);
  margin: 0 16px;
}

/* Accordion */
.settings-accordion {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease;
}
.settings-accordion.open {
  max-height: 300px;
}
.settings-accordion-text {
  font-size: 13px;
  color: var(--text-second);
  line-height: 1.6;
  padding: 0 16px 14px;
}
#settings-disclaimer-chevron {
  transition: transform 0.3s ease;
}
#settings-disclaimer-chevron.open {
  transform: rotate(180deg);
}
#settings-back {
  margin-top: 20px;
}

/* Segmented control */
.settings-segmented {
  display: flex;
  background: var(--bg-search);
  border-radius: 20px;
  padding: 2px;
  gap: 2px;
  width: 100%;
  box-sizing: border-box;
}
.settings-seg-btn {
  flex: 1;
  padding: 7px 0;
  border-radius: 15px;
  border: none;
  background: transparent;
  color: var(--text-second);
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.settings-seg-btn.active {
  background: var(--bg-app);
  color: var(--text-primary);
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

/* Settings gear button — matches new-chat-btn style */
#settings-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-second);
  transition: opacity 0.15s;
}
#settings-btn:hover {
  background: rgba(0, 0, 0, 0.12);
}
body.dark #settings-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* ── Error boundary ── */
.msg-error {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #FF3B30;
  font-size: 14px;
  padding: 10px 14px;
  line-height: 1.4;
  background: rgba(255, 59, 48, 0.08);
  border: 1px solid rgba(255, 59, 48, 0.35);
  border-radius: 10px;
  margin: 8px 12px 0;
}


/* ── Typing indicator */
.typing-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 16px;
  background: var(--bubble-in);
  border-radius: 18px 18px 18px 4px;
}
.typing-dot {
  width: 8px; height: 8px;
  background: var(--text-second);
  border-radius: 50%;
  animation: typingBounce 1.2s infinite ease-in-out;
}
.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Input bar ─────────────────────────────────────────── */
#input-bar {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  padding: 8px 12px 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom));
  background: transparent;
  z-index: 6;
}
#msg-input {
  display: block;
  width: 100%;
  min-height: 36px;
  max-height: 120px;
  padding: 7px 48px 7px 14px;
  border-radius: 20px;
  font-size: 16px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  resize: none;
  overflow-y: auto;
  scrollbar-width: none;
  line-height: 1.4;
  background: transparent;
  border: none;
}
#msg-input::-webkit-scrollbar { display: none; }
#msg-input::placeholder { color: var(--text-second); }

#send-btn {
  position: absolute;
  right: 4px;
  bottom: 4px;
  top: auto;
  transform: none;
  width: 40px;
  height: 28px;
  min-width: 40px;
  min-height: 28px;
  border-radius: 20px;
  border: none;
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.1s, scale 0.15s;
  opacity: 0;
  pointer-events: none;
  scale: 0.7;
}

#send-btn:not(:disabled) {
  opacity: 1;
  pointer-events: auto;
  scale: 1;
}

#send-btn:not(:disabled):hover { opacity: 0.85; }
#send-btn:not(:disabled):active { transform: translateY(-50%) scale(0.92); }
#send-btn svg { width: 22px; height: 22px; }

#input-bar-inner {
  position: relative;
  display: flex;
  align-items: flex-end;
}

#input-gradient {
  position: absolute;
  bottom: 0; left: 0; right: 0;
  height: 80px;
  background: linear-gradient(to top, #FFFFFF 40%, rgba(255,255,255,0) 100%);
  pointer-events: none;
  z-index: 5;
}
body.dark #input-gradient {
  background: linear-gradient(to top, #000000 40%, rgba(0,0,0,0) 100%);
}


/* ── Long-press action popup ─────────────────────────────── */
#msg-action-popup {
  display: none;
  position: fixed;
  z-index: 200;
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 14px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.18);
  border: 1px solid var(--divider);
  overflow: hidden;
  min-width: 180px;
}
#msg-action-popup.visible { display: block; }
.msg-action-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 14px 18px;
  background: none;
  border: none;
  font-size: 16px;
  font-family: var(--font);
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}
.msg-action-btn:not(:last-child) {
  border-bottom: 1px solid var(--divider);
}
.msg-action-btn:active { background: var(--conv-hover); }
.msg-action-btn.destructive { color: #FF3B30; }

/* ── Circle overlay (outside scroll container, no iOS lag) ── */
#circle-overlay {
  display: none;
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 5;
}
#messages.selecting ~ #circle-overlay,
#circle-overlay.visible {
  display: block;
}
.out-circle-proxy {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #48484A;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  pointer-events: auto;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
body.light .out-circle-proxy { border-color: #C7C7CC; }
.out-circle-proxy.selected {
  background: #007AFF;
  border: none;
}

/* ── Message selection mode ─────────────────────────────── */
.msg-row {
  transition: transform 0.3s ease;
  position: relative;
}
.msg-date {
  transition: transform 0.3s ease;
}
/* .in rows and dates slide right */
#messages.selecting .msg-row.in,
#messages.selecting .msg-date {
  transform: translateX(40px);
}
/* .out rows stay put */
#messages.selecting .msg-row.out {
  transform: none;
}
/* .out circle inside row is hidden — proxy in overlay handles it */
#messages.selecting .msg-row.out .msg-select-circle {
  display: none;
}

#messages.selecting .bubble {
  -webkit-user-select: none;
  user-select: none;
}

.msg-select-circle {
  position: absolute;
  left: -36px;
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid #C7C7CC;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-sizing: border-box;
  transition: background 0.15s, border-color 0.15s;
  opacity: 0;
  pointer-events: none;
}
body.dark .msg-select-circle { border-color: #48484A; }
#messages.selecting .msg-select-circle {
  opacity: 1;
  pointer-events: auto;
  transition: background 0.15s, border-color 0.15s, opacity 0.2s;
}
.msg-row.selected .msg-select-circle {
  background: #007AFF;
  border: none;
}


/* Delete bar */
#delete-bar {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom));
  background: var(--header-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-shadow: 0 -1px 0 var(--divider);
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 7;
}
#delete-bar.visible {
  display: flex;
}
#delete-selected-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  opacity: 0.4;
  transition: opacity 0.15s;
}
#delete-selected-btn.has-selection {
  opacity: 1;
}
#delete-selected-btn img {
  width: 26px;
  height: 26px;
  display: block;
}
#delete-bar-cancel {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 16px;
  font-family: var(--font);
  cursor: pointer;
  padding: 6px;
}
#delete-bar-count {
  font-size: 14px;
  color: var(--text-second);
  font-family: var(--font);
}

/* ══ AUTH SCREENS (full-screen page-replacement views) ═════ */
.auth-header {
  width: 100%;
  background: #1C1C1E;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 24px 12px;
  padding-top: env(safe-area-inset-top, 0px);
  flex-shrink: 0;
}
.auth-header-avatar {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  object-fit: cover;
  margin-top: 12px;
}
.auth-header-title {
  font-size: 20px;
  font-weight: 700;
  color: #FFFFFF;
  letter-spacing: -0.3px;
}
.auth-screen {
  position: fixed;
  inset: 0;
  z-index: 5000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  background: var(--bg-app);
  font-family: var(--font);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  transition: opacity 0.15s ease;
}
.auth-screen.hiding {
  opacity: 0;
  pointer-events: none;
}
.auth-screen-inner {
  width: 100%;
  max-width: 440px;
  display: flex;
  flex-direction: column;
}
.auth-screen-body {
  padding: 32px 28px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}
#screen-settings .auth-screen-body {
  gap: 1px;
  padding: 8px 28px 16px;
}
.auth-screen-footer {
  padding: 12px 28px 0px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}
.auth-logo {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.5px;
  margin-bottom: 8px;
}
.auth-screen-heading {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.3;
}
.auth-screen-subheading {
  font-size: 15px;
  color: var(--text-second);
  line-height: 1.5;
  margin-top: -8px;
}
.auth-field {
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 2px 0;
}
.auth-field-row {
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--divider);
  padding-bottom: 8px;
}
.auth-field-row:focus-within { border-bottom-color: var(--text-primary); }
.auth-field-icon {
  flex-shrink: 0;
  color: var(--text-second);
  display: flex;
  align-items: center;
}
.auth-field-text {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.auth-field-label {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: 0.01em;
}
.auth-field-input {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 3px 0;
  font-size: 15px;
  font-family: var(--font);
  color: var(--text-primary);
  outline: none;
  width: 100%;
  -webkit-appearance: none;
}
.auth-field-input::placeholder { color: var(--text-second); }
.auth-field-pw-wrap {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}
.auth-field-pw-wrap .auth-field-input { padding-right: 36px; }
.auth-pw-toggle {
  position: absolute;
  right: 0;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0;
  color: #8E8E93;
  display: flex;
  align-items: center;
}
.auth-pw-toggle:hover { color: var(--text-primary); }
.auth-error {
  font-size: 14px;
  color: #D0021B;
  min-height: 0;
  line-height: 1.4;
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.auth-error:empty { display: none; }
.auth-error-icon { flex-shrink: 0; margin-top: 1px; }
.auth-success {
  font-size: 14px;
  color: #34C759;
  line-height: 1.4;
}
.auth-btn-primary {
  width: 100%;
  padding: 17px 0;
  border-radius: 50px;
  border: none;
  background: var(--text-primary);
  color: var(--bg-app);
  font-size: 17px;
  font-weight: 600;
  font-family: var(--font);
  cursor: pointer;
  transition: opacity 0.15s;
  -webkit-appearance: none;
}
.auth-btn-primary:hover { opacity: 0.88; }
.auth-btn-primary:disabled {
  background: var(--bg-search);
  color: var(--text-second);
  cursor: default;
  opacity: 1;
}
/* Account screen — flip visual hierarchy */
#account-signout,
#account-signout-desktop {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--divider);
  font-size: 15px;
  font-weight: 500;
  padding: 14px 0;
  transition: background 0.15s;
  opacity: 1;
  border-radius: 50px;
  width: 100%;
  font-family: var(--font);
  cursor: pointer;
}
#account-signout:hover,
#account-signout-desktop:hover {
  background: rgba(0,0,0,0.04);
  opacity: 1;
}
body.dark #account-signout,
body.dark #account-signout-desktop {
  background: rgba(255,255,255,0.08);
}
body.dark #account-signout:hover,
body.dark #account-signout-desktop:hover {
  background: rgba(255,255,255,0.13);
}
#account-back,
#account-back-mobile {
  background: var(--text-primary) !important;
  color: var(--bg-app) !important;
  border-radius: 50px !important;
  border: none !important;
  width: 100% !important;
  padding: 17px 0 !important;
  font-size: 17px !important;
  font-weight: 600 !important;
  font-family: var(--font) !important;
  cursor: pointer !important;
  transition: opacity 0.15s !important;
  text-decoration: none !important;
  opacity: 1 !important;
}
#account-back:hover,
#account-back-mobile:hover { opacity: 0.88 !important; }
.auth-link {
  background: none;
  border: none;
  font-size: 15px;
  font-family: var(--font);
  color: var(--text-second);
  cursor: pointer;
  padding: 2px 0;
  text-decoration: underline;
  text-underline-offset: 2px;
  text-align: center;
  width: fit-content;
  align-self: center;
}
.auth-link:hover { color: var(--text-primary); }
.auth-back-btn {
  background: var(--bg-search);
  border-radius: 980px;
  padding: 10px 24px !important;
  font-size: 16px !important;
  color: var(--text-primary) !important;
  text-decoration: none;
}
.auth-back-btn:hover { background: var(--bg-input); }
.auth-link-danger { color: #D0021B !important; }
.auth-link-guest { color: var(--text-second); text-decoration: none; font-size: 14px; }
.auth-btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 0;
  border-radius: 50px;
  border: 1px solid var(--divider);
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.auth-btn-google:hover { background: rgba(0,0,0,0.04); }
body.dark .auth-btn-google { background: rgba(255,255,255,0.08); }
body.dark .auth-btn-google:hover { background: rgba(255,255,255,0.13); }
.auth-btn-apple {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 0;
  border-radius: 50px;
  border: 1px solid var(--divider);
  background: transparent;
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 500;
  font-family: var(--font);
  cursor: pointer;
  text-decoration: none;
  transition: background 0.15s;
}
.auth-btn-apple:hover { background: rgba(0,0,0,0.04); }
body.dark .auth-btn-apple { background: rgba(255,255,255,0.08); }
body.dark .auth-btn-apple:hover { background: rgba(255,255,255,0.13); }
.auth-btn-mobile-only { display: none; }
@media (max-width: 700px) {
  .auth-btn-mobile-only { display: block; }
}
/* Desktop: show inline buttons, hide sticky footer */
@media (min-width: 701px) {
  .auth-btn-desktop-only:not([style*="display:none"]):not([style*="display: none"]) {
    display: block !important;
  }
  .auth-screen-footer {
    display: none !important;
  }
}

/* Mobile: hide inline buttons, show sticky footer */
@media (max-width: 700px) {
  .auth-btn-desktop-only {
    display: none !important;
  }
  .auth-screen { justify-content: flex-start; }
  .auth-screen-inner { flex: 1; display: flex; flex-direction: column; }
  .auth-screen-body { flex: 1; }
  .auth-screen-footer {
    display: flex !important;
    flex-direction: column;
    position: sticky;
    bottom: 0;
    background: var(--bg-app);
    padding: 12px 28px calc(12px + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid var(--divider);
  }
}
@media (max-width: 700px) {
  .auth-field-input {
    font-size: 16px;
  }
}
.account-avatar {
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border-radius: 50%;
  overflow: hidden;
  background: var(--bg-search);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 700;
  color: #FFFFFF;
  flex-shrink: 0;
}
.account-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }

#account-identity-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 14px;
  border-bottom: 1px solid var(--divider);
  width: 100%;
}
#account-identity-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0;
}
#account-provider {
  font-size: 11px;
  color: var(--text-second);
  margin-top: 3px;
  opacity: 0.75;
}
#account-stats-row {
  display: flex;
  gap: 10px;
  width: 100%;
  padding: 14px 0 2px;
}
.account-stat-card {
  flex: 1;
  background: var(--bg-sidebar);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}
.account-stat-value {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}
.account-stat-label {
  font-size: 11px;
  color: var(--text-second);
  font-weight: 500;
}
#account-quote {
  font-size: 13px;
  font-style: italic;
  color: var(--text-second);
  text-align: center;
  line-height: 1.6;
  padding: 14px 4px 6px;
  width: 100%;
}
#account-pro-pill {
  display: flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  font-weight: 600;
  color: #A52535;
  background: rgba(165, 37, 53, 0.12);
  border-radius: 20px;
  padding: 3px 8px 3px 10px;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  font-family: var(--font);
  transition: opacity 0.15s;
}

body.dark #account-pro-pill {
  color: #FF6B7A;
  background: rgba(255, 107, 122, 0.15);
}
#account-pro-pill:hover { opacity: 0.8; }

.account-name {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}
.account-name-edit-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-second);
  opacity: 0.6;
  transition: opacity 0.15s;
  line-height: 1;
  padding: 0 0 0 3px;
  display: inline-flex;
  align-items: center;
  justify-self: start;
}
.account-name-edit-btn:hover { opacity: 1; }
.account-name-inline-input {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--divider);
  color: var(--text-primary);
  font-size: 15px;
  font-weight: 600;
  font-family: var(--font);
  width: 100%;
  padding: 2px 0;
  outline: none;
}

.account-email {
  font-size: 12px;
  color: var(--text-second);
  line-height: 1.2;
}
.account-change-password-btn {
  background: none;
  border: none;
  padding: 1px 0 0;
  font-size: 12px;
  font-family: var(--font);
  color: var(--accent);
  cursor: pointer;
  text-align: left;
}
.account-change-password-btn:hover { opacity: 0.75; }

/* Sidebar backdrop for mobile tap-to-close */
#sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 19;
  opacity: 0;
  pointer-events: none;
  background: rgba(0,0,0,0.4);
  transition: opacity 0.3s ease;
}
#sidebar-backdrop.active {
  display: block;
  opacity: 1;
  pointer-events: auto;
}

/* ══════════════════════════════════════════════════════════
   MOBILE  (≤ 700px) — non-sidebar rules only
   Sidebar mobile rules live in @media (pointer: coarse) and (max-width: 767px) below
══════════════════════════════════════════════════════════ */
@media (max-width: 700px) {
  #back-btn { display: flex; }
  #profile-btn { display: flex; right: 12px; }
}

/* ── Loading overlay ──────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: var(--bg-app);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  transition: opacity 0.15s;
}
#loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}
.loading-spinner {
  width: 40px; height: 40px;
  border: 3px solid var(--divider);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }


/* ══ UNIFIED NOTIFICATION BANNER ═══════════════════════ */
#notify-banner {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  z-index: 100;
  flex-shrink: 0;
}
#notify-banner.notify-offline {
  background: linear-gradient(90deg, #FF3B30, #C0392B);
  color: #FFFFFF;
}
#notify-banner.notify-low {
  background: linear-gradient(90deg, #FF9500, #E67E00);
  color: #FFFFFF;
}
#notify-banner.notify-depleted {
  background: linear-gradient(90deg, #FF3B30, #C0392B);
  color: #FFFFFF;
}
#notify-banner-icon {
  flex-shrink: 0;
  display: flex;
  align-items: center;
}
#notify-banner-msg {
  flex: 1;
  line-height: 1.4;
  white-space: normal;
}
#notify-banner-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
#notify-banner-action {
  background: rgba(255,255,255,0.25);
  border: none;
  border-radius: 12px;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
#notify-banner-action:hover { background: rgba(255,255,255,0.35); }
#notify-banner-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 15px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
#notify-banner-dismiss:hover { color: #FFFFFF; }

@media (min-width: 768px) {
  #notify-banner {
    display: none !important;
  }
}

body.sheet-is-open #notify-banner {
  display: none !important;
}

/* Auth screen offline banner */
.auth-screen-offline-banner {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  background: linear-gradient(90deg, #FF3B30, #C0392B);
  color: #FFFFFF;
  flex-shrink: 0;
}

/* Sidebar banner — same styles as chat banner */
#notify-banner-sidebar {
  position: relative;
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font);
  font-weight: 500;
  z-index: 100;
  flex-shrink: 0;
}
#notify-banner-sidebar.notify-offline {
  background: linear-gradient(90deg, #FF3B30, #C0392B);
  color: #FFFFFF;
}
#notify-banner-sidebar.notify-low {
  background: linear-gradient(90deg, #FF9500, #E67E00);
  color: #FFFFFF;
}
#notify-banner-sidebar.notify-depleted {
  background: linear-gradient(90deg, #FF3B30, #C0392B);
  color: #FFFFFF;
}
#notify-banner-sidebar #notify-banner-sidebar-action {
  background: rgba(255,255,255,0.25);
  border: none;
  border-radius: 12px;
  color: #FFFFFF;
  font-size: 13px;
  font-weight: 600;
  font-family: var(--font);
  padding: 4px 10px;
  cursor: pointer;
  white-space: nowrap;
}
#notify-banner-sidebar #notify-banner-sidebar-action:hover { background: rgba(255,255,255,0.35); }
#notify-banner-sidebar #notify-banner-sidebar-dismiss {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  font-size: 15px;
  cursor: pointer;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}
#notify-banner-sidebar #notify-banner-sidebar-dismiss:hover { color: #FFFFFF; }

/* ── Donation modal (Ko-fi iframe) ───────────────────── */
/* ── Donation modal ───────────────────────────────────── */
#donate-amounts {
  display: flex;
  gap: 7px;
  margin-bottom: 10px;
}
.amount-btn {
  flex: 1;
  padding: 8px 4px;
  border-radius: 10px;
  border: 2px solid var(--divider);
  background: var(--bg-search);
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.amount-btn.selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}
#donate-custom-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  border: 2px solid var(--divider);
  border-radius: 10px;
  padding: 8px 12px;
  margin-bottom: 14px;
  background: var(--bg-search);
  transition: border-color 0.15s;
}
#donate-custom-wrap:focus-within { border-color: var(--accent); }
#donate-custom-wrap span { color: var(--text-second); font-size: 14px; font-weight: 500; }
#donate-custom {
  border: none;
  background: none;
  font-size: 14px;
  font-family: var(--font);
  color: var(--text-primary);
  width: 100%;
  outline: none;
}
#donate-custom::placeholder { color: var(--text-second); }
/* ── Step 1 vs Step 2 toggle ──────────────────────────── */
#screen-donate:not(.donate-confirm) #donate-amount-summary { display: none; }

#screen-donate.donate-confirm .auth-screen-heading,
#screen-donate.donate-confirm .auth-screen-subheading,
#screen-donate.donate-confirm #donate-amounts,
#screen-donate.donate-confirm #donate-custom-wrap { display: none; }

#donate-amount-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 4px 0 8px;
}
#donate-amount-label {
  font-size: 26px;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.3px;
}
#donate-payment-element {
  margin-bottom: 12px;
}
#donate-stripe-badge {
  margin: 10px 0 14px;
}


/* Icon images — file-based PNGs with transparent backgrounds */
body.light .icon-dark  { display: none !important; }
body.light .icon-light { display: inline-block !important; }
body.dark  .icon-light { display: none !important; }
body.dark  .icon-dark  { display: inline-block !important; }


/* ── Ellipsis button (desktop conv-item hover) ─────────── */
.conv-ellipsis {
  position: absolute;
  right: 0;
  top: 0;
  height: 100%;
  width: 44px;
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 8px;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 2;
  box-sizing: border-box;
  color: var(--text-primary);
}
@media (pointer: fine) {
  .conv-item:hover .conv-ellipsis { opacity: 1; pointer-events: auto; }
}
.conv-ellipsis-pill {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 6px;
  background: rgba(0,0,0,0.08);
  transition: background 0.15s;
  flex-shrink: 0;
}
body.dark .conv-ellipsis-pill {
  background: rgba(255,255,255,0.12);
}
.conv-ellipsis:hover .conv-ellipsis-pill {
  background: rgba(0,0,0,0.16);
}
body.dark .conv-ellipsis:hover .conv-ellipsis-pill {
  background: rgba(255,255,255,0.22);
}
.conv-item.active .conv-ellipsis-pill {
  background: rgba(0,0,0,0.12);
}
@media (pointer: coarse) {
  .conv-ellipsis { display: none !important; }
}

@media (pointer: coarse) and (max-width: 767px) {

  /* ── Sidebar ── */
  #sidebar {
    position: fixed;
    top: 0; left: 0;
    width: 100%;
    max-width: none;
    min-width: unset;
    height: 100%;
    height: 100dvh;
    margin: 0;
    padding: 0;
    display: none;
    filter: none;
    background: var(--bg-sidebar);
    overflow: hidden;
    z-index: 5001;
  }

  #sidebar-disclaimer-popover {
    top: 60px;
  }

  #sidebar::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-top);
    background: var(--bg-sidebar);
    z-index: 26;
    pointer-events: none;
  }

  #sidebar::after {
    content: '';
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: env(safe-area-inset-bottom);
    background: var(--bg-sidebar);
    z-index: 24; /* below the bottom zone but above the list */
    pointer-events: none;
  }


  #sidebar.mobile-open {
    display: flex;
    animation: sidebar-slide-in 0.3s ease forwards;
  }
  @keyframes sidebar-slide-in {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
  }
  #sidebar-inner {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-app);
    border-radius: 0;
    overflow: hidden;
    box-shadow: none;
    height: 100%;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  #sidebar-topbar {
    padding-top: max(12px, env(safe-area-inset-top, 0px));
    background: var(--bg-sidebar);
  }

  #sidebar-bottom-zone {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
  }

  #sidebar-bottom-bar {
    padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }

  #sidebar-backdrop { display: none !important; }
  #back-btn { display: flex; }
  #profile-btn { display: flex; right: 12px; }
  #chat-panel { width: 100%; background: var(--bg-app); }
  #input-bar {
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }

/* ── Mobile sheet presentation — rules live in bottom @media block ── */
  .auth-screen.sheet-open {
    transform: translateY(0) !important;
    transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1) !important;
    overscroll-behavior: none;
  }
  .auth-screen.sheet-dismissing {
    transform: translateY(100%) !important;
    transition: transform 0.44s cubic-bezier(0.32, 0.72, 0, 1) !important;
  }
  body.sheet-is-open {
    overscroll-behavior: none;
    overflow: hidden;
  }

  /* X close button injected by JS */
  .sheet-close-btn {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    flex-shrink: 0;
  }
  .sheet-close-btn:active { background: rgba(255,255,255,0.28); }

  /* Hide "Back to app" pills — X button and swipe handle dismissal */
  #screen-donate #donate-back,
  #screen-paywall #paywall-close,
  #screen-account #account-back { display: none !important; }

  /* Account sign-out — primary dominant style in mobile footer */
  #account-signout {
    background: var(--text-primary) !important;
    color: var(--bg-app) !important;
    border: none !important;
    font-size: 17px !important;
    font-weight: 600 !important;
    padding: 17px 0 !important;
  }
  body.dark #account-signout {
    background: var(--text-primary) !important;
    color: var(--bg-app) !important;
  }
  #account-signout:hover {
    background: var(--text-primary) !important;
    opacity: 0.88 !important;
  }

  #screen-settings .auth-screen-inner {
    padding-bottom: env(safe-area-inset-bottom);
    background: var(--bg-app);
  }
}

/* ── Context menu ──────────────────────────────────────── */
/* Shared panel container (desktop + mobile, position:absolute in sidebar) */
.ctx-desktop-panel {
  position: absolute;
  z-index: 10;
}
.ctx-menu-card {
  width: fit-content;
  min-width: 150px;
  border-radius: 20px;
  background: var(--bg-app);
  box-shadow: 0 8px 32px rgba(0,0,0,0.18);
  overflow: hidden;
  padding: 0;
  margin-top: 10px;
}
.ctx-menu-btn {
  width: 100%;
  padding: 14px 16px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 15px;
  font-family: var(--font);
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
@media (hover: hover) {
  .ctx-menu-btn:hover { background: var(--conv-hover); }
}
.ctx-menu-delete { color: #FF3B30; }
.ctx-menu-delete svg { stroke: #FF3B30 !important; }
.ctx-menu-cancel { color: var(--text-second); justify-content: flex-start; }
.ctx-menu-divider { height: 1px; background: var(--divider); margin: 0 12px; }

/* ── Undo-delete toast ─────────────────────────────────── */
#delete-toast {
  position: fixed;
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  min-height: 44px;
  background: #1C1C1E;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
  font-size: 13px;
  font-weight: 500;
  font-family: -apple-system, "Helvetica Neue", sans-serif;
  color: #FFFFFF;
  z-index: 5500;
}
#delete-toast-label {
  display: flex;
  align-items: center;
  gap: 8px;
}
#delete-toast.toast-dark-mode {
  background: #E5E5EA;
  color: #1C1C1E;
}
#delete-toast.visible {
  animation: toast-spring-in 250ms ease-out forwards;
}
#delete-toast.hiding {
  animation: toast-fade-out 200ms ease-in forwards;
}
@keyframes toast-spring-in {
  0%   { transform: translateY(-12px); opacity: 0; }
  60%  { transform: translateY(3px);   opacity: 1; }
  100% { transform: translateY(0);     opacity: 1; }
}
@keyframes toast-fade-out {
  0%   { transform: translateY(0);    opacity: 1; }
  100% { transform: translateY(-8px); opacity: 0; }
}
#delete-toast-undo {
  color: #007AFF;
  font-weight: 600;
  font-size: 13px;
  font-family: var(--font);
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}

/* ── Swipe-to-delete (mobile) ──────────────────────────── */
.conv-delete-reveal {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: 100%;
  background: transparent;
  visibility: hidden;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 12px;
  box-sizing: border-box;
}
.conv-item.reveal-open .conv-delete-reveal {
  visibility: visible;
}
.conv-delete-pill {
  flex-shrink: 0;
  margin-left: 12px;
  height: 36px;
  width: clamp(150px, 75%, 270px);
  border-radius: 980px;
  background: #FF3B30;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  overflow: hidden;
}

/* ── Rename modal ─────────────────────────────────────────── */
.rename-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 6000;
}

body.dark .rename-modal-overlay {
  background: rgba(0, 0, 0, 0.72);
}

.rename-modal-dialog {
  background: #f2f2f7;
  border-radius: 14px;
  padding: 20px 16px 16px;
  width: min(90vw, 480px);
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
}

body.dark .rename-modal-dialog {
  background: #3a3a3c;
}

.rename-modal-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  color: var(--text-primary);
  font-family: var(--font);
}

.rename-modal-input {
  width: 100%;
  background: #fff;
  border: none;
  border-radius: 10px;
  font-size: 15px;
  color: var(--text-primary);
  padding: 10px 12px;
  outline: none;
  box-sizing: border-box;
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.08);
  font-family: var(--font);
}

body.dark .rename-modal-input {
  background: #2c2c2e;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08);
  color: #fff;
}

.rename-modal-buttons {
  display: flex;
  gap: 8px;
}

.rename-modal-btn {
  flex: 1;
  padding: 11px;
  border-radius: 980px;
  border: none;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  font-family: var(--font);
}

.rename-modal-cancel {
  background: #fff;
  color: var(--text-primary);
}

body.dark .rename-modal-cancel {
  background: #2c2c2e;
  color: #fff;
}

.rename-modal-save {
  background: #fff;
  color: var(--text-primary);
  font-weight: 500;
}

body.dark .rename-modal-save {
  background: #2c2c2e;
  color: #fff;
}

#signup-strength-wrap {
  display: none;
  flex-direction: column;
  gap: 6px;
  margin-top: -8px;
}
#signup-strength-bar {
  height: 4px;
  border-radius: 2px;
  background: var(--divider);
  overflow: hidden;
}
#signup-strength-fill {
  height: 100%;
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s ease, background 0.3s ease;
}
#signup-strength-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
}

/* Signup screen — tighter spacing to fit mobile */
#screen-signup .auth-screen-body {
  gap: 10px;
  padding-top: 24px;
  padding-bottom: 8px;
}
#screen-signup .auth-field-row {
  padding-bottom: 5px;
}
#screen-signup .auth-header {
  padding-top: 10px;
  padding-bottom: 8px;
  gap: 4px;
}
#screen-signup .auth-header-avatar {
  width: 40px;
  height: 40px;
}
#screen-signup .auth-header-title {
  font-size: 16px;
}
#signup-strength-wrap {
  margin-top: -4px;
}
#signup-pw-hint {
  font-size: 12px;
  color: var(--text-second);
  margin-top: -6px;
}

/* ══ MOBILE SHEET PRESENTATION ══════════════════════════════
   Applies to all auth-screens on touch/mobile devices.
   Desktop layout is completely untouched.
══════════════════════════════════════════════════════════ */
@media (pointer: coarse) and (max-width: 767px) {
  .auth-screen {
    top: auto !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    height: 99dvh !important;
    max-height: 99dvh !important;
    border-radius: 24px 24px 0 0 !important;
    overflow-y: hidden !important;
    overflow-x: hidden !important;
    justify-content: flex-start !important;
    transform: translateY(100%);
    transition: none;
    opacity: 1 !important;
    will-change: transform;
    display: flex !important;
    flex-direction: column !important;
  }

  .auth-screen.sheet-open {
    transform: translateY(0) !important;
    transition: transform 0.5s cubic-bezier(0.32, 0.72, 0, 1) !important;
    overscroll-behavior: none;
  }

  .auth-screen.sheet-dismissing {
    transform: translateY(100%) !important;
    transition: transform 0.44s cubic-bezier(0.32, 0.72, 0, 1) !important;
  }

  body.sheet-is-open {
    overscroll-behavior: none;
    overflow: hidden;
  }

  /* Allow drag tracking on header only */
  .auth-screen.sheet-open .auth-header {
    touch-action: none;
  }

  .auth-screen .auth-header {
    border-radius: 24px 24px 0 0;
    flex-shrink: 0;
    position: relative;
    top: auto;
    z-index: 10;
  }

  .auth-screen .auth-screen-inner {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    display: flex;
    flex-direction: column;
  }

  .auth-screen .auth-screen-footer {
    border-top: none !important;
  }

  /* X close button injected by JS */
  .sheet-close-btn {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: none;
    background: rgba(255,255,255,0.18);
    color: rgba(255,255,255,0.85);
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    flex-shrink: 0;
  }
  .sheet-close-btn:active {
    background: rgba(255,255,255,0.28);
  }

  /* Hide "Back to app" pills on mobile sheets */
  #screen-donate #donate-back,
  #screen-paywall #paywall-close,
  #screen-account #account-back {
    display: none !important;
  }
}

body.sheet-is-open {
  background: var(--bg-app) !important;
}

#screen-settings .auth-screen-inner {
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--bg-app);
}

#settings-footer {
  min-height: 1px;
  background: var(--bg-app);
  padding-bottom: env(safe-area-inset-bottom);
  position: sticky;
  bottom: 0;
}

@media (pointer: fine) {
  #sidebar-bottom-bar {
    padding: 10px 12px 16px;
  }
}