/* ═══════════════════════════════════════
   QUILL CHAT — Main Stylesheet
   Theme: Midnight Violet
   Font: Bebas Neue (display) + Outfit (body)
═══════════════════════════════════════ */

:root {
  /* Core palette */
  --bg-dark: #1A1040;
  --bg-darker: #0F0A28;
  --accent: #8B5CF6;
  --accent-light: #A78BFA;
  --accent-dark: #6D28D9;
  --accent-soft: #EDE9FE;

  --bg-page: #F5F3FF;
  --bg-card: #FFFFFF;
  --border-soft: #EDE9FE;
  --border-mid: #DDD6FE;

  --text-primary: #1A1A2E;
  --text-secondary: #6B6580;
  --text-muted: #A6A0BF;
  --text-on-dark: #FFFFFF;
  --text-on-dark-soft: rgba(255,255,255,.7);

  --success: #10B981;
  --danger: #EF4444;
  --warning: #F59E0B;
  --info: #22D3EE;

  --bubble-in: #EEEEFF;
  --bubble-out: #DDD6FE;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 22px;
  --radius-full: 999px;

  --shadow-card: 0 2px 12px rgba(107, 70, 193, 0.08);
  --shadow-float: 0 8px 28px rgba(45, 20, 90, 0.18);

  --font-display: 'Bebas Neue', sans-serif;
  --font-body: 'Outfit', sans-serif;
}

/* ─── Reset ─── */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  overscroll-behavior-y: contain;
}

body {
  font-family: var(--font-body);
  background: var(--bg-darker);
  color: var(--text-primary);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: inherit;
  border: none;
  background: none;
  cursor: pointer;
  color: inherit;
}

input, textarea {
  font-family: inherit;
  font-size: inherit;
  border: none;
  outline: none;
  background: none;
  color: inherit;
}

a { color: inherit; text-decoration: none; }

.muted { color: var(--text-muted); }

/* Visible keyboard focus everywhere */
button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* ─── App Shell ─── */
.screen {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
}
.screen.active { display: block; }

/* ═══════════════════════════════════════
   SPLASH SCREEN
═══════════════════════════════════════ */
#splash {
  background: linear-gradient(160deg, var(--bg-darker) 0%, var(--bg-dark) 60%, #2D1B69 100%);
  display: flex;
  align-items: center;
  justify-content: center;
}
.splash-content {
  text-align: center;
  animation: splashIn 0.6s ease;
}
@keyframes splashIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
.splash-logo { margin-bottom: 18px; display: flex; justify-content: center; }
.splash-name {
  font-family: var(--font-display);
  font-size: 48px;
  letter-spacing: 3px;
  color: #fff;
  line-height: 1;
}
.splash-tagline {
  color: var(--accent-light);
  font-size: 13px;
  letter-spacing: 1.5px;
  margin-top: 10px;
}
.splash-loader {
  width: 140px;
  height: 3px;
  background: rgba(255,255,255,0.1);
  border-radius: var(--radius-full);
  margin: 36px auto 0;
  overflow: hidden;
}
.loader-bar {
  width: 40%;
  height: 100%;
  background: var(--accent);
  border-radius: var(--radius-full);
  animation: loaderSlide 1.1s ease-in-out infinite;
}
@keyframes loaderSlide {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}

/* ═══════════════════════════════════════
   ONBOARDING
═══════════════════════════════════════ */
#onboarding {
  background: var(--bg-page);
  overflow-y: auto;
}
.onboard-wrap {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 32px 24px 40px;
  max-width: 420px;
  margin: 0 auto;
}
.onboard-step { display: none; }
.onboard-step.active { display: block; animation: stepIn 0.35s ease; }
@keyframes stepIn {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}
.onboard-icon { display: flex; justify-content: center; margin-bottom: 20px; }
.onboard-title {
  font-family: var(--font-display);
  font-size: 30px;
  letter-spacing: 0.5px;
  text-align: center;
  color: var(--text-primary);
  margin-bottom: 10px;
}
.onboard-desc {
  text-align: center;
  color: var(--text-secondary);
  font-size: 14px;
  line-height: 1.6;
  margin-bottom: 28px;
}
.onboard-points {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 32px;
}
.point {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 12px 16px;
  font-size: 13.5px;
  color: var(--text-primary);
}
.point i { color: var(--accent); font-size: 18px; flex-shrink: 0; }

