/* web/css/composer.css
 *
 * The message box and everything that hangs off it (web/composer/): the
 * send queue, slash-command completion, the unclippable popover and snippets.
 *
 * Linked from web/index.html in the order the sections had in the old
 * web/styles.css, and concatenated in that order they reproduce it exactly, so
 * the cascade is unchanged. A rule that moves between these files moves in the
 * cascade too: check what it now comes before and after.
 */

/* ── composer ────────────────────────────────────────────────────────── */

/* The extra right padding is the turn rail's width: it keeps the composer on
   the same centre line as the transcript, which the rail narrows. */
/* Inset by whatever the side columns are using, so the 1000px inner below is
   centred over the transcript and not over the whole pane — see `--pane-left`
   on .conv-main. */
/* The same duration and easing the columns use, started by the same click, so
   the composer and the transcript travel together instead of one arriving first.
   `syncPaneInsets` writes the insets once, to where the column is *going* —
   driving them frame by frame from a ResizeObserver instead left the composer
   one frame behind for the length of the animation, which is a rubber-band on
   exactly the interaction this is meant to fix. */
.composer {
    flex: none;
    padding: var(--sp-2) calc(var(--pane-x, 28px) + var(--pane-right)) var(--sp-7) calc(var(--pane-x, 28px) + var(--pane-left));
    transition: padding var(--t-fast) var(--ease);
}
@media (prefers-reduced-motion: reduce) { .composer { transition: none; } }
.composer-inner { max-width: 1000px; margin: 0 auto; }

/* A session that cannot take a message (`capabilities.send` false): the line
   below stands in for the whole composer — box, queue, chips and pickers — so
   nothing offers to send what the bridge would refuse. */
.composer.read-only .composer-inner > :not(.composer-readonly) { display: none !important; }
.composer-readonly {
    padding: var(--sp-4) var(--sp-5);
    border: 1px dashed var(--outline);
    border-radius: var(--r-sm);
    color: var(--text-3);
    font-size: var(--fs-sm);
    line-height: 1.5;
}
.composer-readonly strong { color: var(--text-2); font-weight: 600; }

.status-line {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    height: 22px;
    margin-bottom: var(--sp-4);
    padding-left: var(--sp-2);
    font: 400 var(--fs-md)/var(--lh-none) var(--sans);
    color: var(--text-3);
}
.status-line .led { width: 7px; height: 7px; border-radius: 50%; background: var(--text-4); flex: none; }
.status-line[data-state="busy"] .led { background: var(--yellow); animation: breathe var(--dur-loop) var(--ease) infinite; }
.status-line[data-state="error"] .led { background: var(--red); }
.status-line[data-state="idle"] .led { background: var(--green); }
/* Still running, but something is wrong — an API call being retried. */
.status-line[data-state="retrying"] .led {
    background: var(--yellow);
    animation: breathe var(--dur-loop) var(--ease) infinite;
}
/* Running and saying nothing — bridge/runner.js. Still, like the rail's dot. */
.status-line[data-state="stalled"] .led { background: var(--red); }
.status-line .err { color: var(--red); }
.status-line .warn { color: var(--yellow); }
.status-line .muted { color: var(--text-4); }

@keyframes breathe {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}
@media (prefers-reduced-motion: reduce) {
    .status-line[data-state="busy"] .led,
    .status-line[data-state="ask"] .led,
    .status-line[data-state="retrying"] .led,
    :is(.strip-meta .tag-pr, .lcard-head .tag-pr, .conv-sub .pr, .sig.pr, .pr-pop .pr)[data-status="checks-pending"] svg,
    .tool[data-status="pending"] > summary::before,
    .strip[data-state="running"] .strip-meta::before { animation: none; }
}

.btn-stop {
    margin-left: auto;
    height: 28px;
    padding: 0 var(--sp-6);
    font: 500 var(--fs-sm)/var(--lh-none) var(--sans);
    color: var(--red);
    border-radius: var(--pill);
    transition: background var(--t-fast) var(--ease);
}
.btn-stop:hover { background: var(--red-cont); }

/* ── send queue ───────────────────────────────────────────────────────────
   Sits directly above the box you type in, so the panel and the composer read
   as one column in send order: what is waiting, then what you are writing. */

.queue[hidden] { display: none; }
.queue {
    margin-bottom: var(--sp-4);
    padding: var(--sp-4);
    background: var(--s1);
    border-radius: var(--r-lg);
}

