:root {
  /* Dark Theme Default Palette */
  --bg: #0B0D17;
  --bg-elevated: #12131F;
  --surface: #171929;
  --surface-alt: #20223A;
  --surface-hover: #262943;
  --primary: #8B5CF6;
  --primary-alt: #EC4899;
  --primary-dim: #6D5EF0;
  --text: #F5F5FA;
  --text-muted: #9A9BC0;
  --border: #2A2D48;
  --border-soft: #22243B;
  --danger: #FF5C7A;
  --gold: #F0B93B;
  --success: #22C55E;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --shadow-sm: 0 2px 8px rgba(0,0,0,0.25);
  --shadow-md: 0 8px 24px rgba(0,0,0,0.3);
  --shadow-lg: 0 24px 64px rgba(0,0,0,0.45);

  /* Mapping for icons & textarea */
  --text-main: var(--text);
}

:root[data-theme="light"] {
  --bg: #F5F5FA;
  --bg-elevated: #FFFFFF;
  --surface: #FFFFFF;
  --surface-alt: #EEEEF5;
  --surface-hover: #E4E4F0;
  --primary: #7C3AED;
  --primary-alt: #DB2777;
  --primary-dim: #6D5EF0;
  --text: #17181F;
  --text-muted: #5B5C7A;
  --border: #DADAE8;
  --border-soft: #E4E4F0;
  --danger: #E11D48;
  --gold: #B8860B;
  --success: #16A34A;
  --shadow-sm: 0 2px 8px rgba(20,20,40,0.08);
  --shadow-md: 0 8px 24px rgba(20,20,40,0.10);
  --shadow-lg: 0 24px 64px rgba(20,20,40,0.16);

  --text-main: var(--text);
}

/* Universal SVG Styling */
.chat-icon-svg {
  width: 20px;
  height: 20px;
  display: inline-block;
  vertical-align: middle;
  flex-shrink: 0;
  color: var(--text-muted);
  transition: color 0.15s ease;
}

.icon-btn:hover .chat-icon-svg,
.btn-icon-label:hover .chat-icon-svg {
  color: var(--text-main);
}

.chat-icon-svg.icon-stop {
  color: var(--danger, #ef4444);
}

/* Container Wrapper for Textarea + Inside Buttons */
.chat-input-wrapper {
  position: relative;
}

.textarea-container {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
}

/* Textarea Padding: Extra space on the left for the inner Emoji button */
.chat-textarea {
  width: 100%;
  padding-right: 12px;  /* Space for text on right in RTL */
  padding-left: 42px;   /* Extra space on the left for the inner Emoji button */
  background-color: var(--surface);
  color: var(--text-main);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  resize: none;
}

/* Emoji Button Positioned Inside Textbox (Left Side) */
.btn-inside-textarea {
  position: absolute;
  left: 6px; 
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 2;
}

.btn-inside-textarea:hover {
  background: var(--surface-hover);
}

/* Emoji Popover Positioned Relative to Input */
.emoji-picker-popover {
  position: absolute;
  bottom: 100%; /* Positions the picker right above the input bar */
  left: 12px;
  z-index: 50;
  overflow-y: auto;  /* Adds scrolling inside the emoji grid */
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px;
  box-shadow: var(--shadow-md);
  margin-bottom: 8px;
}

.emoji-picker-popover[hidden] {
  display: none !important;
}

/* Grid Layout */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
  max-height: 220px;
  overflow-y: auto;
  padding-right: 4px;
}

/* Individual Emoji Item */
.emoji-grid button,
.emoji-btn {
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 1.25rem;
  padding: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, transform 0.1s ease;
}

.emoji-grid button:hover,
.emoji-btn:hover {
  background-color: var(--hover-bg, rgba(255, 255, 255, 0.08));
  transform: scale(1.15);
}

/* Scrollbar styling inside picker */
.emoji-grid::-webkit-scrollbar {
  width: 6px;
}

.emoji-grid::-webkit-scrollbar-thumb {
  background: var(--border, rgba(255, 255, 255, 0.2));
  border-radius: 3px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Assistant", -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  direction: rtl;
  -webkit-font-smoothing: antialiased;
}

button, input, textarea { font-family: inherit; }

.view { display: none; min-height: 100vh; }
.view.active { display: block; }

.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 40px 24px;
}
.centered { text-align: center; }

