/* Author: Koushik Sen (ksen@berkeley.edu)
   Contributors:
   Koushik Sen (ksen@berkeley.edu)
   add your name here */

:root {
  font-size: var(--theme-font-size);
  color-scheme: dark;

  /* The look is Claude Code Desktop's: near-monochrome surfaces three
     shades apart (canvas, panel, raised), hairlines and hover fills at
     low alpha, text in four steps and ONE blue accent, kept for links,
     focus rings and selection.  web_server.py supplies the --theme-*
     palette; the fallbacks are its dark values.  Every name here that
     depends on the theme is re-derived on body.remote-chat in
     remote-codex.css (see its header comment). */
  --bg: var(--theme-editor-background, #0b0b0b);         /* chat canvas */
  --bg2: var(--theme-sideBar-background, #151515);        /* side panels */
  --surface: var(--theme-sideBar-background, #151515);    /* sunken cards */
  --surface2: var(--theme-input-background, #1f1f1f);     /* raised: composer, inputs */
  --menu-bg: var(--theme-editorWidget-background, #1f1f1f);  /* menus, dialogs */
  --code-bg: var(--theme-textCodeBlock-background, #151515);
  --code-inline-fg: var(--theme-textPreformat-foreground, #fa8080);

  /* Text: emphasis, body, secondary, tertiary (labels, placeholders),
     and the icons' own step between body and secondary. */
  --fg-strong: var(--theme-tab-activeForeground, #fff);
  --fg: var(--theme-editor-foreground, #f0efec);
  --dim: var(--theme-descriptionForeground, #9c9a92);
  --faint: var(--theme-input-placeholderForeground, #898781);
  --icon: var(--theme-icon-foreground, #c3c2b7);
  --accent: var(--theme-textLink-foreground, #4d9fff);

  /* Hairlines, and the neutral fills of a row or button under the
     pointer and of the selected one. */
  --border: var(--theme-panel-border, #ffffff1a);
  --border-soft: var(--theme-sideBar-border, #ffffff14);
  --border-input: var(--theme-input-border, #ffffff26);
  --border-hover: color-mix(in srgb, var(--fg) 30%, transparent);
  --ring-focus: var(--theme-focusBorder, #4d9fff);
  --hover: var(--theme-list-hoverBackground, #ffffff13);
  --hover-strong: var(--theme-toolbar-hoverBackground, #ffffff1a);
  --selected: var(--theme-list-inactiveSelectionBackground, #ffffff26);

  /* The primary button: a near-white (dark) or near-black (light)
     fill. */
  --primary-bg: var(--theme-button-background, #efefef);
  --primary-fg: var(--theme-button-foreground, #0b0b0b);
  --primary-hover-bg: var(--theme-button-hoverBackground, #d7d7d7);

  /* Scrollbar thumb: the foreground at two strengths - resting, and
     under the pointer or while dragged - so the bar reads on any
     theme without a track of its own. */
  --scrollbar-thumb: color-mix(in srgb, var(--fg) 20%, transparent);
  --scrollbar-thumb-hover: color-mix(in srgb, var(--fg) 45%, transparent);

  /* Status hues come from the palette's chart colours, which are tuned
     for marks on a UI surface, not from the terminal ANSI colours,
     which are tuned for text on a terminal background.  Cyan has no
     chart colour, so it keeps the terminal one. */
  --green: var(--theme-charts-green, #4cc38a);
  --red: var(--theme-charts-red, #ff5a5a);
  --yellow: var(--theme-charts-yellow, #e3c07b);
  --purple: var(--theme-charts-purple, #b796ff);
  --cyan: var(--theme-terminal-ansiCyan, #5ac8d8);
  --error: var(--theme-errorForeground, #ff5a5a);
  --warning: var(--theme-editorWarning-foreground, #e3c07b);

  /* ---- Type ---------------------------------------------------------
     Claude Code Desktop's typography: the platform system font (the
     fallback of the Claude apps' own proprietary face), a 13px base for
     the chrome - sidebars, composer, menus - with 11 / 12px for labels
     and 14px for the transcript's prose, a 1.5 line height, normal
     tracking, greyscale smoothing and three weights only (400, 500,
     600); code in the platform monospace.  Sizes are rem of the 13px
     root (--theme-font-size) so the browser's zoom scales everything. */
  --font-ui: var(--theme-font-family, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif);
  --font-mono: var(--theme-editor-font-family, ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace);
  --fs-sm:  0.846rem;  /* 11px */
  --fs-md:  0.923rem;  /* 12px */
  --fs-base: 1rem;     /* 13px */
  --fs-lg:  1.077rem;  /* 14px */
  --fs-xl:  1.231rem;  /* 16px */
  --fs-2xl: 1.538rem;  /* 20px */
  --fs-inline-code: 0.9em;  /* inline code, a step under the text around it */

  /* ---- Design tokens ------------------------------------------------
     Components use these names instead of raw values, so spacing,
     corners, elevation, stacking and motion stay consistent across the
     chat page and the shared chat pages.  Colours
     still come from the theme (--theme-* above); the semantic colour
     names below are the only fixed hues, and remote-codex.css re-maps
     them onto the theme palette. */

  /* Spacing: padding, margin and gap.  Half steps (2, 6, 10px) exist
     because the compact layout relies on them. */
  --space-0-5: 2px;
  --space-1: 4px;
  --space-1-5: 6px;
  --space-2: 8px;
  --space-2-5: 10px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 20px;
  --space-6: 24px;
  --space-8: 32px;
  --space-10: 40px;

  /* The chat column runs the full width of its pane; the transcript
     and the composer keep the same clear strip on each side, so the
     tool lines and the composer's box share one left edge. */
  --col-pad: var(--space-4);

  /* Corner radii: small and consistent, as in Claude Code Desktop. */
  --radius-xs: 2px;     /* inline highlights, hairline bars */
  --radius-sm: 4px;     /* badges, inline code, checkboxes */
  --radius-md: 6px;     /* list rows, icon buttons, chips, tabs */
  --radius-lg: 8px;     /* buttons, inputs, menus, panes */
  --radius-xl: 10px;    /* composer, speech bubbles, cards, code blocks */
  --radius-2xl: 12px;   /* dialogs */
  --radius-pill: 999px;
  --radius-round: 50%;

  /* Elevation: soft and wide.  --theme-widget-shadow is the palette's
     shadow colour at its strongest (under a menu); the smaller shadows
     thin it out. */
  --shadow-color: var(--theme-widget-shadow, #00000073);
  --shadow-sm:    /* composer, tooltips, banners */
    0 1px 2px color-mix(in srgb, var(--shadow-color) 40%, transparent),
    0 2px 8px color-mix(in srgb, var(--shadow-color) 50%, transparent);
  --shadow-md: 0 4px 24px color-mix(in srgb, var(--shadow-color) 60%, transparent);  /* pickers, cards */
  --shadow-lg: 0 12px 40px var(--shadow-color);   /* menus, dialogs, toasts */
  --scrim: rgb(0 0 0 / 50%);          /* backdrop behind a panel */
  --scrim-strong: rgb(0 0 0 / 70%);   /* backdrop behind a blocking modal */

  /* Stacking layers, lowest first.  The order is load-bearing: a new
     overlay picks the layer it must sit in instead of a fresh number. */
  --z-behind: -1;         /* a panel's own backdrop, under its content */
  --z-raised: 1;          /* sticky list headers, in-panel buttons */
  --z-float: 5;           /* buttons floating over a panel */
  --z-float-top: 10;      /* input clear buttons, above --z-float */
  --z-popup: 50;          /* composer autocomplete */
  --z-handle: 60;         /* composer drawer handle, above the popup */
  --z-menu: 100;          /* composer menus */
  --z-docked: 150;        /* docked side panels (remote desktop) */
  --z-scrim: 199;         /* backdrop directly under a drawer */
  --z-drawer: 200;        /* drawers and slide-in panels */
  --z-dialog: 300;        /* dialogs over a drawer */
  --z-context: 350;       /* context menus, above dialogs */
  --z-modal: 400;         /* blocking modal (password prompt) */
  --z-alert: 500;         /* confirmation over a modal */
  --z-editor-menu: 1000;  /* menus over the embedded editor */
  --z-loading: 9999;      /* server-loading cover */
  --z-tooltip: 10000;     /* tooltips and date picker */
  --z-toast: 10001;       /* notifications, above everything on screen */
  --z-statusbar: 2147483647;  /* the strip a phone reads its status bar's
                                 colour from (it paints nothing): the
                                 highest there is */

  /* Motion.  Durations collapse to 0 under prefers-reduced-motion. */
  --dur-fast: 0.1s;
  --dur-base: 0.15s;
  --dur-slow: 0.2s;
  --dur-slide: 0.45s;     /* a card sliding across its panel */
  --ease: cubic-bezier(0.165, 0.84, 0.44, 1);

  /* Semantic colours.  Success and failure take the palette's chart
     green and red, so the history icons, tab icons and result panels
     follow the light, dark and high-contrast palettes instead of one
     fixed green.  Theme-dependent, so remote-codex.css re-derives them
     on body.remote-chat. */
  --status-ok: var(--green);
  --status-fail: var(--red);
  --favorite: var(--yellow);

  /* Panel chrome.  Every transcript panel (tool call, Bash output,
     tool result, prompts) shares ONE neutral tint and hairline, so the
     transcript reads as one quiet surface.  Theme-dependent:
     remote-codex.css re-derives them on body.remote-chat. */
  --panel-tint: color-mix(in srgb, var(--fg) 4%, transparent);
  --panel-line: color-mix(in srgb, var(--fg) 10%, transparent);

  /* The user's speech bubble (task panel, steering Message), neutral
     as in Claude Code Desktop: a grey wash of the canvas. */
  --bubble-user-tint: color-mix(in srgb, var(--fg) 7%, transparent);

  /* Claude's clay orange: the working indicator only (the spark that
     turns while the agent runs), the one warm hue of the UI. */
  --brand-clay: #d97757;

  /* Text that says "running" (the status timer, a running job's
     badge): the clay mixed toward the text colour, which keeps it
     readable at small sizes on both themes.  Theme-dependent:
     remote-codex.css re-derives it on body.remote-chat. */
  --running-fg: color-mix(in srgb, var(--brand-clay) 70%, var(--fg));
  --paper: #fff;   /* white surfaces: confirm buttons, HTML previews */
  --ink: #000;     /* the dark half of --attention-ring */
  --attention-ring: color-mix(in srgb, var(--ink) 15%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 0s;
    --dur-base: 0s;
    --dur-slow: 0s;
    --dur-slide: 0s;
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* stylelint-disable-next-line property-no-vendor-prefix */
html { max-width: 100vw; overflow-x: hidden; -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }

/* Native form controls follow the page: the same typeface as the body
   (browsers default them to Arial) and the accent for checkboxes, radios and sliders.  The
   colour scheme tells the browser to draw its own widgets - select
   popups, checkboxes, scrollbars - in the page's dark or light
   scheme instead of always light (the dark default is set on :root
   above). */
button, input, select, textarea { font-family: inherit; }
input { accent-color: var(--accent); }
html.light-theme, body.light-theme { color-scheme: light; }

/* Keyboard focus.  A control that draws no ring of its own takes the
   token ring in place of the browser's `auto` ring, so the ring is
   the same from one control to the next.  :where() adds nothing to
   the specificity: a component's own focus rule (a fill, a border, an
   inset ring) outranks this one.  A row as wide as its list wears the
   ring inside its box, where the list does not clip it. */
:where(button, select, summary, a, [role="button"], [tabindex]):focus-visible {
  outline: 1px solid var(--ring-focus);
  outline-offset: 1px;
}

:where(.history-chat-header, .history-project-header, .projects-row, .sidebar-item, .more-menu-item, .scm-section-hdr):focus-visible {
  outline-offset: -1px;
}

body {
  font-family: var(--font-ui);
  font-size: var(--fs-base);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  background: var(--bg);
  color: var(--fg);
  height: 100vh;
  overflow: hidden;
  max-width: 100vw;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 100vw;
  overflow-x: hidden;
}

.kiss-notification-container {
  position: fixed;
  top: 8px;
  right: 8px;
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-2);
  width: min(450px, calc(100vw - 16px));
  pointer-events: none;
}

/* A toast, as Claude Code Desktop raises one: the menus' raised
   surface with a hairline and a wide soft shadow.  Its kind shows in
   the icon's colour only, never in the frame. */
.kiss-notification {
  width: 100%;
  pointer-events: auto;
  color: var(--fg);
  background: var(--menu-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  animation: kiss-notification-in var(--dur-base) var(--ease);
}

.kiss-notification-body {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) 24px;
  gap: var(--space-2);
  padding: var(--space-3);
  align-items: start;
}

.kiss-notification-icon {
  font-size: var(--fs-lg);
  line-height: 1.35;
  color: var(--accent);
}

.kiss-notification-warning .kiss-notification-icon { color: var(--yellow); }
.kiss-notification-error .kiss-notification-icon { color: var(--red); }

.kiss-notification-title {
  font-size: var(--fs-base);
  font-weight: 600;
  color: var(--fg);
  margin-bottom: var(--space-0-5);
}

.kiss-notification-message {
  font-size: var(--fs-base);
  line-height: 1.45;
  color: var(--dim);
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

/* "Do not show this" under a notice that offers it: a small muted
   checkbox row, the whole label clickable. */
.kiss-notification-opt-out {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  margin-top: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--dim);
  cursor: pointer;
  user-select: none;
}

.kiss-notification-opt-out-box {
  margin: 0;
  cursor: pointer;
}

.kiss-notification-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--dim);
  cursor: pointer;
  font-size: var(--fs-xl);
  line-height: 1;
}

.kiss-notification-close:hover,
.kiss-notification-close:focus-visible {
  color: var(--fg);
  background: var(--hover-strong);
  outline: none;
}

.kiss-notification-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: 0 var(--space-3) var(--space-3) calc(var(--space-10) + var(--space-0-5));
  flex-wrap: wrap;
}

/* A toast's buttons are the secondary button: a hairline, a 6px
   corner and the medium weight, filling under the pointer. */
.kiss-notification-action {
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--fg);
  cursor: pointer;
  font-size: var(--fs-md);
  font-weight: 500;
  padding: var(--space-1) var(--space-2-5);
  display: inline-flex;
  align-items: center;
  gap: var(--space-1-5);
}

.kiss-notification-action:hover,
.kiss-notification-action:focus-visible {
  background: var(--hover);
  border-color: var(--border-hover);
  outline: none;
}

/* Destructive choice of a confirm toast (confirmAction({danger: true})). */
.kiss-notification-action-danger {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 45%, transparent);
}

.kiss-notification-action-danger:hover,
.kiss-notification-action-danger:focus-visible {
  background: color-mix(in srgb, var(--error) 12%, transparent);
  border-color: var(--error);
}

/* Text field of a prompt toast (promptText), aligned with the message
   text; the field itself is an .explorer-input. */
.kiss-notification-field {
  padding: 0 var(--space-3) var(--space-2) calc(var(--space-10) + var(--space-0-5));
}

.kiss-notification-action-icon {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.kiss-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

@keyframes kiss-notification-in {
  from { opacity: 0; transform: translateX(24px); }
  to { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .kiss-notification { animation: none; }
}

/* The machine the chat's tasks run on and their working directory:
   two drop-downs styled as plain text at the top of the chat pane, set
   like Claude Code Desktop's breadcrumb - the body colour at the
   medium weight from the chat column's left edge, the separator and
   the chevrons in the faintest text step (main.js lists this daemon's
   machine, from configData.machine, and the reachable registered
   machines); the strip takes no room until it has a name.  A remote
   pick carries a status dot: green while the machine answers the
   daemon's pings, red once it is reported down.  Stays enabled while
   the chat runs (the pick is where the next task goes).  The same
   hairline as the tab rows parts it from the transcript.

   "machine > directory" is ONE line at every width, a phone's
   included: a grid column for each name and one for the ">" between
   them.  The two names share the row: one that fits in its half is
   shown whole and leaves the rest of the row to the other, a longer
   one ellipsizes. */
#chat-header {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: minmax(0, max-content) max-content minmax(0, max-content) max-content minmax(0, max-content);
  align-items: center;
  justify-content: start;
  width: 100%;
  padding: var(--space-1-5) var(--col-pad);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-base);
  font-weight: 500;
  color: var(--fg);
  white-space: nowrap;
}

#chat-machine-wrap { grid-column: 1; }

/* The ">" between the two names, the same gap on either side. */
#chat-header-sep { grid-column: 2; margin: 0 var(--space-1-5); color: var(--faint); font-weight: 400; }

#chat-workdir-wrap { grid-column: 3; }

/* The project of the chat, after a dot: there once a project exists
   (main.js renderChatProject).  The wrap is a flex box, which the
   `hidden` attribute alone would not take off the row. */
#chat-project-sep { grid-column: 4; margin: 0 var(--space-1-5); color: var(--faint); font-weight: 400; }

#chat-project-wrap { grid-column: 5; }

#chat-project-wrap[hidden] { display: none; }

/* Each drop-down is a span holding a label that shows the selected
   entry (main.js renderChatHeaderLabel), the down chevron that marks
   it as a drop-down, and the native select laid over both,
   transparent.  A native select is as wide as its longest option; the
   label is as wide as the one name it shows, so the chevron follows
   the name directly, and a click on either opens the native list. */
.chat-header-select {
  position: relative;
  display: flex;
  align-items: center;
  min-width: 0;
}

.chat-header-select-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* The chevron: the span's ::after, a bordered square turned 45deg.
   Its transform paints it over the select, so it takes no pointer
   events: a click on it opens the native list. */
.chat-header-select::after {
  content: '';
  flex: none;
  width: 0.4em;
  height: 0.4em;
  margin: 0 var(--space-0-5) 0 var(--space-1);
  border-right: 1.5px solid var(--faint);
  border-bottom: 1.5px solid var(--faint);
  transform: translateY(-20%) rotate(45deg);
  pointer-events: none;
}

/* Phone widths: a path too long for its room loses its beginning,
   not its last folder: the right-to-left direction puts the ellipsis
   on the left (the label shows the option's label, fenced by
   left-to-right marks in renderChatWorkDir, so the leading "/" stays
   in front). */
@media (width < 900px) {
  #chat-workdir-wrap > .chat-header-select-label { direction: rtl; }
}

/* The select covers its span and as much as the header's padding
   above and below it: a strip one line tall opens the list over its
   whole height, a finger's target on a phone. */
#chat-machine,
#chat-workdir,
#chat-project {
  position: absolute;
  top: calc(-1 * var(--space-1-5));
  left: 0;
  width: 100%;
  height: calc(100% + 2 * var(--space-1-5));
  font: inherit;
  opacity: 0;
  cursor: pointer;
  appearance: none;
}

/* The select's own focus ring is as transparent as the select: the
   span wears the keyboard-focus ring in its place. */
.chat-header-select:has(> select:focus-visible) {
  outline: 1px solid var(--ring-focus);
  outline-offset: 1px;
}

/* A remote pick is led by a status dot, green like the reachability
   dot of the Machines subpanel; red, like that dot of a machine that
   is down, once the daemon has reported the pick down. */
#chat-machine-wrap:has(> .remote) { color: var(--status-ok); }
#chat-machine-wrap:has(> .remote.down) { color: var(--status-fail); }
#chat-machine-wrap:has(> .remote) > .chat-header-select-label { color: var(--fg); }

#chat-machine-wrap:has(> .remote)::before {
  content: '';
  flex: none;
  width: 6px; height: 6px; margin-right: var(--space-1-5);
  border-radius: var(--radius-round);
  background: currentcolor;
}

#chat-machine option,
#chat-workdir option,
#chat-project option { color: var(--fg); background: var(--bg); font-weight: 400; }

/* The machine drop-down (and its chevron) takes no room until a name
   is known (the directory one always offers at least "Choose ..."). */
#chat-machine:empty,
#chat-machine-wrap:has(> #chat-machine:empty) { display: none; }

/* A stacked surface showing a content tab in place of the chat. */
body.content-tab-open #chat-header { display: none; }

/* The tab rows (renderTabBar).  There is no row of chat tabs: the
   chat on screen is the one picked in the Chats panel.  #tab-bar, the
   group strip, lists the chat on screen with its sub-agents and only
   appears when it has more than one tab; while a stacked surface
   shows a content tab it lists the open file, browser and terminal
   tabs instead, a single one included.  #content-tab-bar is the
   content pane's own row in the desktop remote webapp's split layout
   (remote-codex.css); hidden everywhere else.  #pane-resizer is the
   handle between the two panes of that layout. */
#tab-bar,
#content-tab-bar {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}

#content-tab-bar,
#pane-resizer { display: none; }

/* The strip: smaller type on the chat background. */
#tab-bar {
  background: var(--bg);
  padding-left: var(--space-3);
}

#tab-bar .chat-tab {
  font-size: var(--fs-sm);
}

#tab-list,
#content-tab-list {
  display: flex;
  flex: 1;
  min-width: 0;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.config-label {
  display: block;
  font-size: var(--fs-md);
  color: var(--dim);
  margin-bottom: var(--space-3);
}

.config-label input[type="text"],
.config-label input[type="password"],
.config-label input[type="number"],
.config-label select,
.config-label textarea {
  display: block;
  width: 100%;
  margin-top: var(--space-1);
  padding: var(--space-1-5) var(--space-2-5);
  font-size: var(--fs-base);
  background: var(--surface2);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  color: var(--fg);
}

.config-label textarea { resize: vertical; }

.config-label select { cursor: pointer; }

.config-label input:focus,
.config-label select:focus,
.config-label textarea:focus { outline: 1px solid var(--accent); border-color: var(--accent); }

/* The select wears its ring where the text fields beside it do, on the
   border (the page-wide focus rule would hold it 1px off). */
.config-label select:focus { outline-offset: 0; }

/* A checkbox before its label: the box sits on the label's first line,
   centred on that line's box, however many lines the label runs to.
   The box takes the label's font so that 1lh is the label's line; 13px
   is the height of a native checkbox. */
.config-checkbox { display: flex; align-items: flex-start; gap: var(--space-2); flex-direction: row; }

.config-checkbox input[type="checkbox"] {
  width: auto;
  margin: calc((1lh - 13px) / 2) 0 0;
  font: inherit;
}

/* A box with a "?" next to its label (chat.html#cfg-chrome-bridge): the
   label keeps to the width of its text, the button follows it on its
   line, and the row carries the label's gap to the next field. */
.config-help-row { display: flex; align-items: center; gap: var(--space-1-5); margin-bottom: var(--space-3); }

.config-help-row > .config-label { margin-bottom: 0; }

.config-help-btn {
  flex: none; width: 20px; height: 20px;
  background: none; border: 1px solid var(--border-input); border-radius: var(--radius-round);
  color: var(--dim); font-size: var(--fs-sm); font-weight: 600; line-height: 1;
  cursor: pointer; transition: background var(--dur-base), border-color var(--dur-base), color var(--dur-base);
}

.config-help-btn:hover { background: var(--hover); border-color: var(--border-hover); color: var(--fg); }

/* The help that the "?" shows: the dialogs' card (.auth-modal-content)
   as a popover, centred in the window over a scrim.  The margin is the
   browser's own for a popover, which the reset above zeroes; the card
   sets no `display`: one would outrank the browser's `display: none`
   of a closed popover.  A folder path too long for the card breaks
   instead of widening it. */
.config-help { margin: auto; }

.config-help::backdrop { background: var(--scrim); }

.config-help-text { margin-bottom: var(--space-4); font-size: var(--fs-base); line-height: 1.5; overflow-wrap: anywhere; }

/* A browser without popovers (one from before 2024) shows the help
   under its box, where neither button has anything to do. */
@supports not selector(:popover-open) {
  .config-help { margin: 0 0 var(--space-3); }

  .config-help-btn,
  .config-help .auth-modal-actions { display: none; }
}

.config-sensitivity-row { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-1); }

.config-sensitivity-row input[type="range"] {
  flex: 1;
  margin: 0;
}

.config-sensitivity-value {
  min-width: 3ch;
  text-align: right;
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

.config-divider { border-top: 1px solid var(--border); margin: var(--space-3) 0; }

/* Collapsible section toggles - the settings dialog's API Keys and
   Custom Models subpanels - share one chevron-toggle pattern: a
   small sentence-case label in the faint text step, the body colour
   on hover, chevron turning when open. */
.config-subpanel { margin-top: var(--space-2); }

.config-subpanel-toggle {
  display: flex; align-items: center; gap: var(--space-1);
  width: 100%; padding: var(--space-0-5) 0; margin: 0 0 var(--space-1-5);
  background: none; border: none;
  font-size: var(--fs-md); font-weight: 500;
  color: var(--faint);
  text-align: left;
  cursor: pointer; user-select: none;
}

.config-subpanel-toggle:hover { color: var(--fg); }

.config-subpanel-toggle:focus-visible {
  outline: 1px solid var(--accent); outline-offset: 1px;
}

.config-subpanel-chevron { flex: none; transition: transform var(--dur-slow) var(--ease); }

.config-subpanel-toggle.expanded .config-subpanel-chevron {
  transform: rotate(90deg);
}

.config-subpanel-body[hidden] { display: none !important; }

/* The Claude Code subpanel's login line (claudeCodeStatus reply). */
.claude-code-status { line-height: 1.4; }
.claude-code-status-ok { color: var(--green); }
.claude-code-status-warn { color: var(--warning); }

/* The Codex subpanel's login line (codexStatus reply) and the
   device-code sign-in row (codexLogin reply). */
.codex-status { line-height: 1.4; }
.codex-status-ok { color: var(--green); }
.codex-status-warn { color: var(--warning); }

.codex-login-row {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2);
}

.codex-login-row code { user-select: all; }

/* The Custom Models subpanel's Add / Save / Cancel row and the list of
   models stored in ~/.kiss/MY_MODELS.json. */
.custom-model-actions {
  display: flex; align-items: center; gap: var(--space-2); margin: var(--space-2-5) 0;
}

#custom-models-list { margin-top: var(--space-1); }

.custom-model-row {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-1-5); border-radius: var(--radius-md);
}

.custom-model-row:hover { background: var(--hover); }

.custom-model-row.editing { background: var(--selected); }

.custom-model-name {
  flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-md); color: var(--fg);
}

.custom-model-endpoint {
  flex: none; max-width: 40%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-size: var(--fs-sm);
  color: var(--dim);
}

.custom-model-btn {
  flex: none;
  display: inline-flex; align-items: center; justify-content: center;
  padding: var(--space-1); border: none; border-radius: var(--radius-md);
  background: none; cursor: pointer;
  color: var(--dim);
}

.custom-model-btn:hover {
  color: var(--fg);
  background: var(--hover-strong);
}

.custom-models-empty {
  padding: var(--space-1) var(--space-1-5); font-size: var(--fs-sm);
  color: var(--faint);
}

/* Tips / Update / Reset Server / Update Models.  ``flex-wrap`` + the
   ``white-space: nowrap`` on the buttons below make the row break
   BETWEEN buttons when it is too narrow, never inside a label. */
.config-update-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
}

.config-update-btn {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: var(--space-1-5);
  padding: var(--space-1-5) var(--space-3);
  white-space: nowrap;
  background: var(--surface2);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  color: var(--fg);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-base), border-color var(--dur-base);
}

.config-update-btn:hover:not(:disabled) { background: var(--hover); border-color: var(--border-hover); }

.config-update-btn:focus-visible { outline: 1px solid var(--accent); }

.config-update-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.config-update-btn svg { flex-shrink: 0; }

.config-update-btn.has-update {
  border-color: color-mix(in srgb, var(--status-ok) 60%, var(--border));
  background: color-mix(in srgb, var(--status-ok) 10%, transparent);
}

.config-update-btn.has-update:hover:not(:disabled) {
  border-color: color-mix(in srgb, var(--status-ok) 60%, var(--border));
  background: color-mix(in srgb, var(--status-ok) 18%, transparent);
}

.config-update-btn .update-available-icon {
  color: var(--status-ok);
}

.config-password-wrap { position: relative; margin-top: var(--space-1); }
.config-password-wrap input { margin-top: 0 !important; padding-right: var(--space-8) !important; }

.config-password-toggle {
  position: absolute; top: 50%; right: 6px; transform: translateY(-50%);
  display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0;
  background: transparent; border: none; color: var(--dim); cursor: pointer;
  border-radius: var(--radius-md);
}
.config-password-toggle:hover { color: var(--fg); background: var(--hover-strong); }
.config-password-toggle:focus-visible { outline: 1px solid var(--accent); }

/* Settings > Remote password: the refresh button (new random password,
   setupRemotePasswordField in main.js) sits left of the eye toggle, so
   the box keeps room for both. */
.config-password-wrap-refresh input { padding-right: calc(var(--space-8) + 28px) !important; }
.config-password-refresh { right: 34px; }

#tab-list::-webkit-scrollbar { display: none; }

.chat-tab {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2-5);
  font-size: var(--fs-base);
  color: var(--dim);
  cursor: pointer;
  white-space: nowrap;
  border-radius: var(--radius-md);
  flex-shrink: 0;
  max-width: 140px;
  min-width: 0;
  user-select: none;
}
.chat-tab:hover { color: var(--fg); background: var(--hover); }
.chat-tab.active { color: var(--fg-strong); background: var(--selected); }

.chat-tab:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.chat-tab-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}

/* Task status icons, shared by the composer's wait spinner, the chat
   tab strip, the history rows and the history filter chips: a spinning
   ring while a task runs, a tick once it succeeded, a cross once it
   failed.  Every icon takes its colour from `currentcolor`, so the
   element that carries the state class only has to set `color`. */
.status-spinner, .status-tick, .status-cross, #wait-spinner {
  display: inline-block; flex-shrink: 0;
  width: 12px; height: 12px;
}

/* The one ring every surface shows: a faint track with a single bright
   leading arc, turning once every 0.8s. */
.status-spinner, #wait-spinner {
  border-radius: var(--radius-round);
  border: 2px solid color-mix(in srgb, currentcolor 25%, transparent);
  border-top-color: currentcolor;
}

.status-spinner, #wait-spinner.active {
  animation: status-spin 0.8s linear infinite;
}

/* Rotates through the `rotate` property (not `transform`).  Anything
   that offsets a spinner must use the `translate` property as well:
   the browser applies `transform` BEFORE `rotate`, so an offset given
   as `transform: translateY()` would be rotated too and the ring
   would orbit the point instead of turning in place. */
@keyframes status-spin {
  to { rotate: 360deg; }
}

.status-tick, .status-cross {
  background: currentcolor;
  mask: var(--status-icon) center / contain no-repeat;
}

.status-tick {
  --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 8.5l3.5 3.5 7.5-8' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

.status-cross {
  --status-icon: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M3.5 3.5l9 9M12.5 3.5l-9 9' fill='none' stroke='black' stroke-width='2.6' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* A running tab's ring is Claude's clay, the working colour. */
.chat-tab-spinner { color: var(--brand-clay); }
.chat-tab-ok { color: var(--status-ok); }
.chat-tab-fail { color: var(--status-fail); }

@keyframes running-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 0 1px var(--attention-ring); }
  50% { opacity: 0.4; box-shadow: 0 0 6px 2px color-mix(in srgb, var(--status-ok) 50%, transparent); }
}

.chat-tab-attention {
  font-size: var(--fs-md); font-weight: 600; flex-shrink: 0; line-height: 1;
  color: var(--warning);
  animation: running-pulse 1.5s ease-in-out infinite;
}

.chat-tab-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  font-size: var(--fs-xl);
  line-height: 1;
  color: var(--dim);
  flex-shrink: 0;
}
.chat-tab-close:hover { background: var(--hover-strong); color: var(--fg); }

.chat-tab-close:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* A sub-agent's tab is purple all over - a light tint, text and its
   status icon - so it is told apart from the chat's own tabs at a
   glance without shouting over them.  The tint is the tab's only
   fill-level cue, so it stays above 15%: a fainter one is lost on the
   canvas. */
.chat-tab.subagent-tab {
  background: color-mix(in srgb, var(--purple) 16%, transparent);
  color: color-mix(in srgb, var(--purple) 75%, var(--fg));
  max-width: 160px;
}

.chat-tab.subagent-tab:hover {
  background: color-mix(in srgb, var(--purple) 20%, transparent);
}

.chat-tab.subagent-tab.active {
  background: color-mix(in srgb, var(--purple) 24%, transparent);
  color: var(--purple);
}

/* The remote webapp's tab chips (remote-codex.css, which carries no
   colour of its own) would flatten a sub-agent tab into an ordinary
   one; these forms outrank them so it stays purple there too. */
body.remote-chat #tab-bar .chat-tab.subagent-tab {
  background: color-mix(in srgb, var(--purple) 16%, transparent);
  border-color: transparent;
  color: color-mix(in srgb, var(--purple) 75%, var(--fg));
}

body.remote-chat #tab-bar .chat-tab.subagent-tab:hover {
  background: color-mix(in srgb, var(--purple) 20%, transparent);
}

body.remote-chat #tab-bar .chat-tab.subagent-tab.active {
  background: color-mix(in srgb, var(--purple) 24%, transparent);
  border-color: color-mix(in srgb, var(--purple) 45%, transparent);
  color: var(--purple);
}

/* Sub-agent tab status: the shared spinner while the sub-agent runs
   (.status-spinner), the shared tick of a finished one on the shared
   page (.status-tick, share.js), both in the tab's purple. */
.subagent-indicator { color: var(--purple); }

#tab-context-menu {
  position: fixed;
  background: var(--menu-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-context);
  min-width: 160px;
  padding: var(--space-1);
  display: none;
}
#tab-context-menu.open { display: block; }

.tab-ctx-item {
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  font-size: var(--fs-base);
  color: var(--fg);
  cursor: pointer;
  white-space: nowrap;
}
.tab-ctx-item:hover { background: var(--hover); }

/* The task's own text opens every task of the thread, and a message
   the user typed into the running task (.user-msg) is the user's
   words too.  Both are Claude Code Desktop's user bubble: a neutral
   wash with no outline and one 10px corner all round, as wide as its
   text (at most 85% of the chat column) and set against the column's
   right edge.  The rest of the transcript runs from the column's left
   edge (see .ev below), so the thread reads as a conversation: the
   user on the right, the agent on the left.  The min-width keeps the
   label and the copy button of a one-word task apart. */
.ev.task-panel, .ev.user-msg {
  width: fit-content; min-width: 120px; max-width: 85%;
  margin: var(--space-4) 0 var(--space-3) auto;
  border-radius: var(--radius-xl);
  background: var(--bubble-user-tint);
  overflow: hidden;
}

/* .task-panel-h, the bubble's label ("Task", "Message"), shares the
   panel-header line below (.tc-h). */

.task-panel-text {
  padding: var(--space-0-5) var(--space-3) var(--space-2);
  font-size: var(--fs-lg);
  color: var(--fg);
  line-height: 1.5;
  max-height: 60vh;
  overflow-y: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.task-panel.collapsed .task-panel-text,
.user-msg.collapsed .task-panel-text,
.user-msg.collapsed .steer-actions,
.task-panel.collapsed .task-panel-info { display: none; }

/* A message the agent has not read yet (.steer-waiting) carries two
   buttons under its text, at the bubble's right edge: Force (hand it
   to the agent now), a secondary button, and Delete (take it out of
   the queue), the destructive one.  main.js removes the row once the
   message is read or deleted, and when the task ends. */
.steer-actions {
  display: flex; justify-content: flex-end; gap: var(--space-2);
  padding: 0 var(--space-3) var(--space-2);
}

.steer-btn {
  padding: var(--space-0-5) var(--space-2-5); border: 1px solid var(--border-input); border-radius: var(--radius-lg);
  font-size: var(--fs-sm); font-weight: 500; cursor: pointer;
  transition: background var(--dur-base), border-color var(--dur-base), color var(--dur-base); background: var(--surface2); color: var(--fg);
}
.steer-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.steer-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

.steer-force:hover:not(:disabled) {
  background: var(--hover);
  border-color: var(--border-hover);
}

.steer-delete {
  border-color: color-mix(in srgb, var(--error) 45%, transparent);
  color: var(--error);
}

.steer-delete:hover:not(:disabled) {
  background: color-mix(in srgb, var(--error) 12%, transparent);
  border-color: var(--error);
}

/* The task's info rows on a saved page: the Task Info panel's rows
   (Tokens, Cost, Steps, Time, Machine, Workdir, Max budget, Date,
   Base model, Chat id, Task id, Parent task, Agent), one per line,
   labelled like the panel's. */
.task-panel-info {
  margin: 0 var(--space-3) var(--space-2);
  padding-top: var(--space-1-5);
  border-top: 1px solid var(--border);
  font-size: var(--fs-sm);
  color: var(--dim);
  line-height: 1.5;
}

.task-panel-info:empty { display: none; }

.task-panel-info-line {
  display: block;
  word-break: break-word;
}

.task-panel-info-label {
  font-weight: 500;
  white-space: nowrap;
  margin-right: var(--space-1);
}

#output {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  overscroll-behavior-y: none;
  padding: var(--space-3) var(--col-pad) var(--space-4);
}

/* The desktop remote webapp's split layout (the #app grid in
   remote-codex.css): the transcript fills the chat pane's `chat` area. */
body.remote-chat.remote-desktop #output {
  grid-area: chat;
  min-height: 0;
}

/* The welcome page: the logo, the product name and the tagline,
   centred in the empty transcript. */
#welcome {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: var(--space-5) var(--space-3); text-align: center;
  min-height: 100%;
}

/* The logo is transparent art in two colourings: navy wordmark for
   the light theme, light wordmark for the dark one.  Both are in the
   page; the theme toggle (body.remote-chat.light-theme) shows exactly
   one.  It is 560px wide where the pane has the room, as wide as the
   pane where it has not (a phone), and smaller in a short window, so
   that the greeting under it stays in sight: its height (840 x 657
   art, so width / 1.28) is at most the window's height less the
   330px the input box, the greeting and the paddings take. */
.welcome-logo { display: block; width: min(560px, 100%, calc((100vh - 330px) * 1.28)); height: auto; margin-bottom: 18px; }
.welcome-logo-dark { display: none; }

body.remote-chat:not(.light-theme) .welcome-logo-light { display: none; }

body.remote-chat:not(.light-theme) .welcome-logo-dark { display: block; }

/* The chat's tasks run on a registered machine whose logos are still
   on their way (paintWelcomeBrand in main.js): this daemon's are not
   shown under that machine's name, and they keep their place so the
   greeting does not jump when the machine's arrive. */
#welcome.logos-pending .welcome-logo { visibility: hidden; }

#welcome h2 { font-size: var(--fs-2xl); font-weight: 600; color: var(--fg); margin-bottom: var(--space-1); }
#welcome p { font-size: var(--fs-base); color: var(--dim); margin-bottom: var(--space-3); }

#remote-url { width: 100%; margin-bottom: var(--space-2-5); }

/* "Settings of <machine>": the settings sheet is for the chat
   header's remote machine (see renderSettingsMachine in main.js). */
.settings-machine {
  width: 100%; margin-bottom: var(--space-2-5);
  font-size: var(--fs-base); font-weight: 600; color: var(--green);
}

.remote-url-bar {
  display: flex; flex-direction: column; align-items: stretch; gap: var(--space-1);
  background: color-mix(in srgb, var(--fg) 3%, transparent);
  border: 1px solid color-mix(in srgb, var(--fg) 8%, transparent);
  border-radius: var(--radius-lg); padding: var(--space-1-5) var(--space-2-5);
}

.remote-url-label {
  font-size: var(--fs-sm); color: var(--dim);
}

.remote-url-row {
  display: flex; align-items: center; gap: var(--space-1-5); min-width: 0;
}

.remote-url-link {
  font-size: var(--fs-sm); color: var(--accent); text-decoration: none;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  user-select: all; cursor: pointer;
}

.remote-url-link:hover { text-decoration: underline; }

.remote-url-copy {
  flex-shrink: 0; background: none; border: none; cursor: pointer;
  color: var(--dim); padding: var(--space-0-5); display: flex; align-items: center;
  border-radius: var(--radius-sm); transition: color var(--dur-base);
}
.remote-url-copy svg { width: 14px; height: 14px; }
.remote-url-copy:hover { color: var(--fg); }
.remote-url-copy.copied { color: var(--status-ok); }

/* One-line note under the Local/LAN URL bars telling the user how to
   trust the local CA that signs their certificate (kiss-web --trust-ca
   on this machine, the /ca.crt download on a phone). */
.remote-url-tls-hint {
  font-size: var(--fs-sm); color: var(--dim); padding: 0 var(--space-2-5);
}
.remote-url-tls-hint code { font-size: inherit; user-select: all; }
.remote-url-tls-hint a { text-decoration: none; }
.remote-url-tls-hint a:hover { text-decoration: underline; }

/* Every transcript panel (tool calls, results, Thinking, prompts, status
   lines) runs the chat column's full width from its left edge; the
   user's own bubbles (.task-panel, .user-msg above) are the exception,
   against the right edge. */
.ev { margin-bottom: var(--space-1); animation: fadeIn var(--dur-base) var(--ease); }

@keyframes fadeIn { from { opacity: 0; transform: translateY(3px); } to { opacity: 1; transform: none; } }

/* The model's thinking tokens, streamed as plain text into the Thinking
   panel ahead of its words (.txt): dimmer and italic, no box of its own. */
.think {
  font-size: var(--fs-base); line-height: 1.5; color: var(--dim); font-style: italic;
  padding: var(--space-0-5) 0 var(--space-1); white-space: pre-wrap; word-break: break-word;
}

/* Keyboard focus ring for the focusable disclosure headers (tabindex="0" role="button"). */
.collapse-header:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* The model's words: plain prose on the canvas at the reading size,
   with no bubble, as Claude Code Desktop shows a reply. */
.txt {
  font-size: var(--fs-lg); line-height: 1.5; color: var(--fg);
  padding: var(--space-0-5) 0; white-space: pre-wrap; word-break: break-word;
}
.txt.md-body { white-space: normal; }

/* Its inline code and code blocks are Markdown's (.md-body, further
   down). */

/* A tool call, as Claude Code Desktop shows one: ONE quiet line on the
   canvas (the header below), with no frame.  Opened, the call's
   arguments, output and result sit in a sunken card under that line:
   the panel's ::before, a rounded wash that starts below the header,
   so the line itself does not move when the panel opens.  `isolation`
   keeps the wash behind the panel's own content only.  The Trajectory
   panel, the prompts and the /ask answer share the line and the card.
   --panel-h-row is the header's one-line height; --panel-h names the
   open panel's header as the anchor of its own card (the scope keeps
   a panel nested in the card out of it). */
.tc, .trajectory, .system-prompt, .prompt, .ask-answer {
  --panel-h-row: calc(1.5 * var(--fs-base) + 2 * var(--space-0-5));

  position: relative;
  margin: var(--space-0-5) 0;
  isolation: isolate;
  anchor-scope: --panel-h;
}

.tc:not(.collapsed), .trajectory:not(.collapsed), .system-prompt:not(.collapsed),
.prompt:not(.collapsed), .ask-answer:not(.collapsed) {
  margin: var(--space-1) 0 var(--space-2-5);
  padding-bottom: var(--space-1);
}

.tc:not(.collapsed)::before, .trajectory:not(.collapsed)::before,
.system-prompt:not(.collapsed)::before, .prompt:not(.collapsed)::before,
.ask-answer:not(.collapsed)::before {
  content: '';
  position: absolute; z-index: var(--z-behind);
  inset: calc(var(--panel-h-row) + var(--space-1)) 0 0;
  border-radius: var(--radius-xl);
  background: var(--panel-tint);
}

/* A header that wraps (a long tool name, the question of an /ask
   answer) is taller than one line: the card starts under the header's
   real bottom edge.  A browser without CSS anchor positioning keeps
   the one-line offset above. */
@supports (anchor-scope: --panel-h) {
  .tc:not(.collapsed)::before, .trajectory:not(.collapsed)::before,
  .system-prompt:not(.collapsed)::before, .prompt:not(.collapsed)::before,
  .ask-answer:not(.collapsed)::before {
    top: calc(anchor(--panel-h bottom, var(--panel-h-row)) + var(--space-1));
  }
}

/* Panel headers: one quiet line for every tool (Bash included), the
   prompts, the LLM call and the user's bubbles, so the transcript
   reads as one surface and the eye is drawn only to the content and
   to the few state colours (a pending question, a failed result, a
   warning).  The name is the body colour at the medium weight, the
   one-line argument after it (.collapse-preview) dimmed; the chevron
   at the line's end is .collapse-header's (further down). */
.tc-h, .task-panel-h, .trajectory-h, .system-prompt-h, .prompt-h {
  padding: var(--space-0-5) var(--space-8) var(--space-0-5) 0;
  font-size: var(--fs-base); font-weight: 400; line-height: 1.5;
  color: var(--dim);
}
.tc-h:hover, .task-panel-h:hover, .trajectory-h:hover { color: var(--fg); }
.tc-h-name { color: var(--fg); font-weight: 500; }

.tc:not(.collapsed) > .tc-h, .trajectory:not(.collapsed) > .trajectory-h,
.system-prompt:not(.collapsed) > .system-prompt-h, .prompt:not(.collapsed) > .prompt-h,
.ask-answer:not(.collapsed) > .ask-answer-h { margin-bottom: var(--space-1); anchor-name: --panel-h; }

/* The user's bubble: its label ("Task", "Message") is the same line a
   step smaller, inset like the bubble's text. */
.task-panel-h {
  padding: var(--space-1-5) var(--space-8) 0 var(--space-3);
  font-size: var(--fs-md);
}

.task-panel.collapsed > .task-panel-h,
.user-msg.collapsed > .task-panel-h { padding-bottom: var(--space-1-5); }

/* While a panel is active (panel.panel-active: a tool call from its
   tool_call to its tool_result, the Thinking panel while the model
   thinks and writes; stampPanelStart / finalizePanelTime in main.js),
   its header text breathes: a mild, slow opacity pulse. */
.panel-active > .tc-h,
.panel-active > .llm-panel-hdr {
  animation: panel-pulse 1.8s ease-in-out infinite;
}

@keyframes panel-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: .55; }
}

@media (prefers-reduced-motion: reduce) {
  .panel-active > .tc-h,
  .panel-active > .llm-panel-hdr { animation: none; }
}

/* The Trajectory panel a finished task's event panels fold into
   (foldTrajectory in main.js): the tool-call panel's frame and quiet
   header (.trajectory / .trajectory-h share .tc's rules above) around
   the task's panels (.trajectory-sub below). */
.trajectory.collapsed > :not(.trajectory-h, .panel-copy-btn) { display: none; }

/* ask_user_question renders as the "Question" panel: the question as
   prose in a raised card with a hairline, the answer typed into the
   composer.  While the question waits for its answer the card's
   hairline is the warning colour and its header carries a dot of it:
   the one panel that asks the user to act. */
.tc-question:not(.collapsed)::before {
  background: var(--surface2);
  border: 1px solid var(--border-input);
}

.tc-question-pending:not(.collapsed)::before { border-color: var(--warning); }

.tc-question-pending > .tc-h.tc-h-question::before {
  content: '';
  flex: none; align-self: center;
  width: 6px; height: 6px; margin-right: var(--space-1-5);
  border-radius: var(--radius-round);
  background: var(--warning);
}

.tc-question-hint { font-weight: 400; color: var(--dim); }

.tc-question-body {
  font-size: var(--fs-lg); line-height: 1.5; padding: var(--space-2-5) var(--space-3);
  color: var(--fg);
  overflow-wrap: anywhere; word-break: break-word;
}

.tc.collapsed > :not(.tc-h, .panel-copy-btn, .panel-stop-btn) { display: none; }

.tc-summary-desc {
  padding: var(--space-1-5) var(--space-3);
  font-size: var(--fs-base);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: var(--fg);
}

/* A folded summary still shows its text, with no card: it lines up
   with the header. */
.tc.tc-summary.collapsed > .tc-summary-desc { display: block; padding: 0 0 var(--space-1); }
.tc-summary-desc.md-body { white-space: normal; }

.tc-summary > .tc-h > .collapse-preview { display: none; }

.tc-summary > .tc-h > .tc-summary-hint {
  color: var(--faint);
  font-weight: 400;
}

.tc.tc-summary:not(.collapsed) > .tc-h > .tc-summary-hint {
  display: none;
}

/* The panels a summary tool call adopted, and the event panels of a
   finished task folded into its Trajectory panel: nested under the
   adopting panel's header, shown when it is opened. */
.summary-sub,
.trajectory-sub {
  margin: var(--space-1) var(--space-3) var(--space-1-5);
  padding-left: var(--space-3);
  border-left: 1px solid var(--panel-line);
}

/* The line an opened panel shows while its events are on their way
   from the daemon, or why they could not be read (setLazyNote in
   main.js). */
.lazy-note {
  margin: var(--space-1) var(--space-3) var(--space-1-5);
  color: var(--dim);
  font-size: var(--fs-sm);
}

/* A file path: monospace in the accent colour, a link once the daemon
   has confirmed the file (data-path): underlined under the pointer
   only, as every link of the transcript. */
.tp {
  font-size: var(--fs-md); color: var(--accent);
  font-family: var(--font-mono);
  word-break: break-all;
}
.tp[data-path] { cursor: pointer; }
.tp[data-path]:hover { text-decoration: underline; }

.kiss-filelink {
  color: var(--accent);
  cursor: pointer;
  word-break: break-all;
}

.kiss-filelink:hover { text-decoration: underline; }

.tc-b {
  padding: var(--space-2-5) var(--space-3); max-height: 200px; overflow-y: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-md); line-height: 1.5; word-break: break-word;
}
.tc-b pre { margin: var(--space-1) 0; white-space: pre-wrap; word-break: break-word; }

/* A path on the card's sunken fill: the accent a step toward the text
   colour, which keeps the link readable on that fill. */
.tc-b .tp { color: color-mix(in srgb, var(--accent) 85%, var(--fg)); }
.tc-arg { margin: var(--space-0-5) 0; color: var(--dim); }
.tc-arg-name { color: var(--faint); font-weight: 400; }

/* A changed line: its hue mixed toward the text colour, so that the
   line, and its changed words on their stronger fill, stay readable
   on the tint of the same hue. */
.diff-old {
  color: color-mix(in srgb, var(--red) 55%, var(--fg));
  background: color-mix(in srgb, var(--red) 8%, transparent);
  padding: 1px var(--space-1-5); display: block; white-space: pre-wrap; word-break: break-word;
}

.diff-new {
  color: color-mix(in srgb, var(--green) 55%, var(--fg));
  background: color-mix(in srgb, var(--green) 8%, transparent);
  padding: 1px var(--space-1-5); display: block; white-space: pre-wrap; word-break: break-word;
}

.diff-ctx {
  color: var(--dim); padding: 1px var(--space-1-5); display: block; opacity: 0.65;
  white-space: pre-wrap; word-break: break-word;
}
.diff-hl-del { background: color-mix(in srgb, var(--red) 30%, transparent); border-radius: var(--radius-xs); padding: 0 1px; }
.diff-hl-add { background: color-mix(in srgb, var(--green) 30%, transparent); border-radius: var(--radius-xs); padding: 0 1px; }
.extra { color: var(--dim); margin: var(--space-0-5) 0; }

/* A tool's result: monospace text in a sunken card of its own.  One
   that failed takes a faint red wash; inside its tool call the result
   is a section of the call's card instead (.tc > .tr below). */
.tr {
  padding: var(--space-2) var(--space-3); margin: var(--space-1-5) 0;
  border-radius: var(--radius-xl);
  font-family: var(--font-mono);
  font-size: var(--fs-md); max-height: 150px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word; background: var(--panel-tint);
}
.tr.err { background: color-mix(in srgb, var(--red) 7%, transparent); }
.tr.err strong { color: var(--red); font-weight: 500; }

/* A note or a warning banner is one quiet line with a coloured label,
   not a box. */
.tr.note, .tr.warn {
  padding: var(--space-0-5) 0; background: none;
  font-family: var(--font-ui); font-size: var(--fs-base); color: var(--dim);
}
.tr.note strong { color: var(--green); font-weight: 500; }
.tr.warn strong { color: var(--warning); font-weight: 500; }

/* The launch-phase line ("Classifying task…", "Preparing worktree…"):
   a dim status line led by the working spinner at the end of the
   transcript while the daemon works before the agent's first output. */
.launch-phase {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) 0; color: var(--dim);
  font-size: var(--fs-base);
}
.launch-phase > .status-spinner { color: var(--brand-clay); }

.tr .rl { font-size: var(--fs-md); font-weight: 500; font-family: var(--font-ui); margin-bottom: var(--space-1); }
.tr .rl.fail { color: var(--red); }

/* The result is the agent's reply: plain prose on the canvas at the
   reading size under a small label, as Claude Code Desktop shows a
   reply, with no bubble of its own.  A hairline over the label sets
   the answer off from the tool lines above it. */
.rc {
  margin: var(--space-3) 0 var(--space-2);
  padding-top: var(--space-3);
  border-top: 1px solid var(--border);
}

.rc-h { display: flex; flex-direction: column; align-items: flex-start; }
.rc-h h3 { color: var(--dim); font-size: var(--fs-md); font-weight: 500; }

.rc-body {
  padding: var(--space-1) 0 0; font-size: var(--fs-lg);
  word-break: break-word; line-height: 1.5;
}
.rc-body.pre { white-space: pre-wrap; }

.rc-status { color: var(--status-ok); font-weight: 500; font-size: var(--fs-base); margin-bottom: var(--space-1-5); }
.rc-status.rc-status-fail { color: var(--status-fail); }

/* .system-prompt / .prompt and their headers share .tc's rules above. */
.system-prompt-body, .prompt-body {
  padding: var(--space-2-5) var(--space-3); font-size: var(--fs-base); word-break: break-word;
  line-height: 1.5; max-height: 400px; overflow-y: auto;
}

/* The finished `/ask` answer, shown inside the running task's transcript
   (the answering sub-agent's nested tab closes when it ends); its card
   is .tc's above, in a faint red wash when the answer failed. */
.ask-answer.failed:not(.collapsed)::before { background: color-mix(in srgb, var(--status-fail) 7%, transparent); }

.ask-answer-h {
  padding: var(--space-0-5) var(--space-8) var(--space-0-5) 0; font-size: var(--fs-base); color: var(--dim);
  display: flex; align-items: baseline; gap: var(--space-2); flex-wrap: wrap;
}

.ask-answer-label { color: var(--fg); font-weight: 500; }

.ask-answer.failed .ask-answer-h,
.ask-answer.failed .ask-answer-label { color: var(--status-fail); }

.ask-answer-q { color: var(--dim); word-break: break-word; }

.ask-answer-body {
  padding: var(--space-2-5) var(--space-3); font-size: var(--fs-lg); word-break: break-word;
  line-height: 1.5;
}

.sys {
  font-size: var(--fs-md); color: var(--dim);
  font-family: var(--font-mono);
  white-space: pre-wrap; word-break: break-word; padding: var(--space-0-5) 0;
}

/* A Bash call's streamed output: a sunken card of its own when it
   stands alone, a section of the call's card (a hairline over it)
   inside its tool call, like the call's result.  A failed result
   keeps its red wash there. */
.bash-panel {
  background: var(--panel-tint);
  border-radius: var(--radius-xl); margin: var(--space-0-5) 0 var(--space-2); padding: var(--space-2) var(--space-3);
}

.tc > .bash-panel,
.tc > .tr {
  margin: 0; border-radius: 0;
  border-top: 1px solid var(--border);
}

.tc > .bash-panel,
.tc > .tr:not(.err) { background: none; }

/* A command that has printed nothing has no output section to show. */
.bash-panel:has(> .bash-panel-content:empty) { display: none; }

.bash-panel-content {
  max-height: 200px; overflow-y: auto;
  font-family: var(--font-mono);
  font-size: var(--fs-md); line-height: 1.5; color: color-mix(in srgb, var(--fg) 70%, transparent);
  white-space: pre-wrap; word-break: break-word;
}

/* Images a tool call generated, embedded on its tool_result event and
   rendered inline in the tool's panel (see appendResultImages). */
.tr-images {
  display: flex; flex-wrap: wrap; gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
}
.tc > .tr-images { border-top: 1px solid var(--border); }

.tr-img-box {
  display: flex; flex-direction: column; gap: var(--space-1);
  max-width: 100%; min-width: 0;
}

.tr-img {
  display: block; max-width: 100%; max-height: 260px;
  width: auto; height: auto;
  border: 1px solid var(--border); border-radius: var(--radius-lg);
  cursor: zoom-in;

  /* Checkerboard-free neutral backing so transparent PNGs stay
     legible on both themes. */
  background: color-mix(in srgb, var(--fg) 4%, var(--bg));
}
.tr-img.tr-img-full { max-height: none; cursor: zoom-out; }

/* A replayed picture not fetched yet (loadReplayImageWhenShown): a
   box of its own, so it has a place on screen to come into view at,
   on the backing the picture then fills.  One the daemon could not
   serve shows its alt text in a dashed box. */
.tr-img.tr-img-lazy { min-width: 160px; min-height: 90px; cursor: default; }

.tr-img.inline-img-missing {
  min-width: 0; min-height: 0; padding: var(--space-1) var(--space-2);
  border-style: dashed; color: var(--dim); font-size: var(--fs-sm);
}

.tr-img-cap {
  font-size: var(--fs-sm); color: var(--dim);
  word-break: break-all;
}

/* A picture the agent wrote to disk and named in a result, answer or
   Markdown panel (loaded by loadInlineImages): never wider than the
   panel; one the daemon could not serve shows its alt text in a
   dashed box with the reason in its tooltip. */
.md-body img, .rc-body img { max-width: 100%; height: auto; }

.md-body img.inline-img-missing, .rc-body img.inline-img-missing {
  display: inline-block; padding: var(--space-1) var(--space-2);
  border: 1px dashed var(--dim); border-radius: var(--radius-sm);
  color: var(--dim); font-size: var(--fs-sm);
}

/* The model's turn (its thinking, then its words): plain prose on the
   canvas under a quiet disclosure line, with no frame and no scroll
   box of its own, as Claude Code Desktop shows a reply. */
.llm-panel { position: relative; margin: var(--space-1) 0 var(--space-2); }

/* The composer's wait spinner: the shared ring (see .status-spinner)
   in Claude's clay, the working colour, faded in while a task runs. */
#wait-spinner {
  color: var(--brand-clay);
  transition: opacity var(--dur-slow); opacity: 0;
}

#wait-spinner.active { opacity: 1; }

/* The suggested next task under a finished one: a quiet card (raised
   surface, hairline) that fills the composer when pressed. */
.followup-bar {
  display: flex; flex-direction: column; gap: var(--space-0-5);
  padding: var(--space-2-5) var(--space-3); margin: var(--space-3) 0 var(--space-2);
  background: var(--surface2); border: 1px solid var(--border);
  border-radius: var(--radius-xl); cursor: pointer; transition: background var(--dur-base), border-color var(--dur-base);
  animation: fadeIn var(--dur-slow) var(--ease);
}

.followup-bar:hover { border-color: var(--border-hover); }

.fu-label { font-size: var(--fs-md); font-weight: 500; color: var(--dim); flex-shrink: 0; }

.fu-text {
  font-size: var(--fs-base); color: var(--fg);
  white-space: normal; word-break: break-word;
}

/* The overlay repeats the typed text invisibly and puts the ghost
   suggestion after it, so its text must lay out exactly like the
   textarea's: browsers reset a textarea's letter-spacing to normal and
   wrap it with overflow-wrap: break-word, while the overlay would
   inherit any letter-spacing set on the page and start the ghost off
   the last typed characters.  The right padding (the same as #task-input's)
   keeps the text clear of the two 24px buttons (save, clear) over the
   box's right end, else a click on the last characters of a full line
   saves or clears the draft instead of moving the caret. */
#ghost-overlay,
#dictation-preview {
  position: absolute; top: 0; left: 0; right: 0;
  pointer-events: none; white-space: pre-wrap; overflow-wrap: break-word;
  font-family: inherit; font-size: var(--fs-base); line-height: 1.5; letter-spacing: normal;
  color: transparent;
  padding: var(--space-0-5) calc(2 * var(--space-6) + var(--space-1)) var(--space-0-5) var(--space-0-5);
  max-height: 50vh; overflow: hidden; scrollbar-gutter: stable;
}

