* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple:       #7C3AED;
  --purple-dark:  #5B21B6;
  --purple-light: #EDE9FE;
  --bg:           #F5F4FA;
  --white:        #ffffff;
  --text:         #1F2937;
  --text-2:       #6B7280;
  --border:       #E8E5F0;
  --danger:       #e53935;
  --success:      #7C3AED;
  --sidebar-w:    300px;
  --header-h:     60px;
  --muted:        #9ca3af;
  --accent:       #5B21B6;
  --secondary:    #EDE9FE;
  --shadow-sm:    0 1px 4px rgba(124,58,237,0.08);
  --shadow-md:    0 4px 16px rgba(124,58,237,0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ═══════════════════════════════════════════════
   AUTH SCREEN
══════════════════════════════════════════════════ */

#auth-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
}

.auth-card {
  background: var(--white);
  border-radius: 24px;
  box-shadow: 0 8px 48px rgba(124,58,237,0.15), 0 2px 12px rgba(0,0,0,0.06);
  padding: 44px 40px;
  width: 100%;
  max-width: 400px;
}

.auth-card h1 {
  text-align: center;
  color: var(--purple);
  font-size: 1.8rem;
  margin-bottom: 4px;
}

.auth-card .tagline {
  text-align: center;
  color: var(--purple);
  font-size: 0.88rem;
  font-style: italic;
  font-weight: 400;
  line-height: 1.55;
  margin-bottom: 28px;
  opacity: 0.85;
}

.tab-row {
  display: flex;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
  margin-bottom: 24px;
}

.tab-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: var(--white);
  color: var(--text-2);
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: var(--purple);
  color: white;
}

.form-group { margin-bottom: 16px; }

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-group input,
.form-group textarea {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
  background: #fafafa;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--purple);
  background: white;
}

.btn {
  display: block;
  width: 100%;
  padding: 13px;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 14px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s, transform 0.12s, box-shadow 0.18s;
  text-align: center;
  font-family: inherit;
  box-shadow: 0 2px 8px rgba(124,58,237,0.2);
}

.btn:hover {
  background: var(--purple-dark);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(124,58,237,0.3);
}
.btn:active { transform: translateY(0); }
.btn:disabled { background: #c4b5fd; cursor: not-allowed; box-shadow: none; transform: none; }

.btn.secondary {
  background: var(--purple-light);
  color: var(--purple);
  box-shadow: none;
}
.btn.secondary:hover {
  background: #DDD6FE;
  color: var(--purple-dark);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(124,58,237,0.12);
}

.error-msg {
  color: var(--danger);
  font-size: 0.85rem;
  margin-top: 8px;
}

.forgot-link-row { text-align: center; margin-top: 14px; }

/* ─── Signup checkboxes ─── */
.signup-checks {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}

.check-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.88rem;
  color: var(--text);
  cursor: pointer;
  line-height: 1.4;
}

.check-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  flex-shrink: 0;
  accent-color: var(--purple);
  cursor: pointer;
}

