.layout {
  display: flex;
  /* fallback for Safari < 17,降级到 vh 行为(包含工具栏可能被遮) */
  height: 100vh;
  /* Dynamic Viewport Height — 自动减去 Safari 工具栏/书签栏,
     永远等于用户实际看得到的高度,根因解 14寸 Safari 翻页按钮被截 */
  height: 100dvh;
  overflow: hidden;
  /* V2: transparent 让全局 AmbientBackground pastel aurora 在主区也能隐约透出 */
  background: transparent;
  position: relative;
  z-index: 2;
}

.sidebar {
  width: var(--sidebar-width);
  min-width: var(--sidebar-width);
  background: var(--color-bg-sidebar);
  /* V2 玻璃 */
  backdrop-filter: var(--bf-glass-md);
  -webkit-backdrop-filter: var(--bf-glass-md);
  border-right: 1px solid var(--color-border-card);
  /* V2 玻璃顶边白高光 + 右侧立体感 */
  box-shadow: inset 0 1px 0 var(--color-inset-highlight),
              2px 0 12px rgba(0, 0, 0, 0.04);
  display: flex;
  flex-direction: column;
  transition: width 0.2s ease, min-width 0.2s ease;
}

.sidebar.collapsed {
  width: var(--sidebar-collapsed-width);
  min-width: var(--sidebar-collapsed-width);
}

.sidebarHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--color-border-card);
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logoText {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
  white-space: nowrap;
}

.collapseBtn {
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  border-radius: 4px;
  display: flex;
  align-items: center;
}

.collapseBtn:hover {
  background: var(--color-sidebar-hover);
}

.nav {
  flex: 1;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow-y: auto;
}

.navItem {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  color: var(--color-text-secondary);
  text-decoration: none;
  font-size: 14px;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.navItem:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-text-primary);
}

.navItemActive {
  background: var(--color-sidebar-active);
  color: var(--color-text-primary);
}

.navDivider {
  height: 1px;
  background: var(--color-border-card);
  margin: 4px 12px;
}

.sidebarFooter {
  padding: 12px;
  border-top: 1px solid var(--color-border-card);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Theme toggle button (super admin sidebar) */
.themeToggle {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
  width: 100%;
  text-align: left;
}

.themeToggle:hover {
  background: var(--color-sidebar-hover);
  color: var(--color-primary);
}

.userInfo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 4px;
}

.userAvatar {
  width: 32px;
  height: 32px;
  min-width: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
}

.userMeta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}

.userName {
  color: var(--color-text-primary);
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logoutLink {
  background: transparent;
  border: none;
  color: var(--color-text-secondary);
  font-size: 12px;
  cursor: pointer;
  text-align: left;
  padding: 0;
}

.logoutLink:hover {
  color: var(--color-danger);
}

.content {
  flex: 1;
  overflow-y: auto;
  /* ★ 关键:让 flex 子元素正确 shrink + 触发 overflow-y;
     不加这个 flex 子默认 min-height: auto,内容溢出时 overflow-y: auto 形同虚设,
     底部按钮会被外层 .layout overflow:hidden 切掉 */
  min-height: 0;
  padding: 24px 32px 32px;
  transition: margin-left 0.2s ease;
}

@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 200;
    transform: translateX(0);
  }

  .sidebar.collapsed {
    transform: translateX(-100%);
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
  }
}