#ghost-overlay { min-height: 4.5em; }

/* The words of an utterance that is being dictated (voice.js
   renderPreview) are laid out the same way, after an invisible copy of
   the text before the caret.  The box is made as tall as they need, so
   their overlay has no height of its own to add. */
#ghost-overlay .ghost-text,
#dictation-preview .dictation-words {
  color: var(--faint);
}

/* While they are shown they stand in for the ghost suggestion and the
   placeholder, which would be drawn in the same place. */
#input-text-wrap.dictating #ghost-overlay { visibility: hidden; }
#input-text-wrap.dictating #task-input::placeholder { color: transparent; }

#listening-overlay {
  display: none; position: absolute; inset: 0; z-index: var(--z-float);
  pointer-events: none; align-items: center; justify-content: flex-start;
  font-family: inherit; font-size: calc(var(--fs-base) * 1.8);
  font-weight: 600; color: var(--brand-clay);
  padding: var(--space-0-5) var(--space-4) var(--space-0-5) var(--space-0-5);
  animation: kiss-listening-blink 1s step-start infinite;
}

#input-text-wrap.listening #listening-overlay { display: flex; }

/* The overlay stands in for the placeholder. */
#input-text-wrap.listening #task-input::placeholder { color: transparent; }

@keyframes kiss-listening-blink {
  50% { opacity: 0; }
}

