/*
 * Оформление облачного веб-клиента Tailchat.
 * Тема: терминальная (TC) — тёмный фон, моноширинный шрифт, зелёные/циановые
 * акценты и чёткие границы, повторяющие интерфейс терминального клиента.
 */

:root {
  color-scheme: dark;

  --paper: #070a0e;
  --surface: #0c1118;
  --raised: #151c25;
  --ink: #e8edf2;
  --muted: #919ba7;
  --line: #29323d;
  --line-soft: #1b2430;
  --cobalt: #70b7ff;
  --cobalt-ink: #070a0e;
  --signal: #56c568;
  --signal-ink: #061008;
  --signal-soft: #102a19;
  --signal-line: #2f8f43;
  --amber: #d9a62e;
  --danger: #ff6863;
  --ai: #bc8cff;
  --ai-soft: #26193b;
  --signal-glow: rgba(86, 197, 104, 0.28);

  --step-1: 4px;
  --step-2: 8px;
  --step-3: 12px;
  --step-4: 16px;
  --step-5: 24px;
  --step-6: 32px;

  --text-xs: 0.72rem;
  --text-sm: 0.8rem;
  --text-md: 0.88rem;
  --text-lg: 1rem;
  /* Shared vector height for bubble and roster receipts, independent of the
     surrounding line's font size. Queued/failed text uses the same size. */
  --receipt-size: 0.72rem;
  --receipt-single: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 12'><path d='M1 6.25 L3.9 9.15 L9 2.85' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  --receipt-double: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14.2 12'><path d='M1 6.25 L3.9 9.15 L9 2.85' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/><path d='M5.2 6.25 L8.1 9.15 L13.2 2.85' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/></svg>");
  --leading-tight: 1.35;
  --leading-body: 1.55;
  --track-caps: 0.08em;
  --dur-fast: 150ms;

  /* Rounder throughout: the terminal look survives sharp *lines*, not sharp
     corners, and every surface a finger touches reads better as a lozenge.
     One factor scales the lot, so «Скругление» in settings is a single knob
     rather than six. The pill is deliberately outside the scale: a fully round
     end is a shape, not an amount of rounding, and scaling it would turn
     buttons into lozenges nobody asked for. */
  --round: 1;
  --radius-s: calc(8px * var(--round));
  --radius-m: calc(14px * var(--round));
  --radius-l: calc(20px * var(--round));
  --radius-bubble: calc(18px * var(--round));
  --radius-tail: calc(6px * var(--round));
  --radius-pill: 999px;
  /* Touch targets: 48px is the platform minimum both Material and HIG land
     on, and the composer row is the one place in the app people aim at in a
     hurry. The old 38/40 pair was below it on every axis. */
  --tap: 48px;
  --rail: 34px;
  --field: 46px;
  --roster-w: 288px;
  --info-w: 236px;
  /* 1.130, flat: own messages are the accent's tone, not a separate hand-picked
     hex per palette — one rule, so a palette change cannot leave its bubbles
     behind. `--own-tone` is the only per-palette knob (14% here, 20% light
     book, 12% light mono), picked so body text holds 9:1 and the meta line and
     the own-side label (`--own-accent`) 4.5:1 on the result; dark mono's meta
     needs its own colour (see the mono rule by the palettes). The own label is
     the accent pulled 30% towards ink: the raw accent on its own tint drops
     under 4.5:1 on most light palettes (green: 3.85:1). */
  --own-tone: 14%;
  --own-bubble-bg: color-mix(in srgb, var(--signal) var(--own-tone), var(--surface));
  /* A surface inside a bubble (bot buttons, a file card, a voice note): one
     step away from whichever bubble it sits in — lighter on a dark palette,
     darker on a light one, because the step is a veil of ink. */
  --bubble-step: color-mix(in srgb, var(--ink) 7%, transparent);
  --own-accent: color-mix(in srgb, var(--signal) 70%, var(--ink));

  /* Decorative edges. The layout separates surfaces by tone and spacing; a line
     around them is the «Обводки» switch (`data-borders`, app.js `setBorders`).
     Every decorative border keeps its width and takes its colour from these
     two, so flipping the switch never moves a pixel of layout. Focus rings and
     the borders that mean something (a pending message, a selection) do not
     read them. */
  --edge: transparent;
  --edge-soft: transparent;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);

  --ease: cubic-bezier(0.16, 1, 0.3, 1);
  --ring: 0 0 0 3px color-mix(in srgb, var(--cobalt) 28%, transparent);
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.28), 0 2px 5px rgba(0, 0, 0, 0.18);
  --shadow-2: 0 8px 20px -6px rgba(0, 0, 0, 0.48), 0 3px 8px -4px rgba(0, 0, 0, 0.36);
  --shadow-3: 0 24px 56px -16px rgba(0, 0, 0, 0.68), 0 8px 20px -8px rgba(0, 0, 0, 0.5);

  --mono: "Roboto Mono", "SF Mono", "SFMono-Regular", Menlo, Monaco, Consolas, "Liberation Mono", "DejaVu Sans Mono", monospace;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
  /* An old-style serif, found rather than shipped: no font file is downloaded,
     because the page is served under a strict CSP and has to work offline. The
     stack walks from real Garamonds through the Garamond-adjacent faces that
     macOS, iOS and Windows actually install, so somewhere in it every platform
     lands on an old-style serif rather than falling all the way to Times. */
  --serif: "EB Garamond", "Adobe Garamond Pro", "Garamond", "Cormorant Garamond",
    "Hoefler Text", "Baskerville", "Palatino Linotype", "Palatino", "Book Antiqua",
    Georgia, "Times New Roman", serif;

  --ui-font: var(--mono);
  font-family: var(--ui-font);
}

:root[data-font="sans"] { --ui-font: var(--sans); }
:root[data-font="serif"] { --ui-font: var(--serif); }

:root[data-round="sharp"] { --round: 0.28; }
:root[data-round="soft"] { --round: 1; }
:root[data-round="round"] { --round: 1.55; }

html[data-borders="on"] {
  --edge: var(--line);
  --edge-soft: var(--line-soft);
}

/* --- Icons: shared inline-SVG glyph set (stroke, currentColor) ----------- */
.icon {
  width: 18px;
  height: 18px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--paper);
  color: var(--ink);
  overflow: hidden;
  font-family: inherit;
  letter-spacing: -0.01em;
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
  font-family: inherit;
}

button {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

:where(button, input, textarea, a):focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 1px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

.eyebrow {
  margin: 0 0 var(--step-1);
  color: var(--signal);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.eyebrow::before {
  content: "[ ";
  color: var(--muted);
}

.eyebrow::after {
  content: " ]";
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.noscript-note {
  margin: 0;
  padding: var(--step-4);
  background: var(--danger);
  color: #fff;
  font-size: var(--text-md);
}

/* --- загрузка ----------------------------------------------------------- */

.boot {
  display: grid;
  place-content: center;
  height: 100dvh;
  padding: var(--step-5);
  text-align: center;
}

.boot .eyebrow {
  margin-bottom: var(--step-2);
}

.auth {
  display: grid;
  place-items: start center;
  min-height: 100dvh;
  padding: calc(var(--step-5) + var(--safe-top)) var(--step-4) var(--step-5);
  overflow-y: auto;
}

.auth-top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--step-2);
  margin-bottom: var(--step-2);
}

/* На карточке входа кнопке установки хватает глифа: подпись «Установить»
   выдавливала заголовок в перенос. */
.auth-top-bar .pwa-install-label {
  display: none;
}

.lang-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.lang-btn {
  min-height: 24px;
  padding: 2px 7px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-s);
  background: var(--raised);
  color: var(--muted);
  font-family: inherit;
  font-size: var(--text-xs);
  font-weight: 700;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.lang-btn:hover {
  color: var(--ink);
}

.lang-btn:active {
  transform: translateY(1px);
}

.lang-btn.active {
  color: var(--signal);
  background: var(--signal-soft);
}

.auth-card {
  width: min(100%, 420px);
  margin: 0 auto;
  padding: var(--step-5) var(--step-4) var(--step-4);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-l);
  background: var(--surface);
}

.auth-title {
  margin-bottom: var(--step-2);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-title::before {
  content: "> ";
  color: var(--cobalt);
}

.auth-lead {
  margin-bottom: var(--step-4);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.5;
}

.auth-form {
  display: grid;
  gap: var(--step-3);
}

.field {
  display: grid;
  gap: var(--step-1);
}

.field label {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--muted);
}

.field input {
  min-height: var(--field);
  padding: 0 var(--step-3);
  border: 1px solid var(--edge);
  border-radius: var(--radius-m);
  background: var(--raised);
  /* Below 16px, iOS Safari zooms the whole page in on focus and does not
     reliably zoom back out — read as "the scale drifts / doesn't fit" on a
     phone. 16px is the documented threshold that keeps it from firing. */
  font-size: 16px;
  color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

.field input:focus {
  border-color: var(--cobalt);
  /* Was a hardcoded dark navy, which turned the focused field into a black
     hole on light backgrounds now that light is a first-class mode. */
  background: var(--surface);
  box-shadow: var(--ring);
  outline: none;
}

.field input:disabled {
  border-color: var(--edge-soft);
  background: var(--line-soft);
  color: var(--muted);
  cursor: not-allowed;
}

.password-wrap {
  position: relative;
  display: flex;
  align-items: center;
}

.password-wrap input {
  width: 100%;
  padding-right: 42px;
}

.pass-toggle-btn {
  position: absolute;
  right: 6px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  border-radius: var(--radius-s);
  font-size: var(--text-lg);
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
  user-select: none;
}

.pass-toggle-btn:hover {
  color: var(--ink);
}

.pass-toggle-btn:active {
  transform: scale(0.9);
}

.field-hint {
  margin: 0;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.4;
}

.primary-button {
  min-height: var(--tap);
  margin-top: var(--step-1);
  padding: 0 var(--step-4);
  border: 1px solid transparent;
  border-radius: var(--radius-m);
  background: var(--signal);
  color: var(--signal-ink);
  font-weight: 700;
  font-size: var(--text-md);
  transition: filter var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}

.primary-button:hover:not(:disabled) {
  filter: brightness(1.08);
  opacity: 0.96;
}

.primary-button:active:not(:disabled) {
  transform: translateY(1px);
}

.primary-button:disabled {
  border-color: var(--edge);
  background: var(--raised);
  color: var(--muted);
  opacity: 0.65;
  cursor: not-allowed;
}

.auth-error {
  min-height: 1.3em;
  margin: var(--step-3) 0 0;
  color: var(--danger);
  font-size: 0.8rem;
  line-height: 1.4;
}

.auth-switch {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin: var(--step-2) 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

.link-button {
  min-height: var(--tap);
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--cobalt);
  font-size: 0.82rem;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* --- каркас ------------------------------------------------------------- */

.app {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) auto;
  height: 100dvh;
}

.app > .roster,
.app > .talk,
.app > .info {
  grid-row: 1;
  grid-column: 1;
  min-width: 0;
}

/* Одна колонка: панели переключаются целиком, а не сжимаются. */
@media (max-width: 719.98px) {
  .app[data-pane="list"] > .talk,
  .app[data-pane="list"] > .info,
  .app[data-pane="talk"] > .roster,
  .app[data-pane="talk"] > .info,
  .app[data-pane="info"] > .roster,
  .app[data-pane="info"] > .talk {
    display: none;
  }

  /* .roster normally carries the real left edge's safe-area padding; it is
     hidden here, so .talk becomes the flush-left pane instead and needs the
     same padding, or content flush against that edge — the logo band first
     among it — crops under a landscape notch/rounded corner. */
  .app[data-pane="talk"] > .talk {
    padding-left: var(--safe-left);
  }

  .pane-grip {
    display: none;
  }
}

/* --- колонка собеседников ---------------------------------------------- */

.roster {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  min-height: 0;
  overflow: hidden;
  padding-left: var(--safe-left);
  background: var(--surface);
}

.roster-top {
  padding: calc(var(--step-3) + var(--safe-top)) var(--step-3) var(--step-2);
  border-bottom: 1px solid var(--edge-soft);
}

.roster-title {
  margin-bottom: var(--step-2);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.roster-title::before {
  content: "# ";
  color: var(--cobalt);
}

.roster-self {
  display: grid;
  grid-template-areas: "name action" "login action";
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px var(--step-2);
  min-width: 0;
  padding: var(--step-1) var(--step-2);
  border-radius: var(--radius-s);
  background: var(--raised);
  border: 1px solid var(--edge-soft);
}

.roster-self-name-row {
  grid-area: name;
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 6px;
}

/* A compact echo of the footer's connection indicator (see `.connection` in
   the statusline), so "am I online" reads next to the name it belongs to —
   the footer keeps the full dot+label version because the roster itself is
   hidden on a phone while a conversation is open (see the `data-pane`
   media query), and the status would otherwise vanish mid-chat. */
.roster-self-dot {
  flex-shrink: 0;
}

.roster-self-name {
  overflow: hidden;
  min-width: 0;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--signal);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster-self-login {
  grid-area: login;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.profile-open-button {
  grid-area: action;
  min-height: 28px;
  padding: 0 var(--step-2);
  border: 1px solid var(--edge);
  border-radius: var(--radius-s);
  background: var(--surface);
  color: var(--cobalt);
  font-size: 0.7rem;
  font-weight: 700;
}

.profile-open-button:hover {
  color: var(--signal);
}

.roster-list {
  min-height: 0;
  padding: var(--step-2) var(--step-2) var(--step-4);
  margin: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  list-style: none;
}

.roster-row {
  position: relative;
  margin-bottom: var(--step-1);
}

/* Sits over the row's bottom-right corner rather than in the row's grid, so
   the existing name/preview/status/badge areas keep their widths exactly as
   they were. Bottom, not top: the badge column's top is where the unread
   pill and the mark/time corner live (`.roster-badge`, `.roster-meta`), and
   stacking this trigger there put the «⋯» directly over the time on every row
   that had no unread — the bottom-right corner sits beside the short presence
   line instead, which is always empty space in that column. */
.roster-menu-btn {
  position: absolute;
  bottom: 4px;
  right: 4px;
  width: 26px;
  height: 26px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--muted);
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms ease, background 120ms ease, color 120ms ease;
}

.roster-row:hover .roster-menu-btn,
.roster-menu-btn:focus-visible {
  opacity: 1;
}

.roster-menu-btn:hover {
  background: var(--signal-soft);
  color: var(--ink);
}

/* No hover on a touch screen, so the trigger is simply always there. */
@media (hover: none) {
  .roster-menu-btn {
    opacity: 1;
  }
}

.roster-item {
  display: grid;
  grid-template-areas: "name badge" "preview badge" "status badge";
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 2px var(--step-2);
  width: 100%;
  min-height: 68px;
  padding: var(--step-2) var(--step-3);
  border: 1px solid var(--edge);
  border-radius: var(--radius-m);
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--ink);
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

/* 1.130, flat: a row is told apart by tone alone — hover the accent's soft
   fill, the open conversation the same accent tone as one's own bubbles —
   with no lift, card edge or side bar. On that stronger tone the accent name
   takes `--own-accent` and the grey lines move a step towards ink: the raw
   accent and `--muted` both drop under 4.5:1 there on the light palettes,
   the book and dark mono (`--muted` 3.55:1); pulled towards ink they clear it
   on every palette. */
.roster-item:hover {
  background: var(--signal-soft);
}

.roster-item.active,
.roster-item[aria-current="true"] {
  background: color-mix(in srgb, var(--signal) var(--own-tone), var(--surface));
}

.roster-item.active .roster-name,
.roster-item[aria-current="true"] .roster-name,
.roster-item.active .roster-status[data-online="online"],
.roster-item[aria-current="true"] .roster-status[data-online="online"] {
  color: var(--own-accent);
}

.roster-item:is(:hover, .active, [aria-current="true"]) :is(.roster-preview, .roster-meta, .roster-status[data-online="offline"]) {
  color: color-mix(in srgb, var(--muted) 60%, var(--ink));
}

/* Server-flagged block (`user.blocked`, never a client-local store — unlike
   the pin above). Muted, not hidden: the contact stays a friend and stays
   in the roster, only new live traffic between the two sides is cut off. */
.roster-item[data-blocked="true"] {
  opacity: 0.55;
}

.roster-name {
  grid-area: name;
  overflow: hidden;
  font-size: 0.88rem;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* The last thing said in the conversation, under the name. Clipped to one
   line: this is a reminder of where the thread left off, not a reading view. */
.roster-preview {
  display: flex;
  grid-area: preview;
  align-items: baseline;
  gap: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-xs);
  letter-spacing: 0.01em;
  white-space: nowrap;
}

/* The label that opens the line. `You:` must never be shrunk — a clipped `You…`
   says nothing — while an AI row puts the model's own name here, long enough to
   eat the whole line. `flex: 0 0 auto` keeps the label at its natural width and
   `max-width` caps the long one, where `overflow`/`text-overflow` turn it into an
   ellipsis. The message body is the part that yields first; the delivery mark
   is not on this line at all (see `.roster-meta`). */
.roster-preview-author {
  flex: 0 0 auto;
  max-width: 40%;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  font-weight: 700;
}

.roster-preview-text {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roster-status {
  display: flex;
  grid-area: status;
  align-items: baseline;
  gap: 5px;
  overflow: hidden;
  color: var(--muted);
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster-status[data-online="online"] {
  color: var(--signal);
}

.roster-status[data-online="idle"],
.roster-status[data-online="away"] {
  color: var(--amber);
}

/* Служебный аккаунт: подпись вместо присутствия, акцентным цветом палитры —
   как `serviceStyle` в APK (android/.../ui/CloudScreen.kt:1036). */
.roster-status[data-online="service"] {
  color: var(--cobalt);
}

.roster-item[data-official="true"]:not(.active):not([aria-current="true"]) .roster-name {
  color: var(--cobalt);
}

.roster-badge {
  display: grid;
  grid-area: badge;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: var(--radius-s);
  background: var(--signal);
  color: var(--signal-ink);
  font-size: 0.7rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* The top-right corner: delivery mark, then time — `✓✓ 12:40` (issue #25,
   owner 2026-10-27). A column of its own rather than the tail of the preview,
   so the mark lands in the same place on every row whatever the text length.
   `--receipt-size` is the mark's own (see `.roster-mark` with `.bubble-mark`);
   the colour is the muted grey `sent`/`ack` inherit, `read` takes the accent. */
.roster-meta {
  display: flex;
  grid-area: badge;
  align-self: start;
  justify-self: end;
  align-items: center;
  gap: 4px;
  color: var(--muted);
}

.roster-time {
  font-family: var(--mono);
  font-size: 0.69rem;
  font-variant-numeric: tabular-nums;
}

.roster-title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px 34px;
  align-items: center;
  gap: var(--step-2);
  margin-bottom: var(--step-2);
}

.roster-title-row .roster-title {
  margin-bottom: 0;
}

/* Replaces the old full-width dashed button that used to sit in its own
   footer row — a compact icon next to the title it belongs to instead. */
.roster-add-button,
.roster-search-button {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  min-width: 38px;
  min-height: 38px;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 50%;
  background: var(--raised);
  color: var(--signal);
}

.roster-add-button:hover,
.roster-search-button:hover {
  background: var(--signal-soft);
}

.roster-search {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: var(--step-2);
}

.roster-search[hidden],
.roster-title-row[hidden] {
  display: none;
}

.roster-search .workspace-search {
  flex: 1;
}

.roster-add-button .icon {
  width: 18px;
  height: 18px;
}

.action-button {
  min-height: var(--tap);
  padding: 0 var(--step-4);
  border: 1px dashed var(--edge);
  border-radius: var(--radius-pill);
  background: var(--signal-soft);
  color: var(--signal);
  font-size: var(--text-md);
  font-weight: 700;
  text-align: center;
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.action-button:hover {
  filter: brightness(1.08);
}

.action-button:active {
  transform: translateY(1px);
}

.quiet-button {
  min-height: var(--tap);
  padding: 0 var(--step-3);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--danger);
  font-size: var(--text-sm);
  font-weight: 700;
  transition: background var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

/* --- Настройки приложения ---------------------------------------------- */

.settings-dialog .modal-card {
  width: min(460px, 94vw);
  max-height: 88vh;
  overflow-y: auto;
  /* The card is the only thing that scrolls, and its own rounded edge is what
     clips the scrollbar. Without this the bar was drawn past the corner, beside
     the outline rather than inside it. */
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: var(--line) transparent;
}

.settings-dialog .modal-card::-webkit-scrollbar {
  width: 8px;
}

.settings-dialog .modal-card::-webkit-scrollbar-track {
  background: transparent;
}

.settings-dialog .modal-card::-webkit-scrollbar-thumb {
  border-radius: var(--radius-pill);
  background: var(--line);
}

.settings-section {
  display: grid;
  gap: var(--step-2);
}

.settings-heading {
  margin: var(--step-3) 0 0;
  color: var(--muted);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
}

.segmented {
  display: flex;
  gap: 2px;
  padding: 3px;
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-pill);
  background: var(--paper);
}

.segmented-btn {
  flex: 1;
  min-height: 36px;
  padding: 0 var(--step-2);
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.segmented-btn.active {
  background: var(--signal);
  color: var(--signal-ink);
}

.segmented-btn:hover:not(.active) {
  color: var(--ink);
  background: var(--raised);
}

.segmented-btn:active {
  transform: scale(0.98);
}

.scheme-grid {
  display: flex;
  flex-wrap: wrap;
  gap: var(--step-1);
}

.scheme-btn {
  min-height: 36px;
  padding: 0 var(--step-3);
  border: 1px solid var(--edge);
  border-radius: var(--radius-pill);
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.scheme-btn.active {
  background: var(--signal-soft);
  color: var(--signal);
  font-weight: 700;
}

.scheme-btn:hover:not(.active) {
  background: var(--signal-soft);
}

.scheme-btn:active {
  transform: translateY(1px);
}

.settings-toggle {
  display: flex;
  align-items: center;
  gap: var(--step-2);
  min-height: var(--tap);
  padding: 0 var(--step-2);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-m);
  background: var(--raised);
  font-size: var(--text-md);
  cursor: pointer;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.settings-toggle:hover {
  background: var(--signal-soft);
}

.settings-toggle input {
  width: 20px;
  height: 20px;
  accent-color: var(--signal);
}

.settings-slider {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--step-2);
  min-height: var(--tap);
  padding: 0 var(--step-2);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-m);
  background: var(--raised);
  font-size: var(--text-md);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.settings-slider input {
  flex: 1 1 auto;
  min-width: 80px;
  max-width: 160px;
  accent-color: var(--signal);
}

.settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--step-2);
}

#settings-sound-custom-name {
  display: inline-flex;
  align-items: center;
  font-size: var(--text-sm);
  color: var(--muted);
}

/* Deliberately understated: these are things one does once (install the app,
   grab the APK, sign out), not part of the daily loop. */
.settings-link-btn {
  min-height: var(--tap);
  padding: 0 var(--step-4);
  border: 1px solid var(--edge);
  border-radius: var(--radius-pill);
  background: var(--raised);
  color: var(--muted);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 700;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.settings-link-btn:hover {
  color: var(--ink);
  background: var(--signal-soft);
}

.settings-link-btn:active {
  transform: translateY(1px);
}

.settings-danger {
  color: var(--danger);
}

.settings-danger:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.settings-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.7rem;
}

/* The APK link on the sign-in screen: a chip, not an underlined link, and
   quiet enough that it never competes with the login form. */
.auth-apk-wrap {
  margin: var(--step-3) 0 0;
  text-align: center;
}

.apk-chip {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 0 var(--step-3);
  border: 1px solid var(--edge);
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-decoration: none;
  opacity: 0.7;
  transition: opacity 120ms ease, border-color 120ms ease, color 120ms ease;
}

.apk-chip:hover {
  opacity: 1;
  color: var(--ink);
}

/* --- модальное окно инвайтов ------------------------------------------- */

.modal-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  max-width: min(92vw, 480px);
  /* A <dialog> scrolls itself by default, and its scrollbar sits outside the
     card's border — which is the bar hanging past the rounded outline. The card
     manages its own height, so the dialog never needs to. */
  overflow: hidden;
  border-radius: var(--radius-l);
}

.modal-dialog::backdrop {
  background: rgba(3, 6, 10, 0.66);
  backdrop-filter: blur(4px);
}

.modal-card {
  padding: var(--step-4);
  border: 1px solid var(--edge);
  border-radius: var(--radius-l);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-3);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--step-3);
  padding-bottom: var(--step-2);
  border-bottom: 1px solid var(--edge-soft);
}

