/* Chat — a centred reading column: the assistant's replies as plain text,
   the user's turns as soft bubbles, and a floating composer card below. */

.view[data-view="chat"] { padding: 0; position: relative }
.view[data-view="chat"].active { display: flex; flex-direction: column }

#log {
  flex: 1;
  overflow-y: auto;
  /* Side padding grows with the view so the conversation stays a readable
     column (--content-w) instead of stretching across a wide screen. */
  padding: 1.5rem max(1rem, calc((100% - var(--content-w)) / 2)) 1rem;
  display: flex;
  flex-direction: column;
  gap: .65rem;
  min-height: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--scrollbar-thumb) transparent;
}

/* Top fade — soft frosted band that masks the hard edge where messages
   would otherwise be clipped as they scroll up under the main bar.

   Two effects layered behind one mask:
     • backdrop-filter blur — frosts whatever passes beneath
     • bg gradient (var(--bg) → transparent) — adds a faint fog tint that
       lets text fade INTO the page colour rather than just blurring
   The mask `linear-gradient(black 30% → transparent)` keeps the top third
   at full strength and lets both effects taper smoothly to zero near the
   bottom — so the chat is fully crisp by the time #log's top padding ends
   and real messages begin. */
.chat-fade-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1.5rem;
  z-index: 3;
  pointer-events: none;
  background: linear-gradient(
    to bottom,
    var(--bg) 0%,
    color-mix(in srgb, var(--bg) 55%, transparent) 50%,
    transparent 100%
  );
  backdrop-filter: blur(8px) saturate(1.05);
  -webkit-backdrop-filter: blur(8px) saturate(1.05);
  -webkit-mask-image: linear-gradient(to bottom, #000 0%, #000 30%, transparent 100%);
          mask-image: linear-gradient(to bottom, #000 0%, #000 30%, transparent 100%);
}
#log::-webkit-scrollbar { width: 8px }
#log::-webkit-scrollbar-track { background: transparent }
#log::-webkit-scrollbar-thumb { background: var(--scrollbar-thumb); border-radius: 4px; transition: background .15s }
#log::-webkit-scrollbar-thumb:hover { background: var(--scrollbar-thumb-hover) }

/* Row wrapper around each bubble. Owns the side-alignment so the
   timestamp (a sibling of the bubble, not a child) sits flush with the
   bubble's tail edge — right under the user's bubble, left under the
   assistant's. The bubble itself no longer carries `align-self`; the
   row does, and `align-items` mirrors it so the bubble and its
   timestamp share the same edge regardless of either's width. */
.msg-row {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  min-width: 0;
  gap: 3px;
}
.msg-row.user      { align-self: flex-end;   align-items: flex-end; }
.msg-row.assistant,
.msg-row.error     { align-self: flex-start; align-items: flex-start; }
/* A reply is prose, not a bubble — it may use the whole column. */
.msg-row.assistant { max-width: 100% }
/* A row the conversation read mid-turn already held of the turn the log
   paints live (live_turn.js): out of the way until the turn is over. */
.msg-row.is-shadowed { display: none }

/* Message system. The user's turn and an error are bubbles (neutral / red,
   with a side-tail corner); the assistant's reply sits directly on the page
   so long answers read like a document. */
.msg {
  padding: .6rem .9rem;
  border-radius: 12px;
  line-height: 1.45;
  font-size: .94rem;
  font-feature-settings: "kern", "liga";
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-weight: 400;
  letter-spacing: 0;
  word-break: break-word;
  /* Never wider than its row. The row stops at the column, but the bubble
     in it sizes to its content, and a code block's longest line (.md-pre,
     white-space: pre) stretched the bubble — and the whole log sideways —
     past the screen. Held to the row, the code block scrolls in its own box. */
  max-width: 100%;
}
.msg .who { display: none } /* bubble form already indicates sender */
.msg .body { white-space: pre-wrap; word-wrap: break-word }

.msg.user {
  background: var(--bubble-user);
  color: var(--text);
  border: 1px solid transparent;
  border-radius: 16px 16px 4px 16px;
}
.msg.assistant {
  padding: .2rem .15rem;
  background: transparent;
  color: var(--text);
  border: 1px solid transparent;
  line-height: 1.6;
}
.msg.error {
  background: var(--error-bubble-bg);
  color: var(--error-bubble-text);
  border: 1px solid var(--error-bubble-border);
  border-radius: 12px 12px 12px 2px;
}
/* Voice-input badge inside the user bubble — small, faded, floats below
   the transcribed text so the user can quickly see which of their turns
   came in via mic without it competing with the message itself. */
.msg.user .voice-input-badge {
  margin-top: 6px;
  font-size: 11px;
  opacity: 0.65;
  font-style: italic;
  letter-spacing: 0.2px;
  user-select: none;
}
/* Per-message timestamp — sibling of the bubble, not a child, so it
   reads as caption rather than as bubble content. Small, faded, inset
   one bubble-corner radius from the row edge so it visually nests
   under the bubble's tail corner. Wall-clock time surfaces on hover
   (full date/time in the user's locale via title=…). The row's
   align-items keeps it on the bubble side; padding-inline mirrors
   the bubble's tail so it doesn't cling to the row edge. */
.msg-row .timestamp {
  font-size: 10.5px;
  opacity: 0.5;
  letter-spacing: 0.2px;
  user-select: none;
  cursor: default;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  padding-inline: .55rem;
  transition: opacity .15s;
}
.msg-row .timestamp:hover { opacity: 0.85; }
/* Links inside an error bubble — match the bubble's red so they don't
   shout in green/blue accent. Underlined for clear affordance, slightly
   brightened on hover. */
.msg.error .body a {
  color: currentColor;
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--danger-action) 55%, transparent);
  text-underline-offset: 2px;
}
.msg.error .body a:hover {
  text-decoration-color: currentColor;
}
/* "Try again" inside an agent-unreachable card — a quiet outlined button
   in the bubble's own red, on its own line under the hint. */
.msg.error .msg-retry {
  display: flex;
  width: fit-content;
  margin-top: .55rem;
}

/* Composer (attachment tray + input row). The textarea sizes itself to
   its content (chat.js auto-grow) up to a third of the viewport, then
   scrolls — there is no manual expand/collapse control. */
#form {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0;
  /* Same column as #log above, so the composer lines up with the messages. */
  padding: .35rem max(1rem, calc((100% - var(--content-w)) / 2)) .55rem;
  flex-shrink: 0;
}
/* A background job's conversation before anybody wrote in it
   (job_conversations.js): its runs are the log and the composer is the
   ordinary one -- the greeting of a new chat is not shown over them. Only
   with another project open than the job's does the composer give way, to
   one line saying which project to pick; the way back down the log stays. */
.view.is-job-thread .chat-start { display: none }
.is-job-thread-locked #form > :not(#jobThreadBar):not(#jumpToEnd) { display: none }
.job-thread-bar {
  padding: .5rem 0;
  font-size: .84rem;
  line-height: 1.5;
}
/* The composer card: the textarea and its buttons share one rounded,
   softly lifted surface; the textarea itself carries no chrome. */
.composer-row {
  display: flex;
  /* Bottom-aligned: once the textarea grows past one line on a long draft
     the buttons stay anchored bottom-right instead of floating mid-height. On a single line every control is 40px tall,
     so the alignment is invisible there. */
  align-items: flex-end;
  gap: .25rem;
  padding: .4rem .45rem .4rem .35rem;
  background: var(--composer-bg);
  border: 1px solid var(--border2);
  border-radius: 18px;
  box-shadow: var(--composer-shadow);
  transition: border-color .15s ease;
}
.composer-row:focus-within { border-color: var(--outline-hover) }
#input {
  flex: 1;
  min-height: 40px;
  /* Auto-grow ceiling: a third of the viewport. chat.js sizes the textarea
     to its content on every keystroke and this is the hard cap after which
     the textarea scrolls instead of pushing the chat log further up.
     dvh tracks the mobile browser chrome; vh is the fallback. */
  max-height: 33.333vh;
  max-height: calc(100dvh / 3);
  resize: none;
  border: 0;
  border-radius: 12px;
  background: transparent;
  font-size: .97rem;
  padding: .6rem .75rem;
  line-height: 1.4;
  /* Default to no scrollbar — JS auto-grow keeps the textarea sized to its
     content, so a scrollbar would only appear due to sub-pixel rounding
     between scrollHeight and clientHeight. We re-enable overflow only when
     content actually exceeds the cap (.is-overflowing). */
  overflow-y: hidden;
  /* The field is a contenteditable box (chat_composer.js), not a textarea:
     the textarea's look by hand, and its text kept as typed. */
  position: relative;
  color: var(--text);
  outline: none;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
}
#input.is-empty::before {
  content: attr(placeholder);
  position: absolute;
  color: var(--muted2);
  pointer-events: none;
}
#input .md-code {
  font-family: var(--mono);
  font-size: .9em;
}
#input:focus { box-shadow: none }
#input.is-overflowing { overflow-y: auto }
/* Attach + mic + Send. Next to a short draft they sit in one row, as they
   always did. Once the textarea is a few lines tall (chat.js toggles
   #form.is-tall) the row would leave three controls strung along the
   bottom of a tall box — so the two icon buttons move up above Send,
   right-aligned, as a compact bottom-right column. The gaps mirror the
   old flat row so the single-line layout is pixel-identical. */
.composer-actions {
  display: flex;
  align-items: flex-end;
  gap: .25rem;
  flex-shrink: 0;
}
.composer-tools {
  display: flex;
  align-items: center;
  gap: .25rem;
}
#form.is-tall .composer-actions {
  flex-direction: column;
  align-items: flex-end;
}
#form.is-tall #send { margin-left: 0 }
#send {
  height: 38px;
  margin-left: .2rem;
  padding: 0 1.05rem;
  border-radius: 12px;
  /* The one solid accent fill on the page: the primary action. */
  background: var(--accent-solid);
  border-color: var(--accent-solid);
  color: var(--on-accent-solid);
  font-weight: 600;
  font-size: .9rem;
  min-width: 76px;
  flex-shrink: 0;
  /* 38px in a 40px row, bottom-aligned: lift by 1px so it reads centred
     next to the 40px icon buttons on a single-line composer. */
  margin-bottom: 1px;
  /* Smooth the colour swap when we toggle .is-stop on/off so the button
     doesn't blink between turns. Animating background + border-color
     keeps the transition cheap (no layout thrash). */
  transition: background .18s ease, border-color .18s ease, color .18s ease;
}
#send:hover {
  background: var(--accent-solid);
  border-color: var(--accent-solid);
  color: var(--on-accent-solid);
  filter: brightness(1.08);
}
#send:disabled { opacity: .4; cursor: not-allowed }

/* Busy state — #send while attachments upload (slow connections). Distinct
   from a plain :disabled so the user reads it as "working", not "dead":
   a wait cursor + a gentle opacity pulse. The `submitting` latch in chat.js
   blocks the duplicate submit underneath; this is purely the visible cue. */
#send.is-busy { cursor: wait; animation: send-busy-pulse var(--beat) ease-in-out infinite; }
@keyframes send-busy-pulse { 0%, 100% { opacity: .7 } 50% { opacity: .4 } }
@media (prefers-reduced-motion: reduce) {
  #send.is-busy { animation: none; }
}

/* Stop state — sendBtn doubles as a "stop generating" button while the
   agent is streaming a reply. Same physical button, different paint job
   so the form layout doesn't shift the moment streaming starts. We keep
   it tagasihoidlik (muted) per the user's brief: a clear cue without
   shouting. The hover deepens slightly to confirm interactivity. */
#send.is-stop {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
}
#send.is-stop:hover {
  border-color: var(--danger-action);
  color: var(--danger-action);
}
/* Tiny square glyph rendered with a pseudo-element so the button label
   keeps the simple "Stop" text node (matches our rule of no inline SVG
   for trivial shapes). The square is the universally-understood stop
   icon and reads at a glance even at sub-15px sizes. */
#send.is-stop::before {
  content: '';
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: .4rem;
  background: currentColor;
  vertical-align: 1px;
  border-radius: 1px;
}

/* Under the composer: what answers the next message — model, then provider
   and credit, on one quiet centred line. They name a state, in one tone; the
   composer is the action. */
.composer-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0 .1rem;
  min-height: 1.7rem;
  margin-top: .4rem;
  padding: 0 .35rem;
}
.composer-meta .pill,
.composer-meta .pill.model {
  min-width: 0;
  max-width: 100%;
  padding: .22rem .55rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  background: transparent;
  border-color: transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 500;
}
.composer-meta .pill.clickable:hover {
  background: var(--shell-hover);
  border-color: transparent;
  color: var(--text);
}
.composer-meta-sep {
  color: var(--muted2);
  font-size: .76rem;
  user-select: none;
}
/* How full the open conversation's context window is after its last reply
   (topbar.js refreshContext): a small ring in the separator's place between
   the model and the provider, in the line's quiet tone until it nears the
   end of the window. The numbers are in its title. */
