/* The frame: sidebar, header, stage, status line.
 *
 * The window paints its own caption, so the sidebar and the header both reach
 * the top edge. The native caption buttons (minimise, maximise, close) are the
 * operating system's and float over the header's right end; the header keeps
 * clear of them by --caption-w, which Python measures.
 */

#app {
  --caption-w: 0px;
  display: flex;
  height: 100vh;
  width: 100vw;
  overflow: hidden;
  background: var(--bg);
}

/* ---- sidebar ------------------------------------------------------------ */
#sidebar {
  position: relative;
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  flex: none;
  background: var(--sidebar);
  border-right: 1px solid var(--border);
  transition: width var(--dur-slow) var(--ease-out);
  overflow: hidden;
  z-index: 3;
}
#app.sidebar-dragging #sidebar { transition: none; }
/* What the sidebar holds is laid out at its full width while it slides open,
   and uncovered: words that ran to a new width every frame cost a slow
   laptop the frames, and a title ellipsised again and again flickered. (The
   bar of chats picked sits inside margins of its own.) */
#sidebar > .expanded-only:not(.bulk-bar) { min-width: calc(var(--sidebar-w) - 1px); }
#app.collapsed #sidebar { width: var(--rail-w); }

#sidebar-resize {
  position: relative;
  width: 0;
  z-index: 4;
}
#sidebar-resize::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -3px;
  width: 6px;
  cursor: col-resize;
}
#app.collapsed #sidebar-resize { display: none; }

.brand {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  height: var(--header-h);
  padding: 0 12px 0 12px;
  flex: none;
}
/* The name, in plain letters, centred on the sidebar whatever the buttons
   either side of it measure. */
.brand .brand-name {
  position: absolute;
  inset: 0 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
}
.wordmark {
  font-family: var(--display);
  font-size: 21px;
  font-weight: 620;
  letter-spacing: -0.015em;
  line-height: 1;
  font-variation-settings: "SOFT" 30, "WONK" 0;
}
.brand .brand-report { color: var(--text3); margin-right: -4px; }
.brand .brand-report:hover { color: var(--text); }
.brand .ibtn { margin-right: 2px; }
/* The sidebar's own button is a plain panel until the pointer is on it; then
   an arrow slides in to say which way it goes. */
.panel-toggle .icon path:nth-of-type(2) {
  opacity: 0;
  transform: translateX(1.5px);
  transition: opacity var(--dur-fast) var(--ease), transform var(--dur) var(--ease-out);
}
.panel-toggle.opens .icon path:nth-of-type(2) { transform: translateX(-1.5px); }
.panel-toggle:is(:hover, :focus-visible) .icon path:nth-of-type(2) { opacity: 1; transform: none; }

.side-actions {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 2px 10px 6px;
  flex: none;
}

.nav {
  display: flex;
  align-items: center;
  gap: 9px;
  height: 32px;
  padding: 0 10px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: var(--ui-size);
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}
.nav .icon { width: 17px; height: 17px; color: var(--text2); }
.nav:hover { background: var(--surface-hover); }
.nav:active { transform: scale(0.99); }
.nav .hint { margin-left: auto; color: var(--text3); font-size: 12px; }
.nav.primary { position: relative; font-weight: 550; }
.nav .label { overflow: hidden; text-overflow: ellipsis; }
.nav.current { background: var(--selection-strong); }

/* New chat is filled only on a new chat: a field of amber tiles (shell.js)
   that fades in under the words. */
.amber-fill {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  border-radius: inherit;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease), filter var(--dur-fast) var(--ease);
}
:is(.nav, .ibtn).primary > :not(.amber-fill) { position: relative; }
/* Wider than the sidebar can be dragged (shell.js), so opening or dragging it
   never cuts the tiles again. */
.nav.primary .amber-fill { right: auto; width: 440px; }
:is(.nav, .ibtn).primary.current { background: transparent; color: var(--primary-text, var(--accent-text)); }
:is(.nav, .ibtn).primary.current .icon { color: var(--primary-text, var(--accent-text)); }
:is(.nav, .ibtn).primary.current .amber-fill { opacity: 1; }
:is(.nav, .ibtn).primary.current:hover .amber-fill { filter: brightness(1.06); }
/* A slight edge round the tiles, the accent's own deeper tone, and nothing
   along the top. */
