/*
 * remote-codex.css — layout restyle of the REMOTE webapp (phone
 * drawers, docked desktop panels, touch-sized controls).  Loaded
 * exclusively by the standalone remote page built by
 * ``web_server._build_html()``.
 *
 * Colours: the page uses ONLY the palette of Claude Code Desktop's
 * dark and light looks.  web_server.py inlines them as ``--theme-*``
 * variables (dark on ``:root``, light on
 * ``body.remote-chat.light-theme``), and the single palette block
 * below maps every semantic name this file and main.css use onto
 * those variables.  main.css derives the same semantic names at
 * ``:root``, where a body-level light override is invisible, which is
 * why they are re-derived here on ``body``: a declaration such as
 * ``--fg: var(--theme-editor-foreground)`` resolves on the body, after
 * the light theme has swapped the ``--theme-*`` value, so one block
 * serves both themes.  The fallbacks are the dark palette's values, for
 * a page that lacks the injected variables.  The theme is toggled by the
 * sun/moon item in the "..." menu (see ``applyRemoteTheme`` in main.js)
 * and persisted in localStorage.
 */

body.remote-chat {
  /* main.css :root names, re-derived (see the header comment). */
  --bg: var(--theme-editor-background, #0b0b0b);
  --bg2: var(--theme-sideBar-background, #151515);
  --surface: var(--theme-sideBar-background, #151515);
  --surface2: var(--theme-input-background, #1f1f1f);
  --menu-bg: var(--theme-editorWidget-background, #1f1f1f);
  --code-bg: var(--theme-textCodeBlock-background, #151515);
  --code-inline-fg: var(--theme-textPreformat-foreground, #fa8080);
  --fg-strong: var(--theme-tab-activeForeground, #fff);
  --fg: var(--theme-editor-foreground, #f0efec);
  --dim: var(--theme-tab-inactiveForeground, #9c9a92);
  --faint: var(--theme-input-placeholderForeground, #898781);
  --icon: var(--theme-icon-foreground, #c3c2b7);
  --accent: var(--theme-textLink-foreground, #4d9fff);
  --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);
  --primary-bg: var(--theme-button-background, #efefef);
  --primary-fg: var(--theme-button-foreground, #0b0b0b);
  --primary-hover-bg: var(--theme-button-hoverBackground, #d7d7d7);
  --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);

  /* Names used only by this file. */
  --chip-bg: var(--theme-input-background, #1f1f1f);
  --chip-border: var(--theme-input-border, #ffffff26);
  --border-widget: var(--theme-widget-border, #ffffff1a);
  --link: var(--theme-textLink-foreground, #4d9fff);
  --link-active: var(--theme-textLink-activeForeground, #6aabf1);
  --tabs-bg: var(--theme-editorGroupHeader-tabsBackground, #0b0b0b);
  --tab-active-line: var(--theme-tab-activeBorderTop, #ffffff26);
  --send-bg: var(--primary-bg);
  --send-fg: var(--primary-fg);
  --send-hover-bg: var(--primary-hover-bg);
  --send-disabled-bg: color-mix(in srgb, var(--send-bg) 40%, transparent);

  /* main.css design tokens whose value depends on the theme: a token
     derived at :root keeps the dark value, so it is re-derived here. */
  --shadow-color: var(--theme-widget-shadow, #00000073);
  --shadow-sm:
    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);
  --shadow-lg: 0 12px 40px var(--shadow-color);
  --attention-ring: var(--shadow-color);

  /* main.css's semantic status colours (history row icons, filter
     chips, the update button, copy / favourite states), panel chrome
     tints and running text, re-derived so the light theme's --fg /
     --green / --red overrides on body.remote-chat.light-theme flow
     through.  Every main.css rule that uses them re-themes with no
     override. */
  --status-ok: var(--green);
  --status-fail: var(--red);
  --favorite: var(--yellow);
  --panel-tint: color-mix(in srgb, var(--fg) 4%, transparent);
  --panel-line: color-mix(in srgb, var(--fg) 10%, transparent);
  --bubble-user-tint: color-mix(in srgb, var(--fg) 7%, transparent);
  --running-fg: color-mix(in srgb, var(--brand-clay) 70%, var(--fg));
  --scrollbar-thumb: color-mix(in srgb, var(--fg) 20%, transparent);
  --scrollbar-thumb-hover: color-mix(in srgb, var(--fg) 45%, transparent);

  /* The settings dialog's outline (main.css #settings-panel): the
     theme's widget border, the hairline of every floating surface. */
  --settings-border: var(--border-widget);

  /*
   * Docked task-history panel geometry (desktop mode only).  The
   * resize floor (--sidebar-min-w) is deliberately tiny — 10px — so a
   * drag can collapse the panel to a sliver when the user wants the
   * chat to take (almost) the whole window; the panel's own
   * overflow:hidden clips the content at any width.  The DEFAULT
   * width is exactly one fifth of the browser window
   * (sidebarDefaultW() in main.js computes the same fraction for the
   * resizer's double-click reset and ARIA seeding).
   */
  --sidebar-min-w: 10px;
  --sidebar-default-w: 20vw;

  /* The docked task-info panel on the RIGHT of the chat mirrors the
     history panel's one-fifth share of the window.  Like the history
     panel it is resizable: --meta-w, set by the #meta-resizer drag
     logic in main.js, overrides this default, and shares the
     --sidebar-min-w collapse floor. */
  --meta-panel-w: 20vw;

  /* Chat width the docked panel may never eat into, so a panel widened
     on a big monitor cannot crush the chat on a smaller window. */
  --chat-min-w: 360px;

  /*
   * Settings drawer width on desktop — wide enough for the Tips,
   * Update, Reset Server, and Update Models actions to stay on one
   * line across font metrics, while remaining a narrow drawer instead
   * of the 90vw mobile sheet.
   */
  --settings-panel-w: 620px;

  background: var(--bg);
  color: var(--fg);
}

/* High contrast (the "..." menu's High contrast item, body.high-contrast):
   web_server.py swaps the --theme-* palette for its full-contrast
   variant; here the translucent tints that would wash out on it become
   solid lines and full-strength text (borders instead of shading). */
body.remote-chat.high-contrast {
  --panel-line: var(--border);
  --border-hover: var(--fg);
  --scrollbar-thumb: var(--theme-scrollbarSlider-background);
  --scrollbar-thumb-hover: var(--fg);
}

body.remote-chat.high-contrast .more-menu-item,
body.remote-chat.high-contrast .more-menu-item:hover:not(:disabled) {
  color: var(--fg);
}

/* The tab rows, as Claude Code Desktop draws its pane tabs: no band
   and no outlines, dim labels, and the active tab a quiet filled chip
   with a hairline (--tab-active-line; the high-contrast palettes make
   it a solid accent line).  #content-tab-bar is the content pane's row
   (desktop split layout, below); the group strip (#tab-bar: the chat
   on screen and its sub-agents) has smaller chip text; both rows keep
   main.css's bottom hairline. */
body.remote-chat #content-tab-bar {
  background: var(--tabs-bg);
  padding: var(--space-2) var(--space-2-5) var(--space-1);
}

body.remote-chat #tab-bar {
  padding: var(--space-1) var(--space-2-5) var(--space-1) var(--space-5);
}

body.remote-chat #content-tab-list,
body.remote-chat #tab-list { gap: var(--space-1-5); }

body.remote-chat #content-tab-bar .chat-tab,
body.remote-chat #tab-bar .chat-tab {
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2-5);
  background: transparent;
  color: var(--dim);
  transition: background var(--dur-base), color var(--dur-base);
}

body.remote-chat #tab-bar .chat-tab { padding: var(--space-0-5) var(--space-2); }

body.remote-chat #content-tab-bar .chat-tab:hover,
body.remote-chat #tab-bar .chat-tab:hover {
  background: var(--hover);
  color: var(--fg);
}

body.remote-chat #content-tab-bar .chat-tab.active,
body.remote-chat #tab-bar .chat-tab.active {
  background: var(--selected);
  border-color: var(--tab-active-line);
  color: var(--fg-strong);
}

body.remote-chat #content-tab-bar .chat-tab-close,
body.remote-chat #tab-bar .chat-tab-close { border-radius: var(--radius-sm); }

/* The hide button at the right end of the content pane's row: a
   chevron pointing at the edge the pane folds into.  The row's tab
   list scrolls (main.css), so the button keeps its place however many
   tabs are open. */
body.remote-chat #content-pane-hide {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  margin: 0 0 0 var(--space-2);
  padding: 0;
  border: none;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--dim);
  font-size: var(--fs-md);
  cursor: pointer;
}

body.remote-chat #content-pane-hide:hover,
body.remote-chat #content-pane-hide:focus-visible {
  background: var(--hover);
  color: var(--fg);
  outline: none;
}

/* The content pane with nothing open (split layout). */
body.remote-chat #content-pane-empty {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  padding: var(--space-5);
  text-align: center;
  color: var(--dim);
  font-size: var(--fs-sm);
}

body.remote-chat #content-pane-empty p { margin: 0; max-width: 36em; }

/* The top status bar goes on the whole remote page: the task-info
   panel — docked on desktop, the right-hand drawer on mobile — shows
   the same values (time, tokens, cost, steps, machine).  The bar's
   spans keep updating unseen; the panel mirrors them from the DOM. */
body.remote-chat #tab-status-bar {
  display: none;
}

body.remote-chat #input-drawer-btn {
  background: var(--surface2);
  border-color: var(--border-input);
}

body.remote-chat #input-drawer-btn:hover {
  color: var(--fg);
  border-color: var(--border-hover);
}

/* The button bar (#input-footer) stays visible while collapsed, so the
   bottom padding keeps its expanded value. */
body.remote-chat #input-area.drawer-collapsed {
  padding-top: var(--space-2-5);
}

body.remote-chat #input-area {
  background: var(--bg);
  border-top: none;
  padding: var(--space-1) var(--space-3) calc(var(--space-2-5) + env(safe-area-inset-bottom, 0px));
}

/* The composer, as in Claude Code Desktop: a raised box with a
   hairline, a 10px corner and a soft shadow.  Focus darkens the
   hairline instead of adding a coloured glow. */
body.remote-chat #input-container {
  background: var(--surface2);
  border: 1px solid var(--border-input);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
  padding: var(--space-2) var(--space-2) var(--space-1-5) var(--space-3);
}

body.remote-chat #input-container:focus-within {
  border-color: var(--border-hover);
}

body.remote-chat #task-input { min-height: 2.4em; }

body.remote-chat #task-input::placeholder { color: var(--faint); }

body.remote-chat #input-footer {
  padding-top: var(--space-0-5);
  margin-top: var(--space-0-5);
}

/* 36px touch targets sit side by side with a small gap so they never
   overlap; when a row cannot hold them all (narrow phones, or the
   running state's spinner + send + stop) the buttons wrap onto the
   next row instead of colliding. */
body.remote-chat #footer-tools { gap: var(--space-0-5); }

/* The buttons of the two side panels' strips (main.css
   .sidebar-tool-btn) are 32px for a mouse; a finger on a phone or
   tablet gets 36px. */
body.remote-chat.remote-mobile .sidebar-tool-btn {
  width: 36px;
  height: 36px;
}

/* The < and > buttons beside the Recommendations card (main.css
   .recommendation-step) are as wide as the panel's padding for a
   mouse; a finger gets twice that, which the card gives up. */
body.remote-chat.remote-mobile .recommendation-step { flex-basis: var(--space-8); }

/* On a phone or tablet the two strips sit a fifth as far above the
   bottom edge of the screen as main.css puts them (its 8px plus the
   bottom safe-area inset). */
body.remote-chat.remote-mobile #sidebar-footer,
body.remote-chat.remote-mobile #meta-footer {
  padding-bottom: calc((var(--space-2) + env(safe-area-inset-bottom, 0px)) / 5);
}

/* The user name of the Chats strip starts 10px further in on a phone,
   26px from the screen's edge: the strip lies along the bottom edge,
   where an iPhone's rounded corner (a 62px radius reaches 19px in at
   the height of the name's baseline when there is no bottom safe-area
   inset) cuts the first letter of a name set at the panel's 16px. */
body.remote-chat.remote-mobile #sidebar-user { padding-left: var(--space-2-5); }

body.remote-chat #menu-btn,
body.remote-chat #meta-drawer-btn,
body.remote-chat #new-chat-btn,
body.remote-chat #dictate-btn,
body.remote-chat #more-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: var(--radius-md);
  color: var(--icon);
  transition: background var(--dur-base);
}

body.remote-chat #dictate-btn.active,
body.remote-chat #voice-btn.active {
  background: var(--selected);
  color: var(--fg-strong);
}