.ctx-gauge {
  display: inline-flex;
  align-items: center;
  padding: .2rem .3rem;
  border-radius: 999px;
  cursor: pointer;
}
.ctx-gauge:hover, .ctx-gauge:focus-visible, .ctx-gauge[aria-expanded="true"] {
  background: var(--shell-hover);
  outline: none;
}
.ctx-gauge[hidden] { display: none }
.ctx-gauge svg { width: .78rem; height: .78rem; display: block }
.ctx-gauge circle { fill: none; stroke-width: 2.4 }
.ctx-gauge-track { stroke: var(--muted2); opacity: .3 }
.ctx-gauge-fill {
  stroke: var(--muted);
  stroke-linecap: round;
  transition: stroke-dasharray .4s ease, stroke .4s ease;
}
.ctx-gauge.is-warn .ctx-gauge-fill { stroke: var(--warn) }
.ctx-gauge.is-err .ctx-gauge-fill { stroke: var(--err) }
/* A compaction in the log (chat_rows.js renderCompaction): a quiet centred
   line, no bubble. */
.msg-row.note { align-self: center; align-items: center; max-width: 100% }
.msg.note {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: .2rem .5rem;
  color: var(--muted);
  font-size: .8rem;
  text-align: center;
}
/* Its card (context_popover.js): the figures, a bar with a tick where Hermes
   compacts by itself, a sentence on what happens when it fills, a link. */
.cp-pop-context { min-width: 16rem }
/* A flex column that may scroll: its rows keep their own height. */
.cp-pop-context > * { flex-shrink: 0 }
.ctx-pop-figure {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: .75rem;
  padding: 0 .65rem .45rem;
  color: var(--text);
  font-size: .85rem;
  font-variant-numeric: tabular-nums;
}
.ctx-pop-tokens { color: var(--muted); text-align: right; white-space: nowrap }
.ctx-pop-bar {
  position: relative;
  height: 6px;
  margin: 0 .65rem .3rem;
  border-radius: 999px;
  background: var(--border);
}
.ctx-pop-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--muted);
  transition: width .4s ease;
}
.ctx-pop-bar.is-warn .ctx-pop-fill { background: var(--warn) }
.ctx-pop-bar.is-err .ctx-pop-fill { background: var(--err) }
.ctx-pop-mark {
  position: absolute;
  top: -3px;
  bottom: -3px;
  width: 2px;
  margin-left: -1px;
  border-radius: 1px;
  background: var(--text);
  opacity: .55;
}
.composer-meta .pill[aria-expanded="true"] {
  background: var(--shell-active);
  color: var(--text);
}
/* Before the first refresh lands there is nothing to name: the line keeps
   its height (no jump when the labels arrive) but shows no placeholder. */
.composer-meta.is-empty { visibility: hidden }

/* The picker a pill opens (composer_picker.js): a small list anchored under
   the pill by popover.js, in the menu's own dress — one surface, a quiet
   caption, the current choice ticked, and the way into Settings at the foot.
   Fixed in the viewport so the scrolling chat can't clip it. */
.cp-pop {
  position: fixed;
  z-index: 960;
  min-width: 14rem;
  max-width: min(22rem, calc(100vw - 16px));
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}
.cp-caption {
  padding: .3rem .65rem .35rem;
  color: var(--muted2);
  font-size: .66rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cp-note {
  padding: .45rem .65rem;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.4;
}
/* Rows are <button>s; undo the everyday button chrome so they read as list
   entries, like .menu-item. */
.cp-opt, .cp-link {
  display: flex;
  align-items: center;
  gap: .6rem;
  width: 100%;
  padding: .42rem .65rem;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: .85rem;
  font-weight: 400;
  line-height: 1.3;
  letter-spacing: 0;
  text-align: left;
  cursor: pointer;
  box-shadow: none;
}
.cp-opt:hover, .cp-opt:focus-visible,
.cp-link:hover, .cp-link:focus-visible {
  background: var(--shell-hover);
  border: 0;
  color: var(--text);
  outline: none;
  box-shadow: none;
}
.cp-opt:active, .cp-link:active { transform: none }
.cp-opt:disabled {
  opacity: .45;
  cursor: default;
}
.cp-opt:disabled:hover { background: transparent }
/* The choice in use: its name in 600 and the tick (shell.css "Dropdowns"). */
.cp-opt[aria-selected="true"] { font-weight: 600 }
.cp-opt-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.cp-opt-meta {
  flex: none;
  /* An absolute cap, not a share of the row: the row is sized by its
     content, so a percentage cut a long note beside a short name ("Codex"
     next to "(your subscription)") to an ellipsis for no reason. The name
     yields first when the popover reaches its own maximum width. */
  max-width: 12rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: .72rem;
  font-weight: 500;
}
/* The tick marks the current choice; the column is reserved on every row so
   names line up. */
.cp-opt-check {
  display: inline-flex;
  flex: none;
  width: 15px;
  height: 15px;
  color: var(--accent);
  visibility: hidden;
}
.cp-opt-check svg { width: 15px; height: 15px }
.cp-opt[aria-selected="true"] .cp-opt-check { visibility: visible }
/* The choice in use sits in its own tinted box (composer_picker.js
   _current): in the model list together with the effort scale, so the scale
   plainly belongs to that model; in the provider list on its own, in the
   same dress. The box spans the row's width, so its text lines up with the
   other rows. */
.cp-current {
  display: flex;
  flex-direction: column;
  padding: .1rem 0 .15rem;
  margin: 1px 0;
  border-radius: 9px;
  background: var(--accent-soft);
}
.cp-current .cp-opt { border-radius: 7px }
.cp-current .cp-effort { margin: 0; padding: 0 .65rem .3rem }
/* The reasoning-effort scale under the model in use (composer_picker.js
   _effortBar): a track with one stop per level, filled up to the level in
   use, the names underneath. The stops share the width equally, so the
   first and last dot centres sit half a stop in from each edge; the track
   line runs between those centres and the fill is the in-use stop's share
   of that run (--cp-effort-n stops, --cp-effort-fill 0..1, set inline). */
.cp-effort {
  margin: 0 0 .35rem;
  padding: .15rem .65rem .25rem;
}
.cp-effort-label {
  display: block;
  margin-bottom: .5rem;
  color: var(--muted);
  font-size: .68rem;
  font-weight: 500;
}
.cp-effort-track {
  position: relative;
  display: flex;
  align-items: flex-start;
  /* Every level name is written out in full: each stop gets room for the
     longest usual one ("medium" at this size), which widens the list past
     its 14rem floor when the scale is in it (five stops ≈ 19rem, inside
     the list's 22rem cap and any phone's width). */
  min-width: calc(var(--cp-effort-n, 1) * 3.4rem);
}
.cp-effort-track::before,
.cp-effort-track::after {
  content: '';
  position: absolute;
  top: 5px;
  height: 2px;
  border-radius: 1px;
  pointer-events: none;
}
.cp-effort-track::before {
  left: calc(50% / var(--cp-effort-n, 1));
  right: calc(50% / var(--cp-effort-n, 1));
  background: var(--border2);
}
.cp-effort-track::after {
  left: calc(50% / var(--cp-effort-n, 1));
  width: calc((100% - 100% / var(--cp-effort-n, 1)) * var(--cp-effort-fill, 0));
  background: var(--accent);
}
.cp-effort-stop {
  position: relative;
  z-index: 1;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .32rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .62rem;
  font-weight: 500;
  line-height: 1.2;
  letter-spacing: 0;
  cursor: pointer;
  box-shadow: none;
}
.cp-effort-stop:hover, .cp-effort-stop:focus-visible {
  background: transparent;
  color: var(--text);
  outline: none;
  box-shadow: none;
}
.cp-effort-stop:active { transform: none }
.cp-effort-knob {
  box-sizing: border-box;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--menu-bg);
  border: 2px solid var(--muted2);
  transition: transform .12s ease, border-color .12s ease, background .12s ease, box-shadow .12s ease;
}
.cp-effort-stop.is-passed .cp-effort-knob { border-color: var(--accent) }
.cp-effort-stop:hover .cp-effort-knob,
.cp-effort-stop:focus-visible .cp-effort-knob {
  border-color: var(--accent);
  transform: scale(1.15);
}
.cp-effort-stop:focus-visible .cp-effort-knob { box-shadow: 0 0 0 3px var(--accent-soft) }
.cp-effort-stop[aria-checked="true"] { color: var(--accent); font-weight: 600 }
.cp-effort-stop[aria-checked="true"] .cp-effort-knob {
  background: var(--accent);
  border-color: var(--accent);
  transform: scale(1.25);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.cp-effort-name { white-space: nowrap }
.cp-foot {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin-top: .2rem;
  padding-top: .25rem;
  border-top: 1px solid var(--border);
}
.cp-link {
  color: var(--muted);
  font-size: .78rem;
}

/* Start of a conversation (.is-start, kept by chat.js): nothing said yet, so
   the composer sits mid-page under a greeting and moves to the bottom edge
   with the first message. */
.chat-start { display: none }
.view[data-view="chat"].is-start {
  justify-content: center;
  padding-bottom: 12vh;
}
.is-start .chat-start {
  display: block;
  margin: 0 0 1.5rem;
  padding: 0 1.25rem;
  font-size: clamp(1.45rem, 1.1rem + 1.2vw, 1.9rem);
  font-weight: 500;
  line-height: 1.25;
  letter-spacing: -.02em;
  text-align: center;
  color: var(--text);
}
.is-start #log {
  flex: 0 0 auto;
  overflow: visible;
  padding-top: 0;
  padding-bottom: .75rem;
}
.is-start #log:empty,
.is-start .chat-fade-top,
.is-start .jump-to-end { display: none }
.is-start .composer-row {
  padding: .55rem .6rem .55rem .5rem;
  border-radius: 20px;
}

/* Loading a conversation (chat.js renderLoadingPlaceholder): three ghost
   bubbles where the messages will be, breathing in turn. The whole group
   fades in after a short delay, so a session that arrives quickly never
   flashes it. */
.chat-loading {
  display: flex;
  flex-direction: column;
  gap: .65rem;
  opacity: 0;
  animation: chat-loading-in .25s ease-out .15s forwards;
}
.chat-loading-row { display: flex }
.chat-loading-row.user { justify-content: flex-end }
.chat-loading-bubble {
  display: block;
  height: 2.4rem;
  border-radius: 18px;
  background: var(--shell-hover);
  animation: chat-loading-breathe var(--beat) ease-in-out infinite;
}
.chat-loading-row.assistant .chat-loading-bubble { width: 62% }
.chat-loading-row.user .chat-loading-bubble { width: 38%; height: 2.1rem }
.chat-loading-row:nth-child(2) .chat-loading-bubble { animation-delay: calc(var(--beat) / 8) }
.chat-loading-row:nth-child(3) .chat-loading-bubble { animation-delay: calc(var(--beat) / 4); width: 48% }
@keyframes chat-loading-in { to { opacity: 1 } }
@keyframes chat-loading-breathe {
  0%, 100% { opacity: 1 }
  50%      { opacity: .45 }
}

/* Markdown rendering: the agent's reply in a chat bubble, a notice's text
   (base.css .job-card-body — in Notifications and on the card a chat opens
   on) and a pin opened in the pin list (.pin-list-full, message_pins.js),
   which are the same renderMarkdown() output and read the same. Block
   elements break out of the surrounding pre-wrap flow on their own; we still
   want tight vertical rhythm so the bubble doesn't bloat. */
.msg.assistant .body .md-h,
.job-card-body .md-h,
.pin-list-full .md-h {
  font-weight: 600;
  margin: .35em 0 .2em;
  line-height: 1.25;
}
.msg.assistant .body h1.md-h, .job-card-body h1.md-h, .pin-list-full h1.md-h { font-size: 1.22rem }
.msg.assistant .body h2.md-h, .job-card-body h2.md-h, .pin-list-full h2.md-h { font-size: 1.12rem }
.msg.assistant .body h3.md-h, .job-card-body h3.md-h, .pin-list-full h3.md-h { font-size: 1.05rem }
.msg.assistant .body .md-code,
.job-card-body .md-code,
.pin-list-full .md-code {
  font-family: var(--mono);
  font-size: .92em;
  background: var(--surface-hover-strong);
  padding: .05em .35em;
  border-radius: 4px;
}
.msg.assistant .body .md-pre,
.job-card-body .md-pre,
.pin-list-full .md-pre {
  background: var(--surface-control);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .55rem .7rem;
  margin: .35em 0;
  overflow-x: auto;
  white-space: pre;
  font-size: .9rem;
}
.msg.assistant .body .md-pre code,
.job-card-body .md-pre code,
.pin-list-full .md-pre code {
  font-family: var(--mono);
  background: transparent;
  padding: 0;
}
/* A fenced block's frame (chat_markdown.js codeBlockHtml): it holds the
   block's margin, so the copy button sits on the code's own corner, and the
   code keeps clear of the button. */
.msg.assistant .body .md-codeblock,
.job-card-body .md-codeblock,
.pin-list-full .md-codeblock {
  position: relative;
  margin: .35em 0;
}
.msg.assistant .body .md-codeblock > .md-pre,
.job-card-body .md-codeblock > .md-pre,
.pin-list-full .md-codeblock > .md-pre {
  margin: 0;
  padding-inline-end: 2.5rem;
}
/* A block fenced as words to paste (```text): its lines wrap in the bubble
   instead of running off sideways. */
.msg.assistant .body .md-pre.md-wrap,
.job-card-body .md-pre.md-wrap,
.pin-list-full .md-pre.md-wrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* The copy button: there at rest, faintly, so it is found without hunting
   for it; plain once the block is pointed at; a tick in the accent for a
   moment once copied. Its own fill keeps a long first line, scrolled under
   it, from showing through. */
.msg.assistant .body .md-copy,
.job-card-body .md-copy,
.pin-list-full .md-copy {
  position: absolute;
  top: .3rem;
  inset-inline-end: .3rem;
  display: grid;
  place-items: center;
  width: 1.75rem;
  height: 1.75rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: var(--surface-control);
  color: var(--muted);
  cursor: pointer;
}
/* Only the icon is faint: the button's fill stays whole, so code scrolled
   under it never shows through. */