:is(.nav, .ibtn).primary.current::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--primary-pressed, var(--accent-pressed)) 60%, transparent);
}

.side-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 10px 22px;
  scrollbar-gutter: stable;
  /* Titles fade out above the strip, not cut by it. A narrow column (speed.md rule 6). */
  -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent calc(100% - 2px));
  mask-image: linear-gradient(to bottom, #000 calc(100% - 24px), transparent calc(100% - 2px));
}
.side-scroll::-webkit-scrollbar { width: 8px; }
/* The list and, in Mosaics, the open mosaic's map share one place
   (css/mosaics.css slides between them). */
.side-panes {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template: minmax(0, 1fr) / minmax(0, 1fr);
}
.side-panes > * { grid-area: 1 / 1; min-height: 0; min-width: 0; }

.group { margin-top: 6px; }
.group-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  height: 30px;
  padding: 10px 12px 4px;
  border: 0;
  background: var(--sidebar);
  color: var(--text3);
  font-size: 12px;
  font-weight: 600;
  text-align: left;
  transition: color var(--dur-fast) var(--ease);
}
.group-head:hover { color: var(--text2); }
.group-head .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.group-head .count { color: var(--text3); font-weight: 500; opacity: 0; transition: opacity var(--dur-fast) var(--ease); }
.group-head .chev {
  margin-left: auto;
  width: 13px;
  height: 13px;
  opacity: 0;
  transform: rotate(90deg);
  transition: transform var(--dur) var(--ease), opacity var(--dur-fast) var(--ease);
}
.group-head:hover .chev, .group-head:hover .count { opacity: 1; }
.group.folded .group-head .chev { transform: rotate(0deg); opacity: 1; }

.group-head .head-action {
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  margin-left: auto;
  border-radius: 6px;
  color: var(--text3);
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.group-head .head-action .icon { width: 14px; height: 14px; }
.group-head:hover .head-action { opacity: 1; }
.group-head .head-action:hover { background: var(--surface-pressed); color: var(--text); }

/* Opened and closed by App.fold (js/moments.js), which moves them. */
.group.folded .group-rows { display: none; }

.row {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  height: 32px;
  padding: 0 4px 0 10px;
  margin: 1px 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text);
  font-size: var(--ui-size);
  text-align: left;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.row .title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.row:hover { background: var(--surface-hover); }
.row.selected { background: var(--selection-strong); font-weight: 550; }
/* In light the chosen chat is a clear step off the sidebar, whatever lies under it. */
html.light .row.selected, html.light .nav.current:not(.primary) { background: color-mix(in srgb, var(--text) 10%, transparent); }
html.light .row:hover:not(.selected), html.light .nav:not(.primary):hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.row .more {
  flex: none;
  width: 24px;
  height: 24px;
  opacity: 0;
  color: var(--text2);
  transition: opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.row:hover .more, .row .more.open, .row:focus-within .more { opacity: 1; }
.row .more:hover { background: var(--surface-pressed); }
.row.entering { animation: rise-in var(--dur-slow) var(--ease-out) both; }
/* Picked with Ctrl or Shift, for the bar at the foot of the list. */
.row.picked { background: var(--accent-wash); box-shadow: inset 2px 0 0 var(--accent); }
.row-empty { padding: 4px 12px 6px 30px; color: var(--text3); font-size: 12px; }
.group-head .folder-glyph { width: 13px; height: 13px; flex: none; opacity: 0.8; }
.group.folder .group-head .head-action { margin-left: auto; }
.group.folder .group-head .head-action + .chev { margin-left: 0; }
.bulk-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  margin: 0 10px 6px;
  padding: 4px 4px 4px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--raised);
  box-shadow: 0 6px 18px var(--shadow-cast);
  animation: rise-in var(--dur) var(--ease-out) both;
}
.bulk-bar[hidden] { display: none; }
.bulk-bar .count { font-size: 12px; font-weight: 600; color: var(--text2); font-variant-numeric: tabular-nums; }
.bulk-bar .spacer { flex: 1; }
.bulk-bar .ibtn.danger:hover { color: var(--danger); }
/* Unsent words waiting in this conversation's composer. */
.row .draft-mark { flex: none; display: inline-flex; margin-right: 7px; color: var(--accent); }
.row .draft-mark .icon { width: 13px; height: 13px; }
.row.selected .draft-mark { display: none; }
/* A chat writing its reply (the star loader), or one that finished while
   another was open (a dot): js/shell.js, chat/turns.py. */