#input-area {
  flex-shrink: 0;
  position: relative;
}

#input-drawer-btn {
  position: absolute;
  top: -13px;
  right: 24px;
  z-index: var(--z-handle);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 24px;
  padding: 0;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-pill);
  color: var(--dim);
  cursor: pointer;
  transition: color var(--dur-base), background var(--dur-base), border-color var(--dur-base);
  user-select: none;
}
#input-drawer-btn * { user-select: none; }

#input-drawer-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}
#input-drawer-btn svg { transition: transform var(--dur-slow) var(--ease); }
#input-drawer-btn[aria-expanded="false"] svg { transform: rotate(180deg); }

/* Collapsing the composer hides the textarea (and file chips /
   autocomplete) but keeps #input-footer -- the button bar below the
   text area -- visible. */
#input-area.drawer-collapsed > :not(#input-drawer-btn, #input-container) { display: none !important; }
#input-area.drawer-collapsed #input-container > :not(#input-footer) { display: none !important; }

#input-area.drawer-collapsed { min-height: 12px; }

/* A tab showing a file or another non-chat view keeps the
   composer's BUTTON ROW: New chat, the mic and ... (more actions)
   stay reachable whatever the tab shows (a mic that is on can always
   be turned off; what it hears brings the chat back). The text box
   and the chat-only controls — Inject promptlet in the ... menu, the
   model picker, Send/Stop — hide: they act on a chat transcript that
   is not on screen. */
body.content-tab-open #input-area > :not(#input-container) { display: none !important; }
body.content-tab-open #input-container > :not(#input-footer) { display: none !important; }

/* The row must survive an owner that hid its composer with an INLINE
   display:none (a finished sub-agent tab, a worktree action bar): the
   + and ... buttons are the point of keeping the footer here. */
body.content-tab-open #input-container { display: block !important; }

/* Chat-only controls hide; Stop stays reachable (its own inline
   display already tracks whether the owning chat is running). */
body.content-tab-open #tricks-btn,
body.content-tab-open #model-picker,
body.content-tab-open #wait-spinner,
body.content-tab-open #send-btn { display: none !important; }
#file-chips { display: flex; flex-wrap: wrap; gap: var(--space-1-5); margin-bottom: var(--space-2); }
#file-chips:empty { display: none; margin-bottom: 0; }

.file-chip {
  display: inline-flex; align-items: center; gap: var(--space-1-5);
  padding: var(--space-1) var(--space-2-5); font-size: var(--fs-md);
}
.file-chip img { width: 20px; height: 20px; border-radius: var(--radius-sm); object-fit: cover; }

.file-chip .fc-rm {
  cursor: pointer; color: var(--faint); margin-left: var(--space-1); transition: color var(--dur-base);
}
.file-chip .fc-rm:hover { color: var(--fg); }

/* A camera photo is decoded and re-encoded before it can be sent; the chip
   stays in place, greyed out, until its bytes are ready. */
.file-chip.pending { opacity: 0.6; }

#input-container { transition: border-color var(--dur-base) var(--ease); }

/* The composer's states: a file dragged over it (the focus ring's
   accent frame over a neutral wash) and, framed in red, an ask_user
   question waiting for the answer typed into it.  Each pair of
   selectors outranks the remote skin's composer rules
   (remote-codex.css), at rest and focused. */
body.remote-chat #input-container.drag-over,
body.remote-chat #input-container.drag-over:focus-within {
  border-color: var(--accent);
  background: var(--hover);
}

body.remote-chat.ask-answering #input-container,
body.remote-chat.ask-answering #input-container:focus-within {
  border-color: color-mix(in srgb, var(--red) 60%, transparent);
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--red) 30%, transparent);
}

#input-wrap { display: flex; align-items: flex-start; gap: var(--space-1); }
#input-text-wrap { flex: 1; min-width: 0; position: relative; }

/* A long draft scrolls inside the box instead of pushing the
   composer off the window.  The ghost overlay shares the cap and the
   scrollbar gutter, so both wrap lines at the same width, and follows
   the textarea's scrollTop (syncGhostScroll in main.js). */
#task-input {
  width: 100%; background: transparent; border: none; color: var(--fg);
  font-size: var(--fs-base); line-height: 1.5;
  resize: none; outline: none;
  padding: var(--space-0-5) calc(2 * var(--space-6) + var(--space-1)) var(--space-0-5) var(--space-0-5);
  max-height: 50vh; overflow-y: auto; scrollbar-gutter: stable;
}

/* 24x24 is the WCAG 2.2 minimum pointer target; the glyph keeps its
   size, the padding grows the hit area so a near miss does not land in
   the input and move the caret instead of clearing.  The same control
   clears the input and the sidebar's search boxes; only its anchor in
   the box differs.  The input's save button is its twin, one button
   to the left. */
#input-clear-btn,
#input-save-btn,
.search-clear-btn {
  position: absolute; z-index: var(--z-float-top);
  background: none; border: none; color: var(--faint);
  font-size: var(--fs-xl); line-height: 1; cursor: pointer;
  width: 24px; height: 24px; border-radius: var(--radius-md); padding: 3px;
  display: flex; align-items: center; justify-content: center;
  transition: color var(--dur-base), background var(--dur-base);
}
#input-clear-btn { top: 0; right: 0; }
#input-save-btn { top: 0; right: var(--space-6); }

/* The save keeps a prompt in the making.  An answer to an agent's
   question is not one: the answer box offers no save. */
body.ask-answering #input-save-btn { display: none; }

.search-clear-btn { top: 50%; right: 5px; transform: translateY(-50%); }

#input-clear-btn:hover,
#input-save-btn:hover,
.search-clear-btn:hover { color: var(--fg); background: var(--hover-strong); }

#input-actions { display: flex; gap: var(--space-2); align-items: center; flex-shrink: 0; }

#send-btn {
  border: none; border-radius: var(--radius-round); cursor: pointer;
  transition: background var(--dur-base), color var(--dur-base); display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
#send-btn svg { width: 16px; height: 16px; }
#send-btn:disabled { cursor: not-allowed; }

#stop-btn {
  border-radius: var(--radius-round); cursor: pointer; transition: background var(--dur-base); display: none;
  align-items: center; justify-content: center; flex-shrink: 0;
}
#stop-btn svg { width: 15px; height: 15px; }

/* Stop requested, agent not there yet: pulse so a pending stop cannot be
   mistaken for a click the daemon never received. */
#stop-btn.stopping { animation: blink-pending 1.1s ease-in-out infinite; }

/* The pending pulse of the Stop button and of the busy voice button. */
@keyframes blink-pending {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

#input-footer {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: var(--space-1) var(--space-2);
}

#footer-tools { position: relative; display: flex; align-items: center; min-width: 0; overflow: visible; flex-wrap: wrap; }

#model-picker { position: relative; display: flex; align-items: center; min-width: 0; overflow: visible; }

#model-btn {
  display: flex; align-items: center;
  font-size: var(--fs-md); font-weight: 500; cursor: pointer;
  transition: background var(--dur-base), color var(--dur-base);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
#model-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

/* A truncated model name keeps its END visible (the distinctive part:
   variant/size/date), so the ellipsis goes at the START: an RTL line
   puts the overflow ellipsis on the left while the label text itself
   stays LTR (refreshModelLabel pins the order with U+200E marks). */
#model-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; }

/* The composer's icon buttons.  remote-codex.css draws them, and
   .more-menu-item below the ones that sit in the "..." menu. */
#menu-btn,
#meta-drawer-btn,
#new-chat-btn,
#more-btn,
.toggle-btn { cursor: pointer; position: relative; }

#share-btn.share-ok { color: var(--green); }
#share-btn.share-err { color: var(--red); }
#voice-btn.voice-loading { opacity: 0.5; }
#voice-btn.voice-listening { animation: voice-pulse 1.6s ease-in-out infinite; }
#voice-btn.voice-error { color: var(--error); }

/* A recording or transcribing round colours the button; the second
   selector of each outranks the remote skin's listening colour. */
#voice-btn.voice-triggered,
body.remote-chat #voice-btn.active.voice-triggered { color: var(--red); animation: blink-pending 0.8s ease-in-out infinite; }

#voice-btn.voice-transcribing,
body.remote-chat #voice-btn.active.voice-transcribing { color: var(--warning); animation: blink-pending 0.8s ease-in-out infinite; }

@keyframes voice-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* The mic (voice.js, "Dictation") in the voice trigger's colours: dim
   while it starts, pulsing while it listens, red while it hears
   speech and amber while a transcript is on its way (also after the
   mic was turned off), and the error colour after a failed start.  The
   selectors after the first of a group outrank the remote skin's
   colours for the button at rest, listening and under the pointer. */
#dictate-btn.dictate-loading { opacity: 0.5; }
#dictate-btn.active { animation: voice-pulse 1.6s ease-in-out infinite; }

#dictate-btn.dictate-error,
body.remote-chat #dictate-btn.dictate-error,
body.remote-chat #dictate-btn.dictate-error:hover { color: var(--error); }

#dictate-btn.dictate-transcribing,
body.remote-chat #dictate-btn.dictate-transcribing,
body.remote-chat #dictate-btn.dictate-transcribing:hover,
body.remote-chat #dictate-btn.active.dictate-transcribing { color: var(--warning); animation: blink-pending 0.8s ease-in-out infinite; }

#dictate-btn.dictate-hearing,
body.remote-chat #dictate-btn.active.dictate-hearing { color: var(--red); animation: blink-pending 0.8s ease-in-out infinite; }

#more-menu-wrap { position: relative; display: flex; align-items: center; }

#more-menu {
  position: absolute; bottom: 100%; left: 0;
  min-width: 180px; max-width: min(280px, calc(100vw - 24px));
  display: none; flex-direction: column; padding: var(--space-1);
  z-index: var(--z-menu); margin-bottom: var(--space-1);
}
#more-menu.open { display: flex; }

.more-menu-item {
  display: flex; align-items: center; gap: var(--space-2);
  background: none; border: none;
  cursor: pointer; text-align: left;
  font-size: var(--fs-base);
  transition: background var(--dur-fast), color var(--dur-base);
  white-space: nowrap;
}

/* 0.5 keeps the disabled label legible so the user can still read
   which action is unavailable. */
.more-menu-item:disabled { opacity: 0.5; cursor: not-allowed; }
.more-item-icon { display: flex; align-items: center; flex-shrink: 0; }
.more-item-icon svg { width: 16px; height: 16px; }
.more-item-label { overflow: hidden; text-overflow: ellipsis; }

/* Anchored to the model button's right edge; positionModelDD() in main.js
   shifts it right when that anchor would push it past the left
   viewport edge (narrow phones, narrow sidebars), so the list is
   always fully on screen. The width caps guarantee it CAN fit. */
#model-dropdown {
  position: absolute; bottom: 100%; right: 0; min-width: min(280px, calc(100vw - 24px)); max-width: min(380px, calc(100vw - 24px));
  max-height: min(320px, calc(100vh - 120px)); display: none; flex-direction: column;
  z-index: var(--z-menu); margin-bottom: var(--space-1);
  overflow: hidden; padding: var(--space-1); gap: var(--space-1);
}
#model-dropdown.open { display: flex; }

.search-wrap { position: relative; }

/* The field's text starts where the rows' text does: the row padding
   less the field's own hairline. */
#model-search {
  width: 100%; background: var(--surface2); border: 1px solid var(--border-input);
  border-radius: var(--radius-md); color: var(--fg);
  font-size: var(--fs-base); padding: var(--space-1-5) 28px var(--space-1-5) calc(var(--space-2) - 1px);
}
#model-search:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }
#model-search::placeholder { color: var(--faint); }
#model-list { overflow-y: auto; overflow-x: hidden; flex: 1; }

/* A "Default model" button (the Settings sheet, a project's panel):
   it looks like the selects of the form it is in and opens the model
   list under itself (wireModelField in main.js moves #model-dropdown
   into this wrapper), from its left edge downwards. */
.model-field { position: relative; }

.model-field-btn {
  display: block; width: 100%; margin-top: var(--space-1);
  padding: var(--space-1-5) var(--space-2-5); min-height: calc(1lh + 2 * var(--space-1-5) + 2px);
  font-size: var(--fs-base); text-align: left;
  background: var(--surface2); border: 1px solid var(--border-input);
  border-radius: var(--radius-lg); color: var(--fg); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.model-field-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 0; border-color: var(--accent); }

/* Never wider than the button: a phone's sheet is narrower than the
   list's own caps, and a list sticking out would scroll it sideways. */
.model-field > #model-dropdown {
  top: 100%; bottom: auto; left: 0; right: auto;
  min-width: min(280px, 100%); max-width: min(380px, 100%);
  margin: var(--space-1) 0 0;
}

/* The form's rule for its own text boxes gives them a top margin. */
.model-field #model-search { margin-top: 0; }

.model-item {
  padding: var(--space-1-5) var(--space-2); font-size: var(--fs-base); color: var(--icon);
  cursor: pointer; display: flex; justify-content: space-between; align-items: center;
  border-radius: var(--radius-md); transition: background var(--dur-fast);
}
.model-item:hover { background: var(--hover); color: var(--fg); }
.model-item.sel { background: var(--selected); color: var(--fg-strong); }

/* Never let a long model name push the list into horizontal
   scrolling: the name shrinks (min-width: 0 overrides the flex
   min-width:auto default) and ellipsizes from the beginning
   (rtl direction, matching the model button's label). */
.model-item-name {
  min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  direction: rtl; text-align: left;
}
.model-item.active { color: var(--fg-strong); font-weight: 500; }

.model-cost {
  font-size: var(--fs-sm); font-weight: 400; font-variant-numeric: tabular-nums;
  color: var(--faint); flex-shrink: 0; margin-left: var(--space-3);
}

/* On the fill of the row under the pointer or the keyboard the faint
   step is too weak for the price: it takes the icon step there. */
.model-item:hover .model-cost,
.model-item.sel .model-cost { color: var(--icon); }

.model-group-hdr {
  padding: var(--space-1-5) var(--space-2) var(--space-1); font-size: var(--fs-md); font-weight: 500;
  color: var(--faint);
  background: var(--menu-bg);
  position: sticky; top: 0; z-index: var(--z-raised);
}

@keyframes acSlideUp {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

/* The popup floats over the composer, inset like the composer's box
   (the input area's side padding in remote-codex.css).  It is the
   scroll container itself, so it has no padding (a padded strip would
   show the rows scrolling past a stuck section header or the footer):
   the rows carry the menu's inset as a margin. */
#autocomplete {
  position: absolute; bottom: 100%; left: 0; right: 0;
  background: var(--menu-bg); border: 1px solid var(--border); border-radius: var(--radius-xl);
  max-height: 300px; overflow-y: auto; display: none;
  z-index: var(--z-popup); box-shadow: var(--shadow-lg);
  margin: 0 var(--space-3) var(--space-1); animation: acSlideUp var(--dur-base) var(--ease);
}

.ac-section {
  padding: var(--space-2) var(--space-3) var(--space-1); font-size: var(--fs-md); font-weight: 500;
  color: var(--faint);
  background: var(--menu-bg);
  position: sticky; top: 0; z-index: var(--z-raised);
}

.ac-item {
  margin: 0 var(--space-1); padding: var(--space-1) var(--space-2); font-size: var(--fs-md); cursor: pointer;
  display: flex; align-items: center; gap: var(--space-1-5);
  border-radius: var(--radius-md);
  transition: background var(--dur-fast);
}
.ac-item:hover { background: var(--hover); }

.ac-item.sel {
  background: var(--selected);
}

.ac-icon {
  flex-shrink: 0; width: 14px; height: 14px;
  display: flex; align-items: center; justify-content: center;
  color: var(--dim); font-size: var(--fs-base);
}

.ac-icon svg {
  width: 10px; height: 10px; stroke: currentcolor; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}

.ac-item.sel .ac-icon {
  color: var(--fg);
}

.ac-text {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: var(--font-mono);
  font-size: var(--fs-md); color: var(--icon); min-width: 0;
}
.ac-item.sel .ac-text { color: var(--fg); }
.ac-dir { color: var(--faint); }
.ac-fname { color: var(--icon); }
.ac-item.sel .ac-dir { color: var(--dim); }
.ac-item.sel .ac-fname { color: var(--fg-strong); }
.ac-hl { color: var(--fg-strong); font-weight: 600; }

.ac-hint {
  font-size: var(--fs-sm); font-weight: 500; color: var(--dim);
  background: var(--hover-strong);
  padding: 0 var(--space-1); border-radius: var(--radius-sm); margin-left: auto;
  flex-shrink: 0;
}

.ac-item.sel .ac-hint {
  color: var(--fg);
}

.ac-footer {
  padding: var(--space-1-5) var(--space-3); font-size: var(--fs-sm); color: var(--faint);
  border-top: 1px solid var(--border); margin-top: var(--space-1);
  display: flex; gap: var(--space-3);
  background: var(--menu-bg);
  position: sticky; bottom: 0;
}

.ac-footer kbd {
  background: var(--hover-strong); color: var(--dim);
  padding: 0 var(--space-1); border-radius: var(--radius-sm); font-size: var(--fs-sm);
  font-family: inherit; font-weight: 500;
}

#sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: 90vw;
  transform: translateX(-100%);

  /* Hidden once the slide out ends, which takes the closed drawer's
     controls out of the Tab order; opening shows it at once (.open). */
  visibility: hidden;
  transition:
    transform var(--dur-slow) var(--ease),
    visibility 0s linear var(--dur-slow);
  z-index: var(--z-drawer);
  padding: var(--space-4);

  /* The horizontal padding, for children that span it (#history-list);
     every rule that changes it resets this too. */
  --sidebar-pad-x: var(--space-4);

  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#sidebar.open { transform: translateX(0); visibility: visible; transition-delay: 0s; }

/* The task-info panel is shown by remote-codex.css (docked on
   desktop, a right-hand drawer on mobile).  Its drawer affordances
   (the tab-bar toggle and the close button) exist only on mobile.
   --meta-hdr-row is the height of a section header's icon buttons,
   and of the header row they sit in (see .meta-section-hdr below).
   --meta-pad-x is the panel's horizontal padding, for the children
   that span it (the section bodies, .meta-section-body, and the
   bottom strip, #meta-footer); every rule that changes the padding
   resets it too.  --meta-bleed is how far a row's fill reaches out of
   the panel's column on each side, and --meta-gutter the room a body
   keeps for its scrollbar. */
#meta-panel {
  --meta-hdr-row: 14px;
  --meta-pad-x: var(--space-4);
  --meta-bleed: calc(var(--meta-pad-x) / 2);
  --meta-gutter: 0px;

  display: none;
}

#meta-close { display: none; }

/* The drawer tab that brings the hidden task-info panel back exists
   only on the desktop remote page with a content tab open
   (remote-codex.css shows it). */
#meta-drawer { display: none; }

/* The tab that unfolds the content pane its hide button folded away
   exists only on the desktop remote page with the pane folded
   (remote-codex.css shows it). */
#content-pane-show { display: none; }

/* Task-info panel sections (every surface).  #meta-panel is a flex
   column; each <section class="meta-section"> is `display: contents`,
   so its header row and its body are the PANEL's flex items: the
   header keeps its natural height whatever happens and only the body
   flexes.  A body scrolls inside its share of the panel.  By default
   every expanded body takes an EQUAL share (`flex: 1 1 0`, below);
   main.js (metasections block) gives a dragged body `flex: 0 1 <px>`,
   except the last expanded section's body, which always fills the
   leftover height.  Every expanded body keeps a minimum share, so a
   dragged body cannot hide the ones below it.  A collapsed section
   shows its header only.  The resizer
   after a section is the separator line between it and the next
   shown section; it drags the boundary while both sides are expanded
   (`static` otherwise: still a separator, no longer a handle).  A
   .meta-section-pinned section (Recommendations) sits on the bottom
   strip and takes no share (see its body's rule below); only its own
   chevron folds or opens it. */
.meta-section { display: contents; }

.meta-section[hidden],
#meta-info:not(.visible) { display: none; }

.meta-section.collapsed > :not(.meta-section-hdr) { display: none !important; }

/* Everything in a section except its body (the header, the Task
   update status line) keeps its own height; only bodies flex. */
.meta-section > :not(.meta-section-body) { flex: 0 0 auto; }

