.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;
  overflow-x: hidden;
  padding: 10px 0 20px;
}

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

/* ── Group label ─────────────────────────────────── */
.ws-group-label {
  padding: 16px 16px 7px;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  font-weight: 700;
}

.ws-group-label:not(:first-child) {
  margin-top: 6px;
  border-top: 1px solid var(--border-color);
  padding-top: 18px;
}

/* ── Workspace item ──────────────────────────────── */
.ws-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  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.85rem;
  width: 18px;
  text-align: center;
  flex-shrink: 0;
  padding-top: 2px;
}

.ws-item .ws-label,
.surface-item .ws-label {
  flex: 1;
  word-break: break-word;
  overflow-wrap: break-word;
  line-height: 1.45;
}

/* ── Surface item ────────────────────────────────── */
.surface-item {
  padding: 10px 14px;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-primary);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  transition: background var(--transition-fast), color var(--transition-fast);
  margin: 2px 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-status {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  margin-top: 6px;
  background: var(--text-dimmed);
  transition: background 0.3s ease;
}

.surface-status.idle {
  background: var(--yellow);
  opacity: 0.7;
}

.surface-status.working {
  background: var(--green);
  animation: status-pulse 1.8s ease-in-out infinite;
}

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

@keyframes status-pulse {
  0%, 100% {
    opacity: 1;
    box-shadow: 0 0 4px var(--green-glow);
  }
  50% {
    opacity: 0.3;
    box-shadow: 0 0 8px var(--green-glow);
  }
}

/* ── Desktop ─────────────────────────────────────── */
@media (min-width: 1024px) {
  .sidebar {
    position: relative;
    transform: none;
    width: 290px;
    flex-shrink: 0;
    box-shadow: none;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
    transition: width 0.22s ease, border-color 0.22s ease;
  }

  .sidebar.open {
    transform: none;
  }

  .sidebar.desktop-hidden {
    width: 0;
    border-right-color: transparent;
  }

  .sidebar-overlay {
    display: none;
  }

  /* Font sizes smaller on desktop — mobile sizes are larger for touch */
  .ws-group-label { font-size: 0.7rem; padding-top: 14px; }
  .ws-group-label:not(:first-child) { padding-top: 16px; }
  .ws-item        { font-size: 0.86rem; padding: 8px 12px; }
  .surface-item   { font-size: 0.84rem; padding: 8px 12px; margin: 1px 8px; }
}

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