.app-shell {
  --app-sidepanel-width: 35rem;
  --app-footer-height: 28px;
  position: relative;
  display: grid;
  /* Center gets a hard floor so a wide side panel yields to it instead of
     crushing the composer. The panel track is minmax(0, …) so on narrow
     desktop windows (769px – ~960px) it shrinks below its JS-clamped width
     rather than overflowing the viewport. */
  grid-template-columns: 58px minmax(480px, 1fr) minmax(0, var(--app-sidepanel-width));
  grid-template-rows: var(--chrome-h) minmax(0, 1fr) var(--app-footer-height);
  height: 100dvh;
  background: var(--agent-bg);
}

.app-shell[data-client-preview="true"] {
  /* Topbar plus the 36px client-preview banner. */
  grid-template-rows: calc(var(--chrome-h) + 36px) minmax(0, 1fr) var(--app-footer-height);
}

@media (min-width: 769px) {
  .app-shell[data-panel-mode="expanded"] {
    grid-template-columns: 58px minmax(360px, 1fr) minmax(0, var(--app-sidepanel-width));
  }

  .app-shell[data-panel-mode="focused"] {
    grid-template-columns: 58px 0 minmax(0, 1fr);
  }

  .app-shell[data-panel-mode="focused"] .app-shell__main,
  .app-shell[data-panel-mode="focused"] .app-shell__resize {
    display: none;
  }

  .app-shell[data-panel-mode="focused"][data-layout] #app_sidepanel {
    display: block;
    grid-column: 2 / 4;
  }

  .app-shell[data-layout="chat-right"] .app-shell__main {
    grid-column: 3;
  }

  .app-shell[data-layout="chat-right"] #app_sidepanel {
    grid-column: 2;
  }

  .app-shell[data-right-pane-open="false"] {
    grid-template-columns: 58px minmax(480px, 1fr) 0;
  }

  .app-shell[data-layout="panel-right"][data-right-pane-open="false"] #app_sidepanel,
  .app-shell[data-layout="chat-right"][data-right-pane-open="false"] .app-shell__main,
  .app-shell[data-right-pane-open="false"] .app-shell__resize {
    display: none;
  }
}

/* Slim full-width strip under every pane: contextual help and market-data attribution
   (docs/platform/market-data-port.md — vendor licenses expect it on end-user
   surfaces) plus the sources popover. */
.app-shell__footer {
  position: relative;
  grid-column: 1 / -1;
  grid-row: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 0 14px;
  border-top: 1px solid var(--agent-line);
  background: var(--agent-sunken);
  font-size: 12px;
  color: var(--agent-faint);
}

/* Centered in the viewport (absolute, so the right-aligned sources link
   doesn't skew it); reserves room on both sides so long text ellipsizes
   before touching the link. */