.btn-primary {
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 15px;
  padding: 15px 20px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.15s, transform 0.1s;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:active { transform: scale(0.98); }
.btn-primary.small { width: auto; padding: 10px 18px; font-size: 13px; }
.btn-primary.large { padding: 17px 24px; font-size: 16px; }

.btn-outline {
  flex: 1;
  background: transparent;
  border: 1.5px solid var(--border-mid);
  color: var(--accent-dark);
  font-weight: 600;
  font-size: 14px;
  padding: 13px 16px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.btn-outline:hover { background: var(--accent-soft); }
.btn-outline.small { flex: none; padding: 8px 14px; font-size: 12.5px; }

.btn-danger {
  background: transparent;
  border: 1.5px solid #FCA5A5;
  color: var(--danger);
  font-weight: 600;
  padding: 12px 24px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* Avatar picker */
.avatar-picker { display: flex; flex-direction: column; align-items: center; margin-bottom: 24px; }
.avatar-preview {
  width: 84px; height: 84px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 34px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}
.avatar-hint { font-size: 11.5px; color: var(--text-muted); margin-top: 8px; }
.color-picker {
  display: none;
  gap: 10px;
  margin-top: 12px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 220px;
}
.color-picker.open { display: flex; }
.color-dot {
  width: 26px; height: 26px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.1s;
}
.color-dot:hover { transform: scale(1.15); }

.input-group { margin-bottom: 16px; }
.input-group label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}
.input-group input {
  width: 100%;
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 13px 16px;
  font-size: 14.5px;
  color: var(--text-primary);
}
.input-group input:focus { border-color: var(--accent); }
.input-with-icon {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-md);
  padding: 0 16px;
}
.input-with-icon:focus-within { border-color: var(--accent); }
.input-prefix { color: var(--text-muted); font-weight: 600; margin-right: 2px; }
.input-with-icon input { padding: 13px 4px; border: none; }
.input-hint { display: block; font-size: 11.5px; margin-top: 5px; min-height: 14px; }
.input-hint.ok { color: var(--success); }
.input-hint.taken { color: var(--danger); }

.success-icon {
  display: flex; justify-content: center;
  font-size: 56px;
  color: var(--success);
  margin-bottom: 14px;
}

.id-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-card);
}
.id-card-avatar {
  width: 56px; height: 56px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 22px;
}
.id-card-name { font-weight: 700; font-size: 16px; }
.id-card-username { color: var(--accent-dark); font-size: 13px; margin-top: 2px; }
.id-card-id { color: var(--text-muted); font-size: 11.5px; margin-top: 2px; letter-spacing: 0.3px; }
.id-actions { display: flex; gap: 10px; margin-bottom: 20px; }

/* ═══════════════════════════════════════
   MAIN APP SHELL
═══════════════════════════════════════ */
#app {
  background: var(--bg-page);
  display: flex;
  flex-direction: column;
}
.connection-bar {
  display: none;
  background: var(--warning);
  color: #451A03;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  padding: 6px;
  gap: 6px;
  align-items: center;
  justify-content: center;
}
.connection-bar.show { display: flex; }

.app-screen {
  display: none;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  position: relative;
}
.app-screen.active { display: flex; }

/* Header */
.app-header {
  background: var(--bg-dark);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.header-left { display: flex; align-items: baseline; gap: 10px; }
.app-title {
  font-family: var(--font-display);
  font-size: 24px;
  letter-spacing: 0.5px;
  color: #fff;
}
.header-actions { display: flex; align-items: center; gap: 6px; }
.icon-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: var(--accent-light);
  font-size: 19px;
  transition: background 0.15s;
}
.icon-btn:hover { background: rgba(167,139,250,0.15); }
.icon-btn.danger { color: var(--danger); }

.ghost-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(167,139,250,0.18);
  color: var(--accent-light);
  font-size: 11px;
  font-weight: 600;
  padding: 3px 9px;
  border-radius: var(--radius-full);
}