.logo-slot { display: flex; justify-content: center; margin-bottom: 14px; }

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

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px;
  margin: 20px 0;
  text-align: right;
  box-shadow: var(--shadow-sm);
}
.card h3 { margin-top: 0; font-size: 16px; }
.bullet { font-size: 13px; color: var(--text-muted); line-height: 1.75; margin: 8px 0; }
.bullet::before { content: "•"; color: var(--primary); margin-inline-end: 6px; font-weight: 700; }

.check-row {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  margin: 12px 0;
  font-size: 14px;
  cursor: pointer;
}
.check-row input { width: 18px; height: 18px; accent-color: var(--primary); }

.btn {
  display: block;
  width: 100%;
  border: none;
  border-radius: var(--radius-md);
  padding: 14px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin-top: 12px;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; filter: none; transform: none; }
.btn-primary { background: linear-gradient(135deg, var(--primary-dim), var(--primary-alt)); color: #fff; box-shadow: 0 6px 18px rgba(139,92,246,0.35); }
.btn-secondary { background: var(--surface-alt); color: var(--text); border: 1px solid var(--border); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-gold { background: linear-gradient(135deg, var(--gold), #F5D98A); color: #241a00; }
.btn-link { background: transparent; color: var(--text-muted); font-weight: 500; }
.btn-tiny { width: auto; padding: 8px 14px; border: 1px solid var(--border); background: transparent; color: var(--text-muted); border-radius: 20px; font-weight: 600; font-size: 13px; }
.btn-inline { width: auto; display: inline-block; margin-top: 0; padding: 10px 16px; font-size: 14px; }
.btn-send { width: auto; margin-top: 0; padding: 12px 22px; }

.avatar-actions { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; margin: 10px 0 4px; }

.section-label { font-size: 13px; color: var(--text-muted); margin: 20px 0 8px; font-weight: 600; }

.chip-row { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  border-radius: 20px;
  padding: 9px 15px;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.chip:hover { border-color: var(--primary-dim); }
.chip.active { background: linear-gradient(135deg, var(--primary-dim), var(--primary-alt)); border-color: transparent; font-weight: 700; color: #fff; }
.chip.locked { opacity: 0.5; }

.text-input {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  color: var(--text);
  font-size: 14.5px;
  margin-top: 6px;
  direction: rtl;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.text-input:focus {
  outline: none;
  border-color: var(--primary-dim);
  box-shadow: 0 0 0 3px rgba(139,92,246,0.18);
}
textarea.text-input { min-height: 46px; resize: vertical; font-family: inherit; }
.flex1 { flex: 1; }

.avatar-preview {
  width: 120px;
  height: 120px;
  border-radius: 60px;
  overflow: hidden;
  margin: 12px auto;
  border: 3px solid var(--border);
  box-shadow: var(--shadow-sm);
}
.avatar-preview img, .avatar-preview canvas { width: 100%; height: 100%; object-fit: cover; }

/* Main app shell */
#view-main.active { display: flex; min-height: 100vh; align-items: stretch; }
.main-content { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-header {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: max(14px, env(safe-area-inset-top)) 18px 14px 18px;
  border-bottom: 1px solid var(--border-soft);
  width: 100%;
  background: var(--bg-elevated);
}
.header-title-wrap { display: flex; align-items: center; }
.header-logo-mobile { display: flex; }
.header-actions { display: flex; flex-direction: row; gap: 16px; align-items: center; }
.header-actions button {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 8px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.tab-page { max-width: 480px; margin: 0 auto; padding: 16px; padding-bottom: calc(90px + env(safe-area-inset-bottom)); min-height: calc(100vh - 60px); width: 100%; }
.tab-title { font-size: 24px; font-weight: 800; margin: 6px 0 18px; letter-spacing: -0.02em; }

.centered-box { text-align: center; padding: 60px 24px; }

/* Animated "X" mark shown while searching for a match */
.x-loader { width: 120px; height: 120px; margin: 0 auto 20px; filter: drop-shadow(0 4px 14px rgba(139, 92, 246, 0.28)); }
.x-loader-svg { width: 100%; height: 100%; overflow: visible; }
.x-loader-track {
  fill: none;
  stroke: var(--border-soft);
  stroke-width: 5;
}
.x-loader-arc {
  fill: none;
  stroke: url(#x-loader-grad);
  stroke-width: 5;
  stroke-linecap: round;
  stroke-dasharray: 62 202;
  transform-origin: 50px 50px;
  animation: x-loader-rotate 1.3s linear infinite;
}
/* The X mark stays a legible X at all times - it only breathes (scale/opacity),
   it never rotates through 45deg/90deg where an X visually turns into a "+". */
.x-loader-mark {
  stroke-linecap: round;
  stroke-width: 9;
  transform-origin: 50px 50px;
  animation: x-loader-breathe 1.6s ease-in-out infinite;
}
.x-loader-mark line:first-child { stroke: var(--primary); }
.x-loader-mark line:last-child { stroke: var(--primary-alt); }
@keyframes x-loader-rotate {
  to { transform: rotate(360deg); }
}
@keyframes x-loader-breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(0.9); opacity: 0.85; }
}
.x-loader-text { display: flex; align-items: center; justify-content: center; gap: 2px; }
.x-loader-dots span {
  animation: x-loader-dot 1.4s infinite;
  opacity: 0;
}
.x-loader-dots span:nth-child(1) { animation-delay: 0s; }
.x-loader-dots span:nth-child(2) { animation-delay: 0.2s; }
.x-loader-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes x-loader-dot {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

/* Bottom tab bar - phone-style navigation, mobile only */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  display: flex;
  flex-direction: row;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border-soft);
  padding: 8px 0 max(10px, env(safe-area-inset-bottom));
  z-index: 20;
}
.nav-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  cursor: pointer;
  padding: 4px 0;
  transition: color 0.12s ease;
}
.nav-btn.active { color: var(--primary); font-weight: 700; }

.nav-icon { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px; }
.nav-icon svg { width: 100%; height: 100%; display: block; }

/* Profile nav button shows the user's actual avatar/photo instead of a
   generic icon. Sized to match .nav-icon so it sits flush with its
   sibling icons; the inner img/avatar element fills it completely. */
.nav-avatar {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  overflow: hidden;
  flex-shrink: 0;
  background: var(--surface-alt);
}
.nav-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.nav-avatar > div { width: 100%; height: 100%; display: block; }
.nav-btn.active .nav-avatar { box-shadow: 0 0 0 2px var(--primary); }

/* Icon-only nav buttons (friends + profile, grouped together, no label) */
.bottom-nav .nav-avatar { width: 24px; height: 24px; }

/* Sidebar navigation, desktop only (hidden by default, see media query) */
.side-nav {
  display: none;
  width: 232px;
  flex-shrink: 0;
  flex-direction: column;
  gap: 4px;
  padding: 22px 16px;
  border-left: 1px solid var(--border-soft);
  background: var(--bg-elevated);
}
.side-nav-logo { display: flex; justify-content: flex-end; padding: 6px 10px 26px; }
.side-nav .nav-btn {
  flex-direction: row;
  justify-content: flex-end;
  gap: 12px;
  padding: 11px 14px;
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
}
.side-nav .nav-btn:hover { background: var(--surface); }
.side-nav .nav-btn.active { background: var(--surface-alt); color: var(--text); box-shadow: inset 3px 0 0 var(--primary); }

/* Chat */
.chat-toolbar {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  padding: 10px 4px;
  border-bottom: 1px solid var(--border-soft);
  gap: 10px;
}
.chat-toolbar-start, .chat-toolbar-end {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 14px;
}
.link-danger { background: none; border: none; color: var(--danger); font-weight: 600; cursor: pointer; padding: 0; }
.link-primary { background: none; border: none; color: var(--primary); font-weight: 600; cursor: pointer; padding: 0; }

.inline-banner {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  margin: 8px 4px 0;
  font-size: 13px;
}
.inline-banner-actions { display: flex; flex-direction: row; gap: 8px; flex-shrink: 0; }
.btn-tiny-primary { background: linear-gradient(135deg, var(--primary-dim), var(--primary-alt)); color: #fff; border-color: transparent; }

/* Small red notification dot on a nav icon (pending friend requests) */
.badge-dot {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 4px;
  background: var(--danger);
  margin-inline-start: -6px;
  margin-top: -4px;
}
.messages { display: flex; flex-direction: column; gap: 8px; padding: 12px 4px; height: calc(100dvh - 380px - env(safe-area-inset-top) - env(safe-area-inset-bottom)); overflow-y: auto; }
.bubble { max-width: 78%; border-radius: var(--radius-md); padding: 10px 14px; font-size: 15px; line-height: 1.4; }
.bubble.mine { align-self: flex-start; background: linear-gradient(135deg, var(--primary-dim), var(--primary-alt)); color: #fff; }
.bubble.theirs { align-self: flex-end; background: var(--surface-alt); color: var(--text); }
.bubble.system { align-self: center; color: var(--text-muted); font-size: 12px; background: none; }
.bubble img { max-width: 220px; border-radius: 12px; display: block; cursor: pointer; }
.bubble img.blurred { filter: blur(20px); }
.bubble audio { max-width: 220px; }

.typing-indicator { color: var(--text-muted); font-size: 12px; padding: 0 8px 6px; }

.chat-input-row {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 4px;
  border-top: 1px solid var(--border-soft);
}
.chat-textarea {
  resize: none;
  min-height: 46px;
  max-height: 140px;
  line-height: 1.4;
  overflow-y: auto;
}
.icon-btn {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 20px;
  padding: 10px 12px;
  font-size: 16px;
  cursor: pointer;
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-hover); }

/* Partner info strip shown at the top of an active random chat, so the
   person you matched with is visible right away instead of hidden behind a
   small text link. */
.chat-partner-strip {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 8px 12px;
  margin: 4px 4px 8px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.chat-partner-strip:hover { background: var(--surface-hover); border-color: var(--primary-dim); }
.partner-strip-avatar { width: 42px; height: 42px; border-radius: 21px; overflow: hidden; flex-shrink: 0; }
.partner-strip-avatar img, .partner-strip-avatar canvas { width: 100%; height: 100%; object-fit: cover; }
.partner-strip-info { flex: 1; min-width: 0; text-align: right; }
.partner-strip-name { font-weight: 700; font-size: 14.5px; }
.partner-strip-meta { font-size: 12px; margin-top: 1px; }
.partner-strip-chevron { color: var(--text-muted); font-size: 18px; flex-shrink: 0; }

/* Online-now members grid on the Home tab */
.online-users-section { margin-top: 8px; padding: 0 4px 10px; }
.online-users-heading { display: flex; flex-direction: row; align-items: center; gap: 8px; }
.online-users-dot { width: 8px; height: 8px; border-radius: 4px; background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,0.18); flex-shrink: 0; }
.online-users-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 12px 8px;
}
.online-user-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 2px;
  border-radius: var(--radius-sm);
  transition: background 0.12s ease;
}
.online-user-item:hover { background: var(--surface); }
.online-user-avatar { width: 52px; height: 52px; border-radius: 26px; overflow: hidden; position: relative; }
.online-user-avatar img, .online-user-avatar canvas { width: 100%; height: 100%; object-fit: cover; }
.online-user-avatar::after {
  content: "";
  position: absolute;
  bottom: -1px;
  right: -1px;
  left: auto; /* Reset top-left positioning if inherited */
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--success);
  border: 2.5px solid var(--bg-elevated);
  z-index: 2;
}
.online-user-name {
  font-size: 11.5px;
  color: var(--text-muted);
  text-align: center;
  max-width: 72px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Friends */
.friend-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 12px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.friend-row:hover { background: var(--surface-hover); border-color: var(--border); }
.friend-avatar { width: 44px; height: 44px; border-radius: 22px; overflow: hidden; flex-shrink: 0; }
.online-dot { width: 10px; height: 10px; border-radius: 5px; background: var(--success); box-shadow: 0 0 0 3px rgba(34,197,94,0.2); }
.dm-unread-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ---------- Appearance toggle (light/dark) ---------- */
.theme-toggle-row { display: flex; align-items: center; justify-content: space-between; padding: 14px 18px; }
.theme-switch {
  position: relative;
  width: 46px;
  height: 26px;
  border-radius: 13px;
  border: none;
  background: var(--surface-alt);
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: background 0.2s ease;
}
.theme-switch[aria-checked="true"] { background: linear-gradient(135deg, var(--primary-dim), var(--primary-alt)); }
.theme-switch-thumb {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border-radius: 10px;
  background: #fff;
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s ease;
}
.theme-switch[aria-checked="true"] .theme-switch-thumb { transform: translateX(-20px); }

/* ---------- Toast notifications (replaces browser alert()) ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 32px));
  pointer-events: none;
}
.toast {
  background: var(--surface);
  border: 1px solid var(--border);
  border-inline-start: 4px solid var(--danger);
  color: var(--text);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  box-shadow: var(--shadow-lg);
  font-size: 14.5px;
  line-height: 1.4;
  text-align: right;
  pointer-events: auto;
  animation: toast-in 0.25s ease;
}
.toast.toast-info { border-inline-start-color: var(--primary); }
.toast.toast-leaving { animation: toast-out 0.2s ease forwards; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0); }
  to { opacity: 0; transform: translateY(12px); }
}

.friend-request-row { cursor: default; }

/* Wall */
.compose-box {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 10px;
}
.error-text { color: var(--danger); font-size: 12px; text-align: center; margin-bottom: 8px; }
.post-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow-sm);
}

@media (min-width: 900px) {
  #header-logo-mobile,
  .app-header {
    display: none !important;
  }
}
.post-header { display: flex; flex-direction: row; justify-content: space-between; align-items: center; }
.post-author { display: flex; flex-direction: row; align-items: center; gap: 10px; }
.post-author-name { font-weight: 700; font-size: 14px; }
.post-avatar { width: 36px; height: 36px; border-radius: 18px; overflow: hidden; flex-shrink: 0; }
.post-text { font-size: 15px; margin: 10px 0 12px; line-height: 1.5; }
.post-actions { display: flex; flex-direction: row; align-items: center; gap: 20px; position: relative; }
.post-actions button { background: none; border: none; color: var(--text-muted); font-size: 13px; cursor: pointer; }
.delete-link { background: none; border: none; color: var(--danger); font-size: 12px; cursor: pointer; }

/* Reaction control (the button that opens the picker) */
.reaction-control { position: relative; }
.reaction-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  font-weight: 600;
  transition: background 0.15s ease, color 0.15s ease;
}
.reaction-btn:hover { background: var(--surface-hover); }
.reaction-btn-icon { width: 18px; height: 18px; flex-shrink: 0; display: inline-flex; }
.reaction-btn-icon svg { width: 100%; height: 100%; display: block; }
.reaction-btn.reaction-like { color: #2E7CF6; }
.reaction-btn.reaction-love { color: #F0405B; }
.reaction-btn.reaction-haha,
.reaction-btn.reaction-wow,
.reaction-btn.reaction-sad { color: #D9971C; }
.reaction-btn.reaction-angry { color: #E8794A; }

/* Picker popover - opens above the button, holds all 6 options */
.reaction-picker {
  position: absolute;
  bottom: calc(100% + 8px);
  inset-inline-start: 0;
  display: flex;
  gap: 2px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px;
  box-shadow: var(--shadow-md);
  z-index: 5;
}
.reaction-picker[hidden] { display: none; }
.reaction-option {
  width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  transition: transform 0.12s ease;
}
.reaction-option svg { width: 100%; height: 100%; display: block; }
.reaction-option:hover { transform: scale(1.3) translateY(-4px); }
.reaction-option.selected { box-shadow: 0 0 0 2px var(--primary); }

/* Small stacked icons + total count next to the reaction button */
.reaction-summary { display: flex; align-items: center; gap: 5px; color: var(--text-muted); font-size: 13px; min-height: 16px; }
.reaction-chips { display: flex; }
.reaction-chip {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  box-shadow: 0 0 0 2px var(--surface);
  margin-inline-start: -6px;
}
.reaction-chip:first-child { margin-inline-start: 0; }
.reaction-chip svg { width: 100%; height: 100%; display: block; }

.comment-btn { display: flex; align-items: center; gap: 6px; }
.comment-btn svg { width: 18px; height: 18px; flex-shrink: 0; }

.comments-list { max-height: 300px; overflow-y: auto; margin-bottom: 10px; }
.comment-row { display: flex; flex-direction: row; align-items: flex-start; gap: 10px; margin-bottom: 12px; }
.comment-avatar { width: 26px; height: 26px; border-radius: 13px; overflow: hidden; flex-shrink: 0; margin-top: 2px; }
.comment-author-name { font-weight: 700; font-size: 12.5px; display: block; margin-bottom: 1px; }

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(4,5,10,0.65);
  backdrop-filter: blur(2px);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
}
.modal-card {
  background: var(--surface);
  border-radius: 24px 24px 0 0;
  padding: 24px;
  width: 100%;
  max-width: 480px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-soft);
  border-bottom: none;
}
.modal-actions { display: flex; flex-direction: row; justify-content: space-between; margin-top: 16px; }
.premium-banner {
  background: rgba(240,185,59,0.1);
  border: 1px solid var(--gold);
  color: var(--gold);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  margin-bottom: 14px;
}
.gold-text { color: var(--gold); }

/* Distance filter controls */
.distance-row { display: flex; flex-direction: column; gap: 10px; margin-top: 4px; }
.switch-row { display: flex; align-items: center; justify-content: flex-end; gap: 10px; font-size: 14px; cursor: pointer; }
.switch-row input { width: 18px; height: 18px; accent-color: var(--primary); }
#distance-slider { width: 100%; accent-color: var(--primary); }
#distance-slider:disabled { opacity: 0.4; }

/* Add-to-home-screen banner (mobile) */
.install-banner {
  position: fixed;
  left: 12px; right: 12px;
  bottom: max(12px, env(safe-area-inset-bottom));
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 60;
  font-size: 13px;
}
.install-banner-actions { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

/* Legal / support footer links (welcome screen + profile tab) */
.legal-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin-top: 16px;
  font-size: 12.5px;
}
.legal-links a { color: var(--text-muted); text-decoration: none; }
.legal-links a:hover { color: var(--text); text-decoration: underline; }
.legal-links-welcome { margin-top: 28px; padding-bottom: 8px; }

/* ------------------------------------------------------------
   Desktop layout: a real web-app shell (sidebar + wide content),
   not a phone frame stretched to fill the screen.
   ------------------------------------------------------------ */
@media (min-width: 900px) {
  body { background: radial-gradient(circle at 15% 0%, #171a2c 0%, var(--bg) 55%); }
  :root[data-theme="light"] body { background: radial-gradient(circle at 15% 0%, #ffffff 0%, var(--bg) 55%); }

  /* Welcome / profile-setup screens: a centered card, not edge-to-edge */
  #view-welcome.active .container,
  #view-profile.active .container {
    max-width: 480px;
    margin-top: 48px;
    background: var(--surface);
    border: 1px solid var(--border-soft);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
  }

  .bottom-nav { display: none; }

  /* Desktop: a real horizontal top nav bar (logo + icon-and-label pills),
     not a vertical rail or the mobile tab bar stretched sideways. Lives
     above the page content, full width. */
  #view-main.active { flex-direction: column; }
  .side-nav {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    flex-shrink: 0;
    gap: 6px;
    padding: 12px 32px;
    border-left: none;
    border-bottom: 1px solid var(--border-soft);
  }
  .side-nav-logo { padding: 0; margin-inline-end: 22px; }
  .side-nav .nav-account-group { display: flex; align-items: center; gap: 6px; margin-inline-start: auto; }
  .side-nav .nav-btn {
    flex: none;
    flex-direction: row;
    justify-content: center;
    align-items: center;
    gap: 8px;
    width: auto;
    height: auto;
    padding: 9px 16px;
    border-radius: 20px;
    font-size: 14.5px;
    font-weight: 600;
  }
  .side-nav .nav-btn small { display: block; font-size: inherit; }
  .side-nav .nav-btn .nav-icon { width: 19px; height: 19px; }
  .side-nav .nav-btn .nav-avatar { width: 19px; height: 19px; }
  .side-nav .nav-btn.nav-btn-compact { padding: 9px 12px; gap: 0; }
  .side-nav .nav-btn.active {
    box-shadow: none;
    background: linear-gradient(135deg, var(--primary-dim), var(--primary-alt));
    color: #fff;
  }
  .header-logo-mobile { display: none; }
  .install-banner { display: none !important; }

  .app-header { padding: 18px 32px; }
  .tab-page { max-width: 680px; padding: 28px 32px; padding-bottom: 40px; min-height: auto; }
  .centered-box { padding: 90px 24px; }

  /* Buttons/content inside a big empty state shouldn't stretch full width -
     a ~320px centered call-to-action reads as an intentional app, not a
     mobile layout blown up to fill a desktop window. */
  .centered-box { max-width: 380px; margin: 0 auto; }
  .centered-box .btn { max-width: 260px; margin-left: auto; margin-right: auto; }
  .centered-box p { font-size: 15px; }

  .modal-backdrop { align-items: center; }
  .modal-card { border-radius: var(--radius-lg); max-width: 420px; border-bottom: 1px solid var(--border-soft); }

  .messages { max-height: 60vh; }

  /* Chat page gets its own comfortable max-width, centered like a real
     desktop messaging pane rather than spanning the whole content column */
  .chat-page { max-width: 640px; margin: 0 auto; }

  .friend-row:hover, .post-card:hover { box-shadow: var(--shadow-md); }
  .friend-row, .post-card { padding: 14px 16px; }

  .btn { font-size: 14.5px; padding: 12px 16px; }
  .btn-inline { padding: 9px 15px; }
}

/* Extra-wide screens: keep the reading column from getting too wide */
@media (min-width: 1200px) {
  .tab-page { max-width: 760px; }
}