.app-shell__footer-disclaimer {
  position: absolute;
  left: 0;
  right: 0;
  margin-inline: auto;
  width: fit-content;
  max-width: calc(100% - 430px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.app-shell__footer-actions {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.app-shell__help {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--agent-faint);
  font: inherit;
  cursor: pointer;
}

.app-shell__help:hover {
  color: var(--agent-body);
}

.app-shell__help:focus-visible {
  border-radius: 3px;
  outline: 2px solid var(--agent-brand);
  outline-offset: 2px;
}

.app-shell__help-icon {
  width: 15px;
  height: 15px;
}

.market-data-sources {
  position: relative;
}

.market-data-sources > summary {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  list-style: none;
  cursor: pointer;
  color: var(--agent-faint);
}

.market-data-sources > summary::-webkit-details-marker {
  display: none;
}

.market-data-sources > summary:hover {
  color: var(--agent-body);
}

.market-data-sources__logo {
  height: 9px;
  width: auto;
  opacity: 0.55;
  transition: opacity 120ms ease;
}

.market-data-sources > summary:hover .market-data-sources__logo,
.market-data-sources[open] .market-data-sources__logo {
  opacity: 1;
}

.market-data-sources__link {
  text-decoration: underline;
  text-decoration-color: #d6d9de;
  text-underline-offset: 2px;
}

.market-data-sources__popover {
  position: absolute;
  bottom: calc(100% + 10px);
  right: 0;
  z-index: 40;
  width: 320px;
  padding: 14px 16px;
  border: 1px solid var(--agent-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 12px 40px rgba(15, 23, 42, 0.14);
  color: var(--agent-body);
  font-size: 12px;
  line-height: 1.5;
}

.app-shell__resize {
  position: absolute;
  top: var(--chrome-h);
  bottom: var(--app-footer-height);
  right: var(--app-sidepanel-width);
  width: 9px;
  transform: translateX(4px);
  z-index: 5;
  display: flex;
  justify-content: center;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: col-resize;
  touch-action: none;
}

.app-shell__resize::before {
  content: "";
  width: 1px;
  height: 100%;
  background: transparent;
  transition: background 0.12s ease;
}

.app-shell__resize:hover::before,
body.is-resizing-panel .app-shell__resize::before {
  background: #2b5cb8;
}

body.is-resizing-panel {
  cursor: col-resize;
  user-select: none;
}

.app-shell__main {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  background: var(--agent-surface);
  border-left: 1px solid var(--agent-line);
  border-right: 1px solid var(--agent-line);
  /* Center content (home composer, sessions list) sizes to the pane width —
     not the viewport — so padding stays proportional when the side panel is open. */
  container-type: inline-size;
  container-name: center;
}

#app_topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  display: block;
}

.client-preview-banner {
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 0 16px;
  border-bottom: 1px solid #f5d39b;
  background: #fff7e6;
  color: #7c4a03;
  font-size: 12px;
}

.client-preview-banner a {
  color: #7c4a03;
  font-weight: 700;
}

#app_center {
  height: 100%;
  min-height: 0;
  display: block;
}

#app_sidepanel {
  grid-column: 3;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  height: 100%;
  display: block;
  overflow: hidden;
  /* v1-parity panel grey; the seam is .app-shell__main's border-right, so the
     panel paints no border of its own. */
  background: var(--agent-sunken);
  /* Panel content adapts to the panel's own width (resizable 260-720px on
     desktop, full-width on mobile) via @container sidepanel queries. */
  container-type: inline-size;
  container-name: sidepanel;
}

.agent-topbar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--chrome-h);
  padding: 0 16px 0 9px;
  background: #fff;
  border-bottom: 1px solid var(--agent-line);
  color: var(--agent-text);
  z-index: 2;
}

.agent-topbar__left {
  display: flex;
  align-items: center;
  height: 34px;
}

.agent-topbar__brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  height: 32px;
  padding: 6px 8px 6px 10px;
  border-radius: 0.55rem;
  color: var(--agent-text);
}

.agent-topbar__brand:hover,
.agent-topbar__switch:hover,
.agent-topbar__action--ghost:hover,
.agent-topbar__button:hover {
  background: var(--agent-hover);
}

.agent-topbar__home {
  display: inline-grid;
  place-items: center;
  color: #2f8b68;
}

.agent-topbar__home .hi {
  width: 1rem;
  height: 1rem;
}

.agent-topbar__name {
  font-size: var(--chrome-title-size);
  font-weight: 600;
  letter-spacing: -0.01em;
}

.agent-topbar__switch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 34px;
  padding: 8px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--agent-muted);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
}

.agent-topbar__switch svg {
  flex: none;
  width: 18px;
  height: 18px;
}

.agent-topbar__switcher {
  position: static;
}

.agent-topbar__switcher-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.agent-topbar__switcher-panel {
  position: absolute;
  top: 54px;
  left: 14px;
  z-index: 50;
  width: min(340px, calc(100vw - 28px));
  overflow: hidden;
  border: 1px solid var(--agent-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 14px 40px rgb(16 24 40 / 0.16);
  animation: panelIn 0.14s ease both;
}

.agent-topbar__switcher-new-wrap {
  padding: 12px 12px 2px;
}

.agent-topbar__switcher-search-wrap {
  padding: 12px 14px 10px;
  border-bottom: 1px solid var(--agent-line-soft);
}

.agent-topbar__switcher-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 11px;
  border-radius: 9px;
  background: var(--agent-hover);
  color: var(--agent-faint);
}