.tos-link {
  background: none;
  border: none;
  padding: 0;
  color: var(--purple);
  font-size: inherit;
  font-weight: 600;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.tos-link:hover { color: var(--purple-dark); }

/* ─── Terms of Service modal ─── */
.tos-modal { max-width: 560px; }

.tos-effective {
  font-size: 0.82rem;
  color: var(--text-2);
  margin-bottom: 20px;
}

.tos-section {
  margin-bottom: 18px;
}

.tos-section h3 {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}

.tos-section p {
  font-size: 0.88rem;
  color: var(--text-2);
  line-height: 1.55;
  margin: 0 0 6px;
}

.tos-section ul {
  margin: 6px 0 0 18px;
  padding: 0;
}

.tos-section ul li {
  font-size: 0.88rem;
  color: var(--text-2);
  line-height: 1.55;
  margin-bottom: 4px;
}

.forgot-link {
  background: none;
  border: none;
  color: var(--purple);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.forgot-link:hover { color: var(--purple-dark); }

.auth-alt-view { padding-top: 4px; }

.back-link {
  background: none;
  border: none;
  color: var(--purple);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
  font-weight: 600;
  margin-bottom: 20px;
  display: inline-block;
}
.back-link:hover { text-decoration: underline; }

.auth-alt-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 8px;
}

.auth-alt-subtitle {
  font-size: 0.88rem;
  color: var(--text-2);
  line-height: 1.5;
  margin-bottom: 4px;
}

.auth-sent-icon {
  font-size: 2.8rem;
  margin-bottom: 12px;
  text-align: center;
}

/* ═══════════════════════════════════════════════
   APP SHELL
══════════════════════════════════════════════════ */

#app-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ─── HEADER: visually split between sidebar and chat ─── */
.app-header {
  height: var(--header-h);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  position: relative;
  z-index: 20;
  box-shadow: 0 1px 0 var(--border);
}

.header-left {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 8px;
  flex-shrink: 0;
}

.logo {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--purple);
  flex: 1;
  letter-spacing: -0.3px;
}

.menu-btn {
  background: none;
  border: none;
  color: var(--text-2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
  flex-shrink: 0;
}
.menu-btn:hover { background: var(--border); }

.header-center {
  flex: 1;
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 20px;
  min-width: 0;
  gap: 10px;
  font-size: 0.97rem;
  font-weight: 600;
  color: var(--text);
}

.header-right {
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 4px;
  flex-shrink: 0;
}

/* ─── LAYOUT ─── */
.app-layout {
  display: flex;
  flex: 1;
  overflow: hidden;
  position: relative;
}

/* ═══════════════════════════════════════════════
   SIDEBAR
══════════════════════════════════════════════════ */

.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
  transition: transform 0.25s ease;
}

.sidebar-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 49;
}

