/* Sidebar: workspace header, jump box, pinned/recent sections, the tree and its footer. */
.sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface-1);
  border-right: 1px solid var(--line);
}

.side-head {
  display: grid;
  gap: var(--sp-4);
  padding: var(--sp-5) var(--sp-5) var(--sp-4);
}

.ws-title {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-width: 0; /* a grid item: without this a long workspace name widens the row and pushes the menu out */
  min-height: 28px;
}

.ws-title .ibtn {
  flex: none;
}

.ws-title h2 {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.jump {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  height: 32px;
  padding: 0 var(--sp-4);
  border: 1px solid var(--line);
  border-radius: var(--r-md);
  background: var(--surface-2);
  color: var(--text-3);
  text-align: left;
  transition: border-color var(--t-fast), color var(--t-fast);
}

.jump:hover {
  border-color: var(--line-strong);
  color: var(--text-2);
}

.jump span {
  flex: 1;
}

.side-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--sp-3) var(--sp-5);
  overscroll-behavior: contain;
}

.side-section + .side-section {
  margin-top: var(--sp-4);
}

.side-label {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: 26px;
  padding: 0 var(--sp-4);
  color: var(--text-3);
  font-size: var(--fs-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.side-foot {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--line);
}

.side-foot .spacer {
  flex: 1;
}

.side-empty {
  padding: var(--sp-5) var(--sp-4);
  color: var(--text-3);
  line-height: 1.6;
}

.tag-filter {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  margin: 0 var(--sp-2) var(--sp-3);
  color: var(--text-3);
  font-size: var(--fs-sm);
}

.tag-filter .ibtn {
  margin-left: auto;
  width: 24px;
  height: 24px;
}

.recent-list {
  display: grid;
  margin: 0 0 var(--sp-3);
  padding: 0;
  list-style: none;
}

.recent-list a {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: var(--row-h);
  padding: 0 var(--sp-3) 0 calc(var(--sp-2) + 20px);
  border-radius: var(--r-sm);
  color: var(--text-2);
  white-space: nowrap;
}

.recent-list a:hover {
  background: var(--surface-3);
  color: var(--text);
  text-decoration: none;
}

.recent-list span {
  overflow: hidden;
  text-overflow: ellipsis;
}

.recent-list .ico {
  flex: none;
  color: var(--ic, var(--text-3));
}

/* "Recent" can be folded away; its label is the toggle */
.side-toggle {
  width: 100%;
  border-radius: var(--r-sm);
  text-align: left;
  cursor: pointer;
}

.side-toggle:hover {
  color: var(--text-2);
  background: var(--surface-3);
}

.side-toggle .chev {
  width: 12px;
  height: 12px;
  transition: transform var(--t-fast) var(--ease-out);
}

.side-toggle[aria-expanded="true"] .chev {
  transform: rotate(90deg);
}

@media (prefers-reduced-motion: reduce) {
  .side-toggle .chev { transition: none; }
}

/* the drag handle on the sidebar's right edge: 8px to grab, a 2px accent line while hovered or dragged */
.side-resize {
  position: absolute;
  top: 0;
  right: -4px;
  bottom: 0;
  z-index: 5;
  width: 8px;
  cursor: col-resize;
  touch-action: none;
}

.side-resize::after {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 3px;
  width: 2px;
  background: var(--accent);
  opacity: 0;
  transition: opacity 120ms ease;
  content: "";
}

.side-resize:hover::after,
.side-resize:focus-visible::after,
.is-resizing .side-resize::after {
  opacity: 1;
}

.side-resize:focus-visible {
  outline: none;
}

body.is-resizing {
  cursor: col-resize;
  user-select: none;
}

@media (max-width: 900px) {
  .side-resize {
    display: none;
  }
}