.modal-title {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
}

.modal-title::before {
  content: "+ ";
  color: var(--signal);
}

.modal-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  min-width: 32px;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: var(--radius-s);
  background: var(--raised);
  color: var(--muted);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.modal-close:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.modal-close:active {
  transform: scale(0.92);
}

.modal-section h3 {
  margin: 0 0 var(--step-1);
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--cobalt);
}

.modal-hint {
  margin: 0 0 var(--step-2);
  font-size: 0.76rem;
  color: var(--muted);
  line-height: 1.4;
}

.modal-divider {
  margin: var(--step-3) 0;
  border: 0;
  border-top: 1px solid var(--line-soft);
}

/* The emoji comparison (stage 7, encryption screens): seven cells that wrap
   on a phone, the three numbers under them. Both people read these aloud, so
   the glyphs are large and the captions are the protocol's own words. */
.sas-emojis {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--step-2);
  margin: var(--step-3) 0 var(--step-2);
}

.sas-emoji {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 4.5rem;
  margin: 0;
  padding: var(--step-2);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-m);
  background: var(--raised);
}

.sas-emoji-glyph {
  font-size: 2rem;
  line-height: 1.2;
}

.sas-emoji-label {
  font-size: var(--text-xs);
  color: var(--muted);
}

.sas-numbers {
  margin: 0 0 var(--step-3);
  text-align: center;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.08em;
  color: var(--ink);
}

.invite-box {
  display: flex;
  gap: var(--step-2);
  align-items: stretch;
}

.invite-box input {
  flex: 1;
  min-width: 0;
  min-height: var(--tap);
  padding: 0 var(--step-3);
  border: 1px solid var(--edge);
  border-radius: var(--radius-m);
  background: var(--raised);
  font-family: inherit;
  font-size: 16px; /* see .field input: keeps iOS from zooming on focus */
  color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.invite-box input:focus {
  border-color: var(--cobalt);
  box-shadow: var(--ring);
  outline: none;
}

.modal-status {
  min-height: 1.2em;
  margin: var(--step-2) 0 0;
  font-size: 0.76rem;
  line-height: 1.4;
}

.modal-status[data-kind="error"] {
  color: var(--danger);
}

.modal-status[data-kind="success"] {
  color: var(--signal);
}
.profile-card {
  display: grid;
  gap: var(--step-3);
  width: min(88vw, 440px);
  max-height: min(88dvh, 720px);
  overflow-y: auto;
}

.profile-card .modal-header,
.profile-card .modal-status {
  margin: 0;
}

.profile-card input[readonly] {
  color: var(--muted);
  cursor: default;
}

.profile-password-block {
  display: grid;
  gap: var(--step-2);
  padding-top: var(--step-3);
  border-top: 1px solid var(--line-soft);
}

.profile-password-block h3 {
  margin: 0;
  color: var(--cobalt);
  font-size: 0.86rem;
}

.profile-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--step-2);
}

.profile-actions .quiet-button,
.profile-actions .primary-button {
  margin: 0;
}

/* --- lightbox ------------------------------------------------------------
   The whole screen is the picture: no card, no title, no frame. The image is
   laid out at its natural size from the stage's top-left corner and placed by
   one transform the script owns, so zoom and pan never touch layout. The
   controls float, which is why they alone may carry a shadow. */
.lightbox {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  overflow: hidden;
  /* The fade follows a swipe down, so the transcript shows through as the
     picture is pulled away. */
  background: rgb(0 0 0 / calc(0.92 * var(--lightbox-fade, 1)));
  color: #fff;
  outline: none;
}

.lightbox::backdrop {
  background: transparent;
}

.lightbox-stage {
  position: absolute;
  inset: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.lightbox-image {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  max-height: none;
  transform-origin: 0 0;
  -webkit-user-drag: none;
}

.lightbox-image--loading {
  opacity: 0;
}

.lightbox-image--enter {
  animation: lightbox-enter var(--dur-fast) var(--ease);
}

@keyframes lightbox-enter {
  from { opacity: 0; }
}

.lightbox--animate .lightbox-image {
  transition: transform 200ms var(--ease);
}

.lightbox-counter {
  position: absolute;
  top: max(var(--step-3), env(safe-area-inset-top));
  left: 50%;
  margin: 0;
  padding: 2px var(--step-2);
  border-radius: var(--radius-pill);
  background: rgb(0 0 0 / 0.45);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  transform: translateX(-50%);
  pointer-events: none;
  transition: opacity var(--dur-fast) var(--ease);
}

.lightbox-controls {
  position: absolute;
  top: max(var(--step-3), env(safe-area-inset-top));
  right: max(var(--step-3), env(safe-area-inset-right));
  display: flex;
  gap: var(--step-2);
  transition: opacity var(--dur-fast) var(--ease);
}

.lightbox-control {
  display: inline-grid;
  place-items: center;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: rgb(0 0 0 / 0.45);
  color: #fff;
  box-shadow: 0 2px 10px rgb(0 0 0 / 0.35);
  opacity: 0.8;
  cursor: pointer;
  transition: opacity var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.lightbox-control:hover,
.lightbox-control:focus-visible {
  background: rgb(0 0 0 / 0.65);
  opacity: 1;
}

.lightbox--idle .lightbox-counter,
.lightbox--idle .lightbox-controls {
  opacity: 0;
  pointer-events: none;
}

.lightbox--idle .lightbox-controls:has(:focus-visible) {
  opacity: 1;
  pointer-events: auto;
}

.lightbox--idle .lightbox-stage {
  cursor: none;
}

/* --- лист превью картинки ------------------------------------------------
   Picture over the whole free area, the panel under it. The crop frame dims
   what it leaves out with an outsized spread shadow that the frame's
   `overflow: hidden` keeps on the picture. */
.image-sheet {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(0 0 0 / 0.92);
  color: var(--ink);
  outline: none;
}

.image-sheet:not([open]) {
  display: none;
}

.image-sheet::backdrop {
  background: transparent;
}

.image-sheet-stage {
  display: grid;
  place-items: center;
  min-height: 0;
  min-width: 0;
  margin: max(var(--step-3), env(safe-area-inset-top)) var(--step-3) var(--step-3);
  overflow: hidden;
}

.image-sheet-frame {
  position: relative;
  overflow: hidden;
  touch-action: none;
}

.image-sheet-canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.image-sheet-crop {
  position: absolute;
  box-shadow: 0 0 0 100vmax rgb(0 0 0 / 0.55);
  outline: 1px solid rgb(255 255 255 / 0.9);
  pointer-events: none;
}

.image-sheet--cropping .image-sheet-crop {
  cursor: move;
  pointer-events: auto;
}

.image-sheet-handle {
  position: absolute;
  display: none;
  width: 22px;
  height: 22px;
}

.image-sheet--cropping .image-sheet-handle {
  display: block;
}

.image-sheet-handle::before {
  content: '';
  position: absolute;
  inset: 6px;
  border-radius: 2px;
  background: #fff;
  box-shadow: 0 0 0 1px rgb(0 0 0 / 0.4);
}

/* Handles sit just inside the frame, so all eight remain visible when the
   crop still touches the picture's edges. */
.image-sheet-handle[data-handle="nw"] { top: 0; left: 0; cursor: nwse-resize; }
.image-sheet-handle[data-handle="n"] { top: 0; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.image-sheet-handle[data-handle="ne"] { top: 0; right: 0; cursor: nesw-resize; }
.image-sheet-handle[data-handle="e"] { top: 50%; right: 0; transform: translateY(-50%); cursor: ew-resize; }
.image-sheet-handle[data-handle="se"] { bottom: 0; right: 0; cursor: nwse-resize; }
.image-sheet-handle[data-handle="s"] { bottom: 0; left: 50%; transform: translateX(-50%); cursor: ns-resize; }
.image-sheet-handle[data-handle="sw"] { bottom: 0; left: 0; cursor: nesw-resize; }
.image-sheet-handle[data-handle="w"] { top: 50%; left: 0; transform: translateY(-50%); cursor: ew-resize; }

.image-sheet-panel {
  display: grid;
  gap: var(--step-2);
  padding: var(--step-3) max(var(--step-3), env(safe-area-inset-right))
    max(var(--step-3), env(safe-area-inset-bottom)) max(var(--step-3), env(safe-area-inset-left));
  background: var(--surface);
}

.image-sheet-ratios,
.image-sheet-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--step-2);
}

.image-sheet-ratios[hidden] {
  display: none;
}

.image-sheet-chip,
.image-sheet-action {
  min-height: var(--tap);
  padding: 0 var(--step-3);
  border: 1px solid var(--edge-soft, transparent);
  border-radius: var(--radius-pill);
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease);
}

.image-sheet-chip:hover,
.image-sheet-action:hover,
.image-sheet-chip[aria-pressed="true"],
.image-sheet-action[aria-pressed="true"] {
  background: var(--signal-soft);
}

.image-sheet-caption {
  flex: 1 1 220px;
  min-width: 0;
  min-height: var(--tap);
  max-height: 7.5em;
  padding: max(0px, calc((var(--tap) - 1lh - 2px) / 2)) var(--step-3);
  border: 1px solid var(--edge-soft, transparent);
  border-radius: var(--radius-m);
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-md);
  line-height: var(--leading-body);
  resize: none;
}

.image-sheet-send {
  margin-top: 0;
}