.online-count, .world-online {
  color: var(--info);
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Stories row */
.stories-row {
  background: var(--bg-card);
  padding: 10px 14px;
  display: flex;
  gap: 12px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.story-item { display: flex; flex-direction: column; align-items: center; gap: 4px; flex-shrink: 0; }
.story-avatar {
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 600;
  position: relative;
  border: 2.5px solid var(--accent);
  padding: 2px;
}
.my-avatar { border-color: var(--border-mid); background: var(--accent); }
.story-add-btn {
  position: absolute;
  bottom: -2px; right: -2px;
  width: 18px; height: 18px;
  background: var(--accent-dark);
  border: 2px solid #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 10px;
  color: #fff;
}
.story-name { font-size: 10.5px; color: var(--text-secondary); }

/* Search bar */
.search-bar {
  background: var(--bg-card);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-soft);
}
.search-bar i:first-child { color: var(--text-muted); }
.search-bar input { flex: 1; font-size: 14px; }

/* Chat list */
.chat-list { flex: 1; overflow-y: auto; background: var(--bg-card); }
.chat-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 16px;
  cursor: pointer;
  border-bottom: 0.5px solid var(--border-soft);
  transition: background 0.1s;
}
.chat-item:hover { background: #FAF8FF; }
.chat-avatar {
  width: 50px; height: 50px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 17px;
  position: relative;
}
.online-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 12px; height: 12px;
  background: var(--success);
  border: 2px solid #fff;
  border-radius: 50%;
}
.chat-info { flex: 1; min-width: 0; }
.chat-top { display: flex; justify-content: space-between; align-items: baseline; }
.chat-name { font-weight: 600; font-size: 14.5px; color: var(--text-primary); }
.chat-time { font-size: 11px; }
.chat-time.unread { color: var(--accent); font-weight: 600; }
.chat-bottom { display: flex; justify-content: space-between; align-items: center; margin-top: 2px; }
.chat-preview {
  font-size: 12.5px; color: var(--text-secondary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 200px;
}
.unread-badge {
  background: var(--accent);
  color: #fff;
  min-width: 20px; height: 20px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700;
  padding: 0 5px;
}

.empty-chats {
  display: flex; flex-direction: column; align-items: center;
  padding: 80px 30px;
  text-align: center;
  color: var(--text-muted);
}
.empty-chats i { font-size: 48px; margin-bottom: 14px; opacity: 0.5; }
.empty-chats p { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 4px; }
.empty-chats span { font-size: 13px; margin-bottom: 18px; }

.empty-thoughts {
  display: flex; flex-direction: column; align-items: center;
  padding: 80px 30px; text-align: center; color: var(--text-muted);
}
.empty-thoughts i { font-size: 48px; margin-bottom: 14px; opacity: 0.5; }
.empty-thoughts p { font-size: 15px; font-weight: 600; color: var(--text-secondary); }
.empty-thoughts span { font-size: 13px; }

/* ─── Individual Chat Screen ─── */
.chat-header {
  background: var(--bg-dark);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.chat-header-info { display: flex; align-items: center; gap: 10px; flex: 1; cursor: pointer; min-width: 0; }
.chat-header-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600;
}
.chat-header-name { color: #fff; font-size: 15px; font-weight: 600; }
.chat-header-status { color: var(--text-on-dark-soft); font-size: 11.5px; }
.chat-header-status.connected { color: var(--success); }
.call-btn { color: var(--accent-light); }

.messages-area {
  flex: 1;
  overflow-y: auto;
  background: var(--bg-page);
  background-size: cover;
  background-position: center;
}
.messages-wrap {
  padding: 12px 12px 6px;
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-height: 100%;
}
.date-divider { display: flex; justify-content: center; margin: 8px 0 10px; }
.date-divider span {
  background: rgba(139,92,246,0.1);
  color: var(--accent-dark);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 13px;
  border-radius: var(--radius-sm);
}
.system-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 11.5px;
  padding: 8px;
}

.msg-row { display: flex; flex-direction: column; max-width: 78%; }
.msg-row.in { align-self: flex-start; align-items: flex-start; }
.msg-row.out { align-self: flex-end; align-items: flex-end; }
.msg-bubble {
  padding: 9px 13px;
  font-size: 14px;
  line-height: 1.45;
  border-radius: var(--radius-md);
  word-wrap: break-word;
  white-space: pre-wrap;
}
.msg-row.in .msg-bubble { background: var(--bubble-in); color: #2D2060; border-bottom-left-radius: 3px; }
.msg-row.out .msg-bubble { background: var(--bubble-out); color: #3730A3; border-bottom-right-radius: 3px; }
.msg-meta { display: flex; align-items: center; gap: 3px; margin-top: 3px; padding: 0 4px; }
.msg-time { font-size: 10px; color: var(--text-muted); }
.msg-tick { font-size: 13px; color: var(--text-muted); }
.msg-tick.read { color: var(--accent); }

.msg-bubble.self-destruct {
  border: 1.5px dashed var(--danger);
  position: relative;
}
.destruct-timer {
  font-size: 10px;
  color: var(--danger);
  display: flex;
  align-items: center;
  gap: 3px;
  margin-top: 3px;
}

.msg-bubble.capsule {
  background: linear-gradient(135deg, #EDE9FE, #DDD6FE);
  border: 1.5px solid var(--accent);
}
.capsule-label {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--accent-dark);
  display: flex; align-items: center; gap: 4px;
  margin-bottom: 4px;
}

.typing-indicator { padding: 9px 14px; display: flex; gap: 4px; align-items: center; }
.typing-dot {
  width: 6px; height: 6px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typingBounce 1.2s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typingBounce {
  0%, 100% { transform: translateY(0); opacity: 0.4; }
  50% { transform: translateY(-4px); opacity: 1; }
}

/* Input area */
.input-area {
  background: var(--bg-card);
  padding: 8px 10px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
  border-top: 0.5px solid var(--border-soft);
  flex-shrink: 0;
}
.message-input-wrap {
  flex: 1;
  background: var(--bg-page);
  border-radius: 20px;
  padding: 9px 15px;
  max-height: 100px;
  overflow-y: auto;
}
.message-input {
  width: 100%;
  resize: none;
  font-size: 14px;
  line-height: 1.4;
  max-height: 80px;
}
.message-input::placeholder { color: var(--text-muted); }
.send-btn, .voice-btn {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.send-btn { display: none; }
.send-btn.show { display: flex; }
.voice-btn.hide { display: none; }

.voice-recording-bar {
  background: var(--bg-card);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 0.5px solid var(--border-soft);
  flex-shrink: 0;
}
.recording-indicator { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-primary); font-weight: 500; }
.rec-dot {
  width: 10px; height: 10px;
  background: var(--danger);
  border-radius: 50%;
  animation: recPulse 1s ease-in-out infinite;
}
@keyframes recPulse { 0%, 100% { opacity: 1; } 50% { opacity: 0.3; } }

.voice-msg {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 160px;
  cursor: pointer;
}
.voice-icon {
  width: 30px; height: 30px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.voice-wave { flex: 1; display: flex; align-items: center; gap: 2px; height: 20px; }
.voice-wave span {
  width: 2.5px;
  background: currentColor;
  opacity: 0.5;
  border-radius: 2px;
}
.voice-duration { font-size: 11px; color: var(--text-muted); flex-shrink: 0; }

/* ─── Random Chat ─── */
.random-state, .random-idle {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 30px;
  text-align: center;
}
.random-pulse {
  position: relative;
  width: 90px; height: 90px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 22px;
}
.random-pulse i { font-size: 34px; color: var(--accent); z-index: 2; }
.pulse-ring {
  position: absolute; inset: 0;
  border: 2px solid var(--accent);
  border-radius: 50%;
  animation: pulseRing 1.8s ease-out infinite;
}
.pulse-ring.delay-1 { animation-delay: 0.6s; }
@keyframes pulseRing {
  0% { transform: scale(0.5); opacity: 1; }
  100% { transform: scale(1.8); opacity: 0; }
}
.random-state h3 { font-size: 17px; margin-bottom: 6px; }
.random-state p { color: var(--text-secondary); font-size: 13.5px; margin-bottom: 22px; }

.random-hero h2 { font-family: var(--font-display); font-size: 30px; letter-spacing: 0.5px; margin: 16px 0 8px; }
.random-hero p { color: var(--text-secondary); font-size: 14px; max-width: 280px; margin: 0 auto 18px; line-height: 1.6; }
.random-rules { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin-bottom: 26px; }
.rule {
  display: flex; align-items: center; gap: 5px;
  background: var(--accent-soft); color: var(--accent-dark);
  font-size: 11.5px; font-weight: 600;
  padding: 6px 12px;
  border-radius: var(--radius-full);
}

.anonymous-avatar { background: var(--accent-dark) !important; font-family: var(--font-display); font-size: 20px; }

/* ─── World Chat ─── */
.lang-filter {
  background: var(--bg-card);
  padding: 8px 12px;
  display: flex;
  gap: 6px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border-soft);
  flex-shrink: 0;
}
.lang-btn {
  flex-shrink: 0;
  background: var(--accent-soft);
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
}
.lang-btn.active { background: var(--accent); color: #fff; }

.world-msg { display: flex; gap: 9px; padding: 6px 10px; align-items: flex-start; }
.world-msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 11px; font-weight: 600;
}
.world-msg-body { flex: 1; min-width: 0; }
.world-msg-head { display: flex; align-items: center; gap: 6px; margin-bottom: 3px; }
.world-msg-name { font-size: 12px; font-weight: 600; }
.world-flag { background: var(--info); color: #fff; font-size: 9px; padding: 1px 6px; border-radius: 4px; opacity: 0.85; }
.world-msg-time { font-size: 10px; color: var(--text-muted); }
.world-msg-text {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: 2px 12px 12px 12px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.45;
  display: inline-block;
  max-width: 100%;
}
.world-msg.own { flex-direction: row-reverse; }
.world-msg.own .world-msg-text {
  background: var(--bubble-out);
  border-color: transparent;
  border-radius: 12px 2px 12px 12px;
}
.world-msg.own .world-msg-head { flex-direction: row-reverse; }

/* ─── Thoughts Feed ─── */
.thoughts-feed { flex: 1; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 10px; }
.thought-card {
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-lg);
  padding: 16px;
}
.thought-head { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.thought-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 14px;
  flex-shrink: 0;
}
.thought-name { font-weight: 600; font-size: 13.5px; }
.thought-time { font-size: 11px; color: var(--text-muted); }
.thought-text { font-size: 14.5px; line-height: 1.6; color: var(--text-primary); margin-bottom: 12px; }
.thought-actions { display: flex; gap: 18px; }
.thought-action {
  display: flex; align-items: center; gap: 5px;
  color: var(--text-secondary);
  font-size: 12.5px;
}
.thought-action i { font-size: 16px; }
.thought-action.liked { color: #EC4899; }

/* ─── Settings ─── */
.settings-body { flex: 1; overflow-y: auto; padding: 14px; }
.profile-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 16px;
  cursor: pointer;
  box-shadow: var(--shadow-card);
}
.profile-avatar {
  width: 60px; height: 60px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 24px;
}
.profile-info { flex: 1; min-width: 0; }
.profile-name { font-weight: 700; font-size: 16px; }
.profile-username { color: var(--accent-dark); font-size: 12.5px; margin-top: 2px; }
.profile-id { color: var(--text-muted); font-size: 10.5px; margin-top: 1px; }

.settings-section {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  overflow: hidden;
  margin-bottom: 14px;
}
.settings-label {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
  padding: 14px 16px 8px;
}
.theme-picker { display: flex; gap: 12px; padding: 0 16px 16px; flex-wrap: wrap; }
.theme-dot {
  width: 36px; height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
}
.theme-dot.active { border-color: var(--accent); }
.theme-dot.light { border-color: var(--border-mid) !important; }

.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 0.5px solid var(--border-soft);
  cursor: pointer;
}
.settings-row:last-child { border-bottom: none; }
.settings-row:hover { background: #FAF8FF; }
.settings-icon {
  width: 36px; height: 36px;
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px;
  flex-shrink: 0;
}
.settings-text { flex: 1; }
.settings-title { font-size: 14px; font-weight: 600; }
.settings-sub { font-size: 11.5px; color: var(--text-muted); margin-top: 1px; }

.toggle-switch {
  width: 44px; height: 26px;
  background: var(--border-mid);
  border-radius: var(--radius-full);
  padding: 3px;
  transition: background 0.2s;
}
.toggle-switch.on { background: var(--accent); }
.toggle-thumb {
  width: 20px; height: 20px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.toggle-switch.on .toggle-thumb { transform: translateX(18px); }

.app-version {
  text-align: center;
  color: var(--text-muted);
  font-size: 11.5px;
  padding: 20px 0 30px;
  line-height: 1.8;
}
.app-version i { color: var(--accent); }

/* ─── Bottom Nav ─── */
.bottom-nav {
  background: var(--bg-card);
  border-top: 0.5px solid var(--border-soft);
  display: flex;
  flex-shrink: 0;
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 0 8px;
  color: var(--text-muted);
  font-size: 10px;
  font-weight: 500;
  position: relative;
}
.nav-btn i { font-size: 21px; }
.nav-btn.active { color: var(--accent); }
.nav-badge {
  position: absolute;
  top: 4px; right: 24%;
  background: var(--danger);
  color: #fff;
  font-size: 9px;
  font-weight: 700;
  min-width: 15px; height: 15px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}

/* ═══════════════════════════════════════
   MODALS
═══════════════════════════════════════ */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(15,10,40,0.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 1000;
  animation: overlayIn 0.2s ease;
}
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: var(--bg-card);
  width: 100%;
  max-width: 480px;
  border-radius: 24px 24px 0 0;
  padding: 18px 18px calc(20px + env(safe-area-inset-bottom, 0));
  max-height: 85vh;
  overflow-y: auto;
  animation: modalUp 0.25s ease;
}
@keyframes modalUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}
.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-tabs { display: flex; gap: 8px; margin-bottom: 16px; }
.modal-tab {
  flex: 1;
  padding: 9px;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 13px;
}
.modal-tab.active { background: var(--accent); color: #fff; }
.modal-tab-content {}

.contact-preview {
  display: flex; align-items: center; gap: 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-md);
  padding: 12px;
  margin-bottom: 14px;
}
.qr-scanner-area {
  background: var(--bg-page);
  border: 2px dashed var(--border-mid);
  border-radius: var(--radius-lg);
  padding: 40px 20px;
  text-align: center;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.qr-scanner-area i { font-size: 44px; margin-bottom: 10px; display: block; }

.qr-display { display: flex; flex-direction: column; align-items: center; padding: 10px 0 20px; }
.qr-id { margin-top: 12px; font-size: 12px; color: var(--text-muted); letter-spacing: 0.5px; }
.modal-actions { display: flex; gap: 10px; }

.thought-composer { display: flex; gap: 12px; margin-bottom: 12px; }
.thought-composer textarea {
  flex: 1;
  min-height: 90px;
  font-size: 14.5px;
  line-height: 1.6;
  resize: none;
}
.thought-footer {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 16px;
  padding-top: 10px;
  border-top: 1px solid var(--border-soft);
}
.char-count { font-size: 11.5px; color: var(--text-muted); }
.thought-options { display: flex; gap: 4px; }

.attach-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 6px; }.attach-option {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--bg-page);
  border-radius: var(--radius-lg);
  padding: 18px 10px;
  text-align: center;
}
.attach-option:hover { background: var(--accent-soft); }
.attach-option span { font-size: 13px; font-weight: 600; }
.attach-icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
}

.proximity-list { display: flex; flex-direction: column; gap: 8px; min-height: 40px; }
.proximity-empty { text-align: center; color: var(--text-muted); font-size: 13px; padding: 20px 0; }
.proximity-item {
  display: flex; align-items: center; gap: 12px;
  background: var(--bg-page);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}
.proximity-avatar {
  width: 36px; height: 36px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 600; font-size: 13px;
}
.proximity-info { flex: 1; min-width: 0; }
.proximity-name { font-size: 13px; font-weight: 600; }
.proximity-dist { font-size: 11px; color: var(--text-muted); }

.wallpaper-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 4px; }
.wallpaper-swatch {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  border: 2.5px solid transparent;
  cursor: pointer;
  position: relative;
  display: flex; align-items: flex-end; justify-content: center;
  padding-bottom: 6px;
}
.wallpaper-swatch.active { border-color: var(--accent); }
.wallpaper-swatch span {
  font-size: 10px; font-weight: 600;
  background: rgba(255,255,255,0.85);
  padding: 2px 7px;
  border-radius: var(--radius-full);
}
.wallpaper-swatch .check {
  display: none;
  position: absolute; top: 6px; right: 6px;
  width: 18px; height: 18px;
  background: var(--accent);
  border-radius: 50%;
  align-items: center; justify-content: center;
  color: #fff; font-size: 10px;
}
.wallpaper-swatch.active .check { display: flex; }