.agent-topbar__switcher-search svg {
  flex: none;
}

.agent-topbar__switcher-input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  background: transparent;
  color: var(--agent-text);
  font: inherit;
  font-size: 14px;
}

.agent-topbar__switcher-input::-webkit-search-cancel-button {
  appearance: none;
}

.agent-topbar__switcher-list {
  max-height: 340px;
  overflow: auto;
  padding: 6px;
}

.agent-topbar__switcher-section-label {
  padding: 9px 8px 4px;
  color: var(--agent-faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.agent-topbar__switcher-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 8px 8px;
  border-radius: 10px;
  color: var(--agent-text);
}

.agent-topbar__switcher-row:hover,
.agent-topbar__switcher-row.is-active {
  background: var(--agent-hover);
}

.agent-topbar__switcher-row > svg {
  flex: none;
}

.agent-topbar__switcher-row-main {
  min-width: 0;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 7px;
}

.agent-topbar__switcher-row-name {
  min-width: 0;
  overflow: hidden;
  color: var(--agent-text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.agent-topbar__switcher-check {
  flex: none;
  display: inline-flex;
  color: var(--agent-faint);
}

.agent-topbar__switcher-pill {
  flex: none;
  display: inline-flex;
  align-items: center;
  padding: 3px 10px;
  border: 1px solid var(--agent-line);
  border-radius: 999px;
  background: var(--agent-hover);
  color: #606a78;
  font-size: 11px;
  font-weight: 500;
}

.agent-topbar__switcher-pill--private {
  border-color: #ddd7f6;
  background: #f4f1ff;
  color: #6553bd;
}

.agent-topbar__switcher-pill--client {
  border-color: #bde7d2;
  background: #edf9f2;
  color: #237a51;
}

.agent-topbar__switcher-pill--prospect {
  border-color: #f5d9a8;
  background: #fff7e8;
  color: #a15c06;
}

.agent-topbar__switcher-pill--onboarding {
  border-color: #cfdcfb;
  background: #eff4ff;
  color: #3659c9;
}

.agent-topbar__switcher-empty {
  padding: 18px 12px;
  color: var(--agent-faint);
  font-size: 13.5px;
  text-align: center;
}

@keyframes panelIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.agent-topbar__right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.agent-topbar__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.agent-topbar__action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 32px;
  padding: 0 0.75rem;
  border-radius: 8px;
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: filter 0.12s ease, background 0.12s ease;
}

.agent-topbar__action--ghost {
  border: 1px solid var(--agent-line);
  background: #fff;
  color: var(--agent-body);
}

.agent-topbar__action--primary {
  border: 1px solid var(--agent-blue);
  background: var(--agent-blue);
  color: #fff;
}

.agent-topbar__action--primary:hover {
  filter: brightness(0.93);
}

.agent-topbar__new {
  position: relative;
}

.agent-topbar__new-btn {
  gap: 0.35rem;
}

.agent-topbar__new-btn .hi {
  flex: none;
  width: 15px;
  height: 15px;
}

.agent-topbar__new-btn svg:last-child {
  flex: none;
  opacity: 0.85;
}

.agent-topbar__new-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.agent-topbar__new-panel {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 50;
  width: min(292px, calc(100vw - 24px));
  max-height: calc(100dvh - 70px);
  overflow-y: auto;
  padding: 6px;
  border: 1px solid var(--agent-line);
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 14px 40px rgb(16 24 40 / 0.16);
  animation: panelIn 0.14s ease both;
}

.agent-topbar__new-item {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  width: 100%;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--agent-text);
  font: inherit;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.agent-topbar__new-item:hover,
.agent-topbar__new-item:focus-visible {
  outline: none;
  background: var(--agent-hover);
}

.agent-topbar__new-item-icon {
  display: grid;
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 1px;
  place-items: center;
  color: #667085;
}

.agent-topbar__new-item-icon .hi {
  width: 16px;
  height: 16px;
}

.agent-topbar__new-item-copy {
  display: flex;
  min-width: 0;
  flex: 1;
  flex-direction: column;
  gap: 2px;
}

.agent-topbar__new-item-label {
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.2;
}

.agent-topbar__new-item-hint {
  color: var(--agent-muted);
  font-size: 12px;
  font-weight: 400;
  line-height: 1.3;
}

.agent-topbar__new-section-label {
  margin: 5px 7px 3px;
  padding-top: 6px;
  border-top: 1px solid var(--agent-line);
  color: #98a2b3;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.07em;
  line-height: 1.2;
  text-transform: uppercase;
}

.agent-topbar__new-upload {
  display: contents;
}

.agent-topbar__button {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--agent-line);
  border-radius: 0.55rem;
  background: #fff;
  color: var(--agent-muted);
}

.agent-topbar__right-pane-toggle,
.agent-topbar__swap-panes {
  cursor: pointer;
}

.agent-topbar__right-pane-toggle[aria-pressed="true"] {
  border-color: #d8dde5;
  background: var(--agent-hover);
  color: var(--agent-text);
}

.agent-topbar__swap-panes:disabled {
  cursor: default;
  opacity: 0.38;
}

.agent-rail {
  grid-column: 1;
  grid-row: 2;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  width: 58px;
  padding: 12px 0;
  background: #fff;
  border-right: 1px solid var(--agent-line);
}

.agent-rail__top,
.agent-rail__nav,
.agent-rail__bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.agent-rail__icon {
  width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border: 0;
  color: var(--agent-muted);
  background: transparent;
  border-radius: 10px;
  cursor: pointer;
}

.agent-rail__icon svg {
  width: 20px;
  height: 20px;
}

.agent-rail__icon:hover {
  background: var(--agent-hover);
  color: var(--agent-text);
}

.agent-rail__icon.is-active {
  background: var(--agent-hover);
  color: #3659c9;
}

.agent-rail__icon--personal.is-active {
  background: #eef2ff;
  color: #3659c9;
}

.agent-rail__icon--private.is-active {
  background: #f4f1ff;
  color: #6553bd;
}

/* The compact rail is intentionally icon-only, so give destinations a quick,
   polished label without relying on the browser's slow native title bubble. */
.agent-rail__tooltip-target {
  position: relative;
}

.agent-rail__tooltip-target::before,
.agent-rail__tooltip-target::after {
  position: absolute;
  top: 50%;
  z-index: 60;
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.12s ease 0.12s,
    transform 0.12s ease 0.12s,
    visibility 0s linear 0.24s;
}

.agent-rail__tooltip-target::before {
  content: "";
  left: calc(100% + 5px);
  width: 7px;
  height: 7px;
  border-radius: 1px;
  background: #20242b;
  transform: translate(-3px, -50%) rotate(45deg);
}

.agent-rail__tooltip-target::after {
  content: attr(data-rail-tooltip);
  left: calc(100% + 9px);
  padding: 7px 9px;
  border: 1px solid rgb(255 255 255 / 0.1);
  border-radius: 8px;
  background: #20242b;
  box-shadow: 0 6px 18px rgb(16 24 40 / 0.18);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0.01em;
  white-space: nowrap;
  transform: translate(-3px, -50%);
}

.agent-rail__tooltip-target:hover::before,
.agent-rail__tooltip-target:hover::after,
.agent-rail__tooltip-target:focus-visible::before,
.agent-rail__tooltip-target:focus-visible::after {
  visibility: visible;
  opacity: 1;
  transition-delay: 0.12s;
}

.agent-rail__tooltip-target:hover::before,
.agent-rail__tooltip-target:focus-visible::before {
  transform: translate(0, -50%) rotate(45deg);
}

.agent-rail__tooltip-target:hover::after,
.agent-rail__tooltip-target:focus-visible::after {
  transform: translate(0, -50%);
}

.agent-rail__tooltip-target[aria-expanded="true"]::before,
.agent-rail__tooltip-target[aria-expanded="true"]::after {
  display: none;
}

.agent-rail__history {
  position: relative;
}

.agent-rail__history::after {
  content: "";
  position: fixed;
  top: var(--chrome-h);
  left: 58px;
  z-index: 49;
  display: none;
  width: 12px;
  height: calc(100vh - var(--chrome-h) - 20px);
}

.agent-rail__history:hover > .agent-rail__icon,
.agent-rail__history:focus-within > .agent-rail__icon {
  background: var(--agent-hover);
  color: var(--agent-text);
}

.agent-rail__history > .agent-rail__icon:focus-visible {
  outline: 2px solid #d4d7dd;
  outline-offset: 1px;
}

.agent-rail__history:hover::after,
.agent-rail__history:focus-within::after {
  display: block;
}

.agent-history-flyout {
  position: fixed;
  top: 60px;
  left: 66px;
  z-index: 50;
  width: 360px;
  max-height: calc(100vh - 80px);
  display: flex;
  flex-direction: column;
  visibility: hidden;
  opacity: 0;
  overflow: hidden;
  border: 1px solid var(--agent-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 44px rgb(16 24 40 / 0.18);
  transform: translateY(-4px);
  transition:
    opacity 0.08s ease 0.22s,
    transform 0.08s ease 0.22s,
    visibility 0s linear 0.3s;
}

.agent-rail__history:hover .agent-history-flyout,
.agent-rail__history:focus-within .agent-history-flyout {
  visibility: visible;
  opacity: 1;
  transform: translateY(0);
  transition-delay: 0s;
}

.agent-history-flyout__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex: none;
  padding: 13px 14px 11px;
  border-bottom: 1px solid var(--agent-line-soft);
}

.agent-history-flyout__title {
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--agent-text);
  font-size: 14px;
  font-weight: 600;
}

