/* ======================== */
/* FF Base Styles           */
/* ======================== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-behavior: smooth;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  font-weight: 400;
  color: var(--text-primary);
  background: var(--bg-app);
  line-height: var(--lh-base);
  overflow-x: hidden;
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  position: relative;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background-image: var(--bg-image);
  background-size: cover;
  background-position: center;
  pointer-events: none;
  opacity: 1;
  transition: opacity 0.5s ease;
}

/* Subtle overlay to improve readability on bright images */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  z-index: -1;
  background: var(--bg-surface);
  opacity: var(--bg-overlay-opacity, 0);
  pointer-events: none;
  transition: opacity 0.5s ease;
}

#app {
  min-height: 100vh;
  min-height: calc(var(--vh, 1vh) * 100);
  height: 100vh;
  height: calc(var(--vh, 1vh) * 100);
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  overflow-y: hidden;
}

#app-shell {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

#page-content {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
  overflow: hidden;
}

a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }

img, video { max-width: 100%; display: block; }

input, textarea, select, button {
  font-family: inherit; font-size: inherit;
  touch-action: manipulation; /* Eliminates 300ms tap delay */
}

a, .btn, .btn-icon, .pill, .fab, .nav-item, .toggle, .checkbox-row { touch-action: manipulation; }

/* ======================== */
/* Typography               */
/* ======================== */
h1, h2, h3, h4 { font-family: var(--font-display); }
h1 { font-size: var(--text-2xl); font-weight: 800; line-height: var(--lh-2xl); }
h2 { font-size: var(--text-xl); font-weight: 700; line-height: var(--lh-xl); }
h3 { font-size: var(--text-lg); font-weight: 700; line-height: var(--lh-lg); }
h4 { font-size: var(--text-md); font-weight: 600; line-height: var(--lh-md); }

.text-xs { font-size: var(--text-xs); line-height: var(--lh-xs); }
.text-sm { font-size: var(--text-sm); line-height: var(--lh-sm); }
.text-base { font-size: var(--text-base); line-height: var(--lh-base); }
.text-muted { color: var(--text-muted); }
.text-secondary { color: var(--text-secondary); }
.text-error { color: var(--text-error); }
.text-success { color: var(--text-success); }

/* ======================== */
/* Buttons - Modern Minimal */
/* ======================== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--sp-2);
  height: 48px; padding: 0 var(--sp-6); border-radius: var(--r-md);
  font-weight: 600; font-size: var(--text-base); cursor: pointer;
  border: none; outline: none; transition: all 150ms var(--ease-out);
  white-space: nowrap; user-select: none;
  background: var(--bg-sunken);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn:active { transform: scale(0.97); }
.btn-primary { background: var(--primary); color: var(--text-inverse); border: none; box-shadow: var(--shadow-sm); }
.btn-primary:hover { background: var(--primary-light); box-shadow: var(--shadow-md); transform: translateY(-1px); }
.btn-secondary { background: var(--bg-surface); color: var(--text-primary); border: 1px solid var(--border-strong); }
.btn-secondary:hover { background: var(--bg-sunken); border-color: var(--text-muted); }
.btn-ghost { background: transparent; color: var(--text-secondary); border: none; }
.btn-ghost:hover { background: var(--bg-sunken); color: var(--text-primary); }
.btn-danger { background: var(--text-error); color: white; border: none; }
.btn-danger:hover { background: #BE123C; }
.btn-disabled, .btn:disabled {
  background: var(--bg-sunken); color: var(--text-placeholder); cursor: not-allowed; pointer-events: none; border: 1px solid var(--border);
}
.btn-sm { height: 36px; padding: 0 var(--sp-4); font-size: var(--text-sm); border-radius: var(--r-sm); }
.btn-xs { height: 28px; padding: 0 var(--sp-3); font-size: var(--text-xs); border-radius: var(--r-xs); }
.btn-full { width: 100%; }
.btn-icon {
  width: 40px; height: 40px; padding: 0; border-radius: var(--r-full);
  background: transparent; color: var(--text-secondary); border: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 150ms var(--ease-out);
}
.btn-icon:hover { background: var(--bg-sunken); color: var(--text-primary); }

.fab {
  position: fixed; bottom: 80px; right: 20px; z-index: 199;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--primary); color: white; border: none;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; cursor: pointer;
  box-shadow: var(--shadow-blue);
  transition: all 200ms var(--ease-spring);
}
.fab:hover { transform: scale(1.08); }
.fab:active { transform: scale(0.95); }

/* ======================== */
/* Inputs                   */
/* ======================== */
.input-group { margin-bottom: var(--sp-4); }
.input-group label {
  display: block; font-size: var(--text-sm); font-weight: 600;
  color: var(--text-secondary); margin-bottom: var(--sp-1);
}
.input {
  width: 100%; height: 48px; padding: 0 var(--sp-4);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--bg-surface); color: var(--text-primary);
  font-size: var(--text-base); outline: none;
  transition: all 200ms var(--ease-out);
}
.input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}
.input::placeholder { color: var(--text-placeholder); }
.input-error { border-color: var(--text-error) !important; }
.input-search {
  border-radius: var(--r-full); background: var(--bg-sunken);
  border: none; padding-left: 40px;
}
.textarea {
  width: 100%; min-height: 100px; padding: var(--sp-3) var(--sp-4);
  border: 1px solid var(--border-strong); border-radius: var(--r-md);
  background: var(--bg-surface); color: var(--text-primary);
  font-size: var(--text-base); outline: none; resize: vertical;
  font-family: var(--font-body);
  transition: all 200ms var(--ease-out);
}
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-pale);
}