.md-copy { transition: background-color .15s ease, color .15s ease }
.md-copy svg {
  width: 1rem;
  height: 1rem;
  display: block;
  opacity: .6;
  transition: opacity .15s ease;
}
.md-codeblock:hover > .md-copy svg,
.md-copy:focus-visible svg,
.md-copy.is-done svg { opacity: 1 }
.msg.assistant .body .md-copy:hover,
.job-card-body .md-copy:hover,
.pin-list-full .md-copy:hover {
  background: color-mix(in srgb, var(--muted) 16%, var(--surface-control));
  color: var(--text);
}
.md-copy:active { transform: none }
.md-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.msg.assistant .body .md-copy.is-done,
.job-card-body .md-copy.is-done,
.pin-list-full .md-copy.is-done { color: var(--accent) }
@media (hover: none) {
  .md-copy svg { opacity: .8 }
}
@media (prefers-reduced-motion: reduce) {
  .md-copy,
  .md-copy svg { transition: none }
}
.msg.assistant .body a,
.job-card-body a,
.pin-list-full a {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.msg.assistant .body strong,
.job-card-body strong,
.pin-list-full strong { font-weight: 600 }

/* Tables / blockquotes — block constructs renderMarkdown() emits as real
   HTML. The browser renders the genuine article (Telegram only approximates
   with monospace). A table is as wide as its columns need and no wider than
   the text; its cells wrap between words, never inside one. When the words
   do not fit even so, the table scrolls sideways in its own box, as a code
   block does: display: block makes the table element that box, and its rows
   are laid out in an anonymous table inside it. */
.msg.assistant .body .md-table,
.job-card-body .md-table,
.pin-list-full .md-table {
  display: block;
  max-width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: .4em 0;
  font-size: .92em;
}
.msg.assistant .body .md-table th,
.msg.assistant .body .md-table td,
.job-card-body .md-table th,
.job-card-body .md-table td,
.pin-list-full .md-table th,
.pin-list-full .md-table td {
  border: 1px solid var(--border);
  padding: .25em .5em;
  text-align: left;
  /* The bubble's and the card's word-break: break-word may break any word,
     and a table squeezes each column to its narrowest such break — on a
     phone "Markdown" came out as "Markdow" / "n" (13.10). */
  word-break: normal;
}
.msg.assistant .body .md-table th,
.job-card-body .md-table th,
.pin-list-full .md-table th {
  font-weight: 600;
  background: var(--surface-hover);
}
.msg.assistant .body .md-quote,
.job-card-body .md-quote,
.pin-list-full .md-quote {
  margin: .35em 0;
  padding: .1em 0 .1em .7em;
  border-left: 3px solid var(--border);
  opacity: .9;
}

@media (max-width: 680px) {
  .msg-row { max-width: 92% }
  #log { padding: 1rem .75rem .75rem }
  #form { padding: .35rem .6rem .45rem }
  /* Slightly tighter fade on phones to match the reduced top padding. */
  .chat-fade-top { height: 1rem }
}

/* Thinking indicator — three dots that pulse in sequence, riding along
   the tail of the assistant's bubble for as long as the stream is alive.
   chat.js attaches the same DOM node before the network call, re-attaches
   it at the bubble root after every renderMarkdown() pass (innerHTML
   reassignment wipes children), and removes it in `finally` once
   streaming ends or errors.

   Visual placement (chat.js placeThinking, for the panel's own turn and
   for one sent from Telegram alike): the dots go last in the bubble being
   written. After words they stay on the last word's line, a clear gap
   away -- an ellipsis glued to the sentence read as part of it. After a
   block (a code block, a table, a heading, a quote, a list, an image)
   they take a line of their own under it, with air above, never pressed
   against its edge. In an empty bubble they start where the text will.

   Sizing: the bubble's vertical padding (.6rem) means a 6px dot row sits
   on the same line height as a single text line — no jumpy resize when
   the first character of the reply lands.

   Accessibility: role=status + aria-label announces "Agent is thinking"
   to screen readers; prefers-reduced-motion swaps the bouncy keyframe
   for a slower fade so users sensitive to motion still see *something*
   moving (silent freeze is worse — they'd think the panel hung). */
.thinking {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  /* The gap after the last word -- on the text's side in a right-to-left
     language too. */
  margin-inline-start: .6em;
  height: 1.2em;
  vertical-align: middle;
}
.thinking.is-alone { margin-inline-start: 0 }
.thinking.is-below {
  display: flex;
  margin-inline-start: 0;
  margin-top: .5em;
}
/* The steps block keeps its own air below it. */
.msg-trace + .thinking.is-below { margin-top: 0 }
/* `display: inline-flex` above outranks the UA's `[hidden] { display: none }`. */
.thinking[hidden] { display: none }
.thinking-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .35;
  animation: thinking-pulse var(--beat) ease-in-out infinite;
}
/* On the panel beat (beat.js): the first dot stands highest on the downbeat,
   as the plan ring passes the top of its turn and the stripes are at their
   brightest; the other two follow an eighth of a beat apart. */
.thinking-dot:nth-child(2) { animation-delay: calc(var(--beat) / 8) }
.thinking-dot:nth-child(3) { animation-delay: calc(var(--beat) / 4) }
@keyframes thinking-pulse {
  0%, 100% { opacity: 1;   transform: translateY(-2px) scale(1.0) }
  40%, 60% { opacity: .25; transform: translateY(0)    scale(.85) }
}

@media (prefers-reduced-motion: reduce) {
  .chat-loading-bubble { animation: none; opacity: .7 }
  .thinking-dot {
    animation: thinking-fade calc(var(--beat) * 2) ease-in-out infinite;
  }
  @keyframes thinking-fade {
    0%, 100% { opacity: .9 }
    50%      { opacity: .25 }
  }
}

/* Minimal style's steps block above the answer: a quiet header line
   (chevron, label, count pill) straight on the chat background -- no card
   -- that folds out into a timeline of the calls. Greys only, no accent:
   the block is there for whoever looks, it does not call the eye away
   from the answer. chat_steps.js moves it: on each new step a spark runs
   along the label into the pill and the number rolls over; unfolded, the
   light starts at the chevron instead and parts in two, the spark into
   the pill and a drop down the timeline that lights the new step's dot.
   The list slides open and shut.
   :not(.panel-section) outranks settings.css's details:not(.panel-section)
   (loaded later) and its padding-top, margin-top and top border. */
details.msg-trace:not(.panel-section) {
  /* The light that moves -- the spark, the drop down the timeline -- in
     the full ink: a point of light on dark, a pencil stroke on light. */
  --trace-glint: var(--text);
  /* The drop and the ring where it lands (chat_steps.js) are laid out from
     here. */
  position: relative;
  margin: 0 0 .6rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--muted);
  font-size: .82rem;
}
/* .trace-head (paintTraceSummary) outranks settings.css's rules for every
   other <details> -- its ▸ glyph, muted colour and spacing -- which load
   after this file. Only as wide as its content, so the hover and click
   area stays on the words instead of the whole column. */
details.msg-trace > summary.trace-head,
details.msg-trace[open] > summary.trace-head {
  /* The header's ink -- the chevron, the words, the pill's number and its
     tint, the sweep's edges: grey until pointed at or unfolded. */
  --trace-ink: var(--muted);
  position: relative;
  margin: 0;
  display: flex;
  width: fit-content;
  align-items: center;
  gap: .45rem;
  padding: .15rem 0;
  border-radius: 6px;
  cursor: pointer;
  color: var(--trace-ink);
  font-size: inherit;
  font-weight: 500;
  list-style: none;
  user-select: none;
  transition: color .15s ease;
}
details.msg-trace > summary.trace-head:hover,
details.msg-trace[open] > summary.trace-head { --trace-ink: var(--text) }
.msg-trace summary::-webkit-details-marker { display: none }
details.msg-trace > summary.trace-head::before { content: none }
.msg-trace summary:focus-visible { outline: 2px solid var(--muted); outline-offset: 3px; }
/* A bare chevron in the label's colour: points along the line folded,
   down unfolded. */
.trace-chevron {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: .9rem;
  height: .9rem;
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
.trace-chevron::before {
  content: '';
  width: .32rem;
  height: .32rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateX(-1px) rotate(-45deg);
}
.trace-chevron:dir(rtl) { scale: -1 1 }
.msg-trace[open]:not(.is-folding) .trace-chevron { transform: rotate(90deg) }
/* The light that follows the spark along the label: the full ink passing
   over the header's own. Its edges are the header's ink, not a fixed grey,
   so an unfolded header -- in the full ink already -- keeps its colour
   while the spark runs instead of greying for a moment. */
.trace-label.is-sweep {
  background: linear-gradient(90deg, var(--trace-ink) 0 40%, var(--trace-glint) 50%, var(--trace-ink) 60% 100%) no-repeat;
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
/* Step count -- the shared .tab-count pill (base.css) at its own size,
   greyed: a soft tint of the header's ink in place of the accent, read
   when looked for and never pulling the eye. Its number on a roller: the
   old one leaves upwards as the new one comes in. */
.msg-trace summary .tab-count {
  position: relative;
  overflow: hidden;
  margin: 0;
  height: 1.15rem;
  background: color-mix(in srgb, var(--trace-ink) 14%, transparent);
  color: inherit;
  font-variant-numeric: tabular-nums;
}
.trace-num { display: block }
.trace-num-out { position: absolute; inset: 0; text-align: center; }
.trace-spark {
  position: absolute;
  top: 0;
  left: 0;
  width: 7px;
  height: 7px;
  margin-left: -3.5px;
  border-radius: 50%;
  background: var(--trace-glint);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--trace-glint) 14%, transparent), 0 0 10px 1px color-mix(in srgb, var(--trace-glint) 30%, transparent);
  pointer-events: none;
  opacity: 0;
}
/* Its comet tail. */
.trace-spark::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 50%;
  width: 24px;
  height: 2px;
  border-radius: 2px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--trace-glint) 60%, transparent));
}
.trace-spark:dir(rtl)::after { right: auto; left: 50%; scale: -1 1; }
/* Unfolded: the calls as a timeline hanging from the chevron (its centre
   sits .45rem in, the dots .8rem left of the text), the latest one lit. */
.msg-trace ol {
  list-style: none;
  margin: 0;
  padding: .2rem 0 .3rem;
  padding-inline-start: 1.25rem;
}
.msg-trace.is-moving > ol { overflow: hidden }
.msg-trace li {
  position: relative;
  padding: .2rem 0;
  line-height: 1.4;
  transition: color .15s ease;
}
/* Steps fade in one by one only while the list slides open (.is-moving,
   set by chat_steps.js). Not on every <li>: a live reply wipes its bubble
   on each streamed chunk and puts the block back, and a reinserted element
   replays its CSS animation -- an open list blinked on every chunk. */
.msg-trace.is-moving:not(.is-folding) li {
  animation: trace-step-in .34s cubic-bezier(.2, .8, .2, 1) both;
  animation-delay: calc(var(--i, 0) * 28ms);
}
.msg-trace li:hover { color: var(--text) }
.msg-trace li::before {
  content: '';
  position: absolute;
  inset-inline-start: calc(-.8rem - 3.5px);
  top: calc(.2rem + .7em - 3.5px);
  width: 7px;
  height: 7px;
  box-sizing: border-box;
  border-radius: 50%;
  border: 1.5px solid color-mix(in srgb, var(--muted) 55%, transparent);
  background: var(--bg);
  transition: opacity .2s ease, transform .45s cubic-bezier(.3, 1.6, .5, 1),
    background-color .3s ease, border-color .3s ease, box-shadow .3s ease;
}
/* The latest step's dot, filled. A new step takes the light over: the dot
   before it keeps it (.is-lit) until the drop lands on the new one, then
   fades back to a ring as the new one comes up. */
.msg-trace li:last-child::before,
.msg-trace li.is-lit::before {
  border-color: var(--muted);
  background: var(--muted);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--muted) 16%, transparent);
}
/* A step that has just come in on an unfolded list: its dot waits for the
   drop running down the line and pops up where it lands (chat_steps.js
   takes the class off). No transition into the wait -- the dot is never
   shown first and then hidden. */
.msg-trace li.is-new::before {
  opacity: 0;
  transform: scale(.2);
  transition: none;
}
.msg-trace li:not(:last-child)::after {
  content: '';
  position: absolute;
  inset-inline-start: calc(-.8rem - .5px);
  top: calc(.2rem + .7em + 6px);
  bottom: calc(-.2rem - .7em + 6px);
  width: 1px;
  background: var(--border2);
  /* Drawn on downwards behind the drop to a new step (chat_steps.js). */
  transform-origin: top;
}
/* The drop: a bead of the spark's light with a short tail up the line,
   from the chevron down to the new step's dot; and the ring that spreads
   where the light sets off and where it lands. */