/* ─── Profile row ─── */
.sidebar-profile-section {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

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

.sidebar-profile-info {
  flex: 1;
  min-width: 0;
}

.sidebar-my-username {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-edit-btn {
  background: none;
  border: none;
  color: var(--purple);
  font-size: 0.73rem;
  cursor: pointer;
  padding: 0;
  font-weight: 500;
  margin-top: 2px;
  display: block;
}
.profile-edit-btn:hover { text-decoration: underline; }

.sidebar-logout-btn {
  background: none;
  border: none;
  color: var(--text-2);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.sidebar-logout-btn:hover { background: #ffebee; color: var(--danger); }

/* ─── Search ─── */
.sidebar-search-section {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.search-input {
  width: 100%;
  background: var(--bg);
  border: 1.5px solid transparent;
  border-radius: 22px;
  padding: 9px 18px;
  font-size: 0.9rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
  color: var(--text);
}
.search-input:focus {
  background: var(--white);
  border-color: var(--purple);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.09);
}
.search-input::placeholder { color: var(--muted); }

/* Search results */
.sidebar-section {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-label {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  margin-bottom: 8px;
}

/* ─── Invite code ─── */
.sidebar-invite-section { }

.sidebar-invite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sidebar-code {
  font-size: 1.2rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--purple);
  font-family: monospace;
}

.btn-copy-sm {
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 5px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-copy-sm:hover { background: var(--purple-dark); }
.btn-copy-sm.copied { background: var(--success); }

/* Invite connect row */
.invite-connect-row {
  display: flex;
  gap: 6px;
}

.invite-connect-row input {
  flex: 1;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.9rem;
  outline: none;
  background: var(--bg);
  min-width: 0;
  font-family: monospace;
  text-align: center;
  letter-spacing: 2px;
}
.invite-connect-row input:focus { border-color: var(--purple); background: white; }

.invite-connect-btn {
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
}
.invite-connect-btn:hover { background: var(--purple-dark); }
.invite-connect-btn:disabled { background: #bbb; cursor: not-allowed; }

/* ─── Sidebar tabs ─── */
.sidebar-tabs {
  display: flex;
  padding: 8px 10px;
  gap: 4px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-tab {
  flex: 1;
  background: none;
  border: none;
  border-radius: 20px;
  padding: 7px 10px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  color: var(--text-2);
  transition: background 0.15s, color 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  font-family: inherit;
}
.sidebar-tab.active { background: var(--purple-light); color: var(--purple); }
.sidebar-tab:hover:not(.active) { background: var(--bg); color: var(--text); }

.sidebar-tab-panel {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

/* ─── Conversations ─── */
#conversations-list {
  flex: 1;
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 18px;
  cursor: pointer;
  transition: background 0.18s;
  position: relative;
}
.conversation-item:hover { background: var(--purple-light); }
.conversation-item.active {
  background: var(--purple-light);
  border-left: 3px solid var(--purple);
  padding-left: 15px;
}

.convo-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  flex-shrink: 0;
}

.convo-info {
  flex: 1;
  min-width: 0;
}

.convo-name {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.convo-name.has-unread { font-weight: 700; }

.convo-preview {
  font-size: 0.8rem;
  color: var(--text-2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  margin-top: 2px;
}
.convo-preview.has-unread { color: var(--text); font-weight: 600; }

.convo-time {
  font-size: 0.72rem;
  color: var(--text-2);
}

.no-convos {
  padding: 28px 16px;
  font-size: 0.84rem;
  color: var(--text-2);
  line-height: 1.6;
  text-align: center;
}

/* ─── Unread indicators ─── */
.unread-dot {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--purple);
  border: 2.5px solid white;
}

.unread-badge {
  background: var(--purple);
  color: white;
  font-size: 0.68rem;
  font-weight: 700;
  border-radius: 12px;
  padding: 2px 7px;
  min-width: 20px;
  text-align: center;
  flex-shrink: 0;
}

/* ─── Search results ─── */
.search-result-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }

.result-username {
  font-size: 0.9rem;
  font-weight: 600;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text);
}

.btn-connect-sm {
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-connect-sm:hover { background: var(--purple-dark); }

.btn-chat-sm {
  background: var(--purple-light);
  color: var(--purple);
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-chat-sm:hover { background: var(--border); }

.btn-requested-sm {
  background: var(--bg);
  color: var(--text-2);
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: not-allowed;
  white-space: nowrap;
}

.no-results {
  font-size: 0.84rem;
  color: var(--text-2);
  padding: 4px 0;
}

/* ─── Requests (in sidebar tab panel) ─── */
.requests-badge {
  background: var(--purple);
  color: white;
  font-size: 0.65rem;
  font-weight: 700;
  border-radius: 10px;
  padding: 2px 6px;
  min-width: 18px;
  text-align: center;
  line-height: 1.4;
}

.request-item {
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
  cursor: default;
}
.request-item:last-child { border-bottom: none; }
.request-item:hover { background: var(--bg); }

.request-item-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.request-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.request-username {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.request-first-message {
  margin-top: 8px;
  font-size: 0.83rem;
  color: var(--text-2);
  line-height: 1.45;
  padding: 8px 12px;
  background: var(--bg);
  border-radius: 0 12px 12px 12px;
  white-space: pre-wrap;
  word-break: break-word;
}

.request-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

.btn-accept-sm {
  background: var(--success);
  color: white;
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-accept-sm:hover { background: #5a7460; }

.btn-reject-sm {
  background: var(--bg);
  color: var(--text-2);
  border: none;
  border-radius: 20px;
  padding: 6px 14px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  white-space: nowrap;
}
.btn-reject-sm:hover { background: #ffebee; color: var(--danger); }

/* ═══════════════════════════════════════════════
   CHAT MAIN
══════════════════════════════════════════════════ */

.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--bg);
  min-width: 0;
  background-image: radial-gradient(ellipse at 80% 0%, rgba(124,58,237,0.04) 0%, transparent 60%);
}

/* Empty state */
.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: var(--text-2);
  padding: 40px 24px;
  gap: 14px;
}

.empty-icon { line-height: 1; }

.empty-state h3 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
}

.empty-state p {
  font-size: 0.9rem;
  max-width: 260px;
  line-height: 1.6;
}

/* Active chat */
#active-chat {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* ─── Messages ─── */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

@keyframes msgFadeIn {
  from { opacity: 0; transform: translateY(6px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.message-bubble {
  max-width: 68%;
  padding: 11px 16px;
  border-radius: 20px;
  font-size: 0.94rem;
  line-height: 1.5;
  word-break: break-word;
  animation: msgFadeIn 0.2s ease;
}

.message-bubble.mine {
  background: var(--purple);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 5px;
  box-shadow: 0 2px 8px rgba(124,58,237,0.22);
}

.message-bubble.theirs {
  background: var(--white);
  color: var(--text);
  align-self: flex-start;
  border-bottom-left-radius: 5px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
}

.message-bubble .time {
  font-size: 0.66rem;
  margin-top: 5px;
  opacity: 0.55;
  display: block;
  letter-spacing: 0.01em;
}

.message-bubble.mine .time { text-align: right; color: rgba(255,255,255,0.85); }
.message-bubble.theirs .time { color: var(--text-2); }

/* Consecutive messages from same sender: tighten gap */
.message-bubble + .message-bubble { margin-top: -4px; }

.empty-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 24px;
}

.empty-chat-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  max-width: 320px;
  gap: 0;
  animation: emptyFadeIn 0.4s ease;
}

@keyframes emptyFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.empty-chat-icon {
  margin-bottom: 18px;
}

.empty-chat-title {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 10px;
  line-height: 1.4;
}

.empty-chat-sub {
  font-size: 13.5px;
  color: #6B7280;
  line-height: 1.6;
  margin: 0 0 24px;
}

.empty-chat-starters {
  display: flex;
  flex-direction: column;
  gap: 9px;
  width: 100%;
}

.empty-starter-btn {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 11px 16px;
  border-radius: 12px;
  border: 1.5px solid var(--border);
  background: #fff;
  color: #4C1D95;
  font-size: 13.5px;
  font-family: inherit;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.empty-starter-btn:hover {
  background: var(--secondary);
  border-color: var(--accent);
  transform: translateY(-1px);
}

.empty-starter-btn:active {
  transform: translateY(0);
}

.starter-icon {
  flex-shrink: 0;
  color: var(--accent);
  display: flex;
  align-items: center;
}

/* ─── Tone insight bar ─── */

/* --- Intent bar --- */

.intent-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 9px 18px 8px;
  border-bottom: 1px solid var(--border);
  background: var(--white);
}

.intent-bar-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  white-space: nowrap;
  margin-right: 2px;
}

.intent-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  flex: 1;
}

.intent-chip {
  font-size: 12px;
  padding: 3px 10px;
  border-radius: 20px;
  border: 1.5px solid var(--border);
  background: transparent;
  color: #4B5563;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  white-space: nowrap;
  font-family: inherit;
  line-height: 1.5;
}

.intent-chip:hover {
  background: var(--secondary);
  border-color: var(--accent);
  color: var(--accent);
}

.intent-chip.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
  font-weight: 600;
}

.intent-suggestion {
  font-size: 11px;
  color: var(--accent);
  font-style: italic;
  white-space: nowrap;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 10px;
  background: var(--secondary);
  border: 1px dashed var(--accent);
  transition: background 0.15s;
}

.intent-suggestion:hover {
  background: #EDE9FE;
}

/* --- Tone insight --- */

@keyframes toneSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.tone-insight {
  margin-bottom: 8px;
  background: #faf8ff;
  border-left: 3px solid var(--purple);
  border-radius: 0 14px 14px 0;
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  animation: toneSlideIn 0.18s ease;
  box-shadow: 0 2px 8px rgba(124,58,237,0.07);
}

.tone-insight.flagged {
  background: #fdf6e8;
  border-left-color: #c4974a;
}

.tone-insight-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 0.8rem;
  color: var(--purple-dark);
  font-weight: 500;
  line-height: 1.3;
}

.tone-insight.flagged .tone-insight-label { color: #7a5c1e; }

.tone-icon { flex-shrink: 0; opacity: 0.75; }

.tone-actions {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

.tone-action-btn {
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 3px 11px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--purple-dark);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-family: inherit;
  white-space: nowrap;
}
.tone-action-btn:hover { background: var(--purple-light); border-color: var(--purple); }
.tone-action-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.tone-insight.flagged .tone-action-btn { border-color: #e0c48a; }
.tone-insight.flagged .tone-action-btn:hover { background: #faefd0; border-color: #c4974a; color: #7a5c1e; }

/* ─── Before-you-send modal icon ─── */
.tone-warn-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #fdf6e8;
  color: #c4974a;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 14px;
}

.modal-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
}

/* ─── Typing indicator ─── */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 2px 24px 8px;
  min-height: 28px;
}

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

.typing-dots span {
  display: block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--purple);
  opacity: 0.5;
  animation: typing-bounce 1.3s infinite ease-in-out;
}

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

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

.typing-text {
  font-size: 0.78rem;
  color: var(--text-2);
  font-style: italic;
}

/* ─── Input area ─── */
.chat-input-area {
  background: var(--white);
  border-top: 1px solid var(--border);
  padding: 12px 18px 16px;
  flex-shrink: 0;
  box-shadow: 0 -4px 20px rgba(124,58,237,0.05);
}

.rewrite-preview {
  margin-bottom: 12px;
  background: #faf8ff;
  border: 1px solid #DDD6FE;
  border-left: 4px solid var(--purple);
  border-radius: 16px;
  padding: 16px;
  box-shadow: 0 2px 12px rgba(124,58,237,0.08);
}

.rewrite-preview-label {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--purple);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.rewrite-before-after {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
}

.rewrite-ba-col {
  flex: 1;
  min-width: 0;
}

.rewrite-ba-tag {
  display: inline-block;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-2);
  background: rgba(0,0,0,0.05);
  padding: 1px 7px;
  border-radius: 8px;
  margin-bottom: 5px;
}

.rewrite-ba-tag-after {
  color: var(--purple-dark);
  background: rgba(124,58,237,0.1);
}

.rewrite-before-text {
  font-size: 0.88rem;
  line-height: 1.48;
  color: var(--text-2);
  text-decoration: line-through;
  text-decoration-color: rgba(107,114,128,0.4);
  word-break: break-word;
}

.rewrite-preview-text {
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--text);
  word-break: break-word;
  font-weight: 500;
}

.rewrite-ba-divider {
  width: 1px;
  background: var(--border);
  flex-shrink: 0;
  margin: 4px 0;
}

.rewrite-value-msg {
  font-size: 0.78rem;
  color: var(--purple-dark);
  font-style: italic;
  margin-bottom: 10px;
  opacity: 0.85;
}

.rewrite-preview-actions {
  display: flex;
  gap: 10px;
}

.rewrite-preview-actions .btn {
  flex: 1;
  padding: 9px;
  font-size: 0.88rem;
}

.rewrite-invite-nudge {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid #DDD6FE;
  display: flex;
  justify-content: center;
}

.rewrite-invite-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--purple);
  font-weight: 600;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.rewrite-invite-btn:hover {
  background: rgba(124,58,237,0.08);
  color: var(--purple-dark);
}