.toggle {
  position: relative; width: 44px; height: 24px;
  background: var(--border-strong); border-radius: var(--r-full);
  cursor: pointer; transition: background 200ms;
  border: none; outline: none;
}
.toggle::after {
  content: ''; position: absolute; top: 2px; left: 2px;
  width: 20px; height: 20px; border-radius: 50%;
  background: white; transition: transform 200ms var(--ease-spring);
  box-shadow: var(--shadow-xs);
}
.toggle.active { background: var(--primary); }
.toggle.active::after { transform: translateX(20px); }

.checkbox-row {
  display: flex; align-items: center; gap: var(--sp-3); cursor: pointer;
}
.checkbox {
  width: 20px; height: 20px; border-radius: var(--r-xs);
  border: 2px solid var(--border-strong); background: var(--bg-surface);
  display: flex; align-items: center; justify-content: center;
  transition: all 150ms; flex-shrink: 0;
}
.checkbox.checked {
  background: var(--primary); border-color: var(--primary);
  color: white;
}

/* ======================== */
/* Cards                    */
/* ======================== */
/* ======================== */
/* Cards - Modern Minimal   */
/* ======================== */
.card {
  background: var(--bg-surface); border-radius: var(--r-md);
  border: 1px solid var(--border); padding: var(--sp-5);
  box-shadow: var(--shadow-xs);
  transition: transform 200ms var(--ease-out), box-shadow 200ms var(--ease-out);
}
.card-elevated {
  background: var(--bg-surface); border-radius: var(--r-md);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md); padding: var(--sp-5);
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-sm); }

/* ======================== */
/* Avatars                  */
/* ======================== */
.avatar {
  border-radius: 50%; object-fit: cover; display: flex;
  align-items: center; justify-content: center; flex-shrink: 0;
  background: var(--bg-sunken);
  color: var(--text-secondary); font-weight: 600; font-family: var(--font-display);
  overflow: hidden; position: relative;
  border: 1px solid var(--border);
  cursor: pointer;
}
.avatar img {
  width: 100%; height: 100%;
  max-width: 100%; max-height: 100%;
  object-fit: cover; display: block;
  border-radius: 50%;
}
.avatar-24 { width: 24px; height: 24px; font-size: 10px; }
.avatar-32 { width: 32px; height: 32px; font-size: 12px; }
.avatar-36 { width: 36px; height: 36px; font-size: 13px; }
.avatar-40 { width: 40px; height: 40px; font-size: 14px; }
.avatar-42 { width: 42px; height: 42px; font-size: 14px; }
.avatar-44 { width: 44px; height: 44px; font-size: 15px; }
.avatar-52 { width: 52px; height: 52px; font-size: 17px; }
.avatar-64 { width: 64px; height: 64px; font-size: 20px; }
.avatar-80 { width: 80px; height: 80px; font-size: 24px; }
.avatar-88 { width: 88px; height: 88px; font-size: 28px; }
.avatar-online::after {
  content: ''; position: absolute; bottom: 0; right: 0;
  width: 25%; height: 25%; border-radius: 50%;
  background: var(--online); border: 2px solid var(--bg-surface);
}

