/* ============================================================
   MAIN LAYOUT
   ============================================================ */
#layout {
  display: flex;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  overflow: hidden;
}

/* ============================================================
   SIDEBAR
   ============================================================ */
#sidebar {
  width: 260px;
  min-width: 260px;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  padding: 12px;
  gap: 4px;
  z-index: 2;
  position: relative;
  overflow: hidden;
  transition: width var(--tr-slow), min-width var(--tr-slow);
}

#chatList {
  flex: 1;
  overflow-y: auto;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 4px 0;
}

.chatItem {
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  color: var(--text-2);
  border: 1px solid transparent;
  border-radius: var(--r-sm);
  cursor: pointer;
  font-size: 0.8rem;
  font-family: var(--font-sans);
  text-align: left;
  letter-spacing: 0;
  position: relative;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chatItem:hover {
  background: var(--bg-hover);
  color: var(--text);
}

.chatItem.active {
  background: var(--accent-bg);
  border-color: var(--accent-border);
  color: var(--accent-text);
  font-weight: 500;
}

/* SIDEBAR BOTTOM */
#sidebarBottom {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

/* Groups the previously-flat wall of sidebar buttons into labeled sections */
.sidebarGroupLabel {
  margin-top: 4px;
  font-family: var(--font-sans);
  font-size: 0.6rem;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  font-weight: 600;
  color: var(--text-3);
}
.sidebarGroup {
  display: grid;
  gap: 6px;
}
.sidebarGroupRow,
.sidebarGroupGrid {
  grid-template-columns: 1fr 1fr;
}
.sidebarGroup .secondaryBtn {
  padding: 8px 6px;
  font-size: 0.68rem;
  justify-content: center;
  text-align: center;
}

/* ============================================================
   BUTTONS
   BookWare's pill buttons: a neutral surface by default, the accent
   reserved for the one primary action on screen.
   ============================================================ */
.primaryBtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--accent);
  color: #fff;
  border: 1px solid var(--accent);
  border-radius: var(--r-full);
  padding: 9px 16px;
  min-height: 34px;
  cursor: pointer;
  font-weight: 500;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  letter-spacing: 0.02em;
  text-transform: none;
  white-space: nowrap;
}

.primaryBtn:hover {
  opacity: 0.88;
  transform: translateY(-1px);
}

.primaryBtn:active {
  transform: translateY(0);
  opacity: 0.96;
}

.primaryBtn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
  transform: none;
}

.secondaryBtn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--bg-inset);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  padding: 8px 14px;
  min-height: 34px;
  cursor: pointer;
  font-family: var(--font-sans);
  font-size: 0.75rem;
  font-weight: 500;
  letter-spacing: 0.02em;
  white-space: nowrap;
}

.secondaryBtn:hover {
  border-color: var(--accent-text);
  color: var(--accent-text);
}

.secondaryBtn:active {
  transform: translateY(1px);
}

.primaryBtn:focus-visible,
.secondaryBtn:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   CHAT WINDOW
   ============================================================ */
#chatWindow {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
  z-index: 1;
  min-width: 0;
}

#messages {
  flex: 1;
  padding: 24px 20px;
  overflow-y: auto;
  position: relative;
  z-index: 1;
}