/* ─── Share invite modal ─── */

.share-invite-modal-card {
  max-width: 380px;
  text-align: center;
  position: relative;
}

.share-invite-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--purple-light);
  color: var(--purple);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.share-invite-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 10px;
}

.share-invite-quote {
  font-size: 0.9rem;
  color: var(--text-2);
  font-style: italic;
  line-height: 1.55;
  margin-bottom: 22px;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 10px;
  border-left: 3px solid var(--purple);
}

.share-invite-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 16px;
}

.share-invite-actions .btn {
  width: 100%;
  padding: 11px;
}

.share-code-row {
  display: flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.share-code-label {
  font-size: 0.82rem;
  color: var(--text-2);
}

.share-code-display {
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--purple);
  letter-spacing: 0.12em;
  background: var(--purple-light);
  padding: 4px 12px;
  border-radius: 8px;
}

.share-copy-code-btn {
  padding: 6px 14px;
  font-size: 0.82rem;
}

.share-invite-note {
  font-size: 0.75rem;
  color: var(--muted);
  line-height: 1.5;
}

.modal-close-x {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-2);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: background 0.15s, color 0.15s;
}

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

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.input-icon-btn {
  background: none;
  border: none;
  color: var(--text-2);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s, color 0.18s;
}
.input-icon-btn:hover { background: var(--purple-light); color: var(--purple); }
.input-icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