/* ======================== */
/* Badges                   */
/* ======================== */
.badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; border-radius: var(--r-full);
  background: #EF4444; color: white; font-size: 10px; font-weight: 700;
  padding: 0 5px;
}

.pill {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  height: 36px; padding: 0 var(--sp-4); border-radius: var(--r-full);
  font-size: var(--text-sm); font-weight: 700; cursor: pointer;
  border: none; color: var(--text-secondary);
  background: var(--bg-surface); transition: all 100ms;
  white-space: nowrap;
  box-shadow: var(--shadow-clay-btn);
}
.pill.active {
  background: var(--primary); color: white; box-shadow: var(--shadow-md);
}
.pill:hover:not(.active) { background: var(--bg-sunken); border-color: var(--border-strong); }

/* ======================== */
/* Navigation               */
/* ======================== */
.top-nav {
  position: sticky; top: 0; z-index: 200;
  height: 56px; display: flex; align-items: center;
  padding: 0 var(--sp-4); gap: var(--sp-3);
  background: var(--bg-surface); border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.top-nav .logo {
  font-family: var(--font-display); font-weight: 800;
  font-size: var(--text-lg); color: var(--primary);
  display: flex; align-items: center; gap: var(--sp-2);
}
.top-nav .title {
  flex: 1; text-align: center; font-family: var(--font-display);
  font-weight: 600; font-size: var(--text-md);
}
.top-nav .nav-actions { display: flex; gap: var(--sp-1); margin-left: auto; }

.bottom-nav {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 200;
  height: 60px; display: flex; align-items: center; justify-content: space-around;
  background: var(--bg-surface); border-top: 1px solid var(--border);
  backdrop-filter: blur(12px);
}
.bottom-nav .nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: var(--sp-1) var(--sp-3); cursor: pointer;
  color: var(--text-muted); font-size: 10px; font-weight: 600;
  transition: color 150ms; position: relative; border: none;
  background: none; min-width: 56px;
}
.bottom-nav .nav-item .nav-icon { font-size: 22px; transition: transform 200ms var(--ease-spring); }
.bottom-nav .nav-item.active { color: var(--primary); }
.bottom-nav .nav-item.active .nav-icon { transform: scale(1.1); }
.bottom-nav .nav-item.active::after {
  content: ''; position: absolute; top: 0;
  width: 20px; height: 3px; border-radius: var(--r-full);
  background: var(--primary);
}
.bottom-nav .nav-item .nav-badge {
  position: absolute; top: 0; right: 8px;
}

/* ======================== */
/* Layout helpers           */
/* ======================== */
/* ── Page Pane (instant-switch with smooth transition) ── */
.page-pane {
  will-change: opacity, transform;
  transform: translateZ(0); /* Force GPU composite layer */
  transition: opacity 50ms ease-out; /* Immediate but smooth */
}

/* GPU visibility toggles (much faster than display: none) */
.page-pane.pane-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  z-index: 0;
}

.page-pane.pane-active {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  position: relative;
  z-index: 10;
  width: 100%;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  padding-bottom: 68px;
}

/* When a pane contains the full-screen chat overlay, disable its own scrolling */
.page-pane.pane-active:has(.cc-chat-page) {
  overflow: hidden !important;
  overflow-y: hidden !important;
  padding-bottom: 0 !important;
}

