Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

39.3 KB
Raw Blame
/*
  App chrome — startup splash and boot animation, sidebar frame
  (header/body/brand), titlebar and native window controls, the conversation
  top bar, and the notification center.
*/

/*
 * The native vibrancy material is visible only through the renderer ancestry.
 * Keep those layers transparent on macOS; the full-height sidebar and the
 * opaque main pane/titlebars still cover their respective regions.
 */
:root[data-platform="darwin"],
:root[data-platform="darwin"] body,
:root[data-platform="darwin"] #root,
:root[data-platform="darwin"] .app-shell {
  background: transparent;
}

/* Boot splash — feedback for host/settings bootstrap (not decorative chrome). */
.startup-splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ds-bg-primary);
  -webkit-app-region: drag;
  animation: startup-splash-in var(--motion-duration-slow) var(--motion-ease-out) both;
}

/*
 * On macOS the splash is glass, so the shell that mounts under it as soon as
 * `ready` flips would bleed through the tint. Hide it until the exit fade,
 * then cross-fade without replaying the dock's explicit toggle animation.
 */
:root[data-platform="darwin"] .app-shell.is-booting:has(.startup-splash:not(.is-exiting))
  > :not(.startup-splash) {
  visibility: hidden;
  opacity: 0;
}

:root[data-platform="darwin"] .app-shell.is-booting:has(.startup-splash.is-exiting)
  > :not(.startup-splash) {
  opacity: 1;
  transition: opacity var(--motion-duration-normal) var(--motion-ease-out);
}

.startup-splash.is-exiting {
  animation: startup-splash-out var(--motion-duration-normal) var(--motion-ease-in) both;
  pointer-events: none;
}

.startup-splash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  width: min(100%, 280px);
  -webkit-app-region: no-drag;
}

.startup-splash-mark {
  display: flex;
  width: 72px;
  height: 72px;
  align-items: center;
  justify-content: center;
  border-radius: var(--ds-composer-radius);
  background: var(--ds-tile-deep);
  animation: startup-mark-in var(--motion-duration-slow) var(--motion-ease-out) both;
}

.startup-splash-copy {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  animation: startup-copy-in var(--motion-duration-slow) var(--motion-ease-out) both;
  animation-delay: 40ms;
}

.startup-splash-name {
  color: var(--ds-text-primary);
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tighter);
}

.startup-splash-tagline {
  color: var(--ds-text-muted);
  font-size: var(--text-md);
  line-height: var(--leading-compact-plus);
}

.startup-splash-track {
  width: 120px;
  height: 3px;
  margin-top: 4px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: color-mix(in oklab, var(--ds-text-primary) 8%, transparent);
  animation: startup-copy-in var(--motion-duration-slow) var(--motion-ease-out) both;
  animation-delay: 80ms;
}

.startup-splash-bar {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: color-mix(in oklab, var(--ds-text-primary) 55%, transparent);
  animation: startup-bar 1.1s var(--motion-ease-standard) infinite;
}