.agent-history-flyout__body {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px;
}

.agent-history-flyout__section-heading {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px 5px;
  color: var(--agent-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.agent-history-flyout__section-heading--other {
  margin-top: 6px;
  padding-top: 14px;
  border-top: 1px solid var(--agent-line-soft);
}

.agent-history-flyout__section-icon,
.agent-history-row__spacer,
.agent-history-row__workspace-icon {
  flex: none;
  width: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.agent-history-row {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 9px;
  color: inherit;
}

.agent-history-flyout__placeholder {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  color: var(--agent-faint);
  font-size: 13px;
}

.agent-history-row--with-context {
  align-items: flex-start;
}

.agent-history-row:hover,
.agent-history-row.is-active {
  background: var(--agent-hover);
}

.agent-history-row__workspace-icon svg {
  flex: none;
  margin-top: 1px;
}

.agent-history-row__main {
  flex: 1;
  min-width: 0;
}

.agent-history-row__title,
.agent-history-row__context {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-history-row__title {
  color: var(--agent-body);
  font-size: 13px;
  font-weight: 400;
}

.agent-history-row__context {
  margin-top: 1px;
  color: var(--agent-faint);
  font-size: 12px;
}

.agent-history-row__time {
  flex: none;
  color: var(--agent-faint);
  font-size: 12.5px;
  white-space: nowrap;
}

/* Unsent-draft badge (email-client style). Neutral so actionable amber remains
   reserved for "Needs You" states. */
.agent-history-row__draft {
  flex: none;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 16px;
  color: var(--agent-muted);
  background: var(--agent-soft);
}

/* Pulsing green dot shown while a session has an active agent run.
   The .run-indicator wrapper stays in the DOM either way so Turbo Stream
   broadcasts can replace it by [data-run-indicator-session-id]. */
.run-indicator {
  display: contents;
}

.run-indicator__dot {
  position: relative;
  flex: none;
  display: inline-flex;
  width: 8px;
  height: 8px;
}

.run-indicator__ping {
  position: absolute;
  inset: 0;
  border-radius: 9999px;
  background: #34d399;
  opacity: 0.75;
  animation: runIndicatorPing 1.2s cubic-bezier(0, 0, 0.2, 1) infinite;
}

.run-indicator__core {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 9999px;
  background: #10b981;
}

@keyframes runIndicatorPing {
  75%,
  100% {
    transform: scale(2.4);
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .run-indicator__ping {
    animation: none;
    opacity: 0;
  }
}

/* Amber "needs you" pill while the session's run is blocked on a consent
   card — same family as the draft pill: attention you owe, distinct from the
   green agent-activity pulse. */
.run-indicator__waiting {
  flex: none;
  padding: 0 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  line-height: 16px;
  color: #b45309;
  background: #fef3c7;
}

/* Live-authorized workspace activity badges pinned to the recent-sessions rail button. */
.rail-activity-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  display: inline-flex;
  pointer-events: none;
}

.rail-workspace-activity {
  display: inline-flex;
}

.agent-rail__history > .agent-rail__icon {
  position: relative;
}

.agent-history-flyout__more {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 8px 10px;
  border-radius: 9px;
  color: var(--agent-muted);
  font-size: 12.5px;
  font-weight: 500;
}

.agent-history-flyout__more:hover {
  background: var(--agent-hover);
  color: var(--agent-text);
}

.agent-history-flyout__more-count {
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: #eef0f2;
  color: var(--agent-muted);
  font-size: 11px;
  font-weight: 600;
}

/* History rendered as a side-panel surface (side=history). Reuses the flyout
   row/heading styles inside a full-height panel. */
.workspace-sidepanel--history {
  display: flex;
  flex-direction: column;
  padding: 0;
  overflow: hidden;
}

.agent-history-panel__body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px;
}

.agent-history-flyout__empty {
  padding: 18px 12px;
  color: var(--agent-faint);
  font-size: 13.5px;
  text-align: center;
}

.agent-rail__bottom {
  width: 34px;
  gap: 13px;
}

.agent-rail__user-menu {
  position: relative;
}

.agent-rail__avatar-button {
  padding: 0;
  border: 0;
  background: transparent;
  border-radius: 9999px;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.agent-rail__avatar-button:hover .agent-rail__avatar,
.agent-rail__avatar-button[aria-expanded="true"] .agent-rail__avatar {
  border-color: #c7cdd6;
  background: #e4e7eb;
}

.agent-rail__avatar-button.is-active .agent-rail__avatar {
  box-shadow: 0 0 0 2px #fff, 0 0 0 4px #3659c9;
}

.agent-rail__avatar-button:focus-visible {
  outline: 2px solid #d4d7dd;
  outline-offset: 2px;
}

.agent-user-menu__backdrop {
  position: fixed;
  inset: 0;
  z-index: 49;
}

.agent-user-menu {
  position: fixed;
  left: 66px;
  bottom: 12px;
  z-index: 50;
  width: 264px;
  padding: 6px;
  border: 1px solid var(--agent-line);
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 16px 44px rgb(16 24 40 / 0.18);
  animation: panelIn 0.14s ease both;
}

.agent-user-menu__identity {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 9px 12px 10px;
  margin-bottom: 6px;
  border-bottom: 1px solid var(--agent-line-soft);
}

.agent-user-menu__name {
  color: var(--agent-text);
  font-size: 13.5px;
  font-weight: 600;
}

.agent-user-menu__email {
  color: var(--agent-muted);
  font-size: 12px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.agent-user-menu__item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--agent-body);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.agent-user-menu__item:hover {
  background: var(--agent-hover);
  color: var(--agent-text);
}

.agent-user-menu__item.is-active {
  color: #3659c9;
}

.agent-user-menu__item svg {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--agent-muted);
}

.agent-user-menu__item.is-active svg {
  color: #3659c9;
}

.agent-user-menu__org {
  margin-top: 6px;
  padding: 8px 12px 10px;
  border-top: 1px solid var(--agent-line-soft);
}

.agent-user-menu__org-label {
  margin-bottom: 6px;
  color: var(--agent-faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.agent-user-menu__org-name {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--agent-body);
  font-size: 13.5px;
}

.agent-user-menu__org-name svg {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--agent-muted);
}

.agent-user-menu__organizations {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 190px;
  margin: 0 -4px;
  overflow-y: auto;
}

.agent-user-menu__organization {
  display: grid;
  grid-template-columns: 16px minmax(0, 1fr) 14px;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 6px 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--agent-body);
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  text-align: left;
}

.agent-user-menu__organization:hover {
  background: var(--agent-hover);
  color: var(--agent-text);
}

.agent-user-menu__organization.is-active {
  background: var(--agent-soft);
  color: var(--agent-text);
  font-weight: 600;
}

.agent-user-menu__organization svg {
  width: 16px;
  height: 16px;
  color: var(--agent-muted);
}

.agent-user-menu__organization > span:not(.agent-user-menu__organization-check) {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.agent-user-menu__organization-check {
  color: var(--agent-blue);
  font-size: 12px;
  text-align: right;
}

.agent-user-menu__organizations-all {
  display: block;
  margin-top: 6px;
  color: var(--agent-blue);
  font-size: 12px;
  font-weight: 600;
}

.agent-user-menu__organizations-all:hover {
  text-decoration: underline;
}

.agent-user-menu__footer {
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--agent-line-soft);
}

.agent-rail__avatar {
  position: relative;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 1px solid #dfe3e8;
  border-radius: 9999px;
  background: #edeff2;
  color: var(--agent-body);
  font-size: 10px;
  font-weight: 500;
}

.agent-rail__avatar--image {
  border-color: #dfe3e8;
  object-fit: cover;
}

.agent-rail__avatar--dark {
  width: 28px;
  height: 28px;
  background: #243b63;
  color: #fff;
  border-color: #243b63;
  font-size: 12px;
  font-weight: 600;
}

.agent-topbar__mobile-nav {
  display: none;
  align-items: center;
  gap: 4px;
}

.agent-topbar__pane-switcher {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 12px;
  background: var(--agent-hover);
}

.agent-topbar__pane-option {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: #667085;
  cursor: pointer;
}

.agent-topbar__pane-option:hover {
  color: #344054;
}

.agent-topbar__pane-option.is-active {
  background: #fff;
  color: var(--agent-text);
  box-shadow: 0 1px 3px rgb(16 24 40 / 0.16), 0 1px 2px rgb(16 24 40 / 0.08);
}

.agent-topbar__mobile-nav .agent-topbar__button {
  width: 2.5rem;
  height: 2.5rem;
  border: 0;
}

.agent-topbar__mobile-nav .agent-topbar__button.is-active {
  background: #eef2ff;
  color: #3659c9;
}

/* Single-pane mobile layout: one pane at a time, driven by data-active-pane
   (which mirrors the URL's `side` / `p` params). */
@media (max-width: 768px) {
  .agent-rail {
    display: none;
  }

  .app-shell {
    grid-template-columns: minmax(0, 1fr);
  }

  .app-shell__main {
    grid-column: 1;
    border-left: 0;
    border-right: 0;
  }

  #app_sidepanel {
    grid-column: 1;
    grid-row: 2;
  }

  .app-shell__resize {
    display: none;
  }

  .app-shell[data-active-pane="center"] #app_sidepanel {
    display: none;
  }

  .app-shell[data-active-pane="side"] .app-shell__main {
    display: none;
  }

  .agent-topbar {
    padding-right: 10px;
    gap: 8px;
  }

  .agent-topbar__left {
    flex: 1 1 auto;
    min-width: 0;
  }

  .agent-topbar__right {
    flex: none;
    gap: 0.25rem;
  }

  .agent-topbar__brand {
    min-width: 0;
    flex: 0 1 auto;
  }

  .agent-topbar__brand .agent-badge {
    display: none;
  }

  .agent-topbar__name {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
  }

  .agent-topbar__switcher {
    flex: none;
  }

  .agent-topbar__switch span {
    display: none;
  }

  .agent-topbar__button--desktop {
    display: none;
  }

  .agent-topbar__mobile-nav {
    display: flex;
  }

  .agent-topbar__new-btn {
    width: 2rem;
    padding: 0;
  }

  .agent-topbar__new-btn > span,
  .agent-topbar__new-btn > svg:last-child {
    display: none;
  }
}

