:root {
  --bg-app: #f1f5f9;
  --bg-rail: #ffffff;
  --bg-sidebar: #ffffff;
  --bg-chat: #efeae2;
  --bg-card: #ffffff;
  --bg-hover: #f8fafc;
  --bg-active: #e6f7f5;
  --bg-pill: #f1f5f9;
  --bubble-mine: #dcfce7;
  --bubble-mine-text: #0f172a;
  --bubble-theirs: #ffffff;
  --bubble-theirs-text: #0f172a;
  --border: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --accent: #0d9488;
  --accent-hover: #0f766e;
  --accent-soft: rgba(13, 148, 136, 0.12);
  --danger: #e11d48;
  --danger-soft: #fff1f2;
  --amber-soft: #fffbeb;
  --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
  --shadow-md: 0 12px 28px rgba(15, 23, 42, 0.1);
}

[data-theme="dark"] {
  --bg-app: #090e1a;
  --bg-rail: #0f172a;
  --bg-sidebar: #11192d;
  --bg-chat: #0b1220;
  --bg-card: #162036;
  --bg-hover: #1d2a46;
  --bg-active: #123638;
  --bg-pill: #1e293b;
  --bubble-mine: #065f46;
  --bubble-mine-text: #f8fafc;
  --bubble-theirs: #1e293b;
  --bubble-theirs-text: #f1f5f9;
  --border: #25334d;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent: #14b8a6;
  --accent-hover: #2dd4bf;
  --accent-soft: rgba(20, 184, 166, 0.16);
  --danger: #fb7185;
  --danger-soft: rgba(225, 29, 72, 0.15);
  --amber-soft: rgba(245, 158, 11, 0.15);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.35);
  --shadow-md: 0 14px 32px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

body {
  background: var(--bg-app);
  color: var(--text-main);
  height: 100dvh;
  overflow: hidden;
}

.hidden {
  display: none !important;
}

.muted {
  font-size: 12px;
  color: var(--text-muted);
}

.strong-text {
  font-weight: 700;
  font-size: 15px;
}

/* ==================== AUTH SHELL ==================== */
.auth-shell {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: radial-gradient(circle at top right, rgba(13, 148, 136, 0.18), transparent 45%), var(--bg-app);
  overflow-y: auto;
}

.auth-card {
  width: 100%;
  max-width: 430px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 22px;
  padding: 24px;
  box-shadow: var(--shadow-md);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
}

.auth-brand h1 {
  font-size: 20px;
  font-weight: 800;
}

.preview-banner {
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 12px;
  padding: 10px 12px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.mini-pill-btn {
  border: none;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  padding: 6px 10px;
  font-size: 11px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  background: var(--bg-pill);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 16px;
}

.auth-tab {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 13px;
  padding: 8px;
  border-radius: 9px;
  cursor: pointer;
}

.auth-tab.active {
  background: var(--bg-card);
  color: var(--text-main);
  box-shadow: var(--shadow-sm);
}

.auth-form, .form-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
}

.field input, .clean-select {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--bg-app);
  color: var(--text-main);
  font-size: 14px;
  outline: none;
}

.field input:focus {
  border-color: var(--accent);
}

.hint-tag {
  font-style: normal;
  font-weight: 600;
  font-size: 11px;
  margin-left: 4px;
}

.hint-tag.ok { color: #16a34a; }
.hint-tag.bad { color: var(--danger); }

.auth-feedback {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  background: var(--danger-soft);
  color: var(--danger);
}

.auth-feedback.ok {
  background: var(--accent-soft);
  color: var(--accent);
}

.quick-demo-box {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px dashed var(--border);
}

.quick-demo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

/* ==================== BUTTONS & AVATARS ==================== */
.primary-btn {
  border: none;
  border-radius: 12px;
  background: var(--accent);
  color: #ffffff;
  font-weight: 700;
  font-size: 14px;
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.15s;
}
.primary-btn:hover { background: var(--accent-hover); }
.primary-btn.full { width: 100%; }

.soft-btn {
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--bg-pill);
  color: var(--text-main);
  font-weight: 600;
  font-size: 12px;
  padding: 8px 12px;
  cursor: pointer;
}
.soft-btn:hover { background: var(--bg-hover); }