@keyframes startup-splash-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes startup-splash-out {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

@keyframes startup-mark-in {
  from {
    opacity: 0;
    transform: scale(0.92) translateY(6px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes startup-copy-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes startup-bar {
  0% {
    transform: translateX(-120%);
  }
  100% {
    transform: translateX(320%);
  }
}

/*
 * Boot animation (D679) — the user's own video as the boot surface.
 *
 * Opaque black for its whole life, including the fade: the video sits on this
 * layer, and once the video is gone the same black is the mask the shell fades
 * in from. One layer rather than two means no seam between the last frame and
 * the mask. The fill is literal black, not `--ds-bg-primary`, so a video's own
 * letterboxing and fades meet the same colour under either theme.
 *
 * No macOS counterpart to the splash's child-hiding rule is needed: that rule
 * exists because the splash is glass and the mounted shell bleeds through its
 * tint. This layer is opaque, so there is nothing to bleed.
 */
.startup-animation {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #000;
  opacity: 1;
  /* The window has no chrome yet, so the surface itself has to be draggable. */
  -webkit-app-region: drag;
  transition: opacity var(--motion-startup-reveal) var(--motion-ease-out);
}

.startup-animation.is-revealing {
  opacity: 0;
  /* The shell underneath takes input for the whole fade, not after it. */
  pointer-events: none;
}

/*
 * `cover` (D679): a user's export almost never matches the window aspect, and
 * a filled frame is what reads as a launch sequence. The trade is that the
 * edges are cropped, which is why the setting copy says to keep the subject
 * centred.
 */
.startup-animation-video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  /* Safari/Chromium paint a 1px seam at the edges of a scaled video. */
  transform: scale(1.002);
  pointer-events: none;
}

/*
 * Progress affordance for a boot that outlasted the video. Absent for the
 * first `STARTUP_ANIMATION_HOLD_HINT_MS` of black so a normal launch stays a
 * clean cut, and borrowed from the splash so a slow boot looks the same
 * whichever surface covered it.
 */
.startup-animation-track {
  position: absolute;
  bottom: 48px;
  width: 120px;
  height: 3px;
  overflow: hidden;
  border-radius: var(--radius-full);
  background: color-mix(in oklab, #fff 8%, transparent);
  animation: startup-splash-in var(--motion-duration-slow) var(--motion-ease-out) both;
}

.startup-animation-bar {
  display: block;
  width: 40%;
  height: 100%;
  border-radius: inherit;
  background: color-mix(in oklab, #fff 55%, transparent);
  animation: startup-bar 1.1s var(--motion-ease-standard) infinite;
}

@media (prefers-reduced-motion: reduce) {
  /*
   * The animation is not played at all under reduced motion (the renderer
   * never mounts this surface), so these rules only cover a preference that
   * changes mid-boot: the reveal becomes instant and the bar stops.
   */
  .startup-animation {
    transition-duration: 0.01ms;
  }
  .startup-animation-track {
    animation: none;
  }
  .startup-animation-bar {
    animation: none;
    width: 100%;
    transform: none;
    opacity: 0.55;
  }
  .startup-splash,
  .startup-splash.is-exiting,
  .startup-splash-mark,
  .startup-splash-copy,
  .startup-splash-track {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }
  .startup-splash-bar {
    animation: none;
    width: 100%;
    transform: none;
    opacity: 0.55;
  }
  :root[data-platform="darwin"]
    .app-shell.is-booting:has(.startup-splash.is-exiting)
    > :not(.startup-splash) {
    transition-duration: 0.01ms;
  }
}

/*
 * Startup recovery — the surface the startup watchdog falls back to when the
 * renderer never receives its initial state (issue #831).
 *
 * It sits above the splash and is opaque by design: the window has no data to
 * show, so there is nothing behind it worth seeing. Unlike the splash it must be
 * operable — every control on it works without any backend — so it is draggable
 * like the splash while its action row opts back out.
 */
.startup-recovery {
  position: fixed;
  inset: 0;
  z-index: 1400; /* above the splash (1300) it replaces */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--ds-bg-primary);
  -webkit-app-region: drag;
  animation: startup-splash-in var(--motion-duration-slow) var(--motion-ease-out) both;
}

/*
 * The renderer-drawn window controls (Windows/Linux, no native chrome) are
 * hidden until the shell is ready, so a window sitting on this surface would
 * have no close control at all. Keep them above it: the surface's own Quit
 * action must not be the only way out of a stuck startup.
 */
.app-shell:has(> .startup-recovery) > .window-controls {
  z-index: 1500;
}

.startup-recovery-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  width: min(100%, 420px);
  text-align: center;
  -webkit-app-region: no-drag;
}

.startup-recovery-mark {
  display: flex;
  width: 56px;
  height: 56px;
  align-items: center;
  justify-content: center;
  border-radius: var(--ds-composer-radius);
  background: var(--ds-tile-deep);
}

.startup-recovery-title {
  margin: 0;
  color: var(--ds-text-primary);
  font-size: var(--text-lg);
  font-weight: var(--font-weight-semibold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-tighter);
}

.startup-recovery-body {
  margin: 0;
  color: var(--ds-text-secondary);
  font-size: var(--text-md);
  line-height: var(--leading-body);
  overflow-wrap: anywhere;
}

.startup-recovery-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 4px;
}

@media (prefers-reduced-motion: reduce) {
  .startup-recovery {
    animation-duration: 0.01ms !important;
    animation-delay: 0ms !important;
  }
}

.sidebar-surface,
.sidebar-rail {
  background-color: var(--ds-bg-sidebar, var(--ds-bg-primary));
  background-image: var(--ds-bg-sidebar-image, none);
  background-repeat: no-repeat;
  background-size: cover;
}

.sidebar {
  width: var(--ds-sidebar-width);
  min-width: 0;
  max-width: 520px;
  height: 100%;
  min-height: 0;
  flex: 0 0 var(--ds-sidebar-width);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

.sidebar.is-entering {
  animation: sidebar-in var(--motion-duration-normal) var(--motion-ease-out) both;
}

.sidebar-resize-handle {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 8px;
  cursor: col-resize;
  touch-action: none;
  user-select: none;
}

.sidebar-resize-handle::after {
  position: absolute;
  top: 50%;
  right: 2px;
  width: 2px;
  height: 32px;
  content: "";
  border-radius: var(--radius-full);
  background: color-mix(in oklab, var(--ds-text-primary) 20%, transparent);
  opacity: 0;
  transform: translateY(-50%);
  transition: opacity var(--motion-duration-fast) var(--motion-ease-out);
}

.sidebar-resize-handle:hover::after,
.sidebar-resize-handle:focus-visible::after,
.sidebar-resize-handle.is-resizing::after {
  opacity: 1;
}

.sidebar-resize-handle:focus-visible {
  outline: none;
}

.sidebar-resize-handle:focus-visible::after,
.sidebar-resize-handle.is-resizing::after {
  background: var(--ds-accent);
}

:root[data-sidebar-resizing="true"],
:root[data-sidebar-resizing="true"] * {
  cursor: col-resize !important;
  user-select: none !important;
}

:root[data-project-reordering="true"],
:root[data-project-reordering="true"] * {
  cursor: grabbing !important;
  user-select: none !important;
}

.sidebar.is-exiting {
  pointer-events: none;
  animation: sidebar-out var(--motion-duration-fast) var(--motion-ease-in) both;
}

@keyframes sidebar-in {
  from {
    opacity: 0;
    flex-basis: 0;
    width: 0;
    transform: translateX(-8px);
  }
  to {
    opacity: 1;
    flex-basis: var(--ds-sidebar-width);
    width: var(--ds-sidebar-width);
    transform: translateX(0);
  }
}

@keyframes sidebar-out {
  from {
    opacity: 1;
    flex-basis: var(--ds-sidebar-width);
    width: var(--ds-sidebar-width);
    transform: translateX(0);
  }
  to {
    opacity: 0;
    flex-basis: 0;
    width: 0;
    transform: translateX(-8px);
  }
}

/* win32 collapse: keep the dock opaque to avoid exposing the frameless
   window background during its exit motion. */
@keyframes sidebar-out-windows {
  from {
    flex-basis: var(--ds-sidebar-width);
    width: var(--ds-sidebar-width);
    transform: translateX(0);
  }
  to {
    flex-basis: 0;
    width: 0;
    transform: translateX(-8px);
  }
}

:root[data-platform="win32"] .sidebar.is-exiting {
  animation-name: sidebar-out-windows;
}

/*
 * The keyframes above drive the dock's own box width, so without this the whole
 * content layer re-lays-out on every frame: section labels wrap to vertical,
 * every session row re-runs its ellipsis, and the collapse reads as flicker
 * rather than motion. Hold the content at the dock's full width and let
 * `overflow: hidden` wipe it — one content layout instead of one per frame.
 * `min-width` (not `width`) so a wider dock still stretches its children. The
 * dock draws no edge stroke (D297), so the pin is the full dock width.
 */
.sidebar-header,
.sidebar-body {
  min-width: var(--ds-sidebar-width);
}

.sidebar-rail {
  width: 56px;
  flex: 0 0 56px;
  display: flex;
  flex-direction: column;
}

/*
 * macOS supplies the blur through native sidebar vibrancy. The renderer
 * only adds a thin tint plus sheen on the sidebar, rail, and boot splash —
 * an opaque splash would flash a painted panel before the glass sidebar.
 * The sheen keeps the material reading as glass; a flat tint looks painted.
 * The main pane and titlebars remain opaque `bg-primary`.
 */
:root[data-platform="darwin"] .startup-splash,
:root[data-platform="darwin"] .sidebar-surface,
:root[data-platform="darwin"] .sidebar-rail {
  background-color: var(--ds-sidebar-glass-tint);
  background-image: var(--ds-bg-sidebar-image, none),
    linear-gradient(
      180deg,
      var(--ds-sidebar-glass-sheen-top),
      transparent 220px
    ),
    linear-gradient(0deg, var(--ds-sidebar-glass-sheen-bottom), transparent 160px);
  background-repeat: no-repeat;
}

:root[data-platform="darwin"] .sidebar-rail {
  position: relative;
}

/* Collapsed-sidebar controls stay in normal flow inside the main drag band so
 * Electron window-drag hit testing never swallows clicks. */
.titlebar-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.main-titlebar-left {
  pointer-events: auto;
  display: flex;
  align-items: center;
  margin-right: auto;
  /* The row already pads 12px, so the title only adds the difference between
     that and the traffic-light reserve. Platforms with no native traffic
     lights, and fullscreen, resolve to the row's own padding. */
  padding-left: max(0px, calc(var(--ds-window-lead-inset) - 12px));
}

/* Preview- and route-band actions take the shared chrome-control geometry from
   the `.ct-icon-btn` group below (28px square, `--radius-md`, transparent seat,
   hover wash). Only the press feedback belongs to the lane itself. */
.title-nav-btn {
  transition:
    background var(--motion-duration-fast) var(--motion-ease-out),
    color var(--motion-duration-fast) var(--motion-ease-out),
    transform var(--motion-duration-fast) var(--motion-ease-out);
}

.title-nav-btn.active {
  color: var(--ds-text-primary);
  background: var(--ds-bg-active);
}

.main-titlebar {
  pointer-events: none;
  position: absolute;
  inset-inline: 0;
  top: 0;
  z-index: 10;
  display: flex;
  height: var(--ds-toolbar-height);
  align-items: center;
  justify-content: flex-end;
  padding: 0 12px;
  background: var(--ds-bg-primary);
  /* Keep the shell continuous; titlebar hierarchy comes from spacing and
   * surface color instead of a hard lower rule. */
  border-bottom: 0;
  -webkit-app-region: drag;
}

.main-titlebar.work-panel-open {
  padding-right: 0;
}

/* Conversation top bar (Codex/WorkBuddy-style): replaces the empty chat
 * titlebar band with a real toolbar — session title and action buttons. It
 * mirrors the frameless drag semantics of .main-titlebar, with interactive
 * controls opting back into pointer events. */
.conversation-topbar {
  --ct-inline-padding: 12px;
  position: fixed;
  left: anchor(--main-pane left);
  /* Follow the pane as it resizes, clamping the action group clear of the
   * fixed toggle even while the dock is too narrow to contain that control. */
  right: max(
    anchor(--main-pane right),
    calc(
      var(--ds-work-panel-toggle-right) + var(--ds-work-panel-toggle-size) +
        8px - var(--ct-inline-padding)
    )
  );
  top: 0;
  z-index: 10;
  display: flex;
  height: var(--ds-toolbar-height);
  align-items: center;
  justify-content: space-between;
  padding: 0 var(--ct-inline-padding);
  background: var(--ds-bg-primary);
  /* Keep the conversation surface visually continuous with the titlebar. */
  border-bottom: 0;
  /* Where the returning dock toggle sits; platform rules below override it. */
  --ct-lead-inset: 12px;
  /*
   * The collapsed lead-in (traffic-light inset + dock toggle) must grow at the
   * same rate as the dock shrinks, or the title snaps ~100px sideways on the
   * first frame and crawls back. The base timing matches sidebar-in, so it
   * governs expansion; the .ct-collapsed rule below matches sidebar-out.
   */
  transition: padding-left var(--motion-duration-normal) var(--motion-ease-out);
  -webkit-app-region: drag;
  app-region: drag;
}

.conversation-topbar.ct-collapsed {
  /* The out-of-flow .ct-lead reserves no space of its own, so the title's
   * offset is the inset plus the 28px button and .ct-left's 8px gap. */
  padding-left: calc(var(--ct-lead-inset) + 36px);
  transition: padding-left var(--motion-duration-fast) var(--motion-ease-in);
}

.conversation-topbar .ct-left,
.conversation-topbar .ct-right {
  -webkit-app-region: no-drag;
  app-region: no-drag;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.conversation-topbar .ct-left {
  flex: 1 1 auto;
  min-width: 0;
  margin-right: auto;
}

.conversation-topbar .ct-right {
  flex: 0 0 auto;
  justify-content: flex-end;
}

.conversation-topbar .ct-title-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  -webkit-app-region: drag; /* keep the title area draggable */
  app-region: drag;
}

/*
 * The project crumb names where the conversation lives, one step quieter than
 * the task title it prefixes. It may truncate, but it never forces the title
 * or the action lane out of the bar.
 */
.conversation-topbar .ct-project {
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
  align-items: center;
  gap: 6px;
  color: var(--ds-text-faint);
  font-size: var(--text-xs);
  line-height: var(--leading-compact);
  white-space: nowrap;
}

.conversation-topbar .ct-project-menu {
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
}

.conversation-topbar .ct-project-trigger {
  max-width: 100%;
  margin: -2px -4px;
  padding: 2px 4px;
  border: 0;
  border-radius: var(--radius-3xs);
  background: transparent;
  font: inherit;
  font-size: var(--text-xs);
  cursor: pointer;
}

.conversation-topbar .ct-project-trigger:hover,
.conversation-topbar .ct-project-trigger[aria-expanded="true"] {
  background: var(--ds-bg-hover);
  color: var(--ds-text-secondary);
}

.conversation-topbar .ct-project-trigger:focus-visible {
  outline: 2px solid var(--ds-focus);
  outline-offset: 1px;
}

.conversation-topbar .ct-project-trigger:disabled {
  cursor: default;
}

.conversation-topbar .ct-project > svg {
  flex: 0 0 auto;
}

.conversation-topbar .ct-project-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.conversation-topbar .ct-sep {
  flex: 0 0 auto;
  color: var(--ds-border-strong);
  font-size: var(--text-xs);
  line-height: var(--leading-compact);
}

.conversation-topbar .ct-title {
  min-width: 0;
  flex: 1 1 auto;
  overflow: hidden;
  margin: 0;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--ds-text-primary);
  font-size: var(--text-sm-plus);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-compact);
}

/*
 * Click-to-edit title. The button only exists to give the text real pointer and
 * keyboard semantics; it must paint and measure exactly like the plain title,
 * so every font/ink property is inherited and the ellipsis stays on the text.
 */
.conversation-topbar .ct-title-trigger {
  display: block;
  width: fit-content;
  max-width: 100%;
  margin: 0;
  overflow: hidden;
  padding: 0;
  border: 0;
  background: transparent;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  text-align: left;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: text;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

/* The title lane clips its children, so a ring would vanish; underline instead. */
.conversation-topbar .ct-title-trigger:focus-visible {
  outline: none;
  text-decoration: underline;
  text-decoration-thickness: 1.5px;
  text-underline-offset: 2px;
  text-decoration-color: var(--ds-accent);
}

/*
 * The editor is deliberately boxless: the title keeps its own type metrics and
 * only the caret marks the mode change. Inside the draggable bar the field
 * must still opt into pointer events or the click never reaches it.
 */
.conversation-topbar .ct-title-input {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  outline: none;
  appearance: none;
  background: transparent;
  box-shadow: none;
  color: var(--ds-text-primary);
  font-family: inherit;
  font-size: var(--text-sm-plus);
  font-weight: var(--font-weight-medium);
  letter-spacing: var(--tracking-tight);
  line-height: var(--leading-compact);
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

/*
 * Where a scheduled run's conversation was opened from: the session list keeps
 * automation transcripts out of the project groups, so this is the way back to
 * the task and the run the reader was reading. It sits in the title's own lane,
 * so a long task title truncates exactly as it did before.
 */
.conversation-topbar .ct-back {
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
  height: 24px;
  align-items: center;
  gap: 2px;
  border: none;
  border-radius: var(--radius-md);
  padding: 0 8px 0 4px;
  background: transparent;
  color: var(--ds-text-secondary);
  cursor: pointer;
  -webkit-app-region: no-drag;
  app-region: no-drag;
  transition: background var(--motion-duration-fast) var(--motion-ease-out),
    color var(--motion-duration-fast) var(--motion-ease-out);
}

.conversation-topbar .ct-back:hover {
  background: var(--ds-bg-hover);
  color: var(--ds-text-primary);
}

.conversation-topbar .ct-back-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-sm);
  line-height: var(--leading-compact);
}

/* One geometry and one seat for every chrome icon control: the topbar's dock
   toggle, the viewport-fixed work-panel toggle, the preview/route-band lane
   actions, and the work-panel header's create and maximize controls. The seat is
   transparent at rest, so the icon alone carries the control and only the pointer
   hover wash paints a surface under it; keyboard focus keeps the global outline.
   `flex: 0 0` keeps them square when a crowded band would otherwise squeeze
   them. */
.conversation-topbar .ct-icon-btn,
.app-work-panel-toggle,
.main-titlebar .title-nav-btn,
.window-chrome-row .title-nav-btn,
.work-panel-new-tab,
.work-panel-maximize {
  display: inline-flex;
  height: var(--ds-work-panel-toggle-size);
  width: var(--ds-work-panel-toggle-size);
  flex: 0 0 var(--ds-work-panel-toggle-size);
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--ds-text-secondary);
  cursor: pointer;
  transition: background var(--motion-duration-fast) var(--motion-ease-out),
    color var(--motion-duration-fast) var(--motion-ease-out);
}