.row .work-mark { flex: none; display: inline-flex; align-items: center; margin-left: 6px; color: var(--accent); }
.row .work-mark .star-loader { width: 13px; height: 13px; }
.row .work-mark.done { width: 7px; height: 7px; border-radius: 50%; background: var(--accent); margin-right: 3px; }
.row:hover .work-mark.done, .row.selected .work-mark.done { display: none; }
.row .work-mark.waiting { width: 7px; height: 7px; border-radius: 50%; border: 1.5px solid var(--accent); margin-right: 3px; }
.row .dot-tile { width: 8px; height: 8px; border-radius: 2px; margin-right: 9px; flex: none; }

.side-foot { flex: none; }
.side-foot .mosaic-strip { height: 6px; }

/* The collapsed rail: the same actions as glyphs. */
.rail {
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  height: 100%;
  padding: 11px 0 12px;
}
#app.collapsed .rail { display: flex; }
#app.collapsed .expanded-only { display: none !important; }
.rail .logo { width: 26px; height: 26px; margin-bottom: 8px; }
.rail .ibtn { width: 34px; height: 34px; border-radius: 10px; }
.rail .ibtn .icon { width: 17px; height: 17px; }
.rail .ibtn.primary { position: relative; overflow: hidden; }
.rail .spacer { flex: 1; }

.side-empty { padding-top: 30px; }

/* ---- main --------------------------------------------------------------- */
#main {
  position: relative;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
}

#header {
  display: flex;
  align-items: center;
  gap: 14px;
  height: var(--header-h);
  padding: 0 calc(var(--caption-w) + 12px) 0 16px;
  border-bottom: 1px solid var(--border);
  flex: none;
  position: relative;
  z-index: 2;
  background: var(--bg);
  container: header / inline-size;
}

.modes {
  position: relative;
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 10px;
  background: var(--sidebar);
  border: 1px solid var(--border);
  flex: none;
}
/* A face slides under the chosen tab (a transform); its glyph comes alive:
   Chat's lines are written in, Mosaics' tiles are set in the Star Window's colours. */
.modes::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 30px;
  height: calc(100% - 4px);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 1px 2px var(--shadow-soft), inset 0 0 0 1px color-mix(in srgb, var(--text) 6%, transparent);
  transition: transform var(--dur) var(--ease-out);
  pointer-events: none;
}
.modes[data-mode="project"]::before { transform: translateX(32px); }
.modes button {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text3);
  transition: color var(--dur) var(--ease), background var(--dur) var(--ease);
}
.modes button .icon { width: 16px; height: 16px; overflow: visible; }
.modes button:not(.on):hover { color: var(--text); background: var(--surface-hover); }
.modes button.on { color: var(--text); }
.modes button:active .icon { transform: scale(0.9); }
.modes button .icon { transition: transform var(--dur-fast) var(--ease); }
.modes button[data-mode="chat"] .icon path:nth-of-type(n+2) {
  transform-box: fill-box;
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  transition: transform var(--dur) var(--ease-out), opacity var(--dur-fast) var(--ease);
}
.modes button[data-mode="chat"].on .icon path:nth-of-type(n+2) { transform: none; opacity: 1; }
.modes button[data-mode="chat"].on .icon path:nth-of-type(2) { transition-delay: 60ms; }
.modes button[data-mode="chat"].on .icon path:nth-of-type(3) { transition-delay: 150ms; }
/* Only the three set tiles pop in about their own centres. The fourth, laid
   past the frame's edge, keeps its tilt about its own corner point
   (icons/mosaic.svg): a CSS origin would move that tilt and throw the tile
   out of place. */