/* After the .active rule (same specificity): hover wins on an active
   button too. */
body.remote-chat #menu-btn:hover,
body.remote-chat #meta-drawer-btn:hover,
body.remote-chat #new-chat-btn:hover,
body.remote-chat #dictate-btn:hover,
body.remote-chat #more-btn:hover {
  background: var(--hover-strong);
  color: var(--fg);
}

/* The floating surfaces: the "..." menu, the model list and the
   dialogs (password, sign-in, server reset): raised, a hairline and
   one wide soft shadow.  A menu's 10px corner is concentric with its
   rows (6px corners inside 4px of padding); a dialog's is 12px. */
body.remote-chat #more-menu,
body.remote-chat #model-dropdown,
body.remote-chat .auth-modal-content,
body.remote-chat .server-reset-confirm-content {
  background: var(--menu-bg);
  border: 1px solid var(--border-widget);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
}

body.remote-chat .auth-modal-content,
body.remote-chat .server-reset-confirm-content {
  border-radius: var(--radius-2xl);
}

body.remote-chat .more-menu-item {
  color: var(--icon);
  padding: var(--space-1-5) var(--space-2);
  border-radius: var(--radius-md);
}

body.remote-chat .more-menu-item:hover:not(:disabled) {
  background: var(--hover);
  color: var(--fg);
}

