/* Shared sidebar controls, loaded after each page stylesheet. */
#menu {
  display: grid;
  place-items: center;
  flex: none;
  width: 38px;
  height: 38px;
  border: 1px solid #33414b;
  border-radius: 10px;
  background: #0b1419;
  color: #b9c5ce;
  cursor: pointer;
}
#menu:hover {
  color: #ff8a32;
  border-color: #ff8a3266;
}
#menu svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: round;
  stroke-linejoin: round;
}
header .strap {
  margin-right: auto;
}
header .account {
  margin-left: auto;
}
aside,
.canvas {
  transition:
    width 0.2s ease,
    margin-left 0.2s ease,
    transform 0.2s ease;
}
/* Collapse control lives in the sidebar footer; reuses .nav so the rail rules below already cover it. */
.sidebar-collapse {
  position: relative;
  flex: none;
  min-width: 0;
  margin-top: auto;
  padding-inline: 12px;
  gap: 10px;
  border: 1px solid #ffffff14;
  background: #ffffff05;
  color: #b9c5ce;
  font-size: 12px;
  transition:
    color 0.18s,
    border-color 0.18s,
    background 0.18s;
}
.sidebar-collapse:before {
  content: "";
  position: absolute;
  inset: -17px 0 auto;
  height: 1px;
  background: #ffffff10;
}
.sidebar-collapse:hover {
  color: #ff8a32;
  border-color: #ff8a3266;
  background: #ffffff08;
}
.sidebar-collapse .icon {
  width: 20px;
  height: 20px;
  transition: transform 0.2s ease;
}
.sidebar-collapse .nav-label {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
:root:not(.has-panel):not(.sidebar-collapsed) .sidebar-collapse .icon,
.has-panel:not(.panel-closed) .sidebar-collapse .icon {
  transform: scaleX(-1);
}
.sidebar-close {
  display: none;
}
.sidebar-backdrop[hidden] {
  display: none;
}
@media (min-width: 701px) {
  #menu {
    display: none;
  }
  .sidebar-collapsed aside {
    width: 80px;
    padding: 30px 12px;
  }
  .sidebar-collapsed .canvas {
    margin-left: 80px;
  }
  .sidebar-collapsed aside .logo {
    width: 36px;
    height: 36px;
    padding: 0;
    margin-inline: auto;
    overflow: visible;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .sidebar-collapsed aside .logo .logo-full {
    display: none;
  }
  .sidebar-collapsed aside .logo .logo-mark {
    display: block;
    width: 36px;
    height: 36px;
    max-width: none;
    margin: 0 auto;
  }
  .sidebar-collapsed aside .nav {
    width: 48px;
    padding: 12px;
    justify-content: center;
    gap: 0;
    margin-inline: auto;
  }
  .sidebar-collapsed .nav-label,
  .sidebar-collapsed aside .motto {
    display: none;
  }
  :root:not(.sidebar-collapsed) #menu svg path:last-child {
    transform: rotate(180deg);
    transform-origin: 16px 12px;
  }
  .sidebar-backdrop {
    display: none;
  }
}
@media (max-width: 700px) {
  body.nav-open {
    overflow: hidden;
  }
  body aside {
    z-index: 40;
    width: 250px;
    padding-top: 70px;
  }
  body.nav-open aside {
    visibility: visible;
    transform: translateX(0);
  }
  .sidebar-collapse {
    display: none;
  }
  .sidebar-close {
    display: grid;
    place-items: center;
    position: absolute;
    top: 18px;
    right: 17px;
    width: 36px;
    height: 36px;
    border: 1px solid #34434b;
    border-radius: 9px;
    background: #101a20;
    color: #c9d2d9;
    font-size: 25px;
    cursor: pointer;
  }
  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: #0009;
    backdrop-filter: blur(4px);
    border: 0;
    padding: 0;
  }
}
@media (prefers-reduced-motion: reduce) {
  aside,
  .canvas,
  .sidebar-collapse,
  .sidebar-collapse .icon {
    transition: none;
  }
}

/* ---- Side panel (sidepanel.js), Investigation page only ------------------
   As ChatGPT's: the sidebar becomes an icon rail and, beside it, a panel holds the saved
   investigations. Every other page keeps the full sidebar. */
.side-panel {
  display: none;
}
@media (min-width: 701px) {
  .side-panel {
    position: fixed;
    inset: 0 auto 0 80px;
    z-index: 9;
    display: flex;
    flex-direction: column;
    width: 264px;
    border-right: 1px solid var(--edge);
    background: var(--surface-deep);
  }
  .panel-closed .side-panel {
    display: none;
  }
  /* The page makes room for the docked panel. */
  .has-panel:not(.panel-closed) .canvas {
    margin-left: 344px;
  }
  /* Peek: hovering the current page's rail icon while the panel is closed floats it over the page. */
  .panel-closed.panel-peek .side-panel {
    display: flex;
    z-index: 20;
    box-shadow: var(--el-3);
  }
}
/* Between 701 and 1100px the panel still makes room rather than floating over the page: floating, it covered
   the composer's agent and model pickers. It opens closed there and closes on a click elsewhere (sidebar.js),
   so the narrower chat column only lasts while the reader has it open. */