.page { flex: 1 1 auto; padding-bottom: 0; max-width: 100%; width: 100%; overflow: hidden; display: flex; flex-direction: column; min-height: 0; position: relative; }
.page-padded { padding: var(--sp-4); padding-left: max(var(--sp-4), env(safe-area-inset-left)); padding-right: max(var(--sp-4), env(safe-area-inset-right)); }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-center { align-items: center; justify-content: center; }
.flex-between { justify-content: space-between; }
.flex-gap-1 { gap: var(--sp-1); }
.flex-gap-2 { gap: var(--sp-2); }
.flex-gap-3 { gap: var(--sp-3); }
.flex-gap-4 { gap: var(--sp-4); }
.flex-1 { flex: 1; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.hidden { display: none !important; }

/* ======================== */
/* Scrollable               */
/* ======================== */
.scroll-h {
  display: flex; overflow-x: auto; scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch; scrollbar-width: none;
  overscroll-behavior-x: contain;
}
.scroll-h::-webkit-scrollbar { display: none; }

/* ======================== */
/* Toast                    */
/* ======================== */
#toast-container {
  position: fixed; top: var(--sp-4); left: 50%; transform: translateX(-50%);
  z-index: 10000; display: flex; flex-direction: column; gap: var(--sp-2);
  pointer-events: none; width: 90vw; max-width: 360px;
}
.toast {
  padding: var(--sp-3) var(--sp-4); border-radius: var(--r-md);
  background: #0F172A; color: white; font-size: var(--text-sm);
  font-weight: 600; box-shadow: var(--shadow-lg);
  animation: toast-in 300ms var(--ease-spring);
  pointer-events: auto; display: flex; align-items: center; gap: var(--sp-2);
}
.toast-success { border-left: 4px solid var(--accent-green); }
.toast-error { border-left: 4px solid #EF4444; }
.toast-info { border-left: 4px solid var(--primary); }

/* ======================== */
/* Modal / Bottom Sheet     */
/* ======================== */
#modal-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: var(--bg-overlay); backdrop-filter: blur(4px);
  display: none; align-items: flex-end; justify-content: center;
}
#modal-overlay.active { display: flex; }
.modal {
  background: var(--bg-surface); border-radius: var(--r-lg) var(--r-lg) 0 0;
  width: 100%; max-width: 560px; max-height: 85vh;
  overflow-y: auto; animation: sheet-up 350ms var(--ease-spring);
}
.modal-header {
  display: flex; align-items: center; padding: var(--sp-4);
  border-bottom: 1px solid var(--border); position: sticky; top: 0;
  background: var(--bg-surface); z-index: 1;
}
.modal-header .drag-handle {
  width: 40px; height: 4px; border-radius: var(--r-full);
  background: var(--border-strong); margin: 0 auto var(--sp-3);
}
.modal-body { padding: var(--sp-4); }

/* ======================== */
/* Skeleton loading         */
/* ======================== */
.skeleton {
  background: var(--border); border-radius: var(--r-sm);
  animation: skeleton-pulse 1.4s ease-in-out infinite;
}
.skeleton-circle { border-radius: 50%; }
.skeleton-text { height: 14px; margin-bottom: var(--sp-2); }
.skeleton-text:last-child { width: 60%; }

/* ======================== */
/* Dividers                 */
/* ======================== */
.divider { height: 1px; background: var(--divider); margin: var(--sp-3) 0; }
.section-label {
  font-size: var(--text-xs); font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.8px; padding: var(--sp-3) var(--sp-4) var(--sp-2);
}

/* ======================== */
/* Empty states             */
/* ======================== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: var(--sp-16) var(--sp-8);
  text-align: center;
}
.empty-state .empty-icon { font-size: 64px; margin-bottom: var(--sp-4); }
.empty-state h3 { margin-bottom: var(--sp-2); color: var(--text-primary); }
.empty-state p { color: var(--text-muted); margin-bottom: var(--sp-6); max-width: 280px; }

/* ======================== */
/* Responsive Layout        */
/* ======================== */

/* Desktop Sidebar — Instagram-style hover-expand */
.desktop-sidebar {
  position: fixed; left: 0; top: 0; bottom: 0; width: 72px;
  background: var(--bg-surface); border-right: 1px solid var(--border);
  display: none; flex-direction: column;
  padding: var(--sp-4) var(--sp-2) var(--sp-4);
  z-index: 200;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
}

.desktop-sidebar:hover {
  width: 245px;
}

.sidebar-logo {
  font-family: var(--font-display); font-weight: 800; font-size: 18px;
  margin-bottom: var(--sp-6); cursor: pointer; color: var(--text-primary);
  display: flex; align-items: center; gap: var(--sp-3);
  padding: var(--sp-2) var(--sp-3);
  width: 100%; white-space: nowrap;
  min-height: 48px;
}
.sidebar-logo .logo-icon {
  display: flex; align-items: center; justify-content: center;
  width: 24px; flex-shrink: 0; font-size: 18px; font-weight: 800;
  color: var(--primary);
}

.sidebar-menu {
  display: flex; flex-direction: column; gap: var(--sp-1);
  width: 100%;
}