.conversation-topbar .ct-icon-btn:hover:not(:disabled),
.app-work-panel-toggle:hover:not(:disabled),
.main-titlebar .title-nav-btn:hover:not(:disabled),
.window-chrome-row .title-nav-btn:hover:not(:disabled),
.work-panel-new-tab:hover:not(:disabled),
.work-panel-maximize:hover:not(:disabled) {
  background: var(--ds-bg-hover);
  color: var(--ds-text-primary);
}

.conversation-topbar .ct-icon-btn:disabled,
.app-work-panel-toggle:disabled,
.main-titlebar .title-nav-btn:disabled,
.window-chrome-row .title-nav-btn:disabled,
.work-panel-new-tab:disabled,
.work-panel-maximize:disabled {
  opacity: 0.4;
  cursor: default;
}

/*
  The mode selector lives in the composer's left toolbar, not the top bar — see
  the topbar source contracts in test/thinking-ui.test.mjs and
  src/plan-mode-source-contract.test.mjs. The `.ct-mode` / `.ct-mode-btn` rules
  that used to sit here styled the retired top-bar control and are intentionally
  absent; do not reintroduce them.
*/

.conversation-topbar .ct-actions {
  display: inline-flex;
  align-items: center;
  gap: 0;
  padding: 2px;
  border-radius: var(--radius-md);
  background: var(--ds-tile);
}