.empty-note {
  padding: var(--step-2) var(--step-3) var(--step-3);
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

/* --- разговор ----------------------------------------------------------- */

.talk {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  min-height: 0;
  padding-right: var(--safe-right);
  background: var(--paper);
}

.talk-top {
  display: flex;
  align-items: center;
  gap: var(--step-2);
  min-width: 0;
  padding: calc(var(--step-2) + var(--safe-top)) var(--step-3) var(--step-2);
  border-bottom: 1px solid var(--edge-soft);
  background: var(--surface);
}

.back-button {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 5px;
  min-height: var(--tap);
  padding: 0 var(--step-2) 0 0;
  border: 0;
  background: transparent;
  color: var(--cobalt);
  font-size: var(--text-sm);
  font-weight: 700;
  transition: color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.back-arrow {
  display: inline-flex;
  align-items: center;
}

.back-arrow .icon {
  width: 18px;
  height: 18px;
}

.talk-peer {
  display: block;
  min-width: 0;
  flex: 1 1 auto;
  padding: 2px var(--step-2) 2px 0;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: inherit;
  text-align: left;
}

/* --- Top Conversation Actions: P2P, Search, Menu (Issue #22: identical 40px circle) --- */
.direct-toggle,
.conversation-search-toggle,
.conversation-menu-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 40px;
  width: 40px;
  min-width: 40px;
  max-width: 40px;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: 50%;
  background: var(--raised);
  color: var(--ink);
  box-sizing: border-box;
  cursor: pointer;
  font: inherit;
  line-height: 1;
  transition: color var(--dur-fast) var(--ease),
    border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.conversation-menu-button {
  font: 700 1.25rem var(--mono);
  line-height: 1;
}

.direct-toggle .icon,
.conversation-search-toggle .icon {
  width: 18px;
  height: 18px;
}

.direct-toggle:disabled,
.conversation-search-toggle:disabled,
.conversation-menu-button:disabled {
  color: var(--muted);
  opacity: 0.45;
  cursor: not-allowed;
}

.msg-menu-item:disabled {
  opacity: 0.45;
  cursor: default;
}

.direct-toggle:hover:not(:disabled),
.conversation-search-toggle:hover:not(:disabled),
.conversation-menu-button:hover:not(:disabled) {
  color: var(--signal);
  background: var(--signal-soft);
}

.direct-toggle:active:not(:disabled),
.conversation-search-toggle:active:not(:disabled),
.conversation-menu-button:active:not(:disabled) {
  transform: translateY(1px);
}

.direct-toggle:focus-visible,
.conversation-search-toggle:focus-visible,
.conversation-menu-button:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 2px;
}

.conversation-search-toggle[aria-expanded="true"] {
  color: var(--signal);
  background: var(--signal-soft);
}

/* The direct link's state is the one ring in the header that is not
   decoration: amber while dialling, accent once connected, red when it
   failed — the same reading as the footer's connection dot — so it ignores
   «Обводки». */
.direct-toggle[data-state="connecting"] {
  border-color: var(--amber);
  color: var(--amber);
  animation: direct-pulse 1s ease-in-out infinite;
}

.direct-toggle[data-state="connected"] {
  border-color: var(--signal);
  background: var(--signal-soft);
  color: var(--signal);
}

.direct-toggle[data-state="failed"] {
  border-color: var(--danger);
  color: var(--danger);
}

@keyframes direct-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

.talk-peer:hover .talk-peer-name {
  color: var(--signal);
}

.talk-peer-name {
  display: block;
  overflow: hidden;
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.talk-peer-status {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: var(--text-xs);
  letter-spacing: 0.01em;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.talk-peer-status[data-online="online"] {
  color: var(--signal);
}

.talk-peer-status[data-online="idle"],
.talk-peer-status[data-online="away"] {
  color: var(--amber);
}

.talk-peer-status[data-online="offline"] {
  color: var(--muted);
}

.connection {
  display: inline-flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
}

.connection-dot {
  width: 8px;
  height: 8px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.connection[data-state="online"] {
  color: var(--signal);
}

.connection[data-state="online"] .connection-dot {
  background: currentColor;
}

.connection[data-state="connecting"] {
  color: var(--amber);
}

.logo-band {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 6px 8px;
  background: var(--surface);
  border-bottom: 1px solid var(--edge-soft);
  overflow: hidden;
  user-select: none;
  flex-shrink: 0;
}

.logo-art {
  display: block;
  width: fit-content;
  min-width: 0;
  margin: 0 auto;
  padding: 0;
  font-family: var(--mono);
  font-size: clamp(0.48rem, 2.3vw, 0.74rem);
  line-height: 1;
  letter-spacing: 0px;
  font-kerning: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0, "tnum" 1;
  text-rendering: geometricPrecision;
  color: var(--signal);
  white-space: pre;
  text-shadow: 0 0 8px var(--signal-glow);
  cursor: pointer;
  text-align: left;
  /* Set by `fitLogoBand`: how much the wordmark has to shrink to fit the talk
     column. `max-width`/`overflow: hidden` used to cut it off instead, which
     is what «логотип обрезан» was. A uniform scale keeps the half-block
     columns lined up; every animation below multiplies this factor rather
     than replacing it, or the logo would snap back to full width mid-pulse. */
  transform: scale(var(--logo-fit, 1));
  transform-origin: center center;
  transition: transform var(--dur-fast) var(--ease), text-shadow var(--dur-fast) var(--ease);
}

.logo-art:hover {
  transform: scale(calc(var(--logo-fit, 1) * 1.02));
  text-shadow: 0 0 14px var(--signal-glow);
}

/* The tap feedback for the logo band. A short scale-and-glow pulse, not a
   bounce: the wordmark is built from half-block glyphs whose columns must
   keep lining up, so nothing here touches letter-spacing or line-height. */
@keyframes logo-pulse {
  0% { transform: scale(var(--logo-fit, 1)); text-shadow: 0 0 8px var(--signal-glow); }
  35% { transform: scale(calc(var(--logo-fit, 1) * 1.08)); text-shadow: 0 0 22px var(--signal-glow); }
  70% { transform: scale(calc(var(--logo-fit, 1) * 0.99)); text-shadow: 0 0 12px var(--signal-glow); }
  100% { transform: scale(var(--logo-fit, 1)); text-shadow: 0 0 8px var(--signal-glow); }
}

.logo-art--pulse {
  animation: logo-pulse 420ms ease-out;
}

@media (prefers-reduced-motion: reduce) {
  .logo-art--pulse {
    animation: none;
  }
}

.transcript-wrapper {
  position: relative;
  min-height: 0;
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  overflow: hidden;
}

/* A serif at the same pixel size reads smaller than a monospace face, and
   message text is where that difference is felt. Scoped to `.bubble-text`
   itself, not the whole `.transcript`: the earlier, wider scope made
   `line-height` inherit into everything else in the transcript that does not
   set its own — reaction chips, meta timestamps, day dividers — inflating
   their line boxes and leaving the emoji inside a reaction pill sitting off
   -centre in extra headroom the mono/sans themes never add («кривая» emoji
   background in the book theme). */
::root[data-font="serif"] .bubble-text {
  font-size: 1.06em;
  line-height: 1.55;
}

.transcript {
  min-height: 0;
  flex: 1 1 auto;
  padding: var(--step-3) var(--step-3) var(--step-2);
  overflow-y: auto;
  overscroll-behavior-y: contain;
  scroll-behavior: smooth;
}

/* --- Обои переписки (docs/archive/HANDOFF_WALLPAPERS.md) ------------------------------
   Seven decorative patterns behind the messages plus the plain background.
   `aurora` is what a browser that never picked one gets (since 1.128, see
   `getInitialWallpaper` in app.js). Gradients and inline SVG rather than image
   files, for the reason the fonts are a system stack: the page is served under
   a CSP that forbids external resources and has to work offline, so a texture
   file would be the one thing the shell could not carry.

   The steps (22/28/34px) are literals, not a variable, because they are not
   free numbers: 23px bubbles with 5px gaps is the transcript's rhythm, and
   28px is what makes `ruled`'s lines land *under* the text instead of through
   it. The colour is `--line`/`--line-soft` of whatever palette is in force, so
   the patterns need no tokens of their own and follow a scheme (or a future
   dark book theme) without an edit.

   Painted on `.talk` — the whole conversation column — rather than on the
   messages, since 1.128: the glass header, the logo band and the floating
   composer all sit *over* the pattern instead of cutting it off at the
   transcript's edges. `.talk` does not scroll, so the pattern stands still
   while the messages travel over it. The colour comes from the two variables
   below, which is also where the one difference between light and dark lives. */

:root {
  --wallpaper-ink: var(--line);
  --wallpaper-ink-soft: var(--line-soft);
}

/* A light dot on black reads louder than a dark one on white, so a dark scheme
   draws the same pattern at 55% — and `ruled` at 70%, since it is already the
   quieter token and has the most lines on screen. Only the density changes:
   the step stays 22/28/34 in both modes, or switching modes would jump the
   whole backdrop. */
html[data-mode="dark"] {
  --wallpaper-ink: color-mix(in oklab, var(--line) 55%, transparent);
  --wallpaper-ink-soft: color-mix(in oklab, var(--line-soft) 70%, transparent);
}

/* The book theme is light whatever `data-mode` says (see the paper block with
   the palettes), so its pattern keeps full strength — the dark reduction is
   for dark *backgrounds*, not for a stored preference. */
html[data-theme="paper"][data-mode] {
  --wallpaper-ink: var(--line);
  --wallpaper-ink-soft: var(--line-soft);
}

/* The `.wallpaper-preview` halves of these selectors are the settings cards:
   one declaration per pattern, so a card cannot show something the transcript
   would not do. */
:root[data-wallpaper="dots"] .talk,
.wallpaper-preview[data-wp="dots"] {
  background-image: radial-gradient(var(--wallpaper-ink) 1px, transparent 1px);
  background-size: 22px 22px;
}

:root[data-wallpaper="ruled"] .talk,
.wallpaper-preview[data-wp="ruled"] {
  background-image: repeating-linear-gradient(180deg, transparent 0 27px, var(--wallpaper-ink-soft) 27px 28px);
}

:root[data-wallpaper="diamond"] .talk,
.wallpaper-preview[data-wp="diamond"] {
  background-image:
    radial-gradient(circle at 50% 50%, var(--wallpaper-ink) 1.5px, transparent 1.6px),
    radial-gradient(circle at 50% 50%, var(--wallpaper-ink) 1.5px, transparent 1.6px);
  background-position: 0 0, 17px 17px;
  background-size: 34px 34px;
}

/* --- 1.128: объёмные обои ------------------------------------------------
   `aurora` is gradients only, all of them from the palette in force: the
   scheme's three accents glow through the paper, which is what turns the
   transcript from a sheet into a space. The other three are line drawings —
   SVG tiles as data URIs (`img-src data:` allows them). An SVG inside `url()`
   cannot read a CSS variable, so each tile exists twice: white ink for a dark
   background, black ink for a light one, both at 6.5–9% so the lines stay
   texture rather than drawing. The scheme still colours them through the
   accent tint laid underneath, which *is* made of variables. Tiles are
   seamless by construction: the wave starts and ends on the same tangent, the
   topographic corner rings are one group drawn at all four corners. */
:root {
  --aurora-strength: 30%;
  --wp-tint: 9%;
  --wp-waves: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='28' viewBox='0 0 140 28'><g fill='none' stroke='white' stroke-opacity='0.07' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'><path d='M0 14C35 4 35 4 70 14S105 24 140 14'/></g></svg>");
  --wp-topo: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><g fill='none' stroke='white' stroke-opacity='0.065' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round'><path d='M134 120C134 123 133 127 131 129C129 132 126 135 123 136C120 136 116 134 113 132C110 130 108 128 107 125C106 122 105 118 106 115C108 112 111 111 114 109C116 108 120 106 122 106C125 106 129 108 131 111C133 113 134 117 134 120Z'/><path d='M144 120C145 126 146 134 143 139C140 144 132 147 125 149C119 150 109 151 104 148C99 144 97 135 96 129C94 123 94 117 96 111C97 105 100 97 105 94C110 91 119 89 125 91C131 93 137 98 140 103C143 108 144 114 144 120Z'/><path d='M162 120C164 129 161 142 155 150C150 158 138 167 128 167C119 168 109 159 100 154C92 149 81 144 77 136C73 127 74 114 78 105C81 96 90 85 98 82C106 78 118 81 126 84C135 86 141 91 147 97C153 103 161 111 162 120Z'/><path d='M183 120C184 132 174 148 165 158C157 168 143 177 131 180C118 183 98 182 88 175C79 168 75 150 71 138C68 125 62 112 65 100C68 88 77 72 88 65C99 58 118 55 131 58C143 61 155 73 164 83C173 93 183 108 183 120Z'/><path d='M200 120C202 135 192 159 181 171C170 184 149 197 134 198C118 198 103 181 90 173C76 164 58 157 52 145C47 132 50 111 56 97C61 82 72 65 85 59C97 53 117 56 131 59C145 63 157 69 168 79C180 90 197 105 200 120Z'/><defs><g id='c'><path d='M12 0C12 3 12 7 11 9C9 10 4 10 2 10C-1 10 -3 10 -5 9C-8 9 -12 7 -13 5C-14 3 -13 -2 -12 -4C-11 -7 -7 -8 -5 -9C-3 -10 -1 -11 2 -11C5 -11 9 -11 11 -9C12 -7 12 -3 12 0Z'/><path d='M24 0C24 5 23 13 20 17C17 20 9 21 4 21C-2 22 -8 23 -12 21C-16 19 -19 12 -20 7C-22 3 -21 -2 -20 -7C-18 -12 -16 -18 -12 -21C-8 -23 -1 -23 4 -22C9 -21 15 -19 18 -15C22 -12 23 -5 24 0Z'/><path d='M40 0C39 8 33 16 28 23C22 30 15 40 7 42C-0 43 -11 36 -18 31C-25 26 -33 21 -37 14C-42 6 -48 -9 -45 -16C-41 -23 -25 -26 -17 -29C-8 -32 -2 -37 6 -37C15 -36 27 -34 33 -28C38 -21 41 -8 40 0Z'/></g></defs><use href='%23c' x='0' y='0'/><use href='%23c' x='240' y='0'/><use href='%23c' x='0' y='240'/><use href='%23c' x='240' y='240'/></g></svg>");
  --wp-doodle: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='168' height='168' viewBox='0 0 168 168'><g fill='none' stroke='white' stroke-opacity='0.085' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><path transform='translate(14 14)' d='M4 0h18a4 4 0 0 1 4 4v10a4 4 0 0 1-4 4H11l-6 5v-5H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z'/><path transform='translate(92 22)' d='M0 6l4 4 8-9M7 8l2 2 8-9'/><path transform='translate(130 56)' d='M9 0l2.6 5.6 6.1.7-4.5 4.2 1.2 6L9 13.6 3.6 16.5l1.2-6L.3 6.3l6.1-.7z'/><path transform='translate(52 70)' d='M9 16S0 10.5 0 5a4.5 4.5 0 0 1 9-1 4.5 4.5 0 0 1 9 1c0 5.5-9 11-9 11z'/><path transform='translate(20 104)' d='M14 6l-8 8a3 3 0 0 0 4 4l9-9a5 5 0 0 0-7-7l-9 9a7 7 0 0 0 10 10l7-7'/><circle cx='112' cy='118' r='7'/><circle cx='112' cy='118' r='1.5'/><path transform='translate(66 16)' d='M6 0v12M0 6h12'/><path transform='translate(140 132)' d='M5 0v10M0 5h10'/><path transform='translate(84 128)' d='M5 0a3 3 0 0 1 3 3v6a3 3 0 0 1-6 0V3a3 3 0 0 1 3-3zM0 9a5 5 0 0 0 10 0M5 14v3'/><path transform='translate(98 74)' d='M0 4c3-4 6-4 9 0s6 4 9 0'/><circle cx='40' cy='60' r='1.6'/><circle cx='148' cy='20' r='1.6'/><circle cx='62' cy='146' r='1.6'/></g></svg>");
}

html[data-mode="light"] {
  --aurora-strength: 16%;
  --wp-tint: 7%;
  --wp-waves: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='140' height='28' viewBox='0 0 140 28'><g fill='none' stroke='black' stroke-opacity='0.075' stroke-width='1.3' stroke-linecap='round' stroke-linejoin='round'><path d='M0 14C35 4 35 4 70 14S105 24 140 14'/></g></svg>");
  --wp-topo: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='240' height='240' viewBox='0 0 240 240'><g fill='none' stroke='black' stroke-opacity='0.07' stroke-width='1.1' stroke-linecap='round' stroke-linejoin='round'><path d='M134 120C134 123 133 127 131 129C129 132 126 135 123 136C120 136 116 134 113 132C110 130 108 128 107 125C106 122 105 118 106 115C108 112 111 111 114 109C116 108 120 106 122 106C125 106 129 108 131 111C133 113 134 117 134 120Z'/><path d='M144 120C145 126 146 134 143 139C140 144 132 147 125 149C119 150 109 151 104 148C99 144 97 135 96 129C94 123 94 117 96 111C97 105 100 97 105 94C110 91 119 89 125 91C131 93 137 98 140 103C143 108 144 114 144 120Z'/><path d='M162 120C164 129 161 142 155 150C150 158 138 167 128 167C119 168 109 159 100 154C92 149 81 144 77 136C73 127 74 114 78 105C81 96 90 85 98 82C106 78 118 81 126 84C135 86 141 91 147 97C153 103 161 111 162 120Z'/><path d='M183 120C184 132 174 148 165 158C157 168 143 177 131 180C118 183 98 182 88 175C79 168 75 150 71 138C68 125 62 112 65 100C68 88 77 72 88 65C99 58 118 55 131 58C143 61 155 73 164 83C173 93 183 108 183 120Z'/><path d='M200 120C202 135 192 159 181 171C170 184 149 197 134 198C118 198 103 181 90 173C76 164 58 157 52 145C47 132 50 111 56 97C61 82 72 65 85 59C97 53 117 56 131 59C145 63 157 69 168 79C180 90 197 105 200 120Z'/><defs><g id='c'><path d='M12 0C12 3 12 7 11 9C9 10 4 10 2 10C-1 10 -3 10 -5 9C-8 9 -12 7 -13 5C-14 3 -13 -2 -12 -4C-11 -7 -7 -8 -5 -9C-3 -10 -1 -11 2 -11C5 -11 9 -11 11 -9C12 -7 12 -3 12 0Z'/><path d='M24 0C24 5 23 13 20 17C17 20 9 21 4 21C-2 22 -8 23 -12 21C-16 19 -19 12 -20 7C-22 3 -21 -2 -20 -7C-18 -12 -16 -18 -12 -21C-8 -23 -1 -23 4 -22C9 -21 15 -19 18 -15C22 -12 23 -5 24 0Z'/><path d='M40 0C39 8 33 16 28 23C22 30 15 40 7 42C-0 43 -11 36 -18 31C-25 26 -33 21 -37 14C-42 6 -48 -9 -45 -16C-41 -23 -25 -26 -17 -29C-8 -32 -2 -37 6 -37C15 -36 27 -34 33 -28C38 -21 41 -8 40 0Z'/></g></defs><use href='%23c' x='0' y='0'/><use href='%23c' x='240' y='0'/><use href='%23c' x='0' y='240'/><use href='%23c' x='240' y='240'/></g></svg>");
  --wp-doodle: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='168' height='168' viewBox='0 0 168 168'><g fill='none' stroke='black' stroke-opacity='0.09' stroke-width='1.4' stroke-linecap='round' stroke-linejoin='round'><path transform='translate(14 14)' d='M4 0h18a4 4 0 0 1 4 4v10a4 4 0 0 1-4 4H11l-6 5v-5H4a4 4 0 0 1-4-4V4a4 4 0 0 1 4-4z'/><path transform='translate(92 22)' d='M0 6l4 4 8-9M7 8l2 2 8-9'/><path transform='translate(130 56)' d='M9 0l2.6 5.6 6.1.7-4.5 4.2 1.2 6L9 13.6 3.6 16.5l1.2-6L.3 6.3l6.1-.7z'/><path transform='translate(52 70)' d='M9 16S0 10.5 0 5a4.5 4.5 0 0 1 9-1 4.5 4.5 0 0 1 9 1c0 5.5-9 11-9 11z'/><path transform='translate(20 104)' d='M14 6l-8 8a3 3 0 0 0 4 4l9-9a5 5 0 0 0-7-7l-9 9a7 7 0 0 0 10 10l7-7'/><circle cx='112' cy='118' r='7'/><circle cx='112' cy='118' r='1.5'/><path transform='translate(66 16)' d='M6 0v12M0 6h12'/><path transform='translate(140 132)' d='M5 0v10M0 5h10'/><path transform='translate(84 128)' d='M5 0a3 3 0 0 1 3 3v6a3 3 0 0 1-6 0V3a3 3 0 0 1 3-3zM0 9a5 5 0 0 0 10 0M5 14v3'/><path transform='translate(98 74)' d='M0 4c3-4 6-4 9 0s6 4 9 0'/><circle cx='40' cy='60' r='1.6'/><circle cx='148' cy='20' r='1.6'/><circle cx='62' cy='146' r='1.6'/></g></svg>");
}

/* The book theme's accents are deliberately muted (sage, slate, plum), so the
   same percentage that glows on a terminal palette barely tints paper. */
html[data-theme="paper"][data-mode="dark"] { --aurora-strength: 32%; }
html[data-theme="paper"][data-mode="light"] { --aurora-strength: 20%; }

:root[data-wallpaper="aurora"] .talk,
.wallpaper-preview[data-wp="aurora"] {
  background-image:
    radial-gradient(var(--wallpaper-ink-soft) 0.8px, transparent 1.1px),
    radial-gradient(60% 50% at 8% 10%, color-mix(in oklab, var(--signal) var(--aurora-strength), transparent), transparent 72%),
    radial-gradient(55% 48% at 94% 26%, color-mix(in oklab, var(--cobalt) var(--aurora-strength), transparent), transparent 72%),
    radial-gradient(75% 55% at 50% 108%, color-mix(in oklab, var(--ai) var(--aurora-strength), transparent), transparent 72%);
  background-size: 24px 24px, 100% 100%, 100% 100%, 100% 100%;
}

:root[data-wallpaper="waves"] .talk,
.wallpaper-preview[data-wp="waves"],
:root[data-wallpaper="topo"] .talk,
.wallpaper-preview[data-wp="topo"],
:root[data-wallpaper="doodle"] .talk,
.wallpaper-preview[data-wp="doodle"] {
  background-image:
    var(--wp-tile),
    radial-gradient(80% 60% at 100% 0%, color-mix(in oklab, var(--cobalt) var(--wp-tint), transparent), transparent 70%),
    radial-gradient(80% 60% at 0% 100%, color-mix(in oklab, var(--signal) var(--wp-tint), transparent), transparent 70%);
  background-size: var(--wp-tile-size), 100% 100%, 100% 100%;
}

:root[data-wallpaper="waves"] .talk,
.wallpaper-preview[data-wp="waves"] { --wp-tile: var(--wp-waves); --wp-tile-size: 140px 28px; }
:root[data-wallpaper="topo"] .talk,
.wallpaper-preview[data-wp="topo"] { --wp-tile: var(--wp-topo); --wp-tile-size: 240px 240px; }
:root[data-wallpaper="doodle"] .talk,
.wallpaper-preview[data-wp="doodle"] { --wp-tile: var(--wp-doodle); --wp-tile-size: 168px 168px; }

/* A backdrop for messages, so nothing is drawn where there are none: the
   «Разговор пока не выбран» pane and a thread whose history has not arrived
   both keep the plain paper the rest of the layout uses. */
:root[data-wallpaper] .talk:has(.placeholder:not([hidden])),
:root[data-wallpaper] .talk:has(.thread:not([hidden]):empty) {
  background-image: none;
}

/* The settings cards: a 120px-tall window of the transcript's own paper with
   the pattern on it, and two bubbles over it. The bubbles carry no text on
   purpose — they are there to show that the pattern never reaches the message
   contrast, which is the one thing a caption cannot say. Eight cards no longer
   fit one scrolling strip, so they wrap into a grid (two across in the 460px
   settings sheet, one column on the narrowest phones). */
.wallpaper-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: var(--step-3) var(--step-2);
  padding-bottom: 2px;
}

.wallpaper-btn {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--muted);
  font-size: var(--text-sm);
  text-align: left;
  transition: color var(--dur-fast) var(--ease);
}

.wallpaper-preview {
  position: relative;
  display: block;
  width: 100%;
  height: 120px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-m);
  background-color: var(--paper);
  overflow: hidden;
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.wallpaper-btn.active {
  color: var(--ink);
  font-weight: 700;
}

.wallpaper-btn.active .wallpaper-preview {
  border-color: var(--signal-line);
  box-shadow: var(--ring);
}

.wallpaper-bubble {
  position: absolute;
  width: 92px;
  height: 30px;
  border-radius: 10px;
  background: var(--raised);
  border: 1px solid var(--edge-soft);
}

.wallpaper-bubble::before,
.wallpaper-bubble::after {
  content: "";
  position: absolute;
  left: 10px;
  height: 3px;
  border-radius: 2px;
  background: var(--muted);
}

.wallpaper-bubble::before {
  top: 9px;
  width: 62px;
  opacity: 0.45;
}

.wallpaper-bubble::after {
  top: 17px;
  width: 40px;
  opacity: 0.3;
}

.wallpaper-bubble--peer {
  top: 22px;
  left: 12px;
}

.wallpaper-bubble--own {
  top: 64px;
  right: 12px;
  background: var(--own-bubble-bg);
}

.scroll-bottom-btn {
  position: absolute;
  bottom: 16px;
  right: 20px;
  z-index: 20;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--edge);
  background: var(--surface);
  color: var(--signal);
  cursor: pointer;
  box-shadow: var(--shadow-2);
  transition: transform var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
  animation: popIn 160ms cubic-bezier(0.18, 0.89, 0.32, 1.28);
}

.scroll-bottom-btn:hover {
  background: var(--signal-soft);
  transform: translateY(-2px);
  box-shadow: var(--shadow-3);
}

.scroll-bottom-btn .scroll-arrow {
  display: inline-flex;
  align-items: center;
}

.scroll-bottom-btn .scroll-arrow .icon {
  width: 15px;
  height: 15px;
}

/* Separate from the arrow on purpose: a corner badge layered above it, not a
 * label sharing its row — the arrow alone means "scroll down", the badge
 * layered on top of it is the only thing that means "something is unread". */
.scroll-bottom-btn .scroll-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  display: inline-grid;
  place-items: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: var(--radius-s);
  border: 2px solid var(--surface);
  background: var(--signal);
  color: var(--signal-ink);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 800;
}