.ringtone-quick-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 14px; }
.silent-toggle { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.ringtone-list { display: flex; flex-direction: column; gap: 6px; max-height: 320px; overflow-y: auto; }
.ringtone-item {
  display: flex; align-items: center; gap: 12px;
  padding: 11px 12px;
  border-radius: var(--radius-md);
  background: var(--bg-page);
  cursor: pointer;
}
.ringtone-item.active { background: var(--accent-soft); border: 1.5px solid var(--accent); }
.ringtone-item i.ti-music-note { color: var(--accent); font-size: 18px; }
.ringtone-item .rt-name { flex: 1; font-size: 13.5px; font-weight: 500; }
.ringtone-item .rt-play { color: var(--accent-dark); font-size: 18px; }

.chat-menu-list .settings-row { padding: 13px 14px; }

.member-picker { display: flex; flex-direction: column; gap: 4px; max-height: 220px; overflow-y: auto; margin-top: 6px; }
.member-row {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px;
  border-radius: var(--radius-md);
  cursor: pointer;
}
.member-row:hover { background: var(--bg-page); }
.member-row .chat-avatar { width: 36px; height: 36px; font-size: 14px; }
.member-row-name { flex: 1; font-size: 13.5px; font-weight: 500; }
.member-checkbox {
  width: 20px; height: 20px;
  border-radius: 6px;
  border: 2px solid var(--border-mid);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.member-checkbox.checked { background: var(--accent); border-color: var(--accent); color: #fff; font-size: 12px; }
.member-picker-empty { text-align: center; color: var(--text-muted); font-size: 12.5px; padding: 16px 0; }

.group-sender-name { font-size: 11px; font-weight: 600; margin-bottom: 2px; display: block; }

/* ─── Toast ─── */
.toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%);
  background: #1A1A2E;
  color: #fff;
  padding: 11px 20px;
  border-radius: var(--radius-full);
  font-size: 13px;
  font-weight: 500;
  z-index: 2000;
  box-shadow: var(--shadow-float);
  animation: toastIn 0.25s ease;
  white-space: nowrap;
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* ─── Call Screen ─── */
.call-screen {
  position: fixed; inset: 0;
  z-index: 3000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  padding: 60px 30px 50px;
}
.call-bg {
  position: absolute; inset: 0;
  background: linear-gradient(160deg, #2D1B69, #1A1040);
  z-index: -1;
}
.call-info { display: flex; flex-direction: column; align-items: center; margin-top: 60px; }
.call-avatar {
  width: 110px; height: 110px;
  border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  color: #fff;
  font-family: var(--font-display);
  font-size: 42px;
  margin-bottom: 20px;
}
.call-name { color: #fff; font-size: 22px; font-weight: 600; }
.call-status { color: var(--text-on-dark-soft); font-size: 14px; margin-top: 6px; }
.call-actions { display: flex; gap: 50px; }
.call-btn-action {
  width: 64px; height: 64px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 26px;
  color: #fff;
}
.call-btn-action.decline { background: var(--danger); }
.call-btn-action.accept { background: var(--success); }

/* ─── Responsive ─── */
@media (min-width: 640px) {
  #app, #onboarding, #splash { max-width: 480px; margin: 0 auto; }
  body { background: var(--bg-darker); }
}
