#sidebar {
  width: var(--sb-open);
  min-width: var(--sb-open);
  height: 100vh;
  height: 100dvh;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition:
    width var(--t) var(--ease),
    min-width var(--t) var(--ease),
    background var(--t) var(--ease);
  flex-shrink: 0;
  z-index: 10;
}

#sidebar.collapsed {
  width: var(--sb-closed);
  min-width: var(--sb-closed);
}

.sb-header {
  padding: 14px 12px 8px;
  flex-shrink: 0;
}

.sb-new-chat {
  padding: 0 10px 4px;
  flex-shrink: 0;
}

.new-chat-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--r-pill);
  background: var(--iris);
  color: #fff;
  font-size: 14px;
  font-weight: 500;
  transition: background var(--t) var(--ease), transform .12s;
  white-space: nowrap;
  overflow: hidden;
}

.new-chat-btn:hover { background: color-mix(in srgb, var(--iris) 82%, #000); }
.new-chat-btn:active { transform: scale(.97); }

.new-chat-btn .material-symbols-outlined { font-size: 20px; flex-shrink: 0; }

.sb-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 8px 10px 0;
}

.sb-section-title {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px;
  color: var(--text-3);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  margin-bottom: 4px;
  flex-shrink: 0;
}

.sb-section-title .material-symbols-outlined { font-size: 18px; flex-shrink: 0; }

.chat-list-wrap {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.chat-list-wrap::-webkit-scrollbar { width: 3px; }
.chat-list-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.chat-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.chat-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border-radius: var(--r);
  cursor: pointer;
  transition: background var(--t) var(--ease);
}

.chat-item:hover { background: var(--surface-hover); }

.chat-item.active {
  background: var(--iris-dim);
}

.chat-item.active .ci-title { color: var(--iris); font-weight: 500; }

.ci-icon {
  font-size: 18px;
  color: var(--text-3);
  flex-shrink: 0;
}

.ci-title {
  flex: 1;
  font-size: 13.5px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ci-edit,
.ci-delete {
  opacity: 0;
  color: var(--text-3);
  border-radius: 6px;
  padding: 2px;
  flex-shrink: 0;
  transition: opacity .15s, color .15s, background .15s;
  display: flex; align-items: center;
}

.ci-edit .material-symbols-outlined,
.ci-delete .material-symbols-outlined { font-size: 16px; }

.chat-item:hover .ci-edit,
.chat-item:hover .ci-delete { opacity: 1; }

.ci-edit:hover {
  color: var(--iris);
  background: var(--iris-dim);
}

.ci-delete:hover {
  color: var(--danger);
  background: var(--danger-dim);
}

.ci-title-input {
  flex: 1;
  font-size: 13.5px;
  font-family: inherit;
  color: var(--text);
  background: var(--bg-main);
  border: 1.5px solid var(--iris);
  border-radius: 6px;
  padding: 3px 7px;
  outline: none;
  min-width: 0;
}

.chat-empty {
  font-size: 13px;
  color: var(--text-3);
  text-align: center;
  padding: 20px 8px;
}

.sb-footer {
  border-top: 1px solid var(--border);
  padding: 12px;
  display: flex;
  justify-content: center;
  flex-shrink: 0;
}

#sidebar.collapsed .sb-label { display: none; }

#sidebar.collapsed .new-chat-btn {
  border-radius: var(--r);
  padding: 9px;
  width: 40px;
  justify-content: center;
}

#sidebar.collapsed .sb-section-title { display: none; }
#sidebar.collapsed .chat-list-wrap   { display: none; }

#sidebar.collapsed .sb-new-chat { padding: 0 12px 4px; }
#sidebar.collapsed .sb-section  { padding: 8px 12px 0; }