.modes button[data-mode="project"] .icon rect:nth-of-type(-n+3) { transform-box: fill-box; transform-origin: center; }
.modes button[data-mode="project"].on .icon rect:nth-of-type(-n+3) { animation: mode-tile-set 380ms var(--ease-out) both; }
.modes button[data-mode="project"].on .icon rect:nth-of-type(2) { animation-delay: 70ms; }
.modes button[data-mode="project"].on .icon rect:nth-of-type(3) { animation-delay: 140ms; }
/* In the Star Window's colours on a light ground only: on a dark one they read
   muddy, so the chosen glyph stays plain white like Chat's (the user, 2026-10-10). */
html:not(.dark) .modes button[data-mode="project"].on .icon rect:nth-of-type(1) { fill: var(--tile-navy); }
html:not(.dark) .modes button[data-mode="project"].on .icon rect:nth-of-type(2) { fill: var(--tile-oxblood); }
html:not(.dark) .modes button[data-mode="project"].on .icon rect:nth-of-type(3) { fill: var(--tile-teal); }
html:not(.dark) .modes button[data-mode="project"].on .icon rect:nth-of-type(4) { fill: var(--tile-gold); }
@keyframes mode-tile-set {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.12); opacity: 1; }
  100% { transform: none; opacity: 1; }
}

/* Chat settings, beside the tabs: a quiet glyph with no frame of its own. Only
   a conversation has it; Home and a mosaic's own pages do not. */
.head-settings {
  position: relative;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin-left: -6px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text3);
  flex: none;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease);
}
.head-settings .icon { width: 16px; height: 16px; }
.head-settings:hover { color: var(--text); background: var(--surface-hover); }
.head-settings .dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 1.5px var(--bg);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease-out);
}
.head-settings.own .dot { opacity: 1; transform: none; }
#app:not([data-view="chat"]) .head-settings { display: none; }

.crumbs {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 0 1 auto;
}
.crumbs .crumb {
  color: var(--text3);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 220px;
  flex: none;
}
.crumbs .crumb.link { cursor: pointer; }
.crumbs .crumb.link:hover { color: var(--text); }
.crumbs .sep { color: var(--text3); }
.crumbs .title {
  font-size: 15px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}
.crumbs .title.swap { animation: rise-in var(--dur) var(--ease-out); }

.header-tools {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex: none;
}
/* A named tool (a mosaic's talk) never pushes the title out of the row. */
.header-tools .pill .label { max-width: 220px; }
/* Glyph-only tools: Temporary inverts while on; Keep wears the accent. */
.header-tools .pill.glyph { width: 30px; height: 30px; padding: 0; justify-content: center; border-radius: 9px; }
.header-tools .pill.glyph .icon { width: 17px; height: 17px; transition: transform var(--dur-fast) var(--ease); }
.header-tools .pill.glyph:active .icon { transform: scale(0.88); }
.header-tools .pill.glyph.active,
html.mosaik-theme .header-tools .pill.glyph.active { background: var(--text); color: var(--bg); box-shadow: 0 1px 3px var(--shadow-soft); }
.header-tools .pill.glyph.active:hover,
html.mosaik-theme .header-tools .pill.glyph.active:hover { background: color-mix(in srgb, var(--text) 84%, var(--bg)); color: var(--bg); }
#app.fresh .header-tools .pill.glyph:not(.active) { background: color-mix(in srgb, var(--bg) 66%, transparent); color: var(--text);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--text) 10%, transparent); }
#app.fresh .header-tools .pill.glyph:not(.active):hover { background: color-mix(in srgb, var(--bg) 86%, transparent); }
.header-tools .pill.glyph.keep { color: var(--accent-ink); border-color: color-mix(in srgb, var(--accent) 45%, transparent); }
.header-tools .pill.glyph.keep:hover { background: var(--accent-wash); color: var(--accent-ink); }
.header-tools .pill .count {
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 999px;
  background: var(--accent-wash);
  color: var(--accent-ink);
  font-size: 11px;
  font-weight: 650;
  display: inline-grid;
  place-items: center;
}