.trace-drop,
.trace-ring {
  position: absolute;
  top: 0;
  left: 0;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
}
.trace-drop {
  width: 5px;
  height: 5px;
  margin: -2.5px 0 0 -2.5px;
  background: var(--trace-glint);
  box-shadow: 0 0 0 2.5px color-mix(in srgb, var(--trace-glint) 14%, transparent), 0 0 8px 1px color-mix(in srgb, var(--trace-glint) 28%, transparent);
}
.trace-drop::after {
  content: '';
  position: absolute;
  bottom: 50%;
  left: 50%;
  width: 1.5px;
  height: 18px;
  border-radius: 2px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--trace-glint) 65%, transparent));
}
.trace-ring {
  width: 7px;
  height: 7px;
  margin: -3.5px 0 0 -3.5px;
  box-sizing: border-box;
  border: 1.5px solid var(--trace-glint);
}
@keyframes trace-step-in {
  from { opacity: 0; transform: translateY(-3px) }
  to   { opacity: 1; transform: none }
}
@media (prefers-reduced-motion: reduce) {
  .msg-trace li { animation: none }
  .msg-trace li::before { transition: none }
  .trace-chevron { transition: none }
}

/* The agent's work plan -- the "plan" reply style (chat_plan.js): the task
   list the agent keeps for a bigger job, above the reply's words, filling
   in live. No card: like the minimal style's steps block it stands straight
   on the chat background -- a header line (chevron, title, a short bar that
   fills, the count) and the items under it, hanging from the chevron on a
   hairline. One line per item: a ring waiting, a spinning ring under way
   (its words in the full ink; under them, on a rail of the accent, what
   the agent says and the call it runs), a bare tick done (the accent: blue
   on the light theme, green on the dark -- never the success green, which
   reads as off-palette on the light theme; Mart 5.11.2026),
   a dashed ring and struck words dropped; a subtask set in. The bar fills in the accent, while
   the plan runs and once it is carried out; a plan carried out folds
   into its header when the turn is over. A sibling of the reply's body,
   never repainted with it, so its transitions run whole.
   :not(.panel-section) outranks settings.css's rules for every other
   <details> -- its padding, margin, border and background -- which load
   after this file. */
details.msg-plan:not(.panel-section) {
  --plan-gap: .65rem;
  --plan-mark: 1.05rem;
  /* The ring's line, one weight for every ring of the plan -- the one
     spinning under way, the grey ones waiting and dropped: the panel's
     other spinners' 2px, as heavy as the tick (Mart 19.11.2026: at 1.5px
     the spinning ring read thinner than everything else that moves). */
  --plan-ring: 2px;
  /* The hairline the items hang from, under the chevron's centre, and how
     far in from it their marks stand. */
  --plan-rail: .45rem;
  --plan-indent: .8rem;
  /* The ring stands centred on its item's first line (line-height 1.45). */
  --plan-mark-top: calc((1.45em - var(--plan-mark)) / 2);
  /* One width from the first item to the last: the reply's bubble sizes
     to its content, and the plan would widen it as the answer streams in.
     Nearly the whole reading column (--content-w), so an item keeps to
     one line (Mart 4.11.2026). */
  box-sizing: border-box;
  width: 48rem;
  max-width: 100%;
  margin: .1rem 0 1rem;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--text);
  font-size: .9rem;
  line-height: 1.45;
}
/* Only as wide as its content, so the hover and click area stays on the
   header instead of the whole column. */
details.msg-plan:not(.panel-section) > summary.plan-head,
details.msg-plan:not(.panel-section)[open] > summary.plan-head {
  display: flex;
  width: fit-content;
  max-width: 100%;
  align-items: center;
  gap: .55rem;
  margin: 0;
  padding: .15rem 0;
  border-radius: 6px;
  color: var(--text);
  font-size: .86rem;
  font-weight: 600;
  list-style: none;
  cursor: pointer;
  user-select: none;
}
details.msg-plan:not(.panel-section) > summary.plan-head::before { content: none }
.msg-plan summary::-webkit-details-marker { display: none }
.msg-plan summary:focus-visible { outline: 2px solid var(--muted); outline-offset: 3px; }
.plan-chevron {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: .9rem;
  height: .9rem;
  color: var(--muted);
  transition: transform .3s cubic-bezier(.2, .8, .2, 1);
}
.plan-chevron::before {
  content: '';
  width: .32rem;
  height: .32rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateX(-1px) rotate(-45deg);
}
.plan-chevron:dir(rtl) { scale: -1 1 }
.msg-plan[open] > summary .plan-chevron { transform: rotate(90deg) }
.plan-icon { flex: none; font-size: .95rem; line-height: 1 }
/* A short bar between the title and the count, not a rule across the
   column: read at a glance, never the widest thing on the line. */
.plan-bar {
  flex: none;
  width: 6.75rem;
  height: 4px;
  overflow: hidden;
  border-radius: 4px;
  background: color-mix(in srgb, var(--muted) 20%, transparent);
}
.plan-fill {
  position: relative;
  display: block;
  width: 0;
  height: 100%;
  overflow: hidden;
  border-radius: inherit;
  background: var(--accent);
  transition: width .6s cubic-bezier(.2, .8, .2, 1), background-color .4s ease;
}
.msg-plan.is-finished .plan-fill { background: var(--accent) }
/* While the plan runs a soft light passes along what is filled; once it is
   carried out the bar glows once. */
