:root {
  /* This UI only ships a light theme. Without this, some browsers/OSes
     (Windows/Edge/Chrome "force dark mode for web content" in particular)
     will forcibly re-invert our colors on top of the ones below, producing
     a muddy double-darkened look — flat gray boxes instead of the intended
     frosted-glass cards. Declaring color-scheme tells the browser this page
     has deliberately chosen light and it shouldn't intervene. */
  color-scheme: light;

  --primary: #3b6df0;
  --primary-dark: #2b52c4;
  --primary-light: #ebf1fe;
  --bg: #f2f4fa;
  --card-bg: #ffffff;
  --text: #1c2233;
  --muted: #6c7488;
  --border: #e6e9f2;
  --danger: #e0455a;
  --success: #29a76c;
  --gold: #c99a3f;
  --radius: 12px;
  /* Glassmorphism: translucent surfaces + backdrop blur over a soft
     gradient page background, used on the topbar, cards, dropdowns and
     modals below. --glass-bg intentionally stays close to --card-bg's
     white so text contrast doesn't suffer. */
  --glass-bg: rgba(255, 255, 255, 0.72);
  --glass-bg-strong: rgba(255, 255, 255, 0.86);
  --glass-border: rgba(255, 255, 255, 0.5);
  --glass-blur: blur(18px);
  --radius-lg: 18px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }

/* Backstop against horizontal page overflow: something (like the topbar's
   icon row before this fix — see .app-nav-icons above) forcing itself
   wider than the viewport used to drag the ENTIRE page sideways, leaving a
   blank strip of body background down the right edge on narrow phones
   instead of just clipping/scrolling the one offending element. */
html { overflow-x: hidden; }

body {
  margin: 0;
  overflow-x: hidden;
  background: var(--bg);
  background:
    radial-gradient(1100px 600px at 8% -10%, rgba(59, 109, 240, 0.10), transparent 60%),
    radial-gradient(900px 500px at 100% 0%, rgba(122, 164, 255, 0.12), transparent 55%),
    var(--bg);
  background-attachment: fixed;
  color: var(--text);
  min-height: 100vh;
}

/* Frosted-glass surface: translucent background + blur behind it, with a
   thin light border to read as "glass" rather than flat gray. Applied to
   the topbar, side/right widgets, the composer, dropdown menus and modals —
   see each rule below (search "glass surface"). */

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

.center-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: var(--card-bg);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(30, 30, 60, 0.08);
  padding: 36px;
  width: 100%;
  max-width: 420px;
}

.card.wide { max-width: 640px; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 22px;
  margin-bottom: 4px;
}
.brand .dot { color: var(--primary); }

.subtitle { color: var(--muted); margin: 0 0 24px; font-size: 14px; }

.field { margin-bottom: 16px; }
.field label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.field input[type="text"],
.field input[type="email"],
.field input[type="password"],
.field input[type="tel"],
.field input[type="date"],
.field select {
  width: 100%;
  padding: 11px 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 14px;
  background: #fff;
}
.field input:focus, .field select:focus {
  outline: none;
  border-color: var(--primary);
}
.field .hint { font-size: 12px; color: var(--muted); margin-top: 4px; }

