/* Windrunner. Every value here comes from the DESIGN PASSPORT in CLAUDE.md. */

:root {
  --ink: #100f18;
  --paper: #fff8f2;
  --raised: #100f18ed;
  --line: #fff8f222;
  --line-strong: #fff8f248;
  --wash: #fff8f20c;
  --leave: #ff8f8f;
  --harm: #ff8f8f;
  --accent: #96ccff;
  --t: 240ms;
  --e: ease;
  --even: linear;
  --sweep: calc(var(--t) * 2);
  --step: calc(var(--t) / 3);
}

* { box-sizing: border-box; }

/* The page never scrolls, so it reserves no gutter: a reserved one was drawn as a dark strip down the right edge. */
html {
  scrollbar-color: var(--accent) var(--ink);
}

/* The page is one screen and never scrolls or stretches; only the surfaces inside it scroll. */
html, body { height: 100%; overflow: hidden; overscroll-behavior: none; }

body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font-family: system-ui, sans-serif;
  font-size: 18px;
  font-weight: 400;
  line-height: 1.4;
  caret-color: var(--accent);
  accent-color: var(--accent);
}

::selection { background: var(--accent); color: var(--ink); }

::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track { background: var(--ink); }
::-webkit-scrollbar-thumb {
  background: var(--accent);
  border-radius: 999px;
  border: 4px solid var(--ink);
  transition: background-color var(--t) var(--e);
}
::-webkit-scrollbar-thumb:hover { background: var(--paper); }

button { font: inherit; color: inherit; }
button { cursor: pointer; }

/* Controls and labels cannot be selected or copied; only what a visitor reads or writes can. */
body { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
.bubble, .md, .note, .field, .mail { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
.bubble button, .md button { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

button:focus-visible, a:focus-visible, input:focus-visible, .scroll:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.app {
  display: grid;
  grid-template-columns: clamp(232px, 23vw, 320px) 1fr;
  position: fixed;
  top: var(--view-top, 0px);
  left: 0;
  right: 0;
  height: var(--view, 100dvh);
}

.side {
  background: var(--ink);
  padding: 32px 16px;
  border-right: 1px solid var(--line);
  z-index: 1;
}

.brand {
  display: flex;
  align-items: center;
  margin: 0 8px 12px;
  height: 34px;
}

.lockup { display: block; width: 168px; height: auto; max-width: 100%; }
.lockup-wing { fill: var(--accent); transition: fill var(--t) var(--e); }
.lockup-word { fill: none; stroke: var(--paper); }

/* The wing: three pieces that jump forward one step apart, largest first. */
.lockup.go .lockup-wing path { animation-name: wing; animation-duration: var(--sweep); animation-timing-function: var(--e); animation-fill-mode: backwards; }
.lockup-wing path:nth-child(2), .sweep i:nth-child(2) { animation-delay: var(--step); }
.lockup-wing path:nth-child(1), .sweep i:nth-child(3) { animation-delay: calc(var(--step) * 2); }

.credit { margin: 0 8px 32px; font-size: 14px; }
.by a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: color var(--t) var(--e), filter var(--t) var(--e);
}

.by a:hover { color: var(--paper); }
.by a:active { filter: brightness(.88); }

.about {
  display: flex;
  align-items: center;
  align-self: flex-start;
  height: 40px;
  margin-bottom: 8px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background-color: transparent;
  font-size: 14px;
  font-weight: 600;
  transition: background-color var(--t) var(--e), border-color var(--t) var(--e),
    filter var(--t) var(--e), opacity var(--t) var(--e);
}

.wing { display: block; flex: none; fill: var(--accent); }
.wing path { transition: transform var(--t) var(--e), fill var(--t) var(--e); }
.wing path:nth-child(2) { transition-delay: var(--step); }
.wing path:nth-child(1) { transition-delay: calc(var(--step) * 2); }

.about:hover:enabled { background-color: var(--wash); border-color: var(--accent); }
.about:active:enabled { filter: brightness(.88); }
.about:disabled { opacity: .5; cursor: default; }

.agents { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
/* Two groups of agents, each under its heading; on a phone a hairline parts them. */
/* passport-gate: wolf-asked "нам надо будет сделать separation между ними" */
.kind { margin: 0; padding: 0 16px; font-size: 14px; font-weight: 600; color: color-mix(in srgb, var(--paper) 60%, var(--ink)); }
.kind ~ .kind { margin-top: 8px; }
.cast .kind { padding: 0; }
.cut { display: none; }

/* Sessions kept with the selected agent. On a desktop: one block under that agent's row. */
/* passport-gate: wolf-asked "Move New Chat thingy from its current position that is below the fuckin left menu right under the agent to whom it is related, AS WELL AS DO SAME FOR SESSIONS" */
.switch { display: contents; }
.now { display: none; }
.own {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
  margin-left: 16px;
  padding-left: 12px;
  border-left: 1px solid var(--line);
  animation: appear var(--t) var(--e);
}
.own > * { box-sizing: border-box; width: 100%; }
.past { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.past:empty, .every[hidden] { display: none; }
.every {
  display: flex;
  align-items: center;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background-color: transparent;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  color: color-mix(in srgb, var(--paper) 60%, var(--ink));
  transition: background-color var(--t) var(--e), color var(--t) var(--e), filter var(--t) var(--e);
}
.every:hover, .every:focus-visible { background-color: var(--wash); color: var(--paper); }
.every:active { filter: brightness(.88); }
/* New: starts an empty session and keeps the one on screen. It holds its slot when dimmed. */
.anew {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background-color: transparent;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  transition: background-color var(--t) var(--e), border-color var(--t) var(--e),
    color var(--t) var(--e), filter var(--t) var(--e), opacity var(--t) var(--e);
}
.anew svg { flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.anew:hover:enabled:not(.full), .anew:focus-visible:enabled:not(.full) { background-color: var(--wash); border-color: var(--accent); color: var(--accent); }
.anew:active:enabled:not(.full) { filter: brightness(.88); }
.anew:disabled, .anew.full { opacity: .5; cursor: default; }
/* Limit line: lies over the page under the New control, takes no space. */
.limit {
  position: fixed;
  z-index: 4;
  box-sizing: border-box;
  margin: 0;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--raised);
  color: var(--paper);
  font-size: 14px;
  line-height: 1.4;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity var(--t) var(--e), visibility var(--t) var(--e);
}
.limit.on { opacity: 1; visibility: visible; }
.session {
  flex: none;
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 8px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background-color: transparent;
  font-size: 14px;
  text-align: left;
  color: color-mix(in srgb, var(--paper) 60%, var(--ink));
  animation: appear var(--t) var(--e);
  transition: background-color var(--t) var(--e), border-color var(--t) var(--e),
    color var(--t) var(--e), filter var(--t) var(--e);
}
.session span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.session:hover, .session:focus-visible { background-color: var(--wash); color: var(--paper); }
.session:active { filter: brightness(.88); }
.session[aria-current=true] {
  color: var(--accent);
  background-color: color-mix(in srgb, var(--accent) 11%, var(--ink));
  border-color: color-mix(in srgb, var(--accent) 42%, var(--ink));
}

/* Bottom of the sidebar: the visitor, then the keepsimple line. */
.side { display: flex; flex-direction: column; min-height: 0; overflow: auto; scrollbar-color: var(--accent) var(--ink); }
.brand, .credit, .about, .agents, .account, .foot { flex: none; }

.account {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr);
  gap: 4px 12px;
  align-items: center;
  justify-items: start;
  min-height: 80px;
  margin: auto 8px 0;
  padding-top: 16px;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t) var(--e), visibility var(--t) var(--e);
}

.account.in, .account.guest { opacity: 1; visibility: visible; }

/* Nobody signed in: the empty picture and the way in, in the cells of the email and Log out. */
.account .face { grid-column: 1; }
.account .mail { grid-column: 2; grid-row: 1; }
.account .out { grid-column: 2; grid-row: 2; }
.account .mail, .account .out, .enter { transition: opacity var(--t) var(--e), visibility var(--t) var(--e), color var(--t) var(--e), text-decoration-color var(--t) var(--e), filter var(--t) var(--e); }
.account.guest .mail, .account.guest .out { opacity: 0; visibility: hidden; }

.enter {
  grid-column: 2;
  grid-row: 1 / 3;
  font-size: 14px;
  color: var(--paper);
  text-decoration: underline transparent;
  text-underline-offset: 4px;
  opacity: 0;
  visibility: hidden;
}

.account.guest .enter { opacity: 1; visibility: visible; }
.enter:hover, .enter:focus-visible { color: var(--accent); text-decoration-color: var(--accent); }
.enter:active { filter: brightness(.88); }

.face {
  grid-row: 1 / 3;
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 999px;
  overflow: hidden;
  background-color: transparent;
  transition: filter var(--t) var(--e), opacity var(--t) var(--e);
}

.face img { display: block; width: 40px; height: 40px; object-fit: cover; }
.face:hover:enabled { filter: brightness(1.12); }
.face:active:enabled { filter: brightness(.88); }
.face:disabled { opacity: .5; cursor: default; }

.mail { align-self: end; font-size: 14px; overflow-wrap: anywhere; }
.account { gap: 0 12px; }

button.out {
  align-self: start;
  padding: 0;
  border: none;
  background-color: transparent;
  font-size: 14px;
  color: color-mix(in srgb, var(--paper) 60%, var(--ink));
  text-decoration: underline transparent;
  text-underline-offset: 4px;
  transition: color var(--t) var(--e), text-decoration-color var(--t) var(--e),
    filter var(--t) var(--e), opacity var(--t) var(--e);
}

button.out:hover:enabled, button.out:focus-visible { color: var(--leave); text-decoration-color: var(--leave); }
button.out:active:enabled { filter: brightness(.72); }
button.out:disabled { opacity: .5; cursor: default; }

.foot {
  margin: 16px 0 0;
  text-align: center;
  font-size: 12px;
  color: color-mix(in srgb, var(--paper) 60%, var(--ink));
}

.foot a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 4px;
  transition: color var(--t) var(--e), filter var(--t) var(--e);
}

.foot a:hover { color: var(--accent); }
.foot a:active { filter: brightness(.88); }

/* Sign-in lies over the message field while the visitor is not signed in. */
.gate {
  position: absolute;
  inset: -1px;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background-color: var(--ink);
  color: var(--paper);
  font-weight: 600;
  text-decoration: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t) var(--e), visibility var(--t) var(--e),
    border-color var(--t) var(--e), color var(--t) var(--e), filter var(--t) var(--e);
}