@keyframes popIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--step-2);
  max-width: 44ch;
  min-height: 100%;
  margin: 0 auto;
  text-align: center;
}

.placeholder-mark {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-m);
  color: var(--cobalt);
  font-size: 1.1rem;
}

.placeholder h2 {
  margin: 0;
  font-size: 1rem;
}

.placeholder p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.5;
}

.day-divider {
  margin: var(--step-4) 0 var(--step-3);
  color: var(--muted);
  font-size: var(--text-xs);
  letter-spacing: var(--track-caps);
  text-align: center;
  text-transform: uppercase;
}

.day-divider::before,
.day-divider::after {
  content: "── ";
  color: var(--line);
}

.day-divider::after {
  content: " ──";
}

/* Where reading stopped. Louder than the day divider on purpose: this is the
   line a person looks for when they come back to a conversation, and the
   whole point of it is that new messages cannot be mistaken for old ones. */
.unread-divider {
  display: flex;
  align-items: center;
  gap: var(--step-2);
  margin: var(--step-4) 0 var(--step-3);
  color: var(--signal);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
}

.unread-divider::before,
.unread-divider::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--signal);
  opacity: 0.45;
}

.unread-badge-line {
  flex: 0 0 auto;
  padding: var(--step-1) var(--step-2);
  border: 1px solid var(--edge);
  border-radius: var(--radius-pill);
  background: var(--signal-soft);
}

.row {
  display: flex;
  margin-bottom: 6px;
}

.row:focus:not(:focus-visible) {
  outline: none;
}

.row:focus-visible {
  outline: 2px solid var(--cobalt);
  outline-offset: 1px;
}

.row[data-side="own"] {
  justify-content: flex-end;
}

.bubble {
  position: relative;
  min-width: 0;
  max-width: min(88%, 560px);
  padding: var(--step-2) var(--step-3);
  border: 1px solid var(--edge);
  /* Three round corners and one small one: the tail corner is what tells the
     two sides of the conversation apart once every edge is soft. */
  border-radius: var(--radius-bubble);
  border-bottom-left-radius: var(--radius-tail);
  /* 1.130, flat: a peer's message is the neutral raised fill and one's own the
     accent's tone (`--own-bubble-bg`); the fill is the whole separation, so
     there is no shadow under either and no line around them unless
     «Обводки» is on. */
  background: var(--raised);
  overflow-wrap: anywhere;
  transition: border-color var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.row[data-side="own"] .bubble {
  background: var(--own-bubble-bg);
  border-bottom-left-radius: var(--radius-bubble);
  border-bottom-right-radius: var(--radius-tail);
}

/* A message still on its way. The dashed edge is the only thing that tells
   «sending» from «sent», so with «Обводки» on it takes the full `--line`
   rather than the edge's colour; with them off there is no edge to dash, and
   the bubble fades further instead. */
.bubble--pending {
  border-style: dashed;
  opacity: 0.7;
}

html[data-borders="on"] .bubble--pending {
  border-color: var(--line);
  opacity: 0.85;
}

.pending-image {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--step-2);
  margin-top: var(--step-1);
}

.pending-image-thumb {
  width: 56px;
  height: 56px;
  object-fit: cover;
  border: 1px solid var(--edge);
  border-radius: var(--radius-s);
  filter: saturate(0.4) brightness(0.8);
}

.pending-image-label {
  color: var(--muted);
  font-size: 0.74rem;
}

.pending-image-label::after {
  content: " ▌";
  animation: pending-blink 1s steps(2, start) infinite;
}

@keyframes pending-blink {
  to { opacity: 0; }
}

.msg-menu {
  position: fixed;
  z-index: 60;
  display: grid;
  min-width: 180px;
  padding: var(--step-1);
  border: 1px solid var(--edge);
  border-radius: var(--radius-m);
  background: var(--raised);
  box-shadow: var(--shadow-3);
}

.msg-menu-item {
  padding: 10px var(--step-3);
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  text-align: left;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.msg-menu-item:hover {
  background: var(--signal-soft);
}

.msg-menu-item--danger {
  color: var(--danger);
}

.msg-menu-item--danger:hover {
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}

/* One full picker for the draft, reactions and settings. Only the categories
   near the viewport have cells; the others reserve their eventual height. */
.emoji {
  display: inline-block;
  width: 1.05em;
  height: 1.05em;
  vertical-align: -0.15em;
  object-fit: contain;
}
.emoji-picker {
  position: fixed;
  z-index: 60;
  width: min(320px, calc(100vw - 16px));
  height: min(340px, calc(100dvh - 16px));
  display: flex;
  flex-direction: column;
  padding: 8px;
  gap: 6px;
  border: 1px solid var(--edge, transparent);
  border-radius: var(--radius-m);
  background: var(--surface);
  color: var(--ink);
  box-shadow: var(--shadow-3);
  overflow: hidden;
}
.emoji-picker-search {
  flex: none;
  width: 100%;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--edge-soft, transparent);
  border-radius: var(--radius-s);
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
}
.emoji-picker-tabs {
  display: flex;
  flex: none;
  overflow-x: auto;
  scrollbar-width: none;
}
.emoji-picker-tab {
  flex: 1 0 30px;
  display: grid;
  place-items: center;
  min-width: 0;
  height: 32px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  cursor: pointer;
  font-size: 15px;
}
.emoji-picker-tab[aria-selected="true"],
.emoji-picker-tab:hover { background: var(--signal-soft); }
.emoji-picker-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.emoji-picker-heading {
  margin: 0;
  padding: 8px 4px 4px;
  color: var(--muted);
  font-size: var(--text-xs);
}
.emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(var(--emoji-columns, 8), minmax(0, 1fr));
}
.emoji-picker-item {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 1;
  padding: 0;
  border: 0;
  border-radius: var(--radius-s);
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}
.emoji-picker-item:hover,
.emoji-picker-item.is-active { background: var(--signal-soft); }
.emoji-picker-item:active { transform: scale(.9); }
.emoji-picker-empty { padding: 24px 8px; text-align: center; color: var(--muted); }
.emoji-picker [hidden] { display: none; }
.emoji-picker--sheet {
  inset: auto 0 0;
  width: 100%;
  max-width: none;
  height: min(380px, 65dvh);
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  border-radius: var(--radius-l) var(--radius-l) 0 0;
}
.row[data-jumbo="true"]:not([data-deleted="true"]) .bubble {
  border-color: transparent;
  padding: 4px 0;
  box-shadow: none;
}
.row[data-jumbo="true"]:not([data-deleted="true"]):not(.row-selected) .bubble {
  background: transparent;
}
.row[data-jumbo="true"]:not([data-deleted="true"]) .bubble-text {
  font-size: 1.75em;
  line-height: 1.2;
}
.row[data-jumbo="true"] .bubble-text .emoji { width: 1em; height: 1em; vertical-align: -.1em; }

.drop-target {
  outline: 2px dashed var(--signal);
  outline-offset: -6px;
}

.row[data-kind="ai"] .bubble {
  background: var(--ai-soft);
}

.bubble-author {
  display: block;
  margin-bottom: 2px;
  color: var(--cobalt);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
}

.row[data-kind="ai"] .bubble-author {
  color: var(--ai);
}

/* The quoted reference at the top of a reply: a thin left rule and a name,
   the same shape `.msg-quote` already uses for a `> ` line, but tappable and
   its own colour so it never reads as the message's own quoted text. */
.bubble-reply {
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 100%;
  margin-bottom: var(--step-2);
  padding: var(--step-1) var(--step-2);
  border: 0;
  border-left: 3px solid var(--cobalt);
  border-radius: var(--radius-s);
  background: color-mix(in srgb, var(--cobalt) 10%, transparent);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.row[data-side="own"] .bubble-reply {
  border-left-color: var(--signal);
  background: color-mix(in srgb, var(--signal) 12%, transparent);
}

.bubble-reply-author {
  font-size: var(--text-xs);
  font-weight: 700;
  color: var(--cobalt);
  letter-spacing: 0.01em;
}

.row[data-side="own"] .bubble-reply-author {
  color: var(--own-accent);
}

.bubble-reply-snippet {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--muted);
  font-size: var(--text-sm);
  line-height: var(--leading-tight);
}

/* A brief highlight on the row a reply's quote jumps to — the same green the
   active roster row and the send affordance already use, so it reads as
   «found it», not as an error state. */
@keyframes row-flash {
  from { background: color-mix(in srgb, var(--signal) 20%, transparent); }
  to { background: transparent; }
}

.row-flash .bubble {
  animation: row-flash 900ms ease-out;
}

/* Content owns the timestamp corner; reaction chips sit outside it. */
.bubble-content {
  position: relative;
  display: flow-root;
  min-width: 0;
}

.bubble-text {
  margin: 0;
  font-size: var(--text-md);
  line-height: var(--leading-body);
  white-space: pre-wrap;
}

.bubble-meta,
.bubble-meta-spacer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 6px;
  width: max-content;
  height: 1.125rem;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.66rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.bubble-meta {
  position: absolute;
  right: 0;
  bottom: 0;
}

/* An invisible copy, not an estimate in em: edited/reminder icons, all five
   receipt states and the menu reserve their actual width even in jumbo text.
   The inline block wraps as a unit only when the last line has no room. */
.bubble-meta-spacer {
  display: inline-flex;
  margin-inline-start: 6px;
  vertical-align: bottom;
  visibility: hidden;
  pointer-events: none;
  user-select: none;
  -webkit-user-select: none;
}

.bubble-content > .bubble-meta-spacer {
  display: flex;
  margin-inline-start: auto;
}

.bubble-meta > *,
.bubble-meta-spacer > * {
  flex: none;
}

.bubble-mark,
.roster-mark {
  display: inline-flex;
  align-items: center;
  line-height: 1;
  font-size: var(--receipt-size);
}

/* Keep setMark's text as the accessible name; only checks use a vector. */
.bubble-mark[data-state="sent"],
.roster-mark[data-state="sent"],
.bubble-mark[data-state="ack"],
.roster-mark[data-state="ack"],
.bubble-mark[data-state="read"],
.roster-mark[data-state="read"] {
  font-size: 0;
}

.bubble-mark[data-state="sent"]::before,
.roster-mark[data-state="sent"]::before,
.bubble-mark[data-state="ack"]::before,
.roster-mark[data-state="ack"]::before,
.bubble-mark[data-state="read"]::before,
.roster-mark[data-state="read"]::before {
  content: '';
  display: block;
  height: var(--receipt-size);
  background: currentColor;
}

.bubble-mark[data-state="sent"]::before,
.roster-mark[data-state="sent"]::before {
  width: calc(var(--receipt-size) * 0.833);
  -webkit-mask: var(--receipt-single) center / contain no-repeat;
  mask: var(--receipt-single) center / contain no-repeat;
}

.bubble-mark[data-state="ack"]::before,
.roster-mark[data-state="ack"]::before,
.bubble-mark[data-state="read"]::before,
.roster-mark[data-state="read"]::before {
  width: calc(var(--receipt-size) * 1.183);
  -webkit-mask: var(--receipt-double) center / contain no-repeat;
  mask: var(--receipt-double) center / contain no-repeat;
}

.bubble-mark[data-state="read"],
.roster-mark[data-state="read"] {
  color: var(--signal);
}

.bubble-reactions {
  display: flex;
  align-items: center;
  min-width: 0;
  height: 1.125rem;
  gap: 4px;
  margin-top: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  scrollbar-width: none;
}

.bubble-reactions::-webkit-scrollbar {
  display: none;
}

.bubble-reaction {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 100%;
  min-width: 30px;
  padding: 0 var(--step-1);
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--raised);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-xs);
  line-height: 1;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.bubble-reaction[data-mine="true"] {
  background: var(--signal-soft);
}

.bubble-reaction:hover {
  background: var(--signal-soft);
}

.bubble-reaction:active {
  transform: scale(0.94);
}

.bubble-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
  margin-bottom: 4px;
}

.bubble-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--edge);
  background: var(--bubble-step);
  color: var(--ink);
  font: inherit;
  font-size: var(--text-xs);
  font-weight: 500;
  cursor: pointer;
  transition: border-color 120ms ease, background 120ms ease, transform 60ms ease;
}

.bubble-btn:hover:not(:disabled) {
  background: color-mix(in srgb, var(--cobalt) 15%, var(--surface));
}

.bubble-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.bubble-btn:disabled {
  opacity: 0.5;
  cursor: default;
}

/* A desktop-sized, never-upscaled image. Sent dimensions reserve its box
   before decoding; the transcript's padded width shrinks it on phones. */
.msg-image-frame {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin-top: 6px;
}

.msg-image-wrap {
  position: relative;
  display: block;
  max-width: 100%;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--edge-soft, transparent);
  border-radius: var(--radius-s);
  background: var(--paper);
  cursor: zoom-in;
}

.msg-image {
  display: block;
  max-width: 100%;
  max-height: 480px;
  height: auto;
  border-radius: inherit;
}

/* A picture served by reference (`/api/media`): the box is reserved at the
   size the reference names, and stays a quiet surface until the bytes land. */
.msg-image-frame[data-media] .msg-image-wrap {
  min-width: 120px;
  min-height: 80px;
  background: var(--line-soft);
  cursor: progress;
}

.msg-image-frame[data-media] .msg-image {
  visibility: hidden;
}

.msg-image-frame[data-media="failed"] .msg-image-wrap {
  cursor: pointer;
}

.msg-image-frame[data-media="gone"] .msg-image-wrap {
  cursor: default;
}

.msg-image-frame[data-media]::after {
  content: attr(data-label);
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--step-2);
  color: var(--muted);
  font-size: var(--text-xs);
  text-align: center;
  pointer-events: none;
}

.voice-card[data-media="loading"] .voice-play-btn {
  cursor: progress;
  opacity: 0.6;
}

.file-card {
  display: grid;
  gap: var(--step-2);
  min-width: min(280px, 70vw);
  margin-top: var(--step-1);
}

.file-audio {
  width: 100%;
  height: 34px;
}

.file-open-link {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: var(--step-2);
  padding: var(--step-2);
  border: 1px solid var(--edge);
  border-radius: var(--radius-m);
  background: var(--bubble-step);
  color: var(--ink);
  text-decoration: none;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.file-open-link:hover {
  background: var(--signal-soft);
}

.file-type {
  padding: 3px 5px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-tail);
  color: var(--cobalt);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.file-copy {
  display: grid;
  min-width: 0;
}


/* A link preview card, one clickable link in three shapes that
   `buildLinkPreviewCard` picks from the picture's own size: `--hero` (picture
   full width on top), `--thumb` (a 56px square beside the text) and `--text`.
   The card is as wide as its bubble, never the other way round: inline-size
   containment takes it out of the bubble's shrink-to-fit sum, so a long
   headline or a 1200px picture cannot stretch the bubble. Text-only bubbles
   have a floor so a one-word message cannot squeeze the card into a column;
   image-caption bubbles instead keep the picture's width, even below 320px.
   Its tone is `--bubble-step`, the shared veil of ink over the bubble — one
   step darker on a light theme, lighter on a dark one, for own and peer
   bubbles alike — and the bubble under it is always opaque, so no wallpaper
   shows through. Flat: hover takes the same `--signal-soft` as the file card,
   no lift and no shadow. */
.row:not([data-image]) > .bubble:has(.link-preview) {
  min-width: min(320px, 100%);
}

.link-preview {
  position: relative;
  display: block;
  container-type: inline-size;
  overflow: hidden;
  margin-top: var(--step-1);
  border: 1px solid var(--edge, transparent);
  border-radius: var(--radius-m);
  background-color: var(--bubble-step);
  color: inherit;
  text-decoration: none;
  transition: background-color var(--dur-fast) var(--ease);
}

.link-preview:hover {
  background-color: var(--signal-soft);
}

/* Full width while cropping to the 280px ceiling costs at most 15% of the
   picture (`object-fit: cover`); past that, the picture's own proportions at
   280px tall, centred on the card's tone. Which one depends on the card's
   live width against the picture's ratio, so it is decided here on every
   resize rather than once in JS: `--hero-fit` is a 0px/1px step that turns
   1px exactly when full width would crop more than 15% (card wider than
   280px / 0.85 × ratio), and the width drops from the card's to the
   picture's own at that step. The height is 280px on both sides of it, so
   crossing the step never moves the text below. */
.link-preview--hero .link-preview-image {
  --hero-fit: clamp(0px, (100cqw - 280px / 0.85 * var(--ratio)) * 1000, 1px);
  display: block;
  width: min(100cqw, 280px * var(--ratio) + (1px - var(--hero-fit)) * 100000);
  height: min(280px, 100cqw / var(--ratio));
  margin-inline: auto;
  object-fit: cover;
}

.link-preview-play {
  position: absolute;
  top: var(--step-2);
  left: var(--step-2);
  padding: 6px 10px;
  border-radius: var(--radius-pill);
  background: #121212dc;
  color: #fff;
  font: 600 12px var(--sans);
}

/* The same one padding as the other two shapes, around picture and text
   together. A picture smaller than the square (`--icon`) stays at its own
   size on the tone rather than being blown up into a blur. The description
   is for hero and text only; it is still in the DOM so a thumbnail whose
   picture fails later becomes a full text card. */
.link-preview--thumb {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  align-items: center;
  gap: var(--step-2);
  padding: var(--step-2);
}

.link-preview--thumb .link-preview-image {
  display: block;
  width: 56px;
  height: 56px;
  border-radius: var(--radius-s);
  background-color: var(--bubble-step);
  object-fit: cover;
}

.link-preview--thumb .link-preview-image--icon {
  object-fit: scale-down;
}

.link-preview--thumb .link-preview-desc {
  display: none;
}

.link-preview-body {
  display: grid;
  gap: 2px;
  min-width: 0;
  padding: var(--step-2);
}

.link-preview--thumb .link-preview-body {
  padding: 0;
}

.link-preview-site {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.link-preview-title {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.3;
}

.link-preview-desc {
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.3;
}

.file-copy strong,
.file-copy small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.file-copy strong {
  font-size: 0.78rem;
}

.file-copy small {
  color: var(--muted);
  font-size: 0.68rem;
}

.system-note {
  margin: var(--step-2) auto;
  color: var(--muted);
  font-size: 0.72rem;
  text-align: center;
}

.system-note::before {
  content: "* ";
  color: var(--cobalt);
}

.typing-bar {
  display: flex;
  align-items: center;
  gap: var(--step-2);
  padding: 0 var(--step-3) var(--step-1);
  min-height: 1.4em;
  font-size: var(--text-md);
  font-family: var(--mono);
  color: var(--muted);
  user-select: none;
}

.typing-bar[hidden] {
  display: none !important;
}

/* The two hairlines that used to flank the «печатает…» line are gone: they
   read as a divider across the transcript rather than as a status.

   What replaces them is a chip shaped like an incoming bubble but deliberately
   lighter — a half-strength fill, and a dashed edge rather than a solid one
   when «Обводки» are on — so it reads as something happening on the other
   side rather than as another message in the transcript, which is what a bare
   line of shimmering text looked like. */
.typing-chip {
  display: inline-flex;
  align-items: center;
  gap: var(--step-2);
  padding: 3px var(--step-3);
  border: 1px dashed var(--edge);
  border-radius: var(--radius-bubble);
  border-bottom-left-radius: var(--radius-tail);
  background: color-mix(in srgb, var(--raised) 55%, transparent);
}

/* Three dots keeping time, the one part of the indicator that says "still
   going" without anybody reading a word. */
.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}

.typing-dots i {
  width: 5px;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--cobalt);
  opacity: 0.35;
  animation: tcTypingDot 1.2s ease-in-out infinite;
}

.typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.typing-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes tcTypingDot {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

/* Motion is decoration here; the dots and the shimmer both stop when the
   reader has asked the system for less of it. */
@media (prefers-reduced-motion: reduce) {
  .typing-dots i,
  .typing-shimmer {
    animation: none;
  }
}

.typing-shimmer {
  display: inline-block;
  font-weight: 600;
  letter-spacing: 0.03em;
  background: linear-gradient(
    90deg,
    var(--muted) 0%,
    var(--cobalt) 25%,
    #5eead4 50%,
    var(--cobalt) 75%,
    var(--muted) 100%
  );
  background-size: 200% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  animation: tcShimmer 1.8s linear infinite;
}

@keyframes tcShimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

.bot-actions {
  display: flex;
  gap: var(--step-2);
  overflow-x: auto;
  padding: var(--step-2) var(--step-3);
  border-bottom: 1px solid var(--edge-soft);
  background: var(--raised);
  scrollbar-width: none;
}

.bot-actions::-webkit-scrollbar {
  display: none;
}

.bot-action {
  flex: none;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--cobalt) 10%, var(--surface));
  color: var(--ink);
  font: inherit;
  font-size: var(--text-sm);
  font-weight: 650;
  white-space: nowrap;
  cursor: pointer;
}

.bot-action:hover {
  background: color-mix(in srgb, var(--cobalt) 17%, var(--surface));
}

.bot-action:active {
  transform: translateY(1px);
}

.bot-action:disabled {
  opacity: 0.5;
  cursor: default;
}

.bot-actions[hidden] {
  display: none !important;
}

/* --- поле ввода --------------------------------------------------------- */
/* The bar that names an active edit or reply above the composer: the entry
   point (message menu) may be a popup, but the editing/replying itself never
   is — it happens in the draft below, this bar just says which mode is on
   and offers a way out of it. */
.composer-context {
  display: flex;
  align-items: center;
  gap: var(--step-2);
  padding: var(--step-2) var(--step-3);
  border-bottom: 1px solid var(--edge-soft);
  background: var(--raised);
}

.composer-context[data-mode="reply"] {
  border-left: 3px solid var(--cobalt);
}

.composer-context[data-mode="edit"] {
  border-left: 3px solid var(--signal);
}

.composer-context-icon {
  flex: none;
  font-size: var(--text-md);
  color: var(--muted);
}

.composer-context-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  gap: 0;
}

.composer-context-label {
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: 0.01em;
}

.composer-context-snippet {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: var(--leading-tight);
}

.composer-context-cancel {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin-left: auto;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease);
}

.composer-context-cancel:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 14%, transparent);
}

.composer-context-cancel:active {
  transform: scale(0.9);
}


.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: end;
  gap: var(--step-2);
  padding: var(--step-2) var(--step-3);
  border-top: 1px solid var(--edge-soft);
  background: var(--surface);
}


.composer-grow {
  position: relative;
  display: grid;
  max-height: 160px;
  min-height: 0;
  overflow: hidden;
}

.composer-grow::after {
  visibility: hidden;
  content: attr(data-value) " ";
}

.composer-grow > textarea,
.composer-grow::after {
  grid-area: 1 / 1 / 2 / 2;
  width: 100%;
  min-height: var(--field);
  /* Vertically centred in the 46px field: (46 − 16×1.4) / 2 ≈ 12.
     Font-size is 16px, not smaller: below that, iOS Safari zooms the whole
     page in when the composer gets focus, which is most of the time. */
  padding: 12px 40px 12px 14px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-m);
  font: inherit;
  font-family: inherit;
  font-size: 16px;
  line-height: 1.4;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  box-sizing: border-box;
}
.composer-grow > textarea {
  /* The mirror (`::after`, see above) has no `max-height`, so once its
     content is a bare space it still sits a couple of px taller than the
     textarea's own clamped box — natural line-height rounding, not a typo.
     `align-items: end` on `.composer` only settles `.composer-grow` itself
     against the round buttons beside it; inside that grid cell the textarea
     was left pinned to the top, floating a few px above them. */
  align-self: end;
  max-height: 160px;
  overflow-y: hidden;
  resize: none;
  background: var(--raised);
  color: var(--ink);
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    box-shadow var(--dur-fast) var(--ease);
}

.composer-grow > textarea::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* The draft is already identified by its shape and position. Focus must not
   add a second rectangular ring around it. */
.composer-grow > textarea:focus,
.composer-grow > textarea:focus-visible {
  border-color: var(--edge);
  box-shadow: none;
  outline: none;
}

.composer-grow > textarea:disabled {
  border-color: var(--edge-soft);
  background: var(--line-soft);
  color: var(--muted);
  cursor: not-allowed;
}

.emoji-toggle {
  position: absolute;
  right: 8px;
  top: 11px;
  width: 24px;
  height: 24px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: var(--radius-pill);
  background: color-mix(in srgb, var(--ink) 8%, transparent);
  color: var(--muted);
  font-size: var(--text-lg);
  line-height: 1;
  cursor: pointer;
  transition: color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.emoji-toggle .emoji {
  width: 18px;
  height: 18px;
  vertical-align: initial;
}

.emoji-toggle:hover:not(:disabled) {
  color: var(--cobalt);
  background: color-mix(in srgb, var(--cobalt) 14%, transparent);
}

.emoji-toggle:active:not(:disabled) {
  transform: scale(0.9);
}

.emoji-toggle:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Узкая строка ввода: подпись прячется, остаётся только иконка. */

.send-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: var(--field);
  height: var(--field);
  padding: 0 var(--step-4);
  border: 1px solid transparent;
  border-radius: var(--radius-pill);
  background: var(--signal);
  color: var(--signal-ink);
  font-weight: 700;
  font-size: var(--text-sm);
  box-sizing: border-box;
  transition: filter var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease), opacity var(--dur-fast) var(--ease);
}

.send-button:hover:not(:disabled) {
  filter: brightness(1.08);
}

.send-button:active:not(:disabled) {
  transform: scale(0.96);
  filter: brightness(0.96);
}

.send-button .send-icon {
  width: 18px;
  height: 18px;
}

@media (max-width: 519.98px) {
  .send-label {
    display: none;
  }

  .send-button {
    width: var(--field);
    padding: 0;
  }
}

.send-button:disabled {
  border-color: var(--edge);
  background: var(--raised);
  color: var(--muted);
  opacity: 0.7;
  cursor: not-allowed;
}

/* --- две колонки -------------------------------------------------------- */

@media (min-width: 720px) {
  .app {
    grid-template-columns: 60px var(--roster-w) minmax(0, 1fr) var(--info-w);
    grid-template-rows: minmax(0, 1fr);
  }

  .app > .roster {
    grid-column: 2;
  }

  .app > .talk {
    grid-column: 3;
  }

  .app > .info {
    grid-column: 4;
  }

  /* Ширина живёт в --roster-user-w (её пишет JS инлайном). Иначе inline-стиль
     на .app перебивал бы схлопывание панели. */
  .app[data-roster="on"] {
    --roster-w: var(--roster-user-w, 288px);
  }

  .app[data-roster="off"] {
    --roster-w: 0px;
  }

  .app[data-roster="off"] > .roster,
  .app[data-roster="off"] > #pane-grip {
    display: none;
  }

  .app[data-info="on"] {
    --info-w: var(--info-user-w, 236px);
  }

  .app[data-info="off"] {
    --info-w: 0px;
  }

  .app[data-info="off"] > .info,
  .app[data-info="off"] > #info-grip {
    display: none;
  }
  /* The rail's edge: the roster's own tone against the room is the seam;
     with «Обводки» on, a hairline draws it as well. */
  .roster {
    border-right: 1px solid var(--edge-soft);
  }

  .back-button {
    display: none;
  }

  .transcript,
  .composer,
  .voice-bar,
  .talk-top,
  .typing-bar {
    padding-inline: var(--step-4);
  }

  /* The rail's own desktop rules are deliberately *not* here. `.statusline` is
     defined as the phone's bottom bar further down this file ("Статус-строка"),
     and two rules of equal specificity are decided by source order — the media
     query does not enter into it. Declared here, every one of them was dead:
     the bar was placed in an implicit grid row under the app (a blank ~280px
     band with the buttons floating in it) instead of in column 1. They live in
     the `@media (min-width: 720px)` block right after their base rules, next to
     the pane grips, which were losing the same way. */

  .auth {
    place-items: center;
  }
}

/* --- узкие телефоны ----------------------------------------------------- */

@media (max-width: 379px) {
  .roster-top,
  .empty-note {
    padding-inline: var(--step-2);
  }

  .send-button {
    padding-inline: var(--step-2);
    font-size: 0.8rem;
  }
}


/* ==========================================================================
   Terminal Features: Themes, Commands Palette, Voice Notes, Screensaver
   ========================================================================== */

/* --- Themes --- */
[data-theme="amber"] {
  --paper: #0c0801;
  --surface: #150e04;
  --raised: #241a0a;
  --ink: #ffdda8;
  --muted: #b58a52;
  --line: #3b2814;
  --line-soft: #251a08;
  --cobalt: #ffaa33;
  --signal: #ffb833;
  --signal-soft: #2b1c06;
  --signal-line: #cc8014;
  --amber: #ffcc00;
  --danger: #ff5533;
  --signal-glow: rgba(255, 184, 51, 0.3);
}

[data-theme="blue"] {
  --paper: #000a14;
  --surface: #001526;
  --raised: #00243f;
  --ink: #d0e7ff;
  --muted: #6d9bc7;
  --line: #0d3055;
  --line-soft: #071f37;
  --cobalt: #38a5ff;
  --signal: #38b6ff;
  --signal-soft: #04263e;
  --signal-line: #1c75b8;
  --amber: #ffd000;
  --danger: #ff5566;
  --signal-glow: rgba(56, 182, 255, 0.3);
}

[data-theme="matrix"] {
  --paper: #000000;
  --surface: #030a03;
  --raised: #0a1c0a;
  --ink: #00ff66;
  --muted: #00b347;
  --line: #0a4020;
  --line-soft: #04250e;
  --cobalt: #00ffaa;
  --signal: #00ff66;
  --signal-soft: #032109;
  --signal-line: #00cc44;
  --amber: #ffee00;
  --danger: #ff2222;
  --signal-glow: rgba(0, 255, 102, 0.38);
}

[data-theme="mono"] {
  --paper: #0b0b0b;
  --surface: #141414;
  --raised: #1f1f1f;
  --ink: #f2f2f2;
  --muted: #8a8a8a;
  --line: #303030;
  --line-soft: #222222;
  --cobalt: #cccccc;
  --signal: #ffffff;
  --signal-soft: #262626;
  --signal-line: #888888;
  --amber: #dddddd;
  --danger: #ff5555;
  --signal-glow: rgba(255, 255, 255, 0.2);
}

/* Mono's grey is the one `--muted` under 4.5:1 on its own tone (3.55:1 on the
   white-tinted bubble): the own meta line takes a grey halfway to ink (6.6:1). */
html[data-theme="mono"][data-mode="dark"] .row[data-side="own"] .bubble-meta {
  color: color-mix(in srgb, var(--muted) 50%, var(--ink));
}

/* The light half of the appearance axis. Not a colour scheme: `data-mode` is
   resolved to `light`/`dark` in JS (`applyMode`), so a person keeps their
   palette when they move between a dark room and daylight. This block carries
   the neutrals — paper instead of a phosphor screen — and each scheme below
   re-states only its accents, because the dark accents are tuned for contrast
   against black and turn to mud on white. `color-scheme` is what stops native
   scrollbars and the caret from forcing dark chrome. */
html[data-mode="light"] {
  color-scheme: light;
  /* Paper, not a lightbox. Pure white at full-screen size is glare, and it
     also leaves nothing for `--surface` to be lighter than — the three steps
     simply run the other way round here: paper is the lightest thing on the
     screen and every panel sits *into* it. */
  --paper: #fafbfc;
  --surface: #f2f4f7;
  --raised: #e7ebf0;
  --ink: #1c1f24;
  --muted: #57606b;
  --line: #dbe0e6;
  --line-soft: #e6e9ee;
  --cobalt: #0969da;
  --cobalt-ink: #ffffff;
  --signal: #1a7f37;
  --signal-ink: #ffffff;
  --signal-soft: #dafbe1;
  --signal-line: #2da44e;
  --amber: #9a6700;
  --danger: #cf222e;
  --ai: #8250df;
  --ai-soft: #f6eeff;
  --signal-glow: rgba(26, 127, 55, 0.25);
  /* Daylight shadows are a hint of grey, not a hole: the same three steps at a
     fraction of the alpha and tinted towards the slate the neutrals carry. */
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.06), 0 1px 3px rgba(16, 24, 40, 0.07);
  --shadow-2: 0 6px 16px -4px rgba(16, 24, 40, 0.1), 0 2px 6px -2px rgba(16, 24, 40, 0.07);
  --shadow-3: 0 24px 48px -16px rgba(16, 24, 40, 0.18), 0 8px 20px -8px rgba(16, 24, 40, 0.1);
}

html[data-mode="light"][data-theme="amber"] {
  /* The old #bf8700 measured 2.9:1 against paper, and this is not decoration:
     names and status text use this accent. Brought down to a readable ochre
     (5.2:1 on --surface); labels on the own tone take `--own-accent`. */
  --cobalt: #875e00;
  --signal: #875e00;
  --signal-soft: #fff5c2;
  --signal-line: #c99a24;
  --amber: #7d4e00;
  --signal-glow: rgba(135, 94, 0, 0.22);
}

html[data-mode="light"][data-theme="blue"] {
  --cobalt: #0969da;
  --signal: #0b62b8;
  --signal-soft: #ddf1ff;
  --signal-line: #4aa3ea;
  --amber: #9a6700;
  --signal-glow: rgba(11, 98, 184, 0.22);
}

html[data-mode="light"][data-theme="matrix"] {
  --cobalt: #0a7a2f;
  --signal: #0a7a2f;
  --signal-soft: #dcf7e3;
  --signal-line: #1c9a45;
  --amber: #7d6a00;
  --signal-glow: rgba(10, 122, 47, 0.24);
}

html[data-mode="light"][data-theme="mono"] {
  --cobalt: #57606a;
  --signal: #24292f;
  --signal-soft: #e6e9ee;
  --signal-line: #8c959f;
  --amber: #4c4f53;
  --signal-glow: rgba(36, 41, 47, 0.16);
  --own-tone: 12%;
}

html[data-theme="paper"][data-mode="light"] {
  color-scheme: light;
  --paper: #f7f2e9;
  --surface: #fcf8f1;
  --raised: #efe7d9;
  --ink: #2e2a24;
  --muted: #766c5e;
  --line: #e1d7c6;
  --line-soft: #ebe3d5;
  --cobalt: #42627f;
  --cobalt-ink: #fcf8f1;
  --signal: #4a6b4e;
  --signal-ink: #fcf8f1;
  --signal-soft: #e4ede2;
  --signal-line: #7d9a80;
  --amber: #8a6a2f;
  --danger: #a8463c;
  --ai: #6b5a8a;
  --ai-soft: #ede7f2;
  --signal-glow: rgba(74, 107, 78, 0.22);
  --own-tone: 20%;
}

/* The dark half of the same book: warm graphite, not the blue-black of the
   other palettes, and the same antiqua stays put — `--ui-font`/`--serif`
   never reads `data-mode`. Contrast held to the same floor as light Paper's
   table (HANDOFF §1): ink 13.4:1, muted 6.0:1, signal 7.0:1 on `--paper`; the
   one pair that missed 4.5:1 at the light palette's exact hues on `--raised`
   (`danger`, 3.99:1) is nudged lighter here (`#ea8072`, 4.87:1) — nothing
   else moved. */
html[data-theme="paper"][data-mode="dark"] {
  color-scheme: dark;
  --paper: #211e1a;
  --surface: #2a2622;
  --raised: #35302a;
  --ink: #ede6d9;
  --muted: #a89a85;
  --line: #453f37;
  --line-soft: #3a352e;
  --cobalt: #7fa3c4;
  --cobalt-ink: #12202e;
  --signal: #86b48a;
  --signal-ink: #16241a;
  --signal-soft: #24312a;
  --signal-line: #4f7357;
  --amber: #d9a94d;
  --danger: #ea8072;
  --ai: #a995c4;
  --ai-soft: #2c2534;
  --signal-glow: rgba(134, 180, 138, 0.22);
}

/* Paper's fills are lighter than `--muted`/`--amber` were measured against
   (HANDOFF §1: 4.9:1 for `muted` on `paper`). On the raised and soft fills the
   same two tokens miss 4.5:1 — `muted` is 4.19:1 on `raised` (a peer's
   bubble since 1.130), 4.30:1 on `signal-soft` and 3.70:1 on the own tone;
   `amber` is 4.09:1 on `raised`. The tokens are the approved palette and do
   not move (lightening `muted` drops it under 4.5:1 on `paper` as well), so
   the small text that lands on those fills takes `ink` (11.6:1 on `raised`),
   and the two amber status chips keep their colour by sitting on `--surface`
   (4.74:1) instead of `--raised`. Scoped to `paper`: every dark palette puts
   `raised` far enough from `muted` that those pairs already clear 4.5:1, and
   a global change would only make them louder. */
html[data-theme="paper"][data-mode] .roster-self-login,
html[data-theme="paper"][data-mode] #auth .lang-btn:not(.active),
html[data-theme="paper"][data-mode] .apk-chip,
html[data-theme="paper"][data-mode] .settings-link-btn:not(.settings-danger),
html[data-theme="paper"][data-mode] .command-palette-hint,
html[data-theme="paper"][data-mode] .command-item.selected .command-alias,
html[data-theme="paper"][data-mode] .row .bubble-meta,
html[data-theme="paper"][data-mode] .direct-toggle[data-state="idle"],
html[data-theme="paper"][data-mode] .conversation-search-toggle,
html[data-theme="paper"][data-mode] .conversation-menu-button,
html[data-theme="paper"][data-mode] .statusline .rail-btn:not([aria-pressed="true"]):not(.rail-update) {
  color: var(--ink);
}