/* The model picker: a quiet text button, as under Claude Code
   Desktop's prompt box (no outline until hovered). */
body.remote-chat #model-btn {
  background: transparent;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-2);
  height: 28px;
  color: var(--fg);

  /* Cap the button (its label truncates via #model-name) so the footer
     usually keeps every button on one row even at phone widths. */
  max-width: clamp(72px, 21vw, 220px);
}

body.remote-chat #model-btn:hover {
  background: var(--hover);
  color: var(--fg-strong);
}

body.remote-chat #send-btn {
  background: var(--send-bg);
  color: var(--send-fg);
  width: 36px;
  height: 36px;
}

body.remote-chat #send-btn:hover,
body.remote-chat #stop-btn:hover {
  background: var(--send-hover-bg);
}

body.remote-chat #send-btn:disabled {
  background: var(--send-disabled-bg);
  opacity: 1;
}

body.remote-chat #stop-btn {
  width: 36px;
  height: 36px;
  background: var(--send-bg);
  color: var(--send-fg);
  border: none;
}

body.remote-chat .file-chip {
  background: var(--chip-bg);
  border: 1px solid var(--chip-border);
  border-radius: var(--radius-md);
  color: var(--fg);
}

/* A file the browser could not decode (a HEIC outside Safari) is reported
   here instead of vanishing; the selector outranks the chip rule above so
   the red wins over the normal chip colours. */
