.sidebar {
  position: relative;
  z-index: 110;
  width: var(--sidebar-width);
  height: 100vh;
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border-right: 1px solid rgba(255, 255, 255, 0.18);
  display: flex;
  flex-direction: column;
  padding: 1.5rem 1.25rem 1.75rem;
  color: var(--color-text);
  box-shadow: 0 6px 24px rgba(45, 60, 115, 0.18);
  overflow: hidden;
}

.sidebar.closed {
  width: 0;
  padding: 0;
  opacity: 0;
  pointer-events: none;
  border-right: none;
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.sidebar-header h2 {
  margin: 0;
  font-size: 1.1rem;
  letter-spacing: 0.02em;
  font-weight: 600;
  color: var(--color-text);
}

.toggle-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 42px;
  height: 42px;
  padding: 0 0.7rem;
  background: rgba(255, 255, 255, 0.16);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--color-muted);
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 6px 14px rgba(45, 60, 115, 0.18);
}

.toggle-button:hover {
  color: var(--color-accent);
  border-color: rgba(125, 167, 242, 0.55);
}

.toggle-button.open {
  color: var(--color-accent);
  border-color: rgba(125, 167, 242, 0.65);
}

.sidebar-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 0.5rem;
  height: 0;
  min-height: 0;
}

.directory-tree {
  display: flex;
  flex-direction: column;
  gap: 0rem;
}

.tree-node {
  user-select: none;
}

.tree-node-content {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.3rem 0.65rem;
  border-radius: 12px;
  color: rgba(31, 42, 68, 0.7);
  cursor: pointer;
  transition: all 0.2s ease;
}

.tree-node-content:hover {
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--color-accent);
  box-shadow: 0 3px 10px rgba(45, 60, 115, 0.16);
}

.tree-node-content.selected {
  background: rgba(255, 255, 255, 0.26);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  color: var(--color-accent);
  font-weight: 600;
  border: 1px solid rgba(255, 255, 255, 0.34);
  box-shadow: 0 4px 14px rgba(125, 167, 242, 0.25);
}

.tree-node-icon {
  font-size: 1rem;
  opacity: 0.9;
  transition: transform 0.2s ease;
}

.tree-node-content.selected .tree-node-icon {
  transform: scale(1.06);
}

.tree-node-children {
  margin-top: 0;
}

.tree-node-name {
  font-weight: 600;
}

.loading,
.error {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.7rem;
  padding: 2.5rem 1rem;
  color: var(--color-muted);
  font-size: 0.9rem;
}

.loading-spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(111, 123, 146, 0.25);
  border-top: 2px solid var(--color-accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.sidebar-backdrop {
  display: none;
}

.sidebar-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 130;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 14px;
  box-shadow: 0 14px 30px rgba(86, 105, 141, 0.18);
}

/* 手机屏 */
@media (max-width: 768px) {
  .sidebar {
    width: var(--sidebar-width-mobile, 280px);
    padding: 0.75rem;
    max-width: calc(100vw - 1rem);
    overflow-x: hidden;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
  }

  .sidebar.closed {
    transform: translateX(-100%);
  }

  .toggle-button {
    top: 0.75rem;
    left: 0.75rem;
    z-index: 1001;
    width: 40px;
    height: 40px;
    font-size: 18px;
  }

  .sidebar-content {
    overflow-x: hidden;
    width: 100%;
  }

  .directory-tree {
    overflow-x: hidden;
    width: 100%;
  }

  .sidebar-header h2 {
    font-size: 1.1rem;
    margin: 0.5rem 0;
  }
}

/* 电脑屏 */
@media (min-width: 769px) {
  .sidebar {
    position: static;
    transform: none;
    opacity: 1;
    pointer-events: auto;
  }
}