/* A short header row: a tight text line (a plain title row is 12px)
   or the --meta-hdr-row icon buttons, then a 4px gap to the body --
   at least a fifth less than the 18px row and 8px gap the panel had
   (26px -> 18px with buttons, 21px -> 16px without).  A collapsed
   section has no body to keep a gap from, so its header drops the
   gap: a collapsed section costs its header row plus the separator
   and nothing else.  The drawers' close button (#meta-close) sizes
   itself from --meta-hdr-row too: its box ends where the first header
   row ends, so it never covers the header that follows a collapsed
   first section. */
.meta-section-hdr {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  min-width: 0;
  line-height: 1;
}

.sidebar-hdr.meta-section-hdr { margin-bottom: var(--space-1); }

.meta-section.collapsed > .meta-section-hdr { margin-bottom: 0; }

/* A folded pinned section is its header over the bottom strip, whose
   top border is the line under it: as far under the header as a
   separator's line is under any other folded one. */
.meta-section-pinned.collapsed > .meta-section-hdr { margin-bottom: var(--space-1-5); }

.meta-section-toggle {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  padding: 0;
  background: none;
  border: none;
  border-radius: var(--radius-sm);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: color var(--dur-base);
}

.meta-section-toggle:hover { color: var(--fg); }

.meta-section-toggle:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 2px;
}

.meta-section-toggle > span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meta-section-chevron {
  flex: 0 0 auto;
  transition: transform var(--dur-fast) var(--ease);
}

.meta-section-toggle[aria-expanded="true"] .meta-section-chevron { transform: rotate(90deg); }

/* An equal share of the height the headers leave, whatever the
   content (more content than fits scrolls).  With a zero basis these
   bodies are the first to give up space when the panel is too short:
   a dragged body (`flex: 0 1 <px>`, set by main.js) keeps the height
   the user chose until nothing else can shrink.  The minimum height
   is what every expanded body keeps against dragged bodies above it:
   half of an equal share (--meta-body-share, measured by main.js's
   applyMetaSectionLayout), at most 5rem (about a row or two: a
   schedule row whose detail line wraps once is 63px at the 13px
   Cursor scale).  Without
   it a persisted drag left a section's header over an empty 0px body,
   which read as "the Schedule shows no jobs".  Tied to the share, the
   minimums never add up to more than the panel has. */
.meta-section-body {
  flex: 1 1 0px;
  min-height: min(5rem, calc(var(--meta-body-share, 0px) / 2));
  overflow-y: auto;
}

/* A pinned section's body is as tall as its content, and no taller
   than an equal share, past which it scrolls: every other expanded
   body is then left a share at least, so a long recommendation never
   pushes a section out of the panel.  It neither grows nor gives way
   (the bodies that share do both), and keeps no minimum: with nothing
   to show it takes no room. */
.meta-section-pinned > .meta-section-body {
  flex: 0 0 auto;
  min-height: 0;
  max-height: var(--meta-body-share, none);
}

/* A body spans the whole panel, as the history list spans the Chats
   sidebar (#history-list): negative margins cancel the panel's
   padding and the body's own padding puts its content back in the
   panel's column.  So the scrollbar rides at the panel's edge, and a
   row's fill may reach out of the column (--meta-bleed) to end 8px
   from the panel's edges, as a chat row's does.  The id outranks the
   margins and paddings the bodies' own classes set. */
#meta-panel .meta-section-body {
  margin-inline: calc(-1 * var(--meta-pad-x));
  padding-inline: var(--meta-pad-x) max(0px, calc(var(--meta-pad-x) - var(--meta-gutter)));
}

/* Where the pointer is a mouse, a body keeps the 6px scrollbar's room
   at all times and counts it into its right padding (as #history-list
   does), so its content is as wide whether or not it overflows. */
@media (hover: hover) and (pointer: fine) {
  #meta-panel { --meta-gutter: 6px; }

  #meta-panel .meta-section-body { scrollbar-gutter: stable; }
}

/* A view that keeps the rows of the machine or folder the chat just
   left while the next one answers (main.js holdView, which also makes
   it inert): they stay as they are for a quick answer and dim after
   0.4s of waiting, so they are not taken for the new machine's.  The
   answer takes the class off and the rows are back at once. */
.is-held {
  opacity: 0.55;
  transition: opacity var(--dur-base) linear 0.4s;
}

/* The separator between two shown sections: a 1px line inside a 9px
   grab area.  main.js hides the one after the last shown section. */
.meta-section-resizer {
  position: relative;
  flex: 0 0 auto;
  height: 9px;
  margin: var(--space-0-5) 0;
  cursor: row-resize;
  touch-action: none;
}

.meta-section-resizer::after {
  content: '';
  position: absolute;
  left: 0;
  right: 0;
  top: 4px;
  border-top: 1px solid var(--border-soft);
}

.meta-section-resizer.static { cursor: default; }

.meta-section-resizer:focus-visible { outline: none; }

/* Set by main.js while a section boundary is being dragged. */
body.meta-section-resizing {
  user-select: none;
  cursor: row-resize;
}

/* A section header's action buttons (refresh, add), ghost icon
   buttons at the right of the toggle.  A refresh button turns, in the
   working colour, while its data is being fetched; the Task update
   one is disabled meanwhile (a second press cannot start a second
   task-update run). */
.meta-info-hdr { justify-content: space-between; }

.meta-section-refresh {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: var(--meta-hdr-row);
  height: var(--meta-hdr-row);
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--dim);
  cursor: pointer;
  flex: 0 0 auto;
  transition: background var(--dur-base), box-shadow var(--dur-base), color var(--dur-base);
}

/* Under the pointer or the keyboard focus the fill reaches 2px past
   the button's box (a ring of the same colour, so the header row
   keeps its height), which rounds its corner to an icon button's 6px. */
.meta-section-refresh:hover:not(:disabled),
.meta-section-refresh:focus-visible {
  background: var(--hover-strong);
  box-shadow: 0 0 0 var(--space-0-5) var(--hover-strong);
  color: var(--fg);
}

/* The focus outline runs around that ring. */
.meta-section-refresh:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: var(--space-0-5);
}

.meta-section-refresh:disabled { cursor: default; }

/* "Add Folder to Explorer..." is withdrawn while the Explorer shows a
   remote machine's folder (the added folders are this machine's). */
.meta-section-refresh[hidden] { display: none; }

.meta-section-refresh.spinning svg {
  color: var(--brand-clay);
  animation: status-spin 1s linear infinite;
}

/* The line under the header: "Updating…", or when and at what cost
   the shown report was produced, and the last run's failure.  Capped
   so a long error never pushes the report below it out of a short
   panel: past a few lines the status scrolls instead.  Set like the
   report under it (#meta-info-content in remote-codex.css). */
.meta-info-status {
  font-size: var(--fs-base);
  line-height: 1.35;
  color: var(--dim);
  margin: calc(-1 * var(--space-0-5)) 0 var(--space-1-5);
  max-height: 5.5em;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

.meta-info-status:empty { display: none; }

/* The example line of the Schedule and Machines sections is the first
   thing in the section's body, over the list: it scrolls away with
   the rows, so it takes none of the height the panel's headers and
   status lines need (a short panel has none to spare).  Set like a
   status line, with a status line's gap to the first row; a panel too
   narrow for it wraps it.  The padding over it is the room of its
   command's focus ring, which is drawn outside the command's box and
   which the body would cut at its top edge. */
.meta-section-example {
  margin-bottom: var(--space-1-5);
  padding-top: var(--space-0-5);
  font-size: var(--fs-base);
  line-height: 1.35;
  color: var(--dim);
  overflow-wrap: anywhere;
}

/* A body no taller than the minimum a body keeps (5rem, a row's room:
   see .meta-section-body) leaves that room to its rows: there the
   example is not shown, so a body squeezed to its minimum still shows
   a whole row.  The body is a size container for that question; its
   size never came from its content (a share of the panel's height or
   a dragged one, the panel's width), so nothing else changes. */
.meta-section-body:has(> .meta-section-example) { container-type: size; }

@container (height <= 5rem) {
  .meta-section-example { display: none; }
}

/* An example's slash command, which a click, Enter or Space inserts
   into the message box (main.js): the text's own colour in the dim
   line, a text button like an id of the Task Info list
   (.meta-item [data-insert-id], which gives it the pointer and the
   underline).  It wraps with the line in a narrow panel. */
.meta-example-cmd { color: var(--fg); }

/* The time the running task has left by its last update's estimate
   ("About 12 min left (8 to 20 min), done around 09:14"), counted
   down by main.js.  Set like the status line over it, in the text's
   own colour: it is the line a glance at the section is for. */
.meta-info-eta {
  font-size: var(--fs-base);
  line-height: 1.35;
  color: var(--fg);
  margin: 0 0 var(--space-1-5);
  overflow-wrap: anywhere;
}

.meta-info-eta:empty { display: none; }

.meta-info-pending { color: var(--faint); }

/* Schedule and Machines rows (every surface).  A row is a name with an
   optional badge, over a dim second line (a job's schedule and next
   run).
   The task-info panel is set like the Chats sidebar (.history-chat-header
   and .history-day-sep): a row's text has a chat summary's size, weight
   and line height, what is secondary to it (a second line, a badge, a
   count, an age, a state) and every label is a step smaller, and a row
   is a chat row's box - its padding, corner and fill under the
   pointer. */
.sidebar-panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-0-5);
  font-size: var(--fs-base);
  line-height: 1.35;
  color: var(--fg);
}

.sched-row,
.machine-row,
.recommendation-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: var(--space-1-5);
  border-radius: var(--radius-lg);
  transition: background var(--dur-base), border-color var(--dur-base);
}

/* The fill of a Schedule or Machines row reaches out of the panel's
   column (--meta-bleed) and its padding puts the text back at the
   column's edge, under the section's chevron. */
.sched-row,
.machine-row {
  margin-inline: calc(-1 * var(--meta-bleed, 0px));
  padding-inline: var(--meta-bleed, var(--space-1-5));
}

.sched-row:hover,
.sched-row:focus-visible,
.machine-row:hover,
.machine-row:focus-visible,
.recommendation-row:hover,
.recommendation-row:focus-visible {
  background: var(--hover);
  outline: none;
}

.sched-row.paused { opacity: 0.6; }

/* The row buttons (edit, run, pause, copy, delete) sit right-justified
   on the name line; they take the line's own gap, not the task panels'
   margin.  The name stretches, so the first button starts the group at
   the right edge. */
.sched-row .sidebar-item-copy,
.sched-row .sidebar-item-edit,
.sched-row .sidebar-item-delete,
.machine-row .sidebar-item-copy,
.machine-row .sidebar-item-edit,
.machine-row .sidebar-item-delete,
.skill-row .sidebar-item-delete,
.skill-found-row .sidebar-item-edit { margin-left: 0; }

/* A disabled row button (a running job's Run, the local machine's
   Delete, the + of a skill being checked) is dimmed and keeps its
   resting look under the pointer. */
.sched-row .sidebar-item-edit:disabled,
.machine-row .sidebar-item-delete:disabled,
.skill-found-row .sidebar-item-edit:disabled {
  opacity: 0.4;
  cursor: default;
  color: var(--faint);
  background: none;
  box-shadow: none;
}

/* The Recommendations body is a row: the list of cards between the <
   and > buttons that step through them.  The buttons stand in the
   panel's padding, which the body spans, so the cards keep the
   panel's column; a card ends where its section does, at the strip
   under it (the section is the panel's last): no gap in between.  It
   does not scroll: its list does. */
#meta-panel #meta-recommendations-body {
  display: flex;
  align-items: stretch;
  padding-inline: 0;
  overflow: visible;
}

/* A step button fills the padding beside the cards, as tall as they
   are.  With a single task there is nothing to step to (main.js
   disables the buttons), and they go, keeping their room. */
.recommendation-step {
  flex: 0 0 var(--meta-pad-x);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--dim);
  font-size: var(--fs-lg);
  cursor: pointer;
  transition: color var(--dur-base);
}

.recommendation-step:hover,
.recommendation-step:focus-visible { color: var(--fg); }

.recommendation-step:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.recommendation-step:disabled { visibility: hidden; }

/* The list shows ONE task at a time (main.js puts the next one on
   show every 30 seconds, and the step buttons the one before or
   after): every task's card fills the same grid cell, so each is as
   tall as the longest task needs and nothing moves when the card
   changes.  The list is no taller than a third of the window (nor
   than an equal share, the cap of a pinned body above), so a long
   task never makes the pinned card a tall one: it scrolls up and
   down.  The cards sliding in and out are clipped at the list's
   sides; --recommendation-from is the side a card slides in from
   (the keyframes below). */
#meta-recommendations-list {
  --recommendation-from: 100%;

  flex: 1 1 0px;
  min-width: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  max-height: min(var(--meta-body-share, 33vh), 33vh);
  overflow-x: hidden;
}

/* A Recommendations row is a click target (it opens a new chat with
   the task in the composer); the whole sentence shows, wrapped, inside
   its own raised, bordered box, a card.  The box is the Chats search
   field's: its fill, hairline and corner. */
.recommendation-row {
  grid-area: 1 / 1;
  cursor: pointer;
  padding: var(--space-1-5) var(--space-2-5);
  border-width: 1px;
  border-style: solid;
  border-color: var(--border-input);
  background: var(--surface2);
  transition:
    background var(--dur-base),
    border-color var(--dur-base);
}

.recommendation-row:hover,
.recommendation-row:focus-visible {
  border-color: var(--border-hover);
}

/* A card off show (main.js makes it inert, so it takes no click and
   no focus either) is hidden. */
.recommendation-row[inert] { visibility: hidden; }

/* When the rotation moves on, the next card slides in from the right
   while the one it replaces slides out to the left and hides (at once
   under prefers-reduced-motion: --dur-slide is 0 there).  A step back
   (main.js marks the list .recommendation-back) runs the other way:
   the card before comes in from the left as the one on show leaves
   to the right. */
#meta-recommendations-list.recommendation-back { --recommendation-from: -100%; }

.recommendation-row.recommendation-in {
  animation: recommendation-slide-in var(--dur-slide) var(--ease);
}

/* The card sliding out is inert already: the animation keeps it in
   sight until it has left. */
.recommendation-row.recommendation-out {
  animation: recommendation-slide-out var(--dur-slide) var(--ease);
}

@keyframes recommendation-slide-in {
  from { transform: translateX(var(--recommendation-from)); opacity: 0; }
}

@keyframes recommendation-slide-out {
  from { visibility: visible; }

  to {
    visibility: hidden;
    transform: translateX(calc(-1 * var(--recommendation-from)));
    opacity: 0;
  }
}

/* The Recommendations section is pinned to the bottom strip: main.js
   (pinMetaSectionsToBottom) marks the separator over it, or its
   header when no section shows above it, and that element's auto top
   margin takes the free height the strip's would, so the empty room
   opens above the section.  The separator's own top margin becomes a
   border as high, which stays when there is no free height left. */
#meta-panel .meta-pin-start { margin-top: auto; }

#meta-panel .meta-section-resizer.meta-pin-start {
  box-sizing: content-box;
  border-top: var(--space-0-5) solid transparent;
}

#meta-panel:has(.meta-pin-start) > #meta-footer { margin-top: 0; }

.recommendation-row .sidebar-panel-name {
  white-space: normal;
  overflow-wrap: anywhere;
}

.machine-row.unreachable .sidebar-panel-name { opacity: 0.6; }

/* The reachability dot before a machine's name.  With the line's gap
   the 2px margin makes the dot's slot as wide as a section header's
   chevron slot, so the name starts under the section's title. */
.machine-status {
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-right: var(--space-0-5);
  border-radius: var(--radius-round);
  background: var(--status-ok);
}

.machine-status.unreachable { background: var(--status-fail); }

/* The in-place editor of a Schedule row: labelled inputs stacked
   under the row, then Save / Cancel. */
.sidebar-inline-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-1-5);
  margin-top: var(--space-1);
  font-size: var(--fs-base);
  line-height: 1.35;
}

.sidebar-inline-form label {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sidebar-inline-form-label {
  font-size: var(--fs-md);
  color: var(--faint);
}

/* A field is the Chats search field: its text, padding and box. */
.sidebar-inline-form input,
.sidebar-inline-form textarea {
  width: 100%;
  font: inherit;
  color: var(--fg);
  background: var(--surface2);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  padding: var(--space-1-5) var(--space-2-5);
  transition: border-color var(--dur-base);
}

.sidebar-inline-form input:focus,
.sidebar-inline-form textarea:focus {
  border-color: var(--ring-focus);
  outline: none;
}

.sidebar-inline-form textarea { resize: vertical; }

.sidebar-inline-form-buttons {
  display: flex;
  gap: var(--space-1);
}

/* The form's Save is its primary button: the delete confirmation's
   button shape (main.js gives it both classes) with the primary fill,
   not its red. */
.sidebar-confirm-yes.sidebar-inline-form-save {
  background: var(--primary-bg);
  border-color: transparent;
  color: var(--primary-fg);
}

.sidebar-confirm-yes.sidebar-inline-form-save:hover:not(:disabled) {
  background: var(--primary-hover-bg);
}

.meta-info-status.is-error { color: var(--status-fail); }

.sidebar-panel-row-top {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  min-width: 0;
}

.sidebar-panel-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sidebar-panel-sub {
  font-size: var(--fs-md);
  color: var(--dim);
  overflow-wrap: anywhere;
}

/* A filled badge ("local", "paused"); the transparent border gives
   it a pixel of height above and below its text.  A running job's
   badge is in the working colour, its text in --running-fg. */
.sidebar-panel-badge {
  flex: 0 0 auto;
  font-size: var(--fs-md);
  font-weight: 500;
  padding: 0 var(--space-1-5);
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  background: var(--hover-strong);
  color: var(--dim);
}

.sidebar-panel-badge.running {
  background: color-mix(in srgb, var(--brand-clay) 12%, transparent);
  color: var(--running-fg);
}

/* Connectors grid (every surface): a square tile per app, as many to
   a row as the panel fits, each the logo of the app's brand
   (media/connectorLogos.js) or, for an app without one, a monogram
   of its label.  The cells abut, so the pointer goes from one tile to
   the next without leaving the tiles (main.js names the tile under it
   in the status line) and a click anywhere in a cell is the tile's.
   The logo's box is inset in its cell by --app-tile-inset, which the
   grid's padding takes back: the outer logos stand at the edges of
   the panel's column.  That padding replaces the one every body has
   (#meta-panel .meta-section-body, above), so its rule names the
   panel too. */
.app-grid {
  --app-tile: 2.25rem;
  --app-tile-inset: var(--space-0-5);

  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(var(--app-tile), 100%), 1fr));
  align-content: start;
  list-style: none;
  font-size: var(--fs-base);
  line-height: 1;
}

#meta-panel .app-grid {
  padding-inline:
    max(0px, calc(var(--meta-pad-x) - var(--app-tile-inset)))
    max(0px, calc(var(--meta-pad-x) - var(--meta-gutter) - var(--app-tile-inset)));
}

/* A finger needs a larger tile than a mouse. */
@media (pointer: coarse) {
  .app-grid { --app-tile: 3.25rem; }
}

.app-tile-main {
  display: block;
  width: 100%;
  padding: var(--app-tile-inset);
  border: none;
  background: none;
  color: inherit;
  font: inherit;
}

button.app-tile-main { cursor: pointer; }

/* The tile of an app that is being connected takes no pointer: a
   disabled button swallows the pointer's events, and its cell passes
   them on to main.js, which names the tile all the same. */
button.app-tile-main:disabled {
  cursor: default;
  pointer-events: none;
}

/* An app that is not connected is greyed out: its glyph in the faint
   text colour on a faint fill, no colour of its brand. */
.app-logo {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--hover);
  color: var(--faint);
  font-weight: 500;
  transition: background var(--dur-base), border-color var(--dur-base), color var(--dur-base);
}

.app-logo svg {
  width: 62%;
  height: 62%;
  fill: currentcolor;
}

/* A connected app's logo is in its brand's colours: the fill is the
   brand's colour (--app-brand, set by main.js), the glyph white, or
   dark on a colour too light for white (.light-brand).  The hairline
   around the fill keeps a black brand a tile on the dark theme (3:1
   against the panel, on a black fill too).  A monogram has no brand,
   and neither has the pictogram of a service that is no brand's:
   their tile is the text colour, inverted. */
.app-tile.connected .app-logo {
  border-color: color-mix(in srgb, var(--fg) 45%, transparent);
  background: var(--app-brand, var(--fg));
  color: var(--paper);
}

.app-tile.connected .light-brand { color: var(--ink); }

.app-tile.connected .app-monogram,
.app-tile.connected .app-pictogram { color: var(--bg2); }

/* The tile of an app that can be connected lights up under the
   pointer and with the keyboard focus, whose ring goes around the
   logo (the cell's own would be cut by the grid's edges). */
.app-tile-main:focus-visible { outline: none; }

.app-tile-main:focus-visible .app-logo {
  outline: 1px solid var(--ring-focus);
  outline-offset: 1px;
}

button.app-tile-main:focus-visible .app-logo {
  border-color: var(--border-hover);
  background: var(--hover-strong);
  color: var(--fg);
}

@media (hover: hover) {
  button.app-tile-main:hover .app-logo {
    border-color: var(--border-hover);
    background: var(--hover-strong);
    color: var(--fg);
  }
}

/* A finger cannot hover: its tap points at a tile (main.js
   `.is-tapped`, which names it in the status line).  The tile is drawn
   selected, and the next tap on it connects its app. */
.app-tile.is-tapped .app-logo { outline: 2px solid var(--fg); }

.app-tile.is-tapped button:enabled .app-logo {
  background: var(--hover-strong);
  color: var(--fg);
}

/* An app whose state could not be checked: a dot in the warning
   colour on the corner of its greyed tile. */
.app-tile.unknown:not(.connecting) .app-logo::after {
  content: "";
  position: absolute;
  top: -1px;
  right: -1px;
  width: 7px;
  height: 7px;
  border-radius: var(--radius-round);
  background: var(--warning);
}

/* An app a task is connecting: its tile in the working colour,
   pulsing while the task is under way. */
.app-tile.connecting .app-logo {
  border-color: var(--brand-clay);
  background: color-mix(in srgb, var(--brand-clay) 12%, transparent);
  color: var(--running-fg);
  animation: blink-pending 1.5s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .app-tile.connecting .app-logo { animation: none; }
}

/* The status line while it names a tile: one line, cut where the
   panel ends.  A second line would push the grid down, from under the
   pointer that is on the tile. */
.meta-info-status.names-tile {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

/* Skills · Extensions · Plugins section (every surface).  Its title is
   the longest of the panel: a panel too narrow for it on one line
   gives it a second one instead of cutting its end off, which a
   folded section, its header alone, would not show anywhere else. */
#meta-skills .meta-section-toggle > span {
  line-height: 1.15;
  white-space: normal;
}

/* Under the header, the tab strip that picks the pane on show: three
   ghost buttons, the picked one filled as a row under the pointer is.
   A strip too narrow for the three at their full size tightens them
   (the container query below), which keeps them on one line down to
   the 180px panel; a panel narrower still wraps them, so no label is
   ever cut short. */
.skills-tabs {
  container: skills-tabs / inline-size;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-0-5);
  margin-bottom: var(--space-1-5);
}

.skills-tab {
  flex: 1 1 auto;
  margin: 0;
  padding: var(--space-0-5) var(--space-1-5);
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--dim);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 1.5;
  white-space: nowrap;
  cursor: pointer;
  transition: color var(--dur-base), background var(--dur-base);
}

.skills-tab:hover {
  color: var(--fg);
  background: var(--hover);
}

.skills-tab[aria-selected="true"] {
  color: var(--fg);
  background: var(--hover-strong);
}

.skills-tab:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* The three tabs need 13.8rem of strip at their full size where the
   system font is DejaVu Sans, a wide one; under 15rem they are a size
   smaller with the least padding, and need just over 11rem (the 180px
   panel has 11.3rem). */
@container skills-tabs (width < 15rem) {
  .skills-tab {
    padding-inline: var(--space-0-5);
    font-size: var(--fs-sm);
  }
}

/* Under a finger a tab is as tall as a chip is (.meta-tag). */
@media (hover: none) {
  .skills-tab { min-height: 28px; }
}

/* Under the tab strip, the picked tab's search of the internet: the
   Chats search field (#history-search) with its button, a ghost icon
   button, inside the box at the right (where that field has its clear
   button, .search-clear-btn).  The row keeps its height over the
   scrolling body, which holds the picked tab's pane: what the search
   found and, under the status line, the list of what is there. */
.skills-search {
  position: relative;
  margin-bottom: var(--space-1-5);
}

.skills-search input {
  width: 100%;
  font-size: var(--fs-base);
  color: var(--fg);
  background: var(--surface2);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  padding: var(--space-1-5) 30px var(--space-1-5) var(--space-2-5);
  outline: none;
  transition: border-color var(--dur-base);
}

.skills-search input::placeholder { color: var(--faint); }

.skills-search input:focus { border-color: var(--ring-focus); }

.skills-search-btn {
  position: absolute;
  top: 50%;
  right: 3px;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--dim);
  font-size: var(--fs-lg);
  cursor: pointer;
  transition: color var(--dur-base), background var(--dur-base);
}

.skills-search-btn:hover:not(:disabled) {
  color: var(--fg);
  background: var(--hover-strong);
}

.skills-search-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* While the search is under way the button rests in the working
   colour (as a turning refresh button does). */
.skills-search-btn:disabled {
  cursor: default;
  color: var(--brand-clay);
}

/* The status line sits in the body here, over the list it counts;
   it has no header right above it to tuck under. */
.meta-info-status.skills-status { margin-top: 0; }

/* What the search found: a label line (what was searched for, or
   the search's failure) with Clear at its right, then the rows; a
   hairline parts them from the listed rows below. */
.skills-found {
  margin-bottom: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-soft);
}

.skills-found-hdr {
  display: flex;
  align-items: baseline;
  gap: var(--space-1-5);
  margin-bottom: var(--space-1);
  font-size: var(--fs-md);
  line-height: 1.35;
  color: var(--faint);
}

.skills-found-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.skills-found-title.is-error { color: var(--status-fail); }

.skills-clear {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 var(--space-1);
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--dim);
  font: inherit;
  cursor: pointer;
  transition: color var(--dur-base), background var(--dur-base);
}

.skills-clear:hover:not(:disabled) {
  color: var(--fg);
  background: var(--hover-strong);
}

.skills-clear:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.skills-clear:disabled { visibility: hidden; }

/* A row of a pane, found or listed, is a Schedule row's box: the
   name line over dim lines.  Nothing happens on a click of the row
   itself, so it has no fill under the pointer. */
.skill-row,
.skill-found-row {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-inline: calc(-1 * var(--meta-bleed, 0px));
  padding: var(--space-1-5) var(--meta-bleed, var(--space-1-5));
  border-radius: var(--radius-lg);
}

.skill-found-row:focus { outline: none; }