.msg-plan.is-live:not(.is-finished) .plan-fill::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, #fff 45%, transparent), transparent);
  transform: translateX(-100%);
  animation: plan-sheen calc(var(--beat) * 2) ease-in-out infinite;
}
.msg-plan.is-live:not(.is-finished) .plan-fill:dir(rtl)::after { animation-direction: reverse }
.msg-plan.is-live.is-finished .plan-bar { animation: plan-done 1.1s ease-out }
.plan-count {
  color: var(--muted);
  font-size: .8rem;
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
/* The items on their hairline. The list itself has no padding above or
   below -- the items carry their own air -- so opening and folding slide
   its height from and to nothing (chat_plan.js). */
.plan-items {
  list-style: none;
  margin: .4rem 0 0;
  margin-inline-start: calc(var(--plan-rail) - .5px);
  padding: 0;
  padding-inline-start: var(--plan-indent);
  /* The hairline fades out at its foot, as the live thread does (Mart
     6.11.2026). */
  border-inline-start: 1px solid var(--border2);
  border-image: linear-gradient(to bottom, var(--border2) 0 calc(100% - 2.25rem), transparent) 1;
}
.msg-plan.is-moving > ol { overflow: hidden }
.plan-item {
  position: relative;
  display: grid;
  grid-template-columns: var(--plan-mark) minmax(0, 1fr);
  column-gap: var(--plan-gap);
  align-items: start;
  padding: .3rem 0;
  padding-inline-start: calc(var(--depth, 0) * 1.25rem);
}
.plan-item.is-leaving { overflow: hidden; pointer-events: none }
.plan-mark {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  box-sizing: border-box;
  width: var(--plan-mark);
  height: var(--plan-mark);
  margin-top: var(--plan-mark-top);
  border: var(--plan-ring) solid color-mix(in srgb, var(--muted) 60%, transparent);
  border-radius: 50%;
  color: transparent;
  transition: background-color .3s ease, border-color .3s ease, color .25s ease;
}
/* The tick spans the whole mark, its ring included: once the item is done
   the ring fades out and the bare tick is all that is left. It reaches
   out by the ring's own line, so the tick stays centred whatever its
   width. */
.plan-mark svg {
  position: absolute;
  top: calc(-1 * var(--plan-ring));
  left: calc(-1 * var(--plan-ring));
  width: calc(100% + 2 * var(--plan-ring));
  height: calc(100% + 2 * var(--plan-ring));
}
.plan-mark .plan-tick { stroke-dasharray: 14; stroke-dashoffset: 0 }
.plan-text {
  grid-column: 2;
  grid-row: 1;
  min-width: 0;
  overflow-wrap: anywhere;
  transition: color .3s ease;
}
/* The item's state in words, for a screen reader; the mark says it on screen. */
.plan-state {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.plan-item[data-status="completed"] .plan-mark {
  border-color: transparent;
  color: var(--accent);
}
.plan-item[data-status="completed"] .plan-text { color: var(--muted) }
/* The item under way spins only while the turn runs (.is-live). Once the
   turn is over -- or the reply is read again -- an item the agent left
   "under way" stands still: a plain accent ring, where the plan stopped,
   never a spinner that says it still works (Mart 5.11.2026: the plan stayed
   in an odd state after the reply was done). */
.plan-item[data-status="in_progress"] .plan-mark {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
}
.msg-plan.is-live .plan-item[data-status="in_progress"] .plan-mark {
  border-color: color-mix(in srgb, var(--accent) 28%, transparent);
  border-top-color: var(--accent);
  animation: plan-spin calc(var(--beat) * .5) linear infinite;
}
.msg-plan.is-live .plan-item[data-status="in_progress"] .plan-text { font-weight: 600 }
.plan-item[data-status="cancelled"] .plan-mark { border-style: dashed }
.plan-item[data-status="cancelled"] .plan-text {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-color: color-mix(in srgb, var(--muted) 70%, transparent);
}
/* The work under way, under its item (else under the list): what the
   agent says and the call it runs. No box and no wash (Mart 6.11.2026):
   a thread of the accent hangs from the spinning ring's centre down along
   them, so ring and thread read as one -- live work, told apart from a
   done item's grey words at a glance. Its height only grows while its
   item is under way (chat_plan.js), so the items under it stay put. */
.plan-live {
  grid-column: 2;
  box-sizing: border-box;
  min-width: 0;
  margin-top: .15rem;
  overflow: hidden;
}
.msg-plan.is-live .plan-item:has(> .plan-live)::before {
  content: '';
  position: absolute;
  inset-inline-start: calc(var(--depth, 0) * 1.25rem + var(--plan-mark) / 2 - .5px);
  /* A breath under the spinning ring, so the thread never touches it
     (Mart 6.11.2026: ~4-5px further off). */
  top: calc(.3rem + var(--plan-mark-top) + var(--plan-mark) + .55rem);
  bottom: .55rem;
  width: 1px;
  border-radius: 1px;
  background: linear-gradient(to bottom, color-mix(in srgb, var(--accent) 75%, transparent),
                                         color-mix(in srgb, var(--accent) 8%, transparent));
  pointer-events: none;
}
/* What the agent says it is doing: its own newest words as they stream,
   a shade under the item's ink. The whole paragraph shows, none of it
   hidden: the box grows with it, smoothly (chat_plan.js). .is-clipped
   fades the top only if a max-height ever caps it. */
.plan-say {
  --say-lh: 1.25rem;
  position: relative;
  overflow: hidden;
  color: color-mix(in srgb, var(--text) 74%, transparent);
  font-size: .84rem;
  line-height: var(--say-lh);
  overflow-wrap: anywhere;
}
.plan-say-text { display: block }
.plan-say.is-clipped {
  -webkit-mask-image: linear-gradient(to bottom, rgb(0 0 0 / .2), #000 .65rem);
          mask-image: linear-gradient(to bottom, rgb(0 0 0 / .2), #000 .65rem);
}
/* The call running now, under the words: its kind's emoji (in colour, as
   the card's own 📋 -- Mart 6.11.2026), the kind's short name, a
   hairline, and what it works on in code type, cut at the column's edge
   (chat_plan.js planNowParts). The accent stays on the ring and its
   thread. While the call runs a light passes over what it works on; once
   it is over the line stays, quieter (.is-idle), until the next call
   takes its place. */
.plan-now {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: .78rem;
  line-height: 1.35rem;
  white-space: nowrap;
  transition: opacity .3s ease;
}
.plan-say + .plan-now { margin-top: .2rem }
/* One column wide for every emoji, so the names under each other line up. */
.plan-now-icon {
  flex: none;
  width: 1rem;
  font-size: .8rem;
  line-height: 1;
  text-align: center;
}
.plan-now-name { flex: none; font-weight: 500 }
/* The hairline between the name and the call; read aloud as ": ". */
.plan-now-sep {
  flex: none;
  width: 1px;
  height: .75rem;
  margin-inline: .1rem;
  overflow: hidden;
  background: var(--border2);
  color: transparent;
  font-size: 0;
}
.plan-now-detail {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: var(--mono);
  font-size: .74rem;
  unicode-bidi: plaintext;
  background: linear-gradient(90deg, var(--muted) 0 40%, var(--text) 50%, var(--muted) 60% 100%) no-repeat;
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: tool-step-shimmer calc(var(--beat) * 2) linear infinite;
}
.plan-now:dir(rtl) .plan-now-detail { animation-direction: reverse }
.plan-now-more {
  flex: none;
  color: color-mix(in srgb, var(--muted) 70%, transparent);
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  unicode-bidi: isolate;
}
.plan-now.is-idle { opacity: .72 }
.plan-now.is-idle .plan-now-detail {
  animation: none;
  background: none;
  color: var(--muted);
}
.msg-plan > .plan-live {
  margin-top: .4rem;
  margin-inline-start: calc(var(--plan-rail) + .5px + var(--plan-indent) + var(--plan-mark) + var(--plan-gap));
}
.plan-more {
  margin-top: .35rem;
  padding-inline-start: calc(var(--plan-rail) + .5px + var(--plan-indent) + var(--plan-mark) + var(--plan-gap));
  color: var(--muted);
  font-size: .8rem;
}
/* The ring turns on `rotate`, never `transform`: the pop an item gives as
   it comes under way (chat_plan.js paintRow, a scale) rides on transform,
   and on the same property it would stop the turn for its 320 ms and snap
   it back -- the jolt Mart saw 6.11.2026. Its phase keeps the page's clock
   (chat_plan.js joinSpin), so a ring drawn again turns on where it was. It
   turns twice a beat (beat.js), in double time: once a beat dragged
   (Mart 17.11.2026: "liiga aeglaseks"), and at half a beat its arc still
   passes the top on every downbeat, as the dots stand highest and the
   stripes shine -- and once more on the off-beat between. */
@keyframes plan-spin { from { rotate: 0deg } to { rotate: 360deg } }
@keyframes plan-sheen {
  0%        { transform: translateX(-100%) }
  60%, 100% { transform: translateX(100%) }
}
@keyframes plan-done {
  from { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent) }
  to   { box-shadow: 0 0 0 6px color-mix(in srgb, var(--accent) 0%, transparent) }
}
@media (prefers-reduced-motion: reduce) {
  .msg-plan.is-live .plan-item[data-status="in_progress"] .plan-mark { animation: none; border-color: var(--accent) }
  .plan-now-detail { animation: none; background: none; color: var(--muted) }
  .plan-fill, .plan-mark, .plan-text, .plan-chevron { transition: none }
  .msg-plan.is-live:not(.is-finished) .plan-fill::after { display: none; animation: none }
  .msg-plan.is-live.is-finished .plan-bar { animation: none }
}

/* Detailed style's tool calls -- one line per call, posted live as the agent
   works (the panel twin of Telegram's tool bubbles) -- straight on the chat
   background like the minimal style's steps block: no card, greys only, the
   emoji in a column of its own on the prose's left edge. Calls that follow
   one another sit closer together than the log's messages, with no line
   between them. Each call is one line, cut short at the column's edge; a
   click on it unfolds the whole call under it (.step-full, below). No time
   under a call: the message before it has one.
   The step's geometry as variables -- line, padding, gap to the next call,
   the emoji column -- so the drop of light (.is-arriving) meets the emoji wherever the font puts them. */
.msg-row.toolstep {
  --step-lh: 1.35rem;
  --step-pad: .125rem;
  --step-gap: .3rem;
  --step-icon: 1.1rem;
  /* The emoji's centre: across from the prose's edge, down from the top. */
  --step-x: calc(.15rem + var(--step-icon) / 2);
  --step-y: calc(var(--step-pad) + var(--step-lh) / 2);
  /* The thread keeps this far clear of each emoji's centre. */
  --step-clear: .6rem;
  /* How long the drop takes from the call before (none on the first). */
  --step-lead: 0s;
  --step-ink: var(--muted);
  --step-glint: var(--text);
  align-self: flex-start;
  align-items: flex-start;
  max-width: 100%;
}
.msg-row.toolstep + .msg-row.toolstep {
  margin-top: calc(var(--step-gap) - .65rem);
  --step-lead: .3s;
}
.msg-row.toolstep > .timestamp { display: none }
.msg.toolstep {
  position: relative;
  padding: var(--step-pad) .15rem;
  background: none;
  border: 0;
  border-radius: 0;
  color: var(--step-ink);
  font-size: .82rem;
  line-height: var(--step-lh);
  transition: color .15s ease;
}
.msg-row.toolstep:hover { --step-ink: var(--text) }
.msg.toolstep .body { min-width: 0 }
.msg.toolstep .step > .step-line { gap: .5rem }
.msg.toolstep .step-icon {
  position: relative;
  flex: none;
  width: var(--step-icon);
  text-align: center;
  font-size: .95em;
}
/* No standing line between the calls: the emoji column alone lines them
   up. A call coming in, live (chat_steps.js arriveToolStep), in one
   movement: a drop of light runs down from the call before, the emoji pops
   up where it lands and a ring spreads from it, the words wipe in after --
   the minimal list's drop and ring. The first call of a run has no call
   before it: its emoji pops at once. The drop is a faint hairline, no glow:
   the ring is what marks the new call, the drop only leads the eye to it
   (Mart, 2026-10-26: a bright drop caught the eye more than the call). */
.msg-row.toolstep + .msg-row.toolstep.is-arriving > .msg::before {
  content: '';
  position: absolute;
  inset-inline-start: calc(var(--step-x) - .75px);
  top: var(--step-y);
  width: 1.5px;
  height: 9px;
  margin-top: -9px;
  border-radius: 2px;
  background: linear-gradient(180deg, transparent, color-mix(in srgb, var(--step-glint) 45%, transparent));
  pointer-events: none;
  opacity: 0;
  animation: tool-step-drop .36s cubic-bezier(.5, 0, .25, 1) both;
}
.msg-row.toolstep.is-arriving .step-icon {
  animation: tool-step-pop .5s cubic-bezier(.3, 1.6, .5, 1) var(--step-lead) both;
}
.msg-row.toolstep.is-arriving .step-icon::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: var(--step-icon);
  height: var(--step-icon);
  margin: calc(var(--step-icon) / -2) 0 0 calc(var(--step-icon) / -2);
  box-sizing: border-box;
  border: 1.5px solid var(--step-glint);
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  animation: tool-step-ring .7s cubic-bezier(.2, .7, .3, 1) calc(var(--step-lead) + .06s) both;
}
.msg-row.toolstep.is-arriving .step-text {
  animation: tool-step-words .5s cubic-bezier(.2, .8, .2, 1) calc(var(--step-lead) + .1s) both;
}
.msg-row.toolstep.is-arriving:dir(rtl) .step-text { animation-name: tool-step-words-rtl }
/* A call still running: a light passing over its words, the minimal
   header's sweep on a loop, until the call is done (chat.js / live_turn.js
   take .is-running off). The light comes in once the words are in
   (.is-arriving gone) and runs on the panel beat (beat.js), in step with
   the plan line and every other loop: a delay of its own would put it out
   of step. Until then the words stand in plain ink, the first third of the
   gradient. */
.msg-row.toolstep.is-running .step-text {
  background: linear-gradient(90deg, var(--step-ink) 0 40%, var(--step-glint) 50%, var(--step-ink) 60% 100%) no-repeat;
  background-size: 300% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.msg-row.toolstep.is-running:not(.is-arriving) .step-text {
  animation: tool-step-shimmer calc(var(--beat) * 2) linear infinite;
}
.msg-row.toolstep.is-running:not(.is-arriving):dir(rtl) .step-text { animation-direction: reverse }
@keyframes tool-step-drop {
  /* Its head from where the thread leaves the emoji before to the top of
     this one: the call before sits a line and a gap up. */
  from { opacity: 0; transform: translateY(calc(var(--step-clear) - var(--step-y) * 2 - var(--step-gap))) }
  30%  { opacity: .8 }
  70%  { opacity: .8 }
  to   { opacity: 0; transform: translateY(calc(4px - var(--step-clear))) }
}
@keyframes tool-step-pop {
  from { opacity: 0; transform: scale(.3) }
  45%  { opacity: 1 }
  to   { opacity: 1; transform: none }
}
@keyframes tool-step-ring {
  from { opacity: .55; transform: scale(.6) }
  to   { opacity: 0; transform: scale(2) }
}
@keyframes tool-step-words {
  from { opacity: 0; transform: translateX(-4px); clip-path: inset(0 100% 0 0) }
  to   { opacity: 1; transform: none; clip-path: inset(0) }
}
@keyframes tool-step-words-rtl {
  from { opacity: 0; transform: translateX(4px); clip-path: inset(0 0 0 100%) }
  to   { opacity: 1; transform: none; clip-path: inset(0) }
}
@keyframes tool-step-shimmer {
  from { background-position: 100% 0 }
  to   { background-position: 0 0 }
}
@media (prefers-reduced-motion: reduce) {
  .msg-row.toolstep .msg::before,
  .msg-row.toolstep .step-icon,
  .msg-row.toolstep .step-icon::after,
  .msg-row.toolstep .step-text { animation: none }
}
/* A tool step's code-like args preview — the shell command, file path or
   search pattern (paintStepLine) — in the code font, in the tool bubble and
   the minimal-style step list alike. */
.step-detail {
  font-family: var(--mono);
  font-size: .95em;
  overflow-wrap: anywhere;
}
/* A step -- a tool bubble's body, a line of the steps block -- is one line:
   the emoji, the words cut short at the column's edge, and a quiet chevron
   where there is more to read (chat_steps.js paintStepLine). A click, or
   Enter or Space, unfolds the whole call under it -- the command with its
   every line, the code, the full path -- in a soft box with a copy button;
   the next folds it back. The chevron shows only where the line has more:
   a whole call longer than its preview, a line cut short (.is-foldable,
   pointed at), or one open now. */
.step > .step-line {
  display: flex;
  align-items: baseline;
  gap: .4rem;
  min-width: 0;
  border-radius: 4px;
}
.step > .step-line > .step-text {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.step.has-more > .step-line,
.step.is-foldable > .step-line,
.step.is-open > .step-line { cursor: pointer }
.step > .step-line:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* The trace header's chevron, smaller and fainter: along the line folded,
   down unfolded. */
.step-more {
  flex: none;
  display: none;
  place-items: center;
  align-self: center;
  width: .8rem;
  height: .8rem;
  color: var(--muted);
  opacity: .55;
  transition: transform .2s cubic-bezier(.2, .8, .2, 1), opacity .15s ease;
}
.step-more::before {
  content: '';
  width: .28rem;
  height: .28rem;
  border: solid currentColor;
  border-width: 0 1.5px 1.5px 0;
  transform: translateX(-1px) rotate(-45deg);
}
.step-more:dir(rtl) { scale: -1 1 }
.step.has-more > .step-line > .step-more,
.step.is-foldable > .step-line > .step-more,
.step.is-open > .step-line > .step-more { display: inline-grid }
.step > .step-line:hover > .step-more,
.step.is-open > .step-line > .step-more { opacity: .9 }
.step.is-open > .step-line > .step-more { transform: rotate(90deg) }
/* The whole call, unfolded: hung under the words in a tool bubble, under
   the line in the steps block. Its own height is animated open and shut
   (chat_steps.js _toggleStep), hence the clip. */
.step-full {
  position: relative;
  overflow: hidden;
  margin: .3rem 0 .35rem;
}
.msg.toolstep .step-full { margin-inline-start: calc(var(--step-icon) + .5rem) }
.step-code {
  max-height: 18rem;
  overflow: auto;
  padding: .55rem .7rem;
  padding-inline-end: 2.2rem;
  border: 1px solid color-mix(in srgb, var(--muted) 14%, transparent);
  border-radius: 8px;
  background: color-mix(in srgb, var(--muted) 8%, transparent);
  color: var(--text);
  font-family: var(--mono);
  font-size: .78rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  tab-size: 4;
  scrollbar-width: thin;
  cursor: text;
}
.step-code.is-prose { font-family: inherit; font-size: .82rem; }
/* Out of the way until the block is pointed at, or the button reached by
   the keyboard; a tick in the accent for a moment once copied. */
.step-copy {
  position: absolute;
  top: .35rem;
  inset-inline-end: .35rem;
  display: grid;
  place-items: center;
  width: 1.6rem;
  height: 1.6rem;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s ease, background-color .15s ease, color .15s ease;
}
.step-copy svg { width: .95rem; height: .95rem; }
.step-full:hover .step-copy,
.step-copy:focus-visible,
.step-copy.is-done { opacity: 1 }
.step-copy:hover {
  background: color-mix(in srgb, var(--muted) 14%, transparent);
  color: var(--text);
}
.step-copy:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.step-copy.is-done { color: var(--accent) }
@media (hover: none) {
  .step-copy { opacity: .7 }
}
@media (prefers-reduced-motion: reduce) {
  .step-more,
  .step-copy { transition: none }
}

/* Phase 2A activity-line — short header above a streaming assistant
   bubble that tells the user why nothing new arrives (the reconnecting
   note). Reasoning is not shown here: the thinking dots already say
   the reply is still coming. Tool calls are not repeated here either:
   detailed style posts each one as its own bubble.
   Subtle by design: this is meta-info, not part of the reply itself.
   Removed by chat.js when the stream finishes / aborts / errors. */
.activity-line {
  font-size: .82em;
  color: var(--muted);
  margin-bottom: .35em;
  font-style: italic;
  letter-spacing: .01em;
}
.activity-line[hidden] { display: none; }
/* The wait before the turn reaches the agent (chat.js setWaitNotice): a
   model switch that drags on past ten seconds. A quiet chip with a small
   spinner instead of an italic line -- it is a status, not a sentence. */
.activity-line.is-wait {
  display: inline-flex;
  align-items: center;
  gap: .5em;
  padding: .3em .75em;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-control);
  font-style: normal;
  line-height: 1.35;
}
.activity-line.is-wait[hidden] { display: none; }
.activity-line.is-wait::before {
  content: '';
  flex: none;
  width: .8em;
  height: .8em;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  opacity: .7;
  animation: wait-spin var(--beat) linear infinite;
}
@keyframes wait-spin { to { rotate: 360deg } }
@media (prefers-reduced-motion: reduce) {
  .activity-line.is-wait::before { animation: none; }
}

/* The way back to the newest message (#jumpToEnd in index.html) — a small
   round chevron that fades in once the reader has scrolled up and away
   from the end of the log, in a stream or not, and fades out again at the
   bottom (chat.js toggles .is-visible).

   Anchored to #form (`position: relative`) rather than the scroll
   container, so it stays put while #log scrolls and hangs off the
   composer's real top edge: the textarea auto-grows, so a fixed offset
   from the view's bottom would end up under a tall draft. It keeps to the
   right edge of the conversation column — the same expression #form uses
   for its side padding — and floats just above the composer card.
   Dressed like the composer, muted until hovered: a hint, not a call.
   The short rise on show is covered by reduced-motion. */
.jump-to-end {
  position: absolute;
  /* Centred over the composer: left + right 0 with a fixed width lets the
     auto margins split the slack. Not left: 50% + translateX — transform
     is already the show / hide animation below. */
  left: 0;
  right: 0;
  margin: 0 auto;
  /* #form's top edge is .35rem above the card (its padding-top), so this
     leaves half a rem of air between the chevron and the card. */
  bottom: calc(100% + .15rem);
  z-index: 5;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border2);
  border-radius: 50%;
  background: var(--composer-bg);
  color: var(--muted);
  cursor: pointer;
  box-shadow: var(--composer-shadow);
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .18s ease-out, transform .18s ease-out, color .15s, border-color .15s;
}
.jump-to-end.is-visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}
.jump-to-end:hover {
  color: var(--text);
  border-color: var(--outline-hover);
  background: var(--composer-bg);
}
/* The global button:active translateY(1px) would replace the show
   transform; the press nudge is the same distance, so keep it as is. */
.jump-to-end.is-visible:active { transform: translateY(1px) }
.jump-to-end svg { width: 16px; height: 16px; display: block }

@media (prefers-reduced-motion: reduce) {
  .jump-to-end { transition: opacity .18s ease-out, color .15s, border-color .15s; transform: none }
  .jump-to-end.is-visible { transform: none }
}

@media (max-width: 680px) {
  /* Slightly smaller on phones. */
  .jump-to-end { width: 32px; height: 32px }
}

/* ── Attachments ─────────────────────────────────────────────────────
   Composer-side: attach button + pending tray + drop overlay.
   Bubble-side: image previews + file download chips that render the
   ![](url) markdown and [[SEND_FILE:...]] markers chat.js extracts. */

/* Attach button (📎). Same height as the textarea so the row stays
   visually centred; transparent so it doesn't pull attention away from
   the primary Send action. */
.attach-btn {
  flex: 0 0 auto;
  height: 40px;
  width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 9px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted2);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s;
}
.attach-btn:hover {
  color: var(--accent);
  background: var(--bg3, color-mix(in srgb, var(--text) 4%, transparent));
  border-color: var(--border);
}
.attach-btn svg { width: 18px; height: 18px; display: block }
/* Override the global button:active translateY(1px) — the icon button
   already nudges via background, no need to slide. */