.queue-head {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
    padding: 0 var(--sp-3) var(--sp-3) var(--sp-4);
    font: 400 var(--fs-sm)/var(--lh-none) var(--sans);
    color: var(--text-4);
}
.queue-count { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The key map appears when the keyboard is actually in the queue, and takes the
   count's place rather than pushing the row wider. */
.queue-keys {
    display: none;
    flex: none;
    gap: var(--sp-2);
    white-space: nowrap;
    color: var(--text-4);
}
.queue-keys b {
    margin-left: var(--sp-3);
    font: 500 var(--fs-xs)/var(--lh-none) var(--mono);
    color: var(--text-3);
}
.queue-keys b:first-child { margin-left: 0; }
.queue:focus-within .queue-keys { display: block; }
.queue-clear {
    flex: none;
    padding: var(--sp-1) var(--sp-4);
    border-radius: var(--pill);
    font: 400 var(--fs-sm)/var(--lh-snug) var(--sans);
    color: var(--text-3);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.queue-clear:hover { background: var(--red-cont); color: var(--red); }

.queue-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin: 0;
    padding: 0;
    list-style: none;
    /* Four chips before it scrolls: enough to see a plan, not enough to eat the
       transcript. */
    max-height: 168px;
    overflow-y: auto;
}

.queue-item {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-2);
    background: var(--s2);
    border-radius: var(--r);
    transition: background var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.queue-item:hover { background: var(--s3); }
.queue-item.dragging { opacity: 0.4; }

/* The roving focus is the only thing telling you which message Enter and Esc are
   about to act on, so it is styled on :focus rather than :focus-visible — it has
   to be unmistakable every time, not only when the browser judges it earned. */
.queue-item:focus {
    outline: none;
    background: var(--blue-cont);
}
.queue-item:focus .queue-text { color: var(--on-blue-cont); }
.queue-item:focus .queue-n { background: var(--blue); color: var(--on-blue); }
.queue-item:focus .queue-act { color: var(--on-blue-cont-2); }

.queue-grip {
    flex: none;
    width: 14px;
    color: var(--text-4);
    font-size: var(--fs-sm);
    text-align: center;
    cursor: grab;
}
.queue-item.dragging .queue-grip { cursor: grabbing; }
/* Handed to the running turn: fixed in place, so no grab cursor, and the arrow
   says it is on its way in rather than waiting. */
.queue-item.handed .queue-grip { cursor: default; color: var(--blue); }

/* The send order, which is the whole point of showing the queue at all. */
.queue-n {
    flex: none;
    width: 17px; height: 17px;
    border-radius: 50%;
    background: var(--s4);
    color: var(--text-3);
    font: 500 var(--fs-xs)/17px var(--mono);
    text-align: center;
}

/* A queued message carrying files. Sits next to the send-order badge because it is
   the same kind of fact about the chip: not its content, but what happens to it. */
.queue-files {
    flex: none;
    font: 400 var(--fs-xs)/var(--lh-base) var(--sans);
    color: var(--text-3);
    cursor: default;
}

.queue-text {
    flex: 1;
    min-width: 0;
    padding: 0;
    text-align: left;
    font: 400 var(--fs-md)/var(--lh-base) var(--sans);
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.queue-item.open .queue-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 132px;
    overflow-y: auto;
}
.queue-text:hover { color: var(--text); }

.queue-acts { flex: none; display: flex; align-items: center; gap: var(--sp-1); }
.queue-act {
    padding: var(--sp-1) var(--sp-4);
    border-radius: var(--pill);
    font: 400 var(--fs-sm)/var(--lh-tight) var(--sans);
    color: var(--text-4);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.queue-act:hover { background: var(--s4); color: var(--text-2); }
.queue-act.danger { font-size: var(--fs-base); line-height: var(--lh-none); padding: var(--sp-1) var(--sp-4) var(--sp-2); }
.queue-act.danger:hover { background: var(--red-cont); color: var(--red); }

/* Files staged for the next message.
   ---------------------------------------------------------------------------
   Built on the queue-chip tokens above rather than on a set of its own: the two
   strips sit one above the other in the same composer, and a second visual
   vocabulary between them would read as two unrelated features that happen to be
   adjacent. Same surface, same pill, same act buttons. */
/* The guard every class here that sets `display` carries: without it the empty
   strip drew as a 12px bar under "First message" in the Start dialog, where
   nothing is attached until you attach something. */
.attach[hidden] { display: none; }
.attach {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
    padding: var(--sp-3) var(--sp-4);
    background: var(--s1);
    border-radius: var(--r-lg);
}

.attach-chip {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    /* Room for a name without letting one long one push the rest off the row. */
    max-width: 260px;
    padding: var(--sp-2);
    background: var(--s2);
    border-radius: var(--r);
    transition: background var(--t-fast) var(--ease), opacity var(--t-fast) var(--ease);
}
.attach-chip:hover { background: var(--s3); }
/* Not yet on disk, so not yet something a message can carry. Dimmed rather than
   hidden: it is the evidence that the paste landed at all. */
.attach-chip.uploading { opacity: 0.6; }
.attach-chip.failed { background: var(--red-cont); }

.attach-thumb {
    flex: none;
    width: 26px; height: 26px;
    border-radius: var(--r-xs);
    object-fit: cover;
    background: var(--s4);
}

/* For everything that is not an image: the extension, which is the most useful
   three characters available and the one people actually scan for. */
.attach-glyph {
    flex: none;
    width: 26px; height: 26px;
    border-radius: var(--r-xs);
    background: var(--s4);
    color: var(--text-3);
    font: 500 9px/26px var(--mono);
    text-align: center;
    text-transform: uppercase;
    overflow: hidden;
}

.attach-name {
    flex: 1;
    min-width: 0;
    font: 400 var(--fs-sm)/var(--lh-snug) var(--sans);
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.attach-size {
    flex: none;
    font: 400 var(--fs-xs)/var(--lh-snug) var(--mono);
    color: var(--text-4);
}

.attach-act {
    flex: none;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--pill);
    font: 400 var(--fs-xs)/var(--lh-tight) var(--sans);
    color: var(--text-4);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.attach-act:hover { background: var(--s4); color: var(--text-2); }
.attach-act.danger { font-size: var(--fs-base); line-height: var(--lh-none); padding: var(--sp-1) var(--sp-3) var(--sp-2); }
.attach-act.danger:hover { background: var(--red-cont); color: var(--red); }

/* Drag a file anywhere over the composer and the whole thing is the target, not a
   strip you have to hit. Inset so it does not shift anything: an outline that
   changed the layout would make the box jump under the pointer mid-drag. */
.composer.drop-target .composer-inner {
    outline: 1.5px dashed var(--blue);
    outline-offset: calc(-1 * var(--sp-2));
    border-radius: var(--r-lg);
    background: var(--blue-tint);
}

/* The icon buttons in the input row — attach, send later, snippets, and Wispr
   (colours.css) — share one shape: a borderless 38px circle, the height of Send
   and the pinned snippets, so the row is one height and one radius throughout
   and Send is the only thing in it with a fill. They used to be two shapes, a
   bordered pair and a borderless pair, which read as two unrelated features.

   The paperclip is quieter than Send on purpose: pasting and dropping are the
   gestures attaching is really for, and this is the fallback for when there is
   nothing to drag from. */
.btn-attach,
.btn-later,
.btn-snippets {
    flex: none;
    display: grid;
    place-items: center;
    width: 38px; height: 38px;
    color: var(--text-3);
    background: transparent;
    border-radius: var(--pill);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.btn-attach:hover:not(:disabled),
.btn-later:hover:not(:disabled),
.btn-later[aria-expanded="true"],
.btn-snippets:hover:not(:disabled),
.btn-snippets[aria-expanded="true"] { background: var(--s4); color: var(--text); }
.btn-attach:disabled,
.btn-later:disabled,
.btn-snippets:disabled { color: var(--text-4); cursor: default; }

/* Send later.
   ---------------------------------------------------------------------------
   The button is the input row's icon button, above.

   A pending chip is amber throughout. The queue's chips are neutral because they
   are about to go; these are about to go *in six hours*, in a mode that may be
   bypassPermissions, and they should not look like the same fact. */

.later-wrap { position: relative; flex: none; }

/* The popover shares .snip-menu's box, animation and positioning; this is only
   what differs. Written as `.snip-menu.later-menu` because .snip-menu is defined
   further down this file and would otherwise win on order — it lays its children
   out as side-by-side grid columns, which is right for snippet groups and wrong
   for a list of times. */
.snip-menu.later-menu {
    display: block;
    width: auto;
    padding: var(--sp-2);
    min-width: 236px;
}
.later-row {
    display: flex;
    align-items: baseline;
    gap: var(--sp-5);
    width: 100%;
    padding: var(--sp-3) var(--sp-4);
    border-radius: var(--r);
    text-align: left;
    font: 400 var(--fs-md)/var(--lh-snug) var(--sans);
    color: var(--text-2);
}
.later-row:hover, .later-row.on { background: var(--s4); color: var(--text); }
/* The absolute time, beside the relative one that names the row. Muted and in the
   mono face, because it is the thing you check rather than the thing you read. */
.later-row .at { margin-left: auto; font: 400 var(--fs-xs)/var(--lh-snug) var(--mono); color: var(--text-4); }
.later-row:hover .at, .later-row.on .at { color: var(--text-3); }

.later-sep { height: 1px; margin: var(--sp-2); background: var(--outline-soft); }

/* Picking an exact time, and the mode it will be delivered in. Not rows: both are
   fields, and a field that looks like a row you can press is a field people press
   and then wonder why nothing happened. */
.later-fields { padding: var(--sp-2) var(--sp-4) var(--sp-3); display: flex; flex-direction: column; gap: var(--sp-3); }
.later-fields label {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    font: 400 var(--fs-sm)/var(--lh-snug) var(--sans);
    color: var(--text-3);
}
.later-fields input, .later-fields select {
    flex: 1;
    min-width: 0;
    padding: var(--sp-2) var(--sp-3);
    background: var(--s2);
    color: var(--text);
    border: 1px solid var(--outline-soft);
    border-radius: var(--r);
    font: 400 var(--fs-sm)/var(--lh-snug) var(--sans);
}
.later-fields .go {
    align-self: flex-end;
    padding: var(--sp-2) var(--sp-6);
    border-radius: var(--pill);
    background: var(--blue-cont);
    color: var(--on-blue-cont);
    font: 500 var(--fs-sm)/var(--lh-snug) var(--sans);
}
.later-fields .go:hover { background: var(--blue); color: var(--on-blue); }

/* The chips, above the queue. */
.later[hidden] { display: none; }
.later {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
}

.later-chip {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    padding: var(--sp-2) var(--sp-3) var(--sp-2) var(--sp-5);
    background: var(--s2);
    box-shadow: inset var(--edge-w) 0 0 var(--yellow);
    border-radius: var(--r);
    transition: background var(--t-fast) var(--ease);
}
.later-chip:hover { background: var(--s3); }
/* Delivered, missed or failed: it is a record now, not a plan, so the accent goes
   and the row steps back. A failure keeps a colour, because it is the one you have
   to do something about. */
.later-chip.done { box-shadow: inset var(--edge-w) 0 0 var(--outline-soft); opacity: 0.72; }
.later-chip.bad { box-shadow: inset var(--edge-w) 0 0 var(--red); }

.later-when {
    flex: none;
    font: 400 var(--fs-xs)/var(--lh-base) var(--mono);
    color: var(--yellow);
    white-space: nowrap;
}
.later-chip.done .later-when { color: var(--text-4); }
.later-chip.bad .later-when { color: var(--red); }

/* The mode is on the face of the chip and not in its expansion, because
   bypassPermissions arriving at 2am is the single most consequential thing about
   a scheduled message and it must not be something you have to click to find. */
.later-mode {
    flex: none;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--pill);
    background: var(--s4);
    font: 400 var(--fs-xs)/var(--lh-snug) var(--mono);
    color: var(--text-3);
    cursor: default;
}
/* bypassPermissions and dontAsk, which is what this pill is really for. */
.later-mode.loud { background: var(--yellow-cont-hover); color: var(--yellow); }

/* A wake-up rather than a message: the session's own, or the bridge's after a
   usage-limit stop (bridge/wakes.js). */
.later-kind {
    flex: none;
    padding: var(--sp-1) var(--sp-3);
    border-radius: var(--pill);
    background: var(--blue-cont);
    font: 400 var(--fs-xs)/var(--lh-snug) var(--sans);
    color: var(--blue);
    white-space: nowrap;
    cursor: default;
}

.later-text {
    flex: 1;
    min-width: 0;
    padding: 0;
    text-align: left;
    font: 400 var(--fs-md)/var(--lh-base) var(--sans);
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    cursor: pointer;
}
.later-chip.open .later-text {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 132px;
    overflow-y: auto;
}
.later-text:hover { color: var(--text); }

/* Images a turn carried, inline. Was two inline properties on the <img> itself, which
   was enough while one image per turn was the only shape there was. */
.ev-images {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-4);
    margin-top: var(--sp-4);
}

.ev-image {
    max-width: 100%;
    /* Several on a turn should read as several, so none of them takes the full width
       on its own. One is unconstrained, which is the case that matters most: a
       screenshot you pasted to be looked at. */
    border: 1px solid var(--outline-soft);
    border-radius: var(--r-xs);
}
.ev-images .ev-image:not(:only-child) { max-width: calc(50% - var(--sp-2)); }

/* Files on a turn in the transcript.
   ---------------------------------------------------------------------------
   A card and not a preview. Knowing a file is there and being able to open it is
   the whole job; rendering a PDF or a spreadsheet inline would be a viewer this
   app has no business being. */
.ev-files {
    display: flex;
    flex-wrap: wrap;
    gap: var(--sp-3);
    margin-top: var(--sp-5);
}

.ev-file {
    display: flex;
    align-items: center;
    gap: var(--sp-4);
    max-width: 300px;
    padding: var(--sp-3) var(--sp-6) var(--sp-3) var(--sp-3);
    background: var(--s2);
    border: 1px solid var(--outline-soft);
    border-radius: var(--r);
    text-align: left;
    transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}
.ev-file:hover:not(:disabled) { background: var(--s3); border-color: var(--outline); }
/* No session in view means no directory to resolve the path against. */
.ev-file:disabled { cursor: default; opacity: 0.6; }

.ev-file-glyph {
    flex: none;
    width: 24px; height: 24px;
    border-radius: var(--r-xs);
    background: var(--s4);
    color: var(--text-3);
    font: 500 8.5px/24px var(--mono);
    text-align: center;
    text-transform: uppercase;
    overflow: hidden;
}

.ev-file-name {
    flex: 1;
    min-width: 0;
    font: 400 var(--fs-md)/var(--lh-snug) var(--sans);
    color: var(--text-2);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ev-file-size {
    flex: none;
    font: 400 var(--fs-xs)/var(--lh-snug) var(--mono);
    color: var(--text-4);
}

/* The live-elsewhere lock, directly above the box it is holding shut. Sits where
   the queue sits, in the warning colour, because it is the one thing between a
   message and two processes writing to one transcript. */
/* Setting `display` here is what makes the guard below necessary: a class beats
   the browser's own `[hidden] { display: none }`, so without it the bar is on
   screen for every session however the attribute is set. */
.lock[hidden] { display: none; }

.lock {
    display: flex;
    align-items: center;
    gap: var(--sp-5);
    margin-bottom: var(--sp-4);
    padding: var(--sp-4) var(--sp-4) var(--sp-4) var(--sp-7);
    background: var(--yellow-cont);
    border-radius: var(--r-lg);
    font: 400 var(--fs-md)/var(--lh-snug) var(--sans);
    color: var(--text-2);
}
.lock-text { flex: 1; min-width: 0; }
/* Edit and branch: the lock's shape, because it is the same kind of thing — a
   fact about where Send is going, directly above the box — on the accent's
   ground rather than the warning's, since nothing here is about to go wrong. */
.lock.branch { background: var(--blue-tint); }
.lock.branch .lock-btn { padding: var(--sp-3) var(--sp-4); }

.lock-btn {
    flex: none;
    padding: var(--sp-3) var(--sp-6);
    border: 0;
    border-radius: var(--pill);
    background: var(--s4);
    color: var(--text-2);
    font: 500 var(--fs-md)/var(--lh-none) var(--sans);
    cursor: pointer;
    transition: background var(--t-fast) var(--ease);
}
.lock-btn:hover { background: var(--s5); }
.lock-btn.primary { background: var(--blue-cont); color: var(--blue); }

/* ── slash-command completion ─────────────────────────────────────────────
   The new-session menu's shape, anchored the other way up: it hangs off the
   bottom of the input row and grows into the log, because the composer is
   already at the foot of the window and a menu below it would be off-screen. */
.slash-menu {
    position: absolute;
    bottom: calc(100% + var(--sp-4));
    left: 0;
    right: 0;
    z-index: var(--z-pop);
    /* Every matching command is rendered — `/` on its own is a request to see
       what there is — so this is the window onto the list rather than the whole
       of it. Tall enough that a dozen are in view and paging feels like paging,
       short enough to leave the turn you are replying to on screen. */
    /* A token, because a floating menu is told at draw time how much room there
       actually is between its box and the edge of the window. The fallback is
       what the anchored one has always used — get it wrong and the live menu
       grows without limit up the transcript. */
    max-height: var(--menu-max, 400px);
    overflow-y: auto;
    /* The keys move a highlight the scrollbar has to follow, so the jumps are
       driven by scrollIntoView and should not be animated on top of that. */
    scroll-behavior: auto;
    overscroll-behavior: contain;
    padding: var(--sp-3);
    background: var(--s3);
    border-radius: var(--r);
    box-shadow: var(--shadow-pop);
    transform-origin: bottom left;
}
.slash-menu[hidden] { display: none; }

.slash-menu .picker-row { gap: var(--sp-5); padding: var(--sp-3) var(--sp-5); }
.slash-menu .picker-row:hover { background: var(--s4); }
/* aria-selected, not aria-current: the folder picker already claims that one
   for "where the input points", which is a different question from "which row
   would Enter take". Both can be on screen at once. */
.slash-menu .picker-row[aria-selected="true"] { background: var(--blue-cont); color: var(--blue); }
.slash-menu .picker-row .name { font-family: var(--mono); font-size: var(--fs-sm); flex: none; }
.slash-menu .picker-row .desc {
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: var(--fs-sm);
    color: var(--text-4);
}
.slash-menu .picker-row .hint {
    margin-left: auto;
    flex: none;
    padding-left: var(--sp-4);
    font-family: var(--mono);
    font-size: var(--fs-xs);
    color: var(--text-4);
}
.slash-menu .menu-note {
    padding: var(--sp-4) var(--sp-5);
    font: 400 var(--fs-sm)/var(--lh-base) var(--sans);
    color: var(--text-4);
}

/* A heading between groups. Deliberately not a `.picker-row`: the keyboard map
   counts those, so a heading that were one would be a row you could land on. */
.slash-menu .menu-group {
    padding: var(--sp-4) var(--sp-5) var(--sp-2);
    font: 500 var(--fs-xs)/var(--lh-snug) var(--sans);
    color: var(--text-3);
}
.slash-menu .menu-group:first-child { padding-top: var(--sp-1); }

/* A session is found by its title and sent to by its name, so the row leads
   with the title in the reading face and follows with the name in the mono one
   — which is also the shape of what gets inserted.

   By class rather than by the id this used to hang off: there are two mention
   menus now, and rows that look the same in one composer and not the other is
   the kind of difference nobody reports and everybody notices. */
.slash-menu.mention .picker-row .name {
    font-family: var(--sans);
    font-size: var(--fs-md);
    flex: 0 1 auto;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.slash-menu.mention .picker-row .desc {
    font-family: var(--mono);
    font-size: var(--fs-xs);
    flex: none;
}

/* A file or directory: icon, name, then the directory it is in, dimmed. Unlike a
   session row the directory is the part that gets long, so it is the part that
   shrinks and takes the ellipsis, and the name keeps its room. */
.slash-menu.mention .picker-row.file-row .file-icon {
    flex: none;
    display: inline-flex;
    color: var(--text-4);
}
.slash-menu.mention .picker-row.file-row .name {
    font-family: var(--mono);
    font-size: var(--fs-sm);
    flex: 0 1 auto;
}
.slash-menu.mention .picker-row.file-row .desc {
    flex: 1 1 0;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
}
.slash-menu .picker-row[aria-selected="true"] .file-icon { color: inherit; }

/* ── a popover that cannot be clipped ─────────────────────────────────────
   The anchored menu above hangs off `.input-row`, which works because the
   composer sits in open page. Inside the new-session dialog it cannot: `.modal`
   is `overflow: hidden` and `.modal-body` scrolls, so an absolutely positioned
   popover is cut by both — and the box it belongs to is the last field in the
   dialog, so "cut" means "mostly gone".

   Fixed leaves every ancestor's overflow out of it. The cost is that the anchor
   moves — the textarea grows as you type, and the modal body scrolls — so
   `left`, `width` and one of `top`/`bottom` are written from script on every
   redraw. Same idea and the same z-index as `.turn-pop`. */
.slash-menu.floating {
    position: fixed;
    left: auto;
    right: auto;
    bottom: auto;
    transform-origin: top left;
}
/* Opening upward when there is more room above. The transform-origin is what
   makes the entry animation grow from the edge nearest the box. */
.slash-menu.floating.up { transform-origin: bottom left; }

/* Nothing but a positioning context and a hit-test target for the
   click-outside rule; the popovers inside it are `position: fixed`. */
.composer-field { position: relative; }
/* The strip sits above the box, so its gap belongs underneath it. */
.composer-field .attach { margin-bottom: var(--sp-4); }
/* The paperclip row under the box. Wraps rather than squeezing the note, which is
   the half that can be truncated without losing the affordance. */
.compose-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: var(--sp-5);
    margin-top: var(--sp-4);
}
.compose-foot .note { margin-top: 0; flex: 1 1 12ch; }
/* `display: flex` above beats the browser's own `[hidden] { display: none }`, so
   without this the row that openNew() hides for a draft or a schedule stayed on
   screen — offering an Attach files button in the two modes whose stores do not
   carry attachments, where the files would have been dropped on save with
   nothing said. The same `.x[hidden]` pattern the rest of this file uses. */
.compose-foot[hidden] { display: none; }
/* Same treatment the live composer gets, so a drop reads as a drop in both. */
.composer-field.drop-target { outline: 2px dashed var(--blue); outline-offset: var(--sp-2); }


.input-row {
    /* The menu above is absolute against this. */
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: var(--sp-3);
    background: var(--s2);
    border-radius: var(--r-xl);
    padding: var(--sp-5) var(--sp-5) var(--sp-5) var(--sp-8);
    transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
/* Focus is the ground lifting a step and a hairline edge appearing, and no blue
   ring: this field has the focus most of the day, and a ring that is always on
   stops meaning anything while costing the one colour that means "selected". The
   edge gives the lifted field a contour against --s3 surfaces behind it. */
.input-row:focus-within {
    background: var(--s3);
    box-shadow: inset 0 0 0 1px var(--outline);
}

.input-row textarea {
    flex: 1;
    /* 22 line + 8 padding top and bottom = 38, the height of the Send button, so
       a single line sits on the button's centre line. Growing past one line keeps
       the button pinned to the bottom via the row's align-items. */
    min-height: 38px;
    max-height: 220px;
    resize: none;
    font-size: var(--fs-base);
    line-height: 22px;
    padding: var(--sp-4) 0;
    overflow-y: auto;
}
.input-row textarea::placeholder { color: var(--text-3); }
.input-row textarea:disabled { opacity: 0.5; }

/* ── find and replace in the message ──────────────────────────────────────
   web/composer/find.js. The bar is the lock's neighbour and its shape — a
   rounded strip directly above the box — and borrows the conversation find's
   round buttons and tabular counter so the two finds read as one control. */

.cfind {
    display: flex;
    flex-direction: column;
    gap: var(--sp-2);
    margin-bottom: var(--sp-4);
    padding: var(--sp-2) var(--sp-3);
    background: var(--s2);
    border-radius: var(--r-lg);
}
.cfind[hidden], .cfind-row[hidden] { display: none; }
.cfind-row {
    display: flex;
    align-items: center;
    gap: var(--sp-2);
    min-width: 0;
}
/* The Replace row lines its field up under Find's, past the toggle. */
#cfind-replace-row { padding-left: calc(26px + var(--sp-2)); }

.cfind-field {
    flex: 1;
    min-width: 80px;
    padding: var(--sp-2) var(--sp-4);
    border-radius: var(--r-sm);
    background: var(--s3);
    font: 400 var(--fs-md)/var(--lh-base) var(--mono);
    outline: none;
}
.cfind-field::placeholder { color: var(--text-4); font-family: var(--sans); }
.cfind-field:focus-visible { box-shadow: inset 0 0 0 1px var(--outline); }
.cfind-field[aria-invalid="true"] { box-shadow: inset 0 0 0 1px var(--red); }
.cfind-count { min-width: 92px; }
/* "Invalid regex" is the one count that is a problem rather than a number. */
.cfind:has(.cfind-field[aria-invalid="true"]) .cfind-count { color: var(--red); }

.cfind-toggle {
    width: 26px; height: 26px;
    border-radius: 50%;
    color: var(--text-3);
    font-size: var(--fs-lg);
    transition: rotate var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.cfind-toggle:hover { background: var(--s4); color: var(--text); }
.cfind-toggle.on { rotate: 90deg; }

/* The three switches: a pressed one wears the accent, the way the conversation
   find's Subagents toggle does when it is on. */
.cfind-opt {
    flex: none;
    min-width: 28px;
    height: 26px;
    padding: 0 var(--sp-2);
    border-radius: var(--r-sm);
    font: 500 var(--fs-xs)/1 var(--mono);
    color: var(--text-3);
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.cfind-opt:hover { background: var(--s4); color: var(--text); }
.cfind-opt[aria-pressed="true"] { background: var(--blue-cont); color: var(--on-blue-cont); }

.cfind-act {
    flex: none;
    height: 26px;
    padding: 0 var(--sp-4);
    border-radius: var(--pill);
    background: var(--s3);
    font: 400 var(--fs-sm)/1 var(--sans);
    color: var(--text-2);
    white-space: nowrap;
}
.cfind-act:hover { background: var(--s4); color: var(--text); }
.cfind-act:disabled { opacity: 0.35; cursor: default; background: var(--s3); }

/* The marks. A copy of the box's text in transparent ink, laid behind it — the
   textarea's own background is `none`, so they show through — with each match
   in a <mark>. Position, size and type are written from script to match the
   box; what is here is only what never varies. Above the row's ground, below
   the textarea, so the caret and the selection still draw over a match. */
.input-row textarea { position: relative; z-index: 1; }
.input-marks {
    position: absolute;
    z-index: 0;
    box-sizing: border-box;
    margin: 0;
    border-style: solid;
    border-color: transparent;
    overflow: hidden;
    white-space: pre-wrap;
    overflow-wrap: break-word;
    color: transparent;
    pointer-events: none;
}
.input-marks[hidden] { display: none; }
.input-marks mark {
    color: transparent;
    background: var(--mark-bg);
    border-radius: var(--r-2xs);
}
/* The current one: the conversation find's yellow would put the box's light
   text on a light ground, so it is the match colour with a yellow edge
   instead — a ring, which takes no room and so cannot move a line. */
.input-marks mark.at {
    background: var(--yellow-cont-strong);
    box-shadow: 0 0 0 1.5px var(--yellow);
}
/* A zero-length match (`^`, `\b`) is a caret-thin bar where it would land. Width
   0, and the bar is a shadow, so it shifts nothing after it. */
.input-marks mark.zero {
    display: inline-block;
    width: 0;
    height: 1lh;
    vertical-align: top;
    background: none;
    box-shadow: 1px 0 0 0 var(--mark-fg);
}
.input-marks mark.zero.at { box-shadow: 2px 0 0 0 var(--yellow); }

/* ── snippets ──────────────────────────────────────────────────────────────
   The pinned buttons and the popover behind them. Quieter than Send and beside
   it rather than anywhere else: each is a way of sending, and the thing it sends
   is not something to hit by accident.

   `--snip-accent` carries a group's colour down from the row that sets it, and
   everything below is mixed from that one value — `.sig.pr`'s idiom, which is
   already how this stylesheet turns one hue into a ground and an edge. Defaulted
   here so an ungrouped snippet is a colourless version of the same button rather
   than an unstyled one. */
.pins { display: contents; }

.btn-pin-snip {
    --snip-accent: var(--text-2);
    flex: none;
    height: 38px;
    padding: 0 var(--sp-7);
    color: var(--snip-accent);
    background: transparent;
    /* An inset ring rather than a border, so it is the same 38px box as Send and
       the icon buttons beside it — a border added its width on top. */
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--snip-accent) 32%, transparent);
    font: 500 var(--fs-md)/var(--lh-none) var(--sans);
    border-radius: var(--pill);
    white-space: nowrap;
    transition: background var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}
.btn-pin-snip:hover:not(:disabled) {
    background: color-mix(in srgb, var(--snip-accent) 12%, transparent);
    box-shadow: inset 0 0 0 1px var(--snip-accent);
}
.btn-pin-snip:disabled { color: var(--text-4); box-shadow: inset 0 0 0 1px var(--s4); cursor: default; }

/* Holds nothing but the popover's anchor: the popover itself is fixed, so this
   exists to keep the button and its menu together for the click-outside rule. */
.snip-wrap { position: relative; flex: none; }

/* .btn-snippets is the input row's icon button — see .btn-attach. */

/* The row the dialog's button sits in. Its own row rather than a place in the
   attach row, which is hidden in draft and schedule mode. */
.snip-foot { margin-top: var(--sp-4); }

.snip-menu {
    /* Fixed for both composers, positioned from script — see positionSnips. The
       dialog's copy has to be, because .modal is `overflow: hidden`; this way the
       arithmetic lives in one place instead of two. */
    position: fixed;
    z-index: var(--z-pop);
    max-height: var(--snip-max, 460px);
    overflow: auto;
    padding: var(--sp-5);
    background: var(--s3);
    border-radius: var(--r);
    box-shadow: var(--shadow-pop);
    transform-origin: top right;
    /* Groups beside each other, in columns as wide as they need. Auto-flow rather
       than a fixed template because the number of groups *is* the data, and
       columns rather than a wrapping grid because a wrapped fourth card lands
       below the fold of a popover this tall — which is the one thing putting them
       side by side was for. It scrolls sideways instead. */
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 1fr);
    gap: var(--sp-5);
    align-items: start;
}
.snip-menu.up { transform-origin: bottom right; }
/* An author `display` beats the UA rule for the `hidden` attribute, so every class
   in this file that sets one carries its own guard — .quota-menu, .new-menu,
   .scrim, .tasks. Without it closeSnips() empties the popover and leaves the box:
   padding, background and the width positionSnips left on the inline style, with
   nothing in it. */
.snip-menu[hidden] { display: none; }

.snip-card {
    --snip-accent: var(--text-3);
    /* Mixed into this popover's own surface rather than into transparent: a card
       that mixed to transparent would take the ground behind it and read as no
       card at all wherever the accent is close to grey. */
    background: color-mix(in srgb, var(--snip-accent) 10%, var(--s2));
    box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--snip-accent) 45%, transparent);
    border-radius: var(--r);
    padding: var(--sp-4);
    /* Without this a grid child refuses to shrink below its content, and every
       ellipsis below stops working. */
    min-width: 0;
    /* And this is the backstop behind that: whatever a row inside gets up to, it
       cannot paint outside its own card and onto the one beside it. The row's own
       track should make it unnecessary — it is here because the failure it catches
       is silent, and lands on the neighbouring column where it is somebody else's
       text that looks broken. */
    overflow: hidden;
}
/* Loose snippets are not a group, so they must not look like one. */
.snip-card.is-loose { background: none; box-shadow: none; }

.snip-card-name {
    margin: var(--sp-1) var(--sp-2) var(--sp-3);
    font: 600 var(--fs-base)/var(--lh-tight) var(--sans);
    letter-spacing: 0.01em;
    color: color-mix(in srgb, var(--snip-accent) 70%, var(--text));
}

/* A one-column grid rather than a flex column, and the track is `minmax(0, 1fr)`
   rather than `1fr` — which is the whole reason this is a grid.

   A flex column stretches its items to the container's width, but only once that
   width is definite, and this row is a <button>: an element with enough intrinsic
   sizing of its own that `width: 100%` on it is not the guarantee it looks like.
   Where that resolved to max-content instead, the preview line grew to the length
   of the text, `text-overflow` had nothing to clip against, and a long body ran
   out of its card and across the one beside it. A `minmax(0, 1fr)` track cannot
   be grown by its contents, so the ellipsis always has a width to land at. */
.snip-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 1px;
    width: 100%;
    min-width: 0;
    text-align: left;
    background: none;
    border: 0;
    border-radius: var(--r-sm);
    padding: var(--sp-3) var(--sp-4);
    cursor: pointer;
}
.snip-row:hover { background: var(--s4); }
/* Where the keyboard is, which is *not* `[aria-selected]`. That attribute is set
   on the first row the moment the popover opens, so styling it painted a row that
   looked permanently hovered under the pointer. `:focus-visible` is the browser's
   own answer to "is this person navigating by keyboard", so the marker appears for
   Ctrl+/ and the arrows and stays away for a mouse. The attribute is still there
   for the listbox semantics; it just no longer decides how this looks. */
