.sidebar {
  flex: 0 0 360px;
  width: 360px;
  /* An explicit height (rather than relying on the container's align-items:
     stretch) gives the collapse/expand height change a real value to animate
     between instead of snapping to/from `auto`. */
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  box-shadow: 0 0px 30px rgba(210, 210, 210, 0.1);
  transition: flex-basis 0.22s ease, width 0.22s ease, height 0.22s ease;
  background: #3d3d3d;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 12px;
  background: white;
  border-radius: 0;
  flex: 0 0 auto;
}

.sidebar-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #303030;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-toggle {
  width: 36px;
  min-width: 36px;
  height: 36px;
  background: #27272b;
  border: 1px solid var(--panel-border);
  color: var(--text);
  font-size: 1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  cursor: pointer;
}

.sidebar-toggle:hover {
  background: #323236;
}

.sidebar-content {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
}

.sidebar-tabs {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 0 8px;
}

.sidebar-tab {
  flex: 1 1 0;
  position: relative;
  background: rgba(255, 250, 240, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-bottom: none;
  color: var(--text);
  padding: 10px 12px 9px;
  border-radius: 11px 11px 0 0;
  font-size: 0.88rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
  transform: translateY(2px);
  transition: transform 0.14s ease, filter 0.14s ease, border-color 0.14s ease;
}

.sidebar-tab[aria-selected="true"] {
  background: rgba(255, 250, 240, 0.03);
  color: #ffffff;
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(0);
  margin-bottom: -1px;
  z-index: 2;
}

.sidebar-tab[aria-selected="true"]::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  bottom: -3px;
  height: 4px;
  background: rgb(67, 67, 67);
  border-bottom: 1px solid rgb(67, 67, 67);
}

.sidebar-tab[aria-selected="false"] {
  filter: brightness(0.92);
}

.sidebar-tab[aria-selected="false"]:hover {
  transform: translateY(1px);
  filter: brightness(0.98);
}

.sidebar-tab:focus-visible {
  outline: 2px solid rgba(255, 255, 255, 0.55);
  outline-offset: 2px;
}

.sidebar-tab-panels {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  scrollbar-gutter: stable;
  padding: 16px 8px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  background: rgba(255, 250, 240, 0.03);
}

.sidebar-tab-panel {
  display: grid;
  gap: 20px;
  align-content: start;
}

.sidebar-tab-panel[hidden] {
  display: none;
}

.sidebar-divider {
  border: 0;
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  margin: 0;
  height: 0;
  align-self: start;
}

.sidebar.collapsed {
  flex-basis: 64px;
  width: 64px;
  /* Matches the header's own box (padding + toggle button + border) so the
     height transition above has a fixed endpoint to animate to. */
  height: 62px;
}

.sidebar.collapsed .sidebar-content {
  display: none;
}

.sidebar.collapsed .sidebar-title {
  display: none;
}

.sidebar.collapsed .sidebar-header {
  margin-bottom: 0;
}