.attach-btn:active { transform: translateY(1px) }

/* Mic button — same shape and behaviour as attach-btn, plus a pulsing
   record state and a subtle busy-spinner ring while transcribing. */
.mic-btn {
  flex: 0 0 auto;
  height: 40px;
  width: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border-radius: 9px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--muted2);
  cursor: pointer;
  transition: color .15s, background .15s, border-color .15s, box-shadow .15s;
}
.mic-btn:hover {
  color: var(--accent);
  background: var(--bg3, color-mix(in srgb, var(--text) 4%, transparent));
  border-color: var(--border);
}
.mic-btn svg { width: 18px; height: 18px; display: block }
.mic-btn:active { transform: translateY(1px) }

/* Recording state: tinted background + pulsing red dot under the icon. */
.mic-btn.is-recording {
  color: var(--err);
  background: color-mix(in srgb, var(--err) 12%, transparent);
  border-color: color-mix(in srgb, var(--err) 35%, transparent);
  animation: mic-pulse var(--beat) ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--err) 45%, transparent) }
  50%      { box-shadow: 0 0 0 6px color-mix(in srgb, var(--err) 0%, transparent) }
}

/* Busy state — transcribing, waiting on Groq. Spinner ring around the
   icon so the user can tell the click was registered. */
.mic-btn.is-busy {
  color: var(--accent);
  pointer-events: none;
  position: relative;
}
.mic-btn.is-busy::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  border: 2px solid transparent;
  border-top-color: var(--accent);
  animation: mic-spin var(--beat) linear infinite;
}
@keyframes mic-spin { to { transform: rotate(360deg) } }
@keyframes mic-busy-fade { 50% { opacity: .35 } }
@media (prefers-reduced-motion: reduce) {
  /* The red tint alone says the mic is recording; the busy ring fades
     instead of spinning, so the wait still reads as work under way. */
  .mic-btn.is-recording { animation: none }
  .mic-btn.is-busy::after { animation: mic-busy-fade calc(var(--beat) * 2) ease-in-out infinite }
}
@media (max-width: 540px) {
  /* 36px in a 40px bottom-aligned row: 2px lift keeps it optically centred. */
  .mic-btn { width: 36px; height: 36px; margin-bottom: 2px }
}

/* Pending-attachment tray: chips listing files queued for the next send.
   Sits above the composer-row when populated; hidden
   when empty so the composer keeps its compact layout. */
.attach-tray {
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
  padding: .25rem 0 .5rem;
  margin: 0;
}
.attach-tray[hidden] { display: none }
.attach-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  max-width: 220px;
  padding: .25rem .35rem .25rem .5rem;
  border-radius: 8px;
  background: var(--bg3, color-mix(in srgb, var(--text) 5%, transparent));
  border: 1px solid var(--border);
  font-size: .8rem;
  color: var(--text);
  /* A click opens the file before it is sent: an image in the viewer, any
     other file saved (chat_attach.js _openChip). */
  cursor: pointer;
}
.attach-chip:hover { border-color: var(--border2) }
.attach-chip:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px }
.attach-chip-thumb {
  width: 26px;
  height: 26px;
  border-radius: 5px;
  object-fit: cover;
  flex-shrink: 0;
  background: rgba(0,0,0,.3);
}
.attach-chip-icon {
  width: 26px;
  height: 26px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  background: rgba(0,0,0,.3);
  font-size: 1rem;
  flex-shrink: 0;
}
.attach-chip-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  flex: 1;
  min-width: 0;
}
.attach-chip-remove {
  flex-shrink: 0;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted2);
  cursor: pointer;
  font-size: 1.1rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.attach-chip-remove:hover { color: var(--danger-action); background: color-mix(in srgb, var(--text) 6%, transparent) }
/* In-flight upload: a fill bar grows behind the chip content (width from
   --upload-pct, set by chat_attach.js on every xhr progress event) and a
   tabular percent sits next to the name. isolation + z-index:-1 keeps the
   fill above the chip background but under the label/thumbnail. */
.attach-chip.is-uploading {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  border-color: var(--accent-dim);
}
.attach-chip.is-uploading::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: var(--upload-pct, 0%);
  background: var(--accent-soft, color-mix(in srgb, var(--accent) 12%, transparent));
  transition: width .15s linear;
  z-index: -1;
  pointer-events: none;
}
.attach-chip-pct {
  flex-shrink: 0;
  min-width: 2.6em;
  text-align: right;
  font-size: .72rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}
.attach-chip.is-error { border-color: var(--danger-action); color: var(--danger-action) }

/* Drop overlay — shown while the user is dragging files over the chat
   view. Pointer events off until visible so it doesn't interfere with
   normal clicks; chat.js toggles .is-visible on dragenter / off on
   dragleave + drop. */
.drop-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  background: color-mix(in srgb, var(--bg2) 88%, transparent);
  border: 2px dashed var(--accent);
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity .12s ease-out;
}
.drop-overlay.is-visible { opacity: 1 }
.drop-overlay-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .5rem;
  color: var(--accent);
  font-weight: 600;
  font-size: 1.05rem;
}
.drop-overlay-icon { font-size: 2.5rem }

/* Bubble-side rendering — both user and assistant attachments share
   the same visual recipe so the chat reads symmetrically. A notice's text
   (.job-card-body) and a pin opened in the pin list (.pin-list-full) are
   the same renderMarkdown() output and take the same recipe: without it a
   notice's screenshot showed at its full size, 2400 px on a 360 px phone,
   and pushed the view sideways past the screen (14.10).
   The `a.att-file` selector deliberately includes the element type so
   its specificity (0,3,1) matches `.msg.assistant .body a` (0,3,1) and
   wins by source order — without `a.` the cascade would re-apply the
   assistant link rule's `text-decoration: underline` to file chips. The
   twins (0,2,1) outrank their own link rules (0,1,1) outright. */
.msg .body .att-image,
.job-card-body .att-image,
.pin-list-full .att-image {
  display: block;
  max-width: 100%;
  max-height: 280px;
  margin: .35em 0;
  border-radius: 8px;
  border: 1px solid var(--border);
  cursor: zoom-in;
  transition: border-color .12s ease, filter .12s ease;
}
/* A picture the server could not hand over just now (local-api restarting
   after a panel update: 502) waits for its next try (chat_media.js
   _mediaRetry) as a quiet blank box, not the browser's broken-image mark
   or a "not available" chip it would be wrong about (Mart 6.11.2026). */
.msg .body img.att-image.is-waiting,
.job-card-body img.att-image.is-waiting,
.pin-list-full img.att-image.is-waiting {
  width: 12rem;
  height: 7rem;
  object-position: -9999px 0;
  color: transparent;
  background: color-mix(in srgb, var(--muted) 10%, transparent);
  cursor: default;
}
/* The thumbnail is a control: it opens the full-screen viewer
   (image_lightbox.js), so it answers hover and keyboard focus like one. */
.msg .body img.att-image:hover,
.job-card-body img.att-image:hover,
.pin-list-full img.att-image:hover {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  filter: brightness(1.05);
}
.msg .body img.att-image:focus-visible,
.job-card-body img.att-image:focus-visible,
.pin-list-full img.att-image:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
/* A voice reply or an audio file: the browser draws its player 300 px wide
   whatever the room, past a notice card on a 320 px phone (14.10). */
.msg .body .att-audio,
.job-card-body .att-audio,
.pin-list-full .att-audio { max-width: 100% }
.msg .body a.att-file,
.job-card-body a.att-file,
.pin-list-full a.att-file {
  display: inline-flex;
  align-items: center;
  gap: .45rem;
  margin: .25em .25em .25em 0;
  padding: .4rem .7rem;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--bg3, color-mix(in srgb, var(--text) 4%, transparent));
  text-decoration: none;
  color: var(--text);
  font-size: .88rem;
  font-weight: 500;
  line-height: 1.2;
  transition: border-color .12s ease, background-color .12s ease, color .12s ease;
}
.msg .body a.att-file:hover,
.msg .body a.att-file:focus-visible,
.job-card-body a.att-file:hover,
.job-card-body a.att-file:focus-visible,
.pin-list-full a.att-file:hover,
.pin-list-full a.att-file:focus-visible {
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  background: color-mix(in srgb, var(--accent) 10%, var(--bg3, color-mix(in srgb, var(--text) 4%, transparent)));
  color: var(--text);
  text-decoration: none;
  outline: none;
}
.msg .body a.att-file:active,
.job-card-body a.att-file:active,
.pin-list-full a.att-file:active {
  transform: translateY(1px);
}
.msg .body a.att-file::before,
.job-card-body a.att-file::before,
.pin-list-full a.att-file::before { content: "📎"; opacity: .85; font-size: .95em }

/* Inline error chip for MEDIA links whose backing file no longer exists.
   Replaces the broken-image icon / 404 download dialog with a clear
   "agent referenced a missing file" hint. Triggered by chat.js onerror
   handlers (img/video/audio) and the click-time HEAD-check on att-file. */
.msg .body .att-missing,
.job-card-body .att-missing,
.pin-list-full .att-missing {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  margin: .25em .25em .25em 0;
  padding: .35rem .6rem;
  border-radius: 8px;
  border: 1px solid var(--err);
  background: color-mix(in srgb, var(--err) 8%, transparent);
  color: var(--err);
  font-size: .82rem;
  font-weight: 500;
}
.msg .body .att-missing::before,
.job-card-body .att-missing::before,
.pin-list-full .att-missing::before { content: "⚠️"; opacity: .9 }

/* Screenshot chip — .att-missing geometry, neutral tone: the image WAS
   sent and seen by the agent, only the old-session preview is gone, so
   the red error styling (and its ⚠️) would read as a fault. The 📷 lives
   in the chip text itself (chat.js _screenshotChip). */
.msg .body .att-screenshot {
  border-color: var(--outline-row);
  background: var(--surface-hover);
  color: var(--muted);
}
.msg .body .att-screenshot::before { content: none }

@media (max-width: 680px) {
  .attach-btn { width: 36px; height: 36px }
  .attach-chip { max-width: 160px; font-size: .75rem }
  .msg .body .att-image,
  .job-card-body .att-image,
  .pin-list-full .att-image { max-height: 200px }
}

/* ── Pinned messages (message_pins.js) ──────────────────────────────── */

/* A message's caption line: its time and its pin. Reserved on every user /
   assistant row, so neither the time (it appears a minute in) nor the pin
   (it shows on hover) moves the conversation when it turns up. */
.msg-meta {
  display: flex;
  align-items: center;
  gap: .1rem;
  min-height: 16px;
}
.msg-row.user .msg-meta { flex-direction: row-reverse }

/* Shared conversations (shared_chat.js, sessions.js sessionLogEntry):
   somebody else's message sits on the far side with their name over it, like
   a group chat; while their turn runs, a line over the composer says who is
   being answered. */