.danger-btn {
  border: 1px solid rgba(225, 29, 72, 0.35);
  border-radius: 11px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 700;
  font-size: 12px;
  padding: 8px 12px;
  cursor: pointer;
}

.brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, #0d9488, #4f46e5);
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(13, 148, 136, 0.25);
}
.brand-logo.lg { width: 48px; height: 48px; font-size: 16px; }

.avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.avatar.lg { width: 56px; height: 56px; font-size: 18px; }
.avatar-badge {
  position: absolute;
  right: -2px;
  bottom: -2px;
  font-size: 12px;
  background: var(--bg-card);
  border-radius: 50%;
  padding: 1px;
}

/* ==================== APP SHELL ==================== */
.app-shell {
  display: flex;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

.nav-rail {
  width: 72px;
  background: var(--bg-rail);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px 8px;
  gap: 8px;
  flex-shrink: 0;
}

.rail-btn {
  width: 58px;
  padding: 9px 4px;
  border-radius: 14px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  font-size: 11px;
  font-weight: 600;
}
.rail-btn.active { background: var(--accent-soft); color: var(--accent); }
.rail-icon { font-size: 18px; }
.rail-spacer { flex: 1; }

.rail-icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-card);
  cursor: pointer;
  font-size: 16px;
}

.user-rail-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
}

.conn-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
}
.conn-dot.offline { background: #f59e0b; }

.outbox-pill {
  background: #f59e0b;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
}

.main-view {
  flex: 1;
  display: none;
  min-width: 0;
  height: 100%;
}
.main-view.active { display: flex; }

/* ==================== CHATS VIEW ==================== */
.chat-sidebar {
  width: 340px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  position: relative;
}

.sidebar-top {
  padding: 16px 16px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.title-row { display: flex; align-items: center; gap: 8px; }
.sidebar-title { font-size: 22px; font-weight: 800; }
.sidebar-sub { font-size: 12px; color: var(--text-muted); }

.mode-chip {
  border: 1px solid var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  cursor: pointer;
}

.top-actions { display: flex; gap: 6px; }
.soft-icon-btn, .circle-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-pill);
  color: var(--text-main);
  cursor: pointer;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.circle-btn { background: var(--accent); color: #fff; border: none; font-weight: 800; }

.search-wrap {
  margin: 4px 14px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-pill);
  border-radius: 12px;
  padding: 8px 12px;
}
.search-wrap input {
  border: none;
  background: transparent;
  color: var(--text-main);
  width: 100%;
  font-size: 13px;
  outline: none;
}

.user-search-dropdown {
  margin: 0 14px 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-card);
  box-shadow: var(--shadow-md);
  max-height: 220px;
  overflow-y: auto;
}
.user-search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
}
.user-search-item:hover { background: var(--bg-hover); }

.filter-pills {
  display: flex;
  gap: 6px;
  padding: 0 14px 10px;
  overflow-x: auto;
}
.pill-filter {
  border: none;
  border-radius: 999px;
  background: var(--bg-pill);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 12px;
  cursor: pointer;
  white-space: nowrap;
}
.pill-filter.active { background: var(--accent); color: #ffffff; }
.count-pill {
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 3px;
}

.conversation-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}
.conv-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px;
  border-radius: 14px;
  cursor: pointer;
}
.conv-row:hover { background: var(--bg-hover); }
.conv-row.active { background: var(--bg-active); }
.conv-meta { flex: 1; min-width: 0; }
.conv-top { display: flex; justify-content: space-between; align-items: baseline; gap: 6px; }
.conv-title { font-weight: 700; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conv-time { font-size: 11px; color: var(--text-muted); }
.conv-preview { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }

/* ==================== CHAT PANE & 6 GEN-Z THEMES ==================== */
.chat-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg-chat);
  position: relative;
}

