/* Khung trang: header, sidebar, vùng nội dung. */
.site-header { position: sticky; top: 0; z-index: 40; min-height: var(--header-h); padding: 0 32px; display: flex; align-items: center; gap: 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.logo { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 18px; white-space: nowrap; }
.logo-mark { width: 36px; height: 36px; border-radius: 10px; background: var(--primary); color: #fff; display: flex; align-items: center; justify-content: center; font-family: var(--serif); font-size: 22px; }
.header-search { width: 380px; max-width: 100%; }
.grade-nav { margin-left: auto; display: flex; gap: 6px; }
.nav-link { height: 44px; padding: 0 16px; display: inline-flex; align-items: center; border-radius: 10px; font-size: 15px; font-weight: 500; color: var(--ink-2); }
.nav-link:hover { background: var(--accent-soft); }
.nav-link[aria-current] { background: var(--ink); color: var(--bg); font-weight: 600; }
.icon-btn { display: none; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); align-items: center; justify-content: center; cursor: pointer; }

.shell { display: flex; align-items: flex-start; min-height: calc(100vh - var(--header-h)); }
.sidebar { width: 290px; flex: none; position: sticky; top: var(--header-h); height: calc(100vh - var(--header-h)); overflow-y: auto; padding: 24px 14px 40px; background: var(--surface); border-right: 1px solid var(--line); }
.sidebar .label { font-size: 12px; font-weight: 700; letter-spacing: .1em; color: var(--muted); padding: 0 12px 10px; }
.chap > summary, .chap-link { list-style: none; cursor: pointer; min-height: 44px; display: flex; align-items: center; gap: 10px; padding: 0 12px; border-radius: 10px; font-size: 15px; font-weight: 500; color: var(--ink-2); }
.chap > summary::-webkit-details-marker { display: none; }
.chap > summary::after { content: '+'; margin-left: auto; color: var(--muted); font-weight: 400; }
.chap[open] > summary::after { content: '–'; }
.chap > summary:hover, .chap-link:hover { background: var(--accent-soft); }
.chap-code { width: 26px; height: 26px; border-radius: 8px; background: var(--accent-soft); color: var(--accent-ink); display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 700; flex: none; }
.chap ul { list-style: none; padding: 2px 0 8px 18px; }
.chap li a { min-height: 40px; display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 14px; border-left: 3px solid var(--line); border-radius: 0 10px 10px 0; font-size: 14px; color: var(--muted); }
.chap li a:hover { background: var(--accent-soft); color: var(--ink); }
.sec-code { font-weight: 700; font-size: 12px; min-width: 24px; }
.sidebar a[aria-current] { border-left-color: var(--accent); background: var(--accent-soft); color: var(--accent-ink); font-weight: 700; }
.chap-link[aria-current] { border-left: 0; }
.guide-link { margin-top: 12px; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; padding-left: 12px; }
#main { flex: 1; min-width: 0; }
.scrim { display: none; }

/* Trang chủ: ẩn mục lục và ô tìm kiếm trên header */
body[data-view='home'] .sidebar, body[data-view='home'] .header-search { display: none; }
body[data-view='home'] .grade-nav { margin-left: auto; }

@media (max-width: 960px) {
  .site-header { flex-wrap: wrap; padding: 10px 16px; gap: 10px; }
  .icon-btn { display: inline-flex; }
  body[data-view='home'] .icon-btn { display: none; }
  .header-search { order: 5; width: 100%; flex: 1 1 100%; }
  .grade-nav { display: none; }
  #theme-btn { margin-left: auto; }
  .theme-long, #theme-btn .long { display: none; }
  .sidebar { position: fixed; z-index: 60; left: 0; top: 0; bottom: 0; height: 100%; width: min(320px, 86vw); transform: translateX(-100%); transition: transform .22s ease; padding-top: 20px; }
  .drawer-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.35); }
  .scrim { position: fixed; inset: 0; z-index: 50; background: rgba(7,13,30,.5); }
  .drawer-open .scrim { display: block; }
}
