/* ==========================================================================
   Bố cục — khung ứng dụng, sidebar, thanh trên
   ========================================================================== */

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ---------- Sidebar ---------- */
.sidebar {
  display: flex;
  flex-direction: column;
  background: rgb(17 17 17 / 72%);
  backdrop-filter: blur(12px);
  border-right: 1px solid var(--line-soft);
  position: sticky;
  top: 0;
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;
  z-index: 40;
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: 1rem .9rem;
  border-bottom: 1px solid var(--line-soft);
}

.sidebar__logo {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  flex: none;
  border-radius: var(--r-sm);
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-family: var(--font-cn);
  font-size: var(--fs-lg);
  font-weight: 700;
}

.sidebar__brandText { display: flex; flex-direction: column; line-height: 1.3; min-width: 0; }
.sidebar__brandText strong {
  font-size: var(--fs-body);
  font-weight: 600;
  letter-spacing: .04em;
}
.sidebar__brandText small { color: var(--text-3); font-size: var(--fs-micro); }

.sidebar__nav { flex: 1; padding: .6rem .5rem; }

.sidebar__sectionLabel {
  padding: .9rem .55rem .3rem;
  font-size: var(--fs-micro);
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--text-3);
}

.navItem {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem .55rem;
  margin-bottom: 1px;
  border-radius: var(--r-sm);
  border: 1px solid transparent;
  color: var(--text-2);
  font-size: var(--fs-body);
  transition: background .2s, color .2s, border-color .2s;
}

.navItem:hover { background: rgb(34 34 34 / 60%); color: var(--text); }

.navItem.is-active {
  background: var(--accent-dim);
  border-color: var(--accent-line);
  color: var(--accent);
  font-weight: 600;
}

.navItem .ic { color: currentColor; opacity: .85; }
.navItem.is-active .ic { opacity: 1; }

.navItem__badge {
  margin-left: auto;
  min-width: 18px;
  padding: 0 .35em;
  border-radius: var(--r-pill);
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-size: var(--fs-micro);
  font-weight: 700;
  text-align: center;
  line-height: 16px;
}

.sidebar__footer { padding: .6rem; border-top: 1px solid var(--line-soft); }

.streakBox {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .5rem .65rem;
  border-radius: var(--r-sm);
  background: var(--card);
  border: 1px solid var(--line-soft);
  color: var(--text-2);
}
.streakBox .ic { color: var(--accent); }
.streakBox strong { display: block; font-size: var(--fs-lg); line-height: 1.15; color: var(--text); }
.streakBox small { font-size: var(--fs-micro); color: var(--text-3); }

/* ---------- Khu vực chính ---------- */
.main { display: flex; flex-direction: column; min-width: 0; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: .7rem;
  height: var(--topbar-h);
  padding: 0 1rem;
  background: rgb(10 10 10 / 78%);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line-soft);
}

.topbar__menu {
  display: none;
  width: 32px;
  height: 32px;
  border: 1px solid var(--line);
  border-radius: var(--r-sm);
  color: var(--text-2);
  align-items: center;
  justify-content: center;
}

.topbar__title {
  font-size: var(--fs-body);
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-2);
}

.topbar__actions { display: flex; align-items: center; gap: .4rem; }

.xpChip {
  display: flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .55rem;
  border-radius: var(--r-pill);
  background: var(--accent-dim);
  border: 1px solid var(--accent-line);
  color: var(--accent);
  font-size: var(--fs-meta);
  font-weight: 600;
}

.content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: 1.5rem 1.2rem 4.5rem;
}

.content[aria-busy="true"] { opacity: .4; pointer-events: none; }

.scrim {
  position: fixed;
  inset: 0;
  z-index: 35;
  background: rgb(0 0 0 / 62%);
  backdrop-filter: blur(2px);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }

  /* Thanh trên điện thoại chỉ đủ chỗ cho MỘT thứ: đang ở đâu.
     Điểm tích luỹ và nút thử giọng đọc đẩy tiêu đề co lại còn "Gặp người Trung ..." —
     cả hai đều không phải việc cần làm ngay, chuyển hết vào Cài đặt. */
  .xpChip, #voiceCheck { display: none; }
  .topbar__title { font-size: var(--fs-md); color: var(--text); }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: min(82vw, 260px);
    background: var(--bg-2);
    transform: translateX(-102%);
    transition: transform .25s cubic-bezier(.4, 0, .2, 1);
    box-shadow: var(--sh-lg);
  }

  .sidebar.is-open { transform: none; }
  .topbar__menu { display: flex; }
  .content { padding: 1.1rem .9rem 4rem; }
}

@media (max-width: 560px) {
  .content { padding: .9rem .75rem 3.5rem; }
}