html[data-theme="paper"][data-mode] .direct-toggle[data-state="connecting"],
html[data-theme="paper"][data-mode] .rail-update {
  background: var(--surface);
}

/* --- Header Controls --- */
.header-controls {
  display: flex;
  align-items: center;
  gap: var(--step-1);
}

.theme-toggle-btn,
.sound-toggle-btn,
.notify-toggle-btn,
.icon-action-btn,
.pwa-install-btn {
  background: var(--raised);
  border: 1px solid var(--edge);
  color: var(--ink);
  padding: 4px var(--step-2);
  font-size: var(--text-xs);
  border-radius: var(--radius-s);
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.theme-toggle-btn:hover,
.sound-toggle-btn:hover,
.notify-toggle-btn:hover,
.pwa-install-btn:hover,
.icon-action-btn:hover:not(:disabled) {
  background: var(--signal-soft);
}

/* Pressed reads as the button going back down into the bar it came out of:
   one pixel of travel, nothing that moves neighbours. */
.theme-toggle-btn:active,
.sound-toggle-btn:active,
.notify-toggle-btn:active,
.pwa-install-btn:active,
.icon-action-btn:active:not(:disabled) {
  transform: translateY(1px);
}

.pwa-install-btn {
  color: var(--signal);
}

.icon-action-btn:disabled {
  border-color: var(--edge-soft);
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
}

.talk-top-actions {
  display: flex;
  align-items: center;
  gap: var(--step-1);
  margin-left: auto;
  margin-right: var(--step-2);
}

/* --- Composer Container & Slash Command Palette --- */
.composer-container {
  position: relative;
  display: grid;
}

.command-palette {
  position: absolute;
  bottom: calc(100% + var(--step-1));
  left: var(--step-3);
  right: var(--step-3);
  max-height: 240px;
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--radius-m);
  box-shadow: var(--shadow-3);
  display: flex;
  flex-direction: column;
  z-index: 100;
  overflow: hidden;
}

.command-palette-header {
  padding: var(--step-1) var(--step-3);
  background: var(--raised);
  border-bottom: 1px solid var(--edge-soft);
  font-size: var(--text-xs);
  font-weight: 700;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
  color: var(--signal);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.command-palette-hint {
  font-size: 0.62rem;
  color: var(--muted);
  font-weight: 400;
  letter-spacing: 0.02em;
  text-transform: none;
}

.command-list {
  list-style: none;
  margin: 0;
  padding: var(--step-1) 0;
  overflow-y: auto;
  max-height: 200px;
}

.command-item {
  padding: var(--step-2) var(--step-3);
  display: flex;
  align-items: baseline;
  gap: var(--step-2);
  min-height: var(--tap);
  cursor: pointer;
  font-size: var(--text-sm);
  border-left: 3px solid transparent;
  transition: background-color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

.command-item:hover {
  background: color-mix(in srgb, var(--signal) 8%, transparent);
}

.command-item.selected {
  background: var(--signal-soft);
  border-left-color: var(--signal);
}

.command-name {
  font-weight: 700;
  color: var(--signal);
}

.command-item.selected .command-name {
  color: var(--signal);
  text-shadow: 0 0 8px var(--signal-glow);
}

.command-alias {
  font-size: var(--text-xs);
  color: var(--muted);
}

.command-help {
  margin-left: auto;
  font-size: var(--text-xs);
  color: var(--muted);
}

.command-item.selected .command-help {
  color: var(--ink);
}

/* --- Голосовые: кнопка записи, полоса записи, плеер --------------------- */

.attach-button,
.voice-button {
  display: grid;
  place-items: center;
  width: var(--field);
  height: var(--field);
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: var(--radius-pill);
  background: var(--raised);
  color: var(--muted);
  box-sizing: border-box;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.attach-button:hover:not(:disabled) {
  color: var(--cobalt);
  background: var(--surface);
}

.voice-button:hover:not(:disabled) {
  color: var(--danger);
  background: var(--surface);
}

.attach-button:active:not(:disabled),
.voice-button:active:not(:disabled) {
  transform: scale(0.94);
}

.attach-button:disabled,
.voice-button:disabled {
  border-color: var(--edge-soft);
  background: transparent;
  opacity: 0.4;
  cursor: not-allowed;
}

.voice-bar {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--step-2);
  padding: var(--step-2) var(--step-3);
  border-top: 1px solid var(--edge);
  background: var(--surface);
}

.voice-bar-state {
  color: var(--danger);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.voice-bar[data-state="recording"] .voice-bar-state {
  animation: pulse 1s infinite alternate;
}

.voice-bar[data-state="capped"] .voice-bar-state {
  color: var(--amber);
  animation: none;
}

/* Waiting on the microphone — a permission prompt, or a device taking its
   time. The bar is up from the moment record is pressed precisely so this
   wait is visible instead of looking like a dead button. */
.voice-bar[data-state="asking"] .voice-bar-state {
  color: var(--muted);
  animation: pulse 1s infinite alternate;
}

/* A recording that never started. The sentence needs room, so it is allowed to
   wrap and the controls that would do nothing are taken away. */
.voice-bar[data-state="error"] .voice-bar-state {
  color: var(--amber);
  animation: none;
  letter-spacing: normal;
  font-weight: 600;
  white-space: normal;
}

.voice-bar[data-state="asking"] .voice-meter,
.voice-bar[data-state="asking"] .voice-bar-timer,
.voice-bar[data-state="asking"] .voice-bar-send,
.voice-bar[data-state="error"] .voice-meter,
.voice-bar[data-state="error"] .voice-bar-timer,
.voice-bar[data-state="error"] .voice-bar-btn {
  display: none;
}

@keyframes pulse {
  from { opacity: 1; }
  to { opacity: 0.35; }
}

.voice-bar-timer {
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.voice-bar[data-state="capped"] .voice-bar-timer {
  color: var(--amber);
}

/* Метр уровня: высота каждой полосы — реальный RMS микрофона. */
.voice-meter {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 20px;
  min-width: 0;
  overflow: hidden;
}

.voice-meter span {
  flex: 1 1 3px;
  min-width: 2px;
  max-width: 5px;
  height: 2px;
  border-radius: 1px;
  background: var(--signal-line);
  transition: height 80ms linear, background-color 80ms linear;
}

.voice-meter span[data-hot="yes"] {
  background: var(--danger);
}

.voice-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 32px;
  padding: 0 var(--step-3);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: 700;
  white-space: nowrap;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.voice-bar-btn:active {
  transform: translateY(1px);
}

.voice-bar-btn .icon {
  width: 14px;
  height: 14px;
}

.voice-bar-cancel {
  border: 1px solid var(--edge);
  background: transparent;
  color: var(--danger);
}

.voice-bar-cancel:hover {
  background: color-mix(in srgb, var(--danger) 12%, transparent);
}

.voice-bar-send {
  border: 1px solid transparent;
  background: var(--signal);
  color: var(--signal-ink);
}

.voice-bar-send:hover {
  filter: brightness(1.08);
}


/* A drag across the transcript selects *messages*, not words: the text inside a
   bubble is not selectable at all (owner: «в веб не должен текст сообщений
   выделяться при проведении трэкадпом или курсом. должны вместо этого
   выделяться полностью баблы сообщений»). Copying the whole message is what
   «Копировать текст» in the ⋯ menu is for. The rule sits on the bubble rather
   than on `.bubble-text` alone so the author line, the forwarded-from line and
   the meta row cannot be half-selected either — the bubble is the unit a
   pointer acts on, which is what makes a drag mark rows instead of glyphs. */
.bubble {
  user-select: none;
  -webkit-user-select: none;
}

.row-selected .bubble {
  background: color-mix(in srgb, var(--raised) 80%, var(--signal));
}

.row-selected[data-side="own"] .bubble {
  background: color-mix(in srgb, var(--own-bubble-bg) 80%, var(--signal));
}

.row-selected[data-kind="ai"] .bubble {
  background: color-mix(in srgb, var(--ai-soft) 80%, var(--signal));
}



.voice-card {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto auto;
  align-items: center;
  gap: var(--step-2);
  margin-top: var(--step-1);
  padding: var(--step-2) var(--step-3);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-m);
  background: var(--bubble-step);
}

.voice-play-btn {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: 50%;
  background: var(--signal);
  color: var(--signal-ink);
  transition: filter var(--dur-fast) var(--ease), transform var(--dur-fast) var(--ease);
}

.voice-play-btn:hover {
  filter: brightness(1.08);
}

.voice-play-btn:active {
  transform: scale(0.92);
}

.voice-play-btn .icon {
  width: 13px;
  height: 13px;
}

.voice-waveform {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 22px;
  min-width: 0;
  border: 0;
  padding: 0;
  background: transparent;
  cursor: pointer;
}

.voice-waveform-bar {
  flex: 1 1 2px;
  min-width: 2px;
  max-width: 4px;
  height: 3px;
  border-radius: 1px;
  background: var(--line);
}

.voice-waveform-bar.played {
  background: var(--signal);
}

.voice-duration {
  color: var(--muted);
  font-size: 0.72rem;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.voice-speed-btn {
  flex-shrink: 0;
  padding: 2px var(--step-2);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-s);
  background: transparent;
  color: var(--muted);
  font-size: 0.7rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.4;
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}

.voice-speed-btn:hover {
  color: var(--ink);
  background: var(--bubble-step);
}

.voice-speed-btn:active {
  transform: scale(0.94);
}

/* --- ASCII Art and Code Blocks --- */
/* Art blocks carry the same half-block wordmark as the header band, so they
   need the header's treatment (`.logo-art`): a real monospace face, a size
   that keeps a 43-column row inside a 320px phone, and no kerning or
   ligatures to shift the columns. `inherit` used to hand the logo whatever
   face the transcript was set to, and its block glyphs then came from a
   fallback font wide enough to push the wordmark off the right edge. */
.msg-art {
  display: block;
  width: fit-content;
  min-width: 0;
  max-width: 100%;
  font-family: var(--mono);
  font-size: clamp(0.5rem, 2.9vw, 0.95rem);
  line-height: 1;
  letter-spacing: 0px;
  font-kerning: none;
  font-variant-ligatures: none;
  font-feature-settings: "liga" 0, "calt" 0, "tnum" 1;
  text-rendering: geometricPrecision;
  white-space: pre;
  background: var(--surface);
  border: 1px solid var(--edge-soft);
  padding: var(--step-2) var(--step-3);
  border-radius: var(--radius-s);
  color: var(--signal);
  margin: var(--step-2) auto;
  /* Only for output genuinely wider than the logo — a /help table on a narrow
     phone — and never the reason the wordmark itself has to be dragged. */
  overflow-x: auto;
}

.msg-code {
  display: block;
  /* Was `inherit` (the chat's proportional font), which is fine for a single
     flat colour but misaligns the moment tokens carry their own colour —
     indentation and column alignment only mean something in a fixed-width
     face. */
  font-family: var(--mono);
  font-size: var(--text-md);
  line-height: var(--leading-tight);
  white-space: pre-wrap;
  background: var(--paper);
  border: 1px solid var(--edge-soft);
  padding: var(--step-2) var(--step-3);
  border-radius: var(--radius-s);
  /* Was a flat var(--cobalt) — every character the same colour is what the
     complaint was about. Plain/identifier tokens keep this ordinary text
     colour; renderCodeBlock in app.js paints everything else per token. */
  color: var(--ink);
  margin: var(--step-2) 0;
  position: relative;
}

.msg-quote {
  border-left: 3px solid var(--signal-line);
  padding-left: var(--step-2);
  color: var(--muted);
  line-height: var(--leading-body);
  margin: var(--step-1) 0;
}

/* --- Screensaver --- */
.screensaver-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100dvh;
  background: #000;
  z-index: 9999;
  cursor: pointer;
}

/* --- Toast: a brief popup for feedback that does not belong in the
   transcript (e.g. /ping's latency readout) — see app.js's showToast. */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  transform: translateX(-50%) translateY(12px);
  z-index: 500;
  max-width: min(90vw, 420px);
  padding: 10px 16px;
  border-radius: var(--radius-l);
  background: var(--raised);
  border: 1px solid var(--edge);
  box-shadow: var(--shadow-2);
  color: var(--ink);
  font-size: 0.82rem;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast[data-visible="true"] {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* --- Wake Flash Effect --- */
@keyframes wakeFlash {
  0% { box-shadow: inset 0 0 0 4px var(--signal); }
  50% { box-shadow: inset 0 0 0 12px var(--cobalt); }
  100% { box-shadow: inset 0 0 0 0 transparent; }
}

.wake-active {
  animation: wakeFlash 0.8s ease-out 3;
}

/* --- Статус-строка ------------------------------------------------------ */

.statusline {
  grid-row: 2;
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: var(--step-2);
  min-height: var(--rail);
  padding:
    2px
    calc(var(--step-2) + var(--safe-right))
    calc(2px + var(--safe-bottom))
    calc(var(--step-2) + var(--safe-left));
  border-top: 1px solid var(--edge-soft);
  background: var(--surface);
}

.statusline-group {
  display: flex;
  align-items: center;
  gap: var(--step-1);
  min-width: 0;
}

.statusline-tools {
  flex-shrink: 0;
  margin-left: auto;
}

/* The profile avatar at the bottom of the rail (HANDOFF §3.2). Hidden unless
   the rail is a column — see the `@media (min-width: 720px)` block below the
   base rules: on a phone the bottom bar has no room for it and the roster
   header's own «Профиль» button is what the design asks for there. */
.statusline-self {
  display: none;
  flex-shrink: 0;
}

.rail-self {
  position: relative;
}

.rail-avatar {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--signal-soft);
  color: var(--signal);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1;
}

/* The connection state rides the avatar rather than a text line: at 60px there
   is no room for words, and the dot is the one thing worth glancing at. */
.rail-self-dot {
  position: absolute;
  right: 0;
  bottom: 0;
  padding: 1px;
  border-radius: 50%;
  background: var(--surface);
}

/* The status rail is the app's bottom bar on a phone, so its buttons are
   thumb-sized rather than the 24px chips they used to be. The drawn height
   stays 32px — the bar has to leave the transcript some room — and the
   coarse-pointer block near the end of the file grows the hit area instead. */
.rail-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 32px;
  padding: var(--step-1) var(--step-3);
  border: 1px solid var(--edge);
  border-radius: var(--radius-pill);
  background: var(--raised);
  color: var(--muted);
  font-size: var(--text-sm);
  font-weight: 700;
  white-space: nowrap;
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

.rail-btn:hover {
  color: var(--ink);
  background: var(--surface);
}

.rail-btn:active {
  transform: translateY(1px);
}

.rail-btn[aria-pressed="true"] {
  color: var(--signal);
  background: var(--signal-soft);
}

.rail-glyph {
  font-size: var(--text-md);
  line-height: 1;
}

.rail-logo {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  margin: 0 auto var(--step-2);
  border: 1px solid var(--edge);
  border-radius: calc(9px * var(--round));
  background: var(--surface);
  color: var(--signal);
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 700;
  flex-shrink: 0;
}

/* An update waiting is a state, not decoration: the amber ring stays whatever
   «Обводки» says. */
.rail-update {
  border-color: var(--amber);
  color: var(--amber);
}

/* Тесная строка: инструменты сжимаются до глифов, затем и переключатели. */
@media (max-width: 1023.98px) {
  .statusline-tools .rail-label {
    display: none;
  }
}

@media (max-width: 519.98px) {
  .rail-label {
    display: none;
  }
}

/* --- Разделитель панелей ------------------------------------------------ */

.pane-grip {
  position: relative;
  grid-row: 1;
  grid-column: 1;
  z-index: 30;
  align-self: stretch;
  justify-self: end;
  width: 9px;
  margin-right: -5px;
  cursor: col-resize;
  touch-action: none;
}

#info-grip {
  grid-column: 3;
  justify-self: start;
  margin-right: 0;
  margin-left: -5px;
}

/* Desktop: the grips sit between the panels, and the statusline is the left
   rail rather than the phone's bottom bar. Both override base rules declared
   above, and equal specificity is settled by source order — so this block has
   to stay *after* them, whatever else moves around it. */
@media (min-width: 720px) {
  #pane-grip {
    grid-column: 2;
  }

  #info-grip {
    grid-column: 4;
  }

  .statusline {
    grid-row: 1;
    grid-column: 1;
    flex-direction: column;
    align-items: stretch;
    justify-content: space-between;
    min-width: 60px;
    padding: calc(8px + var(--safe-top)) 8px calc(8px + var(--safe-bottom));
    border-top: 0;
    border-right: 1px solid var(--edge-soft);
  }

  .statusline-group {
    flex-direction: column;
  }

  .statusline-tools {
    order: 1;
    margin-top: auto;
    margin-left: 0;
  }

  .statusline-settings {
    order: 2;
    margin-top: 0;
  }

  .statusline-self {
    order: 3;
  }

  .statusline .rail-btn {
    width: 42px;
    min-width: 42px;
    height: 42px;
    justify-content: center;
    padding: 0;
    border-radius: 50%;
  }

  .statusline .rail-label {
    display: none;
  }

  /* The rail owns the profile avatar; the roster header's copy is the phone's
     version of the same affordance and has no place in the 60px column. */
  .statusline-self {
    display: flex;
    margin-top: var(--step-1);
  }

  .roster-self {
    display: none;
  }
}

@media (min-width: 720px) {
  .rail-logo {
    display: flex;
  }
}
.pane-grip-handle {
  position: absolute;
  top: 50%;
  left: 0;
  display: grid;
  place-items: center;
  width: 9px;
  height: 44px;
  border: 1px solid var(--edge);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--muted);
  font-size: 1rem;
  transform: translateY(-50%);
  box-shadow: var(--shadow-1);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease);
}

.pane-grip:hover .pane-grip-handle,
.pane-grip:focus-visible .pane-grip-handle,
.pane-grip[data-dragging="yes"] .pane-grip-handle {
  border-color: var(--signal);
  background: var(--signal-soft);
  color: var(--signal);
}

/* The grip is 9px wide, so an outline around it is a sliver nobody can see.
   The keyboard ring is drawn on the handle instead — same job, visible size. */
.pane-grip:focus-visible .pane-grip-handle {
  box-shadow: var(--ring);
}

.pane-grip::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: 4px;
  width: 1px;
  background: transparent;
  transition: background var(--dur-fast) var(--ease);
}

.pane-grip:hover::before,
.pane-grip:focus-visible::before,
.pane-grip[data-dragging="yes"]::before {
  background: var(--signal);
}

.pane-grip:focus-visible {
  outline: none;
}

/* --- Панель информации -------------------------------------------------- */

.info {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  border-left: 1px solid var(--edge);
  background: var(--surface);
}

.info-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--step-2);
  padding: calc(var(--step-3) + var(--safe-top)) var(--step-3) var(--step-2);
  border-bottom: 1px solid var(--edge-soft);
}

.info-top .eyebrow {
  margin: 0;
}

.pane-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  min-height: 26px;
  padding: 0;
  border: 1px solid var(--edge);
  border-radius: var(--radius-s);
  background: var(--raised);
  color: var(--muted);
  transition: color var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    background var(--dur-fast) var(--ease);
}

.pane-close:hover {
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 10%, transparent);
}

