/* Notion-style collapsible sidebar shell */

:root {
  --sidebar-width: 232px;
}

.app-shell {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 100vh;
}

.app-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.app-sidebar {
  flex-shrink: 0;
  width: var(--sidebar-width);
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
  background: var(--surface);
  z-index: 120;
  transition: transform 220ms ease, width 220ms ease;
  overflow-x: hidden;
  overflow-y: auto;
}

/* 桌面：滚动时钉在视口左侧（同结果页目录 sticky 模式） */
@media (min-width: 901px) {
  .app-sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
  }
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--border);
  min-height: 2.75rem;
}

.sidebar-toggle .ui-icon {
  width: 1.1rem;
  height: 1.1rem;
}

.sidebar-toggle {
  flex-shrink: 0;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
}

.sidebar-toggle:hover {
  background: var(--hover-fill);
  color: var(--text-title);
}

.sidebar-workspace {
  min-width: 0;
  flex: 1;
}

.sidebar-workspace-label {
  display: block;
  font-size: 0.625rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  line-height: 1.2;
}

.sidebar-org-name {
  display: block;
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-title);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.3;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0.5rem 0.5rem 0.35rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.4rem 0.55rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-body);
  font: inherit;
  font-size: 0.8125rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
}

.sidebar-nav-item:hover {
  background: var(--hover-fill);
  color: var(--text-title);
}

.sidebar-nav-item.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.sidebar-nav-icon {
  width: 1rem;
  flex-shrink: 0;
  text-align: center;
  font-size: 0.875rem;
  opacity: 0.85;
}

.sidebar-section {
  padding: 0.35rem 0.5rem 0.5rem;
  border-top: 1px solid var(--border);
  margin-top: 0.25rem;
}

.sidebar-section-title {
  margin: 0.35rem 0.5rem 0.25rem;
  font-size: 0.6875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

.sidebar-recent-list {
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
  max-height: 11rem;
  overflow-y: auto;
}

.sidebar-recent-item {
  display: block;
  width: 100%;
  padding: 0.35rem 0.55rem;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-body);
  font: inherit;
  font-size: 0.75rem;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-recent-item:hover {
  background: var(--hover-fill);
  color: var(--text-title);
}

.sidebar-recent-item time {
  display: block;
  font-size: 0.6875rem;
  color: var(--text-muted);
  margin-top: 0.1rem;
}

.sidebar-recent-empty {
  margin: 0.25rem 0.55rem;
  font-size: 0.75rem;
  color: var(--text-muted);
}

.sidebar-stepper-wrap.hidden {
  display: none;
}

.sidebar-stepper-inner {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
  padding: 0 0.25rem 0.35rem;
}

.sidebar-stepper-inner .stepper-step {
  width: 100%;
  padding: 0.35rem 0.55rem;
  font-size: 0.8125rem;
}

.sidebar-stepper-inner .stepper-line {
  display: none;
}

.sidebar-stepper-inner .stepper-dot {
  width: 1.25rem;
  height: 1.25rem;
  font-size: 0.625rem;
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 110;
  background: var(--overlay-scrim);
}

.sidebar-backdrop.visible {
  display: block;
}

.header-sidebar-open {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  margin-right: 0.25rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-body);
  font-size: 1.125rem;
  line-height: 1;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

.header-sidebar-open:hover {
  background: var(--hover-fill);
}

.header-sidebar-open.hidden {
  display: none !important;
}

html[data-chrome="focused"] .header-sidebar-open:not(.hidden) {
  display: inline-flex;
}

.header-nav .nav-header-duplicate {
  display: none;
}

html[data-chrome="focused"] .app-sidebar {
  width: 0;
  border-right: none;
  pointer-events: none;
}

html[data-chrome="hidden"] .app-sidebar,
html.embed-mode:not(.wenjing-embed) .app-sidebar {
  display: none;
}

html[data-chrome="hidden"] .header-sidebar-open,
html.embed-mode .header-sidebar-open {
  display: none !important;
}

html[data-chrome="focused"] .app-main,
html[data-chrome="expanded"] .app-main {
  max-width: none;
  align-self: stretch;
}

html[data-chrome="focused"] .app-main {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

html[data-chrome="expanded"] .auth-banner,
html[data-chrome="focused"] .auth-banner {
  max-width: none;
}

html[data-chrome="hidden"] .app-main {
  max-width: var(--max-width);
  align-self: center;
}

html[data-chrome="hidden"] .page-login,
html[data-chrome="hidden"] .page-register,
html[data-chrome="hidden"] .page-forgot-password,
html[data-chrome="hidden"] .page-reset-password,
html[data-chrome="hidden"] .page-verify-email {
  max-width: 28rem;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .app-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    height: auto;
    max-height: none;
    align-self: auto;
    width: min(var(--sidebar-width), 85vw);
    box-shadow: var(--card-shadow);
    transform: translateX(-100%);
    pointer-events: auto;
  }

  html[data-chrome="expanded"] .app-sidebar {
    transform: translateX(0);
  }

  html[data-chrome="expanded"] .sidebar-backdrop.visible {
    display: block;
  }

  html[data-chrome="focused"] .app-sidebar {
    transform: translateX(-100%);
    width: min(var(--sidebar-width), 85vw);
  }
}

@media (prefers-reduced-motion: reduce) {
  .app-sidebar {
    transition: none;
  }
}
