:root {
  --font-sans: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --font-display: "Plus Jakarta Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --page-bg: #0b111e;
  --shell-bg: #0b111e;
  --sidebar-bg: #111827;
  --sidebar-top: #1f2937;
  --panel-bg: #0b111e;
  --panel-top: #1f2937;
  --composer-bg: #1f2937;
  --field-bg: #374151;
  --field-bg-focus: #4b5563;
  --border: #1f2937;
  --text: #f3f4f6;
  --text-muted: #9ca3af;
  --text-soft: #e5e7eb;
  --received-bg: #1f2937;
  --sent-bg: #1d4ed8;
  --accent: #60a5fa;
  --accent-strong: #3b82f6;
  --danger-bg: rgba(239, 68, 68, 0.15);
  --danger-text: #ef4444;
  --success-bg: rgba(96, 165, 250, 0.1);
  --success-border: rgba(96, 165, 250, 0.2);
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  height: 100dvh;
  margin: 0;
  font-family: var(--font-sans);
  background: var(--page-bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  width: 100%;
}

button,
input,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  border: 0;
  background: transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 150ms ease, color 150ms ease, transform 100ms ease;
}

svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ─── Browser/App Shell ────────────────────────────── */
.app-shell {
  width: 100%;
  height: 100%;
  height: 100dvh;
  display: flex;
  overflow: hidden;
  background: var(--shell-bg);
}

/* Collapsed state */
.sidebar-collapsed .sidebar {
  display: none !important;
}

/* Sidebar overlay default (hidden on desktop) */
.sidebar-overlay {
  display: none !important;
}

/* Sidebar toggle button styling */
.sidebar-toggle {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 150ms ease, color 150ms ease;
}

.sidebar-toggle:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
}

@keyframes overlay-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* ─── Left Sidebar ─────────────────────────────── */
.sidebar {
  width: 380px;
  min-width: 380px;
  display: flex;
  flex-direction: column;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border);
  height: 100%;
}

.sidebar-header {
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
}

.sidebar-title-row {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--sidebar-top);
}

.sidebar-title-row h1 {
  margin: 0;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
}

.sidebar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-actions .icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-muted);
}

.sidebar-actions .icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
}

/* Sidebar profile companion card */
.companion-profile-card {
  margin: 12px 16px 6px;
  padding: 12px 16px;
  background: #182229;
  border: 1px solid var(--border);
  border-radius: 10px;
}

.companion-profile-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 6px;
}

.companion-profile-title {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent);
}

.badge-public {
  background: rgba(96, 165, 250, 0.15);
  color: var(--accent);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  border: 1px solid rgba(96, 165, 250, 0.3);
}

.companion-profile-consent {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-soft);
  line-height: 1.4;
}

/* Search container & field */
.search-container {
  padding: 8px 14px;
  background: var(--sidebar-bg);
}

.search-field {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 12px;
  min-height: 36px;
  border-radius: 8px;
  background: var(--field-bg);
  color: var(--text-muted);
  width: 100%;
}

.search-field svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.search-field input {
  width: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--text);
  font-size: 0.85rem;
}

.search-field input::placeholder {
  color: var(--text-muted);
}

/* Chat list */
.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
  background: var(--sidebar-bg);
}

.conversation-item {
  width: 100%;
  border: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text);
  background: transparent;
  text-align: left;
  border-bottom: 1px solid var(--border);
  transition: background 150ms ease;
}

.conversation-item:hover {
  background: #202c33;
}

.conversation-item.active {
  background: #2a3942;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  overflow: hidden;
}

.avatar-contact {
  color: #0b141a;
  background: var(--accent);
  font-weight: 700;
  font-size: 1.15rem;
}

.conversation-main {
  min-width: 0;
  flex: 1;
}

.conversation-top,
.conversation-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.conversation-name {
  font-weight: 500;
  color: var(--text);
  font-size: 0.95rem;
}

.conversation-time {
  color: var(--text-muted);
  font-size: 0.75rem;
}

.conversation-bottom {
  justify-content: flex-start;
  margin-top: 4px;
}

.conversation-preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: 0.8rem;
  flex: 1;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-right: 6px;
  transition: background 200ms ease, opacity 200ms ease;
}

.status-dot.away {
  background: var(--text-muted);
  opacity: 0.6;
}

