/* layout.css — webchat frame: labelled sidebar (sidebar.js), top bar
 * (top-bar.js), main.
 *
 * Wide screens: the sidebar is docked in the first grid column and there is
 * no top bar; on the conversation page the same element is the conversation's
 * header (its title and status badges) above the reading column. The
 * sidebar's collapse button shrinks it to an icon rail (body.sidebar-rail).
 * Phone width (<= 700px): the top bar holds the menu button that slides the
 * sidebar in over the page as a drawer, and the title of the page shown; the
 * drawer always has its labels.
 */

body {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  overflow: hidden;
}

/* ===== Sidebar ===== */
#sidebar {
  grid-row: 1 / -1;
  grid-column: 1;
  /* The mockup's --side column. */
  width: 228px;
  min-height: 0;
  background: var(--surface-chrome, var(--surface));
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
  z-index: 20;
}

/* Brand block (logo, the workspace's short name, a caption), then the
   workspace picker. */
#sidebar .sidebar-head {
  display: flex; flex-direction: column; align-items: stretch; gap: 14px;
  padding: 22px 14px 2px;
  box-sizing: border-box;
  flex-shrink: 0;
}
#sidebar .sidebar-brand { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 0 8px; }
/* Collapse/expand: next to the brand name; shrinks the sidebar to its rail. */
#sidebar .sidebar-collapse {
  flex: none;
  margin-left: auto;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
#sidebar .sidebar-collapse:hover { background: var(--chip-bg); color: var(--text); }
#sidebar .sidebar-collapse:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
#sidebar .sidebar-logo {
  width: 34px; height: 34px; flex: none;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--chip-bg);
  box-shadow: inset 0 0 0 1px var(--glass-border);
}
#sidebar .sidebar-logo img { width: 24px; height: 24px; object-fit: contain; }
html:not(.light) #sidebar .logo-light, html.light #sidebar .logo-dark { display: none; }
/* The brand block reads "Sherlock" whichever workspace is shown, or the
   workspace's name when there is only one base workspace. */
#sidebar .sidebar-brand-name {
  min-width: 0;
  color: var(--text);
  font-size: 22px; font-weight: 800; line-height: 1.1;
  letter-spacing: -0.02em;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#sidebar .sidebar-workspace { min-width: 0; }
/* One workspace and nothing to pick: the brand block names it. */
#sidebar .sidebar-workspace[hidden] { display: none; }
#sidebar .ws-dropdown { display: block; }
#sidebar .ws-dropdown-trigger {
  width: 100%;
  justify-content: space-between;
  padding: 8px 12px;
  border-radius: var(--radius-md);
  font-size: 14px;
  text-align: left;
}
#sidebar .ws-dropdown-trigger > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
/* The workspace menu opens under the picker, inside the sidebar (which hides
   overflow): it is as wide as the picker and scrolls within the height left
   below it (--ws-menu-top, set by workspace-dropdown.js when it opens). */
#sidebar .ws-dropdown-panel {
  left: 0; right: 0;
  min-width: 0; max-width: none;
  max-height: calc(100dvh - var(--ws-menu-top, 140px) - 12px - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
}

#sidebar .sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  /* The mockup's sidebar: a 4px rhythm, with more room under the button,
     the search and the agent picker. */
  display: flex; flex-direction: column; gap: 4px;
  padding: 16px 14px 12px;
}

#sidebar .new-chat-btn {
  width: 100%;
  flex: none;
  margin-bottom: 8px;
  border: 1px solid transparent;
  border-radius: 13px;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 650;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  transition: all 0.2s ease;
}
#sidebar .new-chat-btn .icon { flex: none; stroke-width: 2.2; }
#sidebar .new-chat-btn:hover { transform: translateY(-1px); }

/* Agent picker: logo, the name with its caption under it, and a chevron;
   opens the agent popover. */
#sidebar .sidebar-agent-slot:not(:empty) { margin-bottom: 10px; }
#sidebar .sidebar-agent {
  width: 100%;
  display: grid; grid-template-columns: auto minmax(0, 1fr) auto; align-items: center; column-gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--bg);
  color: var(--text);
  font: inherit; font-size: 13px;
  cursor: pointer;
  text-align: left;
}
#sidebar .sidebar-agent:hover { border-color: var(--accent); }
#sidebar .sidebar-agent > :first-child { grid-row: 1 / 3; }
#sidebar .sidebar-agent .icon { flex: none; }
#sidebar .sidebar-agent .agent-logo { width: 22px; height: 22px; }
#sidebar .sidebar-agent.is-team { border-color: var(--accent); background: var(--accent-subtle); }
/* Only one agent, nothing to pick: a plain label. */
#sidebar .sidebar-agent.is-fixed { cursor: default; }
#sidebar .sidebar-agent.is-fixed:hover { border-color: var(--border); }
#sidebar .sidebar-agent-caption {
  grid-column: 2; grid-row: 2;
  font-size: 11px; font-weight: 600; line-height: 1.4;
  color: var(--text-dim);
}
#sidebar .sidebar-agent-name {
  grid-column: 2; grid-row: 1;
  min-width: 0;
  font-weight: 700; line-height: 1.4;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#sidebar .sidebar-agent-chevron { grid-column: 3; grid-row: 1 / 3; display: flex; color: var(--text-dim); }