.msg-row.user.is-other { align-self: flex-start; align-items: flex-start; }
.msg-row.user.is-other .msg.user {
  border-radius: 16px 16px 16px 4px;
  border-color: var(--border);
}
.msg-row.user.is-other .msg-meta { flex-direction: row }
.msg-author {
  font-size: .72rem;
  font-weight: 600;
  color: var(--muted2);
  margin-bottom: 3px;
}
.shared-turn {
  font-size: .78rem;
  color: var(--muted2);
  padding: 0 .25rem .35rem;
}
.shared-turn::before {
  content: '\25CF';
  color: var(--accent);
  margin-right: .4rem;
  animation: shared-turn-pulse var(--beat) ease-in-out infinite;
}
@keyframes shared-turn-pulse { 50% { opacity: .35 } }
@media (prefers-reduced-motion: reduce) {
  .shared-turn::before { animation: none }
}
/* A message that waits for the agent (chat_busy.js): the head of the
   composer itself, because sending it is that field's business. One card
   with the input row under it: the same ground a shade greyer, the row's
   line and corners carried on, a hairline (the row's own top line) between.
   It comes sliding up out of the composer: the lane (.busy-turn) opens from
   nothing while the head keeps its size, so its lower part is still behind
   the row's top edge and the log gives way at the same pace. */
.busy-turn {
  display: grid;
  grid-template-rows: 1fr;
  overflow: hidden;
  animation: busy-turn-rise .3s cubic-bezier(.2, .7, .2, 1);
}
.busy-turn[hidden] { display: none }
@keyframes busy-turn-rise {
  from { grid-template-rows: 0fr }
}
/* What slides: it keeps the head's whole height in a lane of any height. It
   has no padding or line of its own, which a lane could not close over. */
.busy-turn-slide {
  align-self: start;
  min-height: 0;
}
.busy-turn-in {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .55rem .8rem;
  padding: .7rem .8rem .7rem 1rem;
  font-size: .88rem;
  color: var(--text);
  background:
    linear-gradient(color-mix(in srgb, currentColor 6%, transparent), color-mix(in srgb, currentColor 6%, transparent)),
    var(--composer-bg);
  border: 1px solid var(--border2);
  border-bottom: 0;
  border-radius: 18px 18px 0 0;
  transition: border-color .15s ease;
}
#form:has(.busy-turn:not([hidden])) .composer-row {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
}
#form:has(.composer-row:focus-within) .busy-turn-in { border-color: var(--outline-hover) }
.busy-turn-text { flex: 1 1 14rem; min-width: 0 }
/* The choices take the rest of the line, or a line of their own, so that
   Cancel stands at the far end either way. */
.busy-turn-actions {
  flex: 1 1 auto;
  display: flex;
  flex-wrap: wrap;
  gap: .35rem;
}
.busy-turn-cancel {
  margin-inline-start: auto;
  font-weight: 500;
  color: var(--muted);
  background: transparent;
  border-color: transparent;
}
.busy-turn-cancel:disabled:hover { border-color: transparent }
.busy-turn.is-nudged .busy-turn-in { animation: busy-turn-nudge .35s ease-in-out }
@keyframes busy-turn-nudge {
  25% { transform: translateX(-3px) }
  75% { transform: translateX(3px) }
}
@media (prefers-reduced-motion: reduce) {
  .busy-turn,
  .busy-turn.is-nudged .busy-turn-in { animation: none }
}
/* A 24px target in the caption's 16px line: the margins give the height back. */
.msg-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  margin: -4px 0;
  padding: 0;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted2);
  cursor: pointer;
  box-shadow: none;
  opacity: 0;
  pointer-events: none;
  transition: opacity .15s, color .15s;
}
.msg-pin svg { width: 13px; height: 13px; display: block; fill: none }
/* A touch screen keeps :hover on whatever was tapped last: there a tap shows
   the pin (.tools-open, message_pins.js) and the next hides it. */
@media (hover: hover) {
  .msg-row:hover .msg-pin { opacity: .7; pointer-events: auto }
  .msg-pin:hover { opacity: 1; color: var(--text); background: var(--shell-hover) }
}
.msg-row.tools-open .msg-pin,
.msg-pin:focus-visible { opacity: .7; pointer-events: auto }
.msg-pin:active { transform: none }
.msg-row.is-pinned .msg-pin { opacity: 1; pointer-events: auto; color: var(--accent) }
.msg-row.is-pinned .msg-pin svg { fill: currentColor }
/* No pin where there is nothing to pin yet: an error card, a reply still
   being written (it has no time until it is done), a chat whose first turn
   has not named its conversation. */
.msg-row.error .msg-pin,
.msg-meta:not(:has(> .timestamp)) > .msg-pin,
#log.pins-off .msg-pin { display: none }

/* The bar: the pin shown now, hanging from the main bar over the top of the
   log like the pinned bar of a messenger, in the composer's card. Where the main
   bar has room for it beside the session's title (message_pins.js
   measures; a long title narrows it from that side) it rises into the main
   bar itself, a little slimmer, and the log keeps its top. */
.pin-bar {
  position: absolute;
  top: calc(100% + .45rem);
  left: 0;
  right: 0;
  z-index: 4;
  width: min(var(--content-w), calc(100% - 2rem));
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: .1rem;
  padding: .2rem .25rem .2rem .2rem;
  background: color-mix(in srgb, var(--composer-bg) 90%, transparent);
  -webkit-backdrop-filter: blur(10px) saturate(1.05);
          backdrop-filter: blur(10px) saturate(1.05);
  border: 1px solid var(--border2);
  border-radius: 12px;
  box-shadow: var(--composer-shadow);
}
.pin-bar[hidden] { display: none }
.pin-bar.is-raised {
  top: 50%;
  translate: 0 -50%;
  padding-block: .1rem;
}
.pin-bar.is-raised .pin-bar-main { padding-block: .2rem }
/* It is the chat's: on any other page it steps out of sight with the title. */
.shell:not([data-main="chat"]) .pin-bar { visibility: hidden }
.pin-bar-main {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .3rem .5rem;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
  box-shadow: none;
}
.pin-bar-main:hover { background: var(--shell-hover); color: var(--text); border: 0 }
.pin-bar-main:active { transform: none }
.pin-bar-icon { flex: none; width: 16px; height: 16px; color: var(--accent); fill: currentColor }
.pin-bar-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.pin-bar-label {
  color: var(--accent);
  font-size: .7rem;
  font-weight: 600;
  line-height: 1.2;
  letter-spacing: .02em;
}
.pin-bar-count {
  color: var(--muted);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}
.pin-bar-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: .84rem;
  line-height: 1.3;
}
.pin-bar-list,
.pin-bar-unpin {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted2);
  cursor: pointer;
  box-shadow: none;
}
.pin-bar-list[hidden] { display: none }
.pin-bar-list:hover,
.pin-bar-unpin:hover { background: var(--shell-hover); color: var(--text); border: 0 }
.pin-bar-list:active,
.pin-bar-unpin:active { transform: none }
.pin-bar-list svg,
.pin-bar-unpin svg { width: 16px; height: 16px; display: block }
/* While the bar shows, the conversation starts below it. */
.view[data-view="chat"].has-pin-bar #log { padding-top: 4.1rem }
/* Compact layout (the sidebar a drawer, shell.css): the room under the title
   is tighter. The bar hangs right at the main bar's edge, and the chat rises
   by as much into the main bar's empty lower edge (it has no background of
   its own), so the conversation shows that much closer to the title. */
@media (max-width: 820px) {
  .pin-bar { top: 100% }
  .view[data-view="chat"] { margin-top: -.45rem }
}

/* The message a pin led to lights up for a moment. */
@keyframes pin-flash {
  0%, 40% {
    background-color: var(--accent-soft);
    box-shadow: 0 0 0 4px var(--accent-soft);
  }
}
.msg-row.pin-flash .msg { animation: pin-flash 1.6s ease-out }
@media (prefers-reduced-motion: reduce) {
  .msg-row.pin-flash .msg { animation: none; box-shadow: 0 0 0 2px var(--accent-soft) }
}

/* Every pin of the conversation, under the bar. A pin whose message is not
   on the page opens its text in place. */
.menu-pop.pin-list {
  max-width: calc(100vw - 16px);
  max-height: 60vh;
  gap: 2px;
}
.pin-list-item {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  border-radius: 8px;
}
.pin-list-item:hover { background: var(--shell-hover) }
.pin-list-open {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: .4rem .55rem;
  border: 0;
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: start;
  cursor: pointer;
  box-shadow: none;
}
.pin-list-open:hover { background: transparent; color: var(--text); border: 0 }
.pin-list-open:active { transform: none }
.pin-list-who {
  color: var(--muted);
  font-size: .64rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.pin-list-text {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: .83rem;
  line-height: 1.35;
}
.pin-list-unpin {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  margin-block-start: .25rem;
  margin-inline-end: .2rem;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--muted2);
  cursor: pointer;
  box-shadow: none;
}
.pin-list-unpin svg { width: 14px; height: 14px; display: block }
.pin-list-text[hidden] { display: none }
.pin-list-unpin:hover {
  background: color-mix(in srgb, var(--text) 10%, transparent);
  color: var(--text);
  border: 0;
}
.pin-list-unpin:active { transform: none }
/* The opened pin's whole text, on a line of its own under the pin. It
   shrinks by its side margins: a full-width line that could not shrink
   stuck out of the list by them, and the list scrolled sideways (14.10). */
.pin-list-full {
  flex: 1 1 100%;
  max-height: 40vh;
  overflow-y: auto;
  margin: 0 .55rem .5rem;
  padding: .45rem .65rem;
  border-inline-start: 2px solid var(--accent);
  color: var(--text);
  font-size: .85rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}

/* An e-mail that started the conversation (chat_mail.js): a trusted sender's
   mail, handed to the agent by its mailbox. Nobody typed it here, so it is a
   card of its own, not the reader's bubble. */
.msg.user.from-mail {
  background: transparent;
  color: var(--text);
  border-color: transparent;
  padding: 0;
  max-width: 100%;
}
/* Inside it the e-mail is the card every e-mail of a conversation is
   (.mail-card, below). A reply's opening (the reader answers an e-mail,
   mail_reply.js) stacks three things: the e-mail, the reply's form, and the
   reader's own words in their bubble's look. */
.chat-mail { display: flex; flex-direction: column; gap: .7rem; text-align: left }
.chat-mail .mail-card-slot,
.chat-mail .mail-draft,
.mail-reply-stage .mail-card-slot,
.mail-reply-stage .mail-draft { margin: 0 }
/* An e-mail is as wide as the conversation's column, whoever's row it
   stands in (Mart, 2026-11-14): the row and the bubble that hold one stretch
   to it, so every card of a conversation has the same width. */
.msg-row:has(.mail-card-slot, .mail-draft, .chat-mail) { align-self: stretch; max-width: 100% }
.msg-row:has(.mail-card-slot, .mail-draft, .chat-mail) > .msg {
  align-self: stretch;
  max-width: 100%;
  /* No inset of the bubble's own: a card in a reply and one in the reader's
     row share their edges to the pixel. */
  padding-inline: 0;
  border-inline-width: 0;
}
.chat-mail-words {
  align-self: flex-end;
  max-width: 100%;
  padding: .55rem .85rem;
  border-radius: 16px 16px 4px 16px;
  background: var(--bubble-user);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.chat-mail-words[hidden] { display: none }
/* The same two before the reader's first message: the stage of a new chat
   that answers an e-mail. */
.mail-reply-stage { display: flex; flex-direction: column; gap: .7rem; width: 100%; margin: 0 0 1rem; text-align: left }
/* One that went and, under it, the e-mails that answered it
   (mail_draft_card.js): one column of cards, as far apart as the stage's. */
.mail-thread { display: flex; flex-direction: column; gap: .7rem; width: 100% }
.mail-thread .mail-card-slot { margin: 0 }

/* An e-mail named in a message (mail_view.js): in the id's place a chip with
   an envelope and the start of the subject; a click opens the e-mail. Its
   colours come from the text around it, so it sits in the reader's bubble
   and in a reply alike. Spelled out as button.mail-ref: the panel's plain
   `button` has a radius, a hover border and a press nudge of its own. In the
   composer's field the same chip is a span (chat_composer.js). Its corners
   are the panel's small ones, like a code word's or a file's -- not a pill
   (Mart, 2026-11-14). */
button.mail-ref,
span.mail-ref {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  max-width: min(100%, 18rem);
  margin: 0 .1rem;
  padding: .02rem .5rem .02rem .4rem;
  vertical-align: bottom;
  border: 1px solid color-mix(in srgb, currentColor 22%, transparent);
  border-radius: 6px;
  background: color-mix(in srgb, currentColor 7%, transparent);
  color: inherit;
  font: inherit;
  font-size: .9em;
  line-height: 1.5;
  cursor: pointer;
  transform: none;
  transition: border-color .15s, background .15s;
}
button.mail-ref:hover,
button.mail-ref:focus-visible,
span.mail-ref:hover {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
}
button.mail-ref:active { transform: none }
.mail-ref-icon { display: inline-flex; flex: none; opacity: .75 }
.mail-ref-icon svg { width: 14px; height: 14px }
.mail-ref-label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600 }

/* One e-mail in a view of its own (mail_view.js), in a modal: the subject as
   the page's heading, the sender with an initial for a face, the text on a
   sheet of its own, the attachments as files to take. */