.composer.locked .gate { opacity: 1; visibility: visible; }
.gate:hover { border-color: var(--accent); color: var(--accent); }
.gate:active { filter: brightness(.88); }
.gate-mark { flex: none; width: 24px; height: 24px; fill: none; stroke: var(--accent); transition: stroke var(--t) var(--e); }

.sheet .account { margin: 0; padding-top: 0; min-height: 0; }
.sheet .account:not(.in):not(.guest) { display: none; }

button.agent {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid transparent;
  border-radius: 12px;
  background-color: transparent;
  text-align: left;
  font-weight: 600;
  transition: background-color var(--t) var(--e), border-color var(--t) var(--e),
    color var(--t) var(--e), filter var(--t) var(--e), opacity var(--t) var(--e);
}

button.agent img { width: 40px; height: 40px; flex: none; }

button.agent::after {
  content: '↗';
  margin-left: auto;
  opacity: 0;
  transition: opacity var(--t) var(--e);
}

button.agent:hover:enabled { background-color: var(--wash); }
button.agent:active:enabled { filter: brightness(.88); }
button.agent:disabled { opacity: .5; cursor: default; }
/* An agent closed to the visitor: the label lies in the arrow's place. */
button.agent.closed::after { display: none; }
button.agent .off { margin-left: auto; font-size: 14px; font-weight: 400; }

button.agent[aria-pressed=true] {
  color: var(--accent);
  background-color: color-mix(in srgb, var(--accent) 11%, var(--ink));
  border-color: color-mix(in srgb, var(--accent) 42%, var(--ink));
}

button.agent[aria-pressed=true]::after { opacity: 1; }

/* A reply being written: the wing on the agent's row lies in the arrow's slot and beats like
   the reply loader, in the row's own text colour. Every row can show it at once. */
button.agent { position: relative; }
/* The holder is 4px wider than the wing on every side, so the wing is easier to hover. */
.working { position: absolute; top: 50%; right: 12px; z-index: 1; display: flex; padding: 4px; transform: translateY(-50%); }
.working > .wing { fill: currentColor; opacity: 0; transition: opacity var(--t) var(--e); }
.working > .wing path { animation: beat calc(var(--t) * 4) var(--e) infinite backwards; }
.working > .wing path:nth-child(2) { animation-delay: calc(var(--step) * 2); }
.working > .wing path:nth-child(3) { animation-delay: calc(var(--step) * 4); }
button.agent.busy > .working > .wing { opacity: 1; }
button.agent.busy::after { opacity: 0; }

.stage {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-height: 0;
  padding: 24px;
  overflow: hidden;
  background: var(--ink);
}