/* Keep the sole work-panel toggle anchored to the viewport while the in-flow
 * panel changes MainPane width. AppShell ownership keeps it available on every
 * non-Settings route and above the panel header throughout both animations. */
.app-work-panel-toggle {
  position: fixed;
  top: 9px;
  right: var(--ds-work-panel-toggle-right);
  z-index: 30;
  pointer-events: auto;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

/* The open state is the glyph swap plus the engaged ink — the same transparent
   seat as every other chrome icon control, so the toggle never floats over the
   panel header as a raised pill. */
.app-work-panel-toggle[aria-pressed="true"] {
  color: var(--ds-text-primary);
}

.app-work-panel-toggle-icon {
  position: relative;
  display: inline-flex;
  width: 15px;
  height: 15px;
}

.app-work-panel-toggle-icon > svg {
  position: absolute;
  inset: 0;
  transition: opacity var(--motion-duration-fast) var(--motion-ease-out);
}

.app-work-panel-toggle[aria-pressed="false"] .app-work-panel-toggle-icon > svg:last-child,
.app-work-panel-toggle[aria-pressed="true"] .app-work-panel-toggle-icon > svg:first-child {
  opacity: 0;
}

:root[data-platform="win32"],
:root[data-platform="linux"] {
  --ds-work-panel-toggle-right: calc(
    var(--ds-window-controls-width) + var(--ds-work-panel-toggle-inset)
  );
}

/* The macOS traffic lights own the window's top-left corner. Everything below
 * reads `--ds-window-lead-inset`: the cluster's right edge (native geometry,
 * injected at boot from @pi-desktop/shared — see window-chrome.ts) plus the
 * breathing room kept before the first shell control. Fullscreen hides the
 * buttons, so the reserve falls back to the ordinary 8px gutter; Windows and
 * Linux keep the 0px default from tokens.css and use their renderer-drawn
 * controls instead.
 *
 * Only the inset moves per platform — the collapsed padding below derives the
 * title's offset from it, so the two can never drift apart. */
:root[data-platform="darwin"] {
  --ds-window-lead-inset: calc(
    var(--ds-traffic-light-edge) + var(--ds-traffic-light-gap)
  );
}

:root[data-platform="darwin"][data-fullscreen="true"] {
  --ds-window-lead-inset: 8px;
}

:root[data-platform="darwin"] .conversation-topbar.ct-collapsed {
  --ct-lead-inset: var(--ds-window-lead-inset);
}

/*
 * The dock toggle returns to the top bar while the sidebar is collapsed, and it
 * stays mounted so it can cross-fade with the dock's own toggle.
 *
 * It is deliberately OUT OF FLOW. An in-flow slot has to animate its own width
 * to keep the title from jumping, and a growing box with `overflow: hidden`
 * slices the 28px glyph down the middle for the whole transition — the icon
 * reads as a torn vertical shard rather than a button. Absolute positioning
 * hands the space back to the top bar's `padding-left`, which already
 * transitions, so the only thing left to animate here is opacity.
 */
.conversation-topbar .ct-lead {
  position: absolute;
  /*
   * The title's edge is `padding-left`; this button must stay exactly 36px to
   * its left (28px button + .ct-left's 8px gap) at EVERY frame, not just at the
   * two endpoints. Deriving `left` from the same inset keeps both ranges
   * identical (112px on darwin, 36px elsewhere), so the pair interpolates in
   * lockstep. Offsetting instead of transitioning 12px->88px matters: that range
   * is only 76px against padding's 112px, and the icon drifts onto the title
   * mid-flight. Expanded it lands off the pane's left edge, where it is
   * invisible anyway, and slides in rather than materialising over the title.
   */
  left: calc(var(--ct-lead-inset) - 36px);
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  /*
   * Out of flow, so .ct-left's no-drag box no longer covers it: .ct-left starts
   * at the padding edge (x=124 collapsed) while this sits at x=88. Without its
   * own carve-out the button falls inside the top bar's drag region, which on
   * macOS swallows the click and keeps the arrow cursor instead of the pointer.
   */
  -webkit-app-region: no-drag;
  app-region: no-drag;
  opacity: 0;
  pointer-events: none;
  transition:
    left var(--motion-duration-normal) var(--motion-ease-out),
    opacity var(--motion-duration-normal) var(--motion-ease-out);
}

.conversation-topbar.ct-collapsed .ct-lead {
  left: var(--ct-lead-inset);
  opacity: 1;
  pointer-events: auto;
  transition:
    left var(--motion-duration-fast) var(--motion-ease-in),
    opacity var(--motion-duration-fast) var(--motion-ease-in);
}

.conversation-topbar .ct-lead > .ct-icon-btn {
  flex: 0 0 28px;
}

.notification-center {
  position: relative;
  flex: 0 0 auto;
}

.notification-trigger {
  position: relative;
  width: 32px;
  height: 32px;
}

.notification-badge {
  position: absolute;
  top: -5px;
  right: -6px;
  display: inline-flex;
  min-width: 16px;
  height: 16px;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--ds-bg-sidebar);
  border-radius: var(--radius-full);
  background: var(--ds-error);
  color: var(--ds-bg-primary);
  font-size: var(--text-3xs);
  font-weight: var(--font-weight-semibold);
  line-height: var(--leading-none);
}