.chat-pane[data-chat-theme="midnight"] {
  background: linear-gradient(160deg, #0f172a 0%, #1e1b4b 55%, #090e1a 100%);
  --bubble-mine: #4f46e5;
  --bubble-mine-text: #ffffff;
  --bubble-theirs: #1e293b;
  --bubble-theirs-text: #f8fafc;
}
.chat-pane[data-chat-theme="sunset"] {
  background: linear-gradient(160deg, #fff1f2 0%, #ffedd5 100%);
  --bubble-mine: #fb7185;
  --bubble-mine-text: #ffffff;
}
[data-theme="dark"] .chat-pane[data-chat-theme="sunset"] {
  background: linear-gradient(160deg, #3b0d1e 0%, #431407 100%);
  --bubble-mine: #e11d48;
  --bubble-mine-text: #ffffff;
}
.chat-pane[data-chat-theme="ocean"] {
  background: linear-gradient(160deg, #ecfeff 0%, #e0f2fe 100%);
  --bubble-mine: #0284c7;
  --bubble-mine-text: #ffffff;
}
[data-theme="dark"] .chat-pane[data-chat-theme="ocean"] {
  background: linear-gradient(160deg, #082f49 0%, #0f172a 100%);
  --bubble-mine: #0369a1;
  --bubble-mine-text: #ffffff;
}
.chat-pane[data-chat-theme="forest"] {
  background: linear-gradient(160deg, #ecfdf5 0%, #dcfce7 100%);
  --bubble-mine: #059669;
  --bubble-mine-text: #ffffff;
}
[data-theme="dark"] .chat-pane[data-chat-theme="forest"] {
  background: linear-gradient(160deg, #022c22 0%, #0f172a 100%);
  --bubble-mine: #047857;
  --bubble-mine-text: #ffffff;
}
.chat-pane[data-chat-theme="lavender"] {
  background: linear-gradient(160deg, #f5f3ff 0%, #fae8ff 100%);
  --bubble-mine: #7c3aed;
  --bubble-mine-text: #ffffff;
}
[data-theme="dark"] .chat-pane[data-chat-theme="lavender"] {
  background: linear-gradient(160deg, #2e1065 0%, #1e1b4b 100%);
  --bubble-mine: #6d28d9;
  --bubble-mine-text: #ffffff;
}

.chat-header {
  background: var(--bg-rail);
  border-bottom: 1px solid var(--border);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.chat-head-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.chat-head-actions { display: flex; align-items: center; gap: 6px; }
.mobile-back-btn { display: none; border: none; background: transparent; font-size: 20px; color: var(--text-main); cursor: pointer; }

.pinned-banner, .request-banner {
  padding: 8px 16px;
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
}
.request-banner { background: var(--amber-soft); }

.ai-drawer {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.ai-drawer-head { display: flex; justify-content: space-between; align-items: center; font-size: 13px; font-weight: 700; }
.ai-drawer-head em { font-style: normal; font-weight: 500; font-size: 11px; color: var(--text-muted); }
.ai-recap-box { font-size: 12px; background: var(--bg-pill); padding: 8px 10px; border-radius: 10px; }
.ai-section-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.ai-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.ai-chip, .ai-tone-btn {
  border: 1px solid var(--border);
  background: var(--bg-pill);
  color: var(--text-main);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.ai-chip:hover, .ai-tone-btn:hover { border-color: var(--accent); color: var(--accent); }

.message-stream {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.load-older-wrap { display: flex; justify-content: center; margin-bottom: 8px; }

.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 74%;
  position: relative;
}
.msg-row.mine { align-self: flex-end; align-items: flex-end; }
.msg-row.theirs { align-self: flex-start; align-items: flex-start; }

.msg-sender { font-size: 11px; font-weight: 700; color: var(--text-muted); margin-bottom: 2px; padding: 0 6px; }

.msg-bubble {
  padding: 9px 13px;
  border-radius: 16px;
  background: var(--bubble-theirs);
  color: var(--bubble-theirs-text);
  box-shadow: var(--shadow-sm);
  font-size: 14px;
  line-height: 1.42;
  word-break: break-word;
  user-select: text;
}
.msg-row.mine .msg-bubble {
  background: var(--bubble-mine);
  color: var(--bubble-mine-text);
  border-bottom-right-radius: 4px;
}
.msg-row.theirs .msg-bubble {
  border-bottom-left-radius: 4px;
}
.msg-bubble.deleted { font-style: italic; opacity: 0.7; }

.msg-reply-quote {
  font-size: 11px;
  border-left: 3px solid var(--accent);
  padding-left: 8px;
  margin-bottom: 5px;
  opacity: 0.85;
}

.spoiler-token {
  background: rgba(100, 116, 139, 0.45);
  color: transparent;
  text-shadow: 0 0 8px rgba(15, 23, 42, 0.9);
  border-radius: 6px;
  padding: 1px 5px;
  cursor: pointer;
  transition: all 0.15s;
}
.spoiler-token.revealed {
  background: var(--accent-soft);
  color: inherit;
  text-shadow: none;
}

.msg-link { color: inherit; text-decoration: underline; }
.msg-link.suspicious { color: #e11d48; font-weight: 700; }

.msg-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  opacity: 0.72;
  margin-top: 4px;
  justify-content: flex-end;
}

.msg-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react-chip {
  border: 1px solid var(--border);
  background: var(--bg-card);
  color: var(--text-main);
  border-radius: 999px;
  font-size: 11px;
  padding: 2px 7px;
  cursor: pointer;
}
.react-chip.mine { border-color: var(--accent); background: var(--accent-soft); }

.msg-actions {
  display: none;
  gap: 4px;
  margin-top: 4px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 2px 6px;
  box-shadow: var(--shadow-sm);
}
.msg-row:hover .msg-actions { display: flex; }
.msg-act-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 4px;
  color: var(--text-main);
}

.typing-indicator { padding: 4px 18px; font-size: 12px; color: var(--text-muted); font-style: italic; }

.context-bar {
  background: var(--bg-card);
  border-top: 1px solid var(--border);
  padding: 7px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
}

.composer-wrap { padding: 10px 16px 14px; }
.composer-pill {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 5px 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  box-shadow: var(--shadow-sm);
}
.composer-pill input {
  flex: 1;
  border: none;
  background: transparent;
  color: var(--text-main);
  font-size: 14px;
  outline: none;
  min-width: 0;
}
.comp-icon-btn {
  border: none;
  background: transparent;
  font-size: 18px;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
}
.comp-icon-btn.active { background: var(--accent-soft); }
.send-circle-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
}

.popover-anchor { position: relative; }
.emoji-popover {
  position: absolute;
  bottom: 46px;
  left: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  display: flex;
  gap: 6px;
  box-shadow: var(--shadow-md);
  z-index: 20;
}
.emoji-popover button { border: none; background: transparent; font-size: 18px; cursor: pointer; }

/* ==================== SAFETY & PROFILE PAGES ==================== */
.page-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 22px;
  max-width: 1120px;
  margin: 0 auto;
  width: 100%;
}

.safety-hero {
  background: linear-gradient(135deg, #0f172a, #1e1b4b);
  color: #ffffff;
  border-radius: 20px;
  padding: 22px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}
.safety-badge { font-size: 11px; font-weight: 800; letter-spacing: 0.06em; color: #5eead4; margin-bottom: 6px; }
.safety-hero p { font-size: 13px; color: #cbd5e1; max-width: 520px; margin-top: 6px; }
.sos-box { display: flex; flex-direction: column; gap: 8px; min-width: 250px; }
.sos-btn {
  border: none;
  border-radius: 14px;
  background: #e11d48;
  color: #ffffff;
  font-weight: 800;
  font-size: 14px;
  padding: 12px 18px;
  cursor: pointer;
}
.sos-note-input {
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
}
.gps-check { font-size: 12px; color: #e2e8f0; display: flex; align-items: center; gap: 6px; }

.cards-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 18px;
  box-shadow: var(--shadow-sm);
}
.card.full-width { grid-column: 1 / -1; }
.card-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.card-desc { font-size: 13px; color: var(--text-muted); margin-bottom: 12px; }
.sub-label { font-size: 11px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; margin: 14px 0 8px; }

.tag-pill { background: var(--bg-pill); color: var(--text-muted); font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px; }
.tag-pill.green { background: var(--accent-soft); color: var(--accent); }

.clean-list { display: flex; flex-direction: column; gap: 8px; }
.list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-pill);
  font-size: 13px;
}

.switches-list { display: flex; flex-direction: column; gap: 10px; }
.switch-row-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--bg-pill);
}
.switch { position: relative; width: 42px; height: 24px; display: inline-block; flex-shrink: 0; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; inset: 0; background: #94a3b8; border-radius: 999px; cursor: pointer; transition: 0.2s; }
.slider:before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; bottom: 3px; background: #fff; border-radius: 50%; transition: 0.2s; }
.switch input:checked + .slider { background: var(--accent); }
.switch input:checked + .slider:before { transform: translateX(18px); }

.choice-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.choice-card {
  border: 2px solid var(--border);
  background: var(--bg-pill);
  color: var(--text-main);
  border-radius: 14px;
  padding: 12px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.choice-card span { font-size: 12px; color: var(--text-muted); }
.choice-card.selected { border-color: var(--accent); background: var(--accent-soft); }

.profile-preview-top { display: flex; align-items: center; gap: 12px; margin-bottom: 14px; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.vibe-presets, .gradient-row { display: flex; flex-wrap: wrap; gap: 6px; }
.vibe-pill {
  border: 1px solid var(--border);
  background: var(--bg-pill);
  color: var(--text-main);
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  cursor: pointer;
}
.grad-swatch { width: 26px; height: 26px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.grad-swatch.selected { border-color: var(--text-main); }

.invite-box { display: flex; gap: 8px; margin-top: 14px; }
.invite-box input { flex: 1; padding: 8px 10px; border-radius: 10px; border: 1px solid var(--border); background: var(--bg-app); color: var(--text-main); font-size: 12px; }
.fingerprint-box { background: var(--bg-pill); padding: 10px 12px; border-radius: 12px; display: flex; justify-content: space-between; align-items: center; font-size: 12px; }
.inline-action { display: flex; gap: 8px; align-items: center; }
.inline-action input { flex: 1; }
.sep { border: none; border-top: 1px solid var(--border); margin: 16px 0; }
.mode-status-card { margin-top: 12px; padding: 10px 12px; border-radius: 12px; background: var(--bg-pill); font-size: 12px; }

/* ==================== MODAL & TOAST ==================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 50;
}
.modal-card {
  width: 100%;
  max-width: 480px;
  max-height: 85dvh;
  overflow-y: auto;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-md);
}
.modal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.close-x { border: none; background: var(--bg-pill); color: var(--text-main); width: 30px; height: 30px; border-radius: 50%; cursor: pointer; }
.close-x.sm { width: 24px; height: 24px; font-size: 12px; }
.modal-body { display: flex; flex-direction: column; gap: 12px; font-size: 13px; }

.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: #0f172a;
  color: #ffffff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  box-shadow: var(--shadow-md);
  z-index: 100;
}

/* ==================== MOBILE RESPONSIVE (< 768px) ==================== */
@media (max-width: 767px) {
  .app-shell { flex-direction: column-reverse; }
  .nav-rail {
    width: 100%;
    height: 60px;
    flex-direction: row;
    justify-content: space-around;
    border-right: none;
    border-top: 1px solid var(--border);
    padding: 4px 8px;
  }
  .brand-logo, .rail-spacer, #btnThemeToggle, #statusPill { display: none; }
  .chat-sidebar { width: 100%; }
  #view-chats .chat-pane { display: none; }
  #view-chats.mobile-chat-open .chat-sidebar { display: none; }
  #view-chats.mobile-chat-open .chat-pane { display: flex; width: 100%; }
  .mobile-back-btn { display: inline-flex; }
  .cards-grid, .choice-row, .two-col { grid-template-columns: 1fr; }
  .msg-row { max-width: 86%; }
}