.avatar-picker {
  display: flex;
  align-items: center;
  gap: 14px;
}
.avatar-preview {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--border) center/cover no-repeat;
  border: 2px solid var(--border);
  flex-shrink: 0;
}
.file-btn {
  border: 1px dashed var(--border);
  padding: 8px 14px;
  border-radius: 8px;
  font-size: 13px;
  cursor: pointer;
  background: #f8f7f4;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 16px;
  border-radius: 10px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, box-shadow .15s ease;
}
.btn:active { transform: scale(0.99); }
.btn-primary { background: var(--primary); color: #fff; box-shadow: 0 2px 8px rgba(59,109,240,.28); }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(59,109,240,.36); }
.btn-primary:disabled { background: #9db8b1; cursor: not-allowed; box-shadow: none; }

.btn-google {
  background: #fff;
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-google:hover { background: #f7f7fb; }

.btn-outline {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text);
}
.btn-outline:hover { background: #f7f7fb; }

.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c93a4c; }

.btn-sm { width: auto; padding: 6px 12px; font-size: 13px; }

.divider {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--muted);
  font-size: 12px;
  margin: 18px 0;
}
.divider::before, .divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.error-box {
  background: #fdecee;
  color: var(--danger);
  border: 1px solid #f6c7ce;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.error-box.show { display: block; }

.success-box {
  background: #e9f9f0;
  color: var(--success);
  border: 1px solid #bfe9d4;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 13px;
  margin-bottom: 16px;
  display: none;
}
.success-box.show { display: block; }

.foot-note {
  text-align: center;
  margin-top: 20px;
  font-size: 13px;
  color: var(--muted);
}

/* =========================================================
   Auth screens (login / register) — split hero + form panel
   ========================================================= */
body.auth-body { background: #fff; }
.auth-screen { min-height: 100vh; display: flex; }
.auth-hero {
  flex: 1.15; display: flex; flex-direction: column; justify-content: center;
  padding: 60px 64px; background: linear-gradient(160deg, #f4f7ff, #eef2ff);
  position: relative; overflow: hidden;
}
.auth-hero-brand { margin-bottom: 34px; }
.auth-hero-brand .brand-mark { width: 40px; height: 40px; font-size: 20px; }
.auth-hero-brand .brand-text { font-size: 20px; }
.auth-hero-title {
  font-size: 44px; font-weight: 800; line-height: 1.18; margin: 0 0 16px; color: var(--text);
  max-width: 480px;
}
.auth-hero-title span { color: var(--primary); }
.auth-hero-sub { font-size: 16px; color: var(--muted); max-width: 420px; line-height: 1.5; margin: 0 0 46px; }

.auth-hero-graphic { position: relative; height: 220px; max-width: 460px; }
.auth-float-card {
  position: absolute; background: #fff; border-radius: 16px; box-shadow: 0 14px 34px rgba(30,40,80,.14);
  padding: 14px; display: flex; align-items: center; gap: 10px;
}
.auth-float-card.card-a { top: 0; left: 10px; width: 210px; transform: rotate(-4deg); }
.auth-float-card.card-b {
  top: 26px; right: 20px; width: 68px; height: 68px; justify-content: center; transform: rotate(6deg);
  background: linear-gradient(135deg, var(--primary), #7aa4ff);
}
.auth-float-card.card-c { bottom: 0; left: 60px; width: 230px; flex-direction: column; align-items: stretch; transform: rotate(3deg); }
.fc-avatar { width: 34px; height: 34px; border-radius: 50%; background: linear-gradient(135deg, #ffb86b, #ff7a7a); flex-shrink: 0; }
.fc-lines { display: flex; flex-direction: column; gap: 6px; flex: 1; }
.fc-lines span { display: block; height: 8px; border-radius: 4px; background: var(--border); }
.fc-lines span:first-child { width: 80%; }
.fc-lines span:last-child { width: 55%; }
.fc-icon { font-size: 26px; color: #fff; }
.fc-bar { height: 9px; border-radius: 4px; background: var(--border); margin-bottom: 8px; }
.fc-bar.short { width: 60%; }
.fc-dots { display: flex; gap: 5px; }
.fc-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--primary-light); display: block; }
.fc-dots i:first-child { background: var(--primary); }

.auth-panel { flex: 1; display: flex; align-items: center; justify-content: center; padding: 40px 24px; }
.auth-form-card { width: 100%; max-width: 400px; }
.auth-form-title { font-size: 24px; font-weight: 800; margin: 0 0 22px; }
.auth-form-card .field { margin-bottom: 12px; }
.auth-form-card .field input,
.auth-form-card .field select {
  padding: 13px 16px; border-radius: 8px; font-size: 15px;
}
.auth-forgot-link {
  display: block; text-align: center; margin: 6px 0 2px; border: none; background: none;
  color: var(--primary); font-size: 13.5px; font-weight: 600; cursor: pointer; padding: 6px;
}
.auth-forgot-link:hover { text-decoration: underline; }
.auth-info-box {
  background: var(--bg); color: var(--text); border: 1px solid var(--border);
  padding: 10px 12px; border-radius: 8px; font-size: 13px; margin-bottom: 12px; display: none; text-align: center;
}
.auth-info-box.show { display: block; }
.auth-create-btn { display: block; text-align: center; text-decoration: none; margin-top: 10px; }
.auth-create-btn:hover { text-decoration: none; }
.auth-avatar-picker-wrap { display: flex; justify-content: center; margin-bottom: 18px; }

@media (max-width: 860px) {
  .auth-hero { display: none; }
  .auth-panel { padding: 32px 20px; }
}

/* Category picker */
.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 12px;
  margin: 20px 0 28px;
}
.category-chip {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 16px 10px;
  text-align: center;
  cursor: pointer;
  background: #fff;
  font-size: 14px;
  font-weight: 600;
  user-select: none;
  transition: all 0.12s ease;
}
.category-chip .icon { font-size: 24px; display: block; margin-bottom: 6px; }
.category-chip.selected {
  border-color: var(--primary);
  background: var(--primary-light);
  color: var(--primary-dark);
}

/* Top nav (dashboard / admin) */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 28px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}
.topbar .brand { margin: 0; }
.topbar-actions { display: flex; align-items: center; gap: 14px; }
.chip-role {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  background: var(--primary-light);
  color: var(--primary-dark);
  padding: 3px 8px;
  border-radius: 20px;
}

.page-wrap { max-width: 960px; margin: 0 auto; padding: 32px 20px; }

/* =========================================================
   Post permalink page (public/post.html + public/js/post.js)
   ========================================================= */
.post-page-header {
  display: flex; align-items: center; gap: 14px; padding: 12px 20px; background: var(--card-bg);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 40;
}
.post-page-back-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; background: var(--bg); color: var(--text);
  cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.post-page-back-btn:hover { background: var(--border); }
.post-page-title { font-weight: 800; font-size: 17px; }
.post-page-wrap { max-width: 620px; margin: 0 auto; padding: 20px 16px 60px; }
@media (max-width: 480px) {
  .post-page-wrap { padding: 12px 10px 40px; }
}

.profile-header { display: flex; align-items: center; gap: 20px; margin-bottom: 28px; }
.profile-avatar {
  width: 84px; height: 84px; border-radius: 50%;
  background: var(--border) center/cover no-repeat;
  border: 3px solid #fff;
  box-shadow: 0 0 0 1px var(--border);
}
.profile-name { font-size: 22px; font-weight: 700; margin: 0; }
.profile-email { color: var(--muted); font-size: 14px; margin: 2px 0 8px; }
.badge-list { display: flex; gap: 8px; flex-wrap: wrap; }
.badge {
  background: var(--primary-light); color: var(--primary-dark);
  border-radius: 20px; padding: 4px 12px; font-size: 12px; font-weight: 600;
}

.section-title { font-size: 16px; font-weight: 700; margin: 28px 0 12px; }

.info-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
}
.info-item {
  background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px;
}
.info-item .label { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.info-item .value { font-size: 14px; font-weight: 600; }

/* Admin tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.tab-btn {
  padding: 10px 18px; border: none; background: none; cursor: pointer;
  font-size: 14px; font-weight: 600; color: var(--muted);
  border-bottom: 2px solid transparent;
}
.tab-btn.active { color: var(--primary-dark); border-color: var(--primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.table-wrap { background: #fff; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td { text-align: left; padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
th { background: #f8f7f4; font-size: 12px; text-transform: uppercase; color: var(--muted); }
tr:last-child td { border-bottom: none; }
.row-actions { display: flex; gap: 8px; }
.status-pill { padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.status-active { background: #e9f9f0; color: var(--success); }
.status-blocked { background: #fdecee; color: var(--danger); }

.toolbar { display: flex; gap: 10px; margin-bottom: 16px; flex-wrap: wrap; align-items: center; }
.toolbar input[type="text"] {
  padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; flex: 1; min-width: 200px;
}

.inline-form { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 16px; }
.inline-form input, .inline-form textarea { padding: 9px 12px; border: 1px solid var(--border); border-radius: 8px; font-size: 13px; }
.inline-form input[type="text"] { flex: 1; min-width: 160px; }

.stat-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 24px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: 10px; padding: 16px; }
.stat-card .num { font-size: 26px; font-weight: 700; }
.stat-card .lbl { font-size: 12px; color: var(--muted); }

.empty-state { text-align: center; padding: 40px 20px; color: var(--muted); font-size: 14px; }

.loading { text-align: center; padding: 20px; color: var(--muted); font-size: 13px; }

/* =========================================================
   Timeline (home feed) — logo mark, app topbar, 3-column
   layout, composer, post cards, and the right-rail widgets.
   ========================================================= */

.brand-mark {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 16px; flex-shrink: 0;
}
/* Now an <a href="/timeline.html"> (clicking the logo goes home, like any
   normal site) — reset link styling so it still just looks like a logo,
   not a blue underlined link. */
.brand-row, .brand-row:hover { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--text); text-decoration: none; }

.app-topbar {
  display: flex; align-items: center; gap: 20px;
  padding: 10px 24px; border-bottom: 1px solid var(--glass-border);
  position: sticky; top: 0; z-index: 50;
  /* glass surface */
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.brand-row { flex-shrink: 0; }
/* The search box is the only topbar element allowed to shrink — everything
   else (logo, nav icons, notifications/avatar) keeps its size so a narrower
   window compresses gracefully instead of the whole topbar overflowing and
   forcing the page into horizontal scroll. */
.app-search { flex: 1 1 180px; min-width: 0; max-width: 320px; position: relative; }
.app-search input {
  width: 100%; padding: 9px 14px 9px 36px; border-radius: 20px;
  border: 1px solid var(--border); background: var(--bg); font-size: 13.5px;
}
.app-search input:focus { outline: none; border-color: var(--primary); background: #fff; }
.app-search .icon { position: absolute; left: 13px; top: 50%; transform: translateY(-50%); color: var(--muted); font-size: 13px; }

.search-results {
  position: absolute; top: calc(100% + 8px); left: 0; width: 320px;
  background: #fff; border: 1px solid var(--border); border-radius: 12px;
  box-shadow: 0 16px 40px rgba(20, 20, 20, .14); max-height: 380px; overflow: auto;
  display: none; z-index: 60;
}
.search-results.show { display: block; }
.search-section-label { font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); padding: 10px 14px 4px; }
.search-result-item { display: flex; align-items: center; gap: 10px; padding: 9px 14px; cursor: pointer; }
.search-result-item:hover { background: var(--bg); }
.search-empty { padding: 16px 14px; font-size: 13px; color: var(--muted); }

/* flex-shrink:1 + min-width:0 (not the flex-item default of "auto", which
   would refuse to shrink below the sum of every icon's width) lets this
   row give up space to .topbar-right/.brand-row when the window is too
   narrow to fit everything, scrolling its own icons internally instead of
   forcing .app-topbar — and the whole page — wider than the viewport. See
   the ≤480px rule below for why that matters on real phones. */
.app-nav-icons {
  display: flex; align-items: center; gap: 4px; margin: 0 auto; flex-shrink: 1; min-width: 0;
  background: var(--bg); padding: 4px; border-radius: 14px;
  overflow-x: auto; scrollbar-width: none; -ms-overflow-style: none;
}
.app-nav-icons::-webkit-scrollbar { display: none; }
.nav-icon-btn {
  width: 52px; height: 40px; flex-shrink: 0; border-radius: 10px; display: flex; align-items: center; justify-content: center;
  border: none; background: transparent; cursor: pointer; color: var(--muted); font-size: 19px; position: relative;
  transition: background-color .15s ease, color .15s ease, transform .1s ease;
}
.nav-icon-btn svg { transition: transform .15s ease; }
.nav-icon-btn.active { color: var(--primary); background: #fff; box-shadow: 0 1px 4px rgba(20,30,60,.12); }
.nav-icon-btn:hover:not(.active) { background: rgba(255,255,255,.7); color: var(--text); }
.nav-icon-btn:active svg { transform: scale(.88); }
.nav-icon-btn[disabled] { opacity: .35; cursor: not-allowed; }
.nav-icon-btn[disabled]:hover { background: none; }

.topbar-right { display: flex; align-items: center; gap: 12px; margin-left: auto; position: relative; flex-shrink: 0; }

/* Below ~860px even a fully-shrunk search box plus the logo text, six nav
   icons, and the notifications/avatar cluster can't fit on one line — trim
   the least essential pixels first (logo wordmark, icon padding/gaps) so
   the topbar keeps working right down to a narrow window instead of
   overflowing and dragging the whole page into horizontal scroll. */
@media (max-width: 860px) {
  .app-topbar { padding: 10px 12px; gap: 10px; }
  .brand-text { display: none; }
  .app-nav-icons { gap: 0; padding: 3px; }
  .nav-icon-btn { width: 38px; height: 34px; font-size: 17px; }
  .app-search { min-width: 70px; }
}
@media (max-width: 560px) {
  .app-search { display: none; }
}
/* Real phones (most Android devices report a 360-412px CSS viewport) are
   narrower than the 5 nav icons + logo + messages/notifications/avatar
   cluster can fit even after the steps above — .app-nav-icons now scrolls
   internally instead of overflowing (see its rule above), but shave a
   little more off here too so as few icons as possible need scrolling. */
@media (max-width: 480px) {
  .app-topbar { padding: 8px 10px; gap: 6px; }
  .nav-icon-btn { width: 34px; height: 32px; font-size: 16px; }
  .topbar-right { gap: 8px; }
}
.icon-btn {
  position: relative; width: 40px; height: 40px; border-radius: 50%; border: none;
  background: var(--bg); display: flex; align-items: center; justify-content: center; cursor: pointer; font-size: 16px;
  transition: background-color .15s ease, transform .1s ease;
}
.icon-btn:hover { background: var(--primary-light); }
.icon-btn:active { transform: scale(.92); }
.icon-badge {
  position: absolute; top: -3px; right: -3px; background: var(--danger); color: #fff;
  font-size: 10px; font-weight: 700; border-radius: 10px; min-width: 16px; height: 16px;
  display: flex; align-items: center; justify-content: center; padding: 0 3px;
}
.avatar-btn-wrap {
  display: flex; align-items: center; gap: 5px; border: none; background: var(--bg);
  cursor: pointer; padding: 2px 8px 2px 2px; border-radius: 22px;
}
.avatar-btn-wrap:hover { background: var(--primary-light); }
.avatar-btn-img { width: 34px; height: 34px; border-radius: 50%; background: var(--border) center/cover no-repeat; flex-shrink: 0; }
.avatar-chevron { color: var(--muted); flex-shrink: 0; }

.dropdown-panel {
  position: absolute; top: 50px; right: 0; width: 330px;
  border: 1px solid var(--glass-border); border-radius: var(--radius-lg); box-shadow: 0 18px 44px rgba(20,20,20,.16);
  display: none; overflow: hidden; z-index: 80;
  /* glass surface */
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.dropdown-panel.show { display: block; }
.dropdown-header { padding: 14px 16px; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 14px; }
.dropdown-header button.link-btn { border: none; background: none; font-size: 12px; font-weight: 600; color: var(--primary); cursor: pointer; }
.dropdown-list { max-height: 380px; overflow: auto; }
.dropdown-item { display: flex; gap: 10px; padding: 12px 16px; border-bottom: 1px solid var(--border); cursor: default; }
.dropdown-item:last-child { border-bottom: none; }
.dropdown-item.unread { background: var(--primary-light); }
.dropdown-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--border) center/cover no-repeat; flex-shrink: 0; }
.dropdown-text { font-size: 13px; line-height: 1.4; }
.dropdown-time { font-size: 11px; color: var(--muted); margin-top: 2px; }
.menu-list { padding: 6px; }
.menu-list a, .menu-list button.menu-btn {
  display: block; width: 100%; text-align: left; padding: 10px 12px; border-radius: 8px;
  border: none; background: none; font-size: 14px; cursor: pointer; color: var(--text);
}
.menu-list a:hover, .menu-list button.menu-btn:hover { background: var(--bg); text-decoration: none; }
.menu-list button.menu-btn.danger { color: var(--danger); }
.menu-list button.menu-btn.danger:hover { background: #fdecee; }

.app-layout {
  display: grid; grid-template-columns: 260px minmax(0, 620px) 300px;
  gap: 20px; max-width: 1220px; margin: 0 auto; padding: 20px; align-items: start;
}
/* Graduated collapse instead of one hard cutoff: the right "requests /
   contacts" rail is the first thing to go since it's the least essential,
   so the feed still sits inside a proper two-column layout (not a bare,
   empty-feeling single column) all the way down to tablet width. Only
   below ~900px — genuinely too narrow for any sidebar — does it drop to
   a single column. */
@media (max-width: 1180px) {
  .app-layout { grid-template-columns: 230px minmax(0, 1fr); max-width: 900px; }
  .side-col.right-col { display: none; }
}
@media (max-width: 900px) {
  .app-layout { grid-template-columns: 1fr; }
  .side-col.left-col { display: none; }
}

.side-col { position: sticky; top: 76px; display: flex; flex-direction: column; gap: 16px; }

.widget {
  border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: 18px;
  box-shadow: 0 1px 2px rgba(20,30,60,.04), 0 10px 24px rgba(20,30,60,.07);
  /* glass surface */
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.widget-title { font-size: 14px; font-weight: 700; margin: 0 0 12px; }

.profile-card-mini { display: flex; align-items: center; gap: 12px; }
.profile-card-mini .avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--border) center/cover no-repeat; }
.profile-card-mini .name { font-weight: 700; font-size: 15px; }
.profile-card-mini .link { font-size: 12px; color: var(--muted); }
.profile-card-mini .link:hover { color: var(--primary); }

.side-nav { display: flex; flex-direction: column; gap: 2px; margin-top: 16px; }
.side-nav-item {
  display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px;
  cursor: pointer; font-weight: 600; font-size: 14px; color: var(--text); border: none;
  background: none; width: 100%; text-align: left;
}
.side-nav-item .ic { width: 20px; text-align: center; }
.side-nav-item:hover { background: var(--bg); }
.side-nav-item.active { background: var(--primary-light); color: var(--primary-dark); }
.side-nav-item.disabled { color: var(--muted); cursor: not-allowed; }
.side-nav-item .soon { margin-left: auto; font-size: 10px; background: var(--border); color: var(--muted); padding: 2px 6px; border-radius: 8px; }

.hashtag-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13px; cursor: pointer; border-bottom: 1px solid var(--border); background: none; border-left: none; border-right: none; border-top: none; width: 100%; text-align: left; }
.hashtag-row:last-child { border-bottom: none; }
.hashtag-row .tag { font-weight: 600; color: var(--text); }
.hashtag-row:hover .tag { color: var(--primary); }
.hashtag-row .count { color: var(--muted); }

.composer {
  border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: 16px 20px; margin-bottom: 16px;
  box-shadow: 0 1px 2px rgba(20,30,60,.04), 0 10px 24px rgba(20,30,60,.07);
  /* glass surface */
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  transition: box-shadow .2s ease;
}
.composer:focus-within { box-shadow: 0 1px 2px rgba(20,30,60,.04), 0 14px 30px rgba(59,109,240,.14); }
.composer-top { display: flex; gap: 12px; align-items: flex-start; }
.composer-avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--border) center/cover no-repeat; flex-shrink: 0; }
.composer-textarea {
  width: 100%; border: none; background: var(--bg); border-radius: 16px; resize: vertical; min-height: 44px;
  font-size: 14px; font-family: inherit; padding: 11px 16px; color: var(--text);
}
.composer-textarea:focus { outline: 2px solid var(--primary-light); background: #fff; }
.composer-preview { margin: 10px 0 0 52px; position: relative; display: none; }
.composer-preview.show { display: block; }
.composer-preview img, .composer-preview video { max-width: 100%; border-radius: 10px; max-height: 260px; object-fit: cover; display: block; }
.composer-media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; }
.composer-media-grid .composer-media-tile img { height: 110px; width: 100%; max-height: none; }
.composer-media-tile { position: relative; }
.composer-preview .remove-preview {
  position: absolute; top: 8px; right: 8px; background: rgba(0,0,0,.6); color: #fff; border: none;
  width: 26px; height: 26px; border-radius: 50%; cursor: pointer; font-size: 14px; z-index: 1;
}
.composer-actions { display: flex; align-items: center; gap: 4px; border-top: 1px solid var(--border); padding-top: 12px; margin-top: 12px; flex-wrap: wrap; }
.composer-action-btn {
  display: flex; align-items: center; gap: 6px; border: none; background: none; cursor: pointer;
  font-size: 13px; font-weight: 700; padding: 8px 10px; border-radius: 8px; color: var(--muted);
}
.composer-action-btn:hover { background: var(--bg); }
.composer-action-btn.active { background: var(--primary-light); color: var(--primary-dark); }
.composer-action-btn.photo-tint { color: #2f9e6f; }
.composer-action-btn.hashtag-tint { color: var(--gold); }
/* Anonymous mode gets its own distinct color (not the usual blue "active"
   tint) since it changes what other people see, not just a UI preference —
   worth a clearer visual callout. */
.composer-submit { margin-left: auto; }
.composer-submit .btn { width: auto; padding: 9px 22px; }

/* =========================================================
   Post composer — Facebook-style: a slim trigger bar in the feed opens
   the real composer as a modal (see #post-composer-overlay in timeline.html)
   ========================================================= */
.composer-trigger-card { padding: 14px 18px; }
.composer-trigger-input {
  flex: 1; text-align: left; border: none; background: var(--bg); border-radius: 22px;
  padding: 11px 18px; font-size: 14.5px; color: var(--muted); cursor: pointer; font-family: inherit;
  transition: background-color .15s ease;
}
.composer-trigger-input:hover { background: var(--border); }
.composer-quick-row { display: flex; gap: 4px; border-top: 1px solid var(--border); padding-top: 10px; margin-top: 12px; }
.composer-quick-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 8px;
  border: none; background: none; cursor: pointer; padding: 8px; border-radius: 8px;
  font-size: 13px; font-weight: 700; color: var(--muted);
}
.composer-quick-btn:hover { background: var(--bg); }

.post-composer-box { max-width: 520px; }
.post-composer-body { padding: 14px 18px 18px; }
.post-composer-identity { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.post-composer-name { font-weight: 700; font-size: 15px; }
.post-composer-audience-pill {
  display: inline-flex; align-items: center; gap: 5px; margin-top: 3px;
  border: none; background: var(--bg); color: var(--text); font-size: 12px; font-weight: 700;
  padding: 3px 9px; border-radius: 6px; cursor: pointer;
}
.post-composer-audience-pill:hover { background: var(--border); }
.post-composer-audience-pill.active { background: rgba(224, 69, 90, 0.12); color: var(--danger); }

.post-composer-feeling-chip {
  display: none; align-items: center; gap: 8px; background: var(--primary-light); color: var(--primary-dark);
  font-size: 13px; font-weight: 700; padding: 7px 12px; border-radius: 10px; margin-bottom: 10px;
}
.feeling-chip-remove { margin-left: auto; border: none; background: none; cursor: pointer; color: inherit; font-size: 16px; line-height: 1; opacity: .7; }
.feeling-chip-remove:hover { opacity: 1; }

.post-composer-textarea {
  width: 100%; border: none; background: transparent; resize: vertical; min-height: 90px;
  font-size: 18px; font-family: inherit; padding: 4px 0; color: var(--text);
}
.post-composer-textarea:focus { outline: none; }
.post-composer-body .composer-preview { margin: 6px 0 0; }

.upload-inline-progress { display: none; align-items: center; gap: 10px; margin-top: 12px; }
.upload-inline-track { flex: 1; height: 7px; border-radius: 5px; background: var(--border); overflow: hidden; }
.upload-inline-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #7aa4ff); border-radius: 5px; transition: width .15s ease; }
.upload-inline-pct { font-size: 12px; font-weight: 700; color: var(--muted); flex-shrink: 0; }

.feeling-picker { display: none; margin-top: 12px; }
.feeling-picker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 6px; max-height: 220px; overflow-y: auto; }
.feeling-option {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--bg);
  border-radius: 8px; padding: 8px 10px; font-size: 13px; font-weight: 600; color: var(--text); cursor: pointer;
  text-transform: capitalize;
}
.feeling-option:hover { background: var(--primary-light); border-color: var(--primary-light); }
.feeling-option-emoji { font-size: 16px; }

.post-composer-add-row {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-top: 14px;
}
.post-composer-add-label { font-size: 13px; font-weight: 700; color: var(--text); }
.post-composer-add-icons { display: flex; align-items: center; gap: 4px; }
.post-composer-add-icons .composer-action-btn { padding: 6px; border-radius: 6px; }
.composer-action-btn.feeling-tint { color: var(--gold); }
.post-composer-submit-btn { width: 100%; margin-top: 14px; padding: 10px; font-size: 15px; }
.post-composer-submit-btn:disabled { opacity: .6; cursor: default; }

.feed-list { display: flex; flex-direction: column; gap: 16px; }
.post-card {
  border: 1px solid var(--glass-border); border-radius: var(--radius-lg); padding: 18px 20px;
  box-shadow: 0 1px 2px rgba(20,30,60,.04), 0 10px 24px rgba(20,30,60,.07);
  /* glass surface */
  background: var(--glass-bg);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.post-head { display: flex; align-items: flex-start; gap: 12px; }
.post-avatar { width: 42px; height: 42px; border-radius: 50%; background: var(--border) center/cover no-repeat; flex-shrink: 0; }
.post-authorline { flex: 1; min-width: 0; }
.post-author { font-weight: 700; font-size: 14px; }
.post-meta { font-size: 12px; color: var(--muted); display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.post-menu-wrap { position: relative; }
.post-menu-btn { border: none; background: none; cursor: pointer; color: var(--muted); font-size: 18px; padding: 4px 8px; border-radius: 6px; }
.post-menu-btn:hover { background: var(--bg); }
.post-menu-dropdown {
  position: absolute; top: 34px; right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 10px; box-shadow: 0 12px 30px rgba(0,0,0,.14); display: none; min-width: 140px; overflow: hidden; z-index: 20;
}
.post-menu-dropdown.show { display: block; }

.suggestion-chip {
  display: inline-flex; align-items: center; gap: 6px; background: var(--primary-light); color: var(--primary-dark);
  font-size: 11.5px; font-weight: 700; padding: 4px 10px; border-radius: 20px; margin: 10px 0 0;
}

.post-content { font-size: 14.5px; line-height: 1.6; margin: 12px 0 0; white-space: pre-wrap; word-break: break-word; }
.post-content .hashtag-link { color: var(--primary); font-weight: 700; cursor: pointer; }
.post-image { margin-top: 12px; border-radius: 10px; overflow: hidden; }
.post-image img { width: 100%; max-height: 480px; object-fit: cover; display: block; }

.post-stats { display: flex; justify-content: space-between; font-size: 12px; color: var(--muted); padding: 10px 0 6px; border-bottom: 1px solid var(--border); margin-top: 4px; }
.post-actions { display: flex; gap: 6px; padding-top: 8px; }
.post-action-btn {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; border: none; background: none;
  cursor: pointer; font-size: 13px; font-weight: 700; color: var(--muted); padding: 8px; border-radius: 8px;
  transition: background-color .12s ease, color .12s ease;
}
.post-action-btn:hover { background: var(--bg); color: var(--text); }
.post-action-btn.liked { color: var(--danger); }
.post-action-btn.saved-active { color: var(--gold); }

/* Real phones (~360-412px CSS width — see the .app-topbar comment above)
   can't fit 4 labeled buttons (Like/Comment/Save/Share) on one row without
   clipping the last one — confirmed by a user screenshot where "Share" was
   cut off at the screen edge. Icon-only below this width, same pattern
   already used for reel action buttons (.reel-action-btn span). */
@media (max-width: 480px) {
  .post-actions { gap: 2px; }
  .post-action-btn { padding: 8px 2px; gap: 0; }
  .post-action-btn span { display: none; }
}

/* Embedded "shared post" preview — the box a repost shows in place of its
   own media (a repost never has its own photos/video, see createPost). */
.shared-post-box {
  border: 1px solid var(--border); border-radius: 10px; margin-top: 12px; overflow: hidden; cursor: pointer;
}
.shared-post-box:hover { background: var(--bg); }
.shared-post-head { display: flex; align-items: center; gap: 10px; padding: 10px 12px 6px; }
.shared-post-avatar { width: 32px; height: 32px; border-radius: 50%; background: var(--border) center/cover no-repeat; flex-shrink: 0; }
.shared-post-author { font-weight: 700; font-size: 13.5px; }
.shared-post-time { font-size: 11.5px; color: var(--muted); }
.shared-post-content { padding: 0 12px 10px; font-size: 13.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.shared-post-media {
  width: 100%; max-height: 320px; min-height: 120px; background-color: var(--bg); background-position: center;
  background-size: cover; background-repeat: no-repeat;
}
.shared-post-media video { width: 100%; max-height: 320px; display: block; object-fit: cover; }

.comments-section { display: none; margin-top: 12px; border-top: 1px solid var(--border); padding-top: 12px; }
.comments-section.show { display: block; }
.comment-item { display: flex; gap: 10px; margin-bottom: 10px; }
.comment-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--border) center/cover no-repeat; flex-shrink: 0; }
.comment-bubble { background: var(--bg); border-radius: 14px; padding: 8px 12px; font-size: 13px; flex: 1; }
.comment-author { font-weight: 700; margin-right: 6px; }
/* Facebook-style comment bar: avatar, a pill input with an in-pill emoji
   button, and a round send button that lights up once there's text. */
.comment-form { display: flex; gap: 8px; margin-top: 10px; align-items: center; }
.comment-form-avatar { width: 30px; height: 30px; border-radius: 50%; background: var(--border) center/cover no-repeat; flex-shrink: 0; }
.comment-input-pill {
  flex: 1; display: flex; align-items: center; gap: 4px; background: var(--bg); position: relative;
  border: 1px solid transparent; border-radius: 20px; padding: 2px 6px 2px 14px; min-width: 0;
}
.comment-input-pill:focus-within { background: #fff; border-color: var(--primary); }
.comment-form input {
  flex: 1; min-width: 0; border: none; background: none; padding: 8px 0; font-size: 13px; outline: none; color: var(--text);
}
.comment-emoji-btn {
  border: none; background: none; cursor: pointer; font-size: 16px; line-height: 1; padding: 6px;
  border-radius: 50%; flex-shrink: 0; display: flex; align-items: center; justify-content: center;
}
.comment-emoji-btn:hover { background: var(--border); }
.comment-send-btn {
  width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; color: var(--muted); background: var(--bg);
  transition: background .12s ease, color .12s ease;
}
.comment-send-btn:hover { background: var(--border); }
.comment-send-btn.active { background: var(--primary); color: #fff; }

.emoji-quickpick {
  position: absolute; bottom: calc(100% + 8px); right: 0; background: #fff; border: 1px solid var(--border);
  border-radius: 12px; box-shadow: 0 8px 24px rgba(30,30,60,.15); padding: 6px; display: none; gap: 2px; z-index: 5;
}
.emoji-quickpick.show { display: flex; }
.emoji-quickpick button {
  border: none; background: none; cursor: pointer; font-size: 18px; padding: 5px; border-radius: 8px; line-height: 1;
}
.emoji-quickpick button:hover { background: var(--bg); }

.group-row, .contact-row { display: flex; align-items: center; gap: 10px; padding: 9px 0; }
.group-row:not(:last-child), .contact-row:not(:last-child) { border-bottom: 1px solid var(--border); }
.group-cover { width: 44px; height: 44px; border-radius: 10px; background: var(--border) center/cover no-repeat; flex-shrink: 0; }
.group-name { font-size: 13.5px; font-weight: 700; }
.group-meta { font-size: 12px; color: var(--muted); }
.group-join-btn { margin-left: auto; border: 1px solid var(--border); background: #fff; padding: 6px 14px; border-radius: 8px; font-size: 12.5px; font-weight: 700; cursor: pointer; white-space: nowrap; }
.group-join-btn:hover { background: var(--bg); }
.group-join-btn.joined { color: var(--primary); border-color: var(--primary); }

.contact-avatar-wrap { position: relative; flex-shrink: 0; }
.contact-avatar { width: 36px; height: 36px; border-radius: 50%; background: var(--border) center/cover no-repeat; }
.presence-dot {
  position: absolute; bottom: 0; right: 0; width: 10px; height: 10px; border-radius: 50%;
  background: #c7c9c2; border: 2px solid #fff;
}
.presence-dot.online { background: #29a76c; }
.contact-name { font-size: 13.5px; font-weight: 600; }
.contact-status { font-size: 11.5px; color: var(--muted); }

.view-panel { display: none; }
.view-panel.active { display: block; }
.panel-heading { font-size: 18px; font-weight: 700; margin: 0 0 16px; display: flex; align-items: center; gap: 10px; }
.panel-heading .clear-filter { font-size: 12px; font-weight: 600; color: var(--primary); cursor: pointer; background: none; border: none; }

.groups-grid, .people-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 14px; }
.groups-grid .group-card, .people-card {
  background: #fff; border: 1px solid var(--border); border-radius: 12px; padding: 16px;
  display: flex; flex-direction: column; align-items: center; text-align: center; gap: 8px;
}
.group-card .group-cover-lg, .people-card .avatar-lg { width: 56px; height: 56px; border-radius: 50%; background: var(--border) center/cover no-repeat; }
.group-card .group-cover-lg { border-radius: 12px; }

.section-subtitle { font-size: 13px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; margin: 22px 0 12px; }

.load-more-btn { display: block; margin: 6px auto 0; }
.empty-feed { text-align: center; padding: 60px 20px; color: var(--muted); }
.empty-feed .big-icon { font-size: 40px; margin-bottom: 10px; }
.spinner-row { text-align: center; padding: 20px; color: var(--muted); font-size: 13px; }

/* =========================================================
   Stories strip + story viewer
   ========================================================= */
.stories-strip {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; margin-bottom: 16px;
}
.stories-strip::-webkit-scrollbar { height: 6px; }
.stories-strip::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }

.story-tile {
  position: relative; flex: 0 0 108px; height: 172px; border-radius: 14px; overflow: hidden;
  cursor: pointer; background: var(--border); box-shadow: 0 2px 8px rgba(20,30,60,.08);
  transition: transform .15s ease, box-shadow .15s ease;
}
.story-tile:hover { transform: translateY(-2px); box-shadow: 0 8px 18px rgba(20,30,60,.14); }
.story-tile .story-bg { position: absolute; inset: 0; background: var(--border) center/cover no-repeat; display: flex; align-items: center; justify-content: center; }
.story-tile .story-play-icon { color: #fff; font-size: 20px; opacity: .9; }
.story-tile::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(0,0,0,0) 45%, rgba(0,0,0,.55) 100%);
}
.story-tile .story-avatar-ring {
  position: absolute; top: 10px; left: 10px; width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--primary), #7aa4ff); padding: 2.5px; z-index: 2;
}
.story-tile.seen .story-avatar-ring { background: var(--border); }
.story-tile .story-avatar-overlay {
  width: 100%; height: 100%; border-radius: 50%; background: var(--border) center/cover no-repeat;
  border: 2px solid #fff;
}
.story-tile .story-name {
  position: absolute; bottom: 8px; left: 8px; right: 8px; color: #fff; font-size: 12px;
  font-weight: 700; z-index: 2; text-shadow: 0 1px 3px rgba(0,0,0,.4);
}

.story-tile.add-story-tile {
  background: var(--primary-light); display: flex; flex-direction: column; align-items: center;
  justify-content: flex-end; padding-bottom: 14px;
}
.story-tile.add-story-tile::after { content: none; }
.story-tile.add-story-tile .story-avatar-overlay#my-story-avatar {
  width: 56px; height: 56px; border: 3px solid #fff; margin-bottom: 8px; box-shadow: 0 2px 8px rgba(20,30,60,.12);
}
.story-add-icon {
  position: absolute; top: 46px; left: 50%; transform: translateX(-50%);
  width: 26px; height: 26px; border-radius: 50%; background: var(--primary); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 16px; font-weight: 700;
  border: 3px solid #fff;
}
.story-tile.add-story-tile .story-name { position: static; color: var(--primary-dark); text-shadow: none; text-align: center; }

.story-viewer-overlay {
  display: none; position: fixed; inset: 0; background: rgba(10,12,20,.85); z-index: 200;
  align-items: center; justify-content: center;
}
.story-viewer-overlay.show { display: flex; }
.story-viewer-box {
  position: relative; width: min(420px, 92vw); height: min(760px, 88vh);
  background: #000; border-radius: 16px; overflow: hidden; display: flex; flex-direction: column;
}
.story-progress-row { display: flex; gap: 4px; padding: 10px 10px 0; }
.story-progress-bar { flex: 1; height: 3px; border-radius: 3px; background: rgba(255,255,255,.3); overflow: hidden; }
.story-progress-bar.filled { background: #fff; }
.story-viewer-header {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; position: relative; z-index: 2;
}
.story-viewer-header .contact-avatar { border: 2px solid rgba(255,255,255,.5); }
.story-viewer-name { color: #fff; font-weight: 700; font-size: 13.5px; }
.story-viewer-time { color: rgba(255,255,255,.7); font-size: 11.5px; }
.story-delete-btn, .story-close-btn {
  border: none; background: rgba(255,255,255,.15); color: #fff; border-radius: 8px; cursor: pointer;
  padding: 6px 10px; font-size: 12px; font-weight: 700; margin-left: 8px;
}
.story-close-btn { font-size: 18px; padding: 4px 10px; margin-left: auto; }
.story-media-wrap {
  flex: 1; display: flex; align-items: center; justify-content: center; background: #000; min-height: 0;
}
.story-media-wrap img, .story-media-wrap video { max-width: 100%; max-height: 100%; object-fit: contain; }
.story-nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.15); color: #fff; font-size: 20px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 3;
}
.story-nav-btn:hover { background: rgba(255,255,255,.3); }
.story-nav-prev { left: 10px; }
.story-nav-next { right: 10px; }

/* =========================================================
   Generic modal (create group, edit profile, ...)
   ========================================================= */
.modal-overlay {
  display: none; position: fixed; inset: 0; background: rgba(15,18,30,.45); z-index: 150;
  align-items: center; justify-content: center; padding: 20px;
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.modal-overlay.show { display: flex; }
.modal-box {
  border-radius: var(--radius-lg); width: 100%; max-width: 460px; max-height: 88vh;
  overflow: auto; box-shadow: 0 24px 60px rgba(10,15,30,.24);
  border: 1px solid var(--glass-border);
  /* glass surface */
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}
.modal-header {
  display: flex; align-items: center; justify-content: space-between; padding: 16px 20px;
  border-bottom: 1px solid var(--border); font-weight: 700; font-size: 16px;
}
.modal-close-btn { border: none; background: none; font-size: 20px; cursor: pointer; color: var(--muted); line-height: 1; }
.modal-close-btn:hover { color: var(--text); }
.modal-body { padding: 18px 20px 20px; }

/* =========================================================
   Threaded comment replies
   ========================================================= */
.comment-meta-row { display: flex; align-items: center; gap: 12px; margin: 3px 0 0 12px; }
.comment-time { font-size: 11px; color: var(--muted); }
.comment-reply-btn { border: none; background: none; color: var(--muted); font-weight: 700; font-size: 11.5px; cursor: pointer; padding: 0; }
.comment-reply-btn:hover { color: var(--primary); }
.replies-list { margin: 8px 0 0 24px; border-left: 2px solid var(--border); padding-left: 12px; }
.replies-list .comment-item { margin-bottom: 8px; }
.reply-form-slot:empty { display: none; }
.reply-form.comment-form { margin: 8px 0 0 12px; }

.edited-tag { color: var(--muted); font-size: 12px; font-weight: 500; }
.post-edit-box textarea { min-height: 70px; }
.post-image video { width: 100%; max-height: 480px; display: block; background: #000; }

/* =========================================================
   Profile page
   ========================================================= */
.profile-cover {
  position: relative; height: 300px; border-radius: 16px 16px 0 0;
  background: linear-gradient(120deg, var(--primary), #7aa4ff) center/cover no-repeat;
  overflow: hidden;
}
.cover-edit-btn {
  position: absolute; right: 16px; bottom: 16px; display: flex; align-items: center; gap: 7px;
  padding: 9px 14px; border-radius: 9px; border: none; cursor: pointer;
  background: rgba(20,25,35,.55); color: #fff; font-size: 13.5px; font-weight: 700;
  backdrop-filter: blur(3px); transition: background-color .15s ease;
}
.cover-edit-btn:hover { background: rgba(20,25,35,.75); }
.cover-edit-btn.uploading { opacity: .7; pointer-events: none; }

.profile-page-header {
  background: #fff; border: 1px solid var(--border); border-radius: 16px; overflow: hidden; margin-bottom: 20px;
}
.profile-page-body { display: flex; align-items: flex-end; gap: 18px; padding: 0 24px 20px; margin-top: -58px; flex-wrap: wrap; }
.profile-page-avatar-wrap { position: relative; flex-shrink: 0; }
.profile-page-avatar {
  width: 132px; height: 132px; border-radius: 50%; background: var(--border) center/cover no-repeat;
  border: 4px solid #fff; box-shadow: 0 4px 14px rgba(20,30,60,.14);
}
.profile-page-avatar-wrap .presence-dot { width: 17px; height: 17px; border-width: 3px; right: 8px; bottom: 8px; }
.avatar-camera-btn {
  position: absolute; right: 2px; bottom: 2px; width: 34px; height: 34px; border-radius: 50%;
  border: 3px solid #fff; background: var(--bg); color: var(--text); cursor: pointer;
  display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(20,30,60,.16);
  transition: background-color .15s ease, transform .1s ease;
}
.avatar-camera-btn:hover { background: var(--primary-light); }
.avatar-camera-btn:active { transform: scale(.92); }
.profile-page-info { padding-top: 62px; flex: 1; min-width: 200px; }
.profile-page-name { font-size: 24px; font-weight: 800; display: flex; align-items: center; gap: 10px; }
.profile-page-status { font-size: 13px; color: var(--muted); margin-top: 2px; }
.profile-page-bio { font-size: 14px; color: var(--text); margin-top: 8px; max-width: 520px; line-height: 1.5; }
.profile-page-stats { display: flex; gap: 20px; margin-top: 10px; font-size: 13.5px; }
.profile-page-stats strong { font-size: 15px; }
.profile-page-actions { display: flex; align-items: center; gap: 8px; padding-top: 62px; flex-shrink: 0; }
.profile-page-actions .btn { width: auto; padding: 9px 18px; }
.btn-icon { display: inline-flex; align-items: center; gap: 8px; }
.btn-icon-only { padding: 9px 11px !important; display: inline-flex; align-items: center; justify-content: center; }
.more-menu-wrap { position: relative; }
.more-dropdown { top: 46px; width: 220px; }

.profile-tabs { display: flex; gap: 4px; padding: 0 24px; border-top: 1px solid var(--border); }

.avatar-edit-picker { display: flex; align-items: center; gap: 14px; margin-bottom: 4px; }
.avatar-edit-preview {
  width: 64px; height: 64px; border-radius: 50%; background: var(--border) center/cover no-repeat;
  border: 2px solid var(--border); flex-shrink: 0;
}

.toast {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: rgba(20,20,25,.9); color: #fff; padding: 11px 18px; border-radius: 10px;
  font-size: 13.5px; font-weight: 600; z-index: 200; box-shadow: 0 10px 28px rgba(0,0,0,.22);
}

/* Facebook-style sidebar (Intro / Photos / Following) next to the feed */
.profile-content-grid {
  display: grid; grid-template-columns: 300px minmax(0, 1fr); gap: 20px; align-items: start;
}
.profile-side-col { display: flex; flex-direction: column; gap: 16px; position: sticky; top: 20px; }
.profile-card {
  background: #fff; border: 1px solid var(--border); border-radius: 14px; padding: 16px;
  box-shadow: 0 1px 2px rgba(20,30,60,.04), 0 6px 16px rgba(20,30,60,.06);
}
.profile-card-title { font-weight: 800; font-size: 17px; }
.profile-card-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 4px; }
.profile-card-count { color: var(--muted); font-size: 13px; }
.link-btn { border: none; background: none; font-size: 13px; font-weight: 700; color: var(--primary); cursor: pointer; padding: 0; }
.link-btn:hover { text-decoration: underline; }

.intro-bio { font-size: 14px; line-height: 1.5; margin: 10px 0; }
.intro-facts { display: flex; flex-direction: column; gap: 11px; margin: 12px 0; }
.intro-fact { display: flex; align-items: center; gap: 10px; font-size: 13.5px; color: var(--text); }
.intro-fact svg { color: var(--muted); flex-shrink: 0; }
.intro-categories { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.btn-block { width: 100%; }

.photos-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-top: 10px; }
.photo-thumb { aspect-ratio: 1 / 1; border-radius: 8px; background: var(--border) center/cover no-repeat; cursor: pointer; transition: opacity .15s ease; }
.photo-thumb:hover { opacity: .85; }

.friends-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.friend-tile { text-align: center; cursor: pointer; }
.friend-tile .friend-avatar { width: 100%; aspect-ratio: 1 / 1; border-radius: 10px; background: var(--border) center/cover no-repeat; margin-bottom: 5px; }
.friend-tile .friend-name { font-size: 11.5px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block; }
.empty-card-note { color: var(--muted); font-size: 13px; margin-top: 8px; }

.connections-tabs { padding: 0 20px; margin: 0 0 4px; }
.connections-list { padding-top: 4px; }
.connection-row {
  display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid var(--border);
  cursor: pointer; border-radius: 8px;
}
.connection-row:last-child { border-bottom: none; }
.connection-row:hover { background: var(--bg); }
.connection-avatar { width: 44px; height: 44px; border-radius: 50%; background: var(--border) center/cover no-repeat; flex-shrink: 0; }
.connection-name { font-weight: 700; font-size: 14px; }
.connection-status { font-size: 12px; color: var(--muted); margin-top: 1px; }

@media (max-width: 900px) {
  .profile-content-grid { grid-template-columns: 1fr; }
  .profile-side-col { position: static; }
}

@media (max-width: 640px) {
  .profile-cover { height: 180px; }
  .profile-page-avatar { width: 96px; height: 96px; }
  .profile-page-body { margin-top: -40px; }
  .profile-page-info { padding-top: 44px; }
  .profile-page-actions { padding-top: 44px; }
  .cover-edit-btn span { display: none; }
}

/* =========================================================
   Feed video (autoplay-on-scroll + mute toggle)
   ========================================================= */
.post-video-wrap { position: relative; }
.post-video-wrap video { width: 100%; max-height: 480px; display: block; background: #000; cursor: pointer; }
.video-mute-btn {
  position: absolute; bottom: 12px; right: 12px; width: 32px; height: 32px; border-radius: 50%;
  border: none; background: rgba(20,20,20,.55); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(2px);
}
.video-mute-btn:hover { background: rgba(20,20,20,.75); }

/* =========================================================
   Category chip pickers + small category badges
   ========================================================= */
.chip-picker { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-option {
  border: 1.5px solid var(--border); background: #fff; border-radius: 20px; padding: 7px 14px;
  font-size: 13px; font-weight: 600; cursor: pointer; color: var(--text);
}
.chip-option:hover { background: var(--bg); }
.chip-option.selected { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }

.group-cats { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mini-badge {
  background: var(--primary-light); color: var(--primary-dark); border-radius: 20px;
  padding: 3px 10px; font-size: 11.5px; font-weight: 700; white-space: nowrap;
}

.group-page-avatar {
  width: 108px; height: 108px; border-radius: 16px; background: var(--border) center/cover no-repeat;
  border: 4px solid #fff; box-shadow: 0 4px 14px rgba(20,30,60,.12);
}

/* =========================================================
   Multi-image gallery grid on a post card
   ========================================================= */
.post-images { margin-top: 12px; border-radius: 10px; overflow: hidden; display: grid; gap: 3px; }
.post-images.grid-1 { grid-template-columns: 1fr; }
.post-images.grid-1 .grid-img { aspect-ratio: 16 / 10; }
.post-images.grid-2 { grid-template-columns: 1fr 1fr; }
.post-images.grid-2 .grid-img { aspect-ratio: 1 / 1; }
.post-images.grid-3 { grid-template-columns: 1.4fr 1fr; }
.post-images.grid-3 .grid-col { display: grid; grid-template-rows: 1fr 1fr; gap: 3px; }
.post-images.grid-3 .grid-img.big { aspect-ratio: unset; height: 100%; }
.post-images.grid-3 .grid-col .grid-img { aspect-ratio: unset; height: 100%; }
.post-images.grid-4 { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
.post-images.grid-4 .grid-img { aspect-ratio: 1 / 1; }
.grid-img { background: var(--border) center/cover no-repeat; cursor: pointer; position: relative; }
.grid-img.more-overlay::after {
  content: ""; position: absolute; inset: 0; background: rgba(10,15,25,.55);
}
.grid-img.more-overlay span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  color: #fff; font-size: 26px; font-weight: 800; z-index: 1;
}

/* Post video: play-icon overlay + mute toggle (shared with the theater) */
.post-video-wrap .video-play-icon {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  pointer-events: none;
}
.post-video-wrap .video-play-icon svg {
  background: rgba(20,20,20,.55); border-radius: 50%; padding: 16px; color: #fff;
}
.post-video-wrap.is-playing .video-play-icon { display: none; }

.post-group-tag { font-weight: 500; color: var(--muted); font-size: 13px; }
.post-group-tag a { font-weight: 700; }
.post-feeling { font-weight: 500; color: var(--muted); font-size: 13.5px; }
.anon-self-badge {
  display: inline-flex; align-items: center; gap: 4px; background: rgba(224, 69, 90, 0.1); color: var(--danger);
  font-weight: 700; font-size: 11px; padding: 2px 8px; border-radius: 8px;
}
.pinned-badge {
  display: inline-flex; align-items: center; gap: 6px; color: var(--primary-dark); font-size: 12px;
  font-weight: 700; margin: 8px 0 -4px;
}
.link-like { cursor: pointer; }
.link-like:hover { text-decoration: underline; }
.mention-link { color: var(--primary); font-weight: 700; }

/* =========================================================
   Comment likes + delete
   ========================================================= */
.comment-like-btn {
  display: inline-flex; align-items: center; gap: 3px; border: none; background: none; cursor: pointer;
  color: var(--muted); font-weight: 700; font-size: 11.5px; padding: 0;
}
.comment-like-btn.liked { color: var(--danger); }
.comment-delete-btn { border: none; background: none; cursor: pointer; color: var(--muted); padding: 0; display: inline-flex; }
.comment-delete-btn:hover { color: var(--danger); }

/* =========================================================
   Full-screen post "theater" (photo/video + comments)
   ========================================================= */
.theater-overlay {
  display: none; position: fixed; inset: 0; background: rgba(8,10,18,.92); z-index: 300;
  align-items: center; justify-content: center; padding: 24px;
}
.theater-overlay.show { display: flex; }
.theater-close-btn {
  position: absolute; top: 18px; right: 20px; width: 40px; height: 40px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.12); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 2;
}
.theater-close-btn:hover { background: rgba(255,255,255,.22); }
.theater-box {
  display: flex; width: min(1200px, 100%); height: min(88vh, 820px); background: #fff; border-radius: 14px; overflow: hidden;
}
/* Text-only post: no black media pane to show, so the theater becomes a
   normal centered modal instead — see renderTheaterMedia(). */
.theater-box.no-media { width: min(640px, 100%); height: min(88vh, 720px); }
.theater-box.no-media .theater-media { display: none; }
.theater-box.no-media .theater-side { max-width: none; min-width: 0; flex: 1; }
.theater-media {
  flex: 1.4; background: #000; display: flex; align-items: center; justify-content: center; position: relative; min-width: 0;
}
.theater-media img { max-width: 100%; max-height: 100%; object-fit: contain; }
.theater-media .post-video-wrap { width: 100%; height: 100%; }
.theater-media .post-video-wrap video { width: 100%; height: 100%; max-height: none; object-fit: contain; }
.theater-nav-btn {
  position: absolute; top: 50%; transform: translateY(-50%); width: 42px; height: 42px; border-radius: 50%;
  border: none; background: rgba(255,255,255,.15); color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.theater-nav-btn:hover { background: rgba(255,255,255,.3); }
.theater-nav-prev { left: 14px; }
.theater-nav-next { right: 14px; }
.theater-image-count {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%); background: rgba(0,0,0,.5);
  color: #fff; font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 20px;
}
.theater-side { flex: 1; min-width: 340px; max-width: 420px; overflow-y: auto; padding: 4px; }
.theater-side .post-card { border: none; box-shadow: none; border-radius: 0; }
.theater-side .comments-section { display: block; }
/* ---------------- Group Details: Members / Join requests ---------------- */
.member-row {
  display: flex; align-items: center; gap: 12px; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: 10px; padding: 10px 14px; margin-bottom: 8px;
}
.member-row .avatar-lg { flex-shrink: 0; }
.member-row-info { flex: 1; min-width: 0; }
.member-row-name { font-weight: 700; font-size: 14px; }
.member-row-sub { font-size: 12px; color: var(--muted); }
.member-row-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.role-badge {
  font-size: 11px; font-weight: 700; padding: 3px 10px; border-radius: 999px;
  background: var(--bg); color: var(--muted); text-transform: uppercase; letter-spacing: .3px; flex-shrink: 0;
}
.role-badge.role-owner { background: #fdf1de; color: var(--gold); }
.role-badge.role-admin { background: var(--primary-light); color: var(--primary-dark); }
.role-badge.role-moderator { background: #e8f7ef; color: var(--success); }
.role-badge.role-member { background: var(--bg); color: var(--muted); }

.member-role-select {
  font-size: 12px; padding: 5px 8px; border-radius: 7px; border: 1px solid var(--border);
  background: var(--card-bg); color: var(--text); cursor: pointer;
}

/* ---------------- Groups Home Screen (Facebook-style: sidebar + grid) ---------------- */
.pull-refresh-indicator {
  position: fixed; top: 0; left: 0; right: 0; z-index: 500;
  text-align: center; font-size: 12px; font-weight: 700; color: var(--primary);
  background: var(--primary-light); padding: 8px; transform: translateY(-100%);
  transition: transform .2s ease; pointer-events: none;
}
.pull-refresh-indicator.show { transform: translateY(0); }

.groups-page-wrap { max-width: 1220px; margin: 0 auto; padding: 20px; }
.groups-page-layout { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 24px; align-items: start; }

.groups-sidebar { position: sticky; top: 20px; display: flex; flex-direction: column; gap: 4px; }
.groups-sidebar-title { margin: 0 0 14px; font-size: 24px; }

.groups-search-bar {
  display: flex; align-items: center; gap: 10px; background: var(--card-bg);
  border: 1px solid var(--border); border-radius: 999px; padding: 10px 16px; margin-bottom: 12px;
}
.groups-search-bar .icon { color: var(--muted); display: flex; }
.groups-search-bar input {
  border: none; outline: none; flex: 1; font-size: 14px; background: transparent; color: var(--text);
}

.groups-sidenav { display: flex; flex-direction: column; gap: 2px; margin-bottom: 16px; }
.groups-sidenav-item {
  display: flex; align-items: center; gap: 12px; padding: 9px 10px; border-radius: 8px;
  font-size: 14.5px; font-weight: 600; color: var(--text); text-decoration: none;
}
.groups-sidenav-item svg { color: var(--muted); flex-shrink: 0; }
.groups-sidenav-item:hover { background: var(--bg); text-decoration: none; }
.groups-sidenav-item.active { background: var(--primary-light); color: var(--primary-dark); }
.groups-sidenav-item.active svg { color: var(--primary-dark); }

.groups-sidebar > .btn { width: 100%; margin-bottom: 18px; }

.groups-sidebar-section { margin-bottom: 18px; }
.groups-sidebar-section-title { font-size: 13px; font-weight: 800; color: var(--muted); text-transform: uppercase; letter-spacing: .3px; margin-bottom: 8px; }
.groups-sidebar-section-title-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.groups-sidebar-section-title-row .groups-sidebar-section-title { margin-bottom: 0; }
.groups-sidebar-list { display: flex; flex-direction: column; gap: 2px; }
.groups-sidebar-row {
  display: flex; align-items: center; gap: 10px; padding: 6px 8px; border-radius: 8px; cursor: pointer;
}
.groups-sidebar-row:hover { background: var(--bg); }
.groups-sidebar-row-avatar { width: 36px; height: 36px; border-radius: 9px; background: var(--border) center/cover no-repeat; flex-shrink: 0; }
.groups-sidebar-row-name { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.groups-sidebar-row-sub { font-size: 11.5px; color: var(--muted); }
.groups-sidebar-empty { font-size: 12.5px; color: var(--muted); padding: 4px 8px; }

.groups-main { min-width: 0; }
.groups-main section { margin-bottom: 32px; scroll-margin-top: 20px; }
.groups-section-header-row { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.groups-section-header-row .section-title { margin: 0; }

.groups-home-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 16px;
}

.group-home-card {
  background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; transition: box-shadow .15s ease, transform .15s ease; position: relative;
}
.group-home-dismiss-btn {
  position: absolute; top: 8px; right: 8px; width: 26px; height: 26px; border-radius: 50%; border: none;
  background: rgba(20,25,35,.55); color: #fff; font-size: 16px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center; z-index: 5; backdrop-filter: blur(2px);
}
.group-home-dismiss-btn:hover { background: rgba(20,25,35,.8); }
.group-home-card:hover { box-shadow: 0 10px 26px rgba(30,30,60,.1); transform: translateY(-2px); }
.group-home-cover {
  height: 120px; background: linear-gradient(135deg, var(--primary-light), var(--border)) center/cover no-repeat;
  cursor: pointer;
}
.group-home-body { padding: 12px 14px 14px; }
.group-home-name { font-weight: 700; font-size: 15px; margin-bottom: 3px; cursor: pointer; }
.group-home-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 12px; }
.group-home-reason { color: var(--primary); font-weight: 600; }
.group-home-desc {
  font-size: 13px; color: var(--muted); margin-bottom: 10px; overflow: hidden;
  text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.group-home-actions { display: flex; gap: 8px; }
.group-home-actions .btn { width: auto; flex: 1; padding: 8px 12px; font-size: 13.5px; }
.group-home-actions .btn-icon-only { flex: 0 0 auto; }
.privacy-badge {
  font-size: 11px; font-weight: 700; padding: 3px 9px; border-radius: 999px;
  background: var(--bg); color: var(--muted); text-transform: uppercase; letter-spacing: .3px;
}
.privacy-badge.public { background: var(--primary-light); color: var(--primary-dark); }
.privacy-badge.private { background: #fdf1de; color: var(--gold); }

@media (max-width: 860px) {
  .groups-page-layout { grid-template-columns: 1fr; }
  .groups-sidebar { position: static; }
}

.privacy-picker { display: flex; flex-direction: column; gap: 10px; }
.privacy-option {
  display: flex; flex-direction: column; align-items: flex-start; gap: 3px; text-align: left;
  border: 1.5px solid var(--border); border-radius: 10px; padding: 10px 14px; background: var(--card-bg);
  cursor: pointer; width: 100%;
}
.privacy-option strong { font-size: 14px; }
.privacy-option span { font-size: 12px; color: var(--muted); }
.privacy-option.selected { border-color: var(--primary); background: var(--primary-light); }
.privacy-option.selected strong { color: var(--primary-dark); }

@media (max-width: 860px) {
  .theater-box { flex-direction: column; height: 92vh; }
  .theater-media { flex: 1; }
  .theater-side { max-width: none; flex: 0 0 auto; max-height: 45%; }
}
@media (max-width: 480px) {
  /* 24px of dead space on every side eats a lot of an already-tight phone
     screen once the media+side panel are stacked — give that room back. */
  .theater-overlay { padding: 0; }
  .theater-box { height: 100vh; border-radius: 0; }
  .theater-close-btn { top: 10px; right: 10px; width: 34px; height: 34px; }
}

/* ==================== Reels (Facebook-style paged viewer) ====================
   Left sidebar (For you / Following / Profile) + one reel at a time in a
   fixed-size player, with like/comment/save/share off to its side and
   up/down arrows to page between reels.

   The visible reel is rendered as `.post-card.reel-stage-card` — reusing
   that class is what lets attachFeedHandlers() from post-render.js drive
   like/save/comment/reply/delete here with no duplicated logic.
   `display: contents` on the card lets its two visual pieces (the player
   and the action rail) lay out as direct flex children of
   .reels-player-row — i.e. side by side on screen — while remaining one
   semantic element for data-post-id / querySelector purposes; the comments
   drawer is `position: fixed` so its place in the DOM doesn't matter either.
   Only this layout, the pager, watch-based view tracking, follow buttons,
   and the create-reel upload flow are Reels-specific — everything else is
   shared with the rest of the app. */
body.reels-body { display: flex; flex-direction: column; height: 100vh; overflow: hidden; background: #000; }

.reels-shell { flex: 1 1 auto; min-height: 0; display: flex; }

.reels-sidebar {
  width: 240px; flex-shrink: 0; padding: 24px 14px; display: flex; flex-direction: column;
  color: #fff; border-right: 1px solid rgba(255,255,255,.1); overflow-y: auto;
}
.reels-sidebar-title { font-size: 21px; font-weight: 800; margin: 0 0 18px 10px; }
.reels-sidebar-nav { display: flex; flex-direction: column; gap: 2px; }
.reels-sidebar-item {
  display: flex; align-items: center; gap: 12px; padding: 11px 12px; border-radius: 10px;
  border: none; background: none; color: rgba(255,255,255,.8); font-weight: 700; font-size: 14.5px;
  cursor: pointer; text-align: left;
}
.reels-sidebar-item svg { flex-shrink: 0; }
.reels-sidebar-item:hover { background: rgba(255,255,255,.08); color: #fff; }
.reels-sidebar-item.active { background: rgba(255,255,255,.15); color: #fff; }
.reels-sidebar-create { margin-top: 18px; }

.reels-stage { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; justify-content: center; gap: 16px; padding: 20px; overflow: hidden; }
.reels-stage-slot { display: flex; }
/* The card itself renders nothing — display:contents makes its children
   (.reels-player-row's contents, the comments drawer) lay out as if this
   wrapper weren't there, while .post-card/data-post-id still work normally
   for attachFeedHandlers()'s querySelector/closest() calls. */
.reel-stage-card { display: contents; }

.reels-loading-state { color: rgba(255,255,255,.75); font-size: 14px; text-align: center; padding: 0 24px; }

.reels-nav-btn {
  width: 42px; height: 42px; border-radius: 50%; border: none; cursor: pointer; flex-shrink: 0;
  background: rgba(255,255,255,.12); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: background-color .12s ease;
}
.reels-nav-btn:hover:not(:disabled) { background: rgba(255,255,255,.25); }
.reels-nav-btn:disabled { opacity: .3; cursor: default; }

/* The reel's two on-screen pieces sit side by side, bottom-aligned. */
.reels-player-row { display: flex; align-items: flex-end; gap: 14px; }

.reels-player-wrap {
  position: relative; width: 400px; max-width: 40vw; aspect-ratio: 9 / 16; max-height: calc(100vh - 150px);
  border-radius: 14px; overflow: hidden; background: #111; box-shadow: 0 12px 40px rgba(0,0,0,.5);
}
.reels-player-wrap .post-video-wrap { width: 100%; height: 100%; }
.reels-player-wrap .post-video-wrap video { width: 100%; height: 100%; max-height: none; object-fit: cover; background: #000; }
.reels-player-wrap .video-mute-btn { top: 14px; left: 14px; bottom: auto; right: auto; }
.reels-player-wrap .video-play-icon { width: 64px; height: 64px; }
.reel-no-media { height: 100%; display: flex; align-items: center; justify-content: center; color: rgba(255,255,255,.6); font-size: 14px; }

.reel-caption-overlay {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 44px 16px 16px;
  background: linear-gradient(to top, rgba(0,0,0,.75), rgba(0,0,0,0) 75%); pointer-events: none;
}
.reel-caption-overlay * { pointer-events: auto; }
.reel-author-row { display: flex; align-items: center; gap: 10px; }
.reel-author-row .post-avatar { width: 36px; height: 36px; border: 2px solid rgba(255,255,255,.85); cursor: pointer; }
.reel-author-name { color: #fff; font-weight: 700; font-size: 14px; cursor: pointer; }
.reel-follow-btn {
  margin-left: 4px; border: 1.5px solid #fff; background: transparent; color: #fff; font-weight: 700;
  font-size: 11.5px; padding: 4px 12px; border-radius: 20px; cursor: pointer;
}
.reel-follow-btn.following { background: rgba(255,255,255,.18); }
.reel-caption { color: #fff; font-size: 13px; line-height: 1.5; margin-top: 8px; word-break: break-word; }
.reel-caption .hashtag-link { color: #fff; font-weight: 700; text-decoration: underline; }

/* Action rail — outside the frame, bottom-aligned beside it. */
.reels-side-actions { display: flex; flex-direction: column; gap: 14px; align-self: flex-end; padding-bottom: 10px; }
.reel-action-item { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.reel-action-btn {
  width: 44px; height: 44px; border-radius: 50%; border: none; cursor: pointer;
  background: rgba(255,255,255,.1); color: #fff; display: flex; align-items: center; justify-content: center;
  transition: background-color .12s ease, transform .1s ease;
}
.reel-action-btn:hover { background: rgba(255,255,255,.2); }
.reel-action-btn:active { transform: scale(.9); }
.reel-action-btn.liked { color: var(--danger); }
.reel-action-btn.saved-active { color: var(--gold); }
/* Handlers reused from post-render.js write "<icon> <span>Label</span>" into
   the button after a click — the visible label lives in .reel-action-count
   instead, so that injected span is just hidden rather than fought. */
.reel-action-btn span { display: none; }
.reel-action-count {
  color: #fff; font-size: 11.5px; font-weight: 600; text-shadow: 0 1px 3px rgba(0,0,0,.6);
  max-width: 70px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Comments open as a right-hand drawer (desktop Facebook Reels pattern)
   rather than an inline expand — same .comments-section/.show toggle as the
   normal feed, just repositioned. */
.reel-comments-drawer.comments-section {
  position: fixed; top: 76px; right: 0; bottom: 0; width: 380px; max-width: 92vw; margin: 0;
  background: #fff; border-radius: 0; border-top: none; padding: 14px 18px 16px;
  display: flex; flex-direction: column; transform: translateX(100%);
  transition: transform .25s ease; z-index: 60; box-shadow: -8px 0 30px rgba(0,0,0,.25);
}
.reel-comments-drawer.comments-section.show { transform: translateX(0); }
.reel-comments-header {
  display: flex; align-items: center; justify-content: space-between; font-weight: 700; font-size: 15px;
  padding-bottom: 10px; border-bottom: 1px solid var(--border); margin-bottom: 10px; flex-shrink: 0;
}
.reel-comments-close { border: none; background: none; font-size: 22px; line-height: 1; color: var(--muted); cursor: pointer; }
.reel-comments-drawer .comment-list { flex: 1; overflow-y: auto; min-height: 0; }
.reel-comments-drawer .comment-form { flex-shrink: 0; }

@media (max-width: 900px) {
  .reels-shell { flex-direction: column; }
  .reels-sidebar {
    width: 100%; flex-direction: row; align-items: center; padding: 10px 14px; gap: 8px;
    border-right: none; border-bottom: 1px solid rgba(255,255,255,.1); overflow-x: auto; overflow-y: visible;
  }
  .reels-sidebar-title { display: none; }
  .reels-sidebar-nav { flex-direction: row; gap: 4px; flex-shrink: 0; }
  .reels-sidebar-item { white-space: nowrap; padding: 8px 10px; }
  .reels-sidebar-create { margin: 0 0 0 auto; flex-shrink: 0; width: auto; padding: 8px 14px; white-space: nowrap; }
}
@media (max-width: 640px) {
  .reels-stage { padding: 10px; gap: 8px; }
  .reels-player-wrap { width: 100%; max-width: none; max-height: calc(100vh - 120px); }
  .reels-nav-btn { width: 36px; height: 36px; }
  .reels-side-actions { gap: 10px; }
  .reel-action-btn { width: 38px; height: 38px; }
  .reel-comments-drawer.comments-section { width: 100%; max-width: 100%; }
}

/* =========================================================
   Email verification banner (see public/js/topbar.js)
   ========================================================= */
.email-verify-banner {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 10px 20px; font-size: 13.5px; color: #7a5300;
  background: linear-gradient(90deg, rgba(255, 208, 92, .35), rgba(255, 190, 60, .28));
  border-bottom: 1px solid rgba(201, 154, 63, .35);
  position: relative; z-index: 90;
}
.email-verify-icon { display: flex; color: #a9781a; flex-shrink: 0; }
.email-verify-text { flex: 1 1 auto; min-width: 200px; }
.email-verify-resend-btn {
  border: 1px solid rgba(169, 120, 26, .4); background: rgba(255,255,255,.55); color: #7a5300;
  font-weight: 700; font-size: 12.5px; padding: 6px 14px; border-radius: 20px; cursor: pointer;
  flex-shrink: 0; transition: background-color .15s ease;
}
.email-verify-resend-btn:hover:not(:disabled) { background: #fff; }
.email-verify-resend-btn:disabled { opacity: .7; cursor: default; }

/* =========================================================
   Toast (small transient confirmation, e.g. "email verified")
   ========================================================= */
.app-toast {
  position: fixed; bottom: 24px; left: 50%; transform: translate(-50%, 12px);
  background: rgba(28, 34, 51, .92); color: #fff; padding: 12px 20px; border-radius: 12px;
  font-size: 13.5px; font-weight: 600; box-shadow: 0 12px 30px rgba(10,15,30,.28);
  z-index: 300; opacity: 0; transition: opacity .25s ease, transform .25s ease;
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  max-width: min(90vw, 420px); text-align: center;
}
.app-toast.show { opacity: 1; transform: translate(-50%, 0); }

/* =========================================================
   Upload progress overlay (see showUploadOverlay in auth-guard.js)
   ========================================================= */
.upload-progress-overlay {
  position: fixed; inset: 0; z-index: 400; display: flex; align-items: center; justify-content: center;
  background: rgba(15,18,30,.42); opacity: 0; transition: opacity .2s ease;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}
.upload-progress-overlay.show { opacity: 1; }
.upload-progress-box {
  width: 260px; padding: 26px 24px; border-radius: var(--radius-lg); text-align: center;
  background: var(--glass-bg-strong);
  -webkit-backdrop-filter: var(--glass-blur); backdrop-filter: var(--glass-blur);
  border: 1px solid var(--glass-border); box-shadow: 0 24px 60px rgba(10,15,30,.28);
}
.upload-progress-spinner {
  width: 34px; height: 34px; margin: 0 auto 14px; border-radius: 50%;
  border: 3px solid var(--primary-light); border-top-color: var(--primary);
  animation: upload-spin 0.8s linear infinite;
}
@keyframes upload-spin { to { transform: rotate(360deg); } }
.upload-progress-label { font-size: 13.5px; font-weight: 700; color: var(--text); margin-bottom: 14px; }
.upload-progress-track { height: 8px; border-radius: 6px; background: var(--border); overflow: hidden; }
.upload-progress-fill { height: 100%; background: linear-gradient(90deg, var(--primary), #7aa4ff); border-radius: 6px; transition: width .15s ease; }
.upload-progress-pct { margin-top: 8px; font-size: 12px; font-weight: 700; color: var(--muted); }

/* =========================================================
   Group page: header menu, member strip, share sheet, related
   groups carousel, poll composer/card, Events tab
   ========================================================= */
.group-member-strip { display: flex; align-items: center; margin-top: 10px; }
.group-member-strip-avatar {
  width: 30px; height: 30px; border-radius: 50%; background: var(--border) center/cover no-repeat;
  border: 2px solid var(--card-bg); margin-left: -10px;
}
.group-member-strip-avatar:first-child { margin-left: 0; }

/* "Joined ▾" dropdown wrapper — needs its own positioned ancestor for the
   dropdown-panel it contains, same idiom as .post-menu-wrap. */
.dropdown-wrap { position: relative; }
#joined-dropdown, #group-more-dropdown { width: 220px; top: 44px; }

.group-your-content-banner {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  background: var(--primary-light); color: var(--primary-dark); font-size: 13.5px; font-weight: 600;
  padding: 10px 14px; border-radius: 10px; margin-bottom: 14px;
}

.share-sheet-box { max-width: 360px; }

/* ---- Related groups carousel ---- */
.group-related-section { margin-bottom: 20px; }
.group-related-carousel {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 4px; scroll-snap-type: x proximity;
}
.group-related-card {
  flex: 0 0 180px; scroll-snap-align: start; background: var(--card-bg); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden; cursor: pointer;
}
.group-related-cover { height: 84px; background: linear-gradient(135deg, var(--primary-light), var(--border)) center/cover no-repeat; }
.group-related-body { padding: 10px 12px 12px; }
.group-related-name {
  font-weight: 700; font-size: 13.5px; margin-bottom: 2px; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap;
}
.group-related-sub { font-size: 11.5px; color: var(--muted); margin-bottom: 8px; }
.group-related-body .btn { width: 100%; padding: 6px 10px; font-size: 12.5px; }

/* ---- Poll composer (group "What's on your mind?" modal) ---- */
.poll-builder {
  position: relative; border: 1px solid var(--border); border-radius: 12px; padding: 14px 34px 10px 14px; margin: 10px 0;
}
.poll-builder-question {
  width: 100%; border: none; border-bottom: 1.5px solid var(--border); padding: 6px 2px 10px; font-size: 14.5px;
  font-weight: 700; background: none; margin-bottom: 8px;
}
.poll-builder-question:focus { outline: none; border-bottom-color: var(--primary); }
.poll-builder-option-row { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.poll-builder-option-input {
  flex: 1; border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; font-size: 13.5px; background: var(--bg);
}
.poll-builder-option-input:focus { outline: none; border-color: var(--primary); }
.poll-builder-option-remove {
  border: none; background: none; color: var(--muted); font-size: 18px; cursor: pointer; flex-shrink: 0; line-height: 1;
}
.poll-builder-option-remove:hover { color: var(--danger); }
.poll-builder-remove-btn {
  position: absolute; top: 10px; right: 10px; border: none; background: var(--bg); color: var(--muted);
  width: 24px; height: 24px; border-radius: 50%; cursor: pointer; font-size: 15px; line-height: 1;
}
.poll-builder-remove-btn:hover { background: var(--border); color: var(--text); }

/* ---- Poll card (rendered inside a post) ---- */
.post-poll { margin: 12px 0; border: 1px solid var(--border); border-radius: 12px; padding: 14px; }
.poll-question { font-weight: 700; font-size: 15px; margin-bottom: 10px; }
.poll-options { display: flex; flex-direction: column; gap: 8px; }
.poll-option {
  position: relative; display: flex; align-items: center; justify-content: space-between; gap: 8px;
  border: 1.5px solid var(--border); border-radius: 8px; padding: 10px 12px; background: var(--bg);
  cursor: pointer; font-size: 13.5px; font-weight: 600; overflow: hidden; text-align: left; width: 100%;
}
.poll-option:hover { border-color: var(--primary); }
.poll-option.voted { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }
.poll-option-fill {
  position: absolute; left: 0; top: 0; bottom: 0; background: var(--primary-light); z-index: 0;
  transition: width .25s ease;
}
.poll-option.voted .poll-option-fill { background: rgba(255,255,255,.35); }
.poll-option-text, .poll-option-pct { position: relative; z-index: 1; }
.poll-option-pct { color: var(--muted); flex-shrink: 0; }
.poll-option.voted .poll-option-pct { color: var(--primary-dark); }
.poll-meta { font-size: 12px; color: var(--muted); margin-top: 10px; }

/* ---- Events tab ---- */
.event-when-toggle { display: flex; gap: 8px; margin: 14px 0; }
.event-when-btn {
  border: 1.5px solid var(--border); background: var(--card-bg); color: var(--muted); font-weight: 700;
  font-size: 13px; padding: 7px 16px; border-radius: 999px; cursor: pointer;
}
.event-when-btn.active { border-color: var(--primary); background: var(--primary-light); color: var(--primary-dark); }

.group-events-list { display: flex; flex-direction: column; gap: 12px; }
.event-card {
  display: flex; gap: 14px; background: var(--card-bg); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; align-items: center;
}
.event-card-date {
  flex-shrink: 0; width: 64px; height: 64px; border-radius: 10px; background: var(--primary-light) center/cover no-repeat;
  display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--primary-dark);
}
.event-card-date-day { font-size: 20px; font-weight: 800; line-height: 1; }
.event-card-date-month { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; }
.event-card-body { min-width: 0; flex: 1; }
.event-card-time { font-size: 12px; color: var(--primary); font-weight: 700; margin-bottom: 2px; }
.event-card-title { font-weight: 800; font-size: 15px; margin-bottom: 3px; }
.event-card-sub { font-size: 12.5px; color: var(--muted); margin-bottom: 10px; }
.event-card-actions { display: flex; gap: 8px; }
.event-card-actions .btn { width: auto; }

@media (max-width: 640px) {
  .event-card { flex-direction: column; align-items: flex-start; }
  .group-related-card { flex-basis: 150px; }
}

/* =========================================================
   Chat / Messages (public/messages.html + public/js/messages.js)
   Backend: controllers/chatController.js, models/Conversation.js,
   models/Message.js. Two-pane layout: conversation list + active
   thread, sized to fill the viewport below the sticky topbar
   (61px ≈ its 10px vertical padding + 40px icon-btn height + 1px
   border — same figure the reels player uses for its own
   calc(100vh - …) sizing above).
   ========================================================= */
.chat-app {
  display: flex;
  height: calc(100vh - 61px);
  max-width: 1220px;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
  background: var(--card-bg);
  overflow: hidden;
}

.chat-list-col {
  width: 340px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.chat-list-header { padding: 18px 20px 12px; font-weight: 800; font-size: 20px; }
.chat-list { flex: 1; overflow-y: auto; padding: 4px 8px 12px; }
.chat-empty-list { padding: 30px 20px; text-align: center; color: var(--muted); font-size: 13.5px; line-height: 1.5; }

.chat-list-item {
  display: flex; align-items: center; gap: 12px; padding: 10px; border-radius: 12px;
  cursor: pointer; transition: background-color .15s ease;
}
.chat-list-item:hover { background: var(--bg); }
.chat-list-item.active { background: var(--primary-light); }
.chat-list-item .contact-avatar { width: 48px; height: 48px; }
.chat-list-item-body { flex: 1; min-width: 0; }
.chat-list-item-top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-list-item-name { font-size: 14px; font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-list-item-time { font-size: 11px; color: var(--muted); flex-shrink: 0; }
.chat-list-item-preview {
  font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; margin-top: 2px;
}
.chat-list-item.unread .chat-list-item-name { color: var(--text); }
.chat-list-item.unread .chat-list-item-preview { color: var(--text); font-weight: 600; }
.chat-list-badge {
  position: static; flex-shrink: 0; background: var(--primary); min-width: 18px; height: 18px; font-size: 10.5px;
}

.chat-main-col { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.chat-empty-state {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 14px; color: var(--muted); font-size: 14px;
}
.chat-empty-icon {
  width: 84px; height: 84px; border-radius: 50%; background: var(--bg);
  display: flex; align-items: center; justify-content: center; color: var(--muted);
}

.chat-thread { flex: 1; min-height: 0; flex-direction: column; }

.chat-thread-header {
  display: flex; align-items: center; gap: 12px; padding: 12px 18px;
  border-bottom: 1px solid var(--border); flex-shrink: 0;
}
.chat-back-btn {
  display: none; width: 34px; height: 34px; border-radius: 50%; border: none; background: none;
  color: var(--text); cursor: pointer; align-items: center; justify-content: center; flex-shrink: 0;
}
.chat-back-btn:hover { background: var(--bg); }
.chat-header-identity { flex: 1; min-width: 0; }
.chat-header-name { font-weight: 700; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header-status { font-size: 12px; color: var(--muted); margin-top: 1px; }
.chat-header-actions { flex-shrink: 0; }
.chat-header-actions .dropdown-panel { top: 44px; width: 260px; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 18px; display: flex; flex-direction: column; gap: 2px;
  background: var(--bg);
}
.chat-load-older-btn {
  align-self: center; margin-bottom: 10px; border: 1px solid var(--border); background: #fff;
  color: var(--primary); font-size: 12.5px; font-weight: 600; padding: 7px 14px; border-radius: 20px;
  cursor: pointer;
}
.chat-load-older-btn:hover { background: var(--primary-light); }

/* ---- Message bubbles ---- */
.msg-row { display: flex; align-items: flex-end; gap: 8px; max-width: 72%; margin: 4px 0; position: relative; }
.msg-row.own { align-self: flex-end; flex-direction: row-reverse; margin-left: auto; }
.msg-bubble {
  background: #fff; border: 1px solid var(--border); border-radius: 16px 16px 16px 4px;
  padding: 9px 13px; font-size: 14px; line-height: 1.45; color: var(--text);
  box-shadow: 0 1px 2px rgba(20,30,60,.04); word-break: break-word;
}
.msg-row.own .msg-bubble {
  background: var(--chat-bubble-own, var(--primary)); color: #fff; border: none;
  border-radius: 16px 16px 4px 16px;
}
.msg-bubble.deleted { font-style: italic; color: var(--muted); background: var(--bg); box-shadow: none; }
.msg-row.own .msg-bubble.deleted { background: var(--bg); color: var(--muted); }
.msg-text { white-space: pre-wrap; }
.msg-meta { display: flex; align-items: center; justify-content: flex-end; gap: 5px; margin-top: 4px; font-size: 10.5px; opacity: .75; }
.msg-edited { font-style: italic; }
.msg-time { white-space: nowrap; }
.msg-tick { display: inline-flex; color: inherit; }
.msg-tick.seen { color: #6fd3ff; }
.msg-row:not(.own) .msg-tick { display: none; }

.msg-menu-btn {
  border: none; background: none; color: var(--muted); cursor: pointer; font-size: 16px;
  width: 24px; height: 24px; border-radius: 50%; flex-shrink: 0; opacity: 0;
  display: flex; align-items: center; justify-content: center; transition: opacity .1s ease, background-color .1s ease;
}
.msg-row:hover .msg-menu-btn { opacity: 1; }
.msg-menu-btn:hover { background: var(--border); }
.msg-menu-dropdown {
  display: none; position: absolute; top: 0; z-index: 30; width: 170px;
  background: #fff; border: 1px solid var(--border); border-radius: 10px;
  box-shadow: 0 10px 28px rgba(20,20,20,.16); padding: 6px; overflow: hidden;
}
.msg-row.own .msg-menu-dropdown { right: 0; }
.msg-row:not(.own) .msg-menu-dropdown { left: 32px; }
.msg-menu-dropdown.show { display: block; }
.msg-menu-dropdown .menu-btn { font-size: 13px; padding: 8px 10px; }

.msg-edit-box { display: flex; flex-direction: column; gap: 6px; min-width: 200px; }
.msg-edit-textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 7px 9px;
  font-size: 13.5px; font-family: inherit; resize: vertical; min-height: 44px; color: var(--text);
}
.msg-edit-actions { display: flex; justify-content: flex-end; gap: 12px; }
.msg-edit-actions .link-btn { color: inherit; opacity: .85; }

.msg-attachments { display: flex; flex-direction: column; gap: 6px; margin-bottom: 6px; }
.msg-attachment-image img {
  display: block; max-width: 260px; max-height: 320px; border-radius: 12px; object-fit: cover;
}
.msg-attachment-file {
  display: flex; align-items: center; gap: 9px; background: rgba(255,255,255,.16);
  border-radius: 10px; padding: 8px 10px; color: inherit; text-decoration: none;
}
.msg-row:not(.own) .msg-attachment-file { background: var(--bg); }
.msg-attachment-file-name {
  font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; max-width: 160px;
}
.msg-attachment-file-size { font-size: 11px; opacity: .75; flex-shrink: 0; }

/* ---- Composer ---- */
.chat-composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid var(--border);
  flex-shrink: 0; background: var(--card-bg);
}
.chat-attach-preview {
  display: none; flex-wrap: wrap; gap: 6px; width: 100%; order: -1; margin-bottom: 8px;
}
.attach-chip {
  display: flex; align-items: center; gap: 6px; background: var(--bg); border: 1px solid var(--border);
  border-radius: 16px; padding: 5px 6px 5px 12px; font-size: 12px; max-width: 200px;
}
.attach-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip button {
  border: none; background: var(--border); color: var(--text); width: 18px; height: 18px; border-radius: 50%;
  cursor: pointer; font-size: 13px; line-height: 1; flex-shrink: 0;
}
.chat-attach-btn, .chat-send-btn {
  width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; transition: background-color .15s ease, transform .1s ease;
}
.chat-attach-btn { background: var(--bg); color: var(--muted); }
.chat-attach-btn:hover { background: var(--border); color: var(--text); }
.chat-send-btn { background: var(--chat-bubble-own, var(--primary)); color: #fff; }
.chat-send-btn:hover { filter: brightness(1.08); }
.chat-send-btn:active { transform: scale(.92); }
.chat-send-btn:disabled { opacity: .6; cursor: not-allowed; }
.chat-text-input {
  flex: 1; resize: none; border: 1px solid var(--border); border-radius: 20px; padding: 9px 16px;
  font-size: 14px; font-family: inherit; max-height: 120px; line-height: 1.4; color: var(--text);
}
.chat-text-input:focus { outline: none; border-color: var(--primary); }

/* ---- Preset color themes ----
   Each sets --chat-bubble-own, picked up by .msg-row.own .msg-bubble and
   .chat-send-btn above. Swatch hex values here must match
   utils/chatThemes.js's CHAT_THEMES on the backend. */
.chat-theme-default { --chat-bubble-own: #4a63e7; }
.chat-theme-ocean { --chat-bubble-own: #0ea5c8; }
.chat-theme-sunset { --chat-bubble-own: #f2703c; }
.chat-theme-forest { --chat-bubble-own: #2f9e5a; }
.chat-theme-midnight { --chat-bubble-own: #5b4fd6; }
.chat-theme-rose { --chat-bubble-own: #e0548a; }

.chat-theme-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.chat-theme-swatch-btn {
  width: 100%; aspect-ratio: 1 / 1; border-radius: 50%; border: 3px solid transparent; cursor: pointer;
  transition: transform .1s ease, border-color .15s ease;
}
.chat-theme-swatch-btn:hover { transform: scale(1.06); }
.chat-theme-swatch-btn.selected { border-color: var(--text); box-shadow: 0 0 0 2px #fff inset; }

/* ---- Mobile: collapse to a single pane, list shown by default ---- */
@media (max-width: 780px) {
  .chat-app { border-left: none; border-right: none; }
  .chat-list-col { width: 100%; border-right: none; }
  .chat-main-col { display: none; }
  .chat-app.chat-open-mobile .chat-list-col { display: none; }
  .chat-app.chat-open-mobile .chat-main-col { display: flex; }
  .chat-back-btn { display: flex; }
  .msg-row { max-width: 86%; }
}