body.remote-chat .file-chip.error {
  background: color-mix(in srgb, var(--red) 12%, transparent);
  border-color: color-mix(in srgb, var(--red) 32%, transparent);
  color: var(--red);
}

body.remote-chat #sidebar,
body.remote-chat #tricks-panel {
  background: var(--surface);
  border-right: 1px solid var(--border-soft);
}

/* The settings dialog floats over the page on the raised surface. */
body.remote-chat #settings-panel {
  background: var(--menu-bg);
}

body.remote-chat .sidebar-hdr {
  color: var(--faint);
  font-size: var(--fs-md);
}

body.remote-chat .sidebar-item:hover {
  background: var(--hover);
}

/* The model list's search field and the Filter and group button
   beside the History search box share the menu rows' corner. */
body.remote-chat #model-search { border-radius: var(--radius-md); }

body.remote-chat #history-filter-btn { border-radius: var(--radius-md); }

/* Buttons share one 8px corner. */
body.remote-chat .config-update-btn {
  border-radius: var(--radius-lg);
}

body.remote-chat .auth-modal-btn,
body.remote-chat .server-reset-confirm-btn {
  border-radius: var(--radius-lg);
}

/* Link colours (main.css declares none of its own). */
body.remote-chat a {
  color: var(--link);
}

body.remote-chat a:hover {
  color: var(--link-active);
}

/* A phone narrows the composer's side inset; the autocomplete popup
   over it keeps the composer's edges.  The rows of the More menu, of
   the model list and of the Filter and group menu, and the list's
   search field, are touch targets there: 36px high, as the footer's
   buttons. */
@media (width <= 600px) {
  body.remote-chat #input-area {
    padding-left: var(--space-2);
    padding-right: var(--space-2);
  }

  body.remote-chat #autocomplete {
    margin-left: var(--space-2);
    margin-right: var(--space-2);
  }

  body.remote-chat .more-menu-item,
  body.remote-chat .model-item,
  body.remote-chat #model-search,
  body.remote-chat .fg-row,
  body.remote-chat .fg-option,
  body.remote-chat .fg-clear,
  body.remote-chat .history-filter-date-group {
    min-height: 36px;
  }
}

/* An iPhone running the page as a Home Screen web app, held upright
   (displayCorners.js sets the class and --display-radius, the radius
   of the corners of the glass).  The composer is the last thing on the
   screen, in its two bottom corners.  It keeps ONE gap to the left,
   right and bottom edge and rounds its bottom corners by the display's
   radius less that gap: the two curves then share a centre, so the gap
   is the same all the way round the bend.  The box now reaches under
   the home indicator, so what is in it ends above the bottom safe-area
   inset; the least height keeps the browser from scaling the radii
   down while only the button row shows. */
html:has(body.remote-chat).display-corners #input-area {
  --display-gap: var(--space-2);

  padding-left: var(--display-gap);
  padding-right: var(--display-gap);
  padding-bottom: var(--display-gap);
}

html:has(body.remote-chat).display-corners #input-container {
  --display-corner: calc(var(--display-radius) - var(--display-gap));

  min-height: calc(var(--display-corner) + var(--radius-xl));
  padding-bottom: max(var(--space-1-5), env(safe-area-inset-bottom, 0px) - var(--display-gap));
  border-bottom-left-radius: var(--display-corner);
  border-bottom-right-radius: var(--display-corner);
}

/* The phone's status bar.  An iPhone (iOS 26 and later) colours the
   top of its screen, around the camera, with the page's background
   and blurs what lies under it, unless an element pinned to the top
   edge of the window covers the one point it looks at (the middle of
   that edge, 4px down): then it takes that element's background-color
   and draws it solid.  A drawer and the scrim behind it cover that
   point, so opening one turned the top of the screen their colour,
   and it stayed so after they closed.  This strip always covers the
   point, above every drawer, scrim, toast and dialog: the top of the
   screen is the chat's colour in every state and never blurred.  The
   phone reads the colour from the style and wants the strip more than
   10px tall and 90% of the window wide; clipped to a text it does not
   have, the background paints nothing over the page.  The strip must
   stay rendered and opaque: nothing may give it a display, visibility,
   opacity, filter or transform, nor an ancestor that has one.  The
   server writes the body's class into the page, so the rule holds in
   the first frame. */
body.remote-chat #statusbar-tint {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 12px;
  z-index: var(--z-statusbar);
  pointer-events: none;
  background-color: var(--bg);
  /* stylelint-disable-next-line property-no-vendor-prefix */
  -webkit-background-clip: text;
  background-clip: text;
}

/* The Explorer and Source Control sections of the task-info panel: a
   row under the pointer takes the hover fill, unless it is selected or
   has its context menu open (main.css fills those as selected). */