#sidebar .sidebar-agent-chevron .icon { width: 16px; height: 16px; }

/* Section labels: above the pages, and above the recent conversations. */
#sidebar .sidebar-navlabel {
  flex: none;
  padding: 10px 12px 4px;
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-dim);
}

/* Pages: icon, label and count; the page shown is highlighted (ui.css). */
#sidebar .sidebar-pages { display: flex; flex-direction: column; gap: 4px; }
#sidebar .sidebar-page {
  display: flex; align-items: center; gap: 13px;
  padding: 10px 12px;
  border-radius: 13px;
  color: var(--text-dim);
  font-size: 15px; font-weight: 650; line-height: 1.55;
  text-decoration: none;
  position: relative;
  transition: background 0.2s, color 0.2s, box-shadow 0.2s;
}
#sidebar .sidebar-page .icon { flex: none; width: 18px; height: 18px; stroke-width: 1.6; }
#sidebar .sidebar-page-label { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#sidebar .sidebar-count {
  min-width: 22px;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--tone-neutral-bg);
  color: var(--tone-neutral-text);
  font-size: 11px; font-weight: 800; text-align: center;
}
#sidebar .sidebar-count:empty { display: none; }
/* Conversations has a page entry only in the rail. */
#sidebar .sidebar-page.rail-only { display: none; }

/* The latest conversations, titled Conversations, ending with the link to
   the Conversations page. */
#sidebar .sidebar-recent { display: flex; flex-direction: column; min-width: 0; }
#sidebar .sidebar-recent-head {
  display: flex; align-items: center; gap: 8px;
  margin: 0;
  padding: 10px 12px 2px;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em;
  color: var(--text-dim);
  white-space: nowrap;
}
#sidebar .sidebar-recent-head .sidebar-count { letter-spacing: 0; }
#sidebar .sidebar-show-all {
  display: block;
  margin-top: 2px;
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: 13px; font-weight: 700;
  text-decoration: none;
}
#sidebar .sidebar-show-all:hover { background: var(--chip-bg); }
#sidebar .sidebar-show-all.active { background: var(--accent-subtle); }
#sidebar .sidebar-show-all:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

/* Account: one row (initials and the full name) that opens the account menu. */
#sidebar .sidebar-foot {
  position: relative;
  padding: 8px 10px;
  padding-bottom: calc(8px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
#sidebar .sidebar-account {
  width: 100%;
  display: flex; align-items: center; gap: 8px;
  padding: 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
#sidebar .sidebar-account:hover,
#sidebar .sidebar-account[aria-expanded="true"] { background: var(--chip-bg); }
#sidebar .sidebar-account:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
/* 13px semibold so a typical name or e-mail fits the 228px mockup sidebar. */
#sidebar .sidebar-account .sidebar-user-name { flex: 1; font-size: 13px; font-weight: 650; }
#sidebar .sidebar-account-chevron { display: flex; flex: none; color: var(--text-dim); transform: rotate(180deg); }
#sidebar .sidebar-avatar {
  width: 30px; height: 30px; flex: none;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: var(--accent-subtle);
  color: var(--accent);
  font-size: 12px; font-weight: 800; letter-spacing: 0.02em;
}
#sidebar .sidebar-user-name {
  min-width: 0;
  font-size: 14px; font-weight: 700;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* The account menu: fixed (sidebar.js places it above the account row), so it
   reaches past the rail's width. */
#sidebar .account-menu {
  position: fixed;
  z-index: 60;
  box-sizing: border-box;
  padding: 6px;
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}
#sidebar .account-menu[hidden] { display: none; }
#sidebar .account-menu-who {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 10px 10px;
  margin-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
