/* 父壳布局：左侧唯一导航 + 右侧 iframe 铺满剩余区域 */
html.ti5-app-shell,
html.ti5-app-shell body {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  height: 100% !important;
  overflow: hidden !important;
  /* 覆盖 custom.css 的 scrollbar-gutter:stable，否则右侧会空出一条深色槽 */
  scrollbar-gutter: auto !important;
  background: #ffffff !important;
}

.ti5-shell {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #ffffff;
  box-sizing: border-box;
}

.ti5-shell-nav {
  flex: 0 0 var(--sidebar-width, 300px);
  width: var(--sidebar-width, 300px);
  max-width: var(--sidebar-width, 300px);
  height: 100%;
  overflow: hidden;
  background: var(--sidebar-bg, #2c2b2b);
  border-right: 1px solid var(--sidebar-border, #383838);
  z-index: 2;
}

.ti5-shell-nav > .wy-nav-side,
.ti5-shell-nav nav.wy-nav-side {
  position: relative !important;
  left: 0 !important;
  top: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-height: 100% !important;
}

.ti5-shell-nav .wy-side-nav-search {
  position: sticky !important;
  top: 0 !important;
  z-index: 20 !important;
  background: var(--sidebar-bg, #2c2b2b) !important;
}

/* 右侧 iframe：占满壳层剩余宽高（width:0 + flex 防止右侧露底） */
.ti5-shell-frame {
  flex: 1 1 0% !important;
  width: 0 !important;
  min-width: 0 !important;
  height: 100% !important;
  border: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #ffffff !important;
  display: block !important;
  align-self: stretch !important;
  opacity: 1;
  transition: opacity 0.18s ease;
  will-change: opacity;
}

/* 切页淡出：露出下层白底，避免白/空闪一下 */
.ti5-shell-frame.ti5-frame-fade {
  opacity: 0;
}

/* iframe 内嵌页：隐藏自带侧栏 / 顶栏，正文铺满白底 */
html.ti5-embed,
html.ti5-embed body,
html.ti5-embed .wy-body-for-nav {
  margin: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  max-width: 100% !important;
  min-height: 100% !important;
  background: #ffffff !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  scrollbar-gutter: auto !important;
}

html.ti5-embed .wy-nav-side,
html.ti5-embed .wy-nav-top,
html.ti5-embed .my-unique-navbar,
html.ti5-embed .ti5-sidebar-footer,
html.ti5-embed .rst-versions {
  display: none !important;
  width: 0 !important;
  height: 0 !important;
  visibility: hidden !important;
}

html.ti5-embed .wy-grid-for-nav {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
  background: #ffffff !important;
}

html.ti5-embed .wy-nav-content-wrap,
html.ti5-embed .wy-nav-content-wrap.shift {
  margin-left: 0 !important;
  margin-right: 0 !important;
  padding: 0 !important;
  width: 100% !important;
  max-width: none !important;
  background: #ffffff !important;
}

html.ti5-embed .wy-nav-content {
  max-width: none !important;
  width: 100% !important;
  margin: 0 !important;
  padding: 1.618em 3.236em !important;
  background: #ffffff !important;
  box-sizing: border-box !important;
}

html.ti5-embed .rst-content {
  max-width: none !important;
}

html.ti5-embed body::-webkit-scrollbar-track,
html.ti5-embed body::-webkit-scrollbar-thumb {
  background: transparent !important;
}

/* 移动端：侧栏改为抽屉，正文铺满，避免上下分栏挤占（尤其嵌在官网顶栏下时） */
.ti5-shell-nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  position: fixed;
  left: 12px;
  bottom: 16px;
  z-index: 40;
  width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #2c2b2b;
  color: #fff;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.28);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.ti5-shell-nav-toggle:focus-visible {
  outline: 2px solid #4ea1ff;
  outline-offset: 2px;
}
.ti5-shell-nav-toggle svg {
  width: 22px;
  height: 22px;
  display: block;
}
.ti5-shell-backdrop {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 25;
  border: 0;
  padding: 0;
  margin: 0;
  background: rgba(0, 0, 0, 0.4);
  cursor: pointer;
}

@media screen and (max-width: 768px) {
  .ti5-shell {
    position: relative;
    flex-direction: row;
    height: 100%;
    height: 100dvh;
  }
  .ti5-shell-nav-toggle {
    display: flex;
  }
  .ti5-shell-nav {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    flex: none;
    width: min(88vw, 300px);
    max-width: none;
    height: 100% !important;
    z-index: 30;
    transform: translateX(-105%);
    transition: transform 0.25s ease;
    border-right: 1px solid var(--sidebar-border, #383838);
    border-bottom: none;
    box-shadow: none;
  }
  .ti5-shell.ti5-nav-open .ti5-shell-nav {
    transform: translateX(0);
    box-shadow: 8px 0 28px rgba(0, 0, 0, 0.28);
  }
  .ti5-shell.ti5-nav-open .ti5-shell-backdrop {
    display: block;
  }
  .ti5-shell-frame {
    flex: 1 1 auto !important;
    width: 100% !important;
    min-width: 0 !important;
    height: 100% !important;
    min-height: 0 !important;
  }
}