/* Rail history flyout rows: wrapper that hosts the row link plus the ⋮ menu.
   The menu overlays the row's right edge on hover, where the timestamp sits.
   Selectors are compound (.agent-history-item …) on purpose: workspace.css
   loads after this file and its base .session-row-menu { position: relative }
   would win the cascade at equal specificity, dropping the menu into flow. */
.agent-history-item {
  position: relative;
}

.agent-history-item .agent-history-item__menu {
  position: absolute;
  top: 50%;
  right: 0.4rem;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.12s ease;
}

.agent-history-item:hover .agent-history-item__menu,
.agent-history-item:focus-within .agent-history-item__menu,
.agent-history-item .agent-history-item__menu[open] {
  opacity: 1;
}

.agent-history-item:hover .agent-history-row__time,
.agent-history-item:focus-within .agent-history-row__time {
  visibility: hidden;
}

/* --- Idle session timeout warning (shared/_session_timeout) ---
   Reuses the nh-modal card from workspace.css; above toasts and the skill
   palette (both z 100) because nothing may cover a sign-out countdown. */
.session-timeout__overlay {
  z-index: 200;
}

.session-timeout__sign-out-form {
  display: none;
}

.session-timeout__icon {
  background: #fef3c7;
  color: #b45309;
}

.session-timeout__copy {
  margin: 0;
  color: var(--agent-muted);
  font-size: 0.875rem;
  line-height: 1.5;
}