body.remote-chat .explorer-row:not(.is-selected, .ctx-active):hover,
body.remote-chat .scm-row:not(.ctx-active):hover,
body.remote-chat .scm-commit:not(.ctx-active):hover {
  background: var(--hover);
}

body.remote-chat .scm-commit.expanded {
  background: var(--selected);
}

body.remote-chat .scm-section-hdr:hover {
  color: var(--fg);
}

body.remote-chat #sidebar-resizer {
  display: none;
}

body.remote-chat #meta-resizer {
  display: none;
}

/* Set by main.js while EITHER docked panel — history or task-info —
   is being dragged. */
body.remote-chat.sidebar-resizing {
  user-select: none;
}

/* The task-info panel's INNER content, shared by the desktop docking
   below and the mobile drawer.  The sections' collapse / scroll /
   resize layout is the generic .meta-section machinery in main.css;
   the rules here only restate the remote theme's colours and
   spacing.  The bodies scroll themselves (not #meta-panel, whose own
   scrolling would carry the resizer away). */
body.remote-chat .meta-section-resizer::after {
  border-top-color: var(--border-soft);
}

body.remote-chat .meta-section-resizer:not(.static):hover::after,
body.remote-chat .meta-section-resizer:not(.static):active::after,
body.remote-chat .meta-section-resizer:not(.static):focus-visible::after {
  /* A sash under the pointer takes the focus colour. */
  border-top-color: var(--ring-focus);
}

/* The list is a section body: it spans the panel (main.css,
   #meta-panel .meta-section-body), so its bullets' indent counts the
   panel's padding in. */
body.remote-chat #meta-list {
  list-style: disc outside;
  margin-block: 0;
  padding-left: calc(var(--meta-pad-x) + var(--space-5));
  display: flex;
  flex-direction: column;
  gap: calc(var(--space-2-5) / 2);
}

/* The rows are set like a chat's summary in the Chats sidebar
   (.history-chat-header in main.css): its size and line height at
   the regular weight, and its colour for the value; the label before
   it steps back as a label of that sidebar does. */
body.remote-chat .meta-item {
  display: list-item;
  font-size: var(--fs-base);
  line-height: 1.35;
  color: var(--fg);
  overflow-wrap: anywhere;
}

body.remote-chat .meta-item::marker {
  color: var(--faint);
}

body.remote-chat .meta-item .meta-label {
  color: var(--faint);
  margin-right: var(--space-1-5);
}

/* The Task update section below the task-info list shows the running
   task's task update (getTaskUpdate poll in main.js).  While there is
   nothing to show (no running task) main.js drops the `visible`
   class and the WHOLE section disappears, header included.  The
   report's text is set like the Task Info rows above it, and so like
   a chat's summary in the Chats sidebar. */
body.remote-chat #meta-info-content {
  font-size: var(--fs-base);
  line-height: 1.35;
  color: var(--fg);
  overflow-wrap: anywhere;
}

/* The report is Markdown (.md-body in main.css) set as the panel's
   text, not as a reply: a heading is a label over its part of the
   report, as a sidebar's header (.sidebar-hdr) is over its list; bold
   text and a table's header are the medium weight, and code is the
   label's size. */
body.remote-chat #meta-info-content :is(h1, h2, h3, h4, h5, h6) {
  font-size: var(--fs-md);
  font-weight: 500;
  color: var(--faint);
}

body.remote-chat #meta-info-content :is(strong, b, th) {
  font-weight: 500;
}

body.remote-chat #meta-info-content code {
  font-size: var(--fs-md);
}

/*
 * Mobile mode: the task-info panel is a DRAWER sliding in from the
 * RIGHT over the chat — the mirror image of the history drawer on the
 * left — toggled by #meta-drawer-btn among the composer's footer icons
 * and dismissed by its close button or the backdrop.  Desktop
 * (>= 900px) docks the panel permanently instead, so both the toggle
 * and the close button exist only here.
 */
@media (width < 900px) {
  body.remote-chat #meta-panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(85vw, 360px);
    background: var(--surface);
    border-left: 1px solid var(--border-soft);
    transform: translateX(100%);
    transition: transform var(--dur-slow) var(--ease);
    z-index: var(--z-drawer);
    padding: var(--space-4);
    overflow: hidden;
  }

  body.remote-chat #meta-panel.open {
    transform: translateX(0);
  }

  body.remote-chat #meta-close { display: block; }

  /* A phone or tablet (body.remote-mobile, set by main.js) swipes
     between the chats, the chat, the file and the task info, so the
     composer's two drawer buttons go.  A narrow mouse-only window
     keeps them: it cannot swipe. */
  body.remote-chat.remote-mobile #menu-btn,
  body.remote-chat.remote-mobile #meta-drawer-btn {
    display: none;
  }
}

/* The panel's close button: the phone drawer's dismiss, and the
   docked desktop panel's "hide" while it lies over an open content
   pane (both contexts set `display`; main.css hides it elsewhere).
   It sits over the first section's header row, which keeps its text
   clear of it.  Its box ends with that row (the panel's 16px padding
   plus the row, --meta-hdr-row from main.css) and the glyph sits on
   the row: the header after a collapsed first section lies below the
   button, clear of its taps. */
