.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: 272px;
  height: 100%;
  background: var(--sidebar-bg);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid var(--sidebar-border);
  z-index: 100;
  transform: translateX(-100%);
  transition: transform var(--transition-smooth);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  box-shadow: var(--shadow-lg);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 99;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-smooth);
}

.sidebar-overlay.visible {
  opacity: 1;
  pointer-events: auto;
}

/* ── Header ──────────────────────────────────────── */
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 12px;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-header h2 {
  margin: 0;
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dimmed);
}

.sidebar-close {
  background: none;
  border: none;
  color: var(--text-dimmed);
  font-size: 1.25rem;
  cursor: pointer;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background var(--transition-fast), color var(--transition-fast);
  line-height: 1;
  padding: 0;
}

.sidebar-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

/* ── Content ─────────────────────────────────────── */
.sidebar-content {
  flex: 1;
  overflow-y: auto;
  padding: 10px 0 16px;
}

.sidebar-content::-webkit-scrollbar {
  width: 3px;
}
.sidebar-content::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 2px;
}

/* ── Group label ─────────────────────────────────── */
.ws-group-label {
  padding: 14px 16px 5px;
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-dimmed);
  font-weight: 700;
}

/* ── Workspace item ──────────────────────────────── */
.ws-item {
  padding: 9px 14px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 0.86rem;
  font-weight: 500;
  color: var(--text-secondary);
  transition: background var(--transition-fast), color var(--transition-fast);
  margin: 1px 8px;
  border-radius: var(--radius-sm);
}

.ws-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.ws-item.active {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.ws-item .ws-icon {
  color: var(--text-dimmed);
  font-size: 0.8rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
}

.ws-item .ws-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Surface item ────────────────────────────────── */
.surface-item {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 0.83rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition-fast), color var(--transition-fast);
  margin: 1px 8px;
  border-radius: var(--radius-sm);
  position: relative;
}

.surface-item:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.surface-item.active {
  background: linear-gradient(90deg, var(--accent-soft) 0%, transparent 100%);
  color: var(--accent-hover);
  font-weight: 600;
}

/* Left accent bar for active item */
.surface-item.active::before {
  content: '';
  position: absolute;
  left: -8px;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 60%;
  background: var(--accent-gradient);
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
}

.surface-item .surface-icon {
  font-size: 0.75rem;
  width: 16px;
  text-align: center;
  flex-shrink: 0;
  opacity: 0.6;
}

.surface-item.active .surface-icon {
  opacity: 1;
}

/* ── Desktop ─────────────────────────────────────── */
@media (min-width: 1024px) {
  .sidebar {
    position: relative;
    transform: none;
    width: 252px;
    flex-shrink: 0;
    box-shadow: none;
    height: 100vh;
    height: 100dvh;
  }

  .sidebar.open {
    transform: none;
  }

  .sidebar-overlay {
    display: none;
  }

  .sidebar-close {
    display: none;
  }
}

.sidebar-empty {
  padding: 24px 16px;
  text-align: center;
  color: var(--text-dimmed);
  font-size: 0.8rem;
}