.info-body {
  min-height: 0;
  padding: var(--step-3);
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

.info-ident {
  display: grid;
  gap: 3px;
}

.info-name {
  font-size: var(--text-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.info-login {
  color: var(--cobalt);
  font-size: var(--text-xs);
  letter-spacing: 0.01em;
}

.info-presence {
  color: var(--muted);
  font-size: var(--text-xs);
}

.info-presence[data-online="online"] {
  color: var(--signal);
}

.info-presence[data-online="idle"],
.info-presence[data-online="away"] {
  color: var(--amber);
}

.info-block {
  margin-top: var(--step-4);
  padding-top: var(--step-3);
  border-top: 1px solid var(--edge-soft);
}

.info-heading {
  margin: 0 0 var(--step-2);
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: var(--track-caps);
  text-transform: uppercase;
}

.info-rows {
  display: grid;
  gap: var(--step-1);
  margin: 0;
}

.info-row {
  display: flex;
  align-items: baseline;
  gap: var(--step-2);
  font-size: var(--text-xs);
  line-height: var(--leading-tight);
}

.info-row dt {
  color: var(--muted);
}

.info-row dd {
  margin: 0 0 0 auto;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  overflow-wrap: anywhere;
  text-align: right;
}

.info-actions {
  display: grid;
  gap: var(--step-1);
}

.info-rows + .info-actions {
  margin-top: var(--step-2);
}

/* The safety code: each account's ten emojis under its login, five to a line
   so the narrow panel never wraps them differently from one reader to the
   next — both people read the same rows in the same order. */
.info-safety-code {
  display: grid;
  gap: var(--step-2);
}

.info-safety-half {
  display: grid;
  gap: 2px;
}

.info-safety-login {
  color: var(--muted);
  font-size: var(--text-xs);
}

.info-safety-emojis {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  font-size: 1.35rem;
  line-height: 1.3;
  text-align: center;
}

.info-safety-status {
  margin: var(--step-2) 0;
  color: var(--muted);
  font-size: var(--text-xs);
  line-height: var(--leading-tight);
}

.info-safety-status[data-verified="yes"] {
  color: var(--signal);
}

/* The one loud state: the peer's keys changed and nothing goes to them until
   the person compares the new code or accepts the keys. Not verified at all is
   the ordinary state and stays in the quiet colour. */
.info-safety-status[data-verified="changed"] {
  color: var(--danger);
}

.info-action {
  min-height: 34px;
  padding: 0 var(--step-3);
  border: 1px solid var(--edge);
  border-radius: var(--radius-s);
  background: var(--raised);
  color: var(--ink);
  font-size: var(--text-xs);
  font-weight: 700;
  text-align: left;
  transition: border-color var(--dur-fast) var(--ease), background var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease);
}

.info-action:hover:not(:disabled) {
  background: var(--signal-soft);
  color: var(--signal);
}

.info-action:disabled {
  border-color: var(--edge-soft);
  color: var(--muted);
  opacity: 0.55;
  cursor: not-allowed;
}

@media (max-width: 719.98px) {
  .info {
    border-left: 0;
  }
}

/* --- касание: площадь попадания ---------------------------------------- */

/* The compact glyph buttons keep their drawn size — growing them would push
   the bars they live in — and gain an invisible hit area instead, so what a
   finger has to land on is never smaller than --tap. */
@media (pointer: coarse) {
  .composer-context-cancel,
  .rail-btn,
  .modal-close,
  .pane-close,
  .roster-add-button,
  .roster-search-button,
  .workspace-button,
  .profile-open-button {
    position: relative;
  }

  .composer-context-cancel::after,
  .modal-close::after,
  .pane-close::after,
  .roster-add-button::after,
  .roster-search-button::after,
  .workspace-button::after,
  .profile-open-button::after,
  .pass-toggle-btn::after,
  .emoji-toggle::after,
  .roster-menu-btn::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: max(100%, var(--tap));
    height: max(100%, var(--tap));
    transform: translate(-50%, -50%);
  }

  /* The rail packs its buttons side by side, so this one only reaches out
     vertically: a horizontal expander would overlap its neighbour and steal
     taps meant for it. */
  .rail-btn::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 0;
    width: 100%;
    height: var(--tap);
    transform: translateY(-50%);
  }

}

/* --- меньше движения ---------------------------------------------------- */

/* One switch for the lot. Every transition and animation in this file is
   decoration — feedback about a state that has already changed — so when the
   system asks for less motion they are all cut at once rather than each block
   remembering to opt out. */