.notification-popover {
  position: fixed;
  top: auto;
  left: 0;
  right: auto;
  bottom: auto;
  z-index: 60;
  display: flex;
  width: min(360px, calc(100vw - 24px));
  max-height: min(560px, calc(100vh - 58px));
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--ds-border-subtle);
  border-radius: var(--radius-sm);
  background: var(--ds-bg-elevated-opaque);
  box-shadow: var(--ds-shadow-dialog);
}

/* Portaled to document.body so the main pane cannot paint over the dialog. */
.notification-popover-portaled {
  z-index: 60;
}

.notification-header {
  display: flex;
  min-height: 46px;
  flex: 0 0 auto;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 10px 4px 14px;
}

.notification-header h2 {
  margin: 0;
  color: var(--ds-text-primary);
  font-size: var(--text-base);
  font-weight: var(--font-weight-semibold);
  line-height: var(--leading-tight);
}

.notification-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
}

.notification-action {
  display: inline-flex;
  width: 28px;
  height: 28px;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-2xs);
  color: var(--ds-text-muted);
  transition: background var(--motion-duration-fast) var(--motion-ease-out), color var(--motion-duration-fast) var(--motion-ease-out), opacity var(--motion-duration-fast) var(--motion-ease-out);
}

.notification-action:hover:not(:disabled) {
  background: var(--ds-bg-hover);
  color: var(--ds-text-primary);
}