.input-row textarea {
  flex: 1;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 24px;
  padding: 11px 18px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 44px;
  line-height: 1.45;
  color: var(--text);
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}
.input-row textarea:focus {
  border-color: var(--purple);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}
.input-row textarea::placeholder { color: var(--muted); }

.send-btn {
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.18s, transform 0.15s, box-shadow 0.18s;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(124,58,237,0.28);
}
.send-btn:hover {
  background: var(--purple-dark);
  transform: scale(1.08);
  box-shadow: 0 4px 12px rgba(124,58,237,0.36);
}
.send-btn:disabled { background: #c4b5fd; cursor: not-allowed; transform: none; box-shadow: none; }

/* Blocked conversation banner */
.chat-blocked-banner {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-2);
  padding: 40px;
  text-align: center;
  font-size: 0.92rem;
}

/* ═══════════════════════════════════════════════
   MODALS
══════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,10,30,0.45);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  backdrop-filter: blur(4px);
  animation: overlayFadeIn 0.18s ease;
}

@keyframes overlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

@media (min-width: 600px) {
  .modal-overlay { align-items: center; }
}

.modal {
  background: white;
  border-radius: 24px;
  padding: 32px;
  width: 100%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(15,10,30,0.2);
  animation: modalSlideUp 0.22s cubic-bezier(0.34, 1.28, 0.64, 1);
}

@keyframes modalSlideUp {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.modal h2 {
  color: var(--purple);
  margin-bottom: 12px;
  font-size: 1.2rem;
}

.modal-icon-danger {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #ffebee;
  color: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
}

.modal-body-text {
  font-size: 0.95rem;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.5;
}

.danger-btn {
  background: var(--danger) !important;
  color: white !important;
}
.danger-btn:hover { background: #c62828 !important; }
.danger-btn:disabled { background: #ef9a9a !important; }

.block-info-list {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.block-info-list li {
  font-size: 0.84rem;
  color: var(--text-2);
  padding-left: 16px;
  position: relative;
  line-height: 1.4;
}
.block-info-list li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: var(--danger);
}

.analysis-content {
  white-space: pre-wrap;
  font-size: 0.92rem;
  line-height: 1.7;
  color: var(--text);
}
.modal-close { margin-top: 20px; width: 100%; }

/* ─── Report modal ─── */
.report-reasons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 10px;
}