body.remote-chat #meta-close {
  position: absolute;
  top: var(--space-1);
  right: 12px;
  height: calc(var(--space-4) - var(--space-1) + var(--meta-hdr-row));
  background: none;
  border: none;
  color: var(--dim);
  font-size: var(--fs-2xl);
  line-height: 1;
  cursor: pointer;
  padding: var(--space-1-5) var(--space-2) 0;
  border-radius: var(--radius-md);
}

body.remote-chat #meta-close:hover {
  color: var(--fg);
  background: var(--hover-strong);
}

body.remote-chat:not(.remote-desktop) #meta-panel > .meta-section:first-of-type > .meta-section-hdr,
body.remote-chat.remote-desktop.content-pane-open #meta-panel > .meta-section:first-of-type > .meta-section-hdr {
  padding-right: var(--space-10);
}

/*
 * Desktop mode: the history panel is DOCKED beside the chat instead of
 * overlaying it as a drawer.  Every docked rule is scoped to
 * ``#sidebar.open`` so the burger button, which only toggles that
 * class, really shows and hides the panel: without ``.open`` the
 * panel falls back to the translated-off-screen drawer rule in
 * main.css and ``#app`` reclaims the freed width.
 */
@media (width >= 900px) {
  /* Non-mobile remote: the panel is permanently docked (main.js keeps
     it open whenever .remote-desktop is set), so the burger — which
     only toggled it — and the drawer's close button go. */
  body.remote-chat.remote-desktop #menu-btn,
  body.remote-chat.remote-desktop #meta-drawer-btn,
  body.remote-chat.remote-desktop #sidebar-close {
    display: none;
  }

  /* With the x gone the refresh row no longer keeps a strip free for
     it (main.css .sidebar-refresh-row). */
  body.remote-chat.remote-desktop .sidebar-refresh-row {
    padding-right: 0;
  }

  body.remote-chat.remote-desktop #sidebar.open {
    transform: none;
    width: var(--sidebar-w, var(--sidebar-default-w));

    /* The panel may be dragged as narrow as --sidebar-min-w (10px).
       With box-sizing:border-box the fixed 2 x 16px padding of
       main.css would force a 32px rendered floor (padding wins over
       width), overlapping the chat, so the horizontal padding
       collapses along with the panel: 16px down to a quarter of the
       panel width. */
    padding-left: min(var(--space-4), calc(var(--sidebar-w, var(--sidebar-default-w)) / 4));
    padding-right: min(var(--space-4), calc(var(--sidebar-w, var(--sidebar-default-w)) / 4));

    /* Children that span the padding (main.css --sidebar-pad-x) follow
       it however narrow the panel gets. */
    --sidebar-pad-x: min(var(--space-4), calc(var(--sidebar-w, var(--sidebar-default-w)) / 4));

    /* The chat panels in the history list run flush to the right edge,
       so the list's scrollbar sits there too: the drag handle
       (#sidebar-resizer below) goes just OUTSIDE the edge to keep the
       two apart.  main.css's overflow: hidden would clip the handle,
       so the panel's content is clipped by #sidebar-body instead. */
    overflow: visible;
  }

  /* Clips the panel's content to the panel's padding box, exactly as
     the panel's overflow: hidden did: the insets reach out over the
     panel's padding (16px top and bottom, --sidebar-pad-x at the
     sides), where the history list bleeds. */
  body.remote-chat.remote-desktop #sidebar.open #sidebar-body {
    clip-path: inset(-16px calc(-1 * var(--sidebar-pad-x)));
  }

  body.remote-chat.remote-desktop #sidebar-overlay,
  body.remote-chat.remote-desktop #meta-overlay {
    display: none;
  }

  body.remote-chat.remote-desktop #app {
    /* Matches the panel's own 0.2s slide in main.css so the chat does
       not jump ahead of it while the burger shows or hides it.  With
       no content tab open the right margin clears the docked
       task-info panel, so the chat never sits under it. */
    margin-left: 0;
    margin-right: var(--meta-w, var(--meta-panel-w));
    transition: margin-left var(--dur-slow) var(--ease);

    /* The containing block of the promptlet and working-directory
       sheets (the grid-placed rule further down).  The closed sheet is
       translated below #app, which clips it: `clip`, not `hidden`,
       because a hidden-overflow box is still a scroll container that
       the focus moving into the opening sheet would scroll, leaving
       the chat shifted up by the sheet's height. */
    position: relative;
    overflow: clip;

    /* #app is a grid.  With no file, browser or terminal tab open
       (no body.content-pane-open) it is the CHAT pane alone: the
       group strip, the machine name, the chat transcript and the
       composer in one column.  Every element keeps its place in the
       flat #app markup; the grid areas (further down) put it in its
       pane. */
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto minmax(0, 1fr) auto;
    grid-template-areas:
      'machine'
      'strip'
      'chat'
      'composer';
  }

  /* The split layout, while a content tab is open: the CHAT pane on
     the left (--chat-pane-w of the width, dragged via #pane-resizer in
     main.js, half by default) and on the right the CONTENT pane with
     its own tab row and the content area showing the open files,
     browser and terminal tabs.  #app then runs to the window's right
     edge and the docked task-info panel (position: fixed) lies ON TOP
     of the content pane; a click in the pane slides the panel away
     (body.meta-hidden, below) and the #meta-drawer tab brings it back. */
  body.remote-chat.remote-desktop.content-pane-open #app {
    margin-right: 0;

    /* Each pane keeps at least 280px, or 30% of #app when the docked
       history panel leaves less than that (two 280px minimums plus
       the handle would otherwise overflow #app near the breakpoint). */
    grid-template-columns:
      minmax(min(280px, 30%), var(--chat-pane-w, 50%))
      5px
      minmax(min(280px, 30%), 1fr);
    grid-template-areas:
      'machine  handle ctabs'
      'strip    handle content'
      'chat     handle content'
      'composer handle content';
  }

  body.remote-chat.remote-desktop:has(#sidebar.open) #app {
    margin-left: var(--sidebar-w, var(--sidebar-default-w));
  }

  /* The content pane's row, area and handle exist only while a
     content tab is open (main.js keeps body.content-pane-open in step
     with the open content tabs). */
  body.remote-chat.remote-desktop:not(.content-pane-open) #content-tab-bar,
  body.remote-chat.remote-desktop:not(.content-pane-open) #content-tab-area,
  body.remote-chat.remote-desktop:not(.content-pane-open) #pane-resizer {
    display: none;
  }

  /* The Inject promptlet and Working directory sheets, and the scrims
     behind them, stay INSIDE the chat pane instead of spanning the
     window: #app is their containing block and the grid places them
     in the `chat` column across every row, so the sheet rises from
     the composer's bottom edge and stops at the history panel, the
     content pane's handle and the docked task-info panel, which the
     scrim leaves undimmed and usable.  Their main.css insets (5% /
     90% / bottom: 0) now measure that column (#app is positioned and
     clips, see its rule above). */
  body.remote-chat.remote-desktop #tricks-panel,
  body.remote-chat.remote-desktop #tricks-overlay {
    position: absolute;
    grid-column: chat;
    grid-row: 1 / -1;
  }

  /* Hiding and showing the task-info panel over the content pane
     slides it through the window's right edge, where the drawer tab
     sits: the panel looks like it emerges from, and folds back into,
     the drawer.  The panel is a fixed-position element (its rule is
     below, with the transition), so the translation moves nothing
     else. */
  body.remote-chat.remote-desktop.content-pane-open.meta-hidden #meta-panel {
    transform: translateX(100%);
  }

  /* Over the content pane the panel shows its close button as the
     "hide" control: a wide panel may cover the whole pane, leaving no
     pane to press. */
  body.remote-chat.remote-desktop.content-pane-open #meta-close { display: block; }

  /* The two pane handles, one small rounded tab on a right edge,
     vertically centred: the drawer tab (#meta-drawer) on the window's
     edge while a content tab is open, and the unfold tab
     (#content-pane-show) on the chat's edge, against the docked
     task-info panel, once the pane was folded away by its hide button
     (body.content-pane-folded, main.js: the chat alone fills #app with
     the panel beside it, the rules above, no body.content-pane-open). */
  body.remote-chat.remote-desktop.content-pane-open #meta-drawer,
  body.remote-chat.remote-desktop.content-pane-folded #content-pane-show {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 50%;
    width: 18px;
    height: 56px;
    margin: 0;
    padding: 0;
    transform: translateY(-50%);
    border: 1px solid var(--border-soft);
    border-right: none;
    border-radius: var(--radius-md) 0 0 var(--radius-md);
    background: var(--surface);
    color: var(--dim);
    font-size: var(--fs-md);
    cursor: pointer;
    z-index: var(--z-docked);
  }

  /* The drawer tab fades in as the panel slides out over it (and back
     out as the panel returns) so that, panel open, nothing of it
     shows.  `visibility` flips with the fade (delayed on the way out)
     so the invisible tab is neither in the tab order nor in the
     accessibility tree. */
  body.remote-chat.remote-desktop.content-pane-open #meta-drawer {
    right: 0;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition:
      opacity var(--dur-slow) var(--ease),
      visibility 0s linear var(--dur-slow);
  }

  body.remote-chat.remote-desktop.content-pane-open.meta-hidden #meta-drawer {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--dur-slow) var(--ease);
  }

  /* The unfold tab is moved in by the panel's width. */
  body.remote-chat.remote-desktop.content-pane-folded #content-pane-show {
    right: var(--meta-w, var(--meta-panel-w));
  }

  /* Both handles light up alike; this rule sits after the folded
     handle's base rule (same specificity) so it wins on hover. */
  body.remote-chat.remote-desktop #meta-drawer:hover,
  body.remote-chat.remote-desktop #meta-drawer:focus-visible,
  body.remote-chat.remote-desktop #content-pane-show:hover,
  body.remote-chat.remote-desktop #content-pane-show:focus-visible {
    color: var(--fg);
    background: var(--hover);
    outline: none;
  }

  body.remote-chat.remote-desktop #settings-panel {
    width: min(90vw, var(--settings-panel-w));
  }

  /* The docked task-info panel: a permanent right-hand twin of the
     history panel that lists the live task metadata (tokens, cost,
     steps, time, machine) as bullet items.  The top status bar goes —
     the panel replaces it on desktop.  Like the history panel it may
     be dragged (via #meta-resizer on its left edge) down to the
     --sidebar-min-w sliver, so its horizontal padding collapses with
     the panel exactly like the history panel's does. */
  body.remote-chat.remote-desktop #meta-panel {
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: var(--meta-w, var(--meta-panel-w));
    background: var(--surface);
    border-left: 1px solid var(--border-soft);
    padding: var(--space-4);
    padding-left: min(var(--space-4), calc(var(--meta-w, var(--meta-panel-w)) / 4));
    padding-right: min(var(--space-4), calc(var(--meta-w, var(--meta-panel-w)) / 4));

    /* The section bodies and the bottom strip span the padding
       (main.css --meta-pad-x) and follow it however narrow the panel
       gets. */
    --meta-pad-x: min(var(--space-4), calc(var(--meta-w, var(--meta-panel-w)) / 4));

    /* The PANEL never scrolls — overflowing values scroll inside
       #meta-list, exactly like #history-list inside the history
       panel.  If the panel itself scrolled, the absolutely-positioned
       #meta-resizer would scroll away with the content and the mouse
       could no longer reach it.  `clip`, not `hidden`: a hidden
       overflow still scrolls from script and from focus (tabbing to a
       section header below a short window's edge), and a window too
       short for every section header would carry the handle away. */
    overflow: clip;
    z-index: var(--z-docked);
    transition: transform var(--dur-slow) var(--ease);
  }

  body.remote-chat.remote-desktop #sidebar.open #sidebar-resizer {
    display: block;
    position: absolute;
    top: 0;
    right: -6px;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    touch-action: none;
  }

  /* The task-info panel's drag handle mirrors the history panel's,
     riding the panel's LEFT edge (the edge facing the chat). */
  body.remote-chat.remote-desktop #meta-panel #meta-resizer {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 6px;
    cursor: col-resize;
    touch-action: none;
  }

  body.remote-chat.remote-desktop #sidebar-resizer:hover,
  body.remote-chat.remote-desktop #sidebar-resizer:active,
  body.remote-chat.remote-desktop #meta-resizer:hover,
  body.remote-chat.remote-desktop #meta-resizer:active {
    background: var(--border-widget);
  }

  /* Keyboard focus fills a handle with the focus colour, as the sash
     between two sections takes it (.meta-section-resizer above): a
     ring around a bar as tall as the panel would be cut at the
     panel's edges. */
  body.remote-chat.remote-desktop #sidebar-resizer:focus-visible,
  body.remote-chat.remote-desktop #meta-resizer:focus-visible {
    background: var(--ring-focus);
    outline: none;
  }

  /* The split layout's grid areas (see the #app rule above; the
     transcript's own, `chat`, is set next to #output in main.css) and
     the handle between its two panes. */
  body.remote-chat.remote-desktop #tab-bar { grid-area: strip; }

  /* The chat header ("machine > working directory") shares its row
     with the content pane's tab row: the strip fills the row's
     height, so its bottom hairline runs on from the tab row's across
     the handle, and the names sit at the row's vertical centre. */
  body.remote-chat.remote-desktop #chat-header {
    grid-area: machine;
    align-self: stretch;
  }

  body.remote-chat.remote-desktop #input-area {
    grid-area: composer;
    min-width: 0;
  }

  body.remote-chat.remote-desktop #content-tab-bar {
    grid-area: ctabs;
    display: flex;
    min-width: 0;
  }

  /* "New output ↓" shares the transcript's cell, pinned to its bottom
     centre (in the stacked flex column it floats over the transcript's
     bottom edge by a negative margin instead). */
  body.remote-chat.remote-desktop .new-output-btn {
    grid-area: chat;
    align-self: end;
    justify-self: center;
    margin-top: 0;
    margin-bottom: var(--space-2);
  }

  body.remote-chat.remote-desktop #content-tab-area {
    grid-area: content;
    min-width: 0;
    border-left: 1px solid var(--border);
  }

  /* The handle: a hairline that widens into a grab target on hover. */
  body.remote-chat.remote-desktop #pane-resizer {
    grid-area: handle;
    display: block;
    cursor: col-resize;
    touch-action: none;
    background: var(--border);
    transition: background var(--dur-base);
  }

  body.remote-chat.remote-desktop #pane-resizer:hover,
  body.remote-chat.remote-desktop #pane-resizer:active {
    background: var(--border-widget);
  }

  /* Keyboard focus, as on the two panel handles above. */
  body.remote-chat.remote-desktop #pane-resizer:focus-visible {
    background: var(--ring-focus);
    outline: none;
  }
}