.status-dot.busy {
  background: #ffb300;
  opacity: 0.8;
}

.status-dot.standby {
  background: #f59e0b;
  opacity: 0.7;
}

/* Sidebar footer */
.sidebar-footer {
  padding: 14px 16px;
  background: var(--sidebar-bg);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: auto;
}

.sidebar-footer .lock-icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* ─── Main Chat Panel ──────────────────────────── */
.chat-panel {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background-color: var(--panel-bg);
  background-image: url("data:image/svg+xml,%3Csvg width='80' height='80' viewBox='0 0 80 80' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='%2353bdeb' fill-opacity='0.03' fill-rule='evenodd'%3E%3Cpath d='M11 18c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm48 25c3.866 0 7-3.134 7-7s-3.134-7-7-7-7 3.134-7 7 3.134 7 7 7zm-43-7c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm63 31c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zM34 90c1.657 0 3-1.343 3-3s-1.343-3-3-3-3 1.343-3 3 1.343 3 3 3zm1-61c3.16 0 5.72-2.56 5.72-5.72 0-3.16-2.56-5.72-5.72-5.72-3.16 0-5.72 2.56-5.72 5.72 0 3.16 2.56 5.72 5.72 5.72zm-2.4 34.6c.22-.11.47-.17.73-.17.94 0 1.7.76 1.7 1.7 0 .26-.06.51-.17.73l-2.26 4.52c-.22.44-.67.72-1.16.72-.72 0-1.3-.58-1.3-1.3 0-.49.28-.94.72-1.16l2.26-4.52zm-32.1-3.7c.22-.11.47-.17.73-.17.94 0 1.7.76 1.7 1.7 0 .26-.06.51-.17.73l-2.26 4.52c-.22.44-.67.72-1.16.72-.72 0-1.3-.58-1.3-1.3 0-.49.28-.94.72-1.16l2.26-4.52zM28.4 14c-.11.22-.17.47-.17.73 0 .94.76 1.7 1.7 1.7.26 0 .51-.06.73-.17l4.52-2.26c.44-.22.72-.67.72-1.16 0-.72-.58-1.3-1.3-1.3-.49 0-.94.28-1.16.72l-2.26 4.52zm38.1-1.3c-.09.18-.14.38-.14.6 0 .77.63 1.4 1.4 1.4.22 0 .42-.05.6-.14l3.7-1.85c.36-.18.6-.54.6-.95 0-.58-.47-1.05-1.05-1.05-.41 0-.77.24-.95.6l-1.85 3.7zM48.5 73c-.09.18-.14.38-.14.6 0 .77.63 1.4 1.4 1.4.22 0 .42-.05.6-.14l3.7-1.85c.36-.18.6-.54.6-.95 0-.58-.47-1.05-1.05-1.05-.41 0-.77.24-.95.6l-1.85 3.7zm-26.6 6c.09-.18.14-.38.14-.6 0-.77-.63-1.4-1.4-1.4-.22 0-.42.05-.6.14l-3.7 1.85c-.36.18-.6.54-.6.95 0 .58.47 1.05 1.05 1.05.41 0 .77-.24.95-.6l1.85-3.7z'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat;
  height: 100%;
}

.chat-header {
  min-height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  padding-top: calc(10px + env(safe-area-inset-top, 0px));
  background: var(--panel-top);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  z-index: 10;
}

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

.contact-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.contact-name-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.contact-name {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
}

.chevron-down-icon {
  width: 14px;
  height: 14px;
  color: var(--text-muted);
}

.contact-status {
  font-size: 0.75rem;
  color: var(--accent); /* Online status in blue/green */
}

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

.chat-actions .icon-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  color: var(--text-muted);
}

.chat-actions .icon-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
}

.reset-button {
  background: transparent;
  border: 1px solid rgba(83, 189, 235, 0.3);
  color: var(--accent);
  padding: 6px 14px;
  border-radius: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  transition: all 150ms ease;
  line-height: 1.2;
}

.reset-button:hover {
  background: rgba(83, 189, 235, 0.1);
  border-color: var(--accent);
}

/* ─── Message Area ────────────────────────────── */
.message-list {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 16px min(5vw, 40px);
  scroll-behavior: smooth;
}

.message-list::-webkit-scrollbar,
.conversation-list::-webkit-scrollbar,
textarea::-webkit-scrollbar {
  width: 6px;
}