.snip-row:focus-visible {
    outline: none;
    background: var(--s4);
    box-shadow: var(--ring-inset);
}
.snip-row-title {
    font: 400 var(--fs-md)/var(--lh-snug) var(--sans);
    color: var(--text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
/* One line of what it says, and only one: the body is cut to 120 characters in
   script so a long single-line snippet never reaches the DOM, and clipped here so
   the ellipsis lands at the real width. */
.snip-row-preview {
    font: 400 var(--fs-sm)/var(--lh-snug) var(--sans);
    color: var(--text-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* The title and, where it has one, the trigger. Flex so the chip keeps its width
   and the title is the one that gives way to an ellipsis. */
.snip-row-head {
    display: flex;
    align-items: baseline;
    gap: var(--sp-3);
    min-width: 0;
}
.snip-row-head .snip-row-title { flex: 0 1 auto; min-width: 0; }

/* A snippet's trigger: the word you type before Tab. Mono because it is something
   you type exactly, and small because it is a reminder rather than a label. Shared
   by the popover rows, the pinned buttons and the Settings list. */
.snip-trigger {
    flex: none;
    font: 500 var(--fs-xs)/var(--lh-snug) var(--mono);
    color: var(--text-3);
    background: var(--s4);
    border-radius: var(--r-sm);
    padding: 0 var(--sp-2);
    white-space: nowrap;
}
.btn-pin-snip .snip-trigger {
    margin-left: var(--sp-3);
    color: inherit;
    background: color-mix(in srgb, var(--snip-accent) 14%, transparent);
}

/* The one line under the cards that says triggers exist. The popover's columns
   are all implicit, so `1 / -1` would span nothing; drawSnips sets the span to the
   number of cards and this puts it on a row of its own, under them rather than
   beside them as one more column. */
.snip-hint {
    grid-row: 2;
    padding: 0 var(--sp-2);
    font: 400 var(--fs-xs)/var(--lh-snug) var(--sans);
    color: var(--text-4);
}

#snip-trigger { font-family: var(--mono); max-width: 20ch; }

.snip-empty {
    padding: var(--sp-5) var(--sp-4);
    font: 400 var(--fs-md)/var(--lh-base) var(--sans);
    color: var(--text-3);
    max-width: 320px;
}

.btn-send {
    flex: none;
    height: 38px;
    padding: 0 var(--sp-8);
    background: var(--blue);
    color: var(--on-blue);
    font: 500 var(--fs-md)/var(--lh-none) var(--sans);
    border-radius: var(--pill);
    transition: filter var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}
.btn-send:hover:not(:disabled) { filter: brightness(1.08); }
.btn-send:disabled { background: var(--s4); color: var(--text-4); cursor: default; }

.opts {
    display: flex;
    align-items: center;
    gap: var(--sp-3);
    margin-top: var(--sp-5);
    padding-left: var(--sp-2);
    font: 400 var(--fs-sm)/var(--lh-none) var(--sans);
    color: var(--text-4);
}
/* Each label sits with the control it names, and the pairs stand apart: the same
   gap between every word made "Model haiku Effort inherit" one run of text. */
.opts select + label { margin-left: var(--sp-4); }
/* The composer's pairs are boxed (`.opt`), so a wrapping row breaks between
   pairs rather than leaving "Permissions" at the end of one line and its select
   at the start of the next. */
.composer .opt { display: inline-flex; align-items: center; gap: var(--sp-3); white-space: nowrap; }
.composer .opt + .opt { margin-left: var(--sp-4); }
.opts select {
    height: 28px;
    background: var(--s2);
    border-radius: var(--pill);
    padding: 0 var(--sp-5);
    font: 400 var(--fs-sm)/var(--lh-tight) var(--sans);
    color: var(--text-2);
    cursor: pointer;
    transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.opts select:hover { background: var(--s3); color: var(--text); }
/* One line, cut short rather than wrapped: in a window narrower than about
   1100px it broke into three lines that hung below the selects and pushed the
   composer up. It is a reminder, so losing its tail is the cheap side. */
.opts .hint {
    margin-left: auto;
    min-width: 0;
    padding-left: var(--sp-4);
    color: var(--text-4);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