.mail-view { display: flex; flex-direction: column; gap: .95rem; padding: .35rem 0 .5rem; text-align: left }
.mail-view-subject { margin: 0; font-size: 1.3rem; line-height: 1.3; font-weight: 700; letter-spacing: -.01em; overflow-wrap: anywhere }
.mail-view-who { display: flex; flex-wrap: wrap; align-items: flex-start; gap: .3rem .75rem }
.mail-view-avatar {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  color: var(--accent);
  font-size: 1.05rem;
  font-weight: 700;
  text-transform: uppercase;
}
.mail-view-names { flex: 1 1 12rem; min-width: 0; display: flex; flex-direction: column; gap: .12rem }
.mail-view-name { font-size: .95rem; font-weight: 600; overflow-wrap: anywhere }
.mail-view-verified {
  display: inline-block;
  margin-left: .45rem;
  padding: 0 .4rem;
  border-radius: 5px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-size: .68rem;
  font-weight: 600;
  vertical-align: middle;
}
.mail-view-line { font-size: .8rem; color: var(--muted); overflow-wrap: anywhere }
.mail-view-date { flex: none; padding-top: .15rem; font-size: .78rem; color: var(--muted); white-space: nowrap }
.mail-view-outside { margin: 0; font-size: .76rem; color: var(--warn) }
/* The text stands on the view's own ground, under a hairline -- no box and
   no grey of its own (Mart, 2026-11-15). */
.mail-view-body {
  padding: .95rem 0 .1rem;
  border-top: 1px solid var(--border2);
  font-size: .92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* The e-mail quoted under an answer is folded away behind a small grey pill
   of three dots, as mail programs do; a click shows it, grey and behind a
   line, and a second one hides it again (Mart, 2026-11-15). */
button.mail-quote-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 1.1rem;
  min-height: 0;
  margin: .7rem 0 0;
  padding: 0;
  border: 1px solid var(--border2);
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  line-height: 0;
  cursor: pointer;
  transition: background-color .15s, color .15s;
}
button.mail-quote-toggle svg { width: 16px; height: 16px }
button.mail-quote-toggle:hover,
button.mail-quote-toggle.is-open { background: color-mix(in srgb, currentColor 10%, transparent); color: var(--text) }
button.mail-quote-toggle:active { transform: none }
.mail-view-quote { margin-top: .7rem; color: var(--muted) }
.mail-quote-who { margin-bottom: .4rem; font-size: .8rem; white-space: normal }
.mail-quote-text { padding-inline-start: .8rem; border-inline-start: 2px solid var(--border2) }
.mail-view-cut, .mail-view-gone { margin: 0 }
.mail-view-files { display: flex; flex-wrap: wrap; gap: .45rem }
a.mail-view-file {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  max-width: 100%;
  padding: .32rem .7rem;
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text);
  font-size: .82rem;
  text-decoration: none;
  transition: border-color .15s;
}
a.mail-view-file:hover { border-color: var(--accent) }
/* In a reply's bubble the assistant's link rule (0,3,1) would colour and
   underline the chip: this outweighs it. */
.msg .body .mail-card a.mail-view-file { color: var(--text); text-decoration: none }
.mail-view-file-icon { display: inline-flex; flex: none; color: var(--muted) }
.mail-view-file-icon svg { width: 14px; height: 14px }
.mail-view-file-name { min-width: 0; overflow-wrap: anywhere }
.mail-view-file-size { flex: none; color: var(--muted); font-size: .74rem }
.mail-view-file-names { margin: 0; font-size: .8rem; color: var(--muted); overflow-wrap: anywhere }
/* Under the e-mail, what can be done with it: answering first and filled,
   the agent's turn beside it, and at the far end the two quiet ones --
   unread, delete (which asks once more in place). */
.mail-view-foot { display: flex; flex-direction: column; gap: .55rem; text-align: left }
.mail-view-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .45rem }
.mail-view-actions-gap { flex: 1 1 .5rem }
button.mail-view-btn {
  transform: none;
}
button.mail-view-btn:active { transform: none }
.mail-view-btn-icon { display: inline-flex; flex: none }
.mail-view-btn-icon svg { width: 16px; height: 16px }
/* The e-mail's pin: in the view's head, beside its title, no taller than the
   title's line. Filled while the e-mail is pinned. */
button.mail-view-pin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.7rem;
  height: 1.7rem;
  margin-block: -.35rem;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transform: none;
  transition: background .15s, color .15s;
}
button.mail-view-pin:hover { background: var(--surface-hover-strong); color: var(--text) }
button.mail-view-pin:active { transform: none }
button.mail-view-pin:disabled { opacity: .6; cursor: default }
button.mail-view-pin.is-on { color: var(--accent) }
button.mail-view-pin.is-on svg path:first-child { fill: currentColor }
button.mail-view-pin svg { width: 17px; height: 17px }

/* An e-mail as a card of a conversation (mail_view.js mailCardOf): the one
   that started it, the one being answered, one the agent sent. The draft's
   card below is its sibling: the same frame and letterhead, the same sheet. */
.mail-card-slot { display: block; margin: .55rem 0 .35rem; white-space: normal }
.mail-card {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--bg, transparent);
  color: var(--text);
  overflow: hidden;
  text-align: left;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.mail-card.is-loading { min-height: 5.5rem; opacity: .5 }
.mail-card.is-empty { padding: .7rem .9rem }
.mail-card-head {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .9rem;
  border-bottom: 1px solid var(--border2);
  background: color-mix(in srgb, currentColor 4%, transparent);
  font-size: .76rem;
  color: var(--muted);
}
/* One that was sent has the same grey letterhead: its badge says it, with a
   tick, and nothing on the card is accent-coloured (Mart, 2026-11-15). */
.mail-card-icon { display: inline-flex }
.mail-card-icon svg { width: 16px; height: 16px }
.mail-card-kind { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; letter-spacing: .01em }
/* When it came or went: at the far end of the letterhead. */
.mail-card-time { flex: none; margin-inline-start: auto; white-space: nowrap; font-variant-numeric: tabular-nums }
.mail-card-state {
  flex: none;
  padding: .05rem .45rem;
  border: 1px solid var(--border2);
  border-radius: 5px;
  font-size: .7rem;
}
.mail-card-state::before { content: '\2713'; margin-inline-end: .28rem }
.mail-card-main.mail-view { gap: .7rem; padding: .85rem .9rem .8rem }
.mail-card .mail-view-subject { font-size: 1.04rem }
.mail-card .mail-view-avatar {
  width: 2.15rem;
  height: 2.15rem;
  background: color-mix(in srgb, currentColor 8%, transparent);
  color: var(--muted);
  font-size: .92rem;
}
/* As on the draft's form: the text on the card's own white, the hairline
   over it from edge to edge of the card. */
.mail-card .mail-view-body {
  margin-inline: -.9rem;
  padding: .8rem .9rem .1rem;
  border-top: 1px solid color-mix(in srgb, currentColor 8%, transparent);
}
/* An e-mail the agent drafted (mail_draft_card.js): drawn in its reply as
   the e-mail it will be -- a letterhead of sender, recipients and subject, the
   text on a sheet of its own -- with Send under it. Once it went, it is the
   card above (.mail-card.is-sent), like every e-mail of a conversation. */
.mail-draft { display: block; margin: .55rem 0 .35rem; white-space: normal }
/* The place a draft had before the agent changed it: its card is further
   down now, in the reply that changed it (mail_draft_card.js). */
.mail-draft.is-moved { display: none }
.mail-draft-card {
  box-sizing: border-box;
  width: 100%;
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  background: var(--bg, transparent);
  color: var(--text);
  overflow: hidden;
  text-align: left;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .05);
}
.mdc-head {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .5rem .9rem;
  border-bottom: 1px solid var(--border2);
  background: color-mix(in srgb, currentColor 4%, transparent);
  font-size: .76rem;
  color: var(--muted);
}
/* Grey like the letterhead of every e-mail: the one coloured thing on a
   draft is its Send button (Mart, 2026-11-15). */
.mdc-icon { display: inline-flex }
.mdc-icon svg { width: 16px; height: 16px }
.mdc-kind { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; letter-spacing: .01em }
.mdc-state {
  flex: none;
  padding: .05rem .45rem;
  border: 1px solid var(--border2);
  border-radius: 5px;
  font-size: .7rem;
}
.mdc-fields { display: flex; flex-direction: column; padding: .35rem .9rem .25rem }
.mdc-field {
  display: flex;
  align-items: baseline;
  gap: .6rem;
  padding: .3rem 0;
  border-bottom: 1px solid color-mix(in srgb, currentColor 8%, transparent);
  font-size: .84rem;
}
.mdc-field:last-child { border-bottom: 0 }
.mdc-label { flex: 0 0 6.4rem; color: var(--muted); font-size: .78rem }
.mdc-value { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere }
.mdc-subject .mdc-value { font-weight: 650; font-size: .92rem }
/* The text stands on the card's own white, under a hairline: a page, not a
   grey box (Mart, 2026-11-15). */
.mdc-body {
  padding: .8rem .9rem .95rem;
  border-top: 1px solid color-mix(in srgb, currentColor 8%, transparent);
  font-size: .92rem;
  line-height: 1.6;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
/* A waiting draft is a form: its fields read as the text they hold. One
   the pointer is over turns a shade of grey; the one in hand shows nothing
   but the caret -- no frame, no accent, no ground of its own
   (Mart, 2026-11-15: "the cursor is enough"). */
input.mdc-input {
  box-sizing: border-box;
  /* Out by its padding and its border, so the text it holds starts where a
     plain value of the row above does. */
  width: calc(100% + .45rem + 1px);
  margin: -.22rem 0 -.22rem calc(-.45rem - 1px);
  padding: .2rem .45rem;
  border: 1px solid transparent;
  border-radius: 6px;
  background: transparent;
  color: inherit;
  font: inherit;
  transition: background .15s;
}
.mdc-value:has(> input.mdc-input) { display: block }
input.mdc-input:hover:not(:focus) { background: color-mix(in srgb, currentColor 4%, transparent) }
input.mdc-input:focus,
input.mdc-input:focus-visible {
  outline: none;
  box-shadow: none;
  border-color: transparent;
  background: transparent;
}
/* The sheet is the panel's rich text field (rich_text_field.js), the
   composer's own: a box as tall as its text, bold and italic shown as typed. */
.mdc-body-input {
  position: relative;
  display: block;
  box-sizing: border-box;
  width: 100%;
  min-height: 8.5rem;
  margin: 0;
  cursor: text;
}
.mdc-body-input:hover,
.mdc-body-input:focus,
.mdc-body-input:focus-visible {
  outline: none;
  box-shadow: none;
}
.mdc-body-input.is-empty::before {
  content: attr(placeholder);
  position: absolute;
  color: var(--muted);
  opacity: .8;
  pointer-events: none;
}
.mdc-body .md-code,
.mail-view-body .md-code {
  font-family: var(--mono);
  font-size: .9em;
}
/* A file held over the form: let go, it is added to the e-mail. */
.mail-draft-card.is-drop {
  outline: 2px dashed var(--accent);
  outline-offset: 2px;
}
/* The files that go along: the foot's first row, over Send, under the line
   that parts the foot from the text (Mart, 2026-11-15). */
.mdc-files { flex: 1 0 100%; display: flex; flex-wrap: wrap; gap: .4rem; padding-bottom: .15rem }
.mdc-file {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  max-width: 100%;
  padding: .2rem .55rem;
  border: 1px solid var(--border2);
  border-radius: 8px;
  font-size: .78rem;
}
.mdc-file-icon { display: inline-flex; flex: none; color: var(--muted) }
.mdc-file-icon svg { width: 13px; height: 13px }
.mdc-file-name { min-width: 0; overflow-wrap: anywhere }
a.mdc-file-name { color: inherit; text-decoration: none }
a.mdc-file-name:hover { text-decoration: underline }
/* In a reply's bubble the assistant's link rule (0,3,1) would colour and
   underline a file's name: these outweigh it. */
.msg .body .mail-draft-card a.mdc-file-name { color: inherit; text-decoration: none }
.msg .body .mail-draft-card a.mdc-file-name:hover { text-decoration: underline }
.mdc-file-size { flex: none; color: var(--muted); font-size: .72rem }
/* One still on its way up. */
.mdc-file.is-adding { opacity: .55 }
button.mdc-file-remove {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.15rem;
  height: 1.15rem;
  margin-inline-end: -.25rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: .95rem;
  line-height: 1;
  cursor: pointer;
  transform: none;
  transition: background .15s, color .15s;
}
button.mdc-file-remove:hover {
  background: color-mix(in srgb, currentColor 14%, transparent);
  color: var(--text);
}
button.mdc-file-remove:active { transform: none }
.mdc-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: .5rem .8rem;
  padding: .65rem .9rem;
  border-top: 1px solid var(--border2);
}
.mdc-send-icon { display: inline-flex }
.mdc-send-icon svg { width: 15px; height: 15px }
/* The clip beside Send adds a file: as tall as Send, flat and grey like
   the bin -- no frame, a faint ground under the pointer. */
button.mdc-attach {
  align-self: stretch;
  min-width: 2.3rem;
  transform: none;
}
button.mdc-attach:active { transform: none }
button.mdc-attach svg { width: 16px; height: 16px }
/* The bin at the far end gives the draft up; it asks once more in place,
   widening to the question. */
button.mdc-discard {
  margin-inline-start: auto;
  transform: none;
}
button.mdc-discard:active { transform: none }
.mdc-discard-icon { display: inline-flex; flex: none }
.mdc-discard-icon svg { width: 16px; height: 16px }
.mdc-discard-text:empty { display: none }
.mdc-hint, .mdc-note { font-size: .78rem; color: var(--muted) }
.mail-draft-card.is-empty .mdc-note { margin: 0; padding: .7rem .9rem }
.mdc-error { flex: 1 0 100%; margin: 0; font-size: .8rem; color: var(--warn) }
.mail-draft-card.is-replaced .mdc-fields,
.mail-draft-card.is-replaced .mdc-body,
.mail-draft-card.is-replaced .mdc-files { opacity: .55 }