.scene, .tint, .shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.scene { background: url('scene/coast.jpg') center / cover; filter: saturate(.95); }

.tint {
  background-color: var(--accent);
  mix-blend-mode: color;
  opacity: .66;
  transition: background-color var(--t) var(--e);
}

.shade {
  background:
    linear-gradient(90deg, #100f1899, transparent 75%),
    linear-gradient(0deg, #100f18 0%, #100f1800 48%, #100f1822);
}

/* Every agent's header and conversation share one grid cell: the frame is
   sized by its largest state and the switch is a cross-fade inside it. */
.heroes, .feeds { display: grid; }
.heroes { flex: none; }
.talk { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.feeds { flex: 1; min-height: 0; grid-template-rows: minmax(0, 1fr); margin-bottom: 12px; }

.hero, .messages {
  grid-area: 1 / 1;
  min-width: 0;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t) var(--e), visibility var(--t) var(--e);
}

.hero.on, .messages.on { opacity: 1; visibility: visible; animation: unveil var(--sweep) var(--e); }

/* Welcome: one more layer in the conversation cell, shown until the visitor's first message. */
.welcome {
  grid-area: 1 / 1;
  min-width: 0;
  min-height: 0;
  overflow: auto;
  scrollbar-color: var(--accent) var(--ink);
  scrollbar-gutter: stable both-edges;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  text-align: center;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t) var(--e), visibility var(--t) var(--e);
}

.welcome.on { opacity: 1; visibility: visible; animation: unveil var(--sweep) var(--e); }
.welcome.gone { opacity: 0; visibility: hidden; }
.welcome > :first-child { margin-top: auto; }
.welcome > :last-child { margin-bottom: auto; }
.welcome > img { flex: none; width: 64px; height: 64px; border-radius: 999px; object-fit: cover; opacity: .72; }
.welcome > b { font-size: 24px; font-weight: 850; font-style: italic; line-height: 1; }
.welcome > span { color: color-mix(in srgb, var(--paper) 60%, var(--ink)); }
.asks { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; width: 100%; max-width: 560px; padding-top: 16px; }

.ask {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--raised);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: border-color var(--t) var(--e), background-color var(--t) var(--e), filter var(--t) var(--e);
}

.ask span { min-width: 0; overflow-wrap: anywhere; }
.ask:hover, .ask:focus-visible { border-color: var(--accent); background-color: color-mix(in srgb, var(--accent) 11%, var(--ink)); }
.ask:hover .wing path { transform: translate(8px, -4px); }
.ask:active { filter: brightness(.72); }

/* One row: picture, name, role. The name, the dash and the role stand on one baseline. */
/* passport-gate: wolf-asked "Италиком выровняй на уровне имени агента и поставь какой-то m-dash между ними, чтобы было ровнее всё" */
.names { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.dash { flex: none; font-style: italic; color: color-mix(in srgb, var(--paper) 60%, var(--ink)); }
.hero { display: flex; align-items: center; gap: 12px; height: 40px; }
.hero img { flex: none; width: 40px; height: 40px; }
.badge {
  flex: none;
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--ink));
  border-radius: 12px;
  background-color: color-mix(in srgb, var(--accent) 11%, var(--ink));
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
}

.hero h1 {
  flex: none;
  font-size: 24px;
  font-weight: 850;
  font-style: italic;
  line-height: 1;
  margin: 0;
}