.notification-action:disabled {
  cursor: default;
  opacity: 0.32;
}

.notification-filters {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
  padding: 4px 10px 8px;
}

.notification-filter {
  min-width: 58px;
  height: 28px;
  border-radius: var(--radius-2xs);
  color: var(--ds-text-muted);
  font-size: var(--text-sm-plus);
  font-weight: var(--font-weight-medium);
  transition: background var(--motion-duration-fast) var(--motion-ease-out), color var(--motion-duration-fast) var(--motion-ease-out);
}

.notification-filter:hover {
  background: var(--ds-bg-hover);
  color: var(--ds-text-primary);
}

.notification-filter.active {
  background: var(--ds-bg-active);
  color: var(--ds-text-primary);
}

/* Rows are separated by a small gap and their own rounded fill, not by
   hairlines (D297). */
.notification-list {
  display: flex;
  min-height: 0;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 0 6px 8px;
  overflow-y: auto;
  list-style: none;
}

.notification-item {
  position: relative;
  display: grid;
  width: 100%;
  grid-template-columns: 22px minmax(0, 1fr) auto;
  align-items: start;
  gap: 9px;
  padding: 10px 9px;
  border-radius: var(--radius-sm);
  color: var(--ds-text-secondary);
  text-align: left;
  transition: background var(--motion-duration-fast) var(--motion-ease-out);
}

