:root{
  /* Defaults if not provided by params.theme */
  --theme-header-height: 64px;
  --theme-breadcrumbs-height: 40px;
  --theme-footer-height: 56px; /* compact footer height */
  /* Widen overall container to use more horizontal space */
  --container: 1440px;
  --adaptive-media-img-height: clamp(200px, 32vw, 420px);
}

/* ============================= */
/* Brand avatar styling (enhanced) */
/* ============================= */
.brand{ display: inline-flex; align-items: center; gap: 8px; }
.brand-avatar-link{ display:inline-flex; line-height:0; }
.brand-avatar-link{ width:32px; height:32px; border-radius:50%; overflow:hidden; position:relative; }
.brand-avatar-link:focus-visible{ outline:2px solid var(--accent, #222); outline-offset:2px; border-radius:50%; }
.brand .logo-avatar{
  width: 32px; height: 32px; border-radius: 50%;
  object-fit: cover; display: inline-block;
  background: #fff;
  border: 2px solid rgba(0,0,0,.15);
  box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 0 0 1px rgba(0,0,0,.04);
  transition: box-shadow .25s ease, transform .25s ease, border-color .25s ease;
}
.brand-avatar-link .logo-avatar{ width:100%; height:100%; border-radius:50%; display:block; }
.brand .logo-avatar:hover{ transform: translateY(-1px); box-shadow: 0 4px 12px -2px rgba(0,0,0,.18), 0 0 0 1px rgba(0,0,0,.05); }
.brand .logo-avatar:active{ transform: scale(.95); }
.brand-text{ font-weight: 600; }
@media (max-width: 900px){
  .brand .logo-avatar{ width:28px; height:28px; }
}
@media (prefers-color-scheme: dark){
  .brand .logo-avatar{ background:#222; border-color:rgba(255,255,255,.35); box-shadow:0 0 0 1px rgba(255,255,255,.12), 0 4px 10px -2px rgba(0,0,0,.6); }
  .brand .logo-avatar:hover{ box-shadow:0 0 0 1px rgba(255,255,255,.25), 0 6px 14px -3px rgba(0,0,0,.7); }
}
.logo-avatar.avatar-fallback{ background:linear-gradient(135deg,#ddd,#bbb); border:2px dashed rgba(0,0,0,.25); box-shadow:none; }
@media (prefers-color-scheme: dark){ .logo-avatar.avatar-fallback{ background:linear-gradient(135deg,#444,#222); border-color:rgba(255,255,255,.3); } }

/* Make header fixed and reserve space so content won't jump under it */
body{ padding-top: var(--theme-header-height); }
.container{ max-width: var(--container); margin: 0 auto; padding: 0 16px; }
.site-header{
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
}

/* Make breadcrumbs stick under the sticky header */
.breadcrumbs{
  position: sticky;
  top: var(--theme-header-height);
  z-index: 60;
  background: rgba(248,246,242,.9);
  -webkit-backdrop-filter: saturate(180%) blur(6px);
  backdrop-filter: saturate(180%) blur(6px);
  padding: 8px 0;
  margin: 0 0 8px !important; /* override inline margin */
  border-bottom: 1px solid var(--border);
}

/* Adjust sticky offsets for sidebar and TOC to sit below header+breadcrumbs */
.docs-sidebar,
.docs-toc{
  position: sticky;
  top: calc(var(--theme-header-height) + var(--theme-breadcrumbs-height));
}

.docs-toc{
  align-self: flex-start;
  padding: 18px 20px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface);
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  --toc-hover-bg: rgba(0,0,0,0.04);
  --toc-active-bg: rgba(0,0,0,0.08);
}

.docs-toc .toc-title{
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--muted);
}

.docs-toc .toc{
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 0px;
}

.docs-toc .toc #TableOfContents{
  display: block;
  padding-top: 16px;
}

.docs-toc .toc #TableOfContents > ul{
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.docs-toc .toc #TableOfContents > ul > li:first-child > a{
  margin-top: 4px;
}

/* ============================= */
/* TOC indentation (up to 3 lvls) */
/* ============================= */
/* Remove bullets and spacing from Hugo TOC structure */
.toc #TableOfContents ul{ list-style: none; margin: 0; padding: 0; }

/* Base link style reset so indentation is controlled purely by level rules */
.toc #TableOfContents a{
  display: block;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid transparent;
  color: var(--muted);
  text-decoration: none;
  transition: background .2s ease, border-color .2s ease, color .2s ease;
}

.toc #TableOfContents a:hover{
  background: var(--toc-hover-bg);
  border-color: var(--border);
  color: var(--text);
}

.toc #TableOfContents a.is-active{
  background: var(--toc-active-bg);
  border-color: var(--border);
  color: var(--text);
}

:root[data-theme="dark"] .docs-toc{
  --toc-hover-bg: rgba(255,255,255,0.08);
  --toc-active-bg: rgba(255,255,255,0.14);
}

/* Level indents: 2ch per level */
.toc #TableOfContents > ul > li > a{ padding-left: 12px; }
.toc #TableOfContents ul ul > li > a{ padding-left: calc(1.2rem + 6px); }
.toc #TableOfContents ul ul ul > li > a{ padding-left: calc(2.4rem + 6px); }

.toc #TableOfContents li + li{ margin-top: 2px; }
.toc #TableOfContents ul ul{ margin-top: 2px; }

/* Hide depth >= 4 */
.toc #TableOfContents ul ul ul ul{ display: none; }

/* ============================= */
/* Docs layout width tuning      */
/* ============================= */
/* Narrow side rails a bit and reduce gap to free center space */
.docs-layout{
  grid-template-columns: 240px minmax(0, 1fr) 220px; /* sidebar | content | toc */
  gap: 22px;
}

/* ============================= */
/* Home updates accordion cards   */
/* ============================= */
.home-updates{
  display: grid;
  gap: 18px;
  margin-top: 18px;
  grid-template-columns: 1fr;
}

.home-updates-column{
  display: flex;
  flex-direction: column;
  gap: 16px;
}

@media (min-width: 900px){
  .home-updates{ grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

.home-update-card{
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--surface);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: box-shadow .2s ease, border-color .2s ease;
  display: block;
}

.home-update-card summary{
  list-style: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 600;
  color: var(--text);
  position: relative;
  padding-right: 44px;
}

.home-update-card summary::-webkit-details-marker{ display: none; }

.home-update-card summary::after{
  content: "\25BC";
  font-size: 12px;
  color: var(--muted);
  transition: transform .2s ease;
  position: absolute;
  right: 20px;
  top: 50%;
  transform: translateY(-50%);
}

.home-update-card[open] summary::after{
  transform: rotate(180deg);
}

.home-update-title{
  font-size: 16px;
  flex: 1 1 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.home-update-meta{
  color: var(--muted);
  font-size: 13px;
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.home-update-card[open]{
  border-color: rgba(0,0,0,0.12);
  box-shadow: var(--shadow-hover);
}

.home-update-body{
  border-top: 1px solid var(--border);
  padding: 16px 20px 18px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.home-update-body p{ margin: 0 0 10px; }

.home-update-link{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  text-decoration: none;
  color: var(--accent-2);
}

.home-update-link::after{
  content: "\2192";
  font-size: 14px;
}

.home-update-more{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  color: var(--accent-2);
  text-decoration: none;
  justify-self: flex-start;
  padding: 6px 0;
}

.home-update-more{ grid-column: 1 / -1; }

.home-update-more::after{
  content: "\2192";
  font-size: 14px;
}

@media (max-width: 600px){
  .home-update-card summary{ flex-direction: column; align-items: flex-start; gap: 8px; padding-right: 20px; }
  .home-update-card summary::after{ right: 16px; }
  .home-update-meta{ font-size: 12px; margin-left: 0; }
}

/* ============================= */
/* Fixed translucent footer      */
/* ============================= */
/* Reserve space so content bottom is not covered by fixed footer */
body{ padding-bottom: var(--theme-footer-height); }

.site-footer{
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 70; /* below header (100) but above content */
  background: rgba(248,246,242,.9);
  -webkit-backdrop-filter: saturate(180%) blur(8px);
  backdrop-filter: saturate(180%) blur(8px);
  border-top: 1px solid var(--border);
  padding: 6px 0; /* compact padding */
  transition: transform .25s ease, opacity .25s ease;
}

/* Footer social icons */
.site-footer .social-links { display: flex; gap: 0.0rem; align-items: center; }
.site-footer .social-links .social-icon { display: inline-flex; width: 32px; height: 32px; border-radius: 50%; align-items: center; justify-content: center; color: var(--color-text-secondary, #555); background: rgba(0,0,0,0.04); text-decoration: none; transition: background .25s, color .25s, transform .25s; }
.site-footer .social-links .bear-badge { width: auto; min-width: 32px; padding: 0 0.85rem; border-radius: 999px; font-size: 0.95rem; font-weight: 600; font-family: "Inter", "SF Pro Text", "Segoe UI", sans-serif; letter-spacing: 0.01em; line-height: 1; }
.site-footer .social-links .social-icon:hover, .site-footer .social-links .social-icon:focus-visible { background: var(--color-accent, #444); color: #fff; transform: translateY(-2px); }
.site-footer .social-links .social-icon svg, .site-footer .social-links .social-icon img { width: 18px; height: 18px; display: block; }
.site-footer .social-links .social-icon img { object-fit: contain; border-radius: 4px; }
@media (prefers-color-scheme: dark) { .site-footer .social-links .social-icon { background: rgba(255,255,255,0.08); color: #ccc; } .site-footer .social-links .social-icon:hover, .site-footer .social-links .social-icon:focus-visible { background: var(--color-accent, #eee); color: #000; } }

/* ============================= */
/* Responsive priorities          */
/* 1) Wide: show all 3 columns    */
/* 2) Medium: hide LEFT sidebar   */
/* 3) Small: only center content  */
/* ============================= */
@media (max-width: 1200px){
  .docs-sidebar{ display: none; }
  .docs-layout{ grid-template-columns: minmax(0,1fr) 280px; }
  .docs-toc{ display: block; }
}
@media (max-width: 900px){
  .docs-layout{ grid-template-columns: 1fr; }
  .docs-toc{ display: none; }
}

/* Header: progressively hide less important items */
@media (max-width: 1200px){
  /* 保留 Posts、主题切换 与 新的搜索图标 */
  .actions .btn.ghost:not(.posts-cta):not(.posts-btn):not(.theme-toggle-btn):not(.search-toggle-btn){ display: none; }
}

.actions .posts-cta{ background: #161616; color: #fff !important; border: 1px solid #161616; text-decoration: none; transition: background .25s ease, color .25s ease, transform .2s ease; }
.actions .posts-cta:hover, .actions .posts-cta:focus-visible{ background: #000; color: #fff; transform: translateY(-1px); }
.actions .posts-cta:active{ transform: translateY(0); background: #1f1f1f; }

/* Footer: collapse nav on small screens */
@media (max-width: 900px){ .footer-nav{ display: none; } .footer-inner{ justify-content: center; } }

/* ============================= */
/* Breadcrumb collapsing rules   */
/* ============================= */
@media (max-width: 900px){
  /* Keep header and breadcrumbs attached on narrow screens */
  body{ padding-top: var(--theme-header-height); }
  .site-header{ position: fixed; top: 0; left: 0; right: 0; z-index: 100; }
  .breadcrumbs{ top: var(--theme-header-height); }
  .breadcrumbs{ font-size: 13px; }
  /* Mobile: show current page title or section name; hide only ancestors */
  .breadcrumbs .crumb-anc{ display: none; }
  .breadcrumbs .crumb-sec{ display: inline; }
  .breadcrumbs .crumb-current{ display: inline; }
  /* No leading slashes when only one label is shown */
  .breadcrumbs .crumb-sep{ display: none; }
}

/* ============================= */
/* Mobile TOC mini button/drawer */
/* ============================= */
.toc-mini-btn{ display: none; }
.toc-drawer{ display: none; }
@media (max-width: 900px){
  .toc-mini-btn{ position: fixed; right: 16px; bottom: calc(var(--theme-footer-height) + 24px); z-index: 200; border: 1px solid var(--border); border-radius: 999px; background: var(--surface); color: var(--text); padding: 8px 12px; box-shadow: var(--shadow); display: inline-flex; }
  .toc-drawer{ position: fixed; right: 0; top: var(--theme-header-height); bottom: calc(var(--theme-footer-height) + 8px); width: min(86%, 340px); z-index: 110; }
  .toc-drawer-inner{ height: 100%; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; }
  .toc-drawer-header{ display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 1px solid var(--border); font-weight: 600; }
  .toc-drawer-close{ border: 1px solid var(--border); background: transparent; border-radius: 8px; padding: 4px 8px; cursor: pointer; }
  .toc-drawer .toc{ padding: 8px 8px; overflow: auto; }
  /* visibility controlled by [hidden] attribute */
  .toc-drawer[hidden]{ display: none; }
  .toc-drawer:not([hidden]){ display: block; }
}

/* Header toggles are provided by theme; keep this block empty */

/* Drawer styles (legacy from site; kept for compatibility if referenced) */
/* If not needed, you may remove this section later. */

/* Adaptive table layout (7-character principle) */
.adaptive-table{ table-layout: fixed; width: 100%; }
.adaptive-table th{ white-space: nowrap; }
.adaptive-table td{ word-break: break-word; vertical-align: top; }
.adaptive-table td .cell-inner{ display: -webkit-box; -webkit-line-clamp: 3; line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; line-height: 1.6; max-height: calc(1.6em * 3); text-overflow: ellipsis; }
.adaptive-table td.nowrap-7{ white-space: nowrap; word-break: normal; }
.adaptive-table td.nowrap-7 .cell-inner{ display: inline; -webkit-line-clamp: initial; line-clamp: unset; max-height: none; overflow: visible; white-space: nowrap; }
.adaptive-table td.cell-media .cell-inner{ display: block; -webkit-line-clamp: initial; line-clamp: unset; max-height: none; overflow: visible; }
.adaptive-table td.cell-media img, .adaptive-table td.cell-media picture, .adaptive-table td.cell-media figure, .adaptive-table td.cell-media iframe, .adaptive-table td.cell-media video, .adaptive-table td.cell-media svg{ max-width: 100%; display: block; margin: 0 auto; }
.adaptive-table td.cell-media img, .adaptive-table td.cell-media picture img, .adaptive-table td.cell-media video, .adaptive-table td.cell-media iframe{ width: 100%; height: var(--adaptive-media-img-height); object-fit: cover; border-radius: 6px; }

/* Responsive media inside article content */
.docs-content .prose img, .docs-content .prose picture, .docs-content .prose video, .docs-content .prose iframe, .docs-content .prose svg{ max-width: 100%; height: auto; }
.docs-content .prose picture, .docs-content .prose video, .docs-content .prose iframe{ display: block; }
.docs-content .prose img,  .docs-content .prose picture img{ display: block; margin: 1.2rem auto; }
  .docs-content .prose figure{ margin-left: 0; margin-right: 0; }
  @media (max-width: 900px){ .adaptive-table{ font-size:14px; } }

/* Remove extra whitespace at page bottom: no trailing margin from last block */
.docs-content .prose > :last-child{ margin-bottom: 0 !important; }

/* Mobile: make footer and reserved space smaller */
@media (max-width: 900px){
  :root{ --theme-footer-height: 44px; }
  .site-footer{ padding: 4px 0; }
}

/* Footer auto-hide state */
.site-footer.footer-hidden{ transform: translateY(100%); opacity: .85; }

/* ===== Header action buttons (e.g., Posts): ensure no underline ===== */
.actions .btn,
.actions .btn:hover,
.actions .btn:focus,
.actions .btn:focus-visible,
.actions .btn:active,
.actions .btn:visited{ text-decoration: none !important; }

/* ===== Mobile top-right permanent Posts button ===== */
/* ============================= */
/* Tablet & mobile header layout */
@media (max-width: 1200px){
  .site-header .nav{ display: none; }
  .brand-text{ display: none; }
  .mobile-nav-btn,
  .mobile-nav-btn--header{
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    margin-left: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: 8px;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    position: static !important;
    right: auto;
    top: auto;
    transform: none;
    z-index: 101;
  }
  .site-header .actions{
    display: inline-flex;
    align-items: center;
    gap: 10px;
  }
  .actions .posts-btn{ margin-left: auto; }
  .site-header .header-inner{ height: 66px; align-items: center; }
}

/* ============================= */
/* Mobile: hide breadcrumbs       */
/* ============================= */
@media (max-width: 1200px){
  .breadcrumbs{ display: none !important; }
  .nav-drawer{
    position: fixed;
    left: 0;
    top: var(--theme-header-height, 64px);
    bottom: 0;
    width: min(86%, 360px);
    z-index: 400;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow);
    display: none;
  }
  .nav-drawer-inner{
    height: 100%;
    width: 100%;
    background: var(--surface);
    display: flex;
    flex-direction: column;
    overflow: hidden;
  }
  .nav-drawer-header{
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
  }
  .nav-drawer-title{
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: rgba(107,102,95,.85);
    font-weight: 600;
  }
  .nav-drawer-close{
    border: 1px solid var(--border);
    background: transparent;
    border-radius: 8px;
    padding: 4px 8px;
    cursor: pointer;
  }
  .nav-drawer-list{
    padding: 8px 10px;
    overflow: visible;
    display: grid;
    gap: 0;
    max-height: none;
  }
  .nav-drawer-item,
  .nav-drawer-subitem{
    display: block;
    padding: 8px 10px;
    text-decoration: none;
    color: var(--text);
    border-bottom: none;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .nav-drawer-subitem{ padding-left: 24px; color: var(--muted); }
  .nav-drawer[hidden]{ display: none; }
  .nav-drawer:not([hidden]){ display: block; }
  .nav-drawer-folder{
    border-top: 1px solid var(--border);
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
  }
  .nav-drawer-subtitle{
    padding: 10px 12px;
    font-size: 12px;
    letter-spacing: .08em;
    color: rgba(107,102,95,.8);
    text-transform: uppercase;
  }
  .nav-drawer-folder .docs-nav.in-drawer{
    padding: 6px 10px;
    overflow: auto;
    display: flex;
    flex-direction: column;
    gap: 2px;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: stable;
    flex: 1 1 auto;
    min-height: 0;
    background: var(--surface);
  }
  .nav-drawer-folder .docs-nav.in-drawer a{
    border: none;
    border-radius: 6px;
    padding: 6px 8px;
    margin: 0;
    display: block;
    line-height: 1.5;
    color: var(--text);
    text-decoration: none;
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
  }
}

.theme-toggle-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  padding: 6px 12px;
  font-size: 16px;
}

.actions .theme-toggle-btn{
  display: inline-flex;
}

.actions .btn.ghost.theme-toggle-btn{
  display: inline-flex;
}

.posts-btn{
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--surface);
  transition: background .2s ease, color .2s ease, border-color .2s ease;
  text-decoration: none !important;
  font-weight: 500;
}
.posts-btn:hover,
.posts-btn:focus-visible{
  background: var(--text);
  color: var(--surface);
  border-color: var(--text);
}
.actions .posts-btn{ margin-left: auto; }

@media (max-width: 900px){
  .site-header .actions{
    display: inline-flex;
    align-items: center;
    gap: 10px;
  }
  /* 由 search.css 控制右侧对齐顺序，不再让 Posts 主动推到最右侧 */
  .actions .posts-btn{ margin-left: 0; }
}

/* ============================= */
/* Dark mode support             */
/* ============================= */

:root:not([data-theme]){
  color-scheme: light;
}

@media (prefers-color-scheme: dark){
  :root:not([data-theme]){
    color-scheme: dark;
    --bg: #1b1a17;
    --surface: #22211d;
    --border: #35322a;
    --text: #f5f1e6;
    --muted: #9f9a8f;
    --accent: #a6e12d;
    --accent-2: #f9d67b;
    --shadow: 0 12px 28px rgba(0,0,0,0.55);
    --shadow-hover: 0 18px 38px rgba(0,0,0,0.7);
  }
  :root:not([data-theme]) .site-header,
  :root:not([data-theme]) .site-footer{ background: rgba(27,26,23,0.92); backdrop-filter: blur(12px); }
  :root:not([data-theme]) .prose a{ color: var(--accent-2); }
  :root:not([data-theme]) pre{ background:#2a2924; color:#f8f5ec; }
  :root:not([data-theme]) .breadcrumbs{
    background: rgba(34,33,29,0.85);
    border: 1px solid rgba(245,241,230,0.08);
    color: var(--text);
    border-radius: 10px;
    padding: 6px 12px;
  }
  :root:not([data-theme]) .breadcrumbs a{ color: var(--text); }
  :root:not([data-theme]) .breadcrumbs .crumb-current{ color: var(--accent-2); }
  :root:not([data-theme]) .hero .search input[type="search"]{
    background: rgba(40,39,35,0.95);
    border: 1px solid rgba(245,241,230,0.12);
    color: var(--text);
    box-shadow: 0 6px 18px rgba(0,0,0,0.35);
  }
  :root:not([data-theme]) .hero .search input[type="search"]::placeholder{ color: rgba(245,241,230,0.55); }
}

:root[data-theme="light"]{
  color-scheme: light;
  --bg: #F8F6F2;
  --surface: #FCFBF9;
  --border: #E6E3DC;
  --text: #2E2A25;
  --muted: #6B665F;
  --accent: #1B5E4A;
  --accent-2: #0F6DDC;
  --shadow: 0 1px 0 rgba(20,16,12,.04), 0 10px 20px rgba(20,16,12,.06);
  --shadow-hover: 0 2px 0 rgba(20,16,12,.05), 0 16px 28px rgba(20,16,12,.08);
}

:root[data-theme="dark"]{
  color-scheme: dark;
  --bg: #1b1a17;
  --surface: #22211d;
  --border: #35322a;
  --text: #f5f1e6;
  --muted: #9f9a8f;
  --accent: #a6e12d;
  --accent-2: #f9d67b;
  --shadow: 0 12px 28px rgba(0,0,0,0.55);
  --shadow-hover: 0 18px 38px rgba(0,0,0,0.7);
  --docs-nav-current-bg: rgba(50,49,44,0.95);
  --docs-nav-current-border: rgba(249,214,123,0.25);
}

:root[data-theme="dark"] .site-header,
:root[data-theme="dark"] .site-footer{ background: rgba(27,26,23,0.92); backdrop-filter: blur(12px); }
:root[data-theme="dark"] .prose a{ color: var(--accent-2); }
:root[data-theme="dark"] pre{ background:#2a2924; color:#f8f5ec; }
:root[data-theme="dark"] .breadcrumbs{
  background: rgba(34,33,29,0.85);
  border: 1px solid rgba(245,241,230,0.08);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 12px;
}
:root[data-theme="dark"] .breadcrumbs a{ color: var(--text); }
:root[data-theme="dark"] .breadcrumbs .crumb-current{ color: var(--accent-2); }
:root[data-theme="dark"] .hero .search input[type="search"]{
  background: rgba(40,39,35,0.95);
  border: 1px solid rgba(245,241,230,0.12);
  color: var(--text);
  box-shadow: 0 6px 18px rgba(0,0,0,0.35);
}
:root[data-theme="dark"] .hero .search input[type="search"]::placeholder{
  color: rgba(245,241,230,0.55);
}

/* ===== Dark mode readability for content (global, all skins) ===== */
/* Tables */
:root[data-theme="dark"] .docs-content .prose table thead th,
:root[data-theme="dark"] .prose table thead th{
  background-color: rgba(255,255,255,0.06);
  border-bottom-color: rgba(249,214,123,0.22);
}
:root[data-theme="dark"] .docs-content .prose table thead,
:root[data-theme="dark"] .prose table thead{ background-color: rgba(255,255,255,0.04); }
:root[data-theme="dark"] .docs-content .prose table td,
:root[data-theme="dark"] .prose table td{ border-bottom-color: rgba(255,255,255,0.12); }
:root[data-theme="dark"] .docs-content .prose table tbody tr:nth-child(even),
:root[data-theme="dark"] .prose table tbody tr:nth-child(even){ background-color: rgba(255,255,255,0.04); }
:root[data-theme="dark"] .docs-content .prose table tbody tr:hover,
:root[data-theme="dark"] .prose table tbody tr:hover{ background-color: rgba(255,255,255,0.08); }

/* Blockquotes */
:root[data-theme="dark"] .docs-content .prose blockquote,
:root[data-theme="dark"] .prose blockquote{
  background-color: rgba(249,214,123,0.08);
  border-left-color: rgba(249,214,123,0.60);
}

/* System dark fallback before data-theme is set */
@media (prefers-color-scheme: dark){
  :root:not([data-theme]) .docs-content .prose table thead th,
  :root:not([data-theme]) .prose table thead th{ background-color: rgba(255,255,255,0.06); border-bottom-color: rgba(249,214,123,0.22); }
  :root:not([data-theme]) .docs-content .prose table thead,
  :root:not([data-theme]) .prose table thead{ background-color: rgba(255,255,255,0.04); }
  :root:not([data-theme]) .docs-content .prose table td,
  :root:not([data-theme]) .prose table td{ border-bottom-color: rgba(255,255,255,0.12); }
  :root:not([data-theme]) .docs-content .prose table tbody tr:nth-child(even),
  :root:not([data-theme]) .prose table tbody tr:nth-child(even){ background-color: rgba(255,255,255,0.04); }
  :root:not([data-theme]) .docs-content .prose table tbody tr:hover,
  :root:not([data-theme]) .prose table tbody tr:hover{ background-color: rgba(255,255,255,0.08); }
  :root:not([data-theme]) .docs-content .prose blockquote,
  :root:not([data-theme]) .prose blockquote{ background-color: rgba(249,214,123,0.08); border-left-color: rgba(249,214,123,0.60); }
}
:root[data-theme="dark"] .nav-drawer-folder .docs-nav.in-drawer a.is-active,
:root[data-theme="dark"] .nav-drawer-folder .docs-nav.in-drawer a.active,
:root[data-theme="dark"] .nav-drawer-folder .docs-nav.in-drawer a[aria-current="page"],
  :root[data-theme="dark"] .nav-drawer-folder .docs-nav.in-drawer a[aria-current="true"]{
    background: rgba(50,49,44,0.95);
    color: var(--accent-2);
    box-shadow: inset 0 0 0 1px rgba(249,214,123,0.25);
  }
  :root[data-theme="dark"] .nav-drawer-item.is-active,
  :root[data-theme="dark"] .nav-drawer-item.active,
  :root[data-theme="dark"] .nav-drawer-item[aria-current="page"],
  :root[data-theme="dark"] .nav-drawer-item[aria-current="true"],
  :root[data-theme="dark"] .nav-drawer-subitem.is-active,
  :root[data-theme="dark"] .nav-drawer-subitem.active,
  :root[data-theme="dark"] .nav-drawer-subitem[aria-current="page"],
  :root[data-theme="dark"] .nav-drawer-subitem[aria-current="true"]{
    background: rgba(50,49,44,0.95);
    color: var(--accent-2);
    box-shadow: inset 0 0 0 1px rgba(249,214,123,0.25);
  }
  :root[data-theme="dark"] .docs-sidebar .docs-nav a.is-active,
  :root[data-theme="dark"] .docs-sidebar .docs-nav a[aria-current="page"],
  :root[data-theme="dark"] .docs-sidebar .docs-nav a[aria-current="true"],
  :root[data-theme="dark"] .toc a.is-active{
    background: rgba(50,49,44,0.95);
    color: var(--accent-2);
    box-shadow: inset 0 0 0 1px rgba(249,214,123,0.25);
  }

/* ========================================= */
/* Sidebar placeholders only (desktop/tablet) */
/* Hide functional content but keep columns   */
/* ========================================= */
/* 左侧：隐藏标题与导航内容，但保留 <aside.docs-sidebar> 以维持列占位 */
@media (min-width: 768px){
  .docs-sidebar .docs-side-title,
  .docs-sidebar .docs-nav{
    display: none !important;
  }

  /* 右侧：去除卡片外观并隐藏内部内容，但保留 <aside.docs-toc> 以维持列占位 */
  .docs-toc{
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    padding: 0 !important;
  }
  .docs-toc .toc-title,
  .docs-toc .toc{
    display: none !important;
  }
}

/* ========================================= */
/* Enable drawers & TOC mini button on ALL widths */
/* Keep templates/JS unchanged; override visibility via CSS */
/* ========================================= */

/* Show the header nav toggle button on desktop/tablet as well */
.mobile-nav-btn,
.mobile-nav-btn--header{
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-left: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: 8px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

/* Make nav drawer work across all widths */
.nav-drawer{
  position: fixed;
  left: 0;
  top: var(--theme-header-height, 64px);
  bottom: 0;
  width: min(86%, 360px);
  z-index: 400;
  background: var(--surface);
  border-right: 1px solid var(--border);
  box-shadow: var(--shadow);
}
.nav-drawer-inner{ height: 100%; width: 100%; background: var(--surface); display: flex; flex-direction: column; overflow: hidden; }
.nav-drawer-header{ display:flex; align-items:center; justify-content:space-between; padding:10px 12px; border-bottom:1px solid var(--border); }
.nav-drawer-title{ font-size:12px; letter-spacing:.08em; text-transform:uppercase; color: rgba(107,102,95,.85); font-weight:600; }
.nav-drawer-close{ border:1px solid var(--border); background:transparent; border-radius:8px; padding:4px 8px; cursor:pointer; }
.nav-drawer-list{ padding:8px 10px; overflow:auto; display:grid; gap:0; max-height:none; }
.nav-drawer[hidden]{ display: none !important; }
.nav-drawer:not([hidden]){ display: block !important; }

/* Make TOC mini button and drawer available on desktop/tablet too */
.toc-mini-btn{
  position: fixed;
  right: 16px;
  bottom: calc(var(--theme-footer-height) + 24px);
  z-index: 200;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  padding: 8px 12px;
  box-shadow: var(--shadow);
  display: inline-flex !important;
}
.toc-drawer{
  position: fixed;
  right: 0;
  top: var(--theme-header-height);
  bottom: calc(var(--theme-footer-height) + 8px);
  width: min(86%, 340px);
  z-index: 110;
}
  .toc-drawer-inner{ height: 100%; background: var(--surface); border-left: 1px solid var(--border); box-shadow: var(--shadow); display: flex; flex-direction: column; }
  .toc-drawer-header{ display:flex; align-items:center; justify-content:space-between; padding:10px 12px; border-bottom:1px solid var(--border); font-weight:600; }
  .toc-drawer-close{ border:1px solid var(--border); background:transparent; border-radius:8px; padding:4px 8px; cursor:pointer; }
  .toc-drawer .toc{ padding:8px 8px; overflow:auto; }
  .toc-drawer[hidden]{ display: none !important; }
  .toc-drawer:not([hidden]){ display: block !important; }

/* ========================================= */
/* M1: Hoist mobile drawer styles to all widths */
/* - Remove link underlines, unify typography, spacing, states            */
/* - Improve inner padding and list gutters                               */
/* - Define drawer widths: desktop 400px, tablet 340px, mobile min(86%,340)*/
/* ========================================= */

/* Drawer widths */
.nav-drawer{ width: 400px !important; }
@media (max-width: 1200px){ .nav-drawer{ width: 340px !important; } }
@media (max-width: 900px){ .nav-drawer{ width: min(86%, 340px) !important; } }

/* Drawer inner paddings and list gutters */
.nav-drawer-inner{ padding: 8px 12px 18px; }
.nav-drawer-list{ padding: 8px 8px 10px; overflow: visible; flex: 0 0 auto; }

/* Remove underlines and unify link typography in drawer */
.nav-drawer a,
.nav-drawer-item,
.nav-drawer-subitem,
.nav-drawer-folder .docs-nav.in-drawer a{
  text-decoration: none !important;
  display: block;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  padding: 8px 10px;
  margin: 0 4px; /* avoid touching panel edges */
  border-radius: 8px;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, border-color .18s ease;
}

/* Subitems indentation and secondary color */
.nav-drawer-subitem{ padding-left: 24px; color: var(--muted); }

/* Hover and focus states */
.nav-drawer-item:hover,
.nav-drawer-subitem:hover,
.nav-drawer-folder .docs-nav.in-drawer a:hover{
  background: rgba(0,0,0,0.04);
  border: 1px solid var(--border);
}
.nav-drawer a:focus-visible{
  outline: 2px solid var(--border);
  outline-offset: 2px;
  border-radius: 8px;
}
@media (prefers-color-scheme: dark){
  .nav-drawer-item:hover,
  .nav-drawer-subitem:hover,
  .nav-drawer-folder .docs-nav.in-drawer a:hover{
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(245,241,230,0.12);
  }
}

/* Active/current states */
.nav-drawer a.is-active,
.nav-drawer a.active,
.nav-drawer a[aria-current="page"],
.nav-drawer a[aria-current="true"]{
  background: var(--docs-nav-current-bg, rgba(0,0,0,0.06));
  box-shadow: inset 0 0 0 1px var(--docs-nav-current-border, rgba(0,0,0,0.08));
  color: var(--text);
}

/* Section subtitles: subtle separators and spacing */
.nav-drawer-subtitle{
  font-size: 12px;
  letter-spacing: .08em;
  color: rgba(107,102,95,.8);
  text-transform: uppercase;
  padding: 10px 12px 8px;
  margin: 6px 2px 4px;
  border-top: 1px solid var(--border);
}

/* Keep drawer header pinned */
.nav-drawer-header{ position: sticky; top: 0; background: var(--surface); z-index: 2; }

/* Make section area the only scroller; allow flex shrink */
.nav-drawer-folder{ flex: 1 1 auto; display: flex; flex-direction: column; min-height: 0; }
.nav-drawer-folder .docs-nav.in-drawer{ flex: 1 1 auto; overflow: auto; padding: 8px 8px 10px; scrollbar-gutter: stable both-edges; display: flex; flex-direction: column; justify-content: flex-start; align-items: stretch; gap: 4px; }

/* Hide any stray nav toggle buttons inside breadcrumbs on wide screens */
@media (min-width: 900px){
  .breadcrumbs .mobile-nav-btn,
  .breadcrumbs .mobile-nav-btn--header{ display: none !important; }
}

/* TOC drawer link styles (match drawer links) */
.toc-drawer .toc a{
  text-decoration: none !important;
  display: block;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text);
  padding: 6px 10px;
  margin: 0 4px;
  border-radius: 8px;
  transition: background .18s ease, color .18s ease, box-shadow .18s ease, border-color .18s ease;
}
  .toc-drawer .toc a:hover{
    background: rgba(0,0,0,0.04);
    border: 1px solid var(--border);
  }
  @media (prefers-color-scheme: dark){
    .toc-drawer .toc a:hover{
      background: rgba(255,255,255,0.08);
      border: 1px solid rgba(245,241,230,0.12);
    }
  }

/* ========================================= */
/* Fix: remove duplicate divider on tablet    */
/* Root cause: .nav-drawer-folder had border-top in <=1200px block */
/* Keep single separator on .nav-drawer-subtitle only              */
/* ========================================= */
.nav-drawer-folder{ border-top: none !important; }
@media (max-width: 1200px){ .nav-drawer-folder{ border-top: none !important; } }

/* ========================================= */
/* M2: Global backdrop + scroll lock when any drawer is open      */
/* Applies to ALL widths; no template/JS changes                   */
/* ========================================= */
body:has(#navDrawer:not([hidden])),
body:has(#tocDrawer:not([hidden])){
  overflow: hidden;
}
body:has(#navDrawer:not([hidden]))::after,
body:has(#tocDrawer:not([hidden]))::after{
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.12);
  -webkit-backdrop-filter: saturate(120%) blur(1px);
  backdrop-filter: saturate(120%) blur(1px);
  z-index: 105; /* above content/header (100), below drawers (110/400) */
  pointer-events: auto; /* block underlying clicks; document listener still closes */
}

/* ========================================= */
/* Place hamburger to the LEFT of the logo (all widths) */
/* Keep structure unchanged; reorder via flex order */
/* ========================================= */
.brand{ display: inline-flex; align-items: center; gap: 8px; }
.brand .mobile-nav-btn--header{ order: 0; margin-left: 0 !important; margin-right: 6px; }
.brand .brand-avatar-link{ order: 1; }
.brand .brand-text{ order: 2; }