/* A row's description: two lines of it, the rest in its tooltip. */
.skill-description {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

/* A listed row's badge (where a skill comes from, a package's
   version) keeps its text beside a long name, which gives way; a
   version too long for the line is cut short. */
.skill-row .sidebar-panel-badge {
  max-width: 60%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The confirmation of a listed row's delete button has a line of its
   own, under the name line and at its right end: the name it asks
   about keeps its room, however narrow the panel. */
.skill-row > .sidebar-item-confirm {
  align-self: flex-end;
  margin: var(--space-0-5) 0;
}

/* A name that is the link to its page (a found row's, an added
   package's) is as wide as its text (the room after it is not the
   link's) and in the page's link colour (remote-codex.css); what
   follows it (what a found row's + has come to, a listed row's badge
   and delete button) stands at the right end of the line. */
.skill-row a.sidebar-panel-name,
.skill-found-row .sidebar-panel-name {
  flex: 0 1 auto;
  margin-right: auto;
}

a.sidebar-panel-name {
  text-decoration: none;
  border-radius: var(--radius-sm);
}

a.sidebar-panel-name:hover,
a.sidebar-panel-name:focus-visible { text-decoration: underline; }

a.sidebar-panel-name:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* "Checking…", "Added", "Needs review", "Blocked": set a step
   smaller than the row's name, a verdict in its status colour. */
.skill-state {
  flex: 0 0 auto;
  font-size: var(--fs-md);
  color: var(--dim);
}

.skill-state.added { color: var(--status-ok); }

.skill-state.review { color: var(--warning); }

.skill-state.blocked { color: var(--status-fail); }

/* What the check said, in a Recommendations card's box under the
   row's lines: the sentence, the findings (a severity badge, what was
   found, and where in the files) and, for a row a person may still
   add, the secondary buttons "Add anyway" and "Cancel" side by side
   (.sidebar-inline-form-buttons); a box too narrow for both puts one
   under the other, each label whole. */
.skill-verdict {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: var(--space-1-5);
  margin-top: var(--space-1);
  padding: var(--space-1-5) var(--space-2-5);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  background: var(--surface2);
  font-size: var(--fs-md);
  overflow-wrap: anywhere;
}

.skill-verdict-message:empty { display: none; }

.skill-verdict .sidebar-inline-form-buttons { flex-wrap: wrap; }

.skill-verdict .sidebar-inline-form-buttons button { white-space: nowrap; }

.skill-findings {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.skill-severity {
  display: inline-block;
  margin-right: var(--space-0-5);
  padding: 0 var(--space-1);
  border-radius: var(--radius-sm);
  background: var(--hover-strong);
  color: var(--dim);
  font-weight: 500;
}

.skill-severity.critical,
.skill-severity.high {
  background: color-mix(in srgb, var(--status-fail) 14%, transparent);
  color: var(--status-fail);
}

.skill-severity.medium {
  background: color-mix(in srgb, var(--warning) 14%, transparent);
  color: var(--warning);
}

.skill-finding-where {
  display: block;
  color: var(--dim);
}

/* Spend section (every surface): the all-time totals line, the daily
   cost heatmap and the cost-by-model bars.  The heatmap is a row of
   week columns (Monday at the top, latest week at the right) in a
   horizontally scrollable viewport whose scrollbar stays hidden;
   hover-revealed pagers page through older weeks.  Cells and bars
   share four brightness levels of the accent colour, so they follow
   the theme.  ``position: relative`` anchors the pagers and the
   custom tooltip. */
#meta-spend-graph {
  position: relative;
  padding: var(--space-1) var(--space-0-5);
  font-size: var(--fs-base);
  line-height: 1.35;
  color: var(--fg);
}

/* The totals line reads as the status line of the sections around it
   (.meta-info-status); a panel too narrow for it wraps it. */
.spend-total {
  padding-bottom: var(--space-1-5);
  color: var(--dim);
  font-variant-numeric: tabular-nums;
  text-align: center;
  overflow-wrap: anywhere;
}

/* The heatmap's viewport plus its two pagers, which sit over ITS
   edges (not the whole graph's, or the model bars below would push
   them out of view). */
.spend-heatmap { position: relative; }

.spend-viewport {
  display: flex;
  overflow-x: auto;
  scrollbar-width: none;
}

.spend-viewport::-webkit-scrollbar { display: none; }

/* ``margin-left: auto`` keeps the latest week at the RIGHT edge when
   every column fits without scrolling. */
.spend-grid {
  display: flex;
  gap: 3px;
  width: max-content;
  margin-left: auto;
}

.spend-col {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.spend-cell {
  width: 11px;
  height: 11px;
  border-radius: var(--radius-xs);
  background: var(--hover-strong);
}

.spend-cell.blank { visibility: hidden; }

/* .l1-.l4: spend level, built as 'l' + spendLevel() in main.js. */
.spend-cell.l1,
.spend-model-bar.l1 { background: color-mix(in srgb, var(--accent) 30%, transparent); }

.spend-cell.l2,
.spend-model-bar.l2 { background: color-mix(in srgb, var(--accent) 55%, transparent); }

.spend-cell.l3,
.spend-model-bar.l3 { background: color-mix(in srgb, var(--accent) 80%, transparent); }

.spend-cell.l4,
.spend-model-bar.l4 { background: var(--accent); }

.spend-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--surface2);
  box-shadow: var(--shadow-sm);
  color: var(--dim);
  cursor: pointer;
  opacity: 0;
  transition:
    opacity var(--dur-base) var(--ease),
    border-color var(--dur-base),
    color var(--dur-base);
  z-index: var(--z-raised);
}

.spend-nav.left { left: 0; }

.spend-nav.right { right: 0; }

#meta-spend-graph:hover .spend-nav { opacity: 0.9; }

/* A keyboard focus shows the pager too: a focused control the user
   cannot see is no control. */
.spend-nav:hover,
.spend-nav:focus-visible { border-color: var(--border-hover); color: var(--fg); opacity: 1; }

.spend-nav:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* The pager at the end the heatmap has reached: out of the way of
   the pointer AND of the Tab order (visibility, which opacity alone
   does not take it out of), while its box keeps the layout. */
.spend-nav.nav-hidden {
  opacity: 0 !important;
  visibility: hidden;
  pointer-events: none;
}

.spend-nav svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentcolor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Custom tooltip for the hovered cell or bar: the native ``title``
   would be lost to the re-render every poll triggers.  It never gets
   wider than the graph (a narrow sidebar wraps its lines) so the
   centering clamp in main.js can always keep it inside.  Its lines
   are set tight: today's three lines wrap to six in a 240px panel,
   and at the body line-height that stack is as tall as the seven
   cell rows, so it could no longer clear a weekend cell. */
.spend-tip {
  position: absolute;
  max-width: calc(100% - 4px);
  padding: 2px var(--space-1-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--menu-bg);
  box-shadow: var(--shadow-sm);
  color: var(--fg);
  font-size: var(--fs-md);
  line-height: 1.2;
  overflow-wrap: anywhere;
  text-align: center;
  pointer-events: none;
  z-index: var(--z-float);
}

.spend-models {
  margin-top: var(--space-1-5);
  padding-top: var(--space-1-5);
  border-top: 1px solid var(--border);
}

/* A group label, as a day label of the Chats list (.history-day-sep). */
.spend-models-title {
  display: block;
  padding-bottom: var(--space-1);
  color: var(--faint);
  font-size: var(--fs-md);
}

/* The fill under the pointer reaches out of the panel's column as the
   other rows' fills do (the negative margin is the graph's own
   padding plus --meta-bleed), and the row's padding keeps the name
   and the value in line with the heatmap's edges. */
.spend-model-row {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  margin: 0 calc(-1 * (var(--space-0-5) + var(--meta-bleed, 0px)));
  padding: var(--space-0-5) calc(var(--space-0-5) + var(--meta-bleed, 0px));
  border-radius: var(--radius-lg);
  cursor: default;
}

.spend-model-row:hover { background: var(--hover); }

.spend-model-name {
  max-width: 50%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.spend-model-track {
  display: inline-flex;
  flex: 1;
  align-items: center;
  height: 8px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--hover-strong);
}

.spend-model-bar {
  display: inline-block;
  min-width: 2px;
  height: 8px;
  border-radius: var(--radius-pill);
}

.spend-model-value {
  flex-shrink: 0;
  min-width: 34px;
  font-variant-numeric: tabular-nums;
  text-align: right;
  white-space: nowrap;
}

/* The task-info list: a hidden row (the Parent task row of a
   non-subagent task) stays hidden despite remote-codex.css's
   `display: list-item`, and a label ("Chat id:") never wraps — the
   long id value after it breaks instead (overflow-wrap: anywhere). */
.meta-item[hidden] { display: none !important; }
.meta-item .meta-label { white-space: nowrap; }

/* An id that inserts itself into the message box (main.js,
   armMetaId): a text button, underlined under the pointer and the
   keyboard focus as a link is. */
.meta-item [data-insert-id],
.meta-example-cmd {
  border-radius: var(--radius-sm);
  cursor: pointer;
}

.meta-item [data-insert-id]:hover,
.meta-item [data-insert-id]:focus-visible,
.meta-example-cmd:hover,
.meta-example-cmd:focus-visible { text-decoration: underline; }

.meta-item [data-insert-id]:focus-visible,
.meta-example-cmd:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

/* The Tags row of the task-info list (main.js, renderMetaTags): the
   task's tags as chips that wrap under one another in a narrow panel,
   each with the button that removes it, then the select that adds
   one.  A chip is a badge of the subpanels below
   (.sidebar-panel-badge); the select is a chip with a dashed edge. */
.meta-tag,
.meta-tag-add {
  box-sizing: border-box;
  height: 20px;
  margin: 1px var(--space-1) 1px 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  color: var(--dim);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 500;
  line-height: 18px;
  vertical-align: middle;
}

.meta-tag {
  display: inline-flex;
  align-items: center;
  padding: 0 var(--space-1-5);
  background: var(--hover-strong);
  white-space: nowrap;
}

.meta-tag-remove {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  margin: 0 calc(-1 * var(--space-1)) 0 var(--space-0-5);
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--faint);
  font: inherit;
  line-height: 16px;
  cursor: pointer;
}

.meta-tag-remove:hover,
.meta-tag-remove:focus-visible {
  color: var(--fg);
  background: var(--hover-strong);
}

.meta-tag-add {
  max-width: 100%;
  padding: 0 var(--space-1);
  border-style: dashed;
  border-color: var(--border-input);
  background: var(--surface2);
  cursor: pointer;
}

.meta-tag-remove:focus-visible,
.meta-tag-add:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

.meta-tag-remove:disabled,
.meta-tag-add:disabled {
  opacity: 0.5;
  cursor: default;
}

/* Under a finger a chip is taller and its remove button as wide as
   the chip is tall. */
@media (hover: none) {
  .meta-tag,
  .meta-tag-add {
    height: 28px;
    line-height: 26px;
  }

  .meta-tag-remove {
    width: 28px;
    height: 26px;
    margin-right: calc(-1 * var(--space-1-5));
    line-height: 26px;
  }
}

/* The dimming backdrop behind every side panel -- history sidebar,
   task info drawer, settings, tricks: one rule, four ids. */
#sidebar-overlay,
#meta-overlay,
#settings-overlay,
#tricks-overlay {
  position: fixed; inset: 0; background: var(--scrim);
  z-index: var(--z-scrim); opacity: 0; pointer-events: none; transition: opacity var(--dur-slow) var(--ease);
}

#sidebar-overlay.open,
#meta-overlay.open,
#settings-overlay.open,
#tricks-overlay.open { opacity: 1; pointer-events: auto; }

/* A remote machine's settings sheet (renderSettingsMachine in main.js):
   this daemon's URLs and its Update / Reset Server / Update Models
   buttons act here, not on that machine, so they are not offered; nor
   are the default working directory and the default model, a folder
   and a model of this machine. */
#settings-panel.for-machine #cfg-default-work-dir-row,
#settings-panel.for-machine #cfg-default-model-row,
#settings-panel.for-machine #remote-url,
#settings-panel.for-machine #cfg-update-btn,
#settings-panel.for-machine #cfg-server-reset-btn,
#settings-panel.for-machine #cfg-update-models-btn { display: none; }

/* The settings panel: a centered dialog. No entry animation — it is
   display-toggled, never slid in from an edge.  The panel itself does
   not scroll: its section does (below), so the restart confirmation
   (#server-reset-confirm-modal, absolute over the panel) covers the
   panel wherever the settings are scrolled to, instead of scrolling
   away with them. */
#settings-panel {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 90vw;
  max-height: 90vh;

  /* A hairline and the dialog elevation lift the settings dialog off
     the page; the remote page's palette sets --settings-border to the
     theme's widget border (remote-codex.css). */
  border: 1px solid var(--settings-border, var(--border));
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  z-index: var(--z-drawer);
  padding: var(--space-4);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  /* visibility (not display) so the closed panel keeps a measurable
     layout box; no transition, so opening never animates. */
  visibility: hidden;
}

#settings-panel.open { visibility: visible; }

/* The promptlets bottom sheet ("..." menu). */
#tricks-panel {
  position: fixed;
  left: 5%;
  right: 5%;
  bottom: 0;
  width: 90%;
  height: 60vh;
  border: 1px solid var(--border);
  border-bottom: none;
  border-top-left-radius: var(--radius-2xl);
  border-top-right-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);

  /* Hidden when closed, as #sidebar is. */
  visibility: hidden;
  transition:
    transform var(--dur-slow) var(--ease),
    visibility 0s linear var(--dur-slow);
  z-index: var(--z-drawer);
  padding: var(--space-4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

#tricks-panel.open { transform: translateY(0); visibility: visible; transition-delay: 0s; }

/* The title of the settings dialog and of the bottom sheet; it keeps
   the strip under the panel's "x" (below) free. */
#settings-panel .sidebar-hdr,
#tricks-panel .sidebar-hdr {
  padding-right: var(--space-8);
  font-size: var(--fs-lg);
  font-weight: 600;
  color: var(--fg);
}

/* The "x" of every side panel, a ghost icon button; the settings
   dialog's and the bottom sheet's buttons also stack above their own
   scrolling panes (the settings' positioned password toggles would
   otherwise paint over Close once scrolled under it). */
#sidebar-close,
#settings-panel-close,
#tricks-panel-close {
  position: absolute; top: 12px; right: 12px; background: none; border: none;
  color: var(--dim); font-size: var(--fs-2xl); cursor: pointer; padding: var(--space-1) var(--space-2); border-radius: var(--radius-md);
  transition: background var(--dur-base), color var(--dur-base);
}

#settings-panel-close,
#tricks-panel-close { z-index: var(--z-raised); }

#sidebar-close:hover,
#settings-panel-close:hover,
#tricks-panel-close:hover { color: var(--fg); background: var(--hover-strong); }

/* The scrolling list pane of the bottom sheet. */
#tricks-list {
  flex: 1;
  overflow-y: auto;
  margin-top: var(--space-0-5);
}

/* One previously selected working directory in the folder picker's
   "Recently opened" section: its path and when it was last selected. */
.workdir-item {
  display: flex;
  align-items: baseline;
  gap: var(--space-2-5);
  padding: var(--space-2) var(--space-2-5);
  cursor: pointer;
  border-radius: var(--radius-md);
}

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

.workdir-item-path {
  flex: 1;
  min-width: 0;
  font-family: var(--font-mono);
  font-size: var(--fs-sm);
  overflow-wrap: anywhere;
}

.workdir-item-ago {
  flex: 0 0 auto;
  font-size: var(--fs-sm);
  color: var(--faint);
  white-space: nowrap;
}

/* A promptlet row is a .sidebar-item (main.js gives it both classes),
   which lays it out; this adds the gap between its text and buttons. */
.tricks-item {
  word-break: break-word;
  gap: var(--space-1-5);
}

/* The copy and (user-owned rows only) edit and delete buttons sit at
   the right edge of a promptlet row; they take the row's own gap, not
   the task panels' margin. */
.tricks-item > .sidebar-item-copy,
.tricks-item > .sidebar-item-edit,
.tricks-item > .sidebar-item-delete {
  margin-left: 0;
}

/* A user-owned promptlet row while its pencil button's in-place editor
   is open: the textarea takes the row's full width, the Save / Cancel
   buttons sit below it at the right edge. */
.tricks-item.editing {
  flex-wrap: wrap;
  cursor: default;
}

/* The row does not react to the pointer (the selector outranks both
   sheets' .sidebar-item:hover). */
body.remote-chat .tricks-item.editing:hover { background: none; filter: none; }

.tricks-edit-input {
  flex: 1 1 100%;
  width: 100%;
  min-height: 0;
  resize: none;
  overflow: hidden;
  background: var(--surface2);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-base);
  padding: var(--space-1-5) var(--space-2-5);
  outline: none;
  white-space: pre-wrap;
  word-break: break-word;
}

.tricks-edit-input:focus { border-color: var(--ring-focus); }

.tricks-edit-actions {
  display: flex;
  gap: var(--space-1-5);
  margin-left: auto;
}

/* Save is the editor's confirming action: the primary button. */
.tricks-edit-save {
  border-color: transparent;
  background: var(--primary-bg);
  color: var(--primary-fg);
}

.tricks-edit-save:hover:not(:disabled) {
  border-color: transparent;
  background: var(--primary-hover-bg);
}

.sidebar-section {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
  margin-top: var(--space-0-5);
}

/* The settings scroll in their section, which bleeds into the panel's
   padding so the scrollport is the panel's inner box (the scrollbar at
   its edge, the content under the panel's padding), as when the panel
   scrolled; the padding pays the section's usual top margin back. */
#settings-panel > .sidebar-section {
  flex: 1 1 auto;
  overflow: auto;
  margin: calc(-1 * var(--space-4));
  padding: calc(var(--space-4) + var(--space-0-5)) var(--space-4) var(--space-4);
}

/* The history list spans the whole panel width so the chat panels
   (.history-chat-group) run edge to edge: negative margins cancel the
   gap to the panel's left and right boundaries (--history-bleed-l /
   -r).  The Tasks view bleeds too, padding its header
   and search rows back in: it clips its overflow, so a list wider
   than the view would be cut back to the old inset.  Everything else
   in the list keeps the panel's usual inset. */
#sidebar-tab-history-panel {
  --history-bleed-l: var(--sidebar-pad-x);
  --history-bleed-r: var(--sidebar-pad-x);

  margin-left: calc(-1 * var(--history-bleed-l));
  margin-right: calc(-1 * var(--history-bleed-r));
  padding-left: var(--history-bleed-l);
  padding-right: var(--history-bleed-r);
}

#history-list {
  overflow-y: auto;
  flex: 1;
  margin-left: calc(-1 * var(--history-bleed-l));
  margin-right: calc(-1 * var(--history-bleed-r));
}

#history-list > :not(.history-chat-group, .history-project) {
  margin-left: var(--history-bleed-l);
  margin-right: max(0px, calc(var(--history-bleed-r) - var(--history-gutter, 0px)));
}

/* A task row of the flat list: its fill keeps the chat headers' 8px
   from the panel's edges (.history-chat-header). */
#history-list > .sidebar-item {
  margin-left: var(--space-2);
  margin-right: calc(var(--space-2) - var(--history-gutter, 0px));
}

/* Where the pointer is a mouse, the list's scrollbar is the 6px one
   styled at the end of this file: it takes its room from the list,
   and its thumb shows only while the user scrolls.  The list keeps
   that gutter at all times and its children count it into their
   right inset, so a row's fill ends as far from the panel's right
   edge as it starts from the left one, and a day label ends at the
   panel's usual inset, whether or not the list overflows.  On a touch
   screen the bar usually lies over the content, so no room is kept
   for it there. */
@media (hover: hover) and (pointer: fine) {
  #history-list {
    --history-gutter: 6px;

    scrollbar-gutter: stable;
  }
}

/* The history panel's inner layout: #sidebar-body clips the panel's
   content (remote-codex.css) around the stacked #sidebar-views column
   that holds the Chats view. */
#sidebar-body {
  flex: 1;
  display: flex;
  flex-direction: row;
  min-height: 0;
  min-width: 0;
}

#sidebar-views {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

/* The strips at the bottom of the two side panels: the one under the
   Chats list (chat.html #sidebar-footer: the user name at the left,
   the appearance and settings buttons at the right) and its twin
   under the task-info panel (#meta-footer: the buttons that act on
   the chat's machine and folder).  A strip is the last item of its
   panel's column and does not grow, so it stays at the bottom while
   the list above it scrolls; the task-info panel's is pushed there
   when every section above it is folded.  It reaches the panel's
   edges (a hairline across the panel, 8px under the buttons instead
   of the panel's 16px) and clips for itself: a docked desktop panel
   does not (remote-codex.css).  The name takes the width of its text,
   so a short one shares the row with the buttons; a panel too narrow
   for the name and the buttons side by side gives the buttons a row
   of their own, and a narrower one wraps them. */
#sidebar-footer { --strip-pad-x: var(--sidebar-pad-x); }
#meta-footer { --strip-pad-x: var(--meta-pad-x); }

#sidebar-footer,
#meta-footer {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1);
  margin: auto calc(-1 * var(--strip-pad-x)) calc(-1 * var(--space-4));
  padding: var(--space-2) var(--strip-pad-x) calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--border-soft);
  overflow: hidden;
}

#sidebar-user {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--dim);
  font-size: var(--fs-md);
}

/* A strip's buttons, at its right end. */
.strip-tools {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-0-5);
  min-width: 0;
  margin-left: auto;
}

/* The task-info strip has no name before its buttons: they start at
   its left edge, and a row they wrap onto starts there too. */
#meta-tools {
  justify-content: flex-start;
  margin-left: 0;
}

/* One size for every button of both strips: a 32px square around an
   18px icon (36px for a finger, remote-codex.css). */
.sidebar-tool-btn {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  border: none; border-radius: var(--radius-md); color: var(--dim);
  background: none;
  cursor: pointer; transition: color var(--dur-base), background var(--dur-base);
}
.sidebar-tool-btn[hidden] { display: none; }
.sidebar-tool-btn svg { width: 18px; height: 18px; }

/* Under a pointer that hovers.  A finger does not: there the hover of
   a tap stays on the button until the next tap, and a button just
   switched off would keep the fill. */
@media (hover: hover) {
  .sidebar-tool-btn:hover:enabled { color: var(--fg); background: var(--hover-strong); }
}

/* Pressed (high contrast or auto mode is on): the accent icon on the
   selected fill inside a line, a hairline that the high-contrast
   palettes make solid.  The pointer over the button changes none of
   it: a hovered button's fill is about as strong as the selected one,
   so the icon's colour and the line are what tell on from off. */
.sidebar-tool-btn[aria-pressed="true"],
.sidebar-tool-btn[aria-pressed="true"]:hover:enabled {
  color: var(--accent);
  background: var(--selected);
  box-shadow: inset 0 0 0 1px var(--border-hover);
}

/* A font button at its limit. */
.sidebar-tool-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* A button whose request is running (a commit, a pull request): it
   cannot be pressed again, and pulses instead of looking switched
   off. */
.sidebar-tool-btn.is-busy {
  opacity: 1;
  color: var(--accent);
  cursor: progress;
  animation: blink-pending 1.2s ease-in-out infinite;
}

@media (prefers-reduced-motion: reduce) {
  .sidebar-tool-btn.is-busy { animation: none; }
}

/* The Explorer header's action buttons (refresh), grouped at the
   right of the section toggle; the gap keeps one button's hover fill
   off its neighbours. */
.meta-hdr-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  flex: 0 0 auto;
}

.scm-branch {
  font-weight: 400;
  color: var(--dim);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 50%;
}

/* Explorer tree: one .explorer-row per entry, indented by depth via
   the --depth custom property (VS Code's 8px per level plus the
   chevron column).  A folder row carries a chevron that rotates when
   expanded; the folder's children live in the following .explorer-kids
   container.  The tree is its section's .meta-section-body, which
   sizes and scrolls it. */
.explorer-tree {
  overflow-x: auto;
  font-size: var(--fs-base);
  user-select: none;
}

/* A row's fill reaches out of the panel's column (--meta-bleed), as
   the fills of the panel's other rows do; the paddings count the
   reach in, so the row's content stays where the column puts it. */
.explorer-row {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  height: 22px;
  line-height: 22px;
  margin-inline: calc(-1 * var(--meta-bleed, 0px));
  padding-left: calc(var(--depth, 0) * 12px + 4px + var(--meta-bleed, 0px));
  padding-right: calc(var(--space-1-5) + var(--meta-bleed, 0px));
  cursor: pointer;
  white-space: nowrap;
  color: var(--fg);
  border-radius: var(--radius-lg);
}

.explorer-row:focus-visible,
.scm-row:focus-visible,
.scm-commit:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

/* Selected rows (multi-select) take the neutral selection fill.  While
   the tree has keyboard focus the second selector outranks the remote
   page's row hover (remote-codex.css), so a selected row keeps its
   fill under the pointer. */
.explorer-row.is-selected {
  background: var(--selected);
  color: var(--fg-strong);
}

.explorer-tree:focus-within .explorer-row.is-selected {
  background: var(--selected);
}

.explorer-chevron {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: transform var(--dur-fast) var(--ease);
  color: var(--dim);
}

.explorer-row.expanded > .explorer-chevron { transform: rotate(90deg); }

.explorer-row.is-file > .explorer-chevron { visibility: hidden; }

.explorer-icon {
  flex: 0 0 16px;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--dim);
}

.explorer-row.is-dir > .explorer-icon { color: var(--icon); }