.report-reason-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  cursor: pointer;
  font-size: 0.88rem;
  color: var(--text);
  transition: border-color 0.15s, background 0.15s;
}
.report-reason-item:hover { border-color: var(--purple); background: var(--purple-light); }
.report-reason-item input[type="radio"] {
  accent-color: var(--purple);
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

#report-details {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  background: #fafafa;
}
#report-details:focus { border-color: var(--purple); background: white; }

/* ─── Request modal ─── */
#request-modal-message {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.95rem;
  font-family: inherit;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  background: #fafafa;
}
#request-modal-message:focus { border-color: var(--purple); background: white; }

.request-modal-to {
  font-size: 0.88rem;
  color: var(--purple);
  font-weight: 600;
  margin-top: -6px;
  margin-bottom: 16px;
}

.label-optional {
  font-weight: 400;
  color: var(--text-2);
  font-size: 0.84rem;
}

.field-hint {
  font-size: 0.78rem;
  color: var(--text-2);
  margin-top: 6px;
  line-height: 1.4;
}

/* ─── Profile modal ─── */
.profile-preview-row {
  display: flex;
  justify-content: center;
  padding: 12px 0 4px;
}

.avatar-upload-wrapper {
  position: relative;
  display: inline-block;
  cursor: pointer;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
}

