/* A shared, legible local date/time line for real messages, jobs and excerpts.
   Wrapping also covers split workspaces and narrow mobile viewports. */
.message__timestamp { display: flex; flex-wrap: wrap; gap: 0 .4em; margin: 0 0 9px;
  min-width: 0; color: var(--muted); font-size: .72rem; line-height: 1.5;
  font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.message__timestamp-value { min-width: 0; }
@media (max-width: 480px) { .message__timestamp { font-size: .68rem; } }

/* Conversation-specific header; no fixed version caption obscuring the active chat. */
.topbar .topbar__conversation { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; }
#active-chat-title { display: block; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: clamp(.9rem, 1.6vw, 1.05rem); }
.message__heading { display: flex; justify-content: space-between; align-items: center; min-width: 0; gap: 12px; margin-bottom: 6px; }
.message__heading .message__role { margin: 0; }
.message__actions { display: flex; gap: 6px; }
.message__copy { padding: 5px 9px; min-height: 30px; border: 1px solid var(--border); border-radius: 8px; color: var(--muted); background: var(--bg); cursor: pointer; font-size: .72rem; }
.message__copy:hover, .message__copy:focus-visible { background: var(--surface-strong); color: var(--text); }
.message-file { align-items: stretch; flex-wrap: wrap; }
.message-file__copy { flex: 1 1 180px; }
.message-file__actions { display: flex; gap: 5px; flex: 0 0 auto; flex-wrap: wrap; align-items: start; }
.message-file__actions button { white-space: nowrap; }
.message-file__preview { max-width: 100%; margin-top: 8px; }
.message-file__image { display: block; width: min(240px, 100%); max-height: 160px; object-fit: contain; object-position: left center; border-radius: 8px; }
.message-file__excerpt { width: min(400px, 100%); max-height: 88px; overflow: hidden; font-size: .72rem; white-space: pre-wrap; overflow-wrap: anywhere; margin: 4px 0; color: var(--muted); }
.attachment-preview-dialog { width: min(900px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); overflow: auto; padding: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--bg); color: var(--text); }
.attachment-preview-dialog::backdrop { background: rgba(0,0,0,.55); }
.attachment-preview-header { display: flex; gap: 12px; justify-content: space-between; align-items: center; }
.attachment-preview-header h2 { font-size: 1rem; overflow-wrap: anywhere; margin: 0; }
.attachment-preview-header button { padding: 10px; flex: 0 0 auto; }
#attachment-preview-status { font-size: .75rem; color: var(--muted); overflow-wrap: anywhere; }
.attachment-preview-content { overflow: auto; min-height: 120px; max-height: 73dvh; }
.attachment-preview-image { display: block; width: auto; max-width: 100%; max-height: 69dvh; margin: 0 auto; object-fit: contain; }
.attachment-preview-pdf { display: block; width: 100%; min-height: min(68dvh, 720px); background: white; border: 1px solid var(--border); border-radius: 7px; }
.attachment-preview-text { white-space: pre-wrap; overflow-wrap: anywhere; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .83rem; line-height: 1.55; margin: 0; padding: 12px; background: var(--surface); border-radius: 8px; }
/* Parallel scrollbar lanes: native thumb, one marker per message, existing colored highlight marks. */
.chat-scrollbar { flex-basis: 46px; }
.chat-scroll-messages { position: absolute; inset: 0 13px 0 15px; }
.chat-scroll-markers { left: 28px; }
.chat-message-marker { display: block; position: absolute; left: 1px; width: 11px; min-height: 6px; padding: 0; border: 0; border-radius: 2px; cursor: pointer; background: #7a8797; z-index: 2; opacity: .88; }
.chat-message-marker--user { background: #6399cd; }
.chat-message-marker--assistant { background: #aa92c8; }
.chat-message-marker:hover, .chat-message-marker:focus-visible { opacity: 1; width: 13px; outline: 2px solid var(--text); outline-offset: 1px; z-index: 5; }
.chat-scroll-preview { position: fixed; z-index: 65; box-sizing: border-box; width: min(540px, calc(100vw - 72px)); max-height: min(65dvh, 680px); overflow: auto; overscroll-behavior: contain; padding: 12px; background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 13px; box-shadow: 0 18px 48px rgba(0,0,0,.23); scrollbar-width: thin; }
.chat-scroll-preview-list { display: grid; gap: 12px; }
.chat-scroll-preview__message { border-left: 3px solid var(--border); padding: 7px 10px; background: var(--surface); border-radius: 5px; }
.chat-scroll-preview__message.is-current { border-color: #6399cd; background: var(--surface-strong); }
.chat-scroll-preview__message strong { display: block; font-size: .75rem; margin-bottom: 6px; }
.chat-scroll-preview__message p { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; line-height: 1.55; font-size: .83rem; }
.chat-scroll-preview__message small { display: block; margin-top: 8px; color: var(--muted); overflow-wrap: anywhere; }
@media (max-width: 820px) {
  .topbar .topbar__conversation { display: flex !important; }
  .chat-scrollbar { flex-basis: 42px; }
  .chat-scroll-preview { width: min(460px, calc(100vw - 74px)); max-height: 56dvh; padding: 9px; }
}
@media (max-width: 520px) {
  .topbar .topbar__conversation { display: flex !important; }
  .topbar { gap: 5px; }
  #active-chat-title { font-size: .85rem; }
  .message-file__actions { flex: 1 1 100%; }
  .message-file__actions button { flex: 1 1 auto; min-height: 40px; }
  .message__copy { min-height: 38px; }
  .chat-scroll-preview { max-height: 50dvh; }
  .attachment-preview-dialog { padding: 12px; }
  .attachment-preview-header { align-items: flex-start; }
}
@media (prefers-reduced-motion: reduce) {
  .chat-scroll-preview { scroll-behavior: auto; }
}

/* Navigation research panel: independent marker filters, never hides chat content. */
.chat-navigation-toolbar { margin-inline-start: auto; display: flex; align-items: center; gap: 5px; min-width: 0; }
.highlight-tools .chat-navigation-toolbar button { color: var(--text); min-width: 32px; }
.chat-navigation-count { color: var(--muted); font-size: .72rem; white-space: nowrap; font-variant-numeric: tabular-nums; }
.chat-navigation-menu-wrap { position: relative; }
.chat-navigation-filters {
  position: absolute; z-index: 55; inset-block-start: calc(100% + 8px); inset-inline-end: 0;
  box-sizing: border-box; width: min(365px, calc(100vw - 26px)); max-height: min(70dvh, 570px);
  overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
  background: var(--bg); border: 1px solid var(--border); color: var(--text);
  border-radius: 12px; padding: 14px; box-shadow: 0 16px 35px rgba(0,0,0,.22);
  font-size: .84rem; line-height: 1.4;
}
.chat-navigation-filters[hidden] { display: none; }
.chat-navigation-filters h2 { font-size: 1rem; margin: 0 0 10px; }
.chat-navigation-filters .chat-navigation-search-label { display: block; margin-block-end: 5px; font-weight: 600; }
#chat-navigation-search {
  width: 100%; box-sizing: border-box; font: inherit; padding: 9px; min-height: 40px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 7px; color: var(--text);
}
.chat-navigation-filters fieldset { border: 0; padding: 10px 0 0; margin: 10px 0 0; display: grid; gap: 9px; }
.chat-navigation-filters fieldset:disabled { opacity: .5; }
.chat-navigation-filters legend { font-weight: 700; padding: 0; }
.chat-navigation-filters fieldset label { display: flex; align-items: center; gap: 9px; cursor: pointer; min-height: 27px; }
.chat-navigation-filters fieldset input { accent-color: var(--accent); width: 17px; height: 17px; margin: 0; flex: none; }
.chat-navigation-hint { color: var(--muted); font-size: .76rem; margin-block: 13px; }
.highlight-tools .chat-navigation-filters button { color: var(--text); }
.chat-navigation-filters input:focus-visible, .chat-navigation-filters button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 700px) {
  .chat-navigation-toolbar { flex-wrap: wrap; justify-content: flex-end; }
  .chat-navigation-count { flex: 0 0 auto; font-size: .68rem; }
}
@media (max-width: 520px) {
  .chat-navigation-toolbar { width: 100%; }
  .chat-navigation-menu-wrap { margin-inline-start: auto; }
  .chat-navigation-filters { max-height: min(60dvh, 520px); }
  .highlight-tools .chat-navigation-toolbar button { min-height: 40px; min-width: 40px; }
}
@media (forced-colors: active) {
  .chat-navigation-filters { border: 2px solid CanvasText; }
}
.chat-navigation-presets { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; margin-block: 10px 4px; }
.highlight-tools .chat-navigation-presets button { padding: 7px 3px; white-space: normal; min-height: 40px; font-size: .72rem; }
.highlight-tools .chat-navigation-presets button[aria-pressed="true"] { border-color: var(--accent); background: var(--surface-strong); font-weight: 700; }
@media (max-width: 330px) { .chat-navigation-presets { grid-template-columns: repeat(2, minmax(0,1fr)); } }


/* Local highlight draft: custom drag, viewport-clipped overlay, accessible resize handles. */
.highlight-resize-hint { color: var(--muted); font-size: .72rem; flex: 1 1 210px; }
.highlight-resize-hint[hidden] { display: none; }
/* Fixed coordinates are set from the chat reader, NOT the browser window. */
.selection-draft-overlay { position: fixed; z-index: 32; pointer-events: none; overflow: hidden; contain: layout paint; }
.messages.is-highlight-selecting .message__content[data-message-id] { user-select: none; -webkit-user-select: none; }
.messages.is-highlight-selecting { cursor: text; }
.selection-draft-overlay[hidden] { display: none; }
.selection-draft-rectangle { position: absolute; background: rgba(58, 120, 238, .22); outline: 1px solid rgba(39, 102, 235, .48); border-radius: 2px; pointer-events: none; }
.selection-draft-handle { position: absolute; width: 26px; height: 28px; margin: -14px 0 0 -13px; padding: 0; border: none;
  border-radius: 11px; background: transparent; pointer-events: auto; cursor: ew-resize; touch-action: none; }
.selection-draft-handle::before { content: ''; position: absolute; inset: 4px 6px; border-radius: 9px; border: 2px solid white;
  background: #225fd7; box-shadow: 0 0 0 2px #225fd7, 0 3px 8px rgba(0,0,0,.26); }
.selection-draft-handle--start::after, .selection-draft-handle--end::after { content: ''; position: absolute; background: #225fd7; width: 2px; height: 12px; left: 12px; }
.selection-draft-handle--start::after { top: 16px; } .selection-draft-handle--end::after { bottom: 16px; }
.selection-draft-handle:hover::before, .selection-draft-handle.is-dragging::before { background: #09409d; transform: scale(1.18); }
.selection-draft-handle[hidden] { display: none; }
.selection-draft-handle:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
@media (pointer: coarse) { .selection-draft-handle { width: 42px; height: 42px; margin: -21px 0 0 -21px; } .selection-draft-handle::before { inset: 9px 13px; } .selection-draft-handle--start::after, .selection-draft-handle--end::after { left: 20px; } }
@media (forced-colors: active) { .selection-draft-rectangle { background: Highlight; opacity: .5; } .selection-draft-handle::before { background: Highlight; border-color: CanvasText; } }

/* Direct visual editing and recovery (never replaces stored/API source messages). */
.message__edited { align-self: center; font-size: .7rem; font-weight: 600; line-height: 1.5; color: var(--muted); background: var(--surface-strong); border-radius: 6px; padding: 2px 7px; }
.message__edited[hidden] { display: none; }
.message__menu-wrap { position: relative; }
.message__menu-trigger { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; min-width: 30px;
  border: 1px solid var(--border); background: var(--bg); color: var(--muted); border-radius: 8px; font-size: 1.15rem; line-height: 1; cursor: pointer; }
.message__menu-trigger:hover, .message__menu-trigger:focus-visible { background: var(--surface-strong); color: var(--text); }
.message__menu { position: absolute; z-index: 25; top: calc(100% + 5px); right: 0; width: max-content; min-width: 180px;
  max-width: min(280px, calc(100vw - 40px)); display: grid; gap: 3px; border: 1px solid var(--border); border-radius: 11px;
  padding: 6px; box-shadow: 0 10px 28px rgba(0,0,0,.20); background: var(--bg); }
.message__menu[hidden], .message__menu button[hidden] { display: none; }
.message__menu button { text-align: start; color: var(--text); border: 0; background: transparent; padding: 10px; border-radius: 6px;
  font: inherit; font-size: .82rem; white-space: normal; cursor: pointer; }
.message__menu button:hover, .message__menu button:focus-visible { background: var(--surface-strong); }
.message-edit-dialog { width: min(780px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); overflow-y: auto;
  border: 1px solid var(--border); border-radius: 14px; padding: 18px; color: var(--text); background: var(--bg); }
.message-edit-dialog::backdrop { background: rgba(0,0,0,.55); }
.message-edit-form { display: grid; gap: 12px; }
.message-edit-form h2 { font-size: 1.1rem; margin: 0; }
.message-edit-form p { font-size: .81rem; color: var(--muted); margin: 0; }
.message-edit-form textarea { box-sizing: border-box; display: block; width: 100%; min-height: min(44dvh, 340px); max-height: 60dvh;
  resize: vertical; background: var(--surface); color: var(--text); font: inherit; line-height: 1.6;
  border: 1px solid var(--border); border-radius: 9px; padding: 12px; }
.message-edit-dialog__actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; }
.message-edit-dialog__actions button { min-height: 40px; padding: 8px 14px; }
.message-edit-dialog button:focus-visible, .message-edit-dialog textarea:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
@media (max-width: 520px) { .message__actions { gap: 4px; } .message__menu-trigger { min-width: 40px; min-height: 40px; } .message-edit-dialog { padding: 12px; } }
@media (prefers-reduced-motion: reduce) { .selection-draft-handle::before { transition: none; } }

/* v15: Selection never rises above conversation menus (z=40), sidebar (z=30), or sticky header (z=20). */
.selection-draft-overlay { z-index: 18; }

/* Minimal but identifiable authorship even when the message header is offscreen. */
.message--user .message__content { border-inline-start: 2px solid #6b9bbf; padding-inline-start: 12px; }
.message--assistant .message__content { border-inline-start: 2px solid #9b8ab6; padding-inline-start: 12px; }
.message--user .message__inline-editor { --editor-accent: #6b9bbf; }
.message--assistant .message__inline-editor { --editor-accent: #9b8ab6; }
.message__body { min-width: 0; }
.message__edited { white-space: nowrap; }

/* Direct editing preserves the text block's measured height, width, authorship
   stripe, line spacing and whitespace. Only the save/cancel row adds space. */
.message__content[tabindex="0"] { touch-action: manipulation; }
.message__content[tabindex="0"]:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 3px; }
.message__content--empty { min-height: 2.6em; cursor: text; }
.message__content--empty::before { content: attr(data-empty-label); color: var(--muted); font-style: italic; }
.message__inline-editor { width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 7px;
  margin: 0; padding: 0; border: 0; background: transparent; color: var(--text); }
.message__inline-editor textarea {
  display: block; width: 100%; max-width: 100%; flex: 0 0 auto; min-height: 40px;
  resize: vertical; overflow-y: auto; border: 1px solid var(--border);
  border-inline-start: 2px solid var(--editor-accent); border-radius: 0 8px 8px 0;
  padding: 0 10px; padding-inline-start: 12px; background: var(--bg); color: var(--text);
  font: inherit; font-size: .98rem; line-height: 1.7; white-space: pre-wrap; overflow-wrap: anywhere;
}
.message__inline-hint { margin: 0; font-size: .75rem; line-height: 1.45; color: var(--muted); }
.message__inline-actions { display: flex; gap: 8px; justify-content: flex-end; align-items: center;
  flex: 0 0 auto; position: sticky; bottom: 0; padding: 5px 0;
  background: var(--bg); }
.message__inline-actions button { border-radius: 8px; min-height: 40px; padding: 8px 16px;
  border: 1px solid var(--border); cursor: pointer; background: var(--bg); color: var(--text); }
.message__inline-actions .message__inline-save { background: var(--accent); color: var(--accent-contrast);
  border-color: var(--accent); font-weight: 650; }
.message__inline-actions button:disabled { opacity: .55; cursor: wait; }
.message__inline-status { font-size: .78rem; line-height: 1.4; color: var(--danger); margin: 0; }
.message__inline-status.is-saving { color: var(--muted); }
.message__edited[data-unsynced="true"] { border: 1px dashed var(--border); }
.message__inline-editor textarea:focus-visible, .message__inline-editor button:focus-visible,
.message__history button:focus-visible, .message__history summary:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px; }

/* A bounded inline revision queue; opening a snapshot never edits source text. */
.message__history { min-width: 0; max-width: 100%; margin-top: 10px; padding: 12px;
  border: 1px solid var(--border); border-radius: 9px; background: var(--surface); }
.message__history h3 { font-size: .9rem; margin: 0 0 6px; }
.message__history-info, .message__history-status { font-size: .75rem; line-height: 1.5; color: var(--muted); margin: 0 0 7px; }
.message__history-status.is-error { color: var(--danger); }
.message__history-list { display: grid; gap: 7px; padding-inline-start: 1.5em; margin: 8px 0; }
.message__history-list li { min-width: 0; overflow-wrap: anywhere; border-top: 1px solid var(--border); padding-top: 7px; }
.message__history-caption { display: flex; flex-wrap: wrap; gap: 3px 9px; font-size: .75rem; }
.message__history-caption time, .message__history-caption span { color: var(--muted); }
.message__history details { max-width: 100%; font-size: .75rem; margin: 7px 0; }
.message__history summary { cursor: pointer; }
.message__history pre { max-width: 100%; max-height: min(38dvh, 300px); overflow: auto;
  white-space: pre-wrap; overflow-wrap: anywhere; font: inherit; line-height: 1.6;
  padding: 9px; background: var(--bg); border: 1px solid var(--border); border-radius: 7px; }
.message__history button { min-height: 38px; padding: 6px 10px; border: 1px solid var(--border);
  border-radius: 7px; background: var(--bg); color: var(--text); font-size: .75rem; cursor: pointer; }
.message__history button:disabled { opacity: .55; cursor: wait; }
.message__history-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 7px; }
@media (max-width: 520px) {
  .message--user .message__content, .message--assistant .message__content { padding-inline-start: 9px; }
  .message__inline-editor textarea { padding-inline-start: 9px; }
  .message__inline-actions button, .message__history button { min-height: 44px; }
  .message__history { padding: 9px; }
}
@media (forced-colors: active) {
  .message--user .message__content, .message--assistant .message__content { border-inline-start-color: Highlight; }
  .message__inline-editor textarea { border-inline-start-color: Highlight; }
  .message__inline-actions .message__inline-save { border: 2px solid Highlight; }
}

/* Compact research toolbar: a single line on desktop, with a bounded overflow menu. */
.highlight-tools { min-width: 0; flex-wrap: nowrap; gap: 6px; min-height: 42px; }
.highlight-tools > select { min-width: 110px; max-width: 150px; text-overflow: ellipsis; }
.highlight-tools > .highlight-inline-status:empty { display: none; }
.highlight-tools .highlight-resize-hint { display: none; }
.highlight-tools .chat-navigation-toolbar { flex-wrap: nowrap; }
.chat-navigation-panel-actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; margin-top: 12px; }
.chat-navigation-panel-actions button { flex: 1 1 auto; }
.chat-navigation-filters { width: min(355px, calc(100vw - 36px)); }
.chat-navigation-filters fieldset { grid-template-columns: 1fr 1fr; }
.chat-navigation-filters fieldset legend { grid-column: 1/-1; }
.chat-navigation-filters fieldset label { min-width: 0; }
.chat-navigation-filters fieldset label span { overflow-wrap: anywhere; }
.chat-navigation-presets { grid-template-columns: repeat(2, minmax(0,1fr)); }
.highlight-tools .chat-navigation-count { font-size: .69rem; }
@media(max-width: 640px) {
  .highlight-tools { flex-wrap: wrap; }
  .highlight-tools .chat-navigation-toolbar { flex: 1 1 auto; justify-content: flex-end; }
}

.chat-navigation-filters input[type="search"] { width: 100%; box-sizing: border-box; font: inherit; padding: 9px;
  min-height: 38px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 7px; color: var(--text); }
.highlight-tools [hidden], .performance-estimate[hidden] { display: none !important; }

/* v22: selection actions are contextual; the shared reader toolbar stays for navigation. */
.highlight-tools > select[id$="highlight-color"],
.highlight-tools > button[id$="highlight-selection"] { display: none !important; }
.selection-draft-rectangle { pointer-events: auto; cursor: context-menu; }
.selection-actions-menu { position: fixed; z-index: 65; box-sizing: border-box; width: 235px; max-width: calc(100vw - 16px);
  padding: 9px; display: grid; gap: 5px; color: var(--text); background: var(--bg); border: 1px solid var(--border);
  box-shadow: 0 12px 34px rgba(0,0,0,.24); border-radius: 12px; font-size: .81rem; }
.selection-actions-menu[hidden], .selection-actions-menu > [hidden] { display: none !important; }
.selection-actions-menu strong { font-size: .76rem; padding: 5px 7px; }
.selection-actions-menu button, .selection-actions-menu select { font: inherit; width: 100%; padding: 9px; text-align: start;
  border-radius: 7px; border: 1px solid var(--border); color: var(--text); background: var(--surface); cursor: pointer; }
.selection-actions-menu button:hover, .selection-actions-menu button:focus-visible { background: var(--surface-strong); outline-color: var(--accent); }
.selection-actions-menu button:disabled { opacity: .6; cursor: progress; }
.selection-draft-more { position: absolute; width: 32px; height: 32px; padding: 0; border-radius: 9px;
  border: 1px solid #4172c2; background: #225fd7; color: white; font-size: 1.25rem;
  box-shadow: 0 2px 9px rgba(0,0,0,.18); pointer-events: auto; cursor: context-menu; }
.selection-draft-more[hidden] { display:none !important; }
.selection-draft-more:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Only the original pane exposes reply actions. Keep them reachable in split
   views, on touch screens and in forced-colors mode. */
.message--failed .message__heading, .message--pending .message__heading { flex-wrap: wrap; }
.message--failed .message__actions, .message--pending .message__actions { min-width: 0; max-width: 100%; flex-wrap: wrap; }
.message__retry, .message__cancel { min-height: 38px; max-width: 100%; padding: 7px 11px; border: 1px solid var(--border);
  border-radius: 8px; background: var(--surface); color: var(--text); font-size: .78rem;
  font-weight: 600; text-align: center; white-space: normal; overflow-wrap: anywhere; cursor: pointer; }
.message__retry:hover:not(:disabled), .message__cancel:hover:not(:disabled) { background: var(--surface-strong); }
.message__retry:focus-visible, .message__cancel:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.message__retry:disabled, .message__cancel:disabled { opacity: .55; cursor: wait; }
.message__retry-hint, .message__retry-feedback, .message__cancel-hint, .message__cancel-feedback { max-width: 100%; margin: 7px 0 0;
  font-size: .72rem; line-height: 1.45; overflow-wrap: anywhere; }
.message__retry-hint, .message__cancel-hint { color: var(--muted); }
.message__retry-feedback, .message__cancel-feedback { color: var(--danger); }
@media (max-width: 520px) {
  .message--failed .message__actions, .message--pending .message__actions { width: 100%; }
  .message__retry, .message__cancel { min-height: 44px; }
}
@media (forced-colors: active) { .message__retry, .message__cancel { border-color: ButtonText; } }

/* The full-width navigation belongs to each workspace. Only the source owns
   the request editor; a working-pane action returns to its original chat. */
.chat-bottom-nav { flex: 0 0 auto; width: 100%; min-width: 0; display: flex; align-items: center; gap: 6px;
  padding: 6px 12px max(6px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); background: var(--bg); }
.chat-bottom-nav button { display: inline-flex; align-items: center; justify-content: center; gap: 5px; min-height: 40px;
  min-width: 40px; padding: 7px 11px; border: 1px solid var(--border); border-radius: 9px;
  background: var(--bg); color: var(--text); font-size: .78rem; cursor: pointer; white-space: normal; }
.chat-bottom-nav button:hover { background: var(--surface-strong); }
.chat-bottom-nav button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.chat-bottom-nav .chat-bottom-nav__compose { margin-inline-start: auto; max-width: 100%; font-weight: 700;
  color: var(--accent-contrast); background: var(--accent); border-color: var(--accent); }
.chat-bottom-nav .chat-bottom-nav__compose:hover { background: var(--accent); filter: brightness(.9); }
.chat-bottom-nav .chat-bottom-nav__compose[aria-expanded="true"] { box-shadow: inset 0 0 0 2px var(--bg); }
.chat-bottom-nav button span { min-width: 0; }
/* The divider and the manager share the source pane with the chat reader.
   Flexing the reader keeps their heights complementary while the manager scrolls. */
.saved-requests-divider { flex: 0 0 14px; position: relative; z-index: 2; cursor: row-resize;
  touch-action: none; user-select: none; background: var(--surface); border-block: 1px solid var(--border); }
.saved-requests-divider::after { content: ''; position: absolute; width: 36px; height: 2px;
  top: 5px; left: calc(50% - 18px); border-radius: 2px; background: var(--muted); opacity: .65; }
.saved-requests-divider:hover, .saved-requests-divider:focus-visible { background: var(--surface-strong); }
.saved-requests-divider:hover::after, .saved-requests-divider:focus-visible::after { opacity: 1; }
.saved-requests-divider:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
body.is-resizing-saved-requests { user-select: none; cursor: row-resize; }
.app-shell .saved-requests-wrap { flex: 0 0 var(--saved-requests-height, 62dvh); min-height: 0;
  position: relative; inset: auto; display: flex; flex-direction: column; width: 100%; height: var(--saved-requests-height, 62dvh);
  max-height: none; overflow-y: auto; overscroll-behavior: contain;
  padding: 8px 12px 9px; background: var(--bg); border-top: 0; }
.app-shell .saved-requests-wrap.is-collapsed { display: none; }
.saved-request-panel { flex: 1 0 auto; display: flex; flex-direction: column; width: 100%; min-width: 0; }
.saved-requests { flex: 1 1 auto; width: 100%; min-width: 0; display: flex; flex-direction: column; gap: 8px; border: 1px solid var(--border); border-radius: 14px; padding: 10px; background: var(--bg); }
.saved-requests__header, .saved-requests__footer { display: flex; align-items: center; justify-content: space-between; gap: 9px; min-width: 0; }
.saved-requests__footer { padding-top: 5px; background: var(--bg); justify-content: flex-end; }
.saved-requests__header h2 { flex: 1 1 auto; min-width: 0; font-size: .93rem; line-height: 1.3; margin: 0; }
.saved-requests__tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 6px; }
.saved-requests__tools button, .saved-requests__send { min-height: 38px; width: auto; height: auto; padding: 7px 11px; border: 1px solid var(--border); font-size: .77rem; font-weight: 650; white-space: normal; text-align: center; }
.saved-requests__filter-wrap { min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; }
.saved-requests__filter-wrap label { font-size: .75rem; color: var(--muted); }
.saved-requests__filter-wrap select { min-width: 0; max-width: 100%; min-height: 38px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-size: .76rem; }
.saved-requests__master { min-width: 0; padding: 6px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--surface); }
.saved-requests__master button { min-height: 40px; height: auto; padding: 7px 11px; font-size: .76rem; font-weight: 650; white-space: normal; }
.saved-requests__master-toggle { display: flex; align-items: center; gap: 8px; width: 100%; text-align: start; border: 0; background: transparent; color: var(--text); overflow-wrap: anywhere; }
.saved-requests__master-arrow { display: inline-block; flex: 0 0 auto; transition: transform .15s ease; font-size: 1.15rem; }
.saved-requests__master-toggle[aria-expanded="true"] .saved-requests__master-arrow { transform: rotate(90deg); }
.saved-requests__master-dirty { margin-inline-start: auto; color: var(--muted); font-size: .7rem; }
.saved-requests__master-body:not([hidden]) { display: grid; grid-template-columns: minmax(0,1fr) auto; align-items: center; gap: 7px 10px; padding: 6px 0 4px; min-width: 0; }
.saved-requests__master-body > p:not(.saved-requests__master-status) { grid-column: 1 / -1; margin: 0; font-size: .73rem; line-height: 1.45; color: var(--muted); }
.saved-requests__master textarea { grid-column: 1 / -1; width: 100%; min-width: 0; height: min(72px, 15dvh); min-height: min(68px, 15dvh); max-height: min(32dvh, 280px); resize: vertical; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: .84rem; line-height: 1.5; }
.saved-requests__master textarea:disabled { opacity: .65; }
.saved-requests__master-status { min-width: 0; margin: 0; font-size: .71rem; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.saved-requests__master-status.is-error { color: var(--danger); }
.saved-requests__sender { flex: 1 1 auto; min-width: 0; min-height: 0; display: flex; flex-direction: column; gap: 7px; }
.saved-requests__send { background: var(--accent); color: var(--accent-contrast); flex: 0 0 auto; border-color: var(--accent); }
.saved-requests__list { flex: 1 1 auto; list-style: none; display: grid; align-content: start; grid-auto-rows: max-content; gap: 4px; min-height: min(70px, 15dvh); overflow: auto; overscroll-behavior: contain; scrollbar-width: thin; padding: 2px; margin: 0; }
.saved-requests__empty { padding: 7px 8px; font-size: .77rem; color: var(--muted); }
.saved-requests__group { min-width: 0; list-style: none; }
.saved-requests__group h3 { margin: 9px 6px 5px; font-size: .76rem; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.saved-requests__group-list { list-style: none; padding: 0; margin: 0; display: grid; gap: 4px; }
.saved-requests__item { display: flex; min-width: 0; }
.saved-requests__select { min-width: 0; flex: 1 1 auto; text-align: start; display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 2px 8px; padding: 8px 9px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); color: var(--text); cursor: pointer; }
.saved-requests__select[aria-pressed="true"] { border-color: var(--accent); box-shadow: inset 3px 0 0 var(--accent); background: var(--surface-strong); }
.saved-requests__select strong, .saved-requests__select small, .saved-requests__preview { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.saved-requests__select strong { font-size: .78rem; }
.saved-requests__select small { color: var(--muted); font-size: .69rem; grid-column: 1 / -1; }
.saved-requests__state { max-width: min(48%, 190px); font-size: .69rem; line-height: 1.35; text-align: end; color: var(--accent); overflow-wrap: anywhere; }
.saved-requests__preview { color: var(--muted); font-size: .7rem; grid-column: 1/-1; }
.saved-requests__previous-sends { grid-column: 1 / -1; color: var(--muted); font-size: .69rem; line-height: 1.4; overflow-wrap: anywhere; }
.saved-requests__status, .saved-requests__send-state { margin: 0; color: var(--muted); font-size: .71rem; line-height: 1.4; overflow-wrap: anywhere; }
.saved-requests__status:empty { display: none; }
.saved-requests__send-state { color: var(--text); }
.saved-requests-wrap .composer-note { flex: 0 0 auto; margin: 5px 0 0; line-height: 1.4; }
.saved-requests button:hover:not(:disabled), .saved-request-editor button:hover:not(:disabled) { filter: brightness(.93); }
.saved-requests :focus-visible, .saved-request-editor :focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.saved-requests button:disabled, .saved-request-editor button:disabled { opacity: .52; cursor: default; }
.saved-request-inline { min-width: 0; padding: 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.saved-request-dialog { width: min(960px, calc(100vw - 24px)); max-width: none; max-height: calc(100dvh - 24px); overflow-y: auto; border: 1px solid var(--border); border-radius: 14px; padding: 20px; color: var(--text); background: var(--bg); }
.saved-request-dialog::backdrop { background: rgba(0,0,0,.55); }
.saved-request-editor { display: grid; gap: 9px; min-width: 0; }
.saved-request-editor h2 { margin: 0; font-size: 1.08rem; overflow-wrap: anywhere; }
.saved-request-editor p { margin: 0; font-size: .78rem; line-height: 1.45; overflow-wrap: anywhere; color: var(--muted); }
.saved-request-editor label, .saved-request-editor__files-title { font-size: .81rem; font-weight: 650; }
.saved-request-editor textarea { width: 100%; min-width: 0; box-sizing: border-box; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: .87rem; min-height: 112px; max-height: min(28dvh, 250px); resize: vertical; line-height: 1.6; }
/* Give new prompts a usable writing area before any manual resize. */
.saved-request-inline .saved-request-editor textarea { height: min(32dvh, 260px); min-height: min(180px, 32dvh); max-height: min(50dvh, 420px); }
.saved-request-dialog .saved-request-editor textarea { height: min(30dvh, 300px); min-height: min(180px, 30dvh); max-height: min(55dvh, 480px); }
.saved-request-editor__dropzone { width: 100%; min-height: 72px; padding: 12px; border: 2px dashed var(--border); border-radius: 10px; background: var(--bg); color: var(--text); font: inherit; font-size: .82rem; text-align: center; line-height: 1.45; cursor: pointer; overflow-wrap: anywhere; }
.saved-request-editor__dropzone.is-dragover, .saved-request-editor__dropzone:hover:not(:disabled) { border-color: var(--accent); background: var(--surface-strong); }
.saved-request-editor__file-list { display: flex; flex-wrap: wrap; gap: 5px; max-height: 17dvh; overflow-y: auto; }
.saved-request-editor__file-list .pending-file { max-width: 100%; }
.saved-request-editor #saved-request-error { color: var(--danger); }
.saved-request-editor__actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: flex-end; gap: 8px; margin-top: 5px; }
.saved-request-editor__spacer { flex: 1 1 8px; }
.saved-request-editor__actions button { min-height: 44px; height: auto; padding: 7px 13px; margin: 0; overflow-wrap: anywhere; }
.saved-request-editor__delete { color: var(--danger); }
.message__elapsed { display: inline-block; margin-top: 8px; padding: 3px 9px; border: 1px solid var(--border); border-radius: 7px; font-size: .73rem; line-height: 1.4; color: var(--text); background: var(--surface); font-variant-numeric: tabular-nums; }
@media (max-width: 700px) {
  .saved-requests__header, .saved-requests__footer { flex-wrap: wrap; }
  .saved-requests__tools { width: 100%; justify-content: flex-start; }
}
@media (max-width: 520px) {
  .saved-requests-divider { flex-basis: 22px; }
  .saved-requests-divider::after { top: 9px; }
  .chat-bottom-nav { gap: 4px; padding-inline: 6px; }
  .chat-bottom-nav button { min-height: 44px; padding: 6px 8px; font-size: .72rem; }
  .app-shell .saved-requests-wrap { padding: 4px 6px 7px; }
  .saved-requests { padding: 7px; }
  .saved-requests__master { padding: 6px 8px; }
  .saved-requests__master-body:not([hidden]) { grid-template-columns: minmax(0,1fr); }
  .saved-requests__master-status, .saved-requests__master-body button { grid-column: 1; }
  .saved-requests__master button { min-height: 44px; }
  .saved-requests__filter-wrap { flex: 1 1 100%; }
  .saved-requests__filter-wrap select { flex: 1 1 100%; min-height: 44px; }
  .saved-requests__select, .saved-requests__tools button { min-height: 44px; }
  .saved-requests__send { min-height: 44px; width: 100%; }
  .saved-request-inline, .saved-request-dialog { padding: 10px; }
  .saved-request-editor__actions button { flex: 1 1 90px; }
  .saved-request-editor__actions #saved-request-send-now { flex-basis: 100%; }
}
@media (max-height: 510px) { .saved-requests__list { min-height: 48px; } }
@media (forced-colors: active) { .saved-requests-divider { border-color: CanvasText; } .saved-requests-divider::after { background: CanvasText; } .saved-requests__select[aria-pressed="true"], .saved-request-editor__dropzone.is-dragover, .chat-bottom-nav__compose[aria-expanded="true"], .saved-requests__master-toggle[aria-expanded="true"] { outline: 2px solid Highlight; } .message__elapsed { border-color: CanvasText; } }
.active-job-timer { flex: 0 0 auto; padding: 3px 8px; border: 1px solid var(--border); border-radius: 7px;
  font-variant-numeric: tabular-nums; font-size: .72rem; white-space: nowrap; color: var(--text); background: var(--bg); }
@media (max-width: 520px) { .active-job-timer { padding: 3px 5px; font-size: .65rem; } }

