.sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  background: var(--surface);
  border-right: 1px solid var(--border);
  padding: 12px 10px 32px;
}

.sidebar__tools {
  display: flex;
  gap: 6px;
  padding: 0 4px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.sidebar__tools button {
  flex: 1;
  font-size: 12.5px;
  padding: 4px 0;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--muted);
}

.sidebar__tools button:hover {
  background: var(--surface-2);
}

.stree,
.stree ul {
  list-style: none;
}

.stree ul {
  margin-left: 13px;
  padding-left: 6px;
  border-left: 1px solid var(--border);
}

.stree__row {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 0;
  border-radius: 6px;
  font-size: 13.5px;
  line-height: 1.5;
}

.stree__row:hover {
  background: var(--surface-2);
}

.stree__row.is-active {
  background: var(--accent-soft);
}

.stree__row.is-active .stree__link {
  color: var(--accent);
  font-weight: 600;
}

.stree__row.is-trail .stree__link {
  font-weight: 600;
}

.stree__row--root {
  padding-left: 8px;
  margin-bottom: 2px;
}

.stree__caret {
  flex: none;
  width: 20px;
  height: 20px;
  border: 0;
  background: none;
  color: var(--faint);
  font-size: 11px;
  border-radius: 4px;
  transition: transform 0.15s ease;
}

.stree__caret:hover {
  background: var(--border);
}

.stree__caret.is-open {
  transform: rotate(90deg);
}

.stree__caret--none {
  display: inline-block;
}

.stree__link {
  flex: 1;
  min-width: 0;
  color: var(--text);
  padding: 3px 0;
}

.stree__link:hover {
  text-decoration: none;
  color: var(--accent);
}

.stree__count {
  flex: none;
  font-size: 11.5px;
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

/* 窄屏：侧栏变成抽屉 */
@media (max-width: 900px) {
  .sidebar {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 0;
    width: min(85vw, var(--sidebar-w));
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    z-index: 15;
    height: auto;
    box-shadow: var(--shadow-lg);
  }

  .nav-open .sidebar {
    transform: none;
  }
}