/* Info control: the one filled control in the header. */
.tool.info { margin-left: auto; padding: 0; background-color: transparent; border-color: var(--line-strong); color: var(--paper); transition: background-color var(--t) var(--e), border-color var(--t) var(--e), color var(--t) var(--e), filter var(--t) var(--e); }
.tool.info svg { display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
.tool.info:hover, .tool.info:focus-visible { background-color: var(--wash); border-color: var(--accent); color: var(--accent); }
.tool.info:active { filter: brightness(.72); }

/* Clear control: drawn like the info control, left of it. The bin and the tick share one cell. */
.tool.clear { display: grid; margin-left: auto; padding: 0; background-color: transparent; border-color: var(--line-strong); color: var(--paper); transition: background-color var(--t) var(--e), border-color var(--t) var(--e), color var(--t) var(--e), filter var(--t) var(--e), opacity var(--t) var(--e); }
.tool.clear + .tool.info { margin-left: 0; }
.tool.clear { position: relative; }
/* Clear tip: a label under the control, only where a pointer can hover. */
.tip { display: none; }
@media (hover: hover) {
  .tip {
    display: block;
    position: absolute;
    top: calc(100% + 8px);
    left: 50%;
    z-index: 3;
    padding: 4px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background-color: var(--raised);
    color: var(--paper);
    font-size: 14px;
    line-height: 1.4;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateX(-50%);
    transition: opacity var(--t) var(--e), visibility var(--t) var(--e);
  }
  .tool.clear:hover:not(:disabled) .tip, .tool.clear:focus-visible:not(:disabled) .tip { opacity: 1; visibility: visible; }
  /* Field tips: the same label, over the control. */
  /* copy-gate: wolf-asked "add tooltips to these buttons tooo." */
  .bar .tool { position: relative; }
  .bar .tip { top: auto; bottom: calc(100% + 8px); }
  .bar .tool:hover:not(:disabled) .tip, .bar .tool:focus-visible:not(:disabled) .tip { opacity: 1; visibility: visible; }
  /* With nothing to clear the broom still answers a hover, so its tip is not dimmed with it. */
  /* copy-gate: wolf-asked "когда нечего чистить 'Agent context is empty' пусть говорит шоп было ясно" */
  .tool.broom:disabled { opacity: 1; }
  .tool.broom:disabled svg { opacity: .55; }
  .tool.broom svg { transition: opacity var(--t) var(--e); }
  .tool.broom.empty:hover .tip { opacity: 1; visibility: visible; }
  .tool.broom:disabled:hover { background-color: transparent; border-color: var(--line); }
  /* Thinking tip: over the busy wing, its right edge on the wing's, so it stays inside the sidebar. */
  /* copy-gate: wolf-asked "on-hover of the icon write 'Bob is thinking...' ofc names diff depending on agent" */
  .working .tip { top: auto; bottom: calc(100% + 4px); left: auto; right: 4px; font-weight: 400; transform: none; }
  button.agent.busy .working:hover .tip { opacity: 1; visibility: visible; }
}

/* Language control: a globe left of the clear control, muted until a language is chosen. */
.tool.lang { margin-left: auto; padding: 0; background-color: transparent; border-color: var(--line-strong); color: color-mix(in srgb, var(--paper) 60%, var(--ink)); transition: background-color var(--t) var(--e), border-color var(--t) var(--e), color var(--t) var(--e), filter var(--t) var(--e); }
.tool.lang + .tool.clear { margin-left: 0; }
/* New chat in the chat header, left of the language control. Same action and states as the one in the sidebar. */
/* passport-gate: wolf-asked "Add New chat button next to the globe icon on desktop" */
.fresh {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: 40px;
  margin-left: auto;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background-color: transparent;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  transition: background-color var(--t) var(--e), border-color var(--t) var(--e),
    color var(--t) var(--e), filter var(--t) var(--e), opacity var(--t) var(--e);
}
.fresh svg { flex: none; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; }
.fresh:hover:enabled:not(.full), .fresh:focus-visible:enabled:not(.full) { background-color: var(--wash); border-color: var(--accent); color: var(--accent); }
.fresh:active:enabled:not(.full) { filter: brightness(.72); }
.fresh:disabled, .fresh.full { opacity: .5; cursor: default; }
.fresh + .tool.lang { margin-left: 0; }
.tool.lang svg { display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool.lang.set { border-color: color-mix(in srgb, var(--accent) 42%, var(--ink)); color: var(--accent); }
/* A chosen language: its initials take the globe's place in the same slot. */
.tool.lang { display: grid; place-items: center; }
.tool.lang > * { grid-area: 1 / 1; }
.tool.lang .code { font-size: 18px; font-weight: 400; line-height: 1; opacity: 0; transition: opacity var(--t) var(--e); }
.tool.lang svg { transition: opacity var(--t) var(--e); }
.tool.lang.set svg { opacity: 0; }
.tool.lang.set .code { opacity: 1; }
.tool.lang:hover, .tool.lang:focus-visible, .tool.lang[aria-expanded=true] { background-color: var(--wash); border-color: var(--accent); color: var(--accent); }
.tool.lang:active { filter: brightness(.72); }

/* Language menu: one for the stage, under the header row at the right edge. */
.tongues {
  position: absolute;
  top: 72px;
  right: 24px;
  z-index: 3;
  display: grid;
  grid-template-rows: auto 40px 240px;
  gap: 8px;
  width: 320px;
  max-width: calc(100% - 48px);
  padding: 8px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background-color: var(--raised);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--t) var(--e), visibility var(--t) var(--e);
}
.tongues.open { opacity: 1; visibility: visible; }
.tongues .title { padding: 0 4px; font-weight: 600; }
.tongues input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--wash);
  color: var(--paper);
  font: inherit;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
  transition: border-color var(--t) var(--e);
}
.tongues input:focus { border-color: var(--accent); }
.tongues .list { display: flex; flex-direction: column; min-height: 0; overflow-y: auto; scrollbar-color: var(--accent) var(--ink); scrollbar-gutter: stable; }
.tongues .list button {
  flex: none;
  height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background-color: transparent;
  text-align: start;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background-color var(--t) var(--e), border-color var(--t) var(--e), color var(--t) var(--e);
}
.tongues .list button:hover, .tongues .list button:focus-visible { background-color: var(--wash); outline: none; }
.tongues .list button[aria-selected=true] { background-color: color-mix(in srgb, var(--accent) 11%, var(--ink)); border-color: color-mix(in srgb, var(--accent) 42%, var(--ink)); color: var(--accent); }
.tool.clear svg { display: block; grid-area: 1 / 1; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: opacity var(--t) var(--e); }
.tool.clear svg + svg, .tool.clear.armed svg { opacity: 0; }
.tool.clear.armed svg + svg { opacity: 1; }
.tool.clear:hover:not(:disabled), .tool.clear:focus-visible { background-color: var(--wash); border-color: var(--accent); color: var(--accent); }
.tool.clear.armed, .tool.clear.armed:hover, .tool.clear.armed:focus-visible { border-color: var(--leave); color: var(--leave); }
.tool.clear:active:not(:disabled) { filter: brightness(.72); }
.tool.clear:disabled, .tool.clear:disabled:hover, .tool.clear:disabled:active { background-color: transparent; border-color: var(--line-strong); color: var(--paper); }