#sidebar .account-menu-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
/* The menu shows the whole name, on as many lines as it takes. */
#sidebar .account-menu-who .sidebar-user-name { white-space: normal; overflow-wrap: anywhere; }
#sidebar .account-menu-version { color: var(--text-dim); font-size: 12px; }
#sidebar .account-menu-items { display: flex; flex-direction: column; gap: 2px; }
#sidebar .account-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%;
  box-sizing: border-box;
  padding: 9px 10px;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text);
  font: inherit; font-size: 14px; font-weight: 600;
  text-align: left; text-decoration: none;
  cursor: pointer;
}
#sidebar .account-menu-item .icon { flex: none; color: var(--text-dim); }
/* The theme item shows the theme it switches to: the sun in the dark theme. */
#sidebar .theme-icon-sun, #sidebar .theme-icon-moon { display: flex; flex: none; }
html.light #sidebar .theme-icon-sun, html:not(.light) #sidebar .theme-icon-moon { display: none; }
#sidebar .account-menu-item:hover,
#sidebar .account-menu-item:focus-visible { background: var(--chip-bg); color: var(--accent); outline: none; }
#sidebar .account-menu-item:hover .icon,
#sidebar .account-menu-item:focus-visible .icon { color: var(--accent); }

/* Tooltips of the rail's icons (sidebar.js), next to the icon. */
.sidebar-tooltip {
  position: fixed;
  z-index: 70;
  max-width: 260px;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  font-size: 12px; font-weight: 700;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
  box-shadow: var(--shadow-md);
}
.sidebar-tooltip[data-side="right"] { transform: translateY(-50%); }
.sidebar-tooltip[data-side="below"] { transform: translateX(-50%); }
.sidebar-tooltip[hidden] { display: none; }

#sidebar .session-list {
  display: flex; flex-direction: column; gap: 2px;
  margin-top: 2px;
  padding: 0;
}
/* Recent conversations: one line each, the start of the title cut off with an
   ellipsis; the row's tooltip has the whole title. */
#sidebar .session-item {
  display: block; width: 100%; text-align: left;
  box-sizing: border-box;
  text-decoration: none;
  background: transparent; border: none;
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--text-secondary);
  cursor: pointer;
  position: relative;
  font-family: inherit;
}
#sidebar .session-item:hover { background: var(--chip-bg); color: var(--text); }
#sidebar .session-item.active { background: var(--chip-bg-hover); color: var(--text); }
#sidebar .session-title {
  display: block;
  font-size: 13px;
  font-weight: 500;
  line-height: 1.55;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: inherit;
}
/* Delete button — hidden by default, revealed on hover */
#sidebar .session-delete {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: var(--surface, #fff);
  border: 1px solid var(--border, #ddd);
  opacity: 0;
  pointer-events: none;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
  color: var(--text-dim);
  user-select: none;
  white-space: nowrap;
  z-index: 1;
}
#sidebar .session-delete.reveal {
  opacity: 1;
  pointer-events: auto;
}
#sidebar .session-delete:hover {
  background: var(--btn-danger-bg);
  border-color: var(--btn-danger-border);
  color: var(--btn-danger-text);
}
#sidebar .session-delete .confirm-tooltip {
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: #333;
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  padding: 3px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  animation: tooltip-in 0.15s ease;
}
#sidebar .session-delete .confirm-tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  right: 10px;
  border: 4px solid transparent;
  border-top-color: #333;
}
@keyframes tooltip-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}
#sidebar .session-delete[data-confirm="1"] {
  opacity: 1;
  pointer-events: auto;
  width: auto;
  padding: 0 8px;
  background: var(--btn-danger-bg-hover);
  box-shadow: 0 0 0 2px var(--surface);
  color: var(--btn-danger-text-hover);
  font-size: 11px;
  font-weight: 600;
  overflow: visible;
}

#sidebar .session-empty {
  padding: 16px 10px;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
  text-align: center;
}

/* ===== Agent logos (agent-logos.js) =====
   A tile with the company's mark, or the agent's initial. The one-colour marks
   use the text colour, so they read in both themes. */
.agent-logo {
  width: 24px; height: 24px; flex: none;
  display: inline-grid; place-items: center;
  box-sizing: border-box;
  border-radius: var(--radius-sm);
  background: var(--chip-bg);
  box-shadow: inset 0 0 0 1px var(--glass-border);
  color: var(--text);
  line-height: 1;
}
.agent-logo svg { width: 15px; height: 15px; display: block; }
/* Claude's darker orange (#C15F3C) on the light theme: #D97757 is below 3:1
   against the light tile. */