.avatar-upload-overlay {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}
.avatar-upload-wrapper:hover .avatar-upload-overlay { opacity: 1; }

.upload-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 12px 0 4px;
}

.upload-from-device-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--purple);
  color: white;
  border: none;
  border-radius: 8px;
  padding: 8px 14px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}
.upload-from-device-btn:hover { background: var(--purple-dark); }

.remove-photo-btn {
  background: none;
  border: none;
  color: var(--text-2);
  font-size: 0.82rem;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.remove-photo-btn:hover { color: var(--danger); }

.or-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-2);
  font-size: 0.78rem;
  margin: 16px 0 12px;
}
.or-divider::before,
.or-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* ═══════════════════════════════════════════════
   CHAT HEADER DROPDOWN (⋯ menu)
══════════════════════════════════════════════════ */

.chat-header-menu {
  position: relative;
  display: flex;
  align-items: center;
}

.chat-menu-btn {
  background: none;
  border: none;
  color: var(--text-2);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.chat-menu-btn:hover { background: var(--bg); color: var(--purple); }

.chat-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.13);
  min-width: 190px;
  z-index: 200;
  overflow: hidden;
}

.chat-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 12px 16px;
  border: none;
  background: none;
  text-align: left;
  font-size: 0.88rem;
  font-family: inherit;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s;
}
.chat-dropdown-item:hover { background: var(--bg); }
.chat-dropdown-item.danger { color: var(--danger); }
.chat-dropdown-item.danger:hover { background: #ffebee; }

/* ═══════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════ */

.app-toast {
  position: fixed;
  bottom: 28px;
  left: 50%;
  transform: translateX(-50%) translateY(16px);
  background: #1c1c1c;
  color: white;
  padding: 10px 24px;
  border-radius: 30px;
  font-size: 0.88rem;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.22s, transform 0.22s;
  pointer-events: none;
  z-index: 9999;
  white-space: nowrap;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
}
.app-toast.visible { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ═══════════════════════════════════════════════
   MOBILE — sidebar as overlay
══════════════════════════════════════════════════ */

@media (max-width: 700px) {
  :root { --sidebar-w: 85vw; }

  .sidebar {
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    box-shadow: 4px 0 24px rgba(0,0,0,0.18);
  }
  .sidebar.open { transform: translateX(0); }

  .header-left {
    width: auto;
    min-width: unset;
    flex: 0 0 auto;
    border-right: none;
  }

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

  .message-bubble { max-width: 80%; }
}

/* Desktop: hide hamburger, always show sidebar */
@media (min-width: 701px) {
  .menu-btn { display: none; }
  .sidebar { transform: none !important; }
}

/* ─── Onboarding overlay ─── */

.onboarding-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(91, 33, 182, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: onboardingFadeIn 0.3s ease;
}

@keyframes onboardingFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.onboarding-card {
  background: #fff;
  border-radius: 20px;
  padding: 40px 32px 32px;
  max-width: 360px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.18);
  position: relative;
  animation: onboardingSlideUp 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes onboardingSlideUp {
  from { opacity: 0; transform: translateY(24px); }
  to   { opacity: 1; transform: translateY(0); }
}

.onboarding-skip {
  position: absolute;
  top: 16px;
  right: 18px;
  background: none;
  border: none;
  font-size: 13px;
  color: #9CA3AF;
  cursor: pointer;
  padding: 4px 6px;
  border-radius: 6px;
  transition: color 0.15s;
  font-family: inherit;
}

.onboarding-skip:hover { color: var(--accent); }

.onboarding-screens {
  position: relative;
  min-height: 200px;
}

.onboarding-screen {
  display: none;
  flex-direction: column;
  align-items: center;
  animation: screenFadeIn 0.3s ease;
}

.onboarding-screen.active {
  display: flex;
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.onboarding-icon-wrap {
  margin-bottom: 24px;
}

.onboarding-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text);
  margin: 0 0 12px;
  line-height: 1.3;
}

.onboarding-text {
  font-size: 15px;
  color: #6e7e6f;
  line-height: 1.6;
  margin: 0;
  max-width: 280px;
}

.onboarding-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 28px 0 24px;
}

