.sidebar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 16px 12px 10px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border-soft);
  min-height: 0;
  overflow: hidden;
}
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 3px;
  background: var(--bg-deep);
  border-radius: var(--radius-sm);
}
.segmented__btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  transition: background 120ms ease, color 120ms ease;
}
.segmented__btn.is-active {
  background: var(--bg-raised);
  color: var(--text);
}
.segmented__btn [data-icon] { opacity: 0.8; }
.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-raised);
  color: var(--text);
  font-size: 14px;
  transition: background 120ms ease;
}
.new-chat:hover { background: var(--bg-hover-strong); }
.new-chat [data-icon] { color: var(--text-muted); }
.sidebar__section { padding: 16px 12px 6px; }
.sidebar__label {
  color: var(--text-faint);
  font-size: 12px;
  letter-spacing: 0.02em;
}
.chat-list {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
  min-height: 0;
}
.chat-item {
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: 14px;
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}
.chat-item:hover { background: var(--bg-hover-solid); color: var(--text); }
.chat-item.is-active { background: var(--bg-raised); color: var(--text); }
/*
 * The dot is a status light, not a selection marker. Selection is already
 * carried by the row's background, so spending the dot on it too said nothing
 * about what any conversation was actually doing.
 */
.chat-item__bullet {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  border: 1px solid var(--text);
  background: transparent;
  flex: none;
  transition: background 160ms ease, border-color 160ms ease;
}

/*
 * Working: filled white, breathing.
 *
 * Opacity only, no transform: scaling a 7px dot lands on fractional pixels and
 * snaps between rounded sizes, which is what made the old pulse look choppy.
 * The curve below is a sampled cosine played back linearly, so there is no
 * turnaround stutter at the midpoint or at the loop seam the way a two-stop
 * ease-in-out has.
 */
.chat-item__bullet.is-working {
  background: var(--text);
  border-color: var(--text);
  animation: bullet-pulse 2.6s linear infinite;
  will-change: opacity;
}

/* Blocked on a question: amber, and deliberately not animated so it reads as
   stopped-and-waiting rather than busy. */
.chat-item__bullet.is-waiting {
  background: var(--star);
  border-color: var(--star);
}

@keyframes bullet-pulse {
  0% { opacity: 1.0; }
  5% { opacity: 0.986; }
  10% { opacity: 0.947; }
  15% { opacity: 0.885; }
  20% { opacity: 0.807; }
  25% { opacity: 0.72; }
  30% { opacity: 0.633; }
  35% { opacity: 0.555; }
  40% { opacity: 0.493; }
  45% { opacity: 0.454; }
  50% { opacity: 0.44; }
  55% { opacity: 0.454; }
  60% { opacity: 0.493; }
  65% { opacity: 0.555; }
  70% { opacity: 0.633; }
  75% { opacity: 0.72; }
  80% { opacity: 0.807; }
  85% { opacity: 0.885; }
  90% { opacity: 0.947; }
  95% { opacity: 0.986; }
  100% { opacity: 1.0; }
}

@media (prefers-reduced-motion: reduce) {
  .chat-item__bullet.is-working { animation: none; opacity: 0.85; }
}
.chat-item__title {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-item__delete { opacity: 0; color: var(--text-faint); font-size: 12px; }
.chat-item:hover .chat-item__delete { opacity: 1; }
.chat-item__delete:hover { color: var(--accent); }
.profile {
  position: relative;
  margin-top: 6px;
  padding-top: 8px;
  border-top: 1px solid var(--border-soft);
}
.profile__btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border-radius: var(--radius-sm);
  text-align: left;
  transition: background 120ms ease;
}
.profile__btn:hover { background: var(--bg-hover-solid); }
.avatar {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 6px;
  background: var(--accent);
  color: var(--on-accent);
  font-size: 13px;
  font-weight: 600;
  flex: none;
}
.avatar--lg {
  width: 46px;
  height: 46px;
  border-radius: 10px;
  font-size: 20px;
}
.profile__name {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.profile__menu {
  position: absolute;
  left: 4px;
  right: 4px;
  bottom: calc(100% - 2px);
  padding: 4px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow:
    0 2px 5px rgba(0, 0, 0, 0.48),
    0 6px 13px rgba(0, 0, 0, 0.32),
    0 12px 24px rgba(0, 0, 0, 0.2);
  z-index: 10;
}
.profile__menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 13px;
  text-align: left;
  transition: background 120ms ease, color 120ms ease;
}
.profile__menu-item:hover { background: var(--bg-hover-solid); color: var(--text); }
.profile__menu-item [data-icon] { opacity: 0.8; }
/* Inline rename of the open conversation. */
.chat-item__input {
  flex: 1;
  min-width: 0;
  padding: 2px 7px;
  border: 1px solid var(--accent);
  border-radius: 5px;
  background: var(--bg-hover-solid);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
}
/* The title is the rename target once its conversation is open. */
.chat-item.is-active .chat-item__title { cursor: text; }

/* Resize handle -------------------------------------------------------- */

.sidebar { position: relative; }

.sidebar__resizer {
  position: absolute;
  top: 0;
  right: -3px;
  width: 6px;
  height: 100%;
  cursor: col-resize;
  z-index: 5;
  background: transparent;
  transition: background 120ms ease;
}

.sidebar__resizer:hover,
.sidebar__resizer:focus-visible,
body.is-resizing .sidebar__resizer { background: var(--border-focus); }

/* Held on <body> so the cursor survives the pointer outrunning the handle. */
body.is-resizing { cursor: col-resize; user-select: none; }
body.is-resizing iframe { pointer-events: none; }

/*
 * Long names fade out rather than ending in an ellipsis. At a narrow width an
 * ellipsis truncates every row to near-identical stubs; a fade keeps as many
 * real characters as fit and lets the text trail away.
 */
.chat-item__title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: clip;
  -webkit-mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent 100%);
  mask-image: linear-gradient(to right, #000 calc(100% - 24px), transparent 100%);
}