.message-list::-webkit-scrollbar-thumb,
.conversation-list::-webkit-scrollbar-thumb,
textarea::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 3px;
}

/* Privacy Note */
.chat-privacy-note {
  align-self: center;
  margin: 10px 0 16px;
  padding: 8px 14px;
  background: #182229;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 0.78rem;
  max-width: 90%;
  text-align: center;
}

.chat-privacy-note .lock-icon-small {
  width: 12px;
  height: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

/* Date separator */
.date-separator {
  align-self: center;
  margin: 6px 0 14px;
  padding: 5px 12px;
  background: #182229;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Message bubbles */
.message {
  max-width: min(75%, 620px);
  display: flex;
  margin-bottom: 10px;
  animation: message-in 180ms ease-out;
}

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

.message.received {
  align-self: flex-start;
}

.message.sent {
  align-self: flex-end;
}

.bubble {
  position: relative;
  padding: 8px 12px 6px;
  border-radius: 8px;
  color: var(--text);
  box-shadow: var(--shadow);
  word-break: break-word;
}

.message.received .bubble {
  background: var(--received-bg);
  border-top-left-radius: 0;
}

.message.sent .bubble {
  background: var(--sent-bg);
  border-top-right-radius: 0;
}

.message-text {
  margin: 0;
  font-size: 0.92rem;
  line-height: 1.45;
  white-space: pre-wrap;
}

.message-meta {
  display: block;
  float: right;
  margin: 6px 0 0 12px;
  font-size: 0.65rem;
  color: var(--text-muted);
}

.message.sent .message-meta {
  color: rgba(233, 237, 239, 0.6);
}

/* Typing bubble */
.typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border-radius: 12px;
  border-top-left-radius: 0;
  min-width: auto;
  background: var(--received-bg);
  color: var(--text-muted);
}

.typing-label {
  display: none;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #9ab6c5;
  animation: typing-dot 1.2s infinite ease-in-out;
}

.typing-dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes typing-dot {
  0%, 80%, 100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  40% {
    opacity: 1;
    transform: translateY(-4px);
  }
}

/* ─── Bottom Composer ──────────────────────────── */
.composer {
  flex-shrink: 0;
  background: var(--composer-bg);
  padding: 10px 16px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border);
}

/* Dropdown actions menu styling */
.dropdown-wrapper {
  position: relative;
  display: inline-block;
}

.dropdown {
  position: absolute;
  top: 48px;
  right: 0;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.6);
  z-index: 100;
  display: flex;
  flex-direction: column;
  padding: 6px 0;
  min-width: 140px;
  animation: dropdown-fade-in 150ms ease;
}

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

.dropdown button {
  padding: 12px 16px;
  width: 100%;
  text-align: left;
  justify-content: flex-start;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-soft);
  background: transparent;
  border-radius: 0;
  border: none;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.dropdown button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--accent);
}

.dropdown button:focus {
  outline: none;
  background: rgba(255, 255, 255, 0.08);
}

.composer-form {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.composer-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: var(--text-muted);
  flex-shrink: 0;
}

.composer-icon:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-soft);
}

.message-input-wrap {
  flex: 1;
  position: relative;
  background: var(--field-bg);
  border-radius: 12px;
  padding: 4px 16px;
  display: flex;
  align-items: center;
}

textarea {
  width: 100%;
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  resize: none;
  font-size: 0.92rem;
  line-height: 1.4;
  padding: 8px 0;
  min-height: 20px;
  max-height: 120px;
  overflow-y: auto;
}

textarea::placeholder {
  color: var(--text-muted);
}

.char-counter {
  position: absolute;
  right: 12px;
  bottom: -18px;
  font-size: 0.68rem;
  color: var(--text-muted);
  opacity: 0;
  pointer-events: none;
  transition: opacity 150ms ease;
}

.message-input-wrap:focus-within .char-counter,
.char-counter.warning,
.char-counter.limit {
  opacity: 0.7;
}

.char-counter.warning {
  color: #ffb300;
}

.char-counter.limit {
  color: var(--danger-text);
}

.send-button {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: var(--accent);
  color: #111b21;
  flex-shrink: 0;
  box-shadow: none;
}

.send-button:hover:not(:disabled) {
  background: var(--accent-strong);
  transform: scale(1.05);
}