@media (max-width: 980px) { .crumbs .crumb, .crumbs .sep { display: none; } }
/* A pill that can go without its words does, before the title is cut short. */
@container header (max-width: 1240px) { .header-tools .pill.compact .label { display: none; } }

/* ---- stage -------------------------------------------------------------- */
#body {
  position: relative;
  display: flex;
  flex: 1;
  min-height: 0;
}

#stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}

.view {
  position: absolute;
  inset: 0;
}
/* A view arriving is drawn once, unseen, beside the one it replaces; then
   it rises in as that one fades (switchView in shell.js). */
.view.view-arriving { opacity: 0; }
.view.view-arrived { animation: view-in var(--dur-slow) var(--ease-out) both; }
.view.view-leaving { pointer-events: none; animation: view-out var(--dur) var(--ease) both; }
@keyframes view-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}
@keyframes view-out {
  to { opacity: 0; }
}
/* The composer comes and goes with the conversation it floats over. Held, it
   stays where it stood (its place is set inline) though the view that hides
   it has arrived. */
#dock.view-arriving { opacity: 0; }
#dock.view-arrived { animation: dock-in var(--dur-slow) var(--ease-out) both; }
#app #stage #dock.view-held { display: flex; pointer-events: none; transition: none; }
#dock.view-held > * { pointer-events: none; }
#dock.view-leaving { animation: view-out var(--dur) var(--ease) both; }
@keyframes dock-in {
  from { opacity: 0; }
}

/* The composer floats over the foot of whichever conversation is showing. */
#dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  padding: 0 24px 30px;
  pointer-events: none;
}
#dock > * { pointer-events: auto; }
/* ---- the New Chat picture ------------------------------------------------ */
/* Behind the whole main area, header included, while an empty chat shows
   (#app.fresh) and while it comes apart after the first message
   (#app.dismissing); chat.js draws it. The composer sits in the middle of
   the window meanwhile and glides back down when the first message is sent:
   a transform rather than a new position, so the glide keeps its pace while
   the page is busy with the picture. */
/* No mask over the picture: the conversation's fade under the composer
   (chat.css), a mask over the whole window, made the window composite it
   again on every frame the picture drew, and the picture lost half its
   frames on a slow computer (docs/speed.md, rule 6). The New Chat page has
   nothing under its composer to fade. */
#app:is(.fresh, .blank, .dismissing)[data-view="chat"] #view-chat .conversation { -webkit-mask-image: none; mask-image: none; }
#backdrop { position: absolute; inset: 0; z-index: 0; display: none; overflow: hidden; pointer-events: none; }
#app:is(.fresh, .dismissing)[data-view="chat"] #backdrop { display: block; }
/* A temporary chat keeps its black and white picture behind the whole
   conversation, faint enough to read over; it rises to full strength only on
   the New Chat page. Kept after all, it fades away (.letting-go). */
#backdrop { transition: opacity 600ms var(--ease); }
#app:is(.temporary, .letting-go)[data-view="chat"] #backdrop { display: block; }
#app.temporary:not(.fresh)[data-view="chat"] #backdrop { opacity: var(--temporary-picture, 0.14); }
#app.letting-go:not(.fresh)[data-view="chat"] #backdrop { opacity: 0; }
/* Left for a conversation, the New Chat picture fades out under it, quicker
   (chat.js fadeScene). */
#app.picture-going:not(.fresh)[data-view="chat"] #backdrop { display: block; opacity: 0; transition-duration: var(--dur-slow); }
html.light { --temporary-picture: 0.1; }
#app.temporary #view-chat > .scene-pick { display: none; }
#backdrop .scene { position: absolute; inset: 0; animation: fade-in 360ms var(--ease-out) both; }
/* The picture is cut about the window's size and centred on the window
   (chat.js places it with a transform), so the sidebar and small resizes
   only show more or less of it. The canvas and what Mosaic lays beside it
   fill the plate the cut is placed with. */
#backdrop .scene-plate { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
#backdrop canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; object-fit: cover; }
/* A wash of the page's colour at the very top, so the header reads over any
   scene. It is gone well above the greeting. */