.explorer-name {
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Top-level folder rows are in the medium weight, the one emphasis of
   both side panels.  An added folder shows a "Remove Folder from
   Explorer" button on hover / focus. */
.explorer-row.is-root > .explorer-name { font-weight: 500; }

.explorer-root-actions {
  display: inline-flex;
  align-items: center;
  gap: var(--space-0-5);
  margin-left: auto;
  flex: 0 0 auto;
}

.explorer-root-btn {
  background: none;
  border: none;
  padding: 1px;
  border-radius: var(--radius-md);
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  color: var(--dim);
  visibility: hidden;
}

.explorer-row:hover > .explorer-root-actions > .explorer-root-btn,
.explorer-row:focus-within > .explorer-root-actions > .explorer-root-btn,
.explorer-row.ctx-active > .explorer-root-actions > .explorer-root-btn {
  visibility: visible;
}

.explorer-root-btn:hover {
  color: var(--fg);
  background: var(--hover-strong);
}

/* No hover on a touch screen: the buttons stay visible. */
@media (hover: none) {
  .explorer-root-btn { visibility: visible; }
}

.explorer-row.loading > .explorer-name,
.explorer-note {
  color: var(--dim);
}

.explorer-note {
  padding-left: calc(var(--depth, 0) * 12px + 24px);
  height: 22px;
  line-height: 22px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Source Control view: two collapsible sections ("Changes" and
   "Graph") stacked in a scrolling body.  Rows reuse the Explorer row
   geometry; the status letter sits at the right edge in its state
   colour (M yellow, A green, D red, U dim, R/C cyan, ! red).  The
   body is its section's .meta-section-body, which sizes and scrolls
   it. */
.scm-body {
  display: flex;
  flex-direction: column;
  font-size: var(--fs-base);
  user-select: none;
}

.scm-section { flex: 0 0 auto; }

.scm-section-hdr {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  width: 100%;
  padding: var(--space-0-5) 0;
  margin: 0;
  background: none;
  border: none;
  color: var(--faint);
  font-size: var(--fs-md);
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  user-select: none;
}

.scm-section-chevron {
  flex: 0 0 auto;
  transition: transform var(--dur-fast) var(--ease);
}

.scm-section-hdr[aria-expanded="true"] .scm-section-chevron { transform: rotate(90deg); }

.scm-count {
  margin-left: auto;
  font-weight: 500;
  font-size: var(--fs-md);
  color: var(--dim);
  background: var(--hover-strong);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1-5);
  min-width: 10px;
  text-align: center;
}

.scm-count:empty { display: none; }

/* The number of uncommitted files right after the "Source Control"
   title (readable while the section is folded); the badge never
   shrinks, so a long branch name beside it cannot cut the number. */
#scm-hdr-count { margin-left: 0; flex: 0 0 auto; }

/* Under a worktree header (several worktrees) the group headers indent
   by --depth; a single worktree keeps them flush.  A group header is
   set as a day label of the Chats list (.history-day-sep). */
.scm-group-hdr {
  height: 22px;
  line-height: 22px;
  padding-left: calc(var(--depth, 0) * 12px + 4px);
  font-size: var(--fs-md);
  font-weight: 400;
  color: var(--faint);
  white-space: nowrap;
}

.scm-row {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  height: 22px;
  line-height: 22px;
  margin-inline: calc(-1 * var(--meta-bleed, 0px));
  padding-left: calc(var(--depth, 0) * 12px + 4px + var(--meta-bleed, 0px));
  padding-right: calc(var(--space-1-5) + var(--meta-bleed, 0px));
  cursor: pointer;
  white-space: nowrap;
  color: var(--fg);
  border-radius: var(--radius-lg);
}

.scm-path {
  overflow: hidden;
  text-overflow: ellipsis;
}

.scm-dir {
  color: var(--faint);
  font-size: var(--fs-md);
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

.scm-status {
  flex: 0 0 auto;
  margin-left: auto;
  font-weight: 500;
  font-size: var(--fs-md);
  min-width: 12px;
  text-align: center;
}

/* Built as 'scm-status-' + git's one-letter status in main.js. */
.scm-status-M, .scm-status-T { color: var(--yellow); }
.scm-status-A { color: var(--green); }
.scm-status-U { color: var(--dim); }
.scm-status-D { color: var(--red); }
.scm-status-R, .scm-status-C { color: var(--cyan); }
.scm-status-conflict { color: var(--red); }

.scm-row.is-deleted .scm-path { text-decoration: line-through; opacity: 0.7; }

/* Commit graph rows: a lane-graph SVG cell on the left (one lane =
   14px), then the subject, refs and metadata.  Clicking a commit
   expands its file list below it. */
.scm-commit {
  display: flex;
  align-items: stretch;
  min-height: 24px;
  margin-inline: calc(-1 * var(--meta-bleed, 0px));
  padding-left: var(--meta-bleed, 0);
  padding-right: calc(var(--space-1-5) + var(--meta-bleed, 0px));
  cursor: pointer;
  border-radius: var(--radius-lg);
  color: var(--fg);
}

.scm-graph-cell {
  flex: 0 0 auto;
  display: block;
}

/* Refs never shrink, so a commit with several of them is wider than
   the row: what does not fit is cut at the row's own edge, not left to
   run on under the body's scrollbar. */
.scm-commit-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  height: 24px;
  line-height: 24px;
  white-space: nowrap;
  overflow: hidden;
}

.scm-commit-subject {
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1;
  min-width: 0;
}

/* A ref of a commit: a branch is an outlined chip. */
.scm-ref {
  flex: 0 0 auto;
  font-size: var(--fs-md);
  font-weight: 500;
  padding: 0 var(--space-1);
  border-radius: var(--radius-md);
  line-height: 16px;
  border: 1px solid var(--border-input);
  color: var(--fg);
  max-width: 90px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* HEAD, and another worktree checked out at this commit (its folder
   name), are the active chips. */
.scm-ref.is-head,
.scm-ref.is-worktree {
  background: var(--selected);
  border-color: var(--border-hover);
  color: var(--fg-strong);
}

/* A tag is a filled badge. */
.scm-ref.is-tag {
  background: var(--hover-strong);
  border-color: transparent;
  color: var(--dim);
}

/* Multiple worktrees: one header per worktree (folder name, branch,
   change count) above its groups; the group headers indent below it
   (see .scm-group-hdr). */
.scm-worktree-hdr {
  display: flex;
  align-items: center;
  gap: var(--space-1-5);
  margin: var(--space-1) calc(-1 * var(--meta-bleed, 0px)) 0;
  padding-left: calc(var(--depth, 0) * 12px + 4px + var(--meta-bleed, 0px));
  padding-right: calc(var(--space-1-5) + var(--meta-bleed, 0px));
  color: var(--fg);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
  border-radius: var(--radius-lg);
}

/* The header folds the worktree's rows: its chevron points right when
   folded, down when open (like a folder row of the Explorer). */
.scm-worktree-hdr:hover {
  background: var(--hover);
}

.scm-worktree-hdr:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.scm-worktree-hdr.expanded > .explorer-chevron { transform: rotate(90deg); }

.scm-worktree-hdr.is-current .scm-worktree-name::after {
  content: ' (current)';
  font-weight: 400;
  color: var(--faint);
}

.scm-worktree-branch {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 400;
  color: var(--dim);
}

/* Explorer inline name box (New File / New Folder / Rename...). */
.explorer-row.is-editing { cursor: default; }

.explorer-input {
  width: 100%;
  min-width: 60px;
  height: 20px;
  padding: 0 var(--space-1);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-sm);
  background: var(--surface2);
  color: var(--fg);
  font: inherit;
  outline: none;
}

.explorer-input::placeholder { color: var(--faint); }

.explorer-input:focus { border-color: var(--ring-focus); }

/* The row its context menu is open for takes the selection fill. */
.explorer-row.ctx-active,
.scm-row.ctx-active,
.scm-commit.ctx-active {
  background: var(--selected);
  color: var(--fg-strong);
}

/* Sidebar context menu (Explorer rows, commits, changed files): label
   left, shortcut right, greyed disabled items. */
.tree-ctx-menu {
  position: fixed;
  z-index: var(--z-context);
  min-width: 220px;
  padding: var(--space-1);
  background: var(--menu-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-base);
  color: var(--fg);
  user-select: none;
}

.tree-ctx-item {
  display: flex;
  justify-content: space-between;
  gap: var(--space-6);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
  outline: none;
}

.tree-ctx-item:hover,
.tree-ctx-item:focus {
  background: var(--hover);
}

.tree-ctx-item.disabled {
  opacity: 0.45;
  cursor: default;
}

.tree-ctx-item.disabled:hover { background: none; }

.tree-ctx-key {
  color: var(--faint);
  font-size: var(--fs-md);
}

.tree-ctx-sep {
  height: 1px;
  margin: var(--space-1) var(--space-2);
  background: var(--border);
}

/* Submenus and radio items (the Explorer's Sort).  A radio item keeps a
   gutter on its left for the check mark, so the labels of a group line
   up; an item with a submenu ends with a chevron and stays highlighted
   while its submenu is open. */
.tree-ctx-item[role="menuitemradio"] {
  position: relative;
  padding-left: calc(var(--space-2) + 1.2em + var(--space-1));
}

.tree-ctx-check,
.tree-ctx-chevron {
  flex: 0 0 auto;
  width: 1.2em;
  height: 1.2em;
  fill: none;
  stroke: currentcolor;
  stroke-width: 1.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.tree-ctx-check {
  position: absolute;
  top: 50%;
  left: var(--space-2);
  transform: translateY(-50%);
}

.tree-ctx-chevron {
  align-self: center;
  color: var(--dim);
}

.tree-ctx-item[aria-haspopup] > .tree-ctx-label { margin-right: auto; }

.tree-ctx-item[aria-expanded="true"] { background: var(--hover); }

/* Folder picker: a modal folder browser. */
#folder-picker {
  position: fixed;
  inset: 0;
  z-index: var(--z-dialog);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 10vh;
  background: var(--scrim);
}

#folder-picker[hidden] { display: none; }

/* The rows that do not shrink can be taller than a short window (a
   phone held sideways) leaves the dialog: it scrolls them then. */
.folder-picker-dialog {
  display: flex;
  flex-direction: column;
  width: min(560px, calc(100vw - 32px));
  max-height: 70vh;
  overflow-y: auto;
  background: var(--menu-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  color: var(--fg);
  font-size: var(--fs-base);
}

.folder-picker-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-2-5) var(--space-3) var(--space-1-5) var(--space-4);
  font-size: var(--fs-lg);
  font-weight: 600;
}

.folder-picker-close {
  padding: var(--space-1) var(--space-2);
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--dim);
  font-size: var(--fs-xl);
  line-height: 1;
  cursor: pointer;
}

.folder-picker-path {
  display: flex;
  gap: var(--space-1-5);
  padding: var(--space-2) var(--space-4);
}

.folder-picker-up {
  flex: 0 0 auto;
  min-width: 28px;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--dim);
  font-size: var(--fs-xl);
  line-height: 1;
  cursor: pointer;
}

.folder-picker-close:hover,
.folder-picker-up:hover {
  background: var(--hover-strong);
  color: var(--fg);
}

.folder-picker-input,
.folder-picker-new-name {
  flex: 1 1 auto;
  min-width: 0;
  padding: var(--space-1-5) var(--space-2-5);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  background: var(--surface2);
  color: var(--fg);
  font: inherit;
}

.folder-picker-input:focus,
.folder-picker-new-name:focus {
  outline: none;
  border-color: var(--ring-focus);
}

/* "Recently opened": the folder picker's recent folders, offered
   above the subfolder list so one click adds one of them. */
.folder-picker-recent {
  flex: 0 1 auto;
  min-height: 60px; /* the header and two rows, on the shortest screens */
  max-height: 30vh;
  overflow: auto;
  margin: 0 var(--space-2) var(--space-2);
}

/* With the recent section shown, the subfolder list yields some of its
   room so both stay usable on a short screen. */
.folder-picker-recent:not([hidden]) + .folder-picker-list { min-height: 80px; }

.folder-picker-recent-hdr {
  padding: var(--space-1) var(--space-2) 0;
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--faint);
}

.folder-picker-recent .workdir-item {
  padding: var(--space-1) var(--space-2);
}

/* The subfolder list: a hairline box whose rows keep a rounded fill
   clear of its edge. */
.folder-picker-list {
  flex: 1 1 auto;
  min-height: 120px;
  overflow: auto;
  margin: 0 var(--space-4);
  padding: var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.folder-picker-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  height: 24px;
  padding: 0 var(--space-2);
  border-radius: var(--radius-md);
  cursor: pointer;
  white-space: nowrap;
}

.folder-picker-item svg { flex: 0 0 16px; color: var(--icon); }

.folder-picker-item:hover {
  background: var(--hover);
}

.folder-picker-item.selected {
  background: var(--selected);
  color: var(--fg-strong);
}

.folder-picker-note {
  min-height: 18px;
  padding: var(--space-1) var(--space-4);
  font-size: var(--fs-md);
  color: var(--error);
}

.folder-picker-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4) var(--space-4);
}

/* "New Folder" (the button at the left end of the actions): a row
   naming a folder to create in the folder listed above it. */
.folder-picker-new {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4) 0;
}

.folder-picker-new[hidden] { display: none; }

.folder-picker-actions .folder-picker-new-btn { margin-right: auto; }

/* Cancel is the secondary button, Select the primary one. */
.folder-picker-new-create,
.folder-picker-actions button {
  padding: var(--space-1-5) var(--space-3);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  background: var(--surface2);
  color: var(--fg);
  font-size: var(--fs-base);
  font-weight: 500;
  cursor: pointer;
}

.folder-picker-new-create:hover,
.folder-picker-actions button:hover {
  background: var(--hover);
  border-color: var(--border-hover);
}

.folder-picker-actions .folder-picker-select {
  border-color: transparent;
  background: var(--primary-bg);
  color: var(--primary-fg);
}

.folder-picker-actions .folder-picker-select:hover {
  border-color: transparent;
  background: var(--primary-hover-bg);
}

/* PDF / image viewer tabs (binary fileContent). */
.content-binary-holder {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: auto;
}

/* The pdf.js viewer (pdfView.js): a quiet toolbar of borderless
   buttons over a scrolling box of page canvases.  The box is the only
   scroller, and touch-action leaves one-finger panning to the browser
   while the viewer's own touch handlers take the two-finger pinch. */
.pdf-viewer {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.pdf-toolbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font-size: var(--fs-md);
}

.pdf-toolbar button,
.pdf-toolbar .pdf-download {
  min-width: var(--space-8);
  height: var(--space-6);
  padding: 0 var(--space-2);
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--dim);
  font-size: var(--fs-md);
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.pdf-toolbar button:hover,
.pdf-toolbar .pdf-download:hover { background: var(--hover-strong); color: var(--fg); }

/* The zoom glyphs (a minus and a plus sign) are drawn at icon size. */
.pdf-toolbar .pdf-zoom-out,
.pdf-toolbar .pdf-zoom-in { font-size: var(--fs-xl); line-height: 1; }

/* The Download link looks like the buttons; it is an <a> so the browser
   saves the blob: URL itself. */
.pdf-toolbar .pdf-download {
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  white-space: nowrap;
}

/* "Page [N] of M": pushed to the right, before the Download link. */
.pdf-status {
  margin-left: auto;
  color: var(--dim);
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* The page number is a field (its width is set per document, from the
   number of digits in the page count); Enter jumps to the typed page. */
.pdf-page-input {
  height: var(--space-6);
  padding: 0 var(--space-1);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--surface2);
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-sm);
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.pdf-page-input:focus {
  outline: none;
  border-color: var(--ring-focus);
}

.pdf-scroller {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  touch-action: pan-x pan-y;
  -webkit-overflow-scrolling: touch;
  background: var(--bg2);
}

.pdf-pages {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  width: max-content;
  min-width: 100%;
}

.pdf-page {
  flex: 0 0 auto;
  box-shadow: var(--shadow-sm);
  background: var(--paper);
}

.pdf-page canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.content-image {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  margin: auto;
  cursor: zoom-in;
}

.content-image.content-image-full {
  max-width: none;
  max-height: none;
  cursor: zoom-out;
}

.content-binary-note {
  margin: var(--space-6);
  color: var(--dim);
}

/* The note's link form ("Download ...") reads as a link. */
a.content-binary-note { color: var(--accent); text-decoration: none; }
a.content-binary-note:hover { text-decoration: underline; }

/* A page that cannot be drawn shows the note on the page's paper. */
.pdf-page .content-binary-note { color: var(--ink); }

.scm-commit-meta {
  flex: 0 0 auto;
  font-size: var(--fs-md);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
}

.scm-commit-files { padding-bottom: var(--space-0-5); }

/* The working tree's row is not a commit: its subject steps back. */
.scm-commit.is-worktree .scm-commit-subject { color: var(--dim); }

.sidebar-loading {
  text-align: center;
  padding: var(--space-3);
  color: var(--dim);
  font-size: var(--fs-md);
}

/* A panel's header: a small sentence-case label in the faint text
   step. */
.sidebar-hdr {
  font-size: var(--fs-md); font-weight: 500; color: var(--faint);
  margin-bottom: var(--space-2-5);
}

/* The refresh row, the first of the panel: the app's refresh button at
   its right end.  The drawer's absolute #sidebar-close (right: 12px,
   ~28px wide) sits in this row's top-right corner, so the row keeps
   that strip free (sidebar padding 16px + 32px reaches past the x);
   remote-codex.css drops the padding where the x is hidden. */
.sidebar-refresh-row { flex: none; display: flex; justify-content: flex-end; margin-bottom: var(--space-1); padding-right: var(--space-8); }

/* The Projects row, under the refresh row (and so under the drawer's
   x): it opens the Projects page.  Set as a row of the list is (a
   chat's header): the icon, the name, a rounded fill under the
   pointer, which reaches as far left of the icon as the row is
   padded. */
.projects-row {
  flex: none;
  display: flex; align-items: center; gap: var(--space-2);
  margin: 0 0 var(--space-2) calc(-1 * var(--space-1-5));
  padding: var(--space-1-5);
  background: none; border: none; border-radius: var(--radius-lg);
  color: var(--fg); font-family: inherit; font-size: var(--fs-base); font-weight: 400; line-height: 1.35;
  text-align: left; cursor: pointer; transition: background var(--dur-base);
}

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

.projects-row svg { flex: none; color: var(--dim); }

/* The 2px margin centres the icon over the wider Filter and group
   button (#history-filter-btn) of the search row.  The focus ring is drawn
   inside the box: the button's top edge is the top edge of its
   section, which clips (.sidebar-section). */
#chats-refresh-btn {
  flex: none; display: flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; padding: 0; margin-right: var(--space-0-5);
  background: none; border: none;
  border-radius: var(--radius-md); color: var(--dim);
  font-size: var(--fs-lg); cursor: pointer; transition: color var(--dur-base), background var(--dur-base);
}
#chats-refresh-btn:hover { color: var(--fg); background: var(--hover-strong); }
#chats-refresh-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }

#history-search,
#tricks-search,
#tricks-add-input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border-input);
  border-radius: var(--radius-lg); color: var(--fg); font-size: var(--fs-base); padding: var(--space-1-5) 28px var(--space-1-5) var(--space-2-5);
  outline: none;
}
.sidebar-section .search-wrap { margin-bottom: var(--space-2-5); }

#history-search::placeholder,
#tricks-search::placeholder,
#tricks-add-input::placeholder { color: var(--faint); }

#history-search:focus,
#tricks-search:focus,
#tricks-add-input:focus { border-color: var(--ring-focus); }

/* The Inject promptlet panel's "new promptlet" box with its Add button,
   and the History search box with the Filter and group button on its
   right. */
#tricks-add-row,
.history-search-row { display: flex; align-items: center; gap: var(--space-1-5); margin-bottom: var(--space-2-5); }

#tricks-add-row #tricks-add-input { flex: 1; min-width: 0; padding-right: var(--space-2-5); }

.history-search-row .search-wrap { flex: 1; min-width: 0; margin-bottom: 0; }

/* Filter and group: the button beside the search box, as tall as the
   box at any text size.  It takes the hover fill while its menu is
   open and wears a dot in the accent colour while a filter narrows the
   list: the filters are out of sight when the menu is closed. */
#history-filter-btn {
  position: relative;
  flex: none; align-self: stretch; display: flex; align-items: center; justify-content: center;
  width: 28px; padding: 0;
  border: none; border-radius: var(--radius-md); color: var(--dim);
  background: none;
  font-size: var(--fs-lg); cursor: pointer; transition: color var(--dur-base), background var(--dur-base);
}

#history-filter-btn:hover,
#history-filter-btn[aria-expanded="true"] { color: var(--fg); background: var(--hover-strong); }

#history-filter-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

#history-filter-btn.is-filtered::after {
  content: '';
  position: absolute; top: 4px; right: 4px;
  width: 6px; height: 6px;
  border-radius: var(--radius-round);
  background: var(--accent);
}

/* The menu and its submenus (main.js, "The Filter and group menu"):
   the card of a Chats row's menu (.sidebar-item-actions), as the
   "Filter and group" menu of Claude Code's session list.  A row names
   a setting, shows the setting's value in the secondary text step and
   ends in a chevron; a submenu lists the options, the chosen ones
   ticked.  main.js gives a card its left and top before it shows;
   `placing` lays it out, unseen, for that measurement.  Outside those
   two states a card sets no `display`: one would outrank the browser's
   `display: none` of a closed popover. */
.fg-menu {
  position: fixed;
  inset: auto;
  flex-direction: column;
  width: max-content;
  min-width: 220px;
  max-width: calc(100vw - var(--space-4));
  max-height: calc(100vh - var(--space-4));
  margin: 0;
  padding: var(--space-1);
  overflow: hidden auto;
  background: var(--menu-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  color: var(--fg);
  font-size: var(--fs-base);
  line-height: 1.35;
  white-space: nowrap;
}

.fg-menu:popover-open,
.fg-menu.placing { display: flex; }

.fg-menu.placing { visibility: hidden; }

/* A submenu is a card of its own beside the menu, not a part of the
   menu's column; it is narrower, and a long list scrolls. */
.fg-submenu { min-width: 180px; max-height: min(420px, calc(100vh - var(--space-4))); }

.fg-row,
.fg-option,
.fg-clear {
  flex: none;
  display: flex; align-items: center; gap: var(--space-2-5);
  min-height: 30px;
  margin: 0;
  padding: 0 var(--space-2-5);
  border: none; border-radius: var(--radius-md);
  background: none;
  color: var(--fg);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.fg-row[hidden] { display: none; }

/* An option can be longer than the window is wide (the path of a work
   dir on a phone): it wraps inside its card, which keeps the folder's
   own name and the tick in sight. */
.fg-option { padding-block: var(--space-1); white-space: normal; overflow-wrap: anywhere; }

.fg-row:hover,
.fg-row:focus-visible,
.fg-row[aria-expanded="true"],
.fg-option:hover,
.fg-option:focus-visible,
.fg-clear:hover,
.fg-clear:focus-visible {
  background: var(--hover);
  outline: none;
}

.fg-row:disabled { color: var(--faint); cursor: default; background: none; }

.fg-row-name { flex: 1; }

/* The value never pushes the name out: a long one is cut short. */
.fg-row-value {
  max-width: 14em;
  overflow: hidden;
  color: var(--dim);
  text-overflow: ellipsis;
}

/* The chevron of a row: a submenu opens beside it. */
.fg-row::after {
  content: '';
  flex: none;
  width: 6px; height: 6px;
  border: solid var(--dim);
  border-width: 1.5px 1.5px 0 0;
  rotate: 45deg;
}

/* The tick of a chosen option, at the row's right end. */
.fg-option::after {
  content: '';
  flex: none;
  width: 12px; height: 12px;
  margin-left: auto;
}

.fg-option[aria-checked="true"]::after {
  background: var(--fg);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M2.5 8.5l3.5 3.5 7.5-8' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}

/* A status option leads with the glyph the rows of the list wear, in
   the colour they wear it; the ring does not turn in a menu. */
.fg-option > .status-spinner { color: var(--brand-clay); animation: none; }
.fg-option > .status-cross { color: var(--status-fail); }
.fg-option > .status-tick { color: var(--status-ok); }

/* The hairline over Group by, inset to the rows' text. */
.fg-sep {
  flex: none;
  margin: var(--space-1) var(--space-2-5);
  border-top: 1px solid var(--border);
}

/* The Date submenu: the From and To boxes, each with its calendar
   button, and Clear dates while a day is set. */
.history-filter-date-group {
  flex: none;
  display: flex; align-items: center; gap: var(--space-2);
  min-height: 30px;
  padding: 0 var(--space-1) 0 var(--space-2-5);
}

.history-filter-date-lbl {
  flex: none;
  width: 3em;
  color: var(--dim);
  cursor: pointer; user-select: none;
}

.history-filter-date {
  flex: 1;
  min-width: 8.5em;
  padding: var(--space-0-5) var(--space-1-5);
  border: 1px solid var(--border-input); border-radius: var(--radius-md);
  background: var(--surface2);
  color: var(--fg); font: inherit;
  outline: none;
}

.history-filter-date:focus { border-color: var(--ring-focus); }

/* The page's own calendar (the button beside the box) stands in for
   the browser's. */
.history-filter-date::-webkit-calendar-picker-indicator {
  display: none; appearance: none;
}

.history-filter-date::-webkit-inner-spin-button,
.history-filter-date::-webkit-clear-button {
  display: none;
}

.history-filter-date-btn {
  flex: none;
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px; padding: 0;
  border: none; border-radius: var(--radius-md);
  background: none;
  color: var(--dim);
  cursor: pointer;
}

.history-filter-date-btn svg {
  width: 14px; height: 14px;
}

.history-filter-date-btn:hover,
.history-filter-date-btn:focus-visible {
  outline: none; background: var(--hover-strong); color: var(--fg);
}

/* A browser without popovers (one from before 2024) cannot open the
   menu: there the button is left out, and the list shows everything
   but the cron tasks, in the arrangement it was last given. */
@supports not selector(:popover-open) {
  #history-filter-btn,
  .fg-menu { display: none; }
}

/* The date picker: a floating month grid.  The chosen day takes the
   primary fill, today a neutral outline. */
.kiss-datepicker {
  position: fixed; z-index: var(--z-tooltip);
  background: var(--menu-bg);
  border: 1px solid var(--border); border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2); width: 220px;
  font-size: var(--fs-md); color: var(--fg);
  user-select: none;
}

.kiss-datepicker .dp-hdr {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: var(--space-1-5);
}
.kiss-datepicker .dp-title { font-weight: 600; }

.kiss-datepicker .dp-nav {
  background: none; border: none; color: var(--dim);
  cursor: pointer; padding: var(--space-0-5) var(--space-2); font-size: var(--fs-xl);
  line-height: 1; border-radius: var(--radius-md);
}

.kiss-datepicker .dp-nav:hover {
  background: var(--hover-strong); color: var(--fg);
}

.kiss-datepicker .dp-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: var(--space-0-5);
}

.kiss-datepicker .dp-dn {
  text-align: center; font-size: var(--fs-sm);
  color: var(--faint);
  padding: var(--space-0-5) 0;
}

.kiss-datepicker .dp-day {
  background: none; border: 1px solid transparent;
  color: var(--fg); cursor: pointer;
  padding: var(--space-1) 0; font-size: var(--fs-md);
  border-radius: var(--radius-md); text-align: center;
}

.kiss-datepicker .dp-day.dp-empty {
  visibility: hidden; cursor: default;
}

.kiss-datepicker .dp-day:hover {
  background: var(--hover);
}
.kiss-datepicker .dp-today { border-color: var(--border-hover); }

/* The :hover form outranks the neutral day hover above. */
.kiss-datepicker .dp-sel,
.kiss-datepicker .dp-sel:hover {
  background: var(--primary-bg); color: var(--primary-fg);
}

.kiss-datepicker .dp-foot {
  display: flex; justify-content: space-between; margin-top: var(--space-1-5);
}

.kiss-datepicker .dp-foot button {
  background: var(--surface2);
  border: 1px solid var(--border-input); color: var(--fg);
  padding: var(--space-1) var(--space-2); border-radius: var(--radius-md); cursor: pointer;
  font-size: var(--fs-sm); font-weight: 500;
}

.kiss-datepicker .dp-foot button:hover {
  background: var(--hover); border-color: var(--border-hover);
}

/* History: tasks are grouped by chat (newest chat first, by its latest
   task), a day label ahead of the first chat of each day.  The list
   is flat and quiet, as the session list of Claude Code: one line per
   chat, no coloured bands, no per-chat colours, no lines between
   chats, a neutral rounded fill under the pointer and on the chat the
   user is looking at.  A day label is a small line in the regular
   weight, with more room above it than there is between two rows. */
.history-day-sep {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-4) 0 var(--space-1-5);
  font-size: var(--fs-md);
  font-weight: 400;
  color: var(--faint);
  white-space: nowrap;
}

.history-day-sep:first-child { padding-top: var(--space-1); }

/* The chat panels run edge to edge across the history list (which
   itself spans the whole panel width, see #history-list).  No padding:
   the header row is flush with the panel's edges; the task rows get
   their inset from .history-chat-body. */
.history-chat-group {
  display: flex;
  flex-direction: column;
}

/* The chat panel's header, laid out like a task panel: ONE line with
   the chat's title (ellipsized) and, at its right end, the fold button
   and the "…" button whose menu holds the row's other actions
   (.sidebar-item-actions).  A plain row on the list's own background
   (a list of many chats must not become a stack of bands).  No
   tooltip: the line is all there is.  Clicking the row opens the chat;
   only the fold button folds the task panels under it.
   A four-column grid: the first column is the slot of the last
   task's status icon (the icon's 12px and the 6px to the title), then
   the title, then the two buttons.
   The row's fill (hover, active chat) keeps 8px from the panel's
   edges - the right margin counts the list's scrollbar gutter in, see
   #history-list - and 2px from the next row's.
   The header of a project's panel (.history-project-header) is the
   same row, with the Projects icon in the status icon's slot. */