.sidebar-item {
  height: 48px; font-size: 20px; border-radius: var(--r-md);
  color: var(--text-secondary); display: flex; align-items: center;
  gap: var(--sp-4); padding: 0 var(--sp-3);
  transition: background-color 0.2s ease;
  border: none; background: transparent; cursor: pointer;
  position: relative; white-space: nowrap;
  width: 100%;
}
.sidebar-item:hover { background: var(--bg-sunken); color: var(--text-primary); }
.sidebar-item.active { font-weight: 700; color: var(--text-primary); }
.sidebar-item.active::before {
  content: ''; position: absolute; left: 0; top: 50%; transform: translateY(-50%);
  width: 4px; height: 4px; background: var(--primary); border-radius: 50%;
}

.sidebar-item .nav-icon {
  width: 24px; height: 24px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
}

.sidebar-item .sidebar-badge {
  position: absolute; top: 6px; right: 6px;
}

/* Label: hidden by default, fade-in on sidebar hover */
.sidebar-text {
  font-size: var(--text-base); font-weight: 600;
  font-family: var(--font-body); white-space: nowrap;
  opacity: 0; transform: translateX(-8px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}

.desktop-sidebar:hover .sidebar-text {
  opacity: 1; transform: translateX(0);
  pointer-events: auto;
}

.sidebar-bottom-item {
  margin-bottom: var(--sp-2);
}

/* Breakpoints */

/* Tablet & Up (>= 768px): show sidebar, hide bottom nav */
@media (min-width: 768px) {
  .bottom-nav { display: none; }
  .app-shell { padding-left: 72px; }
  .page, .top-nav { margin: 0; max-width: 100%; width: 100%; }
  .desktop-sidebar { display: flex; }
}

/* Large Desktop (>= 1200px): still hover-to-expand, just bump padding-left */
@media (min-width: 1200px) {
  /* Sidebar stays 72px collapsed, 245px on hover — same as tablet */
  .app-shell { padding-left: 72px; }
}

/* ======================== */
/* Feed Content Constraints */
/* ======================== */

/* Mobile: allow generous media height */
@media (max-width: 767px) {
  .post-image,
  .post-single-media img {
    max-height: 600px;
  }

  /* Videos should fill width naturally — no height constraint */
  .post-single-media video {
    max-height: none;
  }

  .post-carousel {
    max-height: 600px;
  }
}

/* ============================================ */
/* Device-Aware Responsive Layout System        */
/* Uses CSS vars set by ResponsiveLayoutController */
/* ============================================ */

/* ── Default CSS vars (overridden by JS controller) ── */
:root {
  --content-max-width: 100vw;
  --content-padding: 16px;
  --feed-max-width: 100vw;
  --discover-max-width: 100vw;
  --profile-max-width: 100vw;
  --settings-max-width: 100vw;
  --messages-max-width: 100vw;
  --groups-max-width: 100vw;
  --notifications-max-width: 100vw;
  --layout-scale: 1;
}

/* ── Pages use dynamic CSS variables for max-width ── */
.feed-page,
.post-detail-page {
  max-width: var(--feed-max-width);
  margin: 0 auto;
  width: 100%;
}

.discover-page {
  max-width: var(--discover-max-width);
  margin: 0 auto;
  width: 100%;
  padding-bottom: 80px;
  min-height: 0;
}

.profile-page {
  max-width: var(--profile-max-width);
  margin: 0 auto;
  width: 100%;
  padding-bottom: 80px;
  min-height: 0;
}

.settings-page {
  max-width: var(--settings-max-width);
  margin: 0 auto;
  width: 100%;
}

.cc-messages-page {
  max-width: var(--messages-max-width);
  margin: 0 auto;
  width: 100%;
  padding-bottom: 80px;
  min-height: 0;
}

.grp-page {
  max-width: var(--groups-max-width);
  margin: 0 auto;
  width: 100%;
}

.notifications-page {
  max-width: var(--notifications-max-width);
  margin: 0 auto;
  width: 100%;
}

/* ── Tablet & Up (>= 768px) ── */
@media (min-width: 768px) {
  .post-card {
    border-radius: var(--r-md);
    margin-bottom: var(--sp-3);
    border: 1px solid var(--border);
  }

  .post-image {
    max-height: 600px;
    object-fit: cover;
  }

  .post-carousel { max-height: none; }
  .post-single-media { max-height: none; }

  .post-single-media img {
    max-height: 600px;
    object-fit: contain;
  }

  .post-single-media video { max-height: none; }

  .post-carousel .carousel-slide-item img,
  .post-carousel .carousel-slide-item video {
    object-fit: contain;
  }

  .composer-overlay {
    max-width: 600px;
    margin: 0 auto;
    border-radius: var(--r-lg);
    top: 5vh;
    bottom: 5vh;
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    width: 90vw;
    box-shadow: var(--shadow-lg);
  }

  /* People grid → CSS grid on non-mobile */
  .people-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: var(--sp-4);
    overflow-x: visible;
    padding: var(--sp-4);
  }

  .person-card {
    min-width: unset;
    max-width: unset;
    width: 100%;
  }

  .discover-page {
    padding: 0 var(--sp-4);
  }
}