.onboarding-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #DDD6FE;
  transition: background 0.2s, transform 0.2s;
}

.onboarding-dot.active {
  background: var(--accent);
  transform: scale(1.25);
}

.onboarding-actions {
  display: flex;
  justify-content: center;
}

.onboarding-next-btn {
  min-width: 140px;
  padding: 11px 28px;
  font-size: 15px;
}

/* ─── Explicit Content Safety System ─── */

/* Sender age-gate checkbox in modal */
.explicit-age-check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  cursor: pointer;
  margin: 16px 0 0;
  padding: 12px 14px;
  background: #fff8f0;
  border: 1px solid #ffd0a0;
  border-radius: 10px;
  font-size: 14px;
  color: #7a4000;
  line-height: 1.45;
}
.explicit-age-check input[type="checkbox"] {
  margin-top: 2px;
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  accent-color: #e65100;
  cursor: pointer;
}

/* Receiver warning card (shown in place of hidden explicit message) */
.explicit-warning-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 6px 0;
  padding: 16px 18px;
  background: #fff8f0;
  border: 1.5px solid #ffd0a0;
  border-radius: 14px;
  max-width: 88%;
  align-self: flex-start;
  animation: fadeInUp 0.18s ease-out;
}
.explicit-warning-header {
  display: flex;
  align-items: center;
  gap: 8px;
}
.explicit-warning-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #ffebd6;
  color: #e65100;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 15px;
}
.explicit-warning-sender {
  font-weight: 600;
  font-size: 13px;
  color: #7a4000;
}
.explicit-warning-desc {
  font-size: 13.5px;
  color: #5c3000;
  line-height: 1.5;
  margin: 0;
}
.explicit-warning-safety {
  font-size: 11.5px;
  color: #a07040;
  line-height: 1.45;
  margin: 0;
  padding: 8px 10px;
  background: #fff3e0;
  border-radius: 7px;
  border-left: 3px solid #ffb74d;
}
.explicit-warning-btns {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 4px;
}
.explicit-warning-btns .btn {
  font-size: 13px;
  padding: 9px 16px;
}
.explicit-warning-btns .btn.danger {
  background: transparent;
  color: #c0392b;
  border: 1.5px solid #e57373;
}
.explicit-warning-btns .btn.danger:hover {
  background: #fdecea;
}

/* Badge shown on acknowledged explicit messages */
.explicit-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  color: #e65100;
  background: #fff3e0;
  border: 1px solid #ffcc80;
  border-radius: 5px;
  padding: 2px 7px;
  margin-top: 5px;
  font-weight: 500;
  letter-spacing: 0.01em;
}