.history-project-header,
.history-chat-header {
  display: grid;
  grid-template-columns: calc(var(--space-3) + var(--space-1-5)) minmax(0, 1fr) auto auto;
  align-items: center;
  margin: 1px calc(var(--space-2) - var(--history-gutter, 0px)) 1px var(--space-2);
  background: transparent;
  border: none;
  border-radius: var(--radius-lg);
  padding: var(--space-1-5) var(--space-1) var(--space-1-5) var(--space-1-5);
  cursor: pointer;
  text-align: left;
  color: var(--fg);
  font-family: inherit;
  font-size: var(--fs-base);
  font-weight: 400;
  line-height: 1.35;
  transition: background var(--dur-base);
}

.history-project-header:hover,
.history-chat-header:hover {
  background-color: var(--hover);
}

/* The fill stays while the row's menu is open, as under the pointer. */
.history-project-header:has(> .sidebar-item-actions:popover-open),
.history-chat-header:has(> .sidebar-item-actions:popover-open) {
  background-color: var(--hover);
}

/* The header of the chat on screen (the chat whose task the visible
   tab shows): the selected row's fill and the strongest text, so the
   chat is found even while its panel is folded and the row is hidden.
   The :hover form outranks the neutral hover above. */
.history-chat-group.history-active-chat > .history-chat-header,
.history-chat-group.history-active-chat > .history-chat-header:hover {
  background-color: var(--selected);
  color: var(--fg-strong);
}

/* The status icon of the chat's last task (the same "?", spinner,
   cross or tick its row shows), in the first column before the title:
   centred in the 12px its margin leaves there (the "?" is narrower
   than the shapes). */
.history-chat-header > .history-chat-status {
  grid-column: 1;
  justify-self: center;
  margin-right: var(--space-1-5);
}

.history-project-title,
.history-chat-title {
  grid-column: 2;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The title turned into a text box while the user retypes the chat's
   summary (startHistoryGroupRename): it fills the title's column and
   looks like the title it replaces. */
.history-chat-title-input {
  width: 100%;
  font: inherit;
  color: var(--fg);
  background: var(--surface2);
  border: 1px solid var(--ring-focus);
  border-radius: var(--radius-sm);
  padding: 0 var(--space-1);
  outline: none;
}

.history-chat-launched:empty { display: none; }

/* The chat's task rows, indented under the header behind a hairline
   guide (under the header's status icon) so the nesting reads without
   a tinted band; their fills end where the header's does. */
.history-chat-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-0-5);
  margin: 0 calc(var(--space-2) - var(--history-gutter, 0px)) var(--space-1) calc(var(--space-4) + var(--space-1));
  padding-left: var(--space-1);
  border-left: 1px solid var(--border);
}

.history-chat-group.collapsed > .history-chat-body { display: none; }

.history-chat-body > .sidebar-item { margin-bottom: 0; }

/* A project's panel (Group by: Project, main.js
   makeHistoryProjectPanel): its header, then its chats, each a chat
   panel of its own, behind a hairline guide under the header's icon,
   as a chat's tasks are behind theirs. */
.history-project {
  display: flex;
  flex-direction: column;
}

/* The Projects icon, or the spinner while a task of the project runs,
   centred in the first column as a chat's status icon is. */
.history-project-icon {
  grid-column: 1;
  justify-self: center;
  display: flex;
  margin-right: var(--space-1-5);
  color: var(--dim);
}

.history-project-icon.status-spinner { display: inline-block; color: var(--brand-clay); }

/* The project of the chat on screen, while its panel is folded and
   the chat's own row is out of sight: the selected row's fill. */
.history-project.collapsed.history-active-project > .history-project-header,
.history-project.collapsed.history-active-project > .history-project-header:hover {
  background-color: var(--selected);
  color: var(--fg-strong);
}

.history-project-body {
  display: flex;
  flex-direction: column;
  margin: 0 0 var(--space-1) calc(var(--space-4) + var(--space-1));
  border-left: 1px solid var(--border);
}

.history-project.collapsed > .history-project-body { display: none; }

/* What an unfolded panel says while it lists no chat ("Loading...",
   "No chats yet", "Listed under Pinned"): gone once a chat with a
   task is listed beside it (a chat whose tasks are all pinned on
   their own has none left in its panel), and while it has nothing to
   say (the filters hide what is pinned of the project). */
.history-project-note {
  padding: var(--space-1) var(--space-2-5) var(--space-1-5);
  font-size: var(--fs-md);
  color: var(--faint);
}

.history-project-note:empty,
.history-project-body:has(> .history-chat-group .sidebar-item) > .history-project-note { display: none; }

/* "Show more chats", the last row of a panel whose newest page of
   rows was a full one: a quiet text button, set as the note is. */
.history-project-more-rows {
  align-self: flex-start;
  margin: 0 0 var(--space-1) var(--space-1);
  padding: var(--space-1) var(--space-1-5);
  background: none; border: none; border-radius: var(--radius-lg);
  color: var(--dim); font-family: inherit; font-size: var(--fs-md);
  cursor: pointer; transition: background var(--dur-base), color var(--dur-base);
}

.history-project-more-rows:hover { background: var(--hover); color: var(--fg); }

/* Rows are flat, as in Claude Code Desktop's session list: no fill,
   no outline and no divider between them; the pointer and the active
   state add a neutral fill.  The 1px transparent border is part of
   the row's box. */
.sidebar-item {
  padding: var(--space-1-5) var(--space-2-5) 3.5px; background: transparent;
  border: 1px solid transparent; border-radius: var(--radius-md);
  margin-bottom: var(--space-1); cursor: pointer; font-size: var(--fs-base);
  color: var(--fg); overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; transition: background var(--dur-base), color var(--dur-base); font-weight: 400;
  display: flex; align-items: center;
}

.sidebar-item-text {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Row status icons (.status-cross / .status-spinner / .status-tick
   shapes): red cross for a failed task, clay spinner while it runs
   (the working colour), green tick once it finished successfully, and
   the tab strip's pulsing "?" (.chat-tab-attention) in the spinner's
   place while the task waits for the user's answer. */
.sidebar-item-failed { color: var(--status-fail); margin-right: var(--space-2); }

.sidebar-item-running { color: var(--brand-clay); margin-right: var(--space-2); }

.sidebar-item-completed { color: var(--status-ok); margin-right: var(--space-2); }

.sidebar-item-running.sidebar-item-asking {
  font-size: var(--fs-md); font-weight: 600; line-height: 1;
  color: var(--warning);
  animation: running-pulse 1.5s ease-in-out infinite;
}

/* A task panel, as a chat panel's header: ONE line with the task's
   text (ellipsized) and the "…" button whose menu holds the row's
   actions; nothing hangs under it.  The
   header's line height and the same padding above and below the line
   make the row as tall as a header, with the text in the middle of
   its fill.  The left padding is the slot of the status icon, which
   hangs there out of the flow so every text starts on the same edge:
   the icon's 5px from the row's edge, its 12px and the 6px to the
   text, as in a chat header. */
.running-item {
  position: relative;
  align-items: center;
  margin-bottom: var(--space-0-5);
  padding: var(--space-1-5) 3px;
  padding-left: 23px;
  border-radius: var(--radius-lg);
  line-height: 1.35;
}

/* The status icon is centred on the panel's line - the task text's,
   which the line's button does not make taller (.sidebar-item-more).
   The offset is the panel's own padding-top
   plus half a line box, and the translation then centres the icon on
   that point.  `translate`, not `transform`: the spinner's `rotate` is
   applied after `translate` (so the ring turns in place) but before
   `transform` (which would make it orbit; see @keyframes
   status-spin). */
.running-item > .sidebar-item-failed,
.running-item > .sidebar-item-running,
.running-item > .sidebar-item-completed {
  position: absolute;
  left: 5px;
  top: calc(var(--space-1-5) + 0.5lh);
  translate: 0 -50%;
  margin-right: 0;
}

/* The task panel of the task the user is looking at (the tab on
   screen): the selected row's neutral fill and the strongest text,
   so the eye finds it in the list.  The :hover forms outrank both
   surfaces' generic .sidebar-item:hover rules, so the cue survives
   the pointer. */
.running-item.history-active-task,
.running-item.history-active-task:hover,
body.remote-chat .running-item.history-active-task,
body.remote-chat .running-item.history-active-task:hover {
  background-color: var(--selected);
  color: var(--fg-strong);
}

/* The task's text keeps to one line (.sidebar-item-text ellipsizes
   it); the row's tooltip shows all of it. */
.running-item > .sidebar-item-text {
  min-width: 0;
  font-weight: 400;
}

/* The two buttons at the right end of a project's or a chat panel's
   header: the fold button, whose chevron points down while what
   hangs under the row is folded away and up while it shows, and the
   "…" button, as on a session of Claude Code's sidebar (a task panel
   has the "…" button alone).  Both are out
   of sight until the pointer is on the row, the keyboard is on the
   row or on the button, or the row's menu is open; a step lighter
   than the row's fill under the pointer and, the "…" button, while
   its menu is open.  A touch screen has no hover: there the buttons
   always show.
   A button is taller than the row's line of text and is centred on
   it; its negative margins keep it from making that line taller, so a
   row is as tall as its text and padding make it. */
.sidebar-item-collapse,
.sidebar-item-more {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  width: var(--space-6);
  height: var(--space-6);
  margin: calc(-1 * var(--space-1)) 0;
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: none;
  color: var(--dim);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--dur-base), background var(--dur-base), color var(--dur-base);
}

.history-chat-header > .sidebar-item-collapse,
.history-project-header > .sidebar-item-collapse { grid-column: 3; }

.history-chat-header > .sidebar-item-more,
.history-project-header > .sidebar-item-more { grid-column: 4; }

.history-project-header:hover > .sidebar-item-collapse,
.history-project-header:hover > .sidebar-item-more,
.history-project-header:focus-visible > .sidebar-item-collapse,
.history-project-header:focus-visible > .sidebar-item-more,
.history-chat-header:hover > .sidebar-item-collapse,
.history-chat-header:hover > .sidebar-item-more,
.history-chat-header:focus-visible > .sidebar-item-collapse,
.history-chat-header:focus-visible > .sidebar-item-more,
.running-item:hover > .sidebar-item-more,
.running-item:focus-visible > .sidebar-item-more,
.sidebar-item-collapse:focus-visible,
.sidebar-item-more:focus-visible {
  opacity: 1;
}

.sidebar-item-collapse:hover,
.sidebar-item-more:hover {
  background: var(--hover-strong);
  color: var(--fg);
}

/* While the row's menu is open: both buttons show, the "…" button as
   under the pointer. */
.sidebar-item-collapse:has(~ .sidebar-item-actions:popover-open) { opacity: 1; }

.sidebar-item-more:has(+ .sidebar-item-actions:popover-open) {
  opacity: 1;
  background: var(--hover-strong);
  color: var(--fg);
}

.sidebar-item-collapse:focus-visible,
.sidebar-item-more:focus-visible { outline: 1px solid var(--accent); outline-offset: -1px; }

/* The chevron is turned over while what hangs under the row shows. */
.sidebar-item-collapse svg { transition: transform var(--dur-base) var(--ease); }

.history-project:not(.collapsed) > .history-project-header > .sidebar-item-collapse svg,
.history-chat-group:not(.collapsed) > .history-chat-header > .sidebar-item-collapse svg {
  transform: rotate(180deg);
}

@media (hover: none) {
  .sidebar-item-collapse,
  .sidebar-item-more { opacity: 1; }
}

/* A row's menu (main.js makeSidebarRowMenu): the row's action strip,
   which its "…" button shows as a popover in the top layer, where
   neither the sidebar's clip nor its width reaches it.  As the "…"
   menu of a session in Claude Code: a raised card with a hairline and
   a 12px corner, one line per button (its icon, then its name) with
   the destructive one in the error colour and, under a hairline, when
   the row's task was launched and, for a task of another machine,
   where.  main.js gives the card its left and top before it shows;
   `placing` lays it out, unseen, for that measurement.  Outside those
   two states the card sets no `display`: one would outrank the
   browser's `display: none` of a closed popover. */
.sidebar-item-actions {
  position: fixed;
  inset: auto;
  flex-direction: column;
  width: max-content;
  min-width: 200px;
  max-width: calc(100vw - var(--space-4));
  max-height: calc(100vh - var(--space-4));
  margin: 0;
  padding: var(--space-1);
  overflow: hidden auto;
  background: var(--menu-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-2xl);
  box-shadow: var(--shadow-lg);
  color: var(--fg);
  font-size: var(--fs-base);
  font-weight: 400;
  line-height: 1.35;
  white-space: nowrap;
  cursor: default;
}

.sidebar-item-actions:popover-open,
.sidebar-item-actions.placing { display: flex; }

.sidebar-item-actions.placing { visibility: hidden; }

/* A browser without popovers (one from before 2024) cannot open a
   row's menu: there a row is its line of text and, a header, its fold
   button. */
@supports not selector(:popover-open) {
  .sidebar-item-more,
  .sidebar-item-actions { display: none; }
}

/* A menu line: the button's icon in the secondary text step (or in its
   state's colour: a lit star, a set pin, a copied tick), then its
   name, which is its aria-label.  The rules below outrank the compact
   icon buttons' (.sidebar-item-delete and its kin, shared with the
   other sidebar lists). */
.sidebar-item-actions > button {
  flex: none;
  gap: var(--space-2-5);
  min-height: 30px;
  margin: 0;
  padding: 0 var(--space-2-5);
  border-radius: var(--radius-md);
  color: var(--dim);
  font: inherit;
}

.sidebar-item-actions > button::after {
  content: attr(aria-label);
  color: var(--fg);
}

.sidebar-item-actions > button > svg {
  flex: none;
  width: 14px;
  height: 14px;
}

.sidebar-item-actions > button:hover,
.sidebar-item-actions > button:focus-visible {
  background: var(--hover);
  box-shadow: none;
  outline: none;
}

.sidebar-item-actions > .sidebar-item-delete,
.sidebar-item-actions > .sidebar-item-delete:hover,
.sidebar-item-actions > .sidebar-item-delete::after {
  color: var(--error);
}

/* The copy line answers in place for as long as its tick shows. */
.sidebar-item-actions > .sidebar-item-copy.copied::after { content: 'Copied'; }
.sidebar-item-actions > .sidebar-item-copy.copy-failed::after { content: 'Copy failed'; }

/* The delete question takes the Delete line's place, its two buttons
   side by side across the menu. */
.sidebar-item-actions > .sidebar-item-confirm {
  gap: var(--space-1-5);
  min-height: 30px;
  margin: 0;
  padding: 0 var(--space-1-5);
}

.sidebar-item-actions > .sidebar-item-confirm > button {
  flex: 1;
  justify-content: center;
}

/* The menu's last lines, small and in the secondary text step: when
   the row's task was launched (a chat's: its last task) and on which
   machine.  The first of them draws the hairline that parts them from
   the buttons, inset to the icons' edge. */
.sidebar-item-actions > .sidebar-item-launched,
.sidebar-item-actions > .history-chat-launched,
.sidebar-item-actions > .sidebar-item-machine {
  flex: none;
  margin: 0 var(--space-2-5);
  padding: var(--space-0-5) 0;
  overflow: hidden;
  font-size: var(--fs-md);
  color: var(--dim);
  text-overflow: ellipsis;
}

.sidebar-item-actions > :is(button, .sidebar-item-confirm) + :not(button, .sidebar-item-confirm),
.sidebar-item-actions > .history-chat-launched:empty + .sidebar-item-machine {
  margin-top: var(--space-1);
  padding-top: var(--space-1-5);
  border-top: 1px solid var(--border);
}

.sidebar-item-actions > .sidebar-item-launched::before { content: 'Launched '; }
.sidebar-item-actions > .history-chat-launched > .sidebar-item-launched::before { content: 'Last task '; }
.sidebar-item-actions > .sidebar-item-machine::before { content: 'on '; }

/* The row's action icons: ghost icon buttons, faint at rest. */
.sidebar-item-delete,
.sidebar-item-copy,
.sidebar-item-edit,
.sidebar-item-favorite,
.sidebar-item-pin {
  flex-shrink: 0; border: none; cursor: pointer; padding: var(--space-0-5) 0; margin-left: var(--space-0-5);
  border-radius: var(--radius-sm); line-height: 1; display: flex; align-items: center;
  color: var(--faint);
  background: none;
  transition: background var(--dur-base), box-shadow var(--dur-base), color var(--dur-base);
}

/* Under the pointer the fill reaches 2px past the icon's box (a ring
   of the same colour, so the box keeps its size), which rounds its
   corner to an icon button's 6px. */
.sidebar-item-delete:hover,
.sidebar-item-copy:hover,
.sidebar-item-edit:hover,
.sidebar-item-favorite:hover,
.sidebar-item-pin:hover {
  color: var(--fg);
  background: var(--hover-strong);
  box-shadow: 0 0 0 var(--space-0-5) var(--hover-strong);
}

.sidebar-item-copy.copied { color: var(--status-ok); }

.sidebar-item-favorite.favorited,
.sidebar-item-favorite.favorited:hover { color: var(--favorite); }

/* A set pin: the filled glyph, in the text's own colour. */
.sidebar-item-pin.pinned { color: var(--fg); }

.sidebar-item-confirm {
  display: flex; align-items: center; gap: var(--space-1); flex-shrink: 0; margin-left: var(--space-1-5);
}

/* The delete confirmation: two small buttons, a destructive Delete and
   a secondary Cancel. */
.sidebar-confirm-yes,
.sidebar-confirm-no {
  background: var(--surface2);
  border: 1px solid var(--border-input);
  cursor: pointer; padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md); line-height: 1; display: flex; align-items: center;
  color: var(--fg);
  font-size: var(--fs-md); font-weight: 500;
  transition: background var(--dur-base), border-color var(--dur-base);
}

.sidebar-confirm-yes {
  color: var(--error);
  border-color: color-mix(in srgb, var(--error) 45%, transparent);
}

.sidebar-confirm-yes:hover:not(:disabled) {
  background: color-mix(in srgb, var(--error) 12%, transparent);
}

/* A spent Delete (its delete is posted and the row waits for the daemon's refetch). */
.sidebar-confirm-yes:disabled { opacity: 0.4; cursor: default; }

.sidebar-confirm-no:hover:not(:disabled) { background: var(--hover); border-color: var(--border-hover); }

.sidebar-confirm-yes:focus-visible,
.sidebar-confirm-no:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

.sidebar-item:hover { background: var(--hover); }
.sidebar-empty { font-size: var(--fs-base); color: var(--faint); padding: var(--space-2) 0; }

/* The auth modal and the sign-in window (chat.html#signin-modal) share
   the scrim. */
#auth-modal,
#signin-modal {
  position: fixed; inset: 0; background: var(--scrim-strong);
  display: flex; align-items: center; justify-content: center; z-index: var(--z-modal);
}

/* The box, title, button row and buttons are shared with the
   server-reset confirm dialog below.  The box is a raised card: a
   hairline, a 12px corner and one wide soft shadow; text without a
   colour of its own (the password prompt's label) is secondary. */
.auth-modal-content,
.server-reset-confirm-content {
  padding: var(--space-5); width: 90%; max-width: 360px;
  background: var(--menu-bg); border: 1px solid var(--border);
  border-radius: var(--radius-2xl); box-shadow: var(--shadow-lg);
  color: var(--dim);
}

/* A window too short for the box (the sign-in window with its paste
   row on a phone held sideways) keeps it inside and scrolls it. */
.auth-modal-content { max-height: calc(100% - var(--space-8)); overflow-y: auto; }

.auth-modal-title,
.server-reset-confirm-title {
  font-size: var(--fs-lg); font-weight: 600; color: var(--fg); margin-bottom: var(--space-3);
}

.auth-modal-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border-input); border-radius: var(--radius-lg); color: var(--fg);
  font-size: var(--fs-lg); padding: var(--space-2) var(--space-2-5); outline: none; margin-bottom: var(--space-3);
}
.auth-modal-input::placeholder { color: var(--faint); }
.auth-modal-input:focus { border-color: var(--ring-focus); }

/* The password prompt's error line (laid out inline by web_server.py)
   belongs to its field: the field's gap goes below the line. */
#auth-modal .auth-modal-input { margin-bottom: 0; }
#auth-modal-error { margin-bottom: var(--space-3); }

.auth-modal-actions,
.server-reset-confirm-actions {
  display: flex; justify-content: flex-end; gap: var(--space-2);
}

.auth-modal-btn,
.server-reset-confirm-btn {
  font-size: var(--fs-base); font-weight: 500; border-radius: var(--radius-lg);
  padding: var(--space-1-5) var(--space-3); cursor: pointer; transition: background var(--dur-base), border-color var(--dur-base);
}

/* Cancel / Not now: the secondary button. */
.auth-modal-cancel,
.server-reset-confirm-cancel {
  background: var(--surface2); border: 1px solid var(--border-input); color: var(--fg);
}

.auth-modal-cancel:hover,
.server-reset-confirm-cancel:hover { background: var(--hover); border-color: var(--border-hover); }

/* The confirming action: the primary button. */
.auth-modal-ok,
.server-reset-confirm-ok {
  background: var(--primary-bg); border: 1px solid transparent;
  color: var(--primary-fg);
}

.auth-modal-ok:hover,
.server-reset-confirm-ok:hover { background: var(--primary-hover-bg); }

/* The sign-in window (chat.html#signin-modal): the auth modal's scrim,
   box and buttons, with one full-width provider button per row. */
.signin-modal-buttons { display: flex; flex-direction: column; gap: var(--space-2); margin-bottom: var(--space-3); }

.signin-modal-buttons .auth-modal-btn { width: 100%; padding: var(--space-2-5) var(--space-3); font-size: var(--fs-lg); }

.signin-modal-note {
  min-height: 1.2em; margin-bottom: var(--space-3); line-height: 1.5;
  font-size: var(--fs-base); color: var(--dim);
  overflow-wrap: anywhere; word-break: break-word;
}

.signin-modal-note.signin-modal-error { color: var(--error); }

.signin-modal-paste { margin-bottom: var(--space-3); }

.signin-modal-paste-label {
  display: block; margin-bottom: var(--space-1-5); font-size: var(--fs-base);
  color: var(--dim); line-height: 1.5;
}

#server-reset-confirm-modal {
  display: none;
  position: absolute; inset: 0;
  background: var(--scrim-strong);
  align-items: center; justify-content: center;
  z-index: var(--z-alert); padding: var(--space-4);
}
#server-reset-confirm-modal.open { display: flex; }

.server-reset-confirm-message {
  font-size: var(--fs-base); color: var(--dim);
  margin-bottom: var(--space-4); line-height: 1.5;
  overflow-wrap: anywhere; word-break: break-word;
}

/* Markdown, as Claude Code Desktop sets a reply: paragraphs 10px
   apart, headings at the semibold weight, inline code a small chip in
   the palette's code colour, code blocks on the code surface with a
   hairline and a 10px corner, links in the accent with an underline
   under the pointer only, and tables in a rounded hairline frame with
   a hairline between rows and columns and no shading. */
.md-body p { margin: var(--space-2-5) 0; }
.md-body :is(h1,h2,h3,h4,h5,h6) { margin: var(--space-4) 0 var(--space-2); font-weight: 600; line-height: 1.3; color: var(--fg); }
.md-body h1 { font-size: var(--fs-2xl); }
.md-body h2 { font-size: var(--fs-xl); }
.md-body :is(h3,h4,h5,h6) { font-size: var(--fs-lg); }
.md-body :is(ul,ol) { margin: var(--space-2) 0; padding-left: var(--space-5); }
.md-body li { margin: var(--space-1) 0; }
.md-body > :first-child { margin-top: 0; }
.md-body > :last-child { margin-bottom: 0; }

.md-body code, .txt code {
  background: var(--hover); border: 1px solid var(--border-soft);
  padding: 1px var(--space-1); border-radius: var(--radius-sm);
  font-size: var(--fs-inline-code); color: var(--code-inline-fg);
}

.md-body pre, .txt pre {
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius-xl); padding: var(--space-3); overflow-x: auto; margin: var(--space-2-5) 0;
}

.md-body pre code, .txt pre code {
  background: none; border: none; padding: 0;
  font-size: var(--fs-md); color: var(--fg);
}

.md-body blockquote {
  border-left: 2px solid var(--border-input); padding: 0 var(--space-3); margin: var(--space-2-5) 0; color: var(--dim);
}
.md-body a { color: var(--accent); text-decoration: none; }
.md-body a:hover { text-decoration: underline; }
.md-body strong { font-weight: 600; color: var(--fg); }
.md-body em { font-style: italic; }
.md-body hr { border: none; border-top: 1px solid var(--border); margin: var(--space-4) 0; }

.md-body table {
  border-collapse: separate; border-spacing: 0; margin: var(--space-2-5) 0; width: 100%;
  border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden;
}

.md-body :is(th,td) {
  border: 0 solid var(--border);
  padding: var(--space-2) var(--space-3); font-size: var(--fs-base);
  text-align: left; vertical-align: top;
}
.md-body :is(th,td) + :is(th,td) { border-left-width: 1px; }

.md-body tr + tr > :is(th,td),
.md-body thead + tbody > tr:first-child > td { border-top-width: 1px; }

.md-body th { font-weight: 600; }

code { font-family: var(--font-mono); }

/* A highlighted block outside Markdown (a tool call's command or file
   content) paints its own code surface, hairline and padding;
   !important beats the `pre code` resets above, which outrank a bare
   class.  Inside a Markdown <pre>, which paints the surface itself,
   the highlighted <code> adds nothing of its own. */
.hljs {
  background: var(--code-bg) !important;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: var(--space-2-5) !important;
}

.md-body pre .hljs, .txt pre .hljs {
  background: none !important;
  border: none; border-radius: 0; padding: 0 !important;
}

#custom-tooltip {
  position: fixed; z-index: var(--z-tooltip); background: var(--menu-bg); color: var(--fg);
  border: 1px solid var(--border); border-radius: var(--radius-lg); padding: var(--space-1) var(--space-2);
  font-size: var(--fs-md); line-height: 1.4; white-space: pre-wrap;
  word-break: break-word; max-width: min(350px, calc(100vw - 20px)); pointer-events: none;
  opacity: 0; transition: opacity var(--dur-base); box-shadow: var(--shadow-md);

  /* Never taller than the viewport (main.js slides it to fit): a text
     longer than a screen, such as a scheduled job's prompt, is cut at
     the bottom edge; its copy button gives the whole of it. */
  max-height: calc(100vh - 16px); overflow: hidden;
}
#custom-tooltip.visible { opacity: 1; }

/* A tooltip that draws with characters (the bars of a cc/ model's plan
   usage) needs every cell as wide as the next: an element's
   data-tooltip-mono asks for it. */
#custom-tooltip.mono { font-family: var(--font-mono); }

/* The post-task choices take the composer's place: a raised card
   with the composer's corner and shadow. */