/* ── Small Desktop (>= 1024px) ── */
@media (min-width: 1024px) {
  .fab {
    right: calc(50vw - 340px + 20px);
  }
}

/* ── Desktop (>= 1280px) ── */
@media (min-width: 1280px) {
  .people-grid {
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  }

  .post-single-media img {
    max-height: 700px;
  }

  .fab {
    right: calc(50% - 360px + 240px + 20px);
  }
}

/* ── Wide Desktop (>= 1440px) ── */
@media (min-width: 1440px) {
  .people-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .composer-overlay {
    max-width: 680px;
  }
}

/* ── Ultra-Wide (>= 1920px) ── */
@media (min-width: 1920px) {
  .people-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--sp-6);
  }

  .composer-overlay {
    max-width: 720px;
  }

  .post-single-media img {
    max-height: 800px;
  }

  /* Ultra-wide: sidebar stays 72px collapsed, hover-expands to 245px */
  .app-shell {
    padding-left: 72px;
  }
}

/* ── Touch device adjustments ── */
body.touch-device .btn,
body.touch-device .pill,
body.touch-device .sidebar-item,
body.touch-device .nav-item {
  min-height: 44px; /* Apple HIG touch target */
}

body.touch-device .post-action {
  padding: var(--sp-4);
}

/* ── Mouse device enhancements ── */
body.mouse-device .post-card:hover {
  box-shadow: var(--shadow-sm);
}

body.mouse-device .chat-row:hover,
body.mouse-device .notif-row:hover,
body.mouse-device .person-card:hover {
  transform: translateY(-1px);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* ── Mobile Only (< 768px) ── */
@media (max-width: 767px) {
  .desktop-sidebar { display: none !important; }
}

/* iOS safe-area insets */
.bottom-nav {
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.top-nav {
  padding-top: env(safe-area-inset-top, 0);
}

/* Interest tag */
.interest-tag {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-full);
  background: var(--primary-pale); color: var(--primary);
  font-size: var(--text-sm); font-weight: 600;
  cursor: pointer; transition: all 150ms; border: 2px solid transparent;
  user-select: none;
}
.interest-tag:hover { background: var(--primary-ghost); border-color: var(--primary-light); }
.interest-tag.selected {
  background: var(--primary); color: white; border-color: var(--primary);
}
[data-theme="dark"] .interest-tag {
  background: rgba(61,126,255,0.15); color: var(--primary-light);
}
[data-theme="dark"] .interest-tag.selected {
  background: var(--primary); color: white;
}
/* ── Skeleton Loaders ── */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border) 50%, var(--bg-sunken) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite linear;
  border-radius: var(--r-md);
  opacity: 0.7;
}