#backdrop::after {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: calc(var(--header-h) + 90px);
  background: linear-gradient(to bottom, color-mix(in srgb, var(--bg) 58%, transparent) 0%,
    color-mix(in srgb, var(--bg) 30%, transparent) 40%, transparent 100%);
  transition: opacity 600ms var(--ease);
}
#app.dismissing #backdrop::after { opacity: 0; }
/* The light theme's header is dark ink: over the picture its quieter greys go
   full strength and its words get a soft halo of the page's colour, so they
   read without whitening the picture itself. */
html.light #app:is(.fresh, .dismissing)[data-view="chat"] #header {
  --text2: var(--text);
  --text3: var(--text);
  text-shadow: 0 0 2px var(--bg), 0 0 8px var(--bg);
}
/* Except the tab you are not on, which stays quieter than the one you are. */
html.light #app:is(.fresh, .dismissing)[data-view="chat"] #header .modes button:not(.on) {
  color: color-mix(in srgb, var(--text) 55%, transparent);
}
#header { transition: background var(--dur-slow) var(--ease), border-color var(--dur-slow) var(--ease); }
#app:is(.fresh, .dismissing)[data-view="chat"] #header { background: transparent; border-bottom-color: transparent; }
/* The picture meets the sidebar itself, with no line between. */
#app:is(.fresh, .dismissing)[data-view="chat"] #sidebar { border-right-color: transparent; }
/* Which picture: a small pill in the bottom-right corner, only while it shows. */
#view-chat > .scene-pick {
  position: absolute;
  right: 16px;
  bottom: 16px;
  z-index: 6;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 11px 0 9px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface) 90%, transparent);
  color: var(--text2);
  font-size: 12.5px;
  box-shadow: 0 1px 2px var(--shadow-soft);
  opacity: 0;
  pointer-events: none;
  transform: translateY(4px);
  transition: opacity var(--dur) var(--ease), transform var(--dur) var(--ease),
    color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
#view-chat > .scene-pick .icon { width: 14px; height: 14px; }
#view-chat > .scene-pick:hover { color: var(--text); background: var(--surface); }
#app.fresh[data-view="chat"] #view-chat > .scene-pick { opacity: 1; pointer-events: auto; transform: none; }
#dock { transition: transform 520ms var(--ease-out); }
#app.settled #dock { transition: none; }
/* Without the picture too (#app.blank): the New Chat page always waits in the middle. */
#app:is(.fresh, .blank)[data-view="chat"] #dock { transform: translateY(calc((var(--dock-h, 150px) - 30px) / 2 + 30px - 50vh)); }
#app:is(.fresh, .dismissing)[data-view="chat"] #view-chat > .veil { opacity: 0; }
#statusline { transition: opacity 520ms var(--ease); }
#app:is(.fresh, .blank)[data-view="chat"] #statusline { opacity: 0; pointer-events: none; }
#app[data-view="home"] #dock { display: none; }

/* ---- status line --------------------------------------------------------- */
#statusline {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 4px;
  height: 28px;
  padding: 0 14px 0 12px;
  font-size: 11.5px;
  color: var(--text3);
  pointer-events: none;
}
#statusline > * { pointer-events: auto; }
/* Hidden on the New Chat page, and nothing in it can be clicked there:
   its readings take clicks of their own, so the line's own none is not enough. */
#app:is(.fresh, .blank)[data-view="chat"] #statusline > * { pointer-events: none; }
/* A chat's foot keeps only what it costs and how full it is, at the right:
   the model is in the composer, and the tokens are in the cost's detail. */
#app[data-view="chat"] #statusline :is(.r-model, .r-tokens) { display: none; }
#app[data-view="home"] #statusline { display: none; }
.reading {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 22px;
  padding: 0 6px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text3);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  animation: fade-in var(--dur) var(--ease) both;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}