.send-button:disabled {
  background: #2a3942;
  color: var(--text-muted);
  cursor: not-allowed;
  transform: none;
}

.send-icon {
  width: 16px;
  height: 16px;
}

/* Error Container */
.notice {
  margin: 8px 16px;
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-radius: 8px;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 0.85rem;
}

.notice-close {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  color: var(--danger-text);
  font-size: 1.1rem;
}

.notice-close:hover {
  background: rgba(255, 255, 255, 0.08);
}

.hidden {
  display: none !important;
}

/* ─── Welcome Gate Overlay ─────────────────────────── */
.welcome-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 17, 30, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: gate-fade-in 250ms ease;
}

@keyframes gate-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.welcome-gate-box {
  width: calc(100% - 32px);
  max-width: 440px;
  background: #1f2937;
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.welcome-gate h2 {
  font-size: 1.6rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.welcome-gate-subtitle {
  font-size: 0.9rem;
  color: var(--text-soft);
  margin: 0;
  line-height: 1.5;
}

.welcome-suggestions {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  width: 100%;
  margin: 8px 0;
}

.suggestion-btn {
  background: #111827;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-soft);
  transition: all 150ms ease;
  text-align: center;
  justify-content: center;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.suggestion-btn:hover {
  background: var(--field-bg-focus);
  color: var(--accent);
  border-color: var(--accent);
}

.welcome-gate-btn {
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: #111827;
  font-weight: 700;
  font-size: 0.95rem;
  border: none;
  border-radius: 24px;
  cursor: pointer;
  transition: background 150ms ease;
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.welcome-gate-btn:hover {
  background: var(--accent-strong);
}

.welcome-gate-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 4px;
  filter: drop-shadow(0 0 20px rgba(96, 165, 250, 0.3));
}

@media (max-width: 767px) {
  /* Welcome Gate Mobile adjustments to prevent vertical overflow */
  .welcome-gate-box {
    padding: 20px 16px;
    gap: 12px;
    max-height: 85dvh;
    overflow-y: auto;
    width: calc(100% - 24px);
  }

  .welcome-gate h2 {
    font-size: 1.35rem;
  }

  .welcome-suggestions {
    gap: 8px;
  }

  .suggestion-btn {
    padding: 10px;
    font-size: 0.8rem;
  }

  .welcome-gate-btn {
    padding: 12px;
    font-size: 0.9rem;
    min-height: 44px;
  }
}

/* ─── Responsiveness ────────────────────────────── */
@media (max-width: 1023px) {
  .sidebar-collapsed .sidebar {
    display: none !important;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 50;
    width: 280px;
    min-width: 280px;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.5);
    display: flex;
  }

  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    z-index: 40;
    display: block;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    animation: overlay-fade-in 150ms ease;
  }

  .sidebar-collapsed .sidebar-overlay {
    display: none !important;
  }

  .chat-header {
    padding: 10px 14px;
  }

  .message-list {
    padding: 16px 14px;
  }

  .message {
    max-width: 85%;
  }

  .composer {
    padding: 8px 12px;
  }

  .composer-icon {
    width: 36px;
    height: 36px;
  }
}

@media (max-width: 767px) {
  /* Hide sidebar and toggle completely on mobile */
  .sidebar {
    display: none !important;
  }
  .sidebar-overlay {
    display: none !important;
  }
  .sidebar-toggle {
    display: none !important;
  }

  /* Full screen chat panel on mobile */
  .chat-panel {
    width: 100%;
    max-width: 100%;
    flex: 1;
  }

  /* Adjust header padding and layout */
  .chat-header {
    padding-left: 16px;
    padding-right: 16px;
    min-height: 56px;
  }

  /* Touch targets for headers */
  .chat-actions .icon-button {
    width: 44px;
    height: 44px;
  }

  /* Message spacing and sizing */
  .message-list {
    padding: 12px 14px;
  }
  
  .message {
    max-width: 82%;
    margin-bottom: 8px;
  }

  .bubble {
    padding: 10px 14px 8px;
    border-radius: 12px;
  }

  .message.received .bubble {
    border-top-left-radius: 2px;
  }

  .message.sent .bubble {
    border-top-right-radius: 2px;
  }

  .message-text {
    font-size: 15px;
    line-height: 1.5;
  }

  .message-meta {
    margin-top: 4px;
  }

  /* Composer optimizations */
  .composer {
    padding: 8px 12px calc(10px + env(safe-area-inset-bottom, 0px));
  }

  .composer-form {
    gap: 8px;
  }

  /* Hide decorative composer icons to maximize text area space */
  .composer-icon {
    display: none !important;
  }

  /* Expand wrap & buttons for mobile input */
  .message-input-wrap {
    padding: 6px 14px;
    border-radius: 20px;
    background: var(--field-bg);
  }

  textarea {
    font-size: 15px;
    line-height: 1.4;
    padding: 6px 0;
    max-height: 100px;
  }

  .send-button {
    width: 44px;
    height: 44px;
    display: inline-flex !important; /* Ensure send button is visible */
  }

  /* Age Gate Mobile adjustments to prevent vertical overflow */
  .age-gate-box {
    padding: 20px 16px;
    gap: 12px;
    max-height: 85dvh;
    overflow-y: auto;
    width: calc(100% - 24px);
  }

}
/* ─── Settings Modal & Sleek Toggle ────────────────── */
.settings-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 17, 30, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  animation: settings-fade-in 200ms ease;
}