.hero p {
  min-width: 0;
  font-size: 18px;
  font-style: italic;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messages {
  min-height: 0;
  overflow: auto;
  scrollbar-color: var(--accent) var(--ink);
  scrollbar-gutter: stable;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Keeps a short conversation at the bottom and a long one scrollable to its start. */
.messages > :first-child { margin-top: auto; }

/* Visitor on the right, agent on the left, as in every messenger. Picture, message, copy control.
   passport-gate: wolf-asked "На мобайле вроде ты справа, собеседник слева, да? ... Переверни." */
.msg {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  animation: arrive var(--t) var(--e);
}

.msg:not(.agent) { flex-direction: row-reverse; }
.msg.agent { font-weight: 400; }
.msg > img { flex: none; width: 40px; height: 40px; border-radius: 999px; object-fit: cover; }

.bubble {
  min-width: 0;
  padding: 12px 16px;
  border-radius: 12px;
  background-color: var(--raised);
  overflow-wrap: anywhere;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: background-color var(--t) var(--e), opacity var(--t) var(--e);
}

/* A one-line visitor message is as high as the picture beside it. */
.msg:not(.agent) .bubble { padding: 8px 16px; }
.msg.agent .bubble { background-color: color-mix(in srgb, var(--accent) 11%, var(--ink)); }
/* A reply being written: the wing pieces light up in turn, smallest first. A piece that steps
   past the edge of the drawing is not cut off. */
.bubble.wait .wing, .working > .wing { overflow: visible; }
.bubble.wait .wing path { animation: beat calc(var(--t) * 4) var(--e) infinite backwards; }
.bubble.wait .wing path:nth-child(2) { animation-delay: calc(var(--step) * 2); }
.bubble.wait .wing path:nth-child(3) { animation-delay: calc(var(--step) * 4); }
/* The retry control stands alone: the bubble around it keeps no fill and no margin, so no
   corner of the reply colour shows behind the round control. */
.msg .bubble.failed { padding: 0; background-color: transparent; }
.bubble.failed .send { margin: 0; }
/* A reply that has just arrived fades in. A kept conversation is drawn without it. */
.bubble.arrived > .md { animation: arrive var(--sweep) var(--e); }
/* A reply drawn while it is written: each word fades in once, in its turn. The page sets the
   wait of a word in milliseconds; the fade itself is the two durations of an arriving reply.
   passport-gate: wolf-asked "сделай плавное появление ответа, чтобы это приятно, тепло ощущалось" */
.bubble.writing .w { animation: arrive var(--sweep) var(--e) backwards; animation-delay: calc(var(--d, 0) * 1ms); }

/* Food card: the index first, the food, the scale, one plain row per named line. */
.food { display: grid; gap: 4px; min-width: 0; }
.sign { display: block; flex: none; width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.dish { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--accent); }
.dish.harm { color: var(--harm); }
.dish b { flex: 1 1 auto; min-width: 0; font-weight: 600; }
.score { flex: none; display: flex; gap: 8px; padding: 4px 12px; border-radius: 999px; background-color: var(--accent); color: var(--ink); font-size: 24px; font-weight: 850; line-height: 1; }
.harm .score { background-color: var(--harm); }
.scale { height: 4px; margin: 4px 0; border-radius: 999px; background-color: var(--wash); overflow: hidden; }
.scale i { display: block; width: calc(var(--fill) * 100%); height: 100%; border-radius: 999px; background-color: var(--accent); transform-origin: left; }
.scale.harm i { background-color: var(--harm); }
/* Comparison: one tile per food, the best first. Two to six tiles, one layout for each count. */
.food.versus { grid-template-columns: repeat(6, minmax(0, 1fr)); gap: 8px; }
.rival { grid-column: span 2; display: flex; flex-direction: column; gap: 4px; min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: 12px; background-color: var(--ink); color: var(--accent); }
.n2 .rival, .n4 .rival, .n5 .rival:nth-child(-n+2) { grid-column: span 3; }
.rival.harm { color: var(--harm); }
.rival.won { border-color: color-mix(in srgb, var(--accent) 42%, var(--ink)); background-color: color-mix(in srgb, var(--accent) 11%, var(--ink)); }
.rank { display: flex; align-items: center; gap: 8px; min-height: 32px; }
.rank .word { flex: 1 1 auto; min-width: 0; font-size: 14px; font-weight: 600; }
.rank .cup { margin-left: auto; }
.rival b { color: var(--paper); font-weight: 600; }
.rival .scale { margin: 4px 0; }
.rival p { margin: 0; font-size: 14px; color: color-mix(in srgb, var(--paper) 60%, var(--ink)); }
/* The cup of a winner: at rest for most of a loop of eight durations, then one lift with a tilt to each side. */
.cup { position: relative; flex: none; display: block; width: 24px; height: 24px; }
.cup .sign { position: relative; animation: turn calc(var(--t) * 16) var(--even) infinite; }
.glow { position: absolute; inset: -8px; border-radius: 999px; background-image: radial-gradient(closest-side, color-mix(in srgb, var(--accent) 42%, transparent), transparent); opacity: 0; animation: shine calc(var(--t) * 32) var(--e) infinite; }
.bubble.arrived .rank .cup { animation: rise var(--sweep) var(--e) backwards; animation-delay: calc(var(--step) * 6); }
/* Menu: the columns, sections and order of the visitor's menu, the index where the price stands. */
.food.menu { grid-template-columns: repeat(var(--cols, 1), minmax(0, 1fr)); align-items: start; gap: 12px 24px; }
.col { display: grid; gap: 12px; min-width: 0; }
.course { display: grid; gap: 4px; min-width: 0; }
.course > b { padding: 0 8px 4px; border-bottom: 1px solid var(--line); font-weight: 600; }
.plate { display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 4px 8px; border: 1px solid transparent; border-radius: 12px; }
.plate > span:first-child { flex: 1 1 auto; min-width: 0; }
.plate.harm > span:first-child { color: var(--harm); }
.plate.won { border-color: color-mix(in srgb, var(--accent) 42%, var(--ink)); background-color: color-mix(in srgb, var(--accent) 11%, var(--ink)); }
.plate .cup { color: var(--accent); }
.plate .score { padding: 4px 8px; font-size: 18px; }
.fact { display: flex; gap: 8px; }
.fact .slot { flex: none; display: flex; align-items: center; justify-content: center; width: 24px; height: 1.4em; color: var(--accent); }
.fact div { min-width: 0; }
.fact b { color: var(--accent); font-weight: 600; }

.bubble.arrived .food > * { animation: rise var(--sweep) var(--e) backwards; animation-delay: calc(var(--step) * var(--i, 0)); }
.bubble.arrived .scale i { animation: grow var(--sweep) var(--e) backwards; animation-delay: calc(var(--step) * var(--i, 0)); }

.msg .copy { opacity: .55; }
.msg .copy:disabled { pointer-events: none; }
@media (hover: hover) {
  .msg .copy { opacity: 0; }
  .msg:hover .copy, .msg .copy:focus-visible { opacity: 1; }
  .msg:hover .copy:disabled { opacity: .55; }
}

/* What a message can hold. */
.md { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.md p, .md h2, .md h3, .md blockquote, .md pre { margin: 0; }
.md p { white-space: pre-wrap; }
.md h2 { font-size: 24px; font-weight: 600; }
.md h3 { font-size: 18px; font-weight: 600; }
.md strong { font-weight: 600; }
.md a { color: var(--accent); transition: color var(--t) var(--e); }
.md a:hover { color: var(--paper); }
.md hr { width: 100%; margin: 4px 0; border: none; border-top: 1px solid var(--line-strong); }
.md code { font-family: ui-monospace, monospace; background: var(--wash); border-radius: 12px; padding: 0 4px; }

.md blockquote {
  padding-left: 12px;
  border-left: 4px solid var(--line-strong);
}

.item { display: flex; gap: 8px; }
.item.lv1 { padding-left: 24px; }
.item.lv2 { padding-left: 56px; }
.item > span:first-child { flex: none; min-width: 16px; color: var(--accent); }
.item > span:last-child { min-width: 0; }

.scroll, .md pre {
  overflow: auto;
  scrollbar-color: var(--accent) var(--ink);
}

.md table { border-collapse: collapse; }
.md th, .md td { padding: 8px 12px; border: 1px solid var(--line-strong); text-align: left; vertical-align: top; }
.md th { background: var(--wash); font-weight: 600; }

.code { position: relative; }
.code pre {
  padding: 12px 56px 12px 16px;
  border-radius: 12px;
  background: var(--wash);
  font-family: ui-monospace, monospace;
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.code .copy { position: absolute; top: 4px; right: 4px; }

.pic {
  display: block;
  width: 320px;
  max-width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  border-radius: 12px;
}

.shots, .files { display: flex; flex-wrap: wrap; gap: 8px; }
.shots img { width: 80px; height: 80px; object-fit: cover; border-radius: 12px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
  max-width: 100%;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  font-size: 14px;
  color: var(--paper);
  text-decoration: none;
  white-space: nowrap;
  animation: arrive var(--t) var(--e);
  transition: border-color var(--t) var(--e), opacity var(--t) var(--e);
}

a.chip:hover { border-color: var(--accent); }
.chip.out { opacity: 0; }
.chip button { border: none; background: none; padding: 0 0 0 4px; transition: color var(--t) var(--e); }
.chip button:hover { color: var(--accent); }

@keyframes beat { 0%, 60%, 100% { opacity: .24; } 30% { opacity: 1; transform: translate(4px, -2px); } }

@keyframes hum { from { opacity: .04; } to { opacity: .24; } }

@keyframes arrive { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } }
@keyframes grow { from { transform: scaleX(0); } }
@keyframes turn { to { transform: rotateY(360deg); } }
@keyframes shine { 0%, 30%, 70%, 100% { opacity: 0; } 50% { opacity: 1; } }

@keyframes wing { 50% { transform: translate(8px, -4px); opacity: .4; } }
@keyframes sweep { from { transform: skewX(-26deg) translateX(-120%); } to { transform: skewX(-26deg) translateX(120%); } }
@keyframes unveil { from { clip-path: polygon(0 0, 0 0, -40% 100%, 0 100%); } to { clip-path: polygon(0 0, 140% 0, 100% 100%, 0 100%); } }
@keyframes appear { from { opacity: 0; } }
/* Cleared-context line: the text sits on the hairline. Everything above the last one is greyed out. */
/* passport-gate: wolf-asked "greatly greyes-out the above-conversation with the agent" */
.forgot { flex: none; display: flex; align-items: center; gap: 12px; font-size: 14px; color: color-mix(in srgb, var(--paper) 60%, var(--ink)); animation: appear var(--t) var(--e); }
.forgot::before, .forgot::after { content: ''; flex: 1; height: 1px; background-color: var(--line-strong); }
.messages > * { transition: opacity var(--t) var(--e); }
.messages > :has(~ .forgot) { opacity: .35; }
@keyframes leave { to { opacity: 0; } }

/* Three slanted bars with the lean and the proportions of the logo wing. */
.sweep { position: absolute; inset: 0; z-index: 2; overflow: hidden; pointer-events: none; }
.sweep i { position: absolute; inset: 0; transform: skewX(-26deg) translateX(-120%); }
.sweep i:nth-child(1) { background: linear-gradient(90deg, transparent 42%, var(--accent) 42% 58%, transparent 58%); }
.sweep i:nth-child(2) { background: linear-gradient(90deg, transparent 46%, var(--accent) 46% 54%, transparent 54%); opacity: .7; }
.sweep i:nth-child(3) { background: linear-gradient(90deg, transparent 48%, var(--accent) 48% 52%, transparent 52%); opacity: .45; }
/* Clearing: the bars go back the other way and the conversation is covered behind the same edge. */
.sweep.back i { animation-name: sweep; animation-duration: var(--sweep); animation-timing-function: var(--e); animation-direction: reverse; }
.messages.on.out { animation: veil var(--sweep) var(--e) forwards; }
@keyframes veil { from { clip-path: polygon(0 0, 140% 0, 100% 100%, 0 100%); } to { clip-path: polygon(0 0, 0 0, -40% 100%, 0 100%); } }
.sweep.go i { animation-name: sweep; animation-duration: var(--sweep); animation-timing-function: var(--e); }

/* ABOUT panel. The dialog covers the screen; the sheet is the panel. */
.brief {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 16px;
  border: none;
  overflow: hidden;
  background-color: #100f1899;
  color: inherit;
}

.brief::backdrop { background: transparent; }
.brief[open] { display: grid; place-items: center; animation: appear var(--t) var(--e); }
.brief.leaving { animation: leave var(--t) var(--e) forwards; }

.sheet {
  position: relative;
  display: grid;
  gap: 16px;
  width: min(700px, 100%);
  max-height: 100%;
  padding: 32px;
  overflow: auto;
  scrollbar-color: var(--accent) var(--ink);
  scrollbar-gutter: stable;
  background: var(--ink);
  border: 1px solid var(--line-strong);
  border-radius: 12px;
}


.shut { position: absolute; top: 16px; right: 16px; }
/* All sessions of the selected agent, with a search. One height whatever the search leaves. */
/* passport-gate: wolf-asked "open modal with all past sessions with ability to search in those" */
.all .sheet { grid-template-rows: auto 40px minmax(0, 1fr); height: min(560px, 100%); overflow: hidden; }
.find {
  display: flex;
  align-items: center;
  gap: 8px;
  box-sizing: border-box;
  height: 40px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--wash);
  transition: border-color var(--t) var(--e);
}
.find:focus-within { border-color: var(--accent); }
.find svg { flex: none; fill: none; stroke: color-mix(in srgb, var(--paper) 60%, var(--ink)); stroke-width: 2; stroke-linecap: round; }
.find input {
  flex: 1;
  min-width: 0;
  height: 100%;
  padding: 0;
  border: none;
  background: transparent;
  color: var(--paper);
  font: inherit;
  outline: none;
  -webkit-user-select: text;
  user-select: text;
}
.all .list { display: flex; flex-direction: column; gap: 4px; min-height: 0; overflow-y: auto; scrollbar-color: var(--accent) var(--ink); scrollbar-gutter: stable; outline: none; }
.all .list button {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  box-sizing: border-box;
  height: 40px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: 12px;
  background-color: transparent;
  text-align: start;
  transition: background-color var(--t) var(--e), border-color var(--t) var(--e), color var(--t) var(--e), filter var(--t) var(--e);
}
.all .list button span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.all .list button time { flex: none; font-size: 14px; white-space: nowrap; color: color-mix(in srgb, var(--paper) 60%, var(--ink)); }
.all .list button:hover, .all .list button:focus-visible { background-color: var(--wash); outline: none; }
.all .list button:active { filter: brightness(.88); }
.all .list button[aria-current=true] { background-color: color-mix(in srgb, var(--accent) 11%, var(--ink)); border-color: color-mix(in srgb, var(--accent) 42%, var(--ink)); color: var(--accent); }
.top { display: flex; min-width: 0; }
/* passport-gate: wolf-asked "В этом about добавь divider линию после delivered to you by keep simple" */
.intro { display: grid; gap: 4px; }
.lead { margin: 0; font-size: 24px; font-weight: 850; font-style: italic; }
.split { width: 100%; height: 0; margin: 0; border: none; border-top: 1px solid var(--line-strong); }
.by { margin: 0; }
.note { margin: 0; overflow-wrap: anywhere; }
.cast { display: grid; gap: 8px; }

/* Info panel: who the agent is, then the owner's text. */
.who { display: flex; align-items: center; gap: 12px; min-height: 40px; padding-right: 32px; }
.who img { flex: none; width: 40px; height: 40px; }
.who span { display: grid; gap: 4px; min-width: 0; }
.who b { font-size: 24px; font-weight: 850; font-style: italic; line-height: 1; }
.more { gap: 12px; overflow-wrap: anywhere; }
.more:empty { display: none; }

/* Examples of use: one frame in the agent's colour, one tile per example. */
.uses {
  gap: 12px;
  padding: 16px;
  border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--ink));
  border-radius: 12px;
  background-color: color-mix(in srgb, var(--accent) 11%, var(--ink));
}