html.light .agent-logo .mark-claude { fill: #C15F3C; }
.agent-logo-initial::before {
  content: attr(data-initial);
  color: var(--text-secondary);
  font-size: 12px; font-weight: 800;
}

/* ===== Agent popover ===== */
.agent-popover {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 4px;
  min-width: 160px;
  z-index: 50;
}
.agent-popover button {
  display: block; width: 100%; text-align: left;
  background: transparent; border: none;
  padding: 8px 12px;
  color: var(--text); font-family: inherit; font-size: 13px; font-weight: 500;
  border-radius: var(--radius-sm);
  cursor: pointer;
}
.agent-popover button:hover { background: var(--chip-bg); color: var(--accent); }
.agent-popover button.active { background: var(--accent-subtle); color: var(--accent); }
.agent-popover button.agent-option { display: flex; align-items: center; gap: 10px; }
.agent-popover .agent-option-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-popover button.unavailable {
  color: var(--text-secondary); cursor: not-allowed;
}
.agent-popover button.unavailable .agent-logo { opacity: 0.55; }
.agent-popover button.unavailable:hover { background: transparent; color: var(--text-secondary); }
.agent-popover .agent-unavail-tag {
  font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.03em;
  padding: 2px 6px; border-radius: 999px;
  background: var(--chip-bg-hover);
  border: 1px solid color-mix(in srgb, var(--text-secondary) 28%, transparent);
  color: var(--text-secondary);
}
.agent-popover button.team.has-unavailable { opacity: 0.85; }

/* ===== Top bar (phones) and conversation header (wider screens) ===== */
#top-bar {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 16px;
  min-height: 52px;
  box-sizing: border-box;
  min-width: 0;
  background: var(--surface-chrome, var(--surface));
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}
#top-bar .topbar-left {
  display: flex; align-items: center; gap: 10px;
  min-width: 0;
}
#top-bar .topbar-right {
  display: flex; align-items: center; gap: 8px;
  margin-left: auto;
  flex-shrink: 0;
}
#top-bar .topbar-menu {
  display: flex; align-items: center; justify-content: center;
  width: 36px; height: 36px;
  padding: 0;
  flex: none;
}
#top-bar .topbar-title {
  font-size: 16px; font-weight: 800;
  color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  min-width: 0;
}
#top-bar button:not(.pty-badge) {
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
}

/* ===== Icon rail (wider screens): the sidebar collapsed by its button. =====
   Icons only, in the sidebar's order; labels are visually hidden (screen
   readers still read them) and shown as tooltips. */
@media (min-width: 701px) {
  body.sidebar-animate #sidebar { transition: width 0.2s ease; }
  body.sidebar-rail #sidebar { width: 68px; }
  body.sidebar-rail #sidebar .sidebar-head { padding: 16px 10px 4px; align-items: center; }
  body.sidebar-rail #sidebar .sidebar-brand { flex-direction: column; gap: 10px; padding: 0; }
  body.sidebar-rail #sidebar .sidebar-collapse { margin-left: 0; }
  body.sidebar-rail #sidebar .sidebar-brand-name,
  body.sidebar-rail #sidebar .sidebar-workspace,
  body.sidebar-rail #sidebar .sidebar-recent,
  body.sidebar-rail #sidebar .sidebar-search-key,
  body.sidebar-rail #sidebar .sidebar-agent-caption,
  body.sidebar-rail #sidebar .sidebar-agent-chevron,
  body.sidebar-rail #sidebar .sidebar-account-chevron,
  body.sidebar-rail #sidebar .sidebar-page .sidebar-count { display: none; }
  body.sidebar-rail #sidebar .new-chat-label,
  body.sidebar-rail #sidebar .sidebar-search-label,
  body.sidebar-rail #sidebar .sidebar-agent-name,
  body.sidebar-rail #sidebar .sidebar-page-label,
  body.sidebar-rail #sidebar .sidebar-account .sidebar-user-name {
    position: absolute;
    width: 1px; height: 1px;
    margin: -1px; padding: 0;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
  }
  body.sidebar-rail #sidebar .sidebar-scroll { padding: 12px 10px; align-items: center; gap: 8px; overflow-x: hidden; }
  body.sidebar-rail #sidebar .new-chat-btn,
  body.sidebar-rail #sidebar .sidebar-search,
  body.sidebar-rail #sidebar .sidebar-agent,
  body.sidebar-rail #sidebar .sidebar-page {
    width: 44px; height: 44px;
    padding: 0;
    justify-content: center;
    box-sizing: border-box;
  }
  body.sidebar-rail #sidebar .sidebar-pages { margin-top: 0; }
  body.sidebar-rail #sidebar .sidebar-page.rail-only { display: flex; }
  body.sidebar-rail #sidebar .sidebar-foot { padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); display: flex; justify-content: center; }
  body.sidebar-rail #sidebar .sidebar-account { width: 44px; height: 44px; padding: 0; justify-content: center; }
}