@keyframes settings-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.settings-box {
  width: calc(100% - 32px);
  max-width: 480px;
  background: #1f2937;
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: settings-slide-up 250ms cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes settings-slide-up {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.settings-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
}

.settings-header h2 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text);
  margin: 0;
}

.settings-close-btn {
  font-size: 1.5rem;
  color: var(--text-muted);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: background 150ms ease, color 150ms ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-close-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-soft);
}

.settings-content {
  padding: 24px;
}

.settings-group {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.settings-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
}

.settings-option-vertical {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.settings-option-vertical h3 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  margin: 0;
}

.settings-option-vertical p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

.tone-selector {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 8px;
}

.tone-radio {
  cursor: pointer;
  position: relative;
}

.tone-radio input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.tone-radio span {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px;
  background: var(--field-bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: all 150ms ease;
  text-align: center;
}

.tone-radio input:checked + span {
  background: var(--sent-bg);
  border-color: var(--accent);
  color: var(--text);
}

.tone-radio span:hover {
  background: var(--field-bg-focus);
  color: var(--text-soft);
}

.settings-option-text {
  flex: 1;
}

.settings-option-text h3 {
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  margin: 0 0 4px;
}

.settings-option-text p {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.4;
}

/* Switch control */
.switch-control {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 28px;
  flex-shrink: 0;
}

.switch-control input {
  opacity: 0;
  width: 0;
  height: 0;
}

.switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: var(--field-bg);
  transition: .4s;
  border-radius: 34px;
  border: 1px solid var(--border);
}

.switch-slider:before {
  position: absolute;
  content: "";
  height: 20px;
  width: 20px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text-muted);
  transition: .4s;
  border-radius: 50%;
}

.switch-control input:checked + .switch-slider {
  background-color: var(--sent-bg);
  border-color: var(--accent);
}

.switch-control input:checked + .switch-slider:before {
  transform: translateX(22px);
  background-color: var(--accent);
}

/* Unavailable composer styles */
.message-input-wrap.unavailable textarea::placeholder {
  opacity: 0.55;
  color: var(--text-muted);
  font-style: italic;
}

/* ─── Brand Logo & Branding ────────────────────── */
.brand-block {
  display: flex;
  align-items: center;
  gap: 10px;
}

.sidebar-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
}

.avatar-contact {
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
}

.avatar-contact .brand-logo {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Welcome Gate Logo styling */
.welcome-gate-logo {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 4px;
  filter: drop-shadow(0 0 20px rgba(96, 165, 250, 0.3));
}

/* Empty State styling */
.chat-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin: auto;
  padding: 40px 24px;
  max-width: 380px;
  animation: empty-state-fade-in 300ms ease-out;
}

@keyframes empty-state-fade-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.empty-state-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  margin-bottom: 16px;
}

.empty-state-logo {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 0 15px rgba(96, 165, 250, 0.25));
}

.empty-state-title {
  font-size: 1.8rem;
  font-weight: 500;
  color: var(--text);
  margin: 0;
  letter-spacing: 0.5px;
}

.empty-state-subtitle {
  font-size: 0.88rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

@media (max-width: 767px) {
  .chat-header .avatar-contact {
    width: 32px;
    height: 32px;
  }
}