.uses h2 { color: var(--accent); }
.uses [role=list] { display: grid; gap: 8px; }

.uses .item {
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: var(--ink);
  transition: border-color var(--t) var(--e);
}

.uses .item > span:first-child { display: flex; align-items: center; height: 1.4em; }
.uses .item:hover { border-color: var(--accent); }
.uses .item:hover .wing path { transform: translate(8px, -4px); }

.pick {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background-color: transparent;
  text-align: left;
  transition: background-color var(--t) var(--e), border-color var(--t) var(--e),
    color var(--t) var(--e), filter var(--t) var(--e), opacity var(--t) var(--e);
}

.pick img { flex: none; width: 40px; height: 40px; }
.pick span { display: grid; min-width: 0; }
.pick b { font-weight: 600; }
.pick:hover:enabled { background-color: var(--wash); border-color: var(--line-strong); }
.pick:active:enabled { filter: brightness(.88); }
.pick:disabled { opacity: .5; cursor: default; }

.pick[aria-current=true] {
  background-color: color-mix(in srgb, var(--accent) 11%, var(--ink));
  border-color: color-mix(in srgb, var(--accent) 42%, var(--ink));
}

.pick[aria-current=true] b { color: var(--accent); }

.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  grid-template-areas: 'chips chips chips' 'bar field send';
  align-items: center;
  column-gap: 12px;
  position: relative;
  isolation: isolate;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  background: var(--raised);
  border-radius: 12px;
  transition: border-color var(--t) var(--e);
}

