/* 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;
  padding: 6px 8px;
  color: inherit;
  text-decoration: none;
  border-radius: var(--r-md);
  transition: background-color .15s ease;
}

.me:hover,
.me:focus-visible {
  background: var(--surface-2);
}

.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;
}

/* Avatar nhỏ (composer thu gọn) — 38px khớp export. */
.avatar.sm {
  width: 38px;
  height: 38px;
}
.avatar-fallback.sm {
  font-size: 17px;
}

/* 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; }
  /* Trong MODAL (#post-modal là dialog top-layer, mobile-top bị che dưới nó) →
     thanh "← Bài viết" dính ĐỈNH modal (top:0), không lùi 54px như bản full-page
     (nếu lùi sẽ hở 54px khiến nội dung lọt lên trên thanh). */
  body:has(.mobile-top) .modal-body .detail-bar { top: 0; }
}

/* ===========================================================================
   TRANG CHỦ chrome MỚI — header có ô tìm kiếm + layout 3 cột (home-grid).
   Tách hẳn .shell cũ (các trang phụ vẫn dùng .shell). Token ngữ nghĩa từ
   tokens.css; khớp 1:1 bản export site/home.html.
   ========================================================================= */

/* ---- Ô tìm kiếm trong header (thay nav ngang ở trang chủ) ---- */
.ahh-in { gap: 16px; }
.ahh-search {
  flex: 1; max-width: 640px; margin: 0 auto; position: relative;
  display: flex; align-items: center; min-width: 0;
}
.ahh-search-ic {
  position: absolute; left: 12px; display: grid; place-items: center;
  color: var(--faint); pointer-events: none;
}
.ahh-search-ic .fa-icon { width: 16px; height: 16px; }
.ahh-search-input {
  width: 100%; height: 40px; padding: 0 14px 0 34px;
  border-radius: var(--r-pill); border: 1px solid var(--border);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px;
}
.ahh-search-input::placeholder { color: var(--faint); }
.ahh-search-input:focus-visible { outline: none; border-color: var(--accent); }

/* ---- Lưới 3 cột ---- */
.home-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  max-width: 600px;
  margin: 0 auto;
  padding: 16px 16px calc(72px + env(safe-area-inset-bottom));
}
.home-left, .home-right { display: none; }
.home-feed { min-width: 0; }
/* Tabs feed dính DƯỚI header sticky (không lùi 0 kẻo lọt dưới header). */
.home-feed .feed-tabs { top: var(--chrome-header-h); }

@media (min-width: 1024px) {
  .home-grid {
    grid-template-columns: 228px minmax(0, 1fr);
    gap: 28px;
    max-width: 920px;
    padding: 24px 16px 48px;
  }
  .home-left {
    display: block;
    position: sticky;
    top: calc(var(--chrome-header-h) + 16px);
    align-self: start;
    max-height: calc(100vh - var(--chrome-header-h) - 32px);
    overflow-y: auto;
  }
}
@media (min-width: 1280px) {
  .home-grid {
    grid-template-columns: 228px minmax(0, 600px) 312px;
    max-width: 1200px;
  }
  .home-right {
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: calc(var(--chrome-header-h) + 16px);
    align-self: start;
    max-height: calc(100vh - var(--chrome-header-h) - 32px);
    overflow-y: auto;
  }
}

/* ---- Rail trái: nav dọc + chủ đề ---- */
.hl-nav { display: flex; flex-direction: column; gap: 2px; }
.hl-link {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; border-radius: var(--r-md);
  font-size: 14.5px; font-weight: 500; color: var(--text); text-decoration: none;
}
.hl-link:hover { background: var(--surface-2); }
.hl-link.active { color: var(--accent); background: var(--accent-soft); font-weight: 600; }
.hl-link .hl-ic { width: 19px; height: 19px; flex: none; }
.hl-soon { color: var(--faint); cursor: default; }
.hl-soon:hover { background: none; color: var(--faint); }
.hl-section {
  margin: 22px 12px 8px; font-size: 11px; font-weight: 600;
  letter-spacing: .08em; text-transform: uppercase; color: var(--faint);
}
.hl-topics { display: flex; flex-direction: column; gap: 2px; }
.hl-topic {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px; border-radius: var(--r-md);
  font-size: 14px; color: var(--muted); text-decoration: none;
}
.hl-topic:hover { background: var(--surface-2); color: var(--text); }
.hl-topic-hash { color: var(--faint); }

/* ---- Rail phải: widget ---- */
.hr-card {
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface); padding: 18px;
}
.hr-card-head { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.hr-card-ic { display: grid; place-items: center; flex: none; }
.hr-card-ic .fa-icon { width: 17px; height: 17px; }
.hr-ic-warn { color: var(--warning); }
.hr-card-title { margin: 0; font-size: 14px; font-weight: 600; color: var(--text); }
.hr-section {
  margin: 0 0 12px; font-size: 12px; font-weight: 600;
  letter-spacing: .04em; text-transform: uppercase; color: var(--faint);
}

/* Câu hỏi đang nóng */
.hr-hotlist { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.hr-hot { display: flex; gap: 12px; }
.hr-hot-rank { flex: none; width: 18px; font-size: 13px; font-weight: 600; color: var(--faint); }
.hr-hot-link { min-width: 0; display: block; text-decoration: none; color: var(--text); }
.hr-hot-q { display: block; font-size: 13.5px; font-weight: 500; line-height: 1.4; }
.hr-hot-link:hover .hr-hot-q { color: var(--accent); }
.hr-hot-meta { display: block; font-size: 12px; color: var(--muted); margin-top: 2px; }

/* Xe của bạn */
.hr-vehicle { padding: 16px 18px 0; overflow: hidden; }
.hr-veh-body { padding-bottom: 16px; }
.hr-veh-name { font-size: 15px; font-weight: 600; color: var(--text); }
.hr-veh-soh { display: flex; align-items: center; gap: 8px; margin-top: 8px; }
.hr-soh-bar { flex: 1; height: 6px; min-width: 70px; border-radius: var(--r-pill); background: var(--surface-3); overflow: hidden; }
.hr-soh-fill { display: block; height: 100%; background: var(--accent); border-radius: var(--r-pill); }
.hr-soh-val { flex: none; font-size: 12px; color: var(--muted); }
.hr-veh-empty { margin: 0 0 14px; color: var(--muted); font-size: 13.5px; }
.hr-veh-actions { display: flex; margin: 0 -18px; border-top: 1px solid var(--border); }
.hr-veh-btn {
  flex: 1; text-align: center; padding: 11px 8px;
  font-size: 13px; font-weight: 500; color: var(--text); text-decoration: none;
}
.hr-veh-btn:hover { background: var(--surface-2); }
.hr-veh-btn + .hr-veh-btn { border-left: 1px solid var(--border); }
.hr-veh-btn[aria-disabled="true"] { color: var(--faint); cursor: default; }
.hr-veh-btn[aria-disabled="true"]:hover { background: none; }

/* Trợ lý EV (brand-soft) */
.hr-assistant { border-color: var(--accent); background: var(--accent-soft); }
.hr-ic-brand {
  width: 32px; height: 32px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent);
}
.hr-assistant-text { margin: 0 0 14px; font-size: 13px; color: var(--muted); line-height: 1.55; }
.hr-assistant-btn {
  display: block; text-align: center; height: 40px; line-height: 40px;
  border-radius: 9px; background: var(--accent); color: var(--on-accent);
  font-size: 14px; font-weight: 500; text-decoration: none;
}
.hr-assistant-btn:hover { background: var(--accent-press); }