@media (prefers-reduced-motion: reduce) {
  .transcript {
    scroll-behavior: auto;
  }

  .roster-item {
    transition: none;
  }

  .voice-bar[data-state="recording"] .voice-bar-state {
    animation: none;
  }

  .voice-meter span {
    transition: none;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* Web workspace: calmer surfaces, readable type and discoverable tools. */
.auth-card { border-radius: var(--radius-l); padding: clamp(24px, 5vw, 48px); }
.auth-title { letter-spacing: -.04em; font-size: clamp(2rem, 5vw, 3rem); }
.auth-lead { max-width: 46ch; line-height: 1.7; }
.auth { background: radial-gradient(ellipse at 25% 15%, color-mix(in srgb, var(--signal) 9%, transparent), transparent 60%), var(--paper); }
.roster-top { padding-bottom: 16px; }
.roster-title { letter-spacing: -.03em; }
.roster-list { padding: 8px; }
.roster-row { margin-bottom: 5px; }
.roster-item { border-radius: var(--radius-m); padding: 14px 16px; }
.roster-name { font-size: .94rem; }
.roster-preview { margin-top: 5px; line-height: 1.5; }
.talk-top { padding-inline: 20px; min-height: 76px; }
.talk-peer-name { font-size: 1.06rem; letter-spacing: -.02em; }
.transcript { padding: 24px clamp(12px, 3vw, 48px); }
.bubble-text { line-height: 1.65; }
.day-badge { border-radius: var(--radius-pill); }
.placeholder { max-width: 440px; margin-inline: auto; }
.placeholder h2 { letter-spacing: -.03em; }
.roster-tools { display: grid; gap: 10px; margin-top: 18px; }
.workspace-search { width: 100%; min-width: 0; min-height: 42px; border: 1px solid var(--edge); border-radius: var(--radius-s); padding: 10px 12px; background: var(--paper); color: var(--ink); font: inherit; font-size: .84rem; }
.workspace-search::placeholder { color: var(--muted); }
.roster-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.workspace-button { min-width: 42px; min-height: 42px; padding: 8px 12px; border: 1px solid var(--edge-soft); border-radius: var(--radius-s); background: var(--surface); color: var(--muted); font: inherit; font-size: 1.05rem; line-height: 1; cursor: pointer; }
.workspace-button:hover { background: var(--raised); color: var(--ink); }
.workspace-button[aria-pressed="true"] { color: var(--signal); background: var(--signal-soft); }
.workspace-button:disabled { opacity: .4; cursor: default; }
.workspace-button:focus-visible, .workspace-search:focus-visible { outline: 2px solid var(--cobalt); outline-offset: 3px; }
.conversation-search { display: flex; gap: 6px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--edge-soft); background: var(--surface); flex: 0 0 auto; }
.conversation-search .workspace-search { flex: 1; }
.search-result-count { font-size: .75rem; color: var(--muted); white-space: nowrap; }
.row.search-match .bubble { outline: 1px solid var(--signal-line); }
.row.search-current .bubble { outline: 2px solid var(--cobalt); box-shadow: var(--ring); }
.roster-row[hidden], .conversation-search[hidden] { display: none; }
@media (max-width: 600px) {
  .talk-top { padding-inline: 12px; min-height: 64px; }
  .transcript { padding: 16px 12px; }
  .conversation-search { flex-wrap: wrap; padding: 8px; }
  .conversation-search .workspace-search { flex-basis: calc(100% - 60px); }
  .conversation-search .workspace-button { min-height: 44px; }
  .workspace-search { font-size: 16px; }
  .auth-card { padding: 24px 20px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; scroll-behavior: auto !important; }
}
.row:focus-visible { outline: none; }
.row:focus-visible .bubble { outline: 2px solid var(--cobalt); }
.quick-reactions { display: flex; gap: 4px; padding: 5px 6px 7px; border-bottom: 1px solid var(--edge-soft, transparent); }
.quick-reactions-item { display: grid; place-items: center; flex: 1; min-width: 28px; min-height: 28px; padding: 0; border: 0; border-radius: var(--radius-s); background: var(--raised); color: var(--ink); font-size: 16px; line-height: 1; cursor: pointer; }
.quick-reactions-item:hover { background: var(--signal-soft); }
.quick-reactions-more { font-size: 20px; }
.quick-reactions--settings { display: grid; grid-template-columns: repeat(auto-fit, minmax(28px, 1fr)); padding: 0; border: 0; max-width: 320px; }
.message-quick-reactions {
  position: fixed;
  z-index: 59;
  flex-direction: column;
  gap: 2px;
  width: 34px;
  max-height: 34px;
  padding: 2px;
  overflow: hidden;
  border: 1px solid var(--edge);
  border-radius: var(--radius-s);
  background: var(--raised);
  box-shadow: var(--shadow-3);
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.message-quick-reactions:hover,
.message-quick-reactions:focus-within,
.message-quick-reactions--touch {
  max-height: 132px;
  overflow-y: auto;
}
.message-quick-reactions .quick-reactions-item { flex: none; min-width: 0; width: 28px; height: 28px; }
.message-quick-reactions:not(:hover):not(:focus-within):not(.message-quick-reactions--touch) {
  width: 17px;
  max-height: 17px;
  padding: .5px;
  box-shadow: none;
}
.message-quick-reactions:not(:hover):not(:focus-within):not(.message-quick-reactions--touch) .quick-reactions-item {
  width: 14px;
  height: 14px;
  min-height: 14px;
  font-size: 8px;
}
.message-quick-reactions:not(:hover):not(:focus-within):not(.message-quick-reactions--touch) .quick-reactions-item:not(:first-child) { display: none; }
.bubble-reaction .emoji { width: 1.1em; height: 1.1em; vertical-align: initial; }
.bubble-edited, .bubble-reminded { color: var(--muted); font-size: .85rem; }
.msg-menu-title { margin: 0; padding: 6px 10px 4px; color: var(--muted); font-size: var(--text-xs); }
.msg-menu-details {
  display: grid;
  gap: 3px;
  padding: 8px 10px;
  border-top: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: var(--text-xs);
}
.msg-menu-details p { margin: 0; }
.bubble-forward { margin: 0 0 4px; color: var(--muted); font-size: var(--text-xs); font-style: italic; }
.row[data-deleted="true"] .bubble-text { color: var(--muted); font-style: italic; }
.bubble-reaction[data-unread="true"] { background: color-mix(in srgb, var(--cobalt) 20%, var(--raised)); }
.rail-update--attention { animation: updatePulse 1.4s ease-in-out 3; }
@keyframes updatePulse { 50% { background: color-mix(in srgb, var(--amber) 20%, var(--surface)); box-shadow: 0 0 0 4px color-mix(in srgb, var(--amber) 18%, transparent); } }
@media (pointer: coarse) {
  /* Keep vertical scrolling and zoom while letting a full reaction strip
     scroll sideways without increasing the bubble's height. */
  .row .bubble { touch-action: pan-x pan-y pinch-zoom; }
}

/* --- 1.130: плоско --------------------------------------------------------
   1.128's «объём» gave every surface a lift — a rim highlight, a contact
   shadow, a sheen on the fill — and the panels cast shadows onto the
   transcript. 1.130 takes that back for everything that sits in the flow
   (bubbles, rows, cards, bars, round buttons): they are told apart by tone
   and spacing, and by an edge only when «Обводки» is on. Shadows stay on what
   actually floats over something else — menus, the command palette, dialogs,
   the toast, the scroll-to-bottom button, and the pickers/lightbox
   that style themselves — through `--shadow-2`/`--shadow-3`, because there
   the shadow says «this is on top». */

/* The header and the composer stay in their own layer: the popovers that
   open from them (command palette, emoji picker) have to stack above the
   transcript, which paints after them in tree order. */
.talk-top,
.composer {
  position: relative;
  z-index: 3;
}

/* The day line sits on the wallpaper, so it is a frosted pill that reads over
   any pattern instead of bare small caps between dashes. */
.day-divider {
  width: fit-content;
  margin-inline: auto;
  padding: 3px var(--step-3);
  border-radius: var(--radius-pill);
  background: color-mix(in oklab, var(--surface) 80%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.day-divider::before,
.day-divider::after {
  content: none;
}

.typing-chip {
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

/* Floating layers rise into place. `scale` rather than `transform`, so
   nothing that positions these layers through `transform` is overwritten
   while the animation runs. */
.msg-menu,
.command-palette:not([hidden]),
.modal-dialog[open] .modal-card {
  animation: tc-rise 160ms var(--ease);
}

@keyframes tc-rise {
  from {
    opacity: 0;
    scale: 0.97;
  }
}

/* --- 1.128: студия -------------------------------------------------------
   The second 1.128 pass. Three layers, back to front: ambient light (the
   app's own background — three accent glows), the room (the conversation
   column carrying the wallpaper, see `.talk` above), and glass (every bar and
   panel is a translucent sheet over one of the two, so colour reads through
   instead of each panel being an opaque slab). On top of that: presence
   avatars in the roster and the info panel (the APK's `PresenceAvatar`, now
   on web too), a composer dock, stat tiles, and a tinted empty state. Since
   1.130 the glass carries no rim and no shadow of its own (see «плоско»
   above). Only paint and spacing change: receipt size and colours (§11/§12),
   the textarea's no-ring rule and every grid that JS measures stay as they
   were. */

:root {
  --glass: color-mix(in oklab, var(--surface) 72%, transparent);
  --glass-strong: color-mix(in oklab, var(--surface) 84%, transparent);
  --glass-blur: blur(18px) saturate(1.35);
  --dock-inset: var(--step-3);
}

@media (min-width: 720px) {
  :root { --dock-inset: var(--step-4); }
}

/* Ambient light: what the translucent panels are tinted by. */
.app,
.auth {
  background:
    radial-gradient(70% 60% at 0% 0%, color-mix(in oklab, var(--signal) 11%, transparent), transparent 70%),
    radial-gradient(55% 55% at 100% 0%, color-mix(in oklab, var(--cobalt) 9%, transparent), transparent 70%),
    radial-gradient(65% 60% at 100% 100%, color-mix(in oklab, var(--ai) 10%, transparent), transparent 70%),
    var(--paper);
}

.roster,
.info,
.statusline {
  background-color: var(--glass);
}

/* Thin, quiet scrollbars: the native ones were the last opaque grey slabs. */
.roster-list,
.transcript,
.info-body,
.settings-dialog .modal-card {
  scrollbar-width: thin;
  scrollbar-color: color-mix(in oklab, var(--muted) 40%, transparent) transparent;
}

/* --- the room: glass over the wallpaper ---------------------------------- */

.talk-top {
  background-color: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.talk-peer-name {
  font-size: 1.12rem;
  letter-spacing: -0.02em;
}

/* The band itself stays transparent over the wallpaper; the wordmark sits on
   its own glass plate. The plate is painted on `.logo-art`, so it scales with
   `--logo-fit` and pulses with the tap animation instead of staying behind as
   a fixed box. */
.logo-band {
  padding: var(--step-2) var(--step-3);
  background: transparent;
  border-bottom: 0;
}

.logo-art {
  padding: var(--step-2) var(--step-4);
  border: 1px solid var(--edge);
  border-radius: var(--radius-l);
  background-color: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
  text-shadow: 0 0 18px var(--signal-glow);
}

.conversation-search {
  background-color: var(--glass-strong);
}

/* The composer is a dock set into the room rather than a bar welded to the
   bottom edge. Its corner is concentric with the 46px pill buttons inside it
   (half the field plus the dock's own padding), scaled down with
   «Скругление» but never past round. The strips that open above it — reply /
   edit context, bot actions, the voice recorder — are cards on the same
   inset, so the stack reads as one object. Glass and tone set it off the
   wallpaper; the field inside it is the solid `--raised` fill (see
   `.composer-grow > textarea`), with no ring and no inset shadow. */
.composer {
  margin: 0 var(--dock-inset) var(--step-3);
  padding: var(--step-2);
  border: 1px solid var(--edge);
  border-radius: calc((var(--field) / 2 + var(--step-2)) * min(var(--round), 1));
  background-color: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

.composer-context,
.bot-actions,
.voice-bar {
  margin: 0 var(--dock-inset) var(--step-2);
  border: 1px solid var(--edge);
  border-radius: var(--radius-l);
  background-color: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

/* Messages fade into the glass at both edges instead of being sliced off by
   a hard line — the mask is on the scroll container, so it stays put while
   the rows travel through it. */
.transcript {
  padding-bottom: var(--step-4);
  -webkit-mask-image: linear-gradient(180deg, transparent 0, #000 18px, #000 calc(100% - 12px), transparent 100%);
  mask-image: linear-gradient(180deg, transparent 0, #000 18px, #000 calc(100% - 12px), transparent 100%);
}

/* --- messages ------------------------------------------------------------- */

.bubble {
  padding: 7px 14px;
}

/* --- roster: avatars and rows ---------------------------------------------- */

.roster-title {
  font-size: 1.35rem;
}

.roster-item {
  grid-template-areas:
    "avatar name badge"
    "avatar preview badge"
    "avatar status badge";
  grid-template-columns: auto minmax(0, 1fr) auto;
  column-gap: var(--step-3);
  padding: 10px 12px;
}

/* The circle. The initial takes the presence colour, the fill its soft twin
   while online — the APK's `PresenceAvatar` states: online (accent),
   idle/away (amber), offline (muted), official account (cobalt), plus Saved
   Messages, which has no presence and takes the AI accent. The ring is an
   outline like any other (owner, 2026-10-28: «обводку аватарок убери»): the
   border keeps its 1.5px and is transparent until «Обводки» is on, so the
   circle is the same size either way. The online halo is part of the ring and
   follows it. The fill is flat, with no highlight and no lift unless «Объёмный
   дизайн» adds them. */
.roster-avatar {
  --av-ring: var(--muted);
  --av-fill: var(--raised);
  grid-area: avatar;
  align-self: center;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1.5px solid transparent;
  border-radius: 50%;
  background: var(--av-fill);
  color: var(--av-ring);
  font-family: var(--mono);
  font-size: 1.05rem;
  font-weight: 700;
  line-height: 1;
  user-select: none;
}

html[data-borders="on"] .roster-avatar {
  border-color: var(--av-ring);
}

.roster-avatar[data-presence="online"] {
  --av-ring: var(--signal);
  --av-fill: var(--signal-soft);
}

html[data-borders="on"] .roster-avatar[data-presence="online"] {
  box-shadow: 0 0 0 3px color-mix(in oklab, var(--signal) 16%, transparent);
}

.roster-avatar[data-presence="idle"],
.roster-avatar[data-presence="away"] {
  --av-ring: var(--amber);
}

.roster-avatar[data-presence="service"] {
  --av-ring: var(--cobalt);
}

.roster-avatar[data-presence="saved"] {
  --av-ring: var(--ai);
  --av-fill: var(--ai-soft);
}

.roster-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  border-radius: var(--radius-pill);
}

/* --- info panel: identity card and stat tiles ------------------------------ */

.info-ident {
  justify-items: center;
  gap: 4px;
  padding: var(--step-3) 0 var(--step-2);
  text-align: center;
}

.info-avatar {
  /* `.roster-avatar` names a grid area the roster row defines; the identity
     column has no such area, and an unknown name would open an implicit
     second column beside the text. */
  grid-area: auto;
  width: 76px;
  height: 76px;
  margin-bottom: var(--step-2);
  font-size: 1.9rem;
}

.info-block {
  margin-top: var(--step-3);
  padding: var(--step-3);
  border: 1px solid var(--edge-soft);
  border-radius: var(--radius-m);
  background: color-mix(in oklab, var(--raised) 50%, transparent);
}

.info-ident + .info-block .info-rows {
  grid-template-columns: 1fr 1fr;
  gap: var(--step-2);
}

.info-ident + .info-block .info-row {
  flex-direction: column-reverse;
  align-items: flex-start;
  gap: 0;
  min-width: 0;
  padding: var(--step-2) 10px;
  border-radius: var(--radius-s);
  background: color-mix(in oklab, var(--surface) 70%, transparent);
}

.info-ident + .info-block .info-row dd {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1.2;
}

.info-ident + .info-block .info-row dt {
  overflow: hidden;
  max-width: 100%;
  font-size: 0.66rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* --- rail ------------------------------------------------------------------- */

.rail-logo {
  background: color-mix(in oklab, var(--signal) 18%, var(--surface));
}

/* --- empty state and sign-in ------------------------------------------------ */

.placeholder-mark {
  width: 76px;
  height: 76px;
  margin-bottom: var(--step-2);
  border-color: var(--edge);
  border-radius: calc(24px * var(--round));
  background: color-mix(in oklab, var(--signal) 14%, var(--surface));
  color: var(--signal);
  font-size: 2rem;
}

.placeholder h2 {
  font-size: 1.3rem;
}

.placeholder p {
  font-size: 0.84rem;
}

.auth-card {
  background-color: var(--glass);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

/* Dialogs are glass too: the room stays faintly visible behind the sheet. */
.modal-card {
  background-color: var(--glass-strong);
  -webkit-backdrop-filter: var(--glass-blur);
  backdrop-filter: var(--glass-blur);
}

/* --- картинка в ленте ----------------------------------------------------
   The image owns the width. A missing caption leaves no bubble behind it;
   a real caption follows below, inside the ordinary own/peer tone. */
.row[data-image] > .bubble {
  width: min(var(--image-w, 480px), 100%);
  max-width: 100%;
  min-width: 0;
}


.row[data-image="bare"][data-side] > .bubble {
  padding: 0;
  border-color: transparent;
  background: none;
  box-shadow: none;
}

.row[data-image="bare"] .msg-image-frame {
  margin-top: 0;
}

/* The same shape as a bubble — three round corners and the tail corner on the
   sender's side — so a picture reads as a message, not as a pasted tile. */
.row[data-image="bare"] .msg-image-wrap {
  border-radius: var(--radius-bubble);
  border-bottom-left-radius: var(--radius-tail);
}

.row[data-image="bare"][data-side="own"] .msg-image-wrap {
  border-bottom-left-radius: var(--radius-bubble);
  border-bottom-right-radius: var(--radius-tail);
}

/* A quote or forward still needs a readable surface over the wallpaper. */
.row[data-image="bare"] .bubble-forward,
.row[data-image="bare"] .bubble-author {
  width: fit-content;
  padding: 2px var(--step-2);
  border-radius: var(--radius-pill);
  background: var(--raised);
}

.row[data-image="bare"] .bubble-reply {
  background-color: var(--raised);
}

html .row[data-image="bare"][data-side][data-kind] .msg-image-frame > .bubble-meta {
  position: absolute;
  right: 6px;
  bottom: 6px;
  height: 1.25rem;
  width: max-content;
  max-width: none;
  margin: 0;
  padding: 0 var(--step-2);
  border-radius: 999px;
  background: rgba(0, 0, 0, .45);
  color: #fff;
}

/* On very narrow peer images the pill can extend right, into the transcript,
   rather than disappear past its left edge. Own images have that room left. */
.row[data-image="bare"][data-side="peer"] .msg-image-frame > .bubble-meta {
  transform: translateX(max(0px, calc(100% + 12px - var(--image-w, 480px))));
}

.row[data-image="bare"] .bubble-mark[data-state="sent"],
.row[data-image="bare"] .bubble-mark[data-state="ack"] {
  color: #fff;
}

.row[data-image="bare"] .bubble-mark[data-state="read"] {
  color: var(--signal);
  /* A photo can be any colour. The opposite-luminance rim keeps the accent
     legible without substituting another receipt colour for --signal. */
  filter: drop-shadow(1px 0 var(--image-read-outline, #000))
    drop-shadow(-1px 0 var(--image-read-outline, #000))
    drop-shadow(0 1px var(--image-read-outline, #000))
    drop-shadow(0 -1px var(--image-read-outline, #000));
}

.row[data-image="bare"] .msg-image-frame > .bubble-meta .bubble-edited,
.row[data-image="bare"] .msg-image-frame > .bubble-meta .bubble-reminded {
  color: inherit;
}

.row[data-image="bare"] .bubble > .bubble-reactions {
  height: 1.5rem;
  margin: 4px 0 0;
}

.row[data-image="bare"][data-side="own"] .bubble > .bubble-reactions {
  justify-content: flex-end;
}

/* There is no bubble fill to tint in selection mode. */
.row-selected[data-image="bare"] .msg-image-wrap::after {
  content: '';
  position: absolute;
  inset: 0;
  background: color-mix(in srgb, var(--signal) 35%, transparent);
  pointer-events: none;
}

.row[data-image="captioned"][data-side] > .bubble {
  /* A needle-thin original keeps a usable caption without upscaling the
     image itself: only its frame gains the metadata's minimum room. */
  min-width: min(10rem, 100%);
  padding: 0 0 4px;
}

.row[data-image="captioned"] .bubble-content > :not(.msg-image-frame):not(.bubble-meta),
.row[data-image="captioned"] .bubble > .bubble-reactions {
  margin-inline: var(--step-3);
}

.row[data-image="captioned"] .bubble-author + :not(.msg-image-frame),
.row[data-image="captioned"] .bubble-content > :first-child:not(.msg-image-frame) {
  margin-top: var(--step-2);
}

.row[data-image="captioned"] .msg-image-frame,
.row[data-image="captioned"] .msg-image-wrap {
  width: 100%;
}

.row[data-image="captioned"] .msg-image {
  width: auto;
  margin-inline: auto;
}

.row[data-image="captioned"] .bubble-meta {
  right: var(--step-3);
}

.row[data-image="captioned"] .msg-image-frame {
  margin-top: 0;
  overflow: hidden;
  border-radius: var(--radius-bubble) var(--radius-bubble) 0 0;
}

.row[data-image="captioned"] .msg-image-wrap {
  border: 0;
  border-radius: 0;
}

/* A caption is a line under a picture, not a second message: tight spacing
   and line height so the strip stays thin (owner, 2026-10-28: «компактно»). */
.row[data-image="captioned"] .bubble-content > .bubble-text {
  margin-top: 4px;
  line-height: 1.35;
}

/* --- «Объёмный дизайн» (опция, 2026-10-28) ---------------------------------
   1.128's depth, back as a switch (Settings → appearance, `data-depth`,
   app.js `setDepth`; default off, so everything above is the flat look). The
   tokens and the rules that used them are the 1.128 ones — the elevation scale
   (rim highlight + contact shadow + ambient shadow), the sheen, the accent
   glow, the glass line and the edge shadows — scoped under
   `html[data-depth="on"]` and last in the file, so they re-skin the flat rules
   without moving a pixel of layout.

   What depth does NOT do:
   - It never turns borders on. Every line stays `--edge`/`--edge-soft`;
     `--glass-line` and `--own-bubble-border` are *derived from* `--edge`, so
     they are transparent while «Обводки» is off. What depth adds is shadow,
     rim light and sheen, which are light and not outlines.
   - It never repaints a fill that text sits on. The own bubble stays
     `--own-bubble-bg`, the open roster row its own tone, badge/send/logo/mark
     fills their flat ones; 1.128's accent-tinted gradients over those are gone.
     Sheen over a bubble is a 2% white film in the dark half (own quote author
     on paper/dark: 4.91:1 → 4.69:1 at its very top) and a 45% one in the light
     half, where lightening only raises dark text's contrast. The accent
     gradient on a badge or the send button lightens towards the top in the
     dark half and darkens towards the bottom in the light one, where white
     text sits on it.
   - It never draws a box around a bare image or a jumbo emoji row, and never
     overrides a state (selection, search match, pending, disabled, pressed):
     those rules are excluded or out-specified below. A bare image gets the
     elevation on the picture itself. */
html[data-depth="on"] {
  --elev-edge: inset 0 1px 0 rgba(255, 255, 255, 0.045);
  --elev-1: var(--elev-edge), 0 1px 2px rgba(0, 0, 0, 0.32), 0 4px 10px -4px rgba(0, 0, 0, 0.42);
  --elev-2: var(--elev-edge), 0 2px 4px rgba(0, 0, 0, 0.3), 0 12px 28px -10px rgba(0, 0, 0, 0.6);
  --elev-3: var(--elev-edge), 0 6px 14px rgba(0, 0, 0, 0.32), 0 32px 64px -20px rgba(0, 0, 0, 0.78);
  --elev-inset: inset 0 1px 3px rgba(0, 0, 0, 0.38), inset 0 0 0 1px rgba(0, 0, 0, 0.1);
  --sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0) 55%);
  --sheen-bubble: linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0) 50%);
  --accent-glow: 0 6px 18px -6px var(--signal-glow);
  --accent-fill: linear-gradient(180deg, color-mix(in oklab, var(--signal) 90%, white), var(--signal));
  --shadow-up: 0 -8px 24px -14px rgba(0, 0, 0, 0.7);
  --shadow-side: 2px 0 20px -10px rgba(0, 0, 0, 0.7);
  --glass-line: color-mix(in oklab, var(--edge) 70%, transparent);
  --own-bubble-border: color-mix(in srgb, var(--signal) 36%, var(--own-bubble-bg));
}

html[data-depth="on"][data-mode="light"] {
  --elev-edge: inset 0 1px 0 rgba(255, 255, 255, 0.85);
  --elev-1: var(--elev-edge), 0 1px 2px rgba(16, 24, 40, 0.07), 0 4px 10px -4px rgba(16, 24, 40, 0.13);
  --elev-2: var(--elev-edge), 0 2px 4px rgba(16, 24, 40, 0.06), 0 14px 30px -12px rgba(16, 24, 40, 0.22);
  --elev-3: var(--elev-edge), 0 8px 16px rgba(16, 24, 40, 0.08), 0 32px 64px -20px rgba(16, 24, 40, 0.3);
  --elev-inset: inset 0 1px 2px rgba(16, 24, 40, 0.08), inset 0 0 0 1px rgba(16, 24, 40, 0.02);
  --sheen: linear-gradient(180deg, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 60%);
  --sheen-bubble: linear-gradient(180deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 55%);
  --accent-fill: linear-gradient(180deg, var(--signal), color-mix(in oklab, var(--signal) 88%, black));
  --shadow-up: 0 -6px 18px -10px rgba(16, 24, 40, 0.14);
  --shadow-side: 1px 0 16px -8px rgba(16, 24, 40, 0.16);
}

/* Panels. The header and the composer cast their shadow onto the transcript;
   both already sit in their own layer (`z-index: 3`, see «плоско»). The rail
   and the roster cast sideways once the rail is a column, the phone's bottom
   bar casts upwards. */
html[data-depth="on"] :is(.roster, .info, .statusline, .talk-top, .composer) {
  background-image: var(--sheen);
  background-origin: border-box;
  background-repeat: no-repeat;
}

html[data-depth="on"] .statusline {
  box-shadow: var(--shadow-up);
}

@media (min-width: 720px) {
  html[data-depth="on"] :is(.roster, .statusline) {
    box-shadow: var(--shadow-side);
  }
}

html[data-depth="on"] .talk-top {
  box-shadow: var(--elev-2);
}

html[data-depth="on"] .composer {
  border-color: var(--glass-line);
  box-shadow: var(--elev-2);
}

html[data-depth="on"] :is(.composer-context, .bot-actions, .voice-bar) {
  border-color: var(--glass-line);
  box-shadow: var(--elev-1);
}

html[data-depth="on"] .roster-self {
  background-image: var(--sheen);
  background-origin: border-box;
  background-repeat: no-repeat;
  box-shadow: var(--elev-1);
}

/* Roster rows: a hovered row rises a pixel, the open one is a lit card with
   the accent bar. The open row keeps its flat tone as the fill (its name and
   preview colours were measured on it), so only shadow and bar are added. */
html[data-depth="on"] .roster-item {
  transition: background var(--dur-fast) var(--ease), border-color var(--dur-fast) var(--ease),
    color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

html[data-depth="on"] .roster-item:hover {
  background-image: var(--sheen);
  background-origin: border-box;
  background-repeat: no-repeat;
  box-shadow: var(--elev-1);
  transform: translateY(-1px);
}

html[data-depth="on"] .roster-item:is(.active, [aria-current="true"]) {
  background-image: none;
  box-shadow: var(--elev-1), inset 3px 0 0 var(--signal);
  transform: none;
}

html[data-depth="on"] .roster-badge {
  background-image: var(--accent-fill);
  box-shadow: var(--accent-glow);
}

/* The circle gets the sheen and the lift; the ring itself is «Обводки»'s, and
   with both on the online halo sits beside the lift. */
html[data-depth="on"] .roster-avatar {
  background-image: var(--sheen);
  background-origin: border-box;
  background-repeat: no-repeat;
  box-shadow: var(--elev-1);
}

html[data-depth="on"][data-borders="on"] .roster-avatar[data-presence="online"] {
  box-shadow: var(--elev-1), 0 0 0 3px color-mix(in oklab, var(--signal) 16%, transparent);
}

html[data-depth="on"] .rail-avatar {
  box-shadow: var(--elev-1);
}

/* Messages. Every state rule that sets its own `box-shadow` on a bubble (a
   search match, a bare picture, a jumbo emoji) is more specific than this one
   and wins as written; the hover lift and the sheen exclude them by name,
   because they are written to out-rank. The sheen is a background *image*, so
   the fills stay the flat tokens; selection and AI rows repaint the whole
   background through their own shorthand and are left out. */
html[data-depth="on"] .bubble {
  box-shadow: var(--elev-1);
  transition: border-color var(--dur-fast) var(--ease), box-shadow var(--dur-fast) var(--ease),
    transform var(--dur-fast) var(--ease);
}

html[data-depth="on"] .row:not(.row-selected, [data-kind="ai"], [data-image="bare"], [data-jumbo="true"]:not([data-deleted="true"])) .bubble {
  background-image: var(--sheen-bubble);
  /* Sized to the border box and not tiled: with «Обводки» off the 1px border
     is transparent, and a repeated tile would draw its brightest strip there
     as a pale hairline along the bottom edge. */
  background-origin: border-box;
  background-repeat: no-repeat;
}

@media (hover: hover) {
  html[data-depth="on"] .row:where(:not(.search-current, [data-image="bare"], [data-jumbo="true"]:not([data-deleted="true"]))) .bubble:hover {
    box-shadow: var(--elev-2);
  }
}

/* With «Обводки» on as well, one's own bubble gets 1.128's accent edge back
   (derived from the fill). `:where()` keeps it below the pending (dashed
   `--line`), bare-image and jumbo rules. */
:where(html[data-depth="on"][data-borders="on"] .row[data-side="own"]) .bubble,
:where(html[data-depth="on"][data-borders="on"]) .wallpaper-bubble--own {
  border-color: var(--own-bubble-border);
}

/* A bare picture has no bubble to lift; the picture itself carries the
   elevation (its frame and the corner pill are untouched). */
html[data-depth="on"] .row[data-image="bare"] .msg-image-wrap {
  box-shadow: var(--elev-1);
}

/* Cards inside a bubble stay on their tone step; a rim of light is all they
   take, because a shadow inside a shadow reads as dirt. */
html[data-depth="on"] :is(.link-preview, .file-open-link, .voice-card) {
  box-shadow: var(--elev-edge);
}

html[data-depth="on"] :is(.day-divider, .typing-chip) {
  box-shadow: var(--elev-1);
}

/* The draft field is pressed into the composer — the same depth focused or
   not, because focus must not add a ring (see the textarea rules above). */
html[data-depth="on"] .composer-grow > textarea,
html[data-depth="on"] .composer-grow > textarea:focus,
html[data-depth="on"] .composer-grow > textarea:focus-visible {
  box-shadow: var(--elev-inset);
}

html[data-depth="on"] .composer-grow > textarea:disabled {
  box-shadow: none;
}

html[data-depth="on"] .workspace-search:not(:focus-visible) {
  box-shadow: var(--elev-inset);
}

/* Round controls: raised discs that sink when pressed. `:active` and
   `:disabled` drop the lift, which is the press. */
html[data-depth="on"] :is(.attach-button, .voice-button, .direct-toggle, .conversation-search-toggle, .conversation-menu-button, .rail-btn, .workspace-button, .info-action, .profile-open-button):not(:disabled, :active) {
  background-image: var(--sheen);
  background-origin: border-box;
  background-repeat: no-repeat;
  box-shadow: var(--elev-1);
}

html[data-depth="on"] .rail-btn:not(:hover, [aria-pressed="true"], :disabled, :active) {
  box-shadow: var(--elev-edge);
}

html[data-depth="on"] .rail-btn[aria-pressed="true"]:not(:disabled) {
  box-shadow: var(--elev-edge), 0 4px 14px -6px var(--signal-glow);
}

/* The one primary action: the accent lit from above (from below in the light
   half, see `--accent-fill`) and glowing onto the composer. */
html[data-depth="on"] .send-button:not(:disabled) {
  background-image: var(--accent-fill);
  box-shadow: var(--elev-edge), var(--accent-glow), 0 1px 2px rgba(0, 0, 0, 0.25);
}

html[data-depth="on"] .send-button:hover:not(:disabled) {
  box-shadow: var(--elev-edge), 0 8px 22px -6px var(--signal-glow), 0 2px 4px rgba(0, 0, 0, 0.25);
}

html[data-depth="on"] .send-button:active:not(:disabled) {
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.25);
}

html[data-depth="on"] .scroll-bottom-btn {
  background-image: var(--sheen);
  background-origin: border-box;
  background-repeat: no-repeat;
  box-shadow: var(--elev-2), var(--accent-glow);
}

html[data-depth="on"] .scroll-bottom-btn:hover {
  box-shadow: var(--elev-3), var(--accent-glow);
}

/* Floating layers: the deepest step. */
html[data-depth="on"] :is(.msg-menu, .command-palette, .modal-card) {
  box-shadow: var(--elev-3);
}

html[data-depth="on"] .wallpaper-preview {
  box-shadow: var(--elev-1);
}

html[data-depth="on"] .wallpaper-btn.active .wallpaper-preview {
  box-shadow: var(--elev-1), var(--ring);
}

/* Glass lines: the 1.128 edges of the glass sheets, `--edge`-derived. */
html[data-depth="on"] :is(.logo-art, .info-block, .auth-card, .modal-card) {
  border-color: var(--glass-line);
}

html[data-depth="on"] .logo-art {
  box-shadow: var(--elev-1), 0 0 24px -8px var(--signal-glow);
}

html[data-depth="on"] .info-block {
  box-shadow: var(--elev-1);
}

html[data-depth="on"] .info-ident + .info-block .info-row {
  box-shadow: var(--elev-inset);
}

html[data-depth="on"] .rail-logo {
  box-shadow: var(--elev-1), 0 0 18px -6px var(--signal-glow);
}

html[data-depth="on"] .placeholder-mark {
  box-shadow: var(--elev-2), 0 0 48px -10px var(--signal-glow);
}

html[data-depth="on"] .auth-card {
  box-shadow: var(--elev-3);
}

@media (prefers-reduced-motion: reduce) {
  .lightbox-image--enter {
    animation: none;
  }

  .lightbox--animate .lightbox-image {
    transition: none;
  }
}