.composer:hover, .composer:focus-within, .composer.over, .composer.live, .composer.writing { border-color: var(--accent); }

/* Two accent layers over the panel while the microphone is on. The first
   shows that it is on; the second follows the voice, frame by frame. */
.composer::before, .composer::after {
  content: '';
  position: absolute;
  inset: -1px;
  z-index: -1;
  border-radius: 12px;
  background-color: var(--accent);
  opacity: 0;
  pointer-events: none;
}

.composer::before { transition: opacity var(--t) var(--e); }
.composer.live::before { opacity: .1; }
.composer.writing::before { animation: hum calc(var(--t) * 4) var(--e) infinite alternate; }
.composer::after { opacity: calc(var(--level, 0) * .45); }

/* The top edge is a handle: dragging it up makes the message field taller. */
.grip {
  position: absolute;
  top: -8px;
  right: 0;
  left: 0;
  height: 16px;
  cursor: ns-resize;
  touch-action: none;
  outline: none;
}

.grip::after {
  content: '';
  position: absolute;
  top: 6px;
  left: calc(50% - 16px);
  width: 32px;
  height: 4px;
  border-radius: 999px;
  background-color: color-mix(in srgb, var(--paper) 60%, var(--ink));
  transition: background-color var(--t) var(--e);
}

.grip:hover::after, .grip:focus-visible::after, .grip.held::after { background-color: var(--accent); }

/* passport-gate: wolf-asked "make it so the | line will be in-line with the line of divider between buttons and input area" */
.field {
  grid-area: field;
  box-sizing: border-box;
  /* passport-gate: wolf-asked "make it so the input area at least a bit increases the size to try to fit user's message" */
  /* As high as its text, from the height the visitor set with the handle. Never more than half of the visible area, so an open keyboard leaves room for the conversation. */
  min-height: max(56px, min(var(--field, 56px), calc(var(--view, 100dvh) / 2)));
  max-height: max(56px, calc(var(--view, 100dvh) / 2));
  /* 16px above the text keeps it level with the divider; 12px under it lets one line fit in 56px, so no scrollbar is drawn while nothing overflows. */
  padding: 16px 0 12px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  scrollbar-color: var(--accent) var(--ink);
  outline: none;
}

.field b, .field strong { font-weight: 600; }

/* Placeholder: held out of the flow, shown only while the field is empty and the visitor is signed in. */
.field { position: relative; }
.field::before {
  content: attr(data-empty);
  position: absolute;
  inset: 16px auto auto 0;
  font-style: italic;
  color: color-mix(in srgb, var(--paper) 60%, var(--ink));
  opacity: 0;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
  transition: opacity var(--t) var(--e);
}
.composer:not(.locked) .field:empty::before { opacity: 1; }

/* The controls stay at the bottom when the field is stretched. A hairline parts them from the field. */
.bar { grid-area: bar; align-self: end; display: flex; align-items: center; gap: 8px; margin-bottom: 8px; padding-right: 12px; border-right: 1px solid var(--line-strong); }

/* Closed until the visitor attaches something. */
.chips {
  grid-area: chips;
  min-width: 0;
  height: 0;
  overflow: hidden;
  transition: height var(--t) var(--e);
  display: flex;
  align-items: center;
  gap: 8px;
  scrollbar-color: var(--accent) var(--ink);
}

.chips.has { height: 40px; overflow-x: auto; }

.tool, .send {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  line-height: 1;
}

.tool {
  border: 1px solid var(--line);
  background-color: transparent;
  transition: background-color var(--t) var(--e), border-color var(--t) var(--e),
    color var(--t) var(--e), opacity var(--t) var(--e);
}