.session-timeout__countdown {
  color: var(--agent-text);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
}

/* --- notifications bell (docs/platform/messaging.md §5.3) ------------------ */

.agent-rail__notifications .agent-rail__icon {
  position: relative;
}

.notification-bell__badge {
  position: absolute;
  top: 2px;
  right: 2px;
  pointer-events: none;
}

.notification-bell__count {
  display: grid;
  place-items: center;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 999px;
  background: #d92d20;
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 0 0 2px #fff;
}

.notification-flyout__read-all {
  border: 0;
  background: transparent;
  padding: 0;
  color: #2b5cb8;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}

.notification-flyout__view-all {
  color: var(--agent-blue);
  font-size: 12px;
  font-weight: 600;
}

.notification-flyout__view-all:hover {
  text-decoration: underline;
}

.notification-flyout__toolbar {
  display: flex;
  justify-content: flex-end;
  padding: 5px 10px 4px;
  border-bottom: 1px solid var(--agent-line-soft);
}

.notification-flyout__loading {
  min-height: 148px;
  padding: 18px 10px;
  color: var(--agent-faint);
  font-size: 12.5px;
}

.notification-flyout__read-all:hover {
  text-decoration: underline;
}

.notification-row {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: #1f2430;
}

.notification-row:hover {
  background: var(--agent-hover);
}

.notification-row__headline {
  font-size: 13px;
  font-weight: 500;
}

.notification-row.is-unread .notification-row__headline {
  font-weight: 700;
}

.notification-row.is-unread {
  position: relative;
}

.notification-row.is-unread::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 50%;
  transform: translateY(-50%);
  width: 5px;
  height: 5px;
  border-radius: 999px;
  background: #2b5cb8;
}

.notification-row__context {
  font-size: 11.5px;
  color: var(--agent-muted);
}

/* A waiting alert (pending consent gate) is a standing to-do: amber unread
   dot, amber tag; it stays unread until the gate resolves. */
.notification-row--waiting.is-unread::before {
  background: #d97706;
}

.notification-row__waiting-tag {
  color: #b45309;
  font-weight: 600;
}

.notification-flyout__empty {
  padding: 12px 10px;
  font-size: 12.5px;
  color: var(--agent-muted);
}

.notification-flyout__empty:not(:only-child) {
  display: none;
}