.reading .icon { width: 13px; height: 13px; }
button.reading:hover { color: var(--text); background: var(--surface-hover); }
.reading.warn { color: var(--accent-ink); }
.reading.danger { color: var(--danger); }
.reading.activity { max-width: 46%; overflow: hidden; text-overflow: ellipsis; }
.reading.activity .busy { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.status-spacer { flex: 1; }
.ring { width: 13px; height: 13px; }
.ring circle { fill: none; stroke-width: 2.4; }
.ring .track { stroke: var(--border-strong); }
.ring .fill { stroke: var(--text2); stroke-linecap: round; transition: stroke-dashoffset var(--dur-slow) var(--ease); }
.ring.warn .fill { stroke: var(--accent); }
.ring.danger .fill { stroke: var(--danger); }

/* ---- the window's own edges (Linux and macOS) ----------------------------- */
#edges .edge { position: fixed; z-index: 100; }
#edges .n { top: 0; left: 8px; right: 8px; height: 5px; cursor: ns-resize; }
#edges .s { bottom: 0; left: 8px; right: 8px; height: 5px; cursor: ns-resize; }
#edges .w { left: 0; top: 8px; bottom: 8px; width: 5px; cursor: ew-resize; }
#edges .e { right: 0; top: 8px; bottom: 8px; width: 5px; cursor: ew-resize; }
#edges .nw { left: 0; top: 0; width: 9px; height: 9px; cursor: nwse-resize; }
#edges .ne { right: 0; top: 0; width: 9px; height: 9px; cursor: nesw-resize; }
#edges .sw { left: 0; bottom: 0; width: 9px; height: 9px; cursor: nesw-resize; }
#edges .se { right: 0; bottom: 0; width: 9px; height: 9px; cursor: nwse-resize; }
html.maximized #edges { display: none; }

/* With WebView2 (shell/edge.py) Windows asks the page, not the shell, what is
   title bar: the same places the move starts from elsewhere, less their controls. */
html.engine-webview2 [data-drag] { -webkit-app-region: drag; app-region: drag; }
html.engine-webview2 [data-drag] :is(button, a, input, textarea, select, [role=button], [role=tab], [data-nodrag], .row) {
  -webkit-app-region: no-drag; app-region: no-drag;
}

/* The window's buttons, drawn by the page under WebView2 (js/shell.js) as
   window_chrome.py paints them under Qt: flat plates at the platform's size,
   red for Close, above everything the page shows. */
#caption {
  position: fixed; top: 0; right: 0; z-index: 1000;
  display: flex; height: var(--header-h);
  -webkit-app-region: no-drag; app-region: no-drag;
}
#caption button {
  width: 46px; height: 100%; padding: 0; border: 0; border-radius: 0;
  display: grid; place-items: center;
  background: transparent; color: var(--text);
  font: 10px/1 "Segoe Fluent Icons", "Segoe MDL2 Assets", sans-serif;
}
html.window-inactive #caption button { color: var(--text3); }
/* A plate under the buttons while the picture is under them (as ui/window_chrome.py paints it). */
#caption::before {
  content: "";
  position: absolute;
  inset: 0;
  border-bottom-left-radius: 12px;
  background: color-mix(in srgb, var(--bg) 66%, transparent);
  box-shadow: inset 1px -1px 0 color-mix(in srgb, var(--text) 8%, transparent);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--dur) var(--ease);
}
#app.fresh ~ #caption::before { opacity: 1; }
#caption button { position: relative; }
#app.fresh ~ #caption button.minimise { border-bottom-left-radius: 12px; }
/* .hover and .pressed: the maximise button's pointer goes to the shell's
   window over it (js/shell.js), which says what it does there. */
#caption button:hover, #caption button.hover { background: var(--caption-hover); color: var(--text); }
#caption button:active, #caption button.pressed { background: var(--caption-pressed); }
#caption button.close:hover { background: var(--caption-close); color: var(--caption-close-text); }
#caption button.close:active { background: var(--caption-close-pressed); color: var(--caption-close-text); }

/* Renaming in place (js/shell.js). */
.renaming { overflow: visible !important; text-overflow: clip !important; }
.inline-rename {
  width: 100%;
  min-width: 120px;
  height: 24px;
  margin: -3px -6px;
  padding: 0 5px;
  border: 0;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  box-shadow: 0 0 0 1px var(--accent), 0 0 0 4px color-mix(in srgb, var(--accent) 22%, transparent);
  outline: none;
}
.crumbs .title.renaming { display: inline-flex; min-width: 260px; }