.tool:hover { background-color: var(--wash); border-color: var(--line-strong); }
.tool:active { color: var(--accent); }
.tool.attach, .tool.broom { padding: 0; }
.tool.attach svg, .tool.broom svg { display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.tool:disabled { opacity: .55; cursor: default; }
@media not (hover: hover) { .tool.broom:disabled { opacity: .55; } }
.tool.mic { position: relative; padding: 0; }
.tool.mic svg { display: block; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; transition: opacity var(--t) var(--e); }
.tool.mic::after { content: '↻'; position: absolute; inset: 0; display: grid; place-items: center; opacity: 0; transition: opacity var(--t) var(--e); }
.tool.mic.again svg { opacity: 0; }
.tool.mic.again::after { opacity: 1; }
.tool.mic.live { background-color: var(--accent); border-color: var(--accent); color: var(--ink); }
.tool.done { color: var(--accent); }

.send {
  grid-area: send;
  align-self: end;
  margin-bottom: 8px;
  border: none;
  background-color: var(--accent);
  color: var(--ink);
  font-size: 24px;
  transition: background-color var(--t) var(--e), filter var(--t) var(--e), opacity var(--t) var(--e);
}

/* passport-gate: wolf-asked "add STOP button on the prompt that replaces arrow \"enter\" button" */
/* The arrow and the stop square share one slot and cross-fade. */
.composer .send { display: grid; place-items: center; padding: 0; }
.composer .send > * { grid-area: 1 / 1; transition: opacity var(--t) var(--e); }
.composer .send svg { display: block; fill: currentColor; stroke: currentColor; stroke-width: 2; stroke-linejoin: round; opacity: 0; }
.composer .send.stop span { opacity: 0; }
.composer .send.stop svg { opacity: 1; }

.send:hover:enabled { filter: brightness(1.12); }
.send:active:enabled { filter: brightness(.88); }
.send:disabled { opacity: .55; cursor: default; }

/* A narrow window: the header row holds the kind label and the controls only, so it never
   runs past the right edge. The sidebar already names the agent. */
@media (max-width: 900px) {
  .hero img, .hero .names { display: none; }
}

@media (max-width: 700px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); }
  .side { padding: 16px 12px; border-right: none; border-bottom: 1px solid var(--line); }
  .side { display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 12px; }
  .brand { margin: 0 8px 16px; }
  .credit, .foot { display: none; }
  .about { height: 32px; margin: 0 8px 16px 0; padding: 0 12px; }
  /* One tile for the selected agent; the others slide in from the right over the sessions. */
  .switch { grid-column: 1 / -1; display: grid; grid-template-columns: auto auto minmax(0, 1fr); column-gap: 8px; overflow: hidden; }
  .anew { grid-area: 1 / 2; box-sizing: border-box; height: 40px; margin: 0; padding: 0 12px; }
  .now {
    display: flex;
    align-items: center;
    gap: 8px;
    box-sizing: border-box;
    height: 40px;
    padding: 0 12px 0 4px;
    border: 1px solid color-mix(in srgb, var(--accent) 42%, var(--ink));
    border-radius: 12px;
    background-color: color-mix(in srgb, var(--accent) 11%, var(--ink));
    color: var(--accent);
    font-size: 14px;
    font-weight: 600;
    transition: background-color var(--t) var(--e), border-color var(--t) var(--e),
      color var(--t) var(--e), filter var(--t) var(--e);
  }
  .now img { width: 32px; height: 32px; flex: none; }
  .now:active { filter: brightness(.88); }
  .own { display: contents; }
  .own > * { width: auto; }
  .every, .fresh { display: none; }
  /* New chat is not shown here, so the language control takes the free space on its left. */
  .fresh + .tool.lang { margin-left: auto; }
  .all .sheet { height: 100%; }
  .all .sheet > .list { flex: 1 1 0; }
  .past { grid-area: 1 / 3; min-width: 0; }
  .agents { grid-area: 1 / 2 / 2 / 4; min-width: 0; }
  .past { flex-direction: row; overflow: auto hidden; scrollbar-color: var(--accent) var(--ink); }
  .past:empty { display: flex; }
  .session { box-sizing: border-box; height: 40px; max-width: 160px; padding: 0 12px; border-color: var(--line); }
  .sheet { display: flex; flex-direction: column; padding: 0 24px 24px; }
  .sheet > * { flex: none; }
  .intro .lead { font-size: 18px; }
  .intro .by { font-size: 14px; }
  /* The first row of every panel and its close control stay in view while the panel scrolls. */
  .sheet > .top { position: sticky; top: 0; z-index: 1; margin: -16px -24px; padding: 24px 56px 16px 24px; background: var(--ink); }
  .sheet > .shut { position: sticky; top: 16px; right: auto; z-index: 2; align-self: flex-end; margin: 16px -8px -56px 0; }
  .agents {
    z-index: 1;
    display: flex;
    gap: 4px;
    background: var(--ink);
    overflow: auto hidden;
    scrollbar-color: var(--accent) var(--ink);
    opacity: 0;
    visibility: hidden;
    transform: translateX(100%);
    transition: transform var(--t) var(--e), opacity var(--t) var(--e), visibility var(--t) var(--e);
  }
  .agents.open { opacity: 1; visibility: visible; transform: none; }
  button.agent { flex: 1 0 auto; box-sizing: border-box; height: 40px; gap: 8px; justify-content: center; padding: 0 8px; font-size: 14px; }
  button.agent[aria-pressed=true] { display: none; }
  .agents .kind { display: none; }
  .cut { display: block; flex: none; align-self: center; width: 1px; height: 24px; background-color: var(--line-strong); }
  .cut:has(+ .kind + button.agent[aria-pressed=true]:last-child) { display: none; }
  button.agent img { width: 32px; height: 32px; }
  button.agent::after { display: none; }
  button.agent .off { margin-left: 0; }
  /* The wing holds its slot after the name on every tile, busy or not. */
  .working { position: static; padding: 0; transform: none; }
  .stage { padding: 16px; gap: 12px; }
  .tongues { top: 64px; right: 16px; max-width: calc(100% - 32px); }
  .composer { grid-template-columns: minmax(0, 1fr) auto; grid-template-areas: 'chips chips' 'field field' 'bar send'; row-gap: 4px; }
  .bar { margin-bottom: 0; padding-right: 0; border-right: none; }
  .field { padding: 0; }
  .field::before { inset: 0 auto auto 0; }
  .send { margin-bottom: 0; }
  .msg { gap: 8px; }
  .msg > img { width: 32px; height: 32px; }
  .msg:not(.agent) .bubble { padding: 4px 12px; }
  .msg > .copy { display: none; }
  /* Two tiles in a row; with three or five foods the best one takes the whole first row. */
  .versus .rival, .n5 .rival:nth-child(-n+2) { grid-column: span 3; }
  .n3 .rival:first-child, .n5 .rival:first-child { grid-column: span 6; }
  .rank { flex-wrap: wrap; }
  /* The columns of a menu follow one another in one column. */
  .food.menu { grid-template-columns: minmax(0, 1fr); }
}

/* A step through the history the page did not start: the browser may have
   drawn it already, so the page applies it without its own motion. */
.still *, .still *::before, .still *::after { transition: none !important; }
.still .brief[open] { animation: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 1ms !important;
    animation-duration: 1ms !important;
    animation-delay: 0s !important;
  }
  .composer.writing::before { animation-iteration-count: 1 !important; }
  .bubble.wait .wing path, .working > .wing path { animation: none; }
  .cup .sign, .glow { animation: none; }
  .composer.writing::before { opacity: .1; }
}