.notification-item:hover {
  background: var(--ds-bg-hover);
}

.notification-item:disabled {
  cursor: default;
}

.notification-item.unread {
  color: var(--ds-text-primary);
  background: color-mix(in oklab, var(--ds-accent) 5%, transparent);
}

.notification-item.unread:hover {
  background: color-mix(in oklab, var(--ds-accent) 9%, transparent);
}

.notification-kind-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-top: 1px;
  color: var(--ds-success);
}

.notification-kind-icon.failed {
  color: var(--ds-error);
}

.notification-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 3px;
}

.notification-item-title {
  overflow: hidden;
  color: inherit;
  font-size: var(--text-md);
  font-weight: var(--font-weight-medium);
  line-height: var(--leading-compact);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notification-item-body {
  display: -webkit-box;
  overflow: hidden;
  color: var(--ds-text-muted);
  font-size: var(--text-sm);
  line-height: var(--leading-body);
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.notification-time {
  flex: 0 0 auto;
  padding-right: 8px;
  color: var(--ds-text-muted);
  font-size: var(--text-xs);
  line-height: var(--leading-compact);
  white-space: nowrap;
}

.notification-unread-dot {
  position: absolute;
  top: 16px;
  right: 9px;
  width: 5px;
  height: 5px;
  border-radius: var(--radius-round);
  background: var(--ds-accent);
}

.notification-empty {
  display: flex;
  min-height: 190px;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 7px;
  padding: 28px 24px;
  color: var(--ds-text-muted);
  text-align: center;
}

.notification-empty svg {
  margin-bottom: 3px;
  color: var(--ds-text-faint);
}

.notification-empty strong {
  color: var(--ds-text-secondary);
  font-size: var(--text-md);
  font-weight: var(--font-weight-medium);
}

.notification-empty span {
  max-width: 260px;
  font-size: var(--text-sm);
  line-height: var(--leading-body);
}

@media (max-width: 480px) {
  .notification-popover {
    position: fixed;
    top: auto;
    bottom: 8px;
    right: 8px;
    left: 8px;
    width: auto;
    max-height: calc(100vh - 16px);
  }
}

.window-controls {
  -webkit-app-region: no-drag;
  app-region: no-drag;
  pointer-events: auto;
  position: fixed;
  top: 0;
  right: 0;
  z-index: 1000; /* above every renderer surface and draggable titlebar */
  display: flex;
  align-items: center;
  width: var(--ds-window-controls-width);
  height: var(--ds-toolbar-height);
  box-sizing: border-box;
  padding-left: 8px;
  /* Paint a separate full hit band so page content cannot show through the
   * controls and panel actions cannot read as part of the same button group. */
  background: var(--ds-bg-primary);
  /* Continuous with the adjacent titlebar: no side seam (D297). */
}

/* Electron resolves app-region hit testing across siblings. The controls must
 * be a later compositor layer than Settings, plugin content, or a work-panel
 * drag header. Direct-child overlays (search, splash) must still win; the toast
 * stack is not one of them — it lives on the body so a dialog cannot cover it. */
.app-shell > .window-controls {
  z-index: 1100;
}

.app-shell > .search-overlay {
  z-index: 1200;
}

.app-shell > .startup-splash {
  z-index: 1300;
}

/* Follow the adjacent titlebar surface when the dock occupies the right edge. */
.app-shell:has(.work-panel) > .window-controls {
  background: var(--ds-bg-dock-raised);
}

.window-control-btn {
  -webkit-app-region: no-drag;
  app-region: no-drag;
  pointer-events: auto;
  display: inline-flex;
  height: 100%;
  min-width: 0;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  border-radius: 0;
  color: color-mix(in oklab, var(--ds-text-primary) 55%, transparent);
  background: transparent;
  transition: background var(--motion-duration-fast) var(--motion-ease-out), color var(--motion-duration-fast) var(--motion-ease-out);
}

.window-control-btn:hover {
  color: var(--ds-text-primary);
  background: var(--ds-bg-hover);
}

.window-control-btn.window-control-close:hover {
  color: var(--ds-bg-primary);
  background: var(--ds-error);
}

/* End every native drag rectangle before the window-control hit targets.
 * Visual padding alone does not exclude an Electron draggable region. */
:root[data-platform="win32"] .main-titlebar,
:root[data-platform="linux"] .main-titlebar {
  right: var(--ds-window-controls-width);
}

:root[data-platform="win32"] .main-titlebar.work-panel-open,
:root[data-platform="linux"] .main-titlebar.work-panel-open {
  right: 0;
}

.sidebar-header {
  display: flex;
  height: var(--ds-toolbar-height);
  flex: 0 0 var(--ds-toolbar-height);
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 0 8px;
  -webkit-app-region: drag;
}

:root[data-platform="darwin"] .sidebar-header {
  padding-left: var(--ds-window-lead-inset);
}

:root[data-platform="darwin"] .sidebar-header > .brand {
  display: none;
}

.sidebar-header-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.sidebar-body {
  display: flex;
  min-height: 0;
  flex: 1 1 auto;
  flex-direction: column;
  padding: 0 8px 6px;
  overflow: hidden auto;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  min-width: 0;
  padding: 0 6px 0 4px;
  border-radius: var(--radius-sm);
  font-size: var(--text-base-plus);
  font-weight: var(--font-weight-semibold);
  letter-spacing: 0;
  color: var(--ds-text-primary);
  transition: background var(--motion-duration-fast) var(--motion-ease-out);
}

.brand:hover {
  background: var(--ds-bg-hover);
}

.brand-logo {
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
  -webkit-user-drag: none;
  -webkit-user-select: none;
  user-select: none;
}

.app-shell.work-panel-maximized {
  --preview-chrome-inset: 8px;
  --preview-chrome-action-lane: calc(var(--ds-control-size) + 8px);
}

.app-shell.work-panel-maximized.sidebar-collapsed {
  --preview-chrome-action-lane: var(--ds-preview-action-lane-width);
}

:root[data-platform="darwin"] .app-shell.work-panel-maximized.sidebar-collapsed {
  --preview-chrome-inset: var(--ds-window-lead-inset);
}

/* Match the scenic backdrop's child-layer specificity so preview navigation
 * stays above the work panel while non-control pixels remain pass-through. */
.app-shell > :where(.app-chat-shell) > .window-chrome-row {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  z-index: 200;
  display: flex;
  height: var(--ds-toolbar-height);
  align-items: center;
  padding-left: var(--preview-chrome-inset);
  pointer-events: none;
}

.window-chrome-row.sidebar-expanded {
  left: var(--ds-sidebar-width);
}

.window-chrome-row button {
  pointer-events: auto;
  -webkit-app-region: no-drag;
  app-region: no-drag;
}

.window-chrome-drag {
  flex: 1 1 auto;
  align-self: stretch;
}