.side-panel-head {
  display: flex;
  flex: none;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 26px 12px 14px 22px;
}
.side-panel-head h2 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
}
.side-panel-toggle {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: var(--r-sm);
  background: none;
  color: var(--muted);
  cursor: pointer;
  transition: background var(--dur-1) var(--ease-out);
}
.side-panel-toggle:hover {
  background: color-mix(in srgb, var(--text) 8%, transparent);
  color: var(--text);
}
.side-panel-toggle .icon {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
}
.side-panel-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 0 12px 16px;
  overflow-y: auto;
  scrollbar-width: thin;
}

/* ---- Saved investigations (chatlist.js) --------------------------------- */
.chats-new {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 40px;
  padding: 0 10px;
  border-radius: var(--r-sm);
  font-size: 13px;
  white-space: nowrap;
  color: var(--text);
  transition: background var(--dur-1) var(--ease-out);
}
.chats-new:hover {
  background: color-mix(in srgb, var(--text) 7%, transparent);
}
.chats-new .icon {
  flex: none;
  width: 18px;
  height: 18px;
}
.chats-search {
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  min-height: 36px;
  margin-top: 8px;
  padding: 0 10px;
  border: 1px solid var(--edge);
  border-radius: var(--r-sm);
  color: var(--ink-subtle);
  transition: border-color var(--dur-1) var(--ease-out);
}
.chats-search:focus-within {
  border-color: var(--ember);
  box-shadow: 0 0 0 1px var(--ember);
}
.chats-search input:focus-visible { outline: none; box-shadow: none; }
.chats-search .icon {
  flex: none;
  width: 16px;
  height: 16px;
}
.chats-search input {
  flex: 1;
  align-self: stretch;
  min-width: 0;
  border: 0;
  background: none;
  font-size: 13px;
  color: var(--text);
}
.chats-group h3 {
  margin: 16px 10px 6px;
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--ink-subtle);
}
.chats-group ul {
  margin: 0;
  padding: 0;
  list-style: none;
}
.chat-row {
  display: flex;
  align-items: center;
  border-radius: var(--r-sm);
  transition: background var(--dur-1) var(--ease-out);
}
.chat-row:hover,
.chat-row:focus-within {
  background: color-mix(in srgb, var(--text) 7%, transparent);
}
.chat-row.is-current {
  background: color-mix(in srgb, var(--ember) 14%, transparent);
}
.chat-link {
  flex: 1;
  min-width: 0;
  padding: 9px 10px;
  overflow: hidden;
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
}
.chat-row:hover .chat-link,
.chat-row.is-current .chat-link {
  color: var(--text);
}
/* The menu button shows on hover, on focus, for the open chat and while its menu is open,
   and always on a screen with no hover, so a tap can reach it. */
.chat-more {
  display: grid;
  flex: none;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-right: 4px;
  border: 0;
  border-radius: var(--r-xs);
  background: none;
  color: var(--muted);
  opacity: 0;
  cursor: pointer;
}
.chat-row:hover .chat-more,
.chat-row:focus-within .chat-more,
.chat-row.is-current .chat-more,
.chat-more[aria-expanded='true'] {
  opacity: 1;
}
@media (hover: none) {
  .chat-more {
    opacity: 1;
  }
}
.chat-more:hover {
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text);
}
.chat-more .icon {
  width: 16px;
  height: 16px;
}
.chat-menu {
  position: fixed;
  z-index: 40;
  min-width: 168px;
  padding: 6px;
  border: 1px solid var(--edge-strong);
  border-radius: var(--r-md);
  background: var(--surface-raised);
  box-shadow: var(--el-3);
}
.chat-menu-item {
  display: block;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: var(--r-xs);
  background: none;
  font-size: 13px;
  text-align: left;
  color: var(--text);
  cursor: pointer;
}
.chat-menu-item:hover,
.chat-menu-item:focus-visible {
  background: color-mix(in srgb, var(--text) 8%, transparent);
}
.chat-menu-item.is-danger {
  color: var(--danger);
}
/* The shared empty state is a large dashed panel; in the sidebar it is a compact note. */
.chats-empty .empty-state {
  margin-top: 12px;
  padding: 14px 12px;
  border-radius: var(--r-sm);
}
.chats-empty .empty-state strong {
  font-size: 13px;
}
.chats-empty .empty-state p {
  font-size: 12px;
}
.chat-rename {
  width: 100%;
  margin-top: 4px;
  padding: 10px 12px;
  border: 1px solid var(--edge-strong);
  border-radius: var(--r-sm);
  background: var(--surface-deep);
  font-size: 14px;
  color: var(--text);
}
.chat-dialog .subtle {
  margin-left: 10px;
}

/* Phone (Investigation page): the drawer holds the nav and, under it, the chat history. */
@media (max-width: 700px) {
  #sidebar .chats {
    display: flex;
    flex: 1 1 0;
    flex-direction: column;
    min-height: 0;
    margin-top: 14px;
  }
  #sidebar .chats-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
  }
  .has-panel #sidebar nav {
    gap: 2px;
  }
  .has-panel #sidebar .nav {
    min-height: 40px;
    padding-block: 9px;
  }
  .has-panel #sidebar .motto {
    display: none;
  }
}

/* A chat asked but not yet saved: shown at once, quieter than saved ones, with no menu. */
.chat-row.is-pending .chat-link {
  color: var(--muted);
}