.wt-bar {
  display: flex; flex-direction: column; gap: var(--space-2-5); padding: var(--space-2-5) var(--space-3);
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.wt-label {
  font-size: var(--fs-md); color: var(--dim);
}
.wt-btns { display: flex; gap: var(--space-2); width: 100%; }

.wt-btns .wt-btn { flex: 1; }

/* A bar button is the secondary button; Merge is the primary one and
   Discard the destructive one. */
.wt-btn {
  padding: var(--space-1-5) var(--space-3); border: 1px solid var(--border-input); border-radius: var(--radius-lg);
  font-size: var(--fs-md); font-weight: 500; cursor: pointer;
  transition: background var(--dur-base), border-color var(--dur-base), color var(--dur-base); background: var(--surface2); color: var(--fg);
}
.wt-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.wt-btn:focus-visible { outline: 1px solid var(--accent); outline-offset: 1px; }

.wt-merge {
  background: var(--primary-bg);
  border-color: transparent;
  color: var(--primary-fg);
}

.wt-merge:hover:not(:disabled) {
  background: var(--primary-hover-bg);
}

.wt-discard {
  border-color: color-mix(in srgb, var(--error) 45%, transparent);
  color: var(--error);
}

.wt-discard:hover:not(:disabled) {
  background: color-mix(in srgb, var(--error) 12%, transparent);
  border-color: var(--error);
}

.wt-nothing:hover:not(:disabled) {
  background: var(--hover);
  border-color: var(--border-hover);
}

/* The action bar's inline two-step confirm ("Delete branch 'x' and all
   of the task's changes?" + Discard / Keep), shown in place of the
   buttons so a destructive click is never a single step. main.js
   toggles it with the hidden attribute. */
.wt-confirm {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); width: 100%;
}
.wt-confirm-text { flex: 1 1 100%; font-size: var(--fs-base); color: var(--fg); }

.wt-confirm[hidden],
.wt-btns[hidden] { display: none !important; }

/* Inline notes under settings fields (#cfg-max-budget-note,
   #settings-update-status) and under the promptlet Add row
   (#tricks-add-error): the message stays next to the field it is about
   instead of vanishing in a toast. */
.config-field-note {
  font-size: var(--fs-sm);
  color: var(--dim);
  padding: 0 var(--space-2-5) var(--space-1-5);
}
.config-field-note-error { color: var(--error); }

/* "New output ↓": the sibling right after #output in #app's column while
   the user has scrolled up and new output arrived below. The negative
   top margin floats it over the transcript's bottom edge so it takes no
   room from the composer.  It floats over the transcript's text, so
   its hover fill is opaque: the row wash pre-mixed over the raised
   surface. */
.new-output-btn {
  position: relative; z-index: var(--z-float);
  align-self: center; margin-top: calc(-1 * var(--space-8)); margin-bottom: var(--space-1-5);
  padding: var(--space-1) var(--space-3); border: 1px solid var(--border-input); border-radius: var(--radius-pill);
  background: var(--surface2); color: var(--fg);
  font-size: var(--fs-md); font-weight: 500; cursor: pointer;
  box-shadow: var(--shadow-md);
}

.new-output-btn:hover {
  background: color-mix(in srgb, var(--fg) 6%, var(--surface2));
  border-color: var(--border-hover);
}
.new-output-btn:focus-visible { outline: 1px solid var(--accent); }

/* The result line of an auto-commit or worktree merge, and the live
   "Staging changes… / Generating commit message… / Committing…" line
   before it (replaced in place and removed by the terminal
   autocommit_done / worktree_result): one quiet line each, like a
   note or a warning, the result in its status colour. */
.wt-result-ok,
.wt-result-err,
.wt-progress {
  padding: var(--space-0-5) 0; margin: var(--space-1-5) 0;
  font-size: var(--fs-base);
}

.wt-result-ok { color: var(--green); }

.wt-result-err { color: var(--red); }

.wt-progress { color: var(--dim); }

.adjacent-loader {
  text-align: center;
  padding: var(--space-2-5);
  color: var(--dim);
  font-size: var(--fs-sm);
}

.adjacent-task {
  border-top: 1px solid var(--border);
  padding-top: var(--space-1);
}

.adjacent-task:first-child {
  border-top: none;
}

.adjacent-task-placeholder {
  padding: var(--space-2-5);
  color: var(--faint);
  font-size: var(--fs-sm);
}

/* A panel's disclosure header (addCollapse in main.js): its title,
   then - while the panel is folded - one line of what it holds
   (.collapse-preview, cut with an ellipsis), then a small chevron
   that points right on a folded panel and down on an open one, as
   after Claude Code Desktop's tool lines.  The chevron follows the
   header's aria-expanded, which main.js and share.js keep in step. */
.collapse-header {
  display: flex; align-items: baseline; gap: var(--space-1-5);
}

.collapse-header::after {
  content: '';
  flex: none; align-self: center;
  width: 12px; height: 12px;
  background: var(--faint);
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3E%3Cpath d='M6 3.5l4.5 4.5L6 12.5' fill='none' stroke='black' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
  transition: transform var(--dur-base) var(--ease);
}

.collapse-header[aria-expanded="true"]::after { transform: rotate(90deg); }

.collapse-preview {
  display: none; color: var(--dim); font-weight: 400;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 0 1 auto; min-width: 0;
}
.collapsed .collapse-preview { display: block; }

.llm-panel-hdr {
  padding: var(--space-0-5) var(--space-8) var(--space-0-5) 0;
  font-size: var(--fs-base); font-weight: 400; line-height: 1.5;
  color: var(--dim);
}
.llm-panel-hdr:hover { color: var(--fg); }
.llm-panel.collapsed > :not(.llm-panel-hdr, .panel-copy-btn) { display: none; }

/* A panel's foot: when it started and how long it took (and what the
   model call cost), in the faintest text step. */
.panel-time {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
  font-size: var(--fs-sm);
  color: var(--faint);
  font-variant-numeric: tabular-nums;
  padding: var(--space-0-5) 0 0;
}

/* Inside a card (an open tool call, a prompt, the user's bubble) the
   foot is inset like the card's content. */
.tc > .panel-time, .trajectory > .panel-time, .system-prompt > .panel-time,
.prompt > .panel-time, .ask-answer > .panel-time,
.task-panel > .panel-time, .user-msg > .panel-time {
  padding: 0 var(--space-3) var(--space-1-5);
}

.panel-elapsed {
  margin-left: auto;
  text-align: right;
  white-space: nowrap;
}

.copyable { position: relative; }

/* A panel's own actions, Copy and (on a running tool call) Stop: ghost
   icon buttons at the right end of the panel's first line.  As in
   Claude Code Desktop, Copy shows only while the pointer is over its
   panel (or it has the keyboard focus, or just copied); a touch
   screen has no pointer to hover with, so there it stays in view. */
.panel-stop-btn,
.panel-copy-btn {
  position: absolute; top: var(--space-1); z-index: var(--z-float);
  align-items: center; justify-content: center;
  padding: var(--space-1); cursor: pointer;
  background: none;
  border: none; border-radius: var(--radius-md);
  transition: opacity var(--dur-base), color var(--dur-base), background var(--dur-base);
}
.panel-copy-btn { display: flex; right: var(--space-1-5); color: var(--dim); opacity: 0; }

@media (hover: none) {
  .panel-copy-btn { opacity: 1; }
}

.copyable:hover > .panel-copy-btn,
.panel-copy-btn:focus-visible,
.panel-copy-btn.copied,
.panel-copy-btn.copy-failed { opacity: 1; }

.panel-copy-btn:hover {
  color: var(--fg);
  background: var(--hover-strong);
}

/* On a panel whose first line sits on the canvas (a tool line, the
   model's turn, the result's label) the buttons end flush with the
   chat column. */
.tc > .panel-copy-btn, .trajectory > .panel-copy-btn, .system-prompt > .panel-copy-btn,
.prompt > .panel-copy-btn, .ask-answer > .panel-copy-btn, .llm-panel > .panel-copy-btn {
  top: 0; right: 0;
}

.rc > .panel-copy-btn { top: var(--space-2-5); right: 0; }

.panel-copy-btn.copied { color: var(--green); }
.panel-copy-btn.copy-failed { color: var(--error); }

/* Per-panel Stop for a running tool call: sits immediately left of the
   copy button (24px wide at the panel's right edge) and is shown only
   while the panel's tool call is in progress -- a .tc stamped with
   data-start-ms (stampPanelStart) and not yet sealed by data-time-done
   (finalizePanelTime / sealPanelTimes). */
.panel-stop-btn { display: none; top: 0; right: var(--space-6); color: var(--red); opacity: 0.8; }
.tc[data-start-ms]:not([data-time-done]) > .panel-stop-btn { display: flex; }

.panel-stop-btn:hover,
.panel-stop-btn:focus-visible { opacity: 1; }

.panel-stop-btn:hover {
  background: color-mix(in srgb, var(--red) 15%, transparent);
}

.panel-stop-btn.stopping {
  cursor: progress;
  color: var(--dim);
  opacity: 0.6;
}

.panel-ts {
  white-space: nowrap;
}

/* The USD cost of the model call a thoughts panel holds, next to its
   time label (from the llm_call event). */
.panel-cost {
  white-space: nowrap;
}

.system-prompt.collapsed .system-prompt-body,
.prompt.collapsed .prompt-body,
.ask-answer.collapsed .ask-answer-body { display: none; }

.tr.collapsed .tr-content { display: none; }

/* Scrollbars: a 4px pill thumb riding in a 6px bare gutter (the 1px
   transparent border keeps it off the content edge), faint at rest
   and stronger under the pointer or while dragged.  (Chromium does
   not restyle the thumb when an ancestor is hovered, so there is no
   "pointer over the list" tier.)  Chromium (Chrome, Edge, Electron)
   draws these ::-webkit-
   parts.  It ignores them on any element that also sets the standard
   scrollbar-width or scrollbar-color, falling back to its wide native
   bar there, so those two properties are set only where the pseudo-
   elements are unsupported (Firefox), and nowhere else in the
   stylesheet except to hide a bar outright. */
::-webkit-scrollbar { width: 6px; height: 6px; }

::-webkit-scrollbar-track,
::-webkit-scrollbar-corner { background: transparent; }

::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  background-clip: padding-box;
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
}

::-webkit-scrollbar-thumb:hover,
::-webkit-scrollbar-thumb:active { background-color: var(--scrollbar-thumb-hover); }

/* On a page that runs main.js (which sets `scrollbars-autohide` on the
   root) a bar stays out of sight unless the user is scrolling: its
   thumb is clear, and is painted while its scroller carries
   `scrolling` (main.js sets it for a scroll the user caused and drops
   it 1.2 s after the last one), while the pointer is on the thumb and
   while it is dragged.  The gutter keeps its room, so nothing moves
   when the thumb comes and goes.  The class goes on the scroller
   itself: that is the element whose class Chromium repaints a thumb
   for. */
.scrollbars-autohide ::-webkit-scrollbar-thumb { background-color: transparent; }

.scrollbars-autohide .scrolling::-webkit-scrollbar-thumb { background-color: var(--scrollbar-thumb); }

.scrollbars-autohide ::-webkit-scrollbar-thumb:hover,
.scrollbars-autohide ::-webkit-scrollbar-thumb:active { background-color: var(--scrollbar-thumb-hover); }

@supports not selector(::-webkit-scrollbar) {
  * {
    scrollbar-width: thin;
    scrollbar-color: var(--scrollbar-thumb) transparent;
  }

  .scrollbars-autohide * { scrollbar-color: transparent transparent; }

  .scrollbars-autohide .scrolling { scrollbar-color: var(--scrollbar-thumb) transparent; }

  /* The bar's width is the browser's here, and it may lie over the
     content: no gutter is kept, and none is counted. */
  #history-list {
    --history-gutter: 0px;

    scrollbar-gutter: auto;
  }

  #meta-panel { --meta-gutter: 0px; }

  #meta-panel .meta-section-body { scrollbar-gutter: auto; }
}

#kiss-server-loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--fg);
  z-index: var(--z-loading);
}

.kiss-server-loading-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  text-align: center;
  padding: var(--space-4);
}

/* The shared ring's shape (see .status-spinner) in Claude's clay, the
   working colour: a faint track with one bright leading arc. */
.kiss-server-loading-spinner {
  width: 28px;
  height: 28px;
  color: var(--brand-clay);
  border: 2px solid color-mix(in srgb, currentcolor 25%, transparent);
  border-top-color: currentcolor;
  border-radius: var(--radius-round);
  animation: status-spin 1s linear infinite;
}

.kiss-server-loading-msg {
  font-size: var(--fs-base);
  color: var(--dim);
}

/* Reconnect banner (remote webapp, socket lost after the app was on
   screen): the overlay shrinks to a pill pinned to the top centre and #app
   stays visible and usable underneath — see setServerLoading() in main.js.
   Clicks pass through to the app. */
#kiss-server-loading.kiss-server-loading--banner {
  inset: 8px auto auto 50%;
  transform: translateX(-50%);
  max-width: calc(100vw - 16px);
  background: var(--menu-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  box-shadow: var(--shadow-sm);
  pointer-events: none;
}

#kiss-server-loading.kiss-server-loading--banner .kiss-server-loading-inner {
  flex-direction: row;
  gap: var(--space-2);
  padding: var(--space-1-5) var(--space-3);
}

#kiss-server-loading.kiss-server-loading--banner .kiss-server-loading-spinner {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

#kiss-server-loading.kiss-server-loading--banner .kiss-server-loading-msg {
  font-size: var(--fs-md);
  color: var(--fg);
  white-space: nowrap;
}

#content-tab-area {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

/* A column: the optional Save bar on top, the editor / frame filling
   the rest (min-height: 0 so the editor shrinks instead of overflowing). */
#content-tab-area .content-tab-view {
  position: relative; /* anchors the floating .content-refresh-overlay */
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
}

/* A shell on the daemon machine as a tab (terminalTab.js): xterm.js
   fills the tab; the fit addon sizes the shell's pty to the surface. */
#content-tab-area .terminal-view {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  padding: var(--space-1) 0 0 var(--space-1);
}

#content-tab-area .terminal-surface {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

#content-tab-area .terminal-surface .xterm {
  height: 100%;
}

#content-tab-area .terminal-load-error {
  padding: var(--space-3);
  color: var(--error);
  font-size: var(--fs-sm);
}

/* xterm.css paints the scroll viewport black (xterm 6 themes its
   scrollable node, not this one); the rows never fill the last few
   pixels, which showed as a black strip under a light theme. */
#content-tab-area .terminal-surface .xterm .xterm-viewport {
  background-color: transparent;
}

.content-tab-icon.terminal-tab-icon {
  font-family: var(--font-mono);
  font-weight: 600;
}

/* The daemon machine's browser streamed as a tab (browserTab.js): an
   address bar over the frame surface.  The surface is the element the
   daemon sizes the page to, so it must fill the tab exactly. */
#content-tab-area .browser-view {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
}

#content-tab-area .browser-toolbar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  flex: 0 0 auto;
  padding: var(--space-1) var(--space-2);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

#content-tab-area .browser-nav-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--icon);
  cursor: pointer;
  transition: background var(--dur-base), color var(--dur-base);
}

#content-tab-area .browser-nav-btn:hover:not(:disabled) {
  background: var(--hover-strong);
  color: var(--fg);
}

#content-tab-area .browser-nav-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

#content-tab-area .browser-url {
  flex: 1 1 auto;
  min-width: 0;
  height: 26px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-lg);
  background: var(--surface2);
  color: var(--fg);
  font: inherit;
  font-size: var(--fs-md);
}

#content-tab-area .browser-url::placeholder { color: var(--faint); }

#content-tab-area .browser-url:focus {
  outline: none;
  border-color: var(--ring-focus);
}

#content-tab-area .browser-badge {
  flex: 0 0 auto;
  max-width: 9em;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: var(--fs-sm);
  color: var(--dim);
  cursor: help;
}

#content-tab-area .browser-error {
  flex: 0 0 auto;
  padding: var(--space-1) var(--space-2);
  color: var(--error);
  font-size: var(--fs-md);
  border-bottom: 1px solid var(--border);
}

#content-tab-area .browser-screen {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: var(--paper);
  cursor: default;
  outline: none;
  touch-action: none;
  user-select: none;
}

#content-tab-area .browser-screen:focus-visible {
  box-shadow: inset 0 0 0 2px var(--accent);
}

#content-tab-area .browser-frame {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center;
  pointer-events: none;
}

#content-tab-area .browser-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--ink);
  opacity: 0.6;
  font-size: var(--fs-md);
  pointer-events: none;
}

#content-tab-area .content-html-frame {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
  border: 0;
  background: var(--paper);
}

#content-tab-area .content-monaco-holder {
  width: 100%;
  flex: 1 1 auto;
  min-height: 0;
}

/* Monaco's stylesheet sizes the text of its own widgets in px: Find
   and Replace, the command palette, the hidden lines of a diff.  Here
   they get the page's sizes, so the text size moves them like every
   other text (the code follows through the editors' fontSize option,
   see applyFontSize in main.js; the right-click menu, which is out of
   this stylesheet's reach, through sizeMonacoMenus).  The id outranks
   Monaco's rules, which load after these. */
#content-tab-area .monaco-findInput .monaco-inputbox,
#content-tab-area .monaco-editor .find-widget .monaco-findInput .input,
#content-tab-area .quick-input-widget,
#content-tab-area .monaco-editor .diff-hidden-lines,
#content-tab-area .monaco-editor .peekview-widget .head .peekview-title {
  font-size: var(--fs-base);
}

#content-tab-area .monaco-editor .find-widget > .find-part,
#content-tab-area .monaco-editor .find-widget > .replace-part,
#content-tab-area .monaco-inputbox-container .monaco-inputbox-message,
#content-tab-area .monaco-hover .hover-row.status-bar,
#content-tab-area .quick-input-list .quick-input-list-separator-as-item {
  font-size: var(--fs-md);
}

#content-tab-area .monaco-keybinding > .monaco-keybinding-key,
#content-tab-area .monaco-diff-editor .diff-hidden-lines-compact .text {
  font-size: var(--fs-sm);
}

/* The preview surface of a .md/.html content tab: itself a flex
   column so its .content-html-frame child stretches to fill it. */
#content-tab-area .content-preview-holder {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#content-tab-area .content-code-fallback {
  height: 100%;
  overflow: auto;
  margin: 0;
  padding: var(--space-2) var(--space-3);
  font-family: var(--font-mono);
  font-size: var(--fs-md);
  white-space: pre;
}

#content-tab-area .content-save-bar {
  display: flex;
  align-items: center;
  gap: var(--space-2-5);
  flex: 0 0 auto;
  padding: var(--space-1) var(--space-2-5);
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  font-size: var(--fs-md);
}

#content-tab-area .content-save-path {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  direction: rtl; /* keep the file name visible when the path is cut */
  text-align: left;
  color: var(--dim);
  font-family: var(--font-mono);
}

#content-tab-area .content-save-status {
  flex: 0 0 auto;
  color: var(--dim);
  white-space: nowrap;
}

/* An error is a sentence: it shrinks and wraps rather than pushing Save
   and Reload out of the pane, which clips its overflow. */
#content-tab-area .content-save-status.error {
  flex-shrink: 1;
  min-width: 0;
  color: var(--error);
  white-space: normal;
  overflow-wrap: anywhere;
}

/* Save is the bar's one confirming action: the primary button while
   there are edits to save, a faint outline until then. */
#content-tab-area .content-save-btn {
  flex: 0 0 auto;
  padding: var(--space-0-5) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: var(--primary-bg);
  color: var(--primary-fg);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-base), border-color var(--dur-base);
}

#content-tab-area .content-save-btn:hover:not(:disabled) { background: var(--primary-hover-bg); }

#content-tab-area .content-save-btn:disabled {
  background: transparent;
  border-color: var(--border-input);
  color: var(--faint);
  cursor: default;
}

#content-tab-area .content-save-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

/* The "Reload from disk" button at the top right of every content tab:
   the last item of the Save bar, or floating over the top right corner
   of a view without one (a PDF, an image, a report, a folder listing). */
#content-tab-area .content-refresh-btn {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--dim);
  font-size: var(--fs-md);
  cursor: pointer;
  transition: background var(--dur-base), color var(--dur-base);
}

#content-tab-area .content-refresh-btn:hover {
  color: var(--fg);
  background: var(--hover-strong);
}

#content-tab-area .content-refresh-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

/* Floating over the content it reloads, the button is a small raised
   chip; it stays opaque under the pointer, so it reads on any page. */
#content-tab-area .content-refresh-overlay {
  position: absolute;
  top: var(--space-1);
  right: var(--space-3);
  z-index: var(--z-float);
  background: var(--menu-bg);
  border-color: var(--border);
  box-shadow: var(--shadow-sm);
}

#content-tab-area .content-refresh-overlay:hover { background: var(--menu-bg); }

/* The Edit source / Preview toggle of a .md/.html tab and the "Open in
   Browser" button of an .html one: secondary buttons next to the
   primary Save. */
#content-tab-area .content-mode-btn,
#content-tab-area .content-browser-btn {
  flex: 0 0 auto;
  padding: var(--space-0-5) var(--space-3);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-md);
  background: var(--surface2);
  color: var(--fg);
  font-size: var(--fs-md);
  font-weight: 500;
  cursor: pointer;
  transition: background var(--dur-base), border-color var(--dur-base);
}

#content-tab-area .content-mode-btn:hover,
#content-tab-area .content-browser-btn:hover { background: var(--hover); border-color: var(--border-hover); }

#content-tab-area .content-mode-btn:focus-visible,
#content-tab-area .content-browser-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: 1px;
}

/* The bar of an .html tab holds one button more than a phone is wide,
   that of a Markdown tab holds more at a large text size: there its
   items take a second row instead of leaving the pane, which clips
   them.  The path takes what its row leaves it and never causes the
   wrap. */
#content-tab-area .content-save-bar:has(.content-mode-btn, .content-browser-btn) {
  flex-wrap: wrap;
  justify-content: flex-end;
  row-gap: var(--space-1);
}

#content-tab-area .content-save-bar:has(.content-mode-btn, .content-browser-btn) .content-save-path { flex-basis: 0; }

/* The File / Edit / Selection / View / Go menus of a content tab's
   Monaco editor: a row of its own directly above the editor. */
#content-tab-area .content-menubar {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: var(--space-0-5);
  padding: var(--space-0-5) var(--space-1-5);
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
}

#content-tab-area .content-menu-btn {
  flex: 0 0 auto;
  padding: var(--space-0-5) var(--space-2);
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--icon);
  font: inherit;
  font-size: var(--fs-md);
  cursor: pointer;
  transition: background var(--dur-base), color var(--dur-base);
}

#content-tab-area .content-menu-btn:hover,
#content-tab-area .content-menu-btn.open {
  background: var(--hover-strong);
  color: var(--fg);
}

#content-tab-area .content-menu-btn:focus-visible {
  outline: 1px solid var(--accent);
  outline-offset: -1px;
}

.content-menu-dropdown {
  position: fixed;
  z-index: var(--z-editor-menu);
  min-width: 220px;
  padding: var(--space-1);
  overflow-y: auto;
  background: var(--menu-bg);
  color: var(--icon);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  font-size: var(--fs-base);
  user-select: none;
}

.content-menu-item {
  display: flex;
  outline: none;
  align-items: center;
  padding: var(--space-1) var(--space-3) var(--space-1) var(--space-1);
  border-radius: var(--radius-md);
  white-space: nowrap;
  cursor: pointer;
}

.content-menu-item:hover,
.content-menu-item:focus {
  background: var(--hover);
  color: var(--fg);
}

.content-menu-item.disabled {
  opacity: 0.4;
  cursor: default;
  pointer-events: none;
}

.content-menu-check {
  flex: 0 0 20px;
  text-align: center;
}

.content-menu-label {
  flex: 1 1 auto;
}

.content-menu-key {
  flex: 0 0 auto;
  padding-left: var(--space-6);
  color: var(--faint);
}

.content-menu-sep {
  height: 1px;
  margin: var(--space-1) 0;
  background: var(--border);
}

.chat-tab .content-tab-icon {
  margin-right: var(--space-1);
  font-size: var(--fs-sm);
  line-height: 1;
}

/* The Projects tab's icon is a drawing, not a character. */
.chat-tab .content-tab-icon svg { display: block; }

/* The Projects page (media/projects.js), a tab of the content pane: a
   scrolling column, a "New project" button over one settings panel
   per project.  A panel is set as the Settings dialog is (the same
   .config-* rows), in a card of its own with a big pin button in its
   top right corner. */
#content-tab-area .projects-tab-view {
  display: block;
  overflow-y: auto;
  background: var(--bg);
}

.projects-page-inner {
  max-width: 720px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-8);
}

.projects-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  margin-bottom: var(--space-2);
}

.projects-title { margin: 0; font-size: var(--fs-xl); font-weight: 600; color: var(--fg); }

.projects-intro,
.projects-empty { margin: 0 0 var(--space-4); font-size: var(--fs-md); color: var(--dim); }

.project-panel {
  position: relative;
  margin-bottom: var(--space-4);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
}

/* The pin, as on a project's page in Claude Code Desktop: a ghost icon
   button (28px with an 8px corner, no border and no fill until the
   pointer is over it) holding a 20px pushpin in the text's colour, an
   outline while the project is not pinned in the sidebar and solid
   while it is.  The fill comes within 60ms and is laid on twice while
   the button is held down. */
.project-pin-btn {
  position: absolute; top: var(--space-3); right: var(--space-3);
  display: flex; align-items: center; justify-content: center;
  width: 28px; height: 28px; padding: 0;
  background: transparent; border: none; border-radius: var(--radius-lg);
  color: var(--fg); cursor: pointer;
  transition: background-color 60ms ease-out;
}

.project-pin-btn:hover { background-color: var(--hover); }

.project-pin-btn:active { background-image: linear-gradient(var(--hover), var(--hover)); }

.project-pin-btn[aria-pressed="false"] .project-pin-solid,
.project-pin-btn[aria-pressed="true"] .project-pin-outline { display: none; }

/* A finger gets the 36px target of the app's other icon buttons; the
   drawing keeps its size. */
body.remote-mobile .project-pin-btn::after { content: ''; position: absolute; inset: -4px; }

/* The first row, the project's name, leaves the corner to the pin. */
.project-pin-btn + .config-label { margin-right: calc(28px + var(--space-3)); }

/* The folder drop-down and "New folder" share a line. */
.project-workdir-row { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-1); }

.project-workdir-row > select { flex: 1 1 auto; min-width: 0; margin-top: 0; }

.project-error { margin: var(--space-2) 0; font-size: var(--fs-md); color: var(--error); }

.project-confirm {
  display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2);
  margin: var(--space-2) 0;
  font-size: var(--fs-md); color: var(--fg);
}

/* Delete at the left end, Cancel and Save (the primary button) at the
   right. */
.project-actions { display: flex; align-items: center; gap: var(--space-2); margin-top: var(--space-3); }

.project-actions-gap { flex: 1 1 auto; }

/* Flex boxes, which the `hidden` attribute alone would not hide. */
.project-confirm[hidden],
.project-delete[hidden] { display: none; }

.project-delete,
.project-delete-yes { color: var(--error); }

.project-actions .project-save { border-color: transparent; background: var(--primary-bg); color: var(--primary-fg); }

.project-actions .project-save:hover:not(:disabled) { border-color: transparent; background: var(--primary-hover-bg); }

/* Unsaved edits: VS Code's filled dot next to the file name. */
.chat-tab .chat-tab-dirty {
  flex-shrink: 0;
  font-size: var(--fs-sm);
  line-height: 1;
  color: var(--fg);
}
