/* Trang chủ: layout 3 cột ở lg, 1 cột mobile-first; menu điều hướng. */
.shell {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px 84px; /* chừa chỗ cho bottom-nav mobile */
}

.rail {
  display: none;
}

/* Composer & bài viết được tạo kiểu trong feed.css (.composer-*, .post-card).
   Các rule .composer/.post cũ đã gỡ vì gây xung đột display:flex với layout mới. */

.post .meta {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 6px;
}

.navlink {
  display: block;
  padding: 8px 10px;
  border-radius: var(--r-md);
  color: var(--text);
  font-weight: 500;
  text-decoration: none;
}

.navlink:hover {
  background: var(--surface-2);
}

.navlink .fa-icon {
  margin-right: .5em;
}

/* Khối thông tin user + ảnh đại diện ở sidebar. */
.me {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 6px 0 10px;
}

.avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--r-pill);
  object-fit: cover;
  flex: none;
}

.avatar-fallback {
  display: grid;
  place-items: center;
  background: var(--surface-2);
  color: var(--muted);
  font-size: 22px;
}

/* Bottom nav mobile (ẩn ở desktop). Icon-only, FAB "+" xanh ở giữa. */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-around;
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
}

.bottom-nav .bn-form {
  display: flex;
}

.bn-item {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  color: var(--muted);
  text-decoration: none;
  background: none;
  border: 0;
  cursor: pointer;
}

.bn-item:hover {
  color: var(--accent);
}

.bn-item.bn-active {
  color: var(--accent);
}

.bn-item .fa-icon {
  width: 24px;
  height: 24px;
}

/* FAB đăng bài: vòng tròn xanh nổi ở giữa. */
.bn-fab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  flex: none;
  border-radius: var(--r-pill);
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
  box-shadow: 0 2px 8px rgba(31, 111, 235, .35);
}

.bn-fab:hover {
  background: var(--accent-press);
}

.bn-fab .fa-icon {
  width: 22px;
  height: 22px;
}

@media (min-width: 1024px) {
  .shell {
    grid-template-columns: 240px minmax(0, 600px) 320px;
    max-width: 1200px;
    padding: 16px;
  }

  /* Sidebar trái/phải DÍNH khi cuộn (sticky). align-self:start để grid item không
     bị kéo cao full → sticky mới có tác dụng. Tự cuộn nếu nội dung dài hơn màn. */
  .rail {
    display: block;
    position: sticky;
    top: 16px;
    align-self: start;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
  }

  .bottom-nav {
    display: none;
  }
}

/* Input link trong composer */
.composer-link {
  width: 100%; margin-top: 8px; padding: 8px 10px; min-height: 40px;
  border: 1px solid var(--border); border-radius: var(--r-md);
  background: var(--surface-2); color: var(--text); font: inherit;
}
.composer-link:focus { outline: none; border-color: var(--accent); }

/* Nút đổi chủ đề sáng/tối (kiểu navlink). Icon đổi theo chủ đề HIỆU LỰC:
   sáng → moon (bấm sang tối); tối → sun (bấm sang sáng). */
.theme-toggle {
  width: 100%;
  background: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  text-align: left;
  color: var(--text);
}
.theme-sun { display: none; }
.theme-moon { display: inline; }
[data-theme=dark] .theme-moon { display: none; }
[data-theme=dark] .theme-sun { display: inline; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) .theme-moon { display: none; }
  :root:not([data-theme]) .theme-sun { display: inline; }
}

/* ---- Drawer menu mobile (off-canvas, trượt từ trái) — đủ mục như sidebar desktop ---- */
.bn-menu { background: none; border: 0; cursor: pointer; }
.drawer-scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 60; }
.mobile-drawer {
  position: fixed; top: 0; left: 0; bottom: 0; width: min(84%, 330px); z-index: 61;
  background: var(--bg); overflow-y: auto; padding: 12px;
  box-shadow: 2px 0 24px rgba(0,0,0,.3); animation: drawer-in .22s cubic-bezier(.16,1,.3,1);
}
@keyframes drawer-in { from { transform: translateX(-100%); } to { transform: translateX(0); } }
/* Card trong drawer: bỏ viền/nền riêng để phủ liền nền drawer. */
.mobile-drawer .card { border: 0; box-shadow: none; background: transparent; padding: 4px; }
/* Desktop: luôn ẩn (đã có rail-left). */
@media (min-width: 1024px) { .mobile-drawer, .drawer-scrim { display: none !important; } }

/* ---- Thanh trên cùng mobile (Facebook-style): ☰ + logo TRÁI, chuông PHẢI ---- */
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); }
.brand img { border-radius: 7px; flex: none; }
.mobile-top { display: none; }
.mtop-brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 800; font-size: 1.12em; }
.mtop-brand img { border-radius: 7px; flex: none; }
.mtop-menu, .mtop-act { position: relative; width: 40px; height: 40px; display: grid; place-items: center; border: 0; background: none; color: var(--text); cursor: pointer; border-radius: 50%; text-decoration: none; flex: none; }
.mtop-menu:hover, .mtop-act:hover { background: var(--surface-2); }
.mtop-menu .fa-icon, .mtop-act .fa-icon { width: 1.3em; height: 1.3em; }
.mtop-menu .bn-dot, .mtop-act .bn-dot { position: absolute; top: 7px; right: 7px; }
@media (max-width: 1023px) {
  .mobile-top { display: flex; align-items: center; gap: 4px; position: fixed; top: 0; left: 0; right: 0; height: 54px; padding: 0 8px; z-index: 30; background: color-mix(in srgb, var(--bg) 90%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
  .mtop-brand { margin-right: auto; }
  body:has(.mobile-top) .shell { padding-top: 62px; }
  body:has(.mobile-top) .feed-tabs, body:has(.mobile-top) .detail-bar { top: 54px; }
}