.skeleton-text { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.skeleton-thumbnail { height: 200px; width: 100%; border-radius: var(--r-md); margin: 12px 0; }
.skeleton-button { height: 36px; width: 80px; border-radius: var(--r-full); }

.skeleton-post-card {
  padding: 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.skeleton-header {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.skeleton-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ======================== */
/* Connection Status Banner */
/* ======================== */
.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
  animation: slide-down 0.3s ease;
}

.connection-banner.ws-connected {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #065f46;
}

.connection-banner.ws-reconnecting {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
}

.connection-banner.polling-active {
  background: linear-gradient(135deg, #fed7aa, #fdba74);
  color: #9a3412;
}

.connection-banner.offline {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
}

@keyframes slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── Message Delivery Ticks ── */
.msg-tick-pending {
  color: #94a3b8;
}

.msg-tick-sent {
  color: rgba(255, 255, 255, 0.5);
}
    max-height: 700px;
  }

  .fab {
    right: calc(50% - 360px + 240px + 20px);
  }
}

/* ── Wide Desktop (>= 1440px) ── */
@media (min-width: 1440px) {
  .people-grid {
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  }

  .composer-overlay {
    max-width: 680px;
  }
}

/* ── Ultra-Wide (>= 1920px) ── */
@media (min-width: 1920px) {
  .people-grid {
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: var(--sp-6);
  }

  .composer-overlay {
    max-width: 720px;
  }

  .post-single-media img {
    max-height: 800px;
  }

  /* Ultra-wide: sidebar stays 72px collapsed, hover-expands to 245px */
  .app-shell {
    padding-left: 72px;
  }
}

/* ── Touch device adjustments ── */
body.touch-device .btn,
body.touch-device .pill,
body.touch-device .sidebar-item,
body.touch-device .nav-item {
  min-height: 44px; /* Apple HIG touch target */
}

body.touch-device .post-action {
  padding: var(--sp-4);
}

/* ── Mouse device enhancements ── */
body.mouse-device .post-card:hover {
  box-shadow: var(--shadow-sm);
}

body.mouse-device .chat-row:hover,
body.mouse-device .notif-row:hover,
body.mouse-device .person-card:hover {
  transform: translateY(-1px);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

/* ── Mobile Only (< 768px) ── */
@media (max-width: 767px) {
  .desktop-sidebar { display: none !important; }
}

/* iOS safe-area insets */
.bottom-nav {
  padding-bottom: env(safe-area-inset-bottom, 0);
}
.top-nav {
  padding-top: env(safe-area-inset-top, 0);
}

/* Interest tag */
.interest-tag {
  display: inline-flex; align-items: center; gap: var(--sp-1);
  padding: var(--sp-2) var(--sp-3); border-radius: var(--r-full);
  background: var(--primary-pale); color: var(--primary);
  font-size: var(--text-sm); font-weight: 600;
  cursor: pointer; transition: all 150ms; border: 2px solid transparent;
  user-select: none;
}
.interest-tag:hover { background: var(--primary-ghost); border-color: var(--primary-light); }
.interest-tag.selected {
  background: var(--primary); color: white; border-color: var(--primary);
}
[data-theme="dark"] .interest-tag {
  background: rgba(61,126,255,0.15); color: var(--primary-light);
}
[data-theme="dark"] .interest-tag.selected {
  background: var(--primary); color: white;
}
/* ── Skeleton Loaders ── */
@keyframes skeleton-shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

.skeleton {
  background: linear-gradient(90deg, var(--bg-sunken) 25%, var(--border) 50%, var(--bg-sunken) 75%);
  background-size: 200% 100%;
  animation: skeleton-shimmer 1.5s infinite linear;
  border-radius: var(--r-md);
  opacity: 0.7;
}

.skeleton-text { height: 14px; margin-bottom: 8px; border-radius: 4px; }
.skeleton-title { height: 20px; width: 60%; margin-bottom: 12px; }
.skeleton-avatar { width: 44px; height: 44px; border-radius: 50%; flex-shrink: 0; }
.skeleton-thumbnail { height: 200px; width: 100%; border-radius: var(--r-md); margin: 12px 0; }
.skeleton-button { height: 36px; width: 80px; border-radius: var(--r-full); }

.skeleton-post-card {
  padding: 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  flex-direction: column;
}

.skeleton-header {
  display: flex;
  gap: 12px;
  margin-bottom: 12px;
}

.skeleton-meta {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* ======================== */
/* Connection Status Banner */
/* ======================== */
.connection-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.3s ease;
  animation: slide-down 0.3s ease;
}

.connection-banner.ws-connected {
  background: linear-gradient(135deg, #d1fae5, #a7f3d0);
  color: #065f46;
}

.connection-banner.ws-reconnecting {
  background: linear-gradient(135deg, #fef3c7, #fde68a);
  color: #92400e;
}

.connection-banner.polling-active {
  background: linear-gradient(135deg, #fed7aa, #fdba74);
  color: #9a3412;
}

.connection-banner.offline {
  background: linear-gradient(135deg, #fee2e2, #fecaca);
  color: #991b1b;
}

@keyframes slide-down {
  from { transform: translateY(-100%); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* ── Message Delivery Ticks ── */
.msg-tick-pending {
  color: #94a3b8;
}

.msg-tick-sent {
  color: rgba(255, 255, 255, 0.5);
}

.msg-tick-delivered {
  color: rgba(255, 255, 255, 0.7);
}

.msg-tick-read {
  color: #34B7F1;
}

.lucide {
  width: 1.2em;
  height: 1.2em;
  vertical-align: middle;
}