@media (min-width: 701px) {
  /* No top bar: the sidebar is always there and each page has its own
     title. */
  body:not(.section-chat) #top-bar { display: none; }
  #top-bar .topbar-menu { display: none; }

  /* The conversation page: its title is in its own header (chat-head.js),
     so the top bar shows only a team's or the PTY badge, lined up with the
     reading column, and nothing when neither is shown. */
  body.section-chat #top-bar .topbar-left { display: none; }
  body.section-chat #top-bar:not(:has(.topbar-right > :not([hidden]))) { display: none; }
  body.section-chat #top-bar {
    min-height: 0;
    padding: 16px max(24px, calc((100% - var(--chat-max)) / 2)) 0;
    background: transparent;
    border-bottom: none;
    box-shadow: none;
  }
  body.section-chat #top-bar .topbar-right { margin-left: 0; flex-wrap: wrap; }
}
@media (max-width: 700px) {
  /* Phones: the open conversation's header names it, so the top bar does not
     name it again. */
  body.section-chat:has(#messages .msg.user) #top-bar .topbar-title { display: none; }
}

/* ===== Main content ===== */
#main {
  grid-row: 2;
  grid-column: 2;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
body.section-workspaces #workspacesPanel { display: block; }
body.section-tools #toolsPanel { display: block; }
body.section-tools #messages,
body.section-tools #inputArea { display: none; }
#toolsPanel { display: none; }

/* Shown when the server cannot be reached at boot (main.js showBootError):
   the message and Retry, a primary button (ui.css .btn-primary) at the size it
   has always had (its 1px border is inside the 8px x 20px of before). */
.boot-error {
  margin: auto;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  color: var(--text-dim);
  text-align: center;
}
.boot-error-retry.btn-primary { padding: 7px 19px; font-weight: 700; }

/* Shown when a conversation link cannot be opened. */
.conversation-not-found {
  margin: auto;
  max-width: 460px;
  padding: 24px;
  text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.conversation-not-found h2 { margin: 0; font-size: 20px; color: var(--text); }
.conversation-not-found p { margin: 0; color: var(--text-dim); font-size: 14px; }

/* ===== Responsive ===== */
/* Drawer backdrop — inert until the phone breakpoint activates it. */
.sidebar-backdrop { display: none; }

@media (max-width: 700px) {
  body { grid-template-columns: 0 minmax(0, 1fr); }
  #top-bar { padding: 0 10px; gap: 8px; }

  /* The sidebar becomes a drawer over the page, opened by the top bar's menu
     button (sidebar.js toggleSidebar). */
  #sidebar {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: min(300px, 86vw);
    padding-top: env(safe-area-inset-top);
    transform: translateX(-100%);
    /* visibility keeps the closed drawer out of the tab order; its delay
       lets the slide-out finish before it hides. */
    transition: transform 0.25s ease, visibility 0.25s;
    box-shadow: var(--shadow-lg);
    z-index: 40;
    visibility: hidden;
  }
  body.drawer-open #sidebar { transform: translateX(0); visibility: visible; }

  .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: var(--modal-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
    z-index: 39;
  }
  body.drawer-open .sidebar-backdrop { opacity: 1; pointer-events: auto; }
  /* The drawer always has its labels: no collapse button there. */
  #sidebar .sidebar-collapse { display: none; }

}
@media (max-width: 520px) {
  /* Prevent iOS Safari from auto-zooming (and shifting the layout) when the
     message field is focused — inputs under 16px trigger the zoom. */
  .input-row textarea { font-size: max(16px, calc(16px * var(--font-scale))); }
}

/* ===== Search: opens the quick search window (quick-search.css) ===== */
#sidebar .sidebar-search {
  width: 100%;
  flex: none;
  margin-bottom: 10px;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--field-border);
  border-radius: var(--radius-md);
  background: var(--field-bg);
  color: var(--field-placeholder);
  font: inherit; font-size: 14px;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s ease;
}
#sidebar .sidebar-search:hover { border-color: var(--field-border-hover); }
#sidebar .sidebar-search:focus-visible { outline: none; border-color: var(--field-focus-border); box-shadow: var(--field-focus-ring); }
#sidebar .sidebar-search .icon { flex: none; width: 16px; height: 16px; }
#sidebar .sidebar-search-label { flex: 1; min-width: 0; }
#sidebar .sidebar-search-key {
  flex: none;
  padding: 1px 6px;
  border: 1px solid var(--tone-neutral-ring);
  border-radius: 5px;
  background: var(--tone-neutral-bg);
  color: var(--tone-neutral-text);
  font: inherit; font-size: 11px; font-weight: 700;
}
