/* What gives way when the row is short, in this order: the channel's
     word, whole (it drops to a line that is not shown; the glyph stays),
     then the account's name, down to a few letters and never to its dot
     alone. The word of trouble is never cut. */
.thread-sender .thread-channel {
  flex: 0 1000 auto;
  flex-wrap: wrap;
  align-content: flex-start;
  min-width: 14px;
  height: 1.4em;
  overflow: hidden;
  line-height: 1.4;
}
.thread-sender .thread-channel > svg {
  flex: 0 0 auto;
  height: 1.4em;
}
.thread-sender .thread-channel > span {
  white-space: nowrap;
}
.thread-sender .tag {
  flex: 0 1 auto;
  min-width: min(100%, 56px);
}
.thread-sender .badge {
  flex: 0 0 auto;
}
/* ThreadBell cabinet. One system on top of the Bearmark Core roles in
   bearmark.css: 4px spacing rhythm, kit control heights (34 / 42, 44 on a
   phone), radii that nest (shell 18 > card 12 > control 8 > chip pill). */

:root {
  --tb-topbar-h: 56px;
  --tb-control-h: 42px;
  --tb-control-sm: 34px;
  --tb-gutter: 28px;
  --tb-rail: 220px;
  --tb-gap: 20px;
  /* The ONE focus indicator (design/core/focusRing.ts): a solid 2px ring
     with the 34% halo outside it. Components that cast a shadow of their own
     add it after the ring, never instead of it. */
  --tb-ring: 0 0 0 2px var(--bm-focus), 0 0 0 5px var(--bm-focus-ring);
  /* The same ring on the iron chrome (top bar, phone tab bar, lightbox). */
  --tb-ring-chrome:
    0 0 0 2px var(--bm-brass-hi),
    0 0 0 5px color-mix(in srgb, var(--bm-brass-hi) 34%, transparent);
}
@media (max-width: 620px), (max-height: 500px) and (pointer: coarse) {
  :root {
    --tb-topbar-h: 48px;
    --tb-control-h: 44px;
    --tb-control-sm: 44px;
    --tb-gutter: 14px;
  }
}
@media (pointer: coarse) {
  :root {
    --tb-control-h: 44px;
    --tb-control-sm: 44px;
  }
}

/* ---- base ----------------------------------------------------------------- */
* {
  box-sizing: border-box;
}
[hidden] {
  display: none !important;
}
html {
  -webkit-text-size-adjust: 100%;
}
/* Type by the brand pack's roles (brand/05-typography; the scale is in
   bearmark.css): text 16/1.5; H1 32 and H2 24 in the display face at 600
   with -0.02em; H3 20 in the text face at 600. Dense parts of the cabinet
   keep sizes of their own below. */
body {
  margin: 0;
  background: var(--bm-bg);
  color: var(--bm-text);
  font: 400 var(--tb-type-body-size) / var(--tb-type-body-line)
    var(--bm-font-body);
  -webkit-font-smoothing: antialiased;
}
h1,
h2,
h3,
p {
  margin: 0;
}
h1,
h2 {
  font-family: var(--bm-font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}
h1 {
  font-size: var(--tb-type-h1-size);
  line-height: var(--tb-type-h1-line);
}
h2 {
  font-size: var(--tb-type-h2-size);
  line-height: var(--tb-type-h2-line);
}
h3 {
  font: 600 var(--tb-type-h3-size) / var(--tb-type-h3-line) var(--bm-font-body);
}
a {
  color: var(--bm-accent-ink);
  text-underline-offset: 2px;
}
code {
  font: 500 var(--tb-type-mono-size) / var(--tb-type-mono-line)
    var(--bm-font-mono);
  overflow-wrap: anywhere;
}
button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}
button {
  cursor: pointer;
}
:where(a, button, input, select, textarea, summary, [tabindex]):focus-visible {
  outline: none;
  box-shadow: var(--tb-ring);
}
/* What focus is moved to by the page (a heading, a region, a message) is not
   a control: no ring around it. */
:where([tabindex='-1']):focus-visible {
  box-shadow: none;
}
/* Controls with a shadow of their own keep the ring in front of it. */
.segmented button[aria-pressed='true']:focus-visible,
.views button[aria-pressed='true']:focus-visible,
.reaction-chip:focus-visible,
.react-button:focus-visible,
.jump-latest:focus-visible {
  box-shadow: var(--tb-ring);
}
.skip-link {
  position: absolute;
  left: 12px;
  top: -64px;
  z-index: 50;
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: var(--bm-radius-md);
  background: var(--bm-surface);
  color: var(--bm-text);
  font-weight: 600;
}
.skip-link:focus {
  top: 8px;
}
.eyebrow {
  margin-bottom: 8px;
  color: var(--bm-accent-ink);
  font: 700 11px/1.4 var(--bm-font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.muted {
  color: var(--bm-text-soft);
}
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0s !important;
    animation-duration: 0s !important;
    scroll-behavior: auto !important;
  }
}

/* ---- form controls --------------------------------------------------------- */
/* Field labels are the kit's mono overline (BmField, reference Field/Select):
   11px, 600, 0.09em, uppercase, soft ink. Option labels next to a checkbox or
   switch are body text (BmCheckbox, BmToggleRow) and reset below. */
label {
  color: var(--bm-text-soft);
  font: 600 11px/1.35 var(--bm-font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
label.check,
label.switch-hit {
  color: var(--bm-text);
  font: 400 14px/1.4 var(--bm-font-body);
  letter-spacing: 0;
  text-transform: none;
}
input,
select,
textarea {
  width: 100%;
  min-height: var(--tb-control-h);
  padding: 0 14px;
  font-size: 14px;
  border: 1px solid var(--bm-control-border);
  border-radius: var(--bm-radius-md);
  background: var(--bm-field);
  transition: border-color var(--bm-dur-fast) var(--bm-ease-standard);
}
textarea {
  padding: 10px 14px;
  line-height: 1.45;
  resize: vertical;
}
input::placeholder,
textarea::placeholder {
  color: var(--bm-text-soft);
  opacity: 0.85;
}
input:not(:disabled):hover,
select:not(:disabled):hover,
textarea:not(:disabled):hover {
  border-color: var(--bm-text-soft);
}
input:disabled,
select:disabled,
textarea:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
/* Focus tints the border as well as drawing the ring (focusRing border:true). */
input:focus-visible,
textarea:focus-visible,
.select-trigger:focus-visible {
  border-color: var(--bm-focus);
}
/* Invalid: border and ring go to the warn ink (BmField error). */
input[aria-invalid='true'],
textarea[aria-invalid='true'],
.select-trigger[aria-invalid='true'] {
  border-color: var(--bm-warn-ink);
}
input[aria-invalid='true']:focus-visible,
textarea[aria-invalid='true']:focus-visible,
.select-trigger[aria-invalid='true']:focus-visible {
  box-shadow:
    0 0 0 2px var(--bm-warn-ink),
    0 0 0 5px color-mix(in srgb, var(--bm-warn-ink) 34%, transparent);
}
/* Checkbox (BmCheckbox): 20px, 5px radius, 1.5px operable border; on, a brass
   fill inside a brass-deep ring with a dark tick. */
input[type='checkbox']:not(.switch) {
  appearance: none;
  display: inline-grid;
  place-content: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--bm-control-border);
  border-radius: var(--bm-radius-sm);
  background: transparent;
  cursor: pointer;
}
input[type='checkbox']:not(.switch)::after {
  content: '';
  width: 5px;
  height: 10px;
  border: solid var(--bm-on-accent);
  border-width: 0 2.5px 2.5px 0;
  rotate: 45deg;
  translate: 0 -1px;
  opacity: 0;
}
input[type='checkbox']:not(.switch):checked {
  border-color: var(--bm-accent-ink);
  background: var(--bm-accent);
}
input[type='checkbox']:not(.switch):checked::after {
  opacity: 1;
}
input[type='checkbox']:not(.switch):not(:disabled):hover {
  border-color: var(--bm-text-soft);
}
input[type='checkbox']:not(.switch):checked:not(:disabled):hover {
  border-color: var(--bm-accent-ink);
}
input[type='checkbox']:focus-visible {
  border-color: var(--bm-focus);
}
input[readonly] {
  background: var(--bm-raised);
}
input[type='search']::-webkit-search-cancel-button {
  cursor: pointer;
}
.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}
.fields {
  display: grid;
  gap: 12px;
}
.fields > label {
  margin-bottom: -5px;
}
.field-hint,
.grant-form .field p {
  font-size: 13px;
  color: var(--bm-text-soft);
}
.search-field {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}
.search-field svg {
  position: absolute;
  left: 12px;
  top: 50%;
  translate: 0 -50%;
  color: var(--bm-text-soft);
  pointer-events: none;
}
.search-field input {
  padding-left: 38px;
}
/* The cross (search-clear.js): inside the field's right end, only while it
   has text; the browser's own cross gives way to it. A finger gets the
   field's full height. */
.search-field:has(> .search-clear) input {
  padding-right: 40px;
}
.search-field input[type='search']::-webkit-search-cancel-button {
  display: none;
  appearance: none;
}
.search-clear {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  display: grid;
  place-items: center;
  width: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--bm-radius-md);
  background: transparent;
  color: var(--bm-text-soft);
  cursor: pointer;
}
.search-field .search-clear svg {
  position: static;
  translate: none;
}
.search-clear:hover {
  color: var(--bm-text);
}
.search-clear:focus-visible {
  outline: 2px solid var(--bm-focus);
  outline-offset: -4px;
}
.search-field:has(> input:placeholder-shown) > .search-clear {
  display: none;
}
@media (pointer: coarse) {
  .search-field:has(> .search-clear) input {
    padding-right: 44px;
  }
  .search-clear {
    width: 44px;
  }
}

/* ---- select (BmSelect) ---------------------------------------------------------
   select.js puts a trigger and a listbox beside the hidden native <select>.
   Trigger = the field: same height, 8px radius, operable border, 14px inset,
   12px chevron (reference Select: M4 6l4 4 4-4, stroke 2). The list is the
   kit's menu surface: 8px radius, hairline edge, shadow-md, 5px inset, 38px
   rows; the chosen row is a 14% brass wash with a brass-deep tick. */
.select {
  position: relative;
  min-width: 0;
}
.select-native {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 1px;
  height: 1px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  pointer-events: none;
}
.select-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: var(--tb-control-h);
  padding: 0 12px 0 14px;
  border: 1px solid var(--bm-control-border);
  border-radius: var(--bm-radius-md);
  background: var(--bm-field);
  color: var(--bm-text);
  font: 400 14px/1.3 var(--bm-font-body);
  text-align: left;
  transition:
    border-color var(--bm-dur-fast) var(--bm-ease-standard),
    box-shadow var(--bm-dur-fast) var(--bm-ease-standard);
}
.select-trigger:not(:disabled):hover {
  border-color: var(--bm-text-soft);
}
.select[data-open] .select-trigger {
  border-color: var(--bm-focus);
}
.select[data-open] .select-trigger:not(:focus-visible) {
  box-shadow: var(--bm-shadow-xs);
}
.select-trigger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.select-value {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.select-chevron {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  color: var(--bm-text-soft);
  transition: rotate var(--bm-dur-fast) var(--bm-ease-standard);
}
.select[data-open] .select-chevron {
  rotate: 180deg;
}
.select-pop {
  position: fixed;
  z-index: var(--bm-z-dropdown);
  top: var(--select-top, 0);
  left: var(--select-left, 0);
  display: flex;
  flex-direction: column;
  width: var(--select-width, 240px);
  padding: 5px 0;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-md);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-md);
  opacity: 0;
  translate: 0 -4px;
  transition:
    opacity var(--bm-dur-fast) var(--bm-ease-out),
    translate var(--bm-dur-fast) var(--bm-ease-out);
}
.select-pop[data-place='above'] {
  translate: 0 4px;
}
.select[data-shown] .select-pop {
  opacity: 1;
  translate: 0 0;
}
.select-title {
  display: none;
}
.select-list {
  max-height: calc(var(--select-max, 296px) - 12px);
  margin: 0;
  padding: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}
.select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  padding: 8px 12px 8px 14px;
  color: var(--bm-text);
  font: 400 14px/1.35 var(--bm-font-body);
  cursor: pointer;
  user-select: none;
}
.select-option.active {
  background: color-mix(in srgb, var(--bm-text) 8%, transparent);
  box-shadow: inset 2px 0 0 var(--bm-focus);
}
.select-option[aria-selected='true'] {
  background: color-mix(in srgb, var(--bm-accent) 14%, transparent);
  font-weight: 600;
}
.select-option[aria-selected='true'].active {
  background: color-mix(in srgb, var(--bm-accent) 22%, transparent);
}
.select-option[aria-disabled='true'] {
  opacity: 0.4;
  cursor: not-allowed;
}
.select-option-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.select-option-hint {
  color: var(--bm-text-soft);
  font-size: 13px;
  font-weight: 400;
}
.select-check {
  flex: 0 0 auto;
  width: 13px;
  height: 13px;
  fill: none;
  stroke: var(--bm-accent-ink);
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
  visibility: hidden;
}
.select-option[aria-selected='true'] .select-check {
  visibility: visible;
}
/* Phone: the list is a bottom sheet (BmSheet): scrim, 18px top corners, grab
   handle, the field's label as its title, 48px rows. */
.select-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--bm-z-dropdown);
  background: var(--bm-scrim);
  opacity: 0;
  transition: opacity var(--bm-dur-moderate) var(--bm-ease-out);
}
.select[data-shown] .select-scrim {
  opacity: 1;
}
.select[data-mode='sheet'] .select-pop {
  top: auto;
  right: 0;
  bottom: 0;
  left: 0;
  width: auto;
  max-height: 80dvh;
  padding: 0 0 calc(8px + env(safe-area-inset-bottom));
  border-width: 1px 0 0;
  border-radius: var(--bm-radius-xl) var(--bm-radius-xl) 0 0;
  box-shadow: var(--bm-shadow-lg);
  translate: 0 32px;
  transition:
    opacity var(--bm-dur-moderate) var(--bm-ease-out),
    translate var(--bm-dur-moderate) var(--bm-ease-out);
}
.select[data-mode='sheet'][data-shown] .select-pop {
  translate: 0 0;
}
.select[data-mode='sheet'] .select-pop::before {
  content: '';
  flex: 0 0 auto;
  align-self: center;
  width: 40px;
  height: 4px;
  margin: 10px 0 6px;
  border-radius: var(--bm-radius-pill);
  background: var(--bm-border-strong);
}
.select[data-mode='sheet'] .select-title {
  display: block;
  padding: 2px 18px 10px;
  color: var(--bm-text);
  font: 700 16px/1.3 var(--bm-font-display);
}
.select[data-mode='sheet'] .select-list {
  flex: 1 1 auto;
  min-height: 0;
  max-height: none;
}
.select[data-mode='sheet'] .select-option {
  min-height: 48px;
  padding: 10px 18px;
  font-size: 16px;
}

/* ---- buttons --------------------------------------------------------------- */
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: var(--tb-control-h);
  padding: 0 18px;
  border: 1px solid var(--bm-control-border);
  border-radius: var(--bm-radius-md);
  background: transparent;
  font: 700 13px/1.2 var(--bm-font-mono);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  text-decoration: none;
  transition:
    background-color var(--bm-dur-fast) var(--bm-ease-standard),
    border-color var(--bm-dur-fast) var(--bm-ease-standard),
    color var(--bm-dur-fast) var(--bm-ease-standard);
}
.button svg {
  flex: 0 0 auto;
}
.button:not(:disabled):active {
  translate: 0 0.5px;
}
.button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.quiet {
  background: transparent;
}
.quiet:not(:disabled):hover {
  background: color-mix(in srgb, var(--bm-text) 9%, transparent);
}
.primary {
  background: var(--bm-accent);
  color: var(--bm-on-accent);
  border-color: var(--bm-brass-deep);
  border-bottom-width: 3px;
}
.primary:not(:disabled):hover {
  background: var(--bm-brass-hi);
}
.danger {
  color: var(--bm-warn-ink);
  border-color: color-mix(in srgb, var(--bm-warn-ink) 45%, transparent);
}
.danger:not(:disabled):hover {
  background: color-mix(in srgb, var(--bm-warn) 12%, transparent);
}
.button.small {
  min-height: var(--tb-control-sm);
  padding: 0 14px;
  font-size: 11px;
}
.icon-button {
  width: var(--tb-control-h);
  padding: 0;
}
.link-button {
  justify-self: start;
  padding: 0 4px;
  border-color: transparent;
  background: transparent;
  color: var(--bm-accent-ink);
  font: 600 14px/1.3 var(--bm-font-body);
  letter-spacing: 0;
  text-transform: none;
}
.link-button:not(:disabled):hover {
  text-decoration: underline;
}
.wide {
  width: 100%;
}
.more {
  display: flex;
  margin: 8px auto;
}
/* Earlier messages from the phone: one muted line, where the request stands
   and what can be asked next. */
.history-request {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: baseline;
  gap: 0 8px;
  margin: 8px auto 12px;
  max-width: 460px;
  color: var(--bm-text-soft);
  font-size: 13px;
  line-height: 1.45;
  text-align: center;
}
.history-request[hidden] {
  display: none;
}
.history-note {
  margin: 0;
}
.history-note[data-tone='warn'] {
  color: var(--bm-warn-ink);
}
.history-note:empty,
.history-request .link-button[hidden] {
  display: none;
}
.history-request .link-button {
  min-height: 32px;
  padding: 0 2px;
  font-size: 13px;
}
.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* ---- hints ------------------------------------------------------------------- */
/* A title or a field label with its «?» beside it (docs/HINTS.md): the words
   that explain it are hidden in the page and shown by the «?». */
.title-help,
.label-help {
  display: flex;
  align-items: center;
  min-width: 0;
}
.label-help > label {
  min-width: 0;
}

/* ---- status, badges, tags ---------------------------------------------------- */
/* A status line says how something went, in its tone: `warn` (did not work;
   the default), `good` (done), `soft` (under way, or by the way). */
.status-message {
  color: var(--bm-warn-ink);
  font-size: 14px;
  font-weight: 500;
  overflow-wrap: anywhere;
}
.status-message[data-tone='good'] {
  color: var(--bm-good-ink);
}
.status-message[data-tone='soft'] {
  color: var(--bm-text-soft);
  font-weight: 400;
}
.status-message:empty {
  display: none;
}
.note {
  padding: 10px 12px;
  border-radius: var(--bm-radius-md);
  background: var(--bm-raised);
  color: var(--bm-text-soft);
  font-size: 14px;
}
/* Status badge (BmBadge soft): mono uppercase pill, the tone's ink on a 15%
   wash of itself with a 32% edge. */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border: 1px solid color-mix(in srgb, currentColor 32%, transparent);
  border-radius: var(--bm-radius-pill);
  background: color-mix(in srgb, currentColor 15%, transparent);
  color: var(--bm-pending-ink);
  font: 700 11px/1.4 var(--bm-font-mono);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  white-space: nowrap;
}
.count {
  display: inline-flex;
  align-items: center;
  border-radius: var(--bm-radius-pill);
  background: var(--bm-raised);
  white-space: nowrap;
  padding: 0 7px;
  min-width: 22px;
  justify-content: center;
  color: var(--bm-text-soft);
  font: 700 11px/1.7 var(--bm-font-mono);
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge:empty {
  display: none;
}
.badge[data-state='connected'] {
  color: var(--bm-good-ink);
}
.badge[data-state='offline'] {
  color: var(--bm-caution-ink);
}
/* Number identity (BmBadge neutral, mono 11/700): a neutral pill with a dot
   from the identity palette, never a status hue. A long name ends in an
   ellipsis inside its column and says itself in full in its title. */
.tag {
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  padding: 0 9px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-pill);
  background: var(--bm-surface);
  color: var(--bm-text);
  font: 700 11px/1.75 var(--bm-font-mono);
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: top;
}
.tag:empty {
  display: none;
}
.tag[data-hue]::before,
.id-dot {
  content: '';
  display: inline-block;
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  margin-right: 6px;
  border-radius: 50%;
  vertical-align: 1px;
}
.id-dot {
  margin-right: 0;
}
[data-hue='2'] {
  --tb-id: var(--tb-id-2);
}
[data-hue='3'] {
  --tb-id: var(--tb-id-3);
}
[data-hue='4'] {
  --tb-id: var(--tb-id-4);
}
[data-hue='5'] {
  --tb-id: var(--tb-id-5);
}
.tag[data-hue]::before,
.id-dot,
.quick-pick[data-hue]::before {
  background: var(--tb-id, var(--tb-id-1));
}
/* A number that is not on the line: the same colour as a ring. */
.id-dot[data-state='off'] {
  background: transparent;
  box-shadow: inset 0 0 0 1.5px var(--tb-id, var(--tb-id-1));
}
.tag.plain-tag {
  color: var(--bm-text-soft);
  background: transparent;
}
.alerts {
  display: grid;
  gap: 8px;
}
.alerts:empty {
  display: none;
}
/* Inline banner (BmAlert): tone icon in a 20px disc, 10% wash, 34% edge. */
.alert {
  position: relative;
  display: block;
  padding: 13px 14px 13px 44px;
  border: 1px solid color-mix(in srgb, var(--bm-caution-ink) 34%, transparent);
  border-radius: var(--bm-radius-md);
  background: color-mix(in srgb, var(--bm-caution) 10%, var(--bm-surface));
  color: var(--bm-text);
  font-size: 14px;
}
.alert::before {
  content: '!';
  position: absolute;
  left: 13px;
  top: 14px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bm-caution);
  color: var(--bm-iron);
  font: 700 12px/1 var(--bm-font-mono);
}
.alert strong {
  color: var(--bm-caution-ink);
}
/* The queue's one line about numbers that cannot work now: the icon, the
   names, a link to «Аккаунты»; the details are on the number's card. */
.alert.slim {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 10px;
  padding: 7px 12px 7px 36px;
  font-size: 14px;
  line-height: 1.45;
}
.alert.slim::before {
  left: 10px;
  top: 8px;
  width: 18px;
  height: 18px;
  font-size: 11px;
}
.alert.slim .link-button {
  min-height: 0;
  padding: 0;
  font-size: 14px;
}
.empty-list {
  padding: 20px 16px;
  color: var(--bm-text-soft);
  text-align: center;
}
.empty-list .button {
  margin-top: 12px;
}
/* Loading (BmSkeleton): soft blocks in the shape of what comes, so nothing
   jumps when it arrives. */
.skeleton {
  display: block;
  min-height: 14px;
  border-radius: var(--bm-radius-md);
  background: var(--bm-track);
  animation: skeleton 1.1s var(--bm-ease-standard) infinite alternate;
}
.skeleton.card-shape {
  min-height: 132px;
  border-radius: var(--bm-radius-lg);
}
.skeleton.tile-shape {
  min-height: 96px;
  border-radius: var(--bm-radius-lg);
}
.skeleton.line {
  width: min(100%, 420px);
}
.chat-skeleton {
  height: 64px;
  margin: 4px 4px 8px;
  border-radius: var(--bm-radius-lg);
}
/* A chat being read: blocks where its messages will be, on their sides. */
.bubble-skeleton {
  align-self: flex-start;
  width: min(52%, 320px);
  height: 44px;
  margin-top: 8px;
  border-radius: var(--bm-radius-lg);
}
.bubble-skeleton.out {
  align-self: flex-end;
}
.bubble-skeleton.wide {
  width: min(68%, 440px);
  height: 64px;
}
@keyframes skeleton {
  to {
    opacity: 0.45;
  }
}

/* ---- top bar ---------------------------------------------------------------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--tb-chrome);
  color: var(--tb-on-chrome);
  border-bottom: 1px solid var(--bm-brass-deep);
}
.topbar-inner {
  width: min(1480px, calc(100% - 2 * var(--tb-gutter)));
  height: var(--tb-topbar-h);
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.brand {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
}
/* The pack's reverse lockup in its 473 x 100 frame, which carries the clear
   space above and below the badge. 36 px high is 170 px wide; the pack asks
   for 144 px at least and names 160 to 240 px for a header. */
.brand .brand-logo {
  display: block;
  width: auto;
  height: 36px;
}
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}
.pilot-label {
  padding: 3px 10px;
  border: 1px solid color-mix(in srgb, var(--bm-brass-hi) 55%, transparent);
  border-radius: var(--bm-radius-pill);
  color: var(--tb-chrome-accent);
  font: 600 11px/1.5 var(--bm-font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}
.account-email {
  max-width: 28ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  color: var(--tb-on-chrome-soft);
}
.topbar .button {
  min-height: 36px;
  border-color: color-mix(in srgb, var(--bm-ivory) 35%, transparent);
  background: transparent;
  color: var(--tb-on-chrome);
}
.topbar .button:not(:disabled):hover {
  background: var(--tb-chrome-2);
}
.topbar :focus-visible {
  box-shadow: var(--tb-ring-chrome);
}

.page {
  width: min(1480px, calc(100% - 2 * var(--tb-gutter)));
  margin: 0 auto;
}

/* ---- welcome, invite, consent ---------------------------------------------- */
.welcome {
  min-height: calc(100dvh - var(--tb-topbar-h));
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(320px, 440px);
  gap: clamp(32px, 7vw, 112px);
  /* Top-aligned: a status line under the form grows it downwards only. */
  align-items: start;
  padding: clamp(40px, 11vh, 120px) clamp(0px, 4vw, 64px) 56px;
}
/* The page's one large heading: the display role. */
.welcome h1 {
  margin-bottom: 20px;
  font-size: var(--tb-type-display-size);
  font-weight: 700;
  line-height: var(--tb-type-display-line);
  letter-spacing: -0.025em;
}
.intro {
  max-width: 32ch;
  color: var(--bm-text-soft);
  font-size: var(--tb-type-h3-size);
  line-height: 1.45;
}
.welcome-features {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;
  margin: 40px 0 0;
  padding: 20px 0 0;
  border-top: 1px solid var(--bm-border-strong);
  list-style: none;
  max-width: 720px;
}
.welcome-features li {
  display: grid;
  gap: 4px;
  align-content: start;
  font-size: 14px;
  color: var(--bm-text-soft);
}
.welcome-features strong {
  color: var(--bm-text);
  font-size: 15px;
}
/* What ThreadBell is and its privacy policy, readable before signing in. */
.welcome-links {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 20px;
  margin-top: 28px;
  font-size: 14px;
}
.welcome-links a {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
}
.feature-num {
  color: var(--bm-accent-ink);
  font: 700 11px var(--bm-font-mono);
  letter-spacing: 0.08em;
}
.login-card {
  display: grid;
  gap: 14px;
  padding: clamp(22px, 3.4vw, 36px);
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-xl);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-md);
}
.login-card h2 {
  margin-bottom: 4px;
}
/* A screen that is one sign-in card carries the signature itself: the pack's
   vertical lockup, primary on the light card and reverse on the dark one
   (the picture follows the same setting as the theme). Its canvas holds the
   margins around the badge and the name. The top bar would say the name a
   second time, so it steps aside on those screens. */
.card-signature {
  display: block;
  justify-self: center;
}
.card-signature img {
  display: block;
  width: 192px;
  height: auto;
}
/* The lockup is a centred composition: the card's heading follows it. */
.login-card:has(.card-signature) > :is(.eyebrow, h1, h2, .muted) {
  text-align: center;
}
body:has(#invite-view:not([hidden])) .topbar,
body:has(#admin-login:not([hidden])) .topbar {
  display: none;
}
.login-card .eyebrow {
  margin: 0;
}
.login-card > .primary {
  margin-top: 6px;
}
/* «Нет кабинета?» and its link, one line under the form. */
.login-alt {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 6px;
  color: var(--bm-text-soft);
  font-size: 14px;
}
.login-alt .link-button {
  padding: 0 2px;
}
#invite-view {
  max-width: 460px;
}
.consent {
  max-width: 560px;
  margin: 0 auto;
  padding: 56px 0;
}
.consent-client {
  font-size: 16px;
  font-weight: 600;
}
/* Continue a connection or make a new one (BmRadioGroup): one choice per
   row, the note under its label, the list of connections between them. */
.checks.consent-choice {
  display: grid;
  gap: 2px;
  padding: 6px 14px 10px;
}
.consent-choice .consent-option {
  align-items: flex-start;
  padding: 10px 0;
}
.consent-option > span {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.consent-option-note {
  color: var(--bm-text-soft);
  font-size: 13px;
  line-height: 1.4;
}
.consent-grant {
  margin: 0 0 6px 31px;
  min-width: 0;
}
.consent-choice input[type='radio'] {
  appearance: none;
  display: inline-grid;
  place-content: center;
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 1.5px solid var(--bm-control-border);
  border-radius: 999px;
  background: transparent;
  cursor: pointer;
  /* On the first line of the label, not the middle of its note. */
  translate: 0 1px;
}
.consent-choice input[type='radio']::after {
  content: '';
  width: 9px;
  height: 9px;
  border-radius: 999px;
  background: var(--bm-accent-ink);
  opacity: 0;
}
.consent-choice input[type='radio']:checked {
  border-color: var(--bm-accent-ink);
}
.consent-choice input[type='radio']:checked::after {
  opacity: 1;
}
.consent-choice input[type='radio']:not(:checked):hover {
  border-color: var(--bm-text-soft);
}
.consent-choice input[type='radio']:focus-visible {
  border-color: var(--bm-focus);
}

/* ---- workspace frame: rail + main ------------------------------------------ */
.workspace {
  display: grid;
  grid-template-columns: var(--tb-rail) minmax(0, 1fr);
  gap: var(--tb-gap);
  padding: 20px 0 24px;
  align-items: start;
}
.workspace-main {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
  min-height: calc(100dvh - var(--tb-topbar-h) - 44px);
}
.workspace[data-view='queue'] .workspace-main {
  height: calc(100dvh - var(--tb-topbar-h) - 44px);
  min-height: 600px;
}

/* Navigation rail. */
.views {
  position: sticky;
  top: calc(var(--tb-topbar-h) + 20px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.views button {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border: 1px solid transparent;
  border-radius: var(--bm-radius-md);
  background: transparent;
  color: var(--bm-text-soft);
  font-weight: 600;
  text-align: left;
  transition:
    background-color var(--bm-dur-fast) var(--bm-ease-standard),
    color var(--bm-dur-fast) var(--bm-ease-standard);
}
.views svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
}
.views .nav-label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.views button:hover {
  background: color-mix(in srgb, var(--bm-text) 6%, transparent);
  color: var(--bm-text);
}
.views button[aria-pressed='true'] {
  background: var(--bm-surface);
  border-color: var(--bm-border-strong);
  color: var(--bm-text);
  box-shadow: var(--bm-shadow-xs);
}
.views button[aria-pressed='true']::before {
  content: '';
  position: absolute;
  left: -1px;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 0 3px 3px 0;
  background: var(--bm-accent-ink);
}
.views button[aria-pressed='true'] svg {
  color: var(--bm-accent-ink);
}
.views .count {
  background: var(--bm-accent);
  color: var(--bm-on-accent);
}

/* Section pages. */
.panel {
  display: grid;
  align-content: start;
  gap: 16px;
  min-width: 0;
}
.panel.narrow {
  max-width: 760px;
}
.view-head {
  display: grid;
  gap: 6px;
}
.view-head .muted {
  max-width: 72ch;
}
.list-title {
  margin-top: 12px;
}
.crumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
  margin-bottom: -6px;
  color: var(--bm-text-soft);
  font-size: 14px;
}
.crumb-back {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 36px;
  padding: 0 10px 0 4px;
  border: 0;
  border-radius: var(--bm-radius-md);
  background: transparent;
  color: var(--bm-accent-ink);
  font-weight: 600;
}
.crumb-back:hover {
  background: color-mix(in srgb, var(--bm-text) 7%, transparent);
}
.crumb-sep {
  color: var(--bm-text-faint);
}
#access-crumb {
  color: var(--bm-text);
  font-weight: 600;
}

/* Cards. */
.cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 340px), 1fr));
  align-items: start;
}
.cards > .empty-list {
  grid-column: 1 / -1;
  padding: 18px 16px;
  border: 1px dashed var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
  text-align: left;
}
.card,
.section-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
  align-content: start;
  min-width: 0;
  padding: 16px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-xs);
}
.section-card {
  gap: 14px;
  padding: 20px;
}
.section-card h3 {
  margin: 0;
}
.card-head {
  line-height: 1.4;
}
.card-head strong {
  font-size: 15px;
}
.card-head .muted {
  font-size: 13px;
}
.card-meta {
  font-size: 14px;
  line-height: 1.45;
}
.card-where {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 6px;
  min-width: 0;
  font-size: 14px;
}
/* The recipient's name opens the chat. */
.card-where .link-button {
  min-height: 32px;
  max-width: 100%;
  overflow: hidden;
  padding: 0 2px;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* A draft's heading: the agent on the left, the time on the right. */
.draft-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 12px;
  min-width: 0;
}
.draft-head strong {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draft-head time {
  flex: 0 0 auto;
  color: var(--bm-text-soft);
  font-size: 13px;
  white-space: nowrap;
}
.card > label {
  margin-top: 4px;
}
.draft-card {
  border-color: color-mix(in srgb, var(--bm-brass-deep) 55%, transparent);
  border-left: 4px solid var(--bm-accent);
}

/* ---- queue: list + open thread side by side --------------------------------- */
.inbox-grid {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(300px, 380px) minmax(0, 1fr);
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-xl);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-sm);
}
.chat-panel,
.thread-panel {
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}
.chat-panel {
  border-right: 1px solid var(--bm-border);
}
/* The queue's head is kept short: the title carries the «ждут / все»
   switch, the search carries «Написать письмо» as an icon beside it. */
.panel-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 0;
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--bm-border);
  container: queue-head / inline-size;
}
.panel-heading > * {
  grid-column: 1 / -1;
}
.panel-heading:has(> .compose:not([hidden], [open])) > .search-field {
  grid-column: 1;
}
.panel-heading > .compose:not([open]) {
  grid-column: 2;
  margin-left: 8px;
}
.heading-line {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.heading-line .segmented {
  flex: 0 0 auto;
  grid-template-columns: auto auto;
  margin-left: auto;
}
.heading-line .segmented button {
  padding: 0 10px;
}
.seg-long {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
/* On a narrow screen the search waits behind its icon in the title's line;
   opened, it takes its usual row. «Написать письмо» then sits by the title. */
.queue-search-toggle {
  display: none;
}
@media (max-width: 620px), (max-height: 500px) and (pointer: coarse) {
  .queue-search-toggle {
    display: inline-grid;
    flex: 0 0 auto;
    margin-left: auto;
  }
  .queue-search-toggle[aria-expanded='true'] {
    background: color-mix(in srgb, var(--bm-text) 8%, transparent);
  }
  .heading-line .queue-search-toggle + .segmented {
    margin-left: 0;
  }
  .panel-heading:not([data-search='open']) > .search-field,
  .panel-heading:not([data-search='open']) > #queue-scope {
    display: none;
  }
  .panel-heading:not([data-search='open']) > .heading-line {
    grid-column: 1;
    grid-row: 1;
  }
  .panel-heading:not([data-search='open']) > .compose:not([open], [hidden]) {
    grid-column: 2;
    grid-row: 1;
  }
}
@container queue-head (min-width: 420px) {
  .seg-long {
    position: static;
    width: auto;
    height: auto;
    overflow: visible;
    clip: auto;
  }
  .seg-short {
    display: none;
  }
}
/* The queue's filter (docs/QUEUE.md): a row of channels, then the accounts
   of the chosen one as chips that wrap (a long name ends in an ellipsis), or
   one select when there are too many for chips. */
.account-filter {
  display: grid;
  gap: 8px;
}
.account-filter:empty {
  display: none;
}
/* Channels: tabs with an underline, one line; a name gives way to its
   glyph and count when the column is narrow. */
.channel-filter {
  display: grid;
  grid-auto-columns: minmax(0, max-content);
  grid-auto-flow: column;
  gap: 2px;
  border-bottom: 1px solid var(--bm-border);
}
.channel-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: var(--tb-control-sm);
  padding: 0 6px;
  border: 0;
  border-radius: var(--bm-radius-sm) var(--bm-radius-sm) 0 0;
  background: transparent;
  color: var(--bm-text-soft);
  font: 600 14px/1.2 var(--bm-font-body);
  white-space: nowrap;
}
.channel-tab:hover {
  color: var(--bm-text);
  background: color-mix(in srgb, var(--bm-text) 5%, transparent);
}
.channel-tab[aria-pressed='true'] {
  color: var(--bm-text);
  box-shadow: inset 0 -2px 0 var(--bm-accent);
}
.channel-tab .chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.channel-tab .count {
  min-width: 18px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 1.6;
}
.channel-tab .count[hidden] {
  display: none;
}
.account-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-width: 0;
}
.account-chips > .account-panel {
  flex: 1 1 100%;
}
/* Many accounts: a chip that says the choice and opens the panel below. */
.account-toggle svg {
  flex: 0 0 auto;
  transition: transform var(--bm-dur-fast) var(--bm-ease-standard);
}
.account-toggle[aria-expanded='true'] svg {
  transform: rotate(180deg);
}
.account-toggle .count {
  min-width: 18px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 1.6;
}
.account-toggle .count[hidden] {
  display: none;
}
.account-filter .account-toggle {
  max-width: 100%;
}
.account-panel {
  display: grid;
  gap: 4px;
  max-height: min(50vh, 420px);
  padding: 4px 6px 8px;
  overflow-y: auto;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-md);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-sm);
  overscroll-behavior: contain;
}
.account-panel[hidden] {
  display: none;
}
.account-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
}
.account-set {
  display: grid;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}
.account-set legend {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 6px 2px;
  color: var(--bm-text-soft);
  font: 600 11px/1.6 var(--bm-font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.account-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 40px;
  padding: 0 6px;
  border-radius: var(--bm-radius-sm);
  font: 500 14px/1.3 var(--bm-font-body);
  cursor: pointer;
}
.account-option:hover {
  background: color-mix(in srgb, var(--bm-text) 6%, transparent);
}
.account-option input {
  flex: 0 0 auto;
  margin: 0;
  accent-color: var(--bm-accent);
}
.account-option .chip-name {
  flex: 1 1 auto;
}
.account-option .count {
  min-width: 18px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 1.6;
}
.account-option .count[hidden] {
  display: none;
}
/* A waiting count on a filter chip: small, and inverse with the chip. */
.chip .count {
  min-width: 18px;
  padding: 0 5px;
  font-size: 11px;
  line-height: 1.6;
}
.chip .count[hidden] {
  display: none;
}
.chip[aria-pressed='true'] .count {
  background: color-mix(in srgb, var(--bm-on-inverse) 18%, var(--bm-inverse));
  color: var(--bm-on-inverse);
}
/* Channels: each has a glyph (web/channels.js) and a tone. The glyph's shape
   alone tells the channel, and every tone is the same quiet ink: a status
   colour (good, info, pending) would read as a state, and colour in the
   queue belongs to the account (its identity hue). A channel keeps its own
   variable so a tone can be given without touching the rules below. */
:root {
  --tb-channel-whatsapp: var(--bm-text-soft);
  --tb-channel-mail: var(--bm-text-soft);
  --tb-channel-telegram: var(--bm-text-soft);
  --tb-channel-chat: var(--bm-text-soft);
}
[data-channel] {
  --tb-channel: var(--tb-channel-chat);
}
[data-channel='whatsapp'] {
  --tb-channel: var(--tb-channel-whatsapp);
}
[data-channel='mail'] {
  --tb-channel: var(--tb-channel-mail);
}
[data-channel='telegram'] {
  --tb-channel: var(--tb-channel-telegram);
}
.channel-glyph {
  flex: 0 0 auto;
  color: var(--tb-channel, currentColor);
}
.chip[aria-pressed='true'] .channel-glyph {
  color: currentColor;
}
/* On the avatar's corner in the queue: a disc cut out of the row. */
.chat-row .avatar {
  position: relative;
}
.channel-mark {
  position: absolute;
  right: -4px;
  bottom: -4px;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bm-surface);
  box-shadow: 0 0 0 1.5px var(--bm-surface);
}
.avatar .channel-mark svg {
  width: 13px;
  height: 13px;
}
.chat-row:hover .channel-mark {
  background: color-mix(in srgb, var(--bm-text) 5%, var(--bm-surface));
}
.chat-row[aria-current='true'] .channel-mark {
  background: color-mix(in srgb, var(--bm-accent) 18%, var(--bm-surface));
  box-shadow: 0 0 0 1.5px
    color-mix(in srgb, var(--bm-accent) 18%, var(--bm-surface));
}
/* The channel in the chat's header, before the account's tag. */
.thread-channel {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--bm-text-soft);
}
/* A letter's subject under the sender's name. */
.thread-subject {
  margin: 0;
  overflow: hidden;
  color: var(--bm-text-soft);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-subject[hidden] {
  display: none;
}
/* «Аккаунты» with accounts of several channels: a heading per channel
   across the grid. */
.numbers-channel {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 0;
  font-size: var(--tb-type-body-size);
}
.numbers-channel:first-child {
  margin-top: 0;
}
.number-phone {
  display: flex;
  align-items: center;
  gap: 6px;
}
.chip,
.chips button {
  flex: 0 1 auto;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  min-width: 0;
  min-height: var(--tb-control-sm);
  padding: 0 12px;
  border: 1px solid var(--bm-control-border);
  border-radius: var(--bm-radius-pill);
  background: transparent;
  font: 700 11px/1.2 var(--bm-font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.account-filter .chip {
  max-width: 200px;
}
.chip-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip:hover,
.chips button:hover {
  background: color-mix(in srgb, var(--bm-text) 9%, transparent);
}
.chip[aria-pressed='true'],
.chips button[aria-pressed='true'] {
  border-color: var(--bm-inverse);
  background: var(--bm-inverse);
  color: var(--bm-on-inverse);
}
.chips button .count {
  background: var(--bm-raised);
}
.chips button[aria-pressed='true'] .count {
  background: color-mix(in srgb, var(--bm-on-inverse) 18%, var(--bm-inverse));
  color: var(--bm-on-inverse);
}
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
/* Segmented control (BmSegmented): 8px track with a 3px inset, 5px cells
   (8 - 3, concentric), the chosen cell lifts on the surface; mono labels. */
.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 3px;
  padding: 3px;
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius-md);
  background: var(--bm-bg);
}
.segmented button {
  min-height: calc(var(--tb-control-sm) - 8px);
  padding: 0 14px;
  border: 0;
  border-radius: var(--bm-radius-sm);
  background: transparent;
  color: var(--bm-text-soft);
  font: 700 11px/1.2 var(--bm-font-mono);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.segmented button:hover {
  color: var(--bm-text);
}
.segmented button[aria-pressed='true'] {
  background: var(--bm-surface);
  color: var(--bm-text);
  box-shadow: var(--bm-shadow-xs);
}
.chat-list {
  flex: 1;
  overflow-y: auto;
  padding: 6px;
  overscroll-behavior: contain;
}
.chat-row {
  width: 100%;
  display: flex;
  align-items: start;
  gap: 12px;
  margin: 0 0 2px;
  padding: 10px;
  border: 0;
  border-radius: var(--bm-radius-lg);
  background: transparent;
  text-align: left;
  transition: background-color var(--bm-dur-fast) var(--bm-ease-standard);
}
.chat-row:hover {
  background: color-mix(in srgb, var(--bm-text) 5%, transparent);
}
.chat-row[aria-current='true'] {
  background: color-mix(in srgb, var(--bm-accent) 18%, var(--bm-surface));
}
.chat-row-body {
  display: grid;
  /* An auto column grows to the longest name and pushes the page sideways. */
  grid-template-columns: minmax(0, 1fr);
  gap: 2px;
  min-width: 0;
  flex: 1;
}
.chat-row-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}
.chat-row-head strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-weight: 600;
  font-size: 15px;
  line-height: 1.35;
}
/* Time, and a pencil when an agent's draft waits in the chat. */
.chat-row-when {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 6px;
}
.chat-row-when time {
  color: var(--bm-text-soft);
  font: 600 12px var(--bm-font-mono);
  white-space: nowrap;
}
.chat-row-when time.waiting {
  color: var(--bm-warn-ink);
}
.chat-row-draft {
  display: inline-grid;
  color: var(--bm-accent-ink);
}
.preview {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--bm-text-soft);
  font-size: 14px;
}
.chat-row-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 8px;
  min-width: 0;
  margin-top: 4px;
}
.chat-row-meta:empty {
  display: none;
}
.chat-row-note {
  color: var(--bm-text-soft);
  font-size: 13px;
}
/* A letter's subject: between who wrote and what was written. */
.chat-row-subject {
  overflow: hidden;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.queue-scope {
  margin: -2px 0 0;
  color: var(--bm-text-soft);
  font-size: 13px;
}
/* «Написать письмо»: a letter that answers nothing, where an account can. */
.compose > summary {
  display: inline-flex;
  gap: 8px;
  list-style: none;
}
/* Closed, it is a square beside the search; the word shows once it is open. */
.compose:not([open]) > summary {
  width: var(--tb-control-h);
  min-height: var(--tb-control-h);
  padding: 0;
  justify-content: center;
}
.compose:not([open]) .compose-word {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
}
.compose > summary::-webkit-details-marker {
  display: none;
}
.compose[open] > summary {
  margin-bottom: 10px;
}
.compose-form {
  display: grid;
  gap: 10px;
}
.avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: color-mix(in srgb, var(--bm-accent) 22%, var(--bm-surface));
  color: var(--bm-accent-ink);
  font: 700 16px var(--bm-font-display);
}
/* A group shows people in place of initials. */
.avatar svg {
  width: 22px;
  height: 22px;
}
/* The conversation's own picture, over its initials (src/photos.ts). */
.avatar {
  position: relative;
}
.avatar-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}
.avatar.has-photo {
  color: transparent;
}

/* Empty thread pane. */
.empty {
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 32px;
  text-align: center;
  background: var(--tb-chat-bg);
}
.empty .muted {
  max-width: 40ch;
}
.empty-mark {
  margin-bottom: 6px;
  color: var(--bm-accent-ink);
  opacity: 0.8;
}

/* Open thread. */
.thread-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--bm-border);
}
.thread-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  flex: 1 1 auto;
  min-width: 0;
}
.thread-names {
  min-width: 0;
}
.thread-header h2 {
  font-size: var(--tb-type-h3-size);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.thread-sender {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
  font-size: 13px;
}
/* A chat with another number of the cabinet: said beside the sender. */
.thread-own {
  min-width: 0;
  overflow: hidden;
  color: var(--bm-muted);
  text-overflow: ellipsis;
  white-space: nowrap;
}
.thread-own[hidden] {
  display: none;
}
.back {
  display: none;
}
/* A wide screen shows the send switch in the header; a phone folds it, the
   search and the chat facts into one menu. */
.thread-more,
.menu-item {
  display: none;
}
.thread-menu {
  display: contents;
}
.phone-only {
  display: none;
}
/* Statistics: a section of its own in the rail on a wide screen, a page
   inside Настройки on a phone (with the crumb back to it). */
.crumbs.phone-crumbs {
  display: none;
}
.draft-preview {
  display: none;
}
/* «О чате»: a short definition list, label and value per line. */
.thread-facts {
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 3px 14px;
  margin: 0;
  padding: 10px 20px;
  border-bottom: 1px solid var(--bm-border);
  background: var(--bm-surface);
  font-size: 13px;
  line-height: 1.45;
}
.thread-facts dt {
  color: var(--bm-text-soft);
  font: 600 11px/1.75 var(--bm-font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.thread-facts dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}
.search-form {
  display: flex;
  gap: 8px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--bm-border);
}
.search-form input {
  min-height: var(--tb-control-sm);
}
.message-pane {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
}
.message-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 12px clamp(14px, 4%, 48px) 16px;
  background: var(--tb-chat-bg);
  overscroll-behavior: contain;
}
.message-scroll:focus-visible {
  box-shadow: inset 0 0 0 2px var(--bm-focus);
}
.messages {
  display: flex;
  flex-direction: column;
  max-width: 920px;
  margin: 0 auto;
}
.day {
  align-self: center;
  margin: 14px 0 8px;
  padding: 3px 12px;
  border-radius: var(--bm-radius-pill);
  background: color-mix(in srgb, var(--bm-surface) 92%, transparent);
  box-shadow: var(--bm-shadow-xs);
  color: var(--bm-text-soft);
  font-size: 13px;
  font-weight: 600;
}
/* While scrolling only: floats over the history, fades when it stops. */
.day-float {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 2;
  margin: 0;
  translate: -50% 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms var(--bm-ease-standard);
}
.day-float:empty {
  display: none;
}
.day-float.shown {
  opacity: 1;
}
.bubble {
  position: relative;
  align-self: flex-start;
  max-width: min(78%, 620px);
  margin-top: 8px;
  padding: 6px 10px 6px;
  border-radius: var(--bm-radius-lg);
  border-top-left-radius: var(--bm-radius-xs);
  background: var(--tb-bubble-in);
  box-shadow: var(--tb-bubble-shadow);
}
/* A message the cabinet does not render yet (contact, location, poll,
   missed call): its label under the kit's mono overline, on a quieter,
   outlined surface. */
.bubble.notice {
  background: var(--bm-surface);
  box-shadow: inset 0 0 0 1px var(--bm-border-strong);
}
.notice-overline {
  display: block;
  margin-bottom: 2px;
  color: var(--bm-text-soft);
  font: 600 11px/1.4 var(--bm-font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.bubble.outgoing {
  align-self: flex-end;
  border-top-left-radius: var(--bm-radius-lg);
  border-top-right-radius: var(--bm-radius-xs);
  background: var(--tb-bubble-out);
}
.bubble.cont {
  margin-top: 2px;
  border-top-left-radius: var(--bm-radius-lg);
}
.bubble.outgoing.cont {
  border-top-right-radius: var(--bm-radius-lg);
}
.bubble.pending {
  opacity: 0.85;
}
.bubble .who {
  display: block;
  margin-bottom: 2px;
  color: var(--bm-accent-ink);
  font-size: 13px;
  font-weight: 700;
}
.bubble .text {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  line-height: 1.42;
}
.bubble .text a {
  color: var(--bm-info-ink);
  overflow-wrap: anywhere;
}
.bubble.emoji-only .text {
  font-family:
    'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji',
    'Twemoji Mozilla', var(--bm-font-body), sans-serif;
  font-size: 40px;
  line-height: 1.2;
}
/* Reserves room on the last line for the time, as messengers do. */
.meta-spacer {
  display: inline-block;
  width: 58px;
  height: 1px;
}
.bubble.outgoing .meta-spacer {
  width: 78px;
}
.bubble.edited .meta-spacer {
  width: 128px;
}
.bubble.outgoing.edited .meta-spacer {
  width: 148px;
}
.bubble .meta {
  position: absolute;
  right: 9px;
  bottom: 4px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--bm-text-soft);
  font-size: 12px;
  line-height: 1;
  white-space: nowrap;
}
.ticks {
  display: inline-flex;
  color: var(--tb-tick);
}
.ticks[data-tick='read'] {
  color: var(--tb-tick-read);
}
.ticks[data-tick='problem'] {
  color: var(--bm-warn-ink);
}
.quote {
  display: block;
  margin: 2px 0 6px;
  padding: 4px 8px;
  border-left: 3px solid var(--bm-accent);
  border-radius: var(--bm-radius-sm);
  background: color-mix(in srgb, var(--bm-text) 6%, transparent);
  font-size: 14px;
}
.quote strong {
  display: block;
  color: var(--bm-accent-ink);
  font-size: 13px;
}
.quote span {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  color: var(--bm-text-soft);
  overflow-wrap: anywhere;
}
/* ---- reactions ------------------------------------------------------------ */
/* Chips sit on the lower edge of the bubble, as in WhatsApp; the bubble
   keeps room for them below. Emoji come from the system font only. */
.bubble.has-reactions {
  margin-bottom: 19px;
  padding-bottom: 9px;
}
.reactions {
  position: absolute;
  /* Overlaps the bubble's lower padding only, never its last line. */
  bottom: -21px;
  left: 8px;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 3px;
}
.bubble.outgoing .reactions {
  right: 8px;
  left: auto;
}
.reaction-chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  box-sizing: border-box;
  height: 24px;
  padding: 0 7px;
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius-pill);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-xs);
  color: var(--bm-text-soft);
  font: 600 12px/1 var(--bm-font-body);
  white-space: nowrap;
}
button.reaction-chip {
  cursor: pointer;
}
button.reaction-chip:hover {
  border-color: var(--bm-border-strong);
}
.reaction-chip[data-mine] {
  border-color: color-mix(in srgb, var(--bm-accent-ink) 38%, transparent);
  background: color-mix(in srgb, var(--bm-accent-ink) 14%, var(--bm-surface));
  color: var(--bm-accent-ink);
}
.reaction-chip[data-state='pending'] {
  opacity: 0.6;
}
.reaction-chip[data-state='failed'] {
  border-color: var(--bm-warn-ink);
  background: var(--bm-surface);
  color: var(--bm-warn-ink);
}
.reaction-emoji,
.reaction-option,
.reaction-person-emoji,
.reaction-other input {
  font-family:
    'Apple Color Emoji', 'Segoe UI Emoji', 'Noto Color Emoji',
    'Twemoji Mozilla', var(--bm-font-body), sans-serif;
}
.reaction-emoji {
  font-size: 16px;
  line-height: 1;
}
/* The round button beside a bubble: on hover with a mouse, on focus, or
   after a tap on the bubble with a finger. */
.react-button {
  position: absolute;
  top: 50%;
  right: -38px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius-pill);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-xs);
  color: var(--bm-text-soft);
  opacity: 0;
  pointer-events: none;
  translate: 0 -50%;
  transition: opacity var(--bm-dur-fast) var(--bm-ease-out);
}
/* Bridges the gap to the bubble, so the hover does not drop on the way. */
.react-button::before {
  content: '';
  position: absolute;
  inset: -8px;
}
.bubble.outgoing .react-button {
  right: auto;
  left: -38px;
}
.react-button:hover {
  color: var(--bm-text);
}
@media (hover: hover) {
  .bubble:hover .react-button {
    opacity: 1;
    pointer-events: auto;
  }
}
.bubble:focus-within .react-button,
.bubble[data-reacting] .react-button,
.bubble[data-touched] .react-button {
  opacity: 1;
  pointer-events: auto;
}
/* Picker and the list of who reacted: the kit's popover surface. */
.reaction-pop {
  position: fixed;
  top: var(--pop-top, 0);
  left: var(--pop-left, 0);
  z-index: var(--bm-z-dropdown);
  padding: 6px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-xl);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-md);
  color: var(--bm-text);
  opacity: 0;
  translate: 0 4px;
  transition:
    opacity var(--bm-dur-fast) var(--bm-ease-out),
    translate var(--bm-dur-fast) var(--bm-ease-out);
}
.reaction-pop[data-shown] {
  opacity: 1;
  translate: 0 0;
}
.reaction-bar {
  display: flex;
  gap: 2px;
}
.reaction-option {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: var(--bm-radius-pill);
  background: transparent;
  color: var(--bm-text-soft);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.reaction-option:hover {
  background: var(--bm-wash-accent);
}
.reaction-option[aria-pressed='true'] {
  background: color-mix(in srgb, var(--bm-accent-ink) 18%, var(--bm-surface));
  box-shadow: inset 0 0 0 1px
    color-mix(in srgb, var(--bm-accent-ink) 45%, transparent);
}
.reaction-other {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 8px 4px 2px;
}
.reaction-other[hidden] {
  display: none;
}
.reaction-other input {
  flex: 1 1 80px;
  min-width: 0;
  min-height: var(--tb-control-sm);
  font-size: 20px;
}
.reaction-hint {
  flex-basis: 100%;
  color: var(--bm-text-soft);
  font-size: 12px;
}
.reaction-other input[aria-invalid='true'] + .reaction-send + .reaction-hint {
  color: var(--bm-warn-ink);
}
.reaction-people {
  min-width: 220px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 8px;
}
.reaction-people-title {
  margin: 2px 6px 6px;
  color: var(--bm-text-soft);
  font-size: 13px;
  font-weight: 700;
}
.reaction-people-list {
  max-height: 260px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}
.reaction-person {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 2px 6px;
  border-radius: var(--bm-radius-md);
}
.reaction-person-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.reaction-person-note {
  color: var(--bm-warn-ink);
  font-size: 12px;
}
.reaction-person-emoji {
  font-size: 20px;
  line-height: 1;
}
.reaction-close {
  display: block;
  width: 100%;
  margin-top: 6px;
}
@media (max-width: 380px) {
  .reaction-option {
    width: 35px;
    height: 35px;
    font-size: 21px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .reaction-pop,
  .react-button {
    transition: none;
  }
}
/* ---- media in the chat --------------------------------------------------- */
/* Pictures sit in a box of their own proportions (set from the message's
   dimensions before anything loads), so the history never jumps. */
.bubble .media {
  display: grid;
  gap: 3px;
}
.bubble .media.album {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: min(320px, 62vw);
}
.bubble .media.album > :first-child:nth-last-child(odd) {
  grid-column: span 2;
}
.bubble.picture {
  padding: 3px 3px 6px;
}
.bubble.picture .text {
  padding: 5px 7px 0;
}
.bubble.picture .meta {
  right: 10px;
  bottom: 6px;
}
.bubble.bare {
  padding-bottom: 3px;
}
.bubble.bare .meta {
  right: 9px;
  bottom: 9px;
  padding: 3px 7px;
  border-radius: var(--bm-radius-pill);
  /* bm-allow-theme-blind: over a photo, light on iron in both themes */
  background: color-mix(in srgb, var(--bm-iron) 58%, transparent);
  color: var(--tb-photo-ink);
}
.bubble.bare .ticks {
  color: inherit;
}
.media-frame {
  position: relative;
  display: grid;
  place-items: center;
  width: min(320px, 62vw);
  max-width: 100%;
  aspect-ratio: var(--media-ratio, 1.333);
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-radius: calc(var(--bm-radius-lg) - 3px);
  background: color-mix(in srgb, var(--bm-text) 9%, transparent);
  color: var(--bm-text-soft);
}
button.media-frame {
  cursor: zoom-in;
}
.bubble .media.album .media-frame {
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--bm-radius-md);
}
.media-frame img {
  grid-area: 1 / 1;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
/* The inline preview is tiny; blurred it reads as "loading", not as blur. */
.media-frame img.preview {
  filter: blur(6px);
  transform: scale(1.08);
}
.media-frame.sticker {
  width: 150px;
  background: transparent;
}
.media-frame.sticker img {
  object-fit: contain;
}
.media-file {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-width: min(250px, 58vw);
  padding: 4px 0 16px;
}
.media-glyph {
  display: grid;
  flex: none;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: var(--bm-radius-md);
  background: var(--bm-wash-accent);
  color: var(--bm-accent-ink);
}
.media-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.media-name {
  font-weight: 600;
  line-height: 1.3;
  overflow-wrap: anywhere;
}
.media-kind {
  color: var(--bm-text-soft);
  font: 600 11px/1.35 var(--bm-font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.media-action-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  margin-top: 6px;
}
/* What can be done with a file: the kit's small quiet button (mono label,
   8px corner, the operable border); a note is plain soft text. */
.media-action {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 6px;
  min-height: var(--tb-control-sm);
  padding: 0 12px;
  border: 1px solid var(--bm-control-border);
  border-radius: var(--bm-radius-md);
  background: transparent;
  color: var(--bm-text);
  font: 700 11px/1.2 var(--bm-font-mono);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  text-decoration: none;
  white-space: nowrap;
}
.media-body > .media-action {
  margin-top: 6px;
}
.media-action:hover {
  background: color-mix(in srgb, var(--bm-text) 9%, transparent);
}
.media-action[aria-pressed='true'] {
  border-color: var(--bm-accent-ink);
  background: var(--bm-wash-accent);
  color: var(--bm-accent-ink);
}
.media-action.busy,
.media-action.note {
  min-height: 0;
  padding: 0;
  border: 0;
  background: none;
  color: var(--bm-text-soft);
  font: 500 13px/1.35 var(--bm-font-body);
  letter-spacing: 0;
  text-transform: none;
  white-space: normal;
}
.media-action:disabled {
  opacity: 0.6;
}
/* «Хранить постоянно»: the toggle, and the mark of a pinned file. */
.media-keep {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}
.media-pinned {
  color: var(--bm-accent-ink);
  font-size: 13px;
  font-weight: 600;
}
.media-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: var(--bm-radius-pill);
  /* bm-allow-theme-blind: over a photo */
  background: color-mix(in srgb, var(--bm-iron) 70%, transparent);
  color: var(--tb-photo-ink);
}
.voice-keep {
  display: inline-flex;
}
.voice-keep:empty {
  display: none;
}
.voice-pin {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 28px;
  min-height: 22px;
  padding: 0 7px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-pill);
  background: transparent;
  color: var(--bm-text-soft);
  font: 600 12px/1 var(--bm-font-body);
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}
.voice-pin:hover {
  background: color-mix(in srgb, var(--bm-text) 7%, transparent);
}
.voice-pin[aria-pressed='true'] {
  border-color: transparent;
  background: var(--bm-wash-accent);
  color: var(--bm-accent-ink);
}
@media (pointer: coarse) {
  .voice-pin {
    min-height: 32px;
    min-width: 40px;
  }
}
.lightbox-keep {
  display: inline-flex;
}
.lightbox-keep .media-pinned {
  color: color-mix(in srgb, var(--tb-photo-ink) 80%, transparent);
}
.lightbox-keep .lightbox-button {
  font: 600 14px/1.2 var(--bm-font-body);
  letter-spacing: 0;
  text-transform: none;
}
@media (max-width: 620px) {
  /* The toggle is pressed: the mark would only crowd the bar. */
  .lightbox-keep .media-pinned {
    display: none;
  }
}
/* Over a picture: centred, light on a dark chip in both themes. */
.media-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  text-align: center;
}
.media-overlay .media-action-row {
  justify-content: center;
  margin: 0;
}
.media-overlay .media-action {
  align-self: center;
  border-color: transparent;
  /* bm-allow-theme-blind: over a photo */
  background: color-mix(in srgb, var(--bm-iron) 70%, transparent);
  color: var(--tb-photo-ink);
}
.media-overlay .media-action:hover {
  background: color-mix(in srgb, var(--bm-iron) 82%, transparent);
}
/* Over a picture there is room for the button only; the reason is still
   read out. */
.media-overlay .media-action.retained {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.media-overlay .media-action.busy,
.media-overlay .media-action.note {
  padding: 6px 12px;
  border-radius: var(--bm-radius-lg);
  color: var(--tb-photo-ink);
  font-size: 13px;
}

/* A voice note: a round play button (a brass fill), the waveform as a
   seekable track, time and speed under it. Progress is one CSS variable
   set from the player; the played bars are the same bars, clipped. */
.voice {
  --voice-progress: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(300px, 64vw);
  padding: 2px 0 16px;
}
.voice-play {
  display: grid;
  flex: none;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--bm-accent);
  color: var(--bm-on-accent);
  cursor: pointer;
}
.voice-play:hover {
  background: color-mix(in srgb, var(--bm-accent) 86%, var(--bm-text));
}
.voice-play:disabled {
  background: var(--bm-track);
  color: var(--bm-text-faint);
  cursor: default;
}
.voice-glyph {
  display: grid;
}
.voice-glyph svg path {
  fill: currentColor;
}
.voice[data-state='loading'] .voice-glyph {
  animation: voice-wait 1.1s var(--bm-ease-standard) infinite alternate;
}
@keyframes voice-wait {
  to {
    opacity: 0.35;
  }
}
.voice-main {
  display: grid;
  flex: 1 1 auto;
  gap: 4px;
  min-width: 0;
}
.voice-track {
  position: relative;
  height: 28px;
  border-radius: var(--bm-radius-xs);
  cursor: pointer;
  touch-action: none;
}
.voice-bars {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--bm-text-faint);
}
.voice-bars.played {
  color: var(--bm-accent-ink);
  clip-path: inset(0 calc((1 - var(--voice-progress)) * 100%) 0 0);
}
.voice-bar {
  flex: 1 1 0;
  min-width: 1px;
  height: calc(var(--bar, 0.3) * 100%);
  border-radius: var(--bm-radius-pill);
  background: currentColor;
}
/* Without a waveform: a plain line. */
.voice-track:not(.wave) .voice-bars::before {
  content: '';
  flex: 1;
  height: 4px;
  border-radius: var(--bm-radius-pill);
  background: currentColor;
}
.voice-thumb {
  position: absolute;
  top: 50%;
  left: calc(var(--voice-progress) * 100%);
  width: 12px;
  height: 12px;
  margin: -6px 0 0 -6px;
  border-radius: 50%;
  background: var(--bm-accent-ink);
  box-shadow: 0 0 0 2px var(--tb-bubble-in, var(--bm-surface));
  opacity: 0;
  transition: opacity var(--bm-dur-fast) var(--bm-ease-standard);
}
.bubble.outgoing .voice-thumb {
  box-shadow: 0 0 0 2px var(--tb-bubble-out);
}
.voice[data-state='playing'] .voice-thumb,
.voice-track:hover .voice-thumb,
.voice-track:focus-visible .voice-thumb {
  opacity: 1;
}
.voice:not([data-state='idle'], [data-state='playing']) .voice-track {
  cursor: default;
}
.voice-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  min-height: 22px;
}
.voice-time {
  color: var(--bm-text-soft);
  font: 600 12px/1.3 var(--bm-font-mono);
  font-variant-numeric: tabular-nums;
}
.voice-speed {
  min-width: 40px;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-pill);
  background: transparent;
  color: var(--bm-text);
  font: 700 11px/1 var(--bm-font-mono);
  cursor: pointer;
}
.voice-speed:hover {
  background: color-mix(in srgb, var(--bm-text) 7%, transparent);
}
.voice-status {
  flex-basis: 100%;
  color: var(--bm-text-soft);
  font-size: 13px;
  line-height: 1.35;
}
.voice-status:empty {
  display: none;
}
@media (pointer: coarse) {
  .voice-play {
    width: 44px;
    height: 44px;
  }
  .voice-track {
    height: 36px;
  }
  .voice-speed {
    min-height: 32px;
    min-width: 48px;
  }
  /* Small controls keep their look and answer a 44px finger: the target
     reaches past the edge, the layout does not move. */
  .voice-speed,
  .voice-pin,
  .reaction-chip {
    position: relative;
  }
  .voice-speed::after,
  .voice-pin::after,
  button.reaction-chip::after {
    content: '';
    position: absolute;
    inset: -6px -2px;
  }
  button.reaction-chip::after {
    inset: -10px -2px;
  }
}
@media (prefers-reduced-motion: reduce) {
  .voice[data-state='loading'] .voice-glyph {
    animation: none;
  }
}

/* The open picture, large, over everything; dark in both themes. */
html[data-lightbox] body {
  overflow: hidden;
}
.lightbox {
  position: fixed;
  inset: 0;
  z-index: calc(var(--bm-z-dropdown) + 20);
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--tb-photo-ground) 97%, transparent);
  color: var(--tb-photo-ink);
}
.lightbox-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: max(10px, env(safe-area-inset-top)) 14px 10px;
}
.lightbox-count {
  font: 600 11px/1.35 var(--bm-font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--tb-photo-ink) 72%, transparent);
}
.lightbox-gap {
  flex: 1;
}
.lightbox-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--tb-photo-ink) 28%, transparent);
  border-radius: var(--bm-radius-pill);
  background: color-mix(in srgb, var(--tb-photo-ground) 50%, transparent);
  color: inherit;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}
.lightbox-button.icon {
  width: 44px;
  padding: 0;
}
.lightbox-button:hover {
  background: color-mix(in srgb, var(--tb-photo-ink) 12%, transparent);
}
.lightbox :focus-visible {
  box-shadow: var(--tb-ring-chrome);
}
.lightbox-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  padding: 0 72px;
}
/* The picture fills the stage, kept whole; arrows sit over its edges. */
.lightbox-stage img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.lightbox-stage .lightbox-button {
  position: absolute;
  top: 50%;
  z-index: 1;
  translate: 0 -50%;
}
.lightbox-stage .lightbox-button:first-child {
  left: 14px;
}
.lightbox-stage .lightbox-button:last-child {
  right: 14px;
}
.lightbox-caption {
  padding: 12px 18px max(18px, env(safe-area-inset-bottom));
  color: color-mix(in srgb, var(--tb-photo-ink) 86%, transparent);
  text-align: center;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
@media (max-width: 620px) {
  .lightbox-stage {
    padding: 0;
  }
  .lightbox-stage .lightbox-button:first-child {
    left: 8px;
  }
  .lightbox-stage .lightbox-button:last-child {
    right: 8px;
  }
}

.messages > .empty-list {
  margin: auto;
}
.jump-latest {
  position: absolute;
  right: 18px;
  bottom: 14px;
  z-index: 2;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 1px solid var(--bm-border-strong);
  border-radius: 50%;
  background: var(--bm-surface);
  color: var(--bm-text);
  box-shadow: var(--bm-shadow-md);
}
.jump-latest:hover {
  background: var(--bm-raised);
}
.thread-drafts:not(:empty) {
  flex: 0 0 auto;
  display: grid;
  overflow-y: auto;
  border-top: 1px solid var(--bm-border);
  background: var(--bm-surface);
}
/* A draft in the open chat is a short bar until the owner edits it: two
   lines of the text, «Изменить», the actions; on a wide pane the text and
   the actions share a line. More drafts of the chat wait behind «Ещё N».
   The pane's own width decides, not the window's: beside the queue the pane
   is narrow on a tablet and just past each step of the layout, and there
   the actions' column left the text no room at all. */
.thread-drafts {
  container: thread-drafts / inline-size;
}
.thread-drafts:not(:empty) {
  gap: 8px;
  max-height: 45%;
  padding: 10px 20px;
}
.thread-drafts:not([data-all]) > .draft-card.in-thread ~ .draft-card.in-thread {
  display: none;
}
.drafts-more {
  justify-self: start;
  min-height: 32px;
  font-size: 14px;
}
.draft-card.in-thread {
  gap: 8px;
  padding: 10px 12px;
}
.draft-card.in-thread .card-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-width: 0;
  font-size: 14px;
}
.draft-card.in-thread .card-head strong {
  min-width: 0;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.draft-card.in-thread:not([data-open]) > .draft-body,
.draft-card.in-thread:not([data-open]) > .draft-tools,
.draft-card.in-thread:not([data-open]) .draft-quote,
.draft-card.in-thread[data-open] > .draft-preview {
  display: none;
}
.draft-card.in-thread:not([data-open]) .draft-preview {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 0;
  border: 0;
  background: transparent;
  font-size: 15px;
  line-height: 1.4;
  text-align: left;
}
.draft-preview-text {
  flex: 1 1 auto;
  min-width: 0;
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow-wrap: anywhere;
}
.draft-open {
  flex: 0 0 auto;
  color: var(--bm-accent-ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.draft-card.in-thread .row-actions {
  flex-wrap: nowrap;
}
.draft-card.in-thread .row-actions .button {
  flex: 1 1 0;
  min-width: 0;
}
/* 550 px inside the pane leaves the text two lines of about twenty letters
   beside the actions; a narrower pane stacks them, as a phone does. */
@container thread-drafts (min-width: 550px) {
  .draft-card.in-thread:not([data-open]) {
    grid-template-columns: minmax(0, 1fr) 280px;
    align-items: end;
    column-gap: 16px;
  }
  .draft-card.in-thread:not([data-open]) > :not(.draft-preview, .row-actions) {
    grid-column: 1 / -1;
  }
  .draft-card.in-thread:not([data-open]) > .draft-preview {
    grid-area: 2 / 1;
  }
  .draft-card.in-thread:not([data-open]) > .row-actions {
    grid-area: 2 / 2;
  }
}
/* A draft's file in the short bar: the picture and the name, no link. */
.draft-card.in-thread:not([data-open]) .draft-file {
  gap: 10px;
  padding: 6px;
}
.draft-card.in-thread:not([data-open]) .draft-file-thumb {
  width: 56px;
}
.draft-card.in-thread:not([data-open]) .draft-file .media-action {
  display: none;
}
.send-form {
  display: grid;
  gap: 6px;
  padding: 10px 20px 14px;
  border-top: 1px solid var(--bm-border);
  background: var(--bm-surface);
}
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.composer textarea {
  flex: 1;
  min-width: 0;
  min-height: var(--tb-control-h);
  max-height: 180px;
  padding-top: 10px;
  padding-bottom: 10px;
  border-radius: 21px;
  resize: none;
}
.send-button {
  flex: 0 0 auto;
}

/* ---- a file in the composer, and a draft's file ---------------------------- */
/* The drop zone covers the open chat while a file is dragged over it. */
.thread-panel {
  position: relative;
}
.attach-button {
  flex: 0 0 auto;
  width: var(--tb-control-h);
  padding: 0;
  border-radius: 50%;
}
.composer-file {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px 8px 8px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-wash-accent);
}
.composer-file .media-body {
  flex: 1 1 auto;
}
.composer-file .media-name,
.draft-file .media-name {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}
.composer-file-thumb {
  display: grid;
  flex: none;
  width: 56px;
  height: 56px;
  overflow: hidden;
  border-radius: var(--bm-radius-md);
  background: color-mix(in srgb, var(--bm-text) 9%, transparent);
}
.composer-file-preview {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.composer-file-remove {
  flex: none;
}
.drop-zone {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  margin: 10px;
  border: 2px dashed var(--bm-accent-ink);
  border-radius: var(--bm-radius-xl);
  background: color-mix(in srgb, var(--bm-surface) 90%, transparent);
  /* The chat under it keeps the drag events. */
  pointer-events: none;
}
.drop-zone p {
  color: var(--bm-accent-ink);
  font: 600 16px/1.4 var(--bm-font-body);
}
.draft-file {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius-md);
  background: var(--bm-bg);
}
.draft-file-thumb {
  display: block;
  flex: none;
  width: 120px;
  aspect-ratio: var(--media-ratio, 1.333);
  overflow: hidden;
  border-radius: var(--bm-radius-sm);
  background: color-mix(in srgb, var(--bm-text) 9%, transparent);
}
.draft-file-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.draft-file .media-action {
  margin-top: 6px;
}
/* A switch with its name and a line under it (BmToggleRow): the whole row
   answers a tap; the switch never shrinks. */
.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  min-height: 44px;
  padding: 8px 0;
  border-top: 1px solid var(--bm-border);
  color: var(--bm-text);
  font: 400 14px/1.4 var(--bm-font-body);
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}
.toggle-words {
  display: flex;
  align-items: center;
  min-width: 0;
}
.toggle-words label {
  color: var(--bm-text);
  font: 600 14px/1.4 var(--bm-font-body);
  letter-spacing: 0;
  text-transform: none;
  cursor: pointer;
}
.toggle-row .switch {
  flex: 0 0 auto;
  margin: 0;
}

/* ---- numbers ---------------------------------------------------------------- */
.number-card {
  gap: 12px;
}
.number-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.number-title {
  margin: 0;
  font-size: var(--tb-type-h3-size);
  overflow-wrap: anywhere;
}
.number-phone {
  margin-top: -6px;
  font: 500 14px var(--bm-font-body);
  font-variant-numeric: tabular-nums;
  color: var(--bm-text-soft);
}
.number-card .alert {
  margin: 0;
}
/* What a number that cannot work now is going through, on its card. */
.card-note {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--bm-caution-ink) 34%, transparent);
  border-radius: var(--bm-radius-md);
  background: color-mix(in srgb, var(--bm-caution) 10%, var(--bm-surface));
  font-size: 14px;
  line-height: 1.45;
}
.card-note strong {
  color: var(--bm-caution-ink);
}
.number-facts {
  display: grid;
  gap: 14px;
}
/* The way from an account to its chats and who may read and answer them.
   A settings row (BmSettingsRow) that is a button: the name of the page it
   opens, where things stand now, and a chevron that says it leads on. It
   is tinted, not a white field: it is pressed, not typed in. */
.fact-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 56px;
  padding: 10px 14px;
  border: 1px solid var(--bm-control-border);
  border-radius: var(--bm-radius-md);
  background: color-mix(in srgb, var(--bm-accent) 8%, var(--bm-surface));
  text-align: left;
  transition: background var(--bm-dur-fast) var(--bm-ease-standard);
}
.fact-link::after {
  content: '';
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-top: 2px solid var(--bm-accent-ink);
  border-right: 2px solid var(--bm-accent-ink);
  rotate: 45deg;
  transition: translate var(--bm-dur-fast) var(--bm-ease-standard);
}
.fact-link:hover {
  background: color-mix(in srgb, var(--bm-accent) 16%, var(--bm-surface));
}
.fact-link:hover::after {
  translate: 3px 0;
}
.fact-words {
  display: grid;
  gap: 2px;
  min-width: 0;
}
.fact-title {
  font-size: 15px;
  font-weight: 600;
  line-height: 1.3;
}
.fact-summary {
  color: var(--bm-text-soft);
  font-size: 14px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.meter {
  display: grid;
  gap: 6px;
}
.meter-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  font-size: 14px;
}
.meter-head {
  align-items: baseline;
}
.meter-head span {
  color: var(--bm-text-soft);
  font: 600 11px/1.35 var(--bm-font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.meter-head strong {
  white-space: nowrap;
  font: 700 12px/1.35 var(--bm-font-mono);
  font-variant-numeric: tabular-nums;
}
.meter-bar {
  height: 8px;
  border-radius: var(--bm-radius-pill);
  background: var(--bm-track);
  overflow: hidden;
}
.meter-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--bm-accent-ink);
}
.meter-fill[data-state='full'] {
  background: var(--bm-warn-ink);
}
.steps {
  margin: 0;
  padding-left: 20px;
  display: grid;
  gap: 4px;
}
.qr {
  width: min(100%, 264px);
  height: auto;
  image-rendering: pixelated;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-md);
}
.number-card .qr {
  justify-self: center;
}
details > summary {
  cursor: pointer;
}
/* One disclosure (BmAccordion): the label, then a chevron that turns when
   open; a 44px header and no native marker. A full-width header puts the
   chevron at its end; an inline one keeps it beside the label. */
.disclosure > summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 44px;
  border-radius: var(--bm-radius-md);
  list-style: none;
}
.disclosure > summary::-webkit-details-marker {
  display: none;
}
.disclosure > summary::after {
  content: '';
  flex: 0 0 auto;
  width: 8px;
  height: 8px;
  margin-right: 5px;
  border-right: 2px solid var(--bm-text-soft);
  border-bottom: 2px solid var(--bm-text-soft);
  rotate: 45deg;
  translate: 0 -2px;
  transition:
    rotate var(--bm-dur-fast) var(--bm-ease-standard),
    translate var(--bm-dur-fast) var(--bm-ease-standard);
}
.disclosure[open] > summary::after {
  border-color: var(--bm-accent-ink);
  rotate: 225deg;
  translate: 0 2px;
}
.disclosure.inline > summary {
  justify-content: flex-start;
  width: fit-content;
  max-width: 100%;
}
.more-actions {
  border-top: 1px solid var(--bm-border);
}
.more-actions > summary {
  color: var(--bm-accent-ink);
  font-weight: 600;
}
.more-list {
  display: grid;
  gap: 10px;
  padding: 4px 0 6px;
}
.limit-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.limit-row input,
.more-list .limit-row input {
  flex: 1 1 90px;
  width: auto;
  max-width: 160px;
}
.meter-note,
.field-note {
  color: var(--bm-text-soft);
  font-size: 13px;
  line-height: 1.4;
}
.field-note {
  max-width: 60ch;
}
.add-number > summary {
  display: inline-flex;
  list-style: none;
}
.add-number > summary::-webkit-details-marker {
  display: none;
}
.add-number[open] > summary {
  margin-bottom: 14px;
}
.add-number .section-card {
  max-width: 640px;
}

/* ---- access (nested in a number) --------------------------------------------- */
.access-body {
  display: grid;
  gap: 16px;
  max-width: 980px;
}
.access-summary {
  font-weight: 600;
}
.policy {
  display: grid;
  gap: 12px;
  padding: 16px 20px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-surface);
}
.policy h3 {
  margin: 0;
}
.policy-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}
.hint {
  font-size: 14px;
  color: var(--bm-text-soft);
}
.hint > summary {
  color: var(--bm-accent-ink);
  font-weight: 600;
}
.hint p {
  margin: 0 0 8px;
  max-width: 70ch;
}
.access-chats {
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-surface);
  overflow: clip;
}
.access-tools {
  display: grid;
  gap: 10px;
  padding: 14px 16px 10px;
}
.access-head,
.access-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 72px 72px;
  gap: 4px 8px;
  align-items: center;
}
.access-head {
  position: sticky;
  top: var(--tb-topbar-h);
  z-index: 1;
  padding: 8px 16px;
  border-top: 1px solid var(--bm-border);
  border-bottom: 1px solid var(--bm-border-strong);
  background: var(--bm-surface);
  color: var(--bm-text-soft);
  font: 700 11px/1.35 var(--bm-font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}
.access-head span:not(:first-child) {
  text-align: center;
}
.access-list > .empty-list {
  border-top: 1px solid var(--bm-border);
}
.access-row {
  min-height: 60px;
  padding: 6px 16px;
  border-top: 1px solid var(--bm-border);
}
.access-row:first-child {
  border-top: 0;
}
.access-row:hover {
  background: color-mix(in srgb, var(--bm-text) 3%, transparent);
}
.access-row .status-message {
  grid-column: 1 / -1;
}
.access-info {
  min-width: 0;
}
.access-info strong,
.access-info small {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.access-info small {
  font-size: 13px;
}
.access-chats > .more {
  margin: 10px auto 14px;
}
.switch-hit {
  display: grid;
  place-items: center;
  align-self: stretch;
  min-height: 44px;
  cursor: pointer;
}
.switch {
  appearance: none;
  justify-self: center;
  position: relative;
  width: 44px;
  height: 26px;
  min-height: 0;
  margin: 8px 0;
  padding: 0;
  border: 1px solid var(--bm-control-border);
  border-radius: var(--bm-radius-pill);
  background: var(--bm-track);
  cursor: pointer;
  transition: background-color var(--bm-dur-fast) var(--bm-ease-standard);
}
.switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-sm);
  transition: transform var(--bm-dur-fast) var(--bm-ease-standard);
}
.switch:checked {
  background: var(--bm-accent);
  border-color: var(--bm-accent-ink);
}
.switch:checked::after {
  transform: translateX(18px);
  background: var(--bm-on-accent);
}
.switch:focus-visible {
  border-color: var(--bm-focus);
}
.switch:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- agents ------------------------------------------------------------------ */
.agents-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 380px), 1fr));
  gap: 14px;
  align-items: start;
}
.connect,
.grant-form {
  display: grid;
  gap: 12px;
  min-width: 0;
}
.copy-row {
  display: flex;
  gap: 8px;
}
.copy-row input {
  min-width: 0;
  font: 500 13px var(--bm-font-mono);
}
.plain {
  margin: 0;
  padding-left: 18px;
  display: grid;
  gap: 8px;
  font-size: 14px;
}
.plain code {
  display: block;
  margin-top: 4px;
  padding: 6px 8px;
  border-radius: var(--bm-radius-sm);
  background: var(--bm-raised);
}
.check {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
}

.checks {
  margin: 0;
  padding: 4px 14px 6px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-md);
  display: flex;
  flex-wrap: wrap;
  gap: 0 20px;
}
.checks legend {
  padding: 0 6px;
  color: var(--bm-text-soft);
  font: 600 11px/1.35 var(--bm-font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.secret {
  display: grid;
  gap: 8px;
  padding: 14px;
  border: 1px solid color-mix(in srgb, var(--bm-brass-deep) 55%, transparent);
  border-radius: var(--bm-radius-md);
  background: var(--bm-wash-accent);
}
/* A connection card: its numbers, and the key shown again. */
.card-numbers-block {
  display: grid;
  gap: 8px;
}
.card-numbers {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0 10px;
  margin-top: -4px;
  font-size: 14px;
}
.card-numbers .link-button {
  min-height: var(--tb-control-sm);
  margin-left: -4px;
  padding: 0 4px;
}
.card-missing {
  color: var(--bm-caution-ink);
  font-weight: 500;
}
/* The key takes the whole row; copy and hide share the next. */
.card-key-shown .copy-row {
  flex-direction: row;
  flex-wrap: wrap;
}
.card-key-shown .copy-row input {
  flex: 1 1 100%;
}
.card-key-shown .copy-row .button {
  flex: 1 1 0;
}
.card-edit {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-md);
  background: var(--bm-raised);
}
.card-edit .checks {
  background: var(--bm-surface);
}
.card-edit .password-field {
  font-size: 16px;
}
.card-key-note {
  color: var(--bm-text-soft);
  font-size: 13px;
  line-height: 1.4;
}
.card-key-shown p {
  font-size: 14px;
}

/* ---- settings, journal --------------------------------------------------------- */
.settings-block {
  justify-items: start;
}
/* A wide screen lays the settings out in two columns of cards. */
@media (min-width: 1180px) {
  #view-settings.panel {
    display: block;
    max-width: 1080px;
    columns: 2 420px;
    column-gap: 16px;
  }
  #view-settings > * {
    margin-bottom: 16px;
    break-inside: avoid;
  }
  #view-settings > .view-head {
    column-span: all;
  }
}
.settings-block .muted,
.grant-form > .muted {
  max-width: 64ch;
}
.danger-zone {
  border-color: color-mix(in srgb, var(--bm-warn-ink) 45%, transparent);
}
.danger-zone h3 {
  color: var(--bm-warn-ink);
}
.danger-zone .danger {
  justify-self: start;
}
.journal {
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-surface);
  overflow: hidden;
}
/* The journal: a day heading, then a time and what happened per row. */
.journal-day {
  padding: 8px 16px 6px;
  border-top: 1px solid var(--bm-border);
  background: var(--bm-raised);
  color: var(--bm-text-soft);
  font: 600 11px/1.35 var(--bm-font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.journal-day:first-child {
  border-top: 0;
}
.journal-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  gap: 2px 14px;
  padding: 10px 16px;
  border-top: 1px solid var(--bm-border);
  font-size: 14px;
}
.journal-day + .journal-row {
  border-top-color: var(--bm-border-strong);
}
.journal-row.failed {
  background: color-mix(in srgb, var(--bm-warn-ink) 5%, transparent);
}
.journal-row time {
  font: 500 12px/1.8 var(--bm-font-mono);
  font-variant-numeric: tabular-nums;
}
.journal-row p {
  min-width: 0;
  overflow-wrap: anywhere;
}
.journal-row small {
  grid-column: 2;
}
.journal-skeleton {
  height: 20px;
  margin: 14px 16px;
}

/* Revoked connections: history in a table (the operator page's pattern),
   folded behind its title when the list is long. */
.revoked-grants {
  margin-top: 12px;
}
.revoked-grants > summary {
  max-width: calc(100% + 16px);
  margin: 0 -8px;
  padding: 0 8px;
}
.revoked-grants .list-title {
  margin: 0;
}
.history-wrap {
  margin-top: 10px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-surface);
  overflow-x: auto;
}
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.history-table th,
.history-table td {
  padding: 11px 14px;
  text-align: left;
  vertical-align: middle;
  border-bottom: 1px solid var(--bm-border);
}
.history-table thead th {
  font: 700 11px/1.3 var(--bm-font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bm-text-soft);
  border-bottom-color: var(--bm-border-strong);
}
.history-table tbody tr:last-child > * {
  border-bottom: 0;
}
.history-table tbody tr:hover {
  background: color-mix(in srgb, var(--bm-text) 3%, transparent);
}
.history-table tbody th {
  min-width: 10em;
  font-weight: 600;
  overflow-wrap: break-word;
}
.history-table .history-kind {
  white-space: nowrap;
}
.history-table td {
  color: var(--bm-text-soft);
}
.history-table .history-time {
  font: 500 12px/1.5 var(--bm-font-mono);
  white-space: nowrap;
}
.history-table .history-actions {
  width: 1%;
  text-align: right;
}
.history-actions .link-button {
  min-height: var(--tb-control-sm);
  padding: 0 4px;
}
.history-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.journal-filter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
  padding: 10px 12px;
  border-radius: var(--bm-radius-md);
  background: var(--bm-raised);
  color: var(--bm-text-soft);
  font-size: 14px;
}
.journal-filter[hidden] {
  display: none;
}

/* ---- tablet: icon rail ------------------------------------------------------------ */
@media (max-width: 1179px) and (min-width: 621px) {
  :root {
    --tb-rail: 76px;
    --tb-gap: 16px;
  }
  .views button {
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    min-height: 62px;
    padding: 6px 2px;
    font-size: 12px;
    text-align: center;
  }
  .views .nav-label {
    flex: none;
    max-width: 100%;
  }
  .views button[aria-pressed='true']::before {
    top: 14px;
    bottom: 14px;
  }
  .views .count {
    position: absolute;
    top: 4px;
    left: calc(50% + 6px);
    padding: 0 6px;
  }
  .inbox-grid {
    grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  }
  .thread-header,
  .thread-facts,
  .search-form,
  .send-form,
  .thread-drafts:not(:empty) {
    padding-left: 14px;
    padding-right: 14px;
  }
  .bubble {
    max-width: 88%;
  }
}
@media (max-width: 840px) and (min-width: 621px) {
  .inbox-grid {
    grid-template-columns: 250px minmax(0, 1fr);
  }
  .send-label {
    display: none;
  }
  .send-button {
    width: var(--tb-control-h);
    padding: 0;
  }
  .welcome {
    grid-template-columns: 1fr;
    gap: 32px;
  }
}

/* ---- phone ------------------------------------------------------------------------ */
@media (max-width: 620px), (max-height: 500px) and (pointer: coarse) {
  .pilot-label,
  .account-email {
    display: none;
  }
  /* A slim brand strip that scrolls away; sign-out lives in Настройки. */
  .topbar {
    position: static;
  }
  /* 32 px high is 151 px wide: above the pack's 144 px minimum. */
  .brand .brand-logo {
    height: 32px;
  }
  .topbar #logout {
    display: none;
  }
  .phone-only {
    display: grid;
  }
  .crumbs.phone-crumbs {
    display: flex;
  }
  .views button.desktop-only {
    display: none;
  }
  /* A phone on its side: keep content clear of the notch. */
  .page,
  .topbar-inner {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .views {
    padding-left: max(4px, env(safe-area-inset-left));
    padding-right: max(4px, env(safe-area-inset-right));
  }
  .message-scroll {
    padding-left: max(10px, env(safe-area-inset-left));
    padding-right: max(10px, env(safe-area-inset-right));
  }
  html[data-thread='open'] .topbar {
    display: none;
  }
  .access-head {
    top: 0;
  }
  input,
  select,
  textarea,
  .select-trigger {
    font-size: 16px;
  }
  /* The sign-in form is what a phone opens this page for: keep it near the
     top; the three-point tour waits for a wider screen. */
  .welcome {
    min-height: 0;
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 22px 0 28px;
  }
  .welcome h1 {
    margin-bottom: 12px;
    font-size: clamp(34px, 10vw, var(--tb-type-display-size));
  }
  .intro {
    font-size: 16px;
  }
  .welcome-features {
    display: none;
  }
  .consent {
    padding: 24px 0;
  }

  .workspace {
    display: block;
    padding: 12px 0 calc(78px + env(safe-area-inset-bottom));
  }
  .workspace-main,
  .workspace[data-view='queue'] .workspace-main {
    height: auto;
    min-height: 0;
    gap: 12px;
  }

  /* Thumb bar at the bottom. */
  .views {
    position: fixed;
    top: auto;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0;
    padding: 4px 4px max(4px, env(safe-area-inset-bottom));
    background: var(--tb-chrome);
    border-top: 1px solid var(--bm-brass-deep);
  }
  .views button {
    flex-direction: column;
    justify-content: center;
    gap: 3px;
    min-height: 56px;
    padding: 6px 2px;
    border: 0;
    color: var(--tb-on-chrome-soft);
    font-size: 11px;
    font-weight: 600;
    text-align: center;
  }
  .views .nav-label {
    flex: none;
    max-width: 100%;
  }
  .views svg {
    width: 24px;
    height: 24px;
  }
  .views button:hover {
    background: transparent;
    color: var(--tb-on-chrome);
  }
  .views button[aria-pressed='true'] {
    background: var(--tb-chrome-2);
    border: 0;
    color: var(--tb-chrome-accent);
    box-shadow: none;
  }
  .views button[aria-pressed='true']::before {
    display: none;
  }
  .views button[aria-pressed='true'] svg {
    color: inherit;
  }
  .views .count {
    position: absolute;
    top: 4px;
    left: calc(50% + 6px);
    padding: 0 6px;
  }
  .views :focus-visible,
  .views button[aria-pressed='true']:focus-visible {
    box-shadow: var(--tb-ring-chrome);
  }

  .panel {
    gap: 14px;
  }
  .cards {
    grid-template-columns: 1fr;
  }
  .row-actions .button,
  .add-number > summary {
    flex: 1 1 100%;
  }
  /* The main action takes the row; the quieter ones share the next. */
  .row-actions .button.quiet {
    flex: 1 1 0;
  }
  html {
    scroll-padding-bottom: calc(76px + env(safe-area-inset-bottom));
  }
  .segmented button {
    min-height: 44px;
  }
  .crumb-back {
    min-height: 44px;
  }
  .add-number > summary {
    display: flex;
  }
  .section-card {
    padding: 16px;
  }
  .policy {
    padding: 14px;
  }
  .policy-grid {
    grid-template-columns: 1fr;
  }
  .access-head,
  .access-row {
    grid-template-columns: minmax(0, 1fr) 56px 56px;
  }
  .access-head,
  .access-row,
  .access-tools {
    padding-left: 12px;
    padding-right: 12px;
  }
  .copy-row {
    flex-direction: column;
  }
  .journal-row {
    grid-template-columns: 44px minmax(0, 1fr);
    gap: 2px 10px;
    padding: 10px 12px;
  }
  .journal-day {
    padding-left: 12px;
    padding-right: 12px;
  }
  /* The revoked table stacks: one card per connection, label: value. */
  .history-table,
  .history-table tbody,
  .history-table tr,
  .history-table th,
  .history-table td {
    display: block;
    width: auto;
  }
  .history-table thead {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
  }
  .history-table tr {
    padding: 12px 14px;
    border-bottom: 1px solid var(--bm-border-strong);
  }
  .history-table tbody tr:last-child {
    border-bottom: 0;
  }
  .history-table th,
  .history-table td {
    padding: 3px 0;
    border: 0;
  }
  .history-table tbody th {
    padding-bottom: 6px;
    font-size: 15px;
  }
  .history-table td {
    display: grid;
    grid-template-columns: minmax(0, 120px) minmax(0, 1fr);
    align-items: baseline;
    gap: 10px;
  }
  .history-table td::before {
    content: attr(data-label);
    font: 700 10px/1.4 var(--bm-font-mono);
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: var(--bm-text-soft);
  }
  .history-table tbody th,
  .history-table .history-time {
    min-width: 0;
  }
  .history-table .history-kind {
    white-space: normal;
  }
  .history-table td.history-actions {
    display: block;
    width: auto;
    padding-top: 6px;
    text-align: left;
  }
  .history-table td.history-actions::before {
    display: none;
  }
  .history-actions .link-button {
    margin-left: -4px;
  }
  .danger-zone .danger {
    justify-self: stretch;
  }
  /* What a phone opens most comes first; the defaults for new numbers after. */
  #agents-entry {
    order: 0;
  }
  #stats-entry {
    order: 1;
  }
  #journal-entry {
    order: 2;
  }
  #files-form {
    order: 3;
  }
  #defaults-form {
    order: 4;
  }
  #session-entry {
    order: 5;
  }
  #erase-form {
    order: 6;
  }

  /* The queue is part of the page: it grows with its chats and the page
     scrolls. Only an open chat keeps a fixed height, so its composer stays at
     the bottom. */
  /* Edge to edge, as a messenger list: every pixel goes to names. */
  .inbox-grid {
    display: flex;
    height: auto;
    min-height: 0;
    overflow: visible;
    margin: 0 calc(-1 * var(--tb-gutter));
    border-width: 0 0 1px;
    border-radius: 0;
    box-shadow: none;
  }
  .workspace[data-view='queue'] {
    padding-top: 0;
  }
  .workspace[data-view='queue'] .alerts:not(:empty) {
    margin-top: 12px;
  }
  .chat-list {
    padding: 4px 4px 6px;
  }
  .chat-row {
    gap: 12px;
    padding: 10px;
    border-radius: var(--bm-radius-md);
  }
  .chat-row:active {
    background: color-mix(in srgb, var(--bm-text) 8%, transparent);
  }
  .chat-panel,
  .thread-panel {
    flex: 1;
    border-right: 0;
  }
  .chat-list {
    overflow: visible;
    flex: none;
  }
  .panel-heading {
    padding: 14px 12px 10px;
  }
  #thread-empty {
    display: none;
  }
  .inbox-grid[data-thread='open'] .chat-panel {
    display: none;
  }
  .workspace[data-thread='open'] {
    padding: 0;
  }
  .workspace[data-thread='open'] .views,
  .workspace[data-thread='open'] .alerts {
    display: none;
  }
  /* The open chat covers the screen and follows the visual viewport, so the
     composer sits on the keyboard and nothing behind it scrolls. */
  html[data-thread='open'],
  html[data-thread='open'] body {
    overflow: hidden;
  }
  .workspace[data-thread='open'] .inbox-grid {
    position: fixed;
    top: var(--tb-vvtop, 0px);
    left: 0;
    right: 0;
    z-index: 40;
    height: var(--tb-vvh, 100dvh);
    min-height: 0;
    overflow: hidden;
    margin: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
  /* One row: back, who, number, menu. */
  .thread-header {
    position: relative;
    flex-wrap: nowrap;
    gap: 2px;
    min-height: 56px;
    padding: max(6px, env(safe-area-inset-top))
      max(4px, env(safe-area-inset-right)) 6px
      max(2px, env(safe-area-inset-left));
    background: var(--bm-surface);
  }
  .back,
  .thread-more {
    display: inline-flex;
    flex: 0 0 auto;
    border-color: transparent;
    background: transparent;
  }
  .back {
    order: -1;
  }
  .thread-heading {
    flex: 1 1 0;
    gap: 10px;
  }
  .thread-header .avatar {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }
  .thread-header h2 {
    font-size: var(--tb-type-body-size);
  }
  .thread-sender {
    flex-wrap: nowrap;
    gap: 6px;
    margin-top: 1px;
    overflow: hidden;
  }
  /* The glyph alone says the channel; the name stays for screen readers. */
  .thread-channel > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .thread-sender .tag {
    /* Down to a few letters beside a word of trouble, never to its dot. */
    min-width: min(100%, 56px);
    overflow: hidden;
    text-overflow: ellipsis;
  }
  .thread-sender .badge {
    flex: 0 0 auto;
  }
  .thread-menu {
    position: absolute;
    top: calc(100% - 6px);
    right: max(8px, env(safe-area-inset-right));
    z-index: 5;
    display: none;
    flex-direction: column;
    min-width: 236px;
    padding: 5px 0;
    border: 1px solid var(--bm-border-strong);
    border-radius: var(--bm-radius-md);
    background: var(--bm-surface);
    box-shadow: var(--bm-shadow-md);
  }
  .thread-header[data-menu='open'] .thread-menu {
    display: flex;
  }
  .menu-item,
  .thread-menu #history-reread,
  .thread-menu #send-permission {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 46px;
    padding: 0 16px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--bm-text);
    font-size: 15px;
    font-weight: 500;
    text-align: left;
    translate: none;
  }
  .menu-item:active,
  .menu-item:hover,
  .thread-menu #history-reread:not(:disabled):active,
  .thread-menu #history-reread:not(:disabled):hover,
  .thread-menu #send-permission:not(:disabled):active,
  .thread-menu #send-permission:not(:disabled):hover {
    background: color-mix(in srgb, var(--bm-text) 7%, var(--bm-surface));
  }
  .thread-menu #history-reread,
  .thread-menu #send-permission {
    border-top: 1px solid var(--bm-border);
  }
  .thread-facts,
  .search-form {
    display: none;
  }
  #thread[data-info='open'] .thread-facts {
    display: grid;
    padding: 8px 14px;
  }
  #thread[data-search='open'] .search-form {
    display: flex;
    padding: 6px 10px;
  }
  .message-scroll {
    padding-top: 4px;
    padding-bottom: 12px;
  }
  .bubble {
    max-width: 86%;
  }

  .thread-drafts:not(:empty) {
    max-height: 55%;
    padding: 8px 10px;
  }
  /* Composer: one row; its label is read aloud, the field names the number. */
  .send-form {
    gap: 4px;
    padding: 6px max(8px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }
  html[data-keyboard='open'] .send-form {
    padding-bottom: 6px;
  }
  @media (max-width: 360px) {
    .views button {
      font-size: 10px;
      letter-spacing: -0.01em;
    }
    .chat-row {
      gap: 10px;
      padding: 10px 8px;
    }
    .chat-row .avatar {
      width: 40px;
      height: 40px;
      font-size: 15px;
    }
  }
  /* The keyboard is up: the tab bar steps aside. */
  html[data-typing='on'] .views {
    display: none;
  }
  .send-label {
    display: none;
  }
  .send-button {
    width: var(--tb-control-h);
    padding: 0;
    border-radius: 50%;
    border-bottom-width: 1px;
  }
  .composer textarea {
    border-radius: 22px;
  }
  .composer {
    gap: 6px;
  }
  .composer-file-thumb {
    width: 48px;
    height: 48px;
  }
}

/* ---- operator page (admin.html); styled by its own sheet ------------------------ */
.admin-page {
  display: grid;
  gap: 24px;
  max-width: 720px;
}
.admin-page section {
  display: grid;
  gap: 12px;
  margin-bottom: 24px;
}
.admin-row {
  display: grid;
  gap: 8px;
}
.admin-link {
  display: block;
  margin-top: 6px;
  overflow-wrap: anywhere;
  user-select: all;
  font: 13px var(--bm-font-mono);
}
.card-list {
  display: grid;
  gap: 10px;
}
.card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

/* ---- drafts: selection, bulk bar, confirmation ------------------------------
   The bar is the kit's floating action surface: 18px corners like the shell,
   12px cards inside it, 8px controls. Brass stays a fill; edges and marks use
   the accent ink. Every movement is a short fade/slide, off with reduced motion. */
.drafts-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
  padding: 8px 14px;
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-surface);
}
.drafts-tools[hidden],
.quick-picks[hidden] {
  display: none;
}
.pick-all {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  min-height: 44px;
  font-weight: 600;
  cursor: pointer;
}
/* Quick picks in three labelled groups: numbers, agents, kinds. */
.quick-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 18px;
  min-width: 0;
}
.quick-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-width: 0;
  max-width: 100%;
}
.quick-label {
  color: var(--bm-text-soft);
  font: 600 11px/1.35 var(--bm-font-mono);
  letter-spacing: 0.09em;
  text-transform: uppercase;
}
.quick-pick {
  flex: 0 1 auto;
  max-width: 220px;
}
.quick-pick .quick-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.quick-pick .count {
  background: var(--bm-raised);
}
.quick-pick[aria-pressed='true'] .count {
  background: color-mix(in srgb, var(--bm-on-inverse) 18%, var(--bm-inverse));
  color: var(--bm-on-inverse);
}
/* A number's chip carries its identity dot. */
.quick-pick[data-hue]::before {
  content: '';
  flex: 0 0 auto;
  width: 7px;
  height: 7px;
  border-radius: 50%;
}
/* Indeterminate («some picked»): the brass fill with a dash. */
input[type='checkbox']:not(.switch):indeterminate {
  border-color: var(--bm-accent-ink);
  background: var(--bm-accent);
}
input[type='checkbox']:not(.switch):indeterminate::after {
  width: 10px;
  height: 0;
  border-width: 0 0 2.5px;
  rotate: 0deg;
  translate: 0 0;
  opacity: 1;
}

.draft-top {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.draft-top .card-head {
  flex: 1 1 auto;
  min-width: 0;
}
.draft-pick {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin: -12px 0 -12px -12px;
  cursor: pointer;
}
.draft-pick[hidden],
.draft-edited[hidden] {
  display: none;
}
.draft-edited {
  flex: 0 0 auto;
}
.draft-card {
  transition:
    border-color var(--bm-dur-fast) var(--bm-ease-standard),
    background-color var(--bm-dur-fast) var(--bm-ease-standard),
    opacity var(--bm-dur-base) var(--bm-ease-standard);
}
.draft-card[data-picked='true'] {
  border-color: var(--bm-accent-ink);
  background: var(--bm-wash-accent);
  box-shadow:
    0 0 0 1px var(--bm-accent-ink),
    var(--bm-shadow-xs);
}
.draft-card[data-busy='true'] {
  opacity: 0.82;
}
/* Decided in a batch: the card stays until «Готово» and only reports. */
.draft-card[data-done='true'] {
  border-left-color: var(--bm-border-strong);
  background: var(--bm-surface);
}
.draft-card[data-done='true'] .draft-read {
  color: var(--bm-text-soft);
}
.draft-card[data-done='true'] .draft-tools {
  display: none;
}
/* Ended while the owner had an edit: the card keeps the text to copy. */
.draft-card[data-gone='true'] {
  border-left-color: var(--bm-border-strong);
}
.draft-card[data-gone='true']
  > :is(
    .draft-when,
    .draft-first,
    .draft-twin,
    .draft-notice,
    .status-message
  ) {
  display: none;
}
.draft-first,
.draft-twin {
  color: var(--bm-text-soft);
  font-size: 14px;
  line-height: 1.4;
}
.draft-first strong {
  color: var(--bm-caution-ink);
  font-weight: 600;
}
.draft-notice {
  padding: 9px 12px;
  border: 1px solid color-mix(in srgb, var(--bm-caution-ink) 34%, transparent);
  border-radius: var(--bm-radius-md);
  background: color-mix(in srgb, var(--bm-caution) 10%, var(--bm-surface));
  color: var(--bm-text);
  font-size: 14px;
  line-height: 1.4;
}
.draft-notice[hidden],
.draft-outcome[hidden] {
  display: none;
}
.draft-outcome {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
  font-size: 14px;
  line-height: 1.4;
}
.draft-outcome-text {
  color: var(--bm-text-soft);
}
.draft-outcome[data-tone='failed'] .draft-outcome-text {
  color: var(--bm-warn-ink);
}
.badge[data-state='pending'] {
  color: var(--bm-pending-ink);
}
.badge[data-state='failed'] {
  color: var(--bm-warn-ink);
}
.badge[data-state='muted'] {
  color: var(--bm-text-soft);
}
.drafts-empty[hidden] {
  display: none;
}
.drafts-empty {
  padding: 18px 16px;
  border: 1px dashed var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
}

.bulk-bar {
  position: sticky;
  bottom: 16px;
  z-index: 15;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px 20px;
  padding: 14px 14px 14px 18px;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-xl);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-lg);
  opacity: 0;
  translate: 0 12px;
  transition:
    opacity var(--bm-dur-moderate) var(--bm-ease-out),
    translate var(--bm-dur-moderate) var(--bm-ease-out);
}
.bulk-bar[hidden] {
  display: none;
}
/* Focus rests here while a batch runs; the live title speaks for it. */
.bulk-bar:focus {
  outline: none;
  box-shadow: var(--bm-shadow-lg);
}
.bulk-bar[data-shown] {
  opacity: 1;
  translate: 0 0;
}
.bulk-summary {
  display: grid;
  gap: 6px;
  min-width: 0;
  flex: 1 1 auto;
}
.bulk-title {
  font: 700 16px/1.3 var(--bm-font-display);
  letter-spacing: -0.01em;
}
.bulk-lines {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
  color: var(--bm-text-soft);
  font-size: 14px;
  line-height: 1.4;
}
.bulk-lines[hidden] {
  display: none;
}
.bulk-lines li {
  min-width: 0;
}
.bulk-lines .tag {
  margin-right: 2px;
  vertical-align: 1px;
}
.bulk-stay,
.bulk-stay-head {
  color: var(--bm-caution-ink);
}
.bulk-stay-head {
  font-weight: 600;
}
.bulk-failed {
  color: var(--bm-warn-ink);
}
.bulk-progress {
  max-width: 420px;
}
.bulk-progress[hidden] {
  display: none;
}
.bulk-progress .meter-fill {
  width: var(--bulk-done, 0%);
  transition: width var(--bm-dur-moderate) var(--bm-ease-out);
}
.bulk-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  flex: 0 0 auto;
}
.bulk-actions .button[hidden] {
  display: none;
}
.bulk-n {
  font-variant-numeric: tabular-nums;
}
@media (max-width: 1179px) and (min-width: 621px) {
  .bulk-bar {
    flex-direction: column;
    align-items: stretch;
  }
}

/* Confirmation (BmModal): centred, 12px corners, scrim; on a phone the
   kit's bottom sheet (BmSheet) with the select's grab handle. */
html[data-dialog] body {
  overflow: hidden;
}
.dialog-scrim {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 16px;
  background: var(--bm-scrim);
  opacity: 0;
  transition: opacity var(--bm-dur-moderate) var(--bm-ease-out);
}
.dialog-scrim[data-shown] {
  opacity: 1;
}
.dialog {
  display: flex;
  flex-direction: column;
  width: min(100%, 500px);
  max-height: 92dvh;
  overflow: hidden;
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-lg);
  translate: 0 8px;
  transition: translate var(--bm-dur-moderate) var(--bm-ease-out);
}
.dialog-scrim[data-shown] .dialog {
  translate: 0 0;
}
.dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 12px 12px 18px;
  border-bottom: 1px solid var(--bm-border);
}
.dialog-title {
  margin: 0;
  font: 700 16px/1.3 var(--bm-font-display);
  letter-spacing: -0.015em;
}
.dialog-close {
  flex: 0 0 auto;
  border-color: transparent;
}
.dialog-body {
  display: grid;
  /* An auto column grows to the longest unbroken label. */
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  font-size: 14px;
  line-height: 1.45;
}
.dialog-numbers {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.dialog-number {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
  padding: 12px 14px;
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius-md);
  background: var(--bm-bg);
}
.dialog-number-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 10px;
}
.dialog-number .muted,
.dialog-number .bulk-stay {
  font-size: 13px;
}
.dialog-ack {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr);
  align-items: start;
  gap: 12px;
  padding: 12px 14px;
  border: 1px solid color-mix(in srgb, var(--bm-caution-ink) 34%, transparent);
  border-radius: var(--bm-radius-md);
  background: color-mix(in srgb, var(--bm-caution) 10%, var(--bm-surface));
  cursor: pointer;
}
.dialog-ack input {
  margin-top: 1px;
}
.dialog-ack strong {
  display: block;
  margin-bottom: 2px;
}
.dialog-ack .muted {
  font-size: 13px;
}
.dialog-foot {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 14px 18px;
  border-top: 1px solid var(--bm-border);
}
.dialog[data-mode='sheet'] {
  width: 100%;
  max-height: 88dvh;
  border-width: 1px 0 0;
  border-radius: var(--bm-radius-xl) var(--bm-radius-xl) 0 0;
  translate: 0 32px;
}
.dialog-scrim:has(.dialog[data-mode='sheet']) {
  place-items: end stretch;
  padding: 0;
}
.dialog[data-mode='sheet']::before {
  content: '';
  flex: 0 0 auto;
  align-self: center;
  width: 40px;
  height: 4px;
  margin: 10px 0 2px;
  border-radius: var(--bm-radius-pill);
  background: var(--bm-border-strong);
}
.dialog[data-mode='sheet'] .dialog-head {
  padding: 4px 8px 10px 18px;
}
.dialog[data-mode='sheet'] .dialog-foot {
  padding: 12px max(16px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.dialog[data-mode='sheet'] .dialog-foot .button {
  flex: 1 1 0;
  min-height: 48px;
}

.limit-field {
  gap: 6px;
}
.limit-field + .limit-field {
  margin-top: 8px;
}
.field-error {
  color: var(--bm-warn-ink);
  font-size: 13px;
  font-weight: 500;
}
.field-error[hidden] {
  display: none;
}

@media (max-width: 620px), (max-height: 500px) and (pointer: coarse) {
  .drafts-tools {
    gap: 6px 14px;
    padding: 4px 12px 10px;
  }
  .pick-all {
    flex: 0 0 auto;
  }
  /* Above the thumb bar and the home indicator. */
  .bulk-bar {
    bottom: calc(76px + env(safe-area-inset-bottom));
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
    padding: 12px;
    border-radius: var(--bm-radius-lg);
  }
  /* While picking, the sheet tells the details; the bar stays short. */
  .bulk-bar[data-mode='select'] .bulk-lines {
    display: none;
  }
  .bulk-title {
    font-size: 15px;
  }
  .bulk-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .bulk-actions .button {
    min-height: 48px;
    padding: 0 10px;
    white-space: normal;
    text-align: center;
    line-height: 1.2;
  }
  .bulk-actions .primary {
    grid-column: 1 / -1;
  }
  .bulk-actions .button:only-of-type,
  .bulk-bar[data-mode='done'] .bulk-actions .button {
    grid-column: 1 / -1;
  }
}

/* Wide screens: the chat header is one calm row, as on a phone. The number is
   named once in the header and once in the field; search, chat facts and the
   rarely used actions live in the menu. */
@media (min-width: 621px) {
  .thread-header {
    position: relative;
  }
  .thread-sender {
    flex-wrap: nowrap;
    overflow: hidden;
  }
  /* What gives way when the row is short, in this order: the channel's
     word, whole (the page takes it out when the row overflows; the glyph
     stays and the name is still there for screen readers), then the
     account's name, down to a few letters and never to its dot alone. The
     word of trouble is never cut. */
  .thread-sender .thread-channel {
    flex: 0 0 auto;
  }
  .thread-sender.tight .thread-channel > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }
  .thread-sender .tag {
    flex: 0 1 auto;
    min-width: min(100%, 56px);
  }
  .thread-sender .badge {
    flex: 0 0 auto;
  }
  .thread-more {
    display: inline-flex;
    flex: 0 0 auto;
  }
  .thread-menu {
    position: absolute;
    top: calc(100% - 6px);
    right: 16px;
    z-index: 5;
    display: none;
    flex-direction: column;
    min-width: 260px;
    padding: 5px 0;
    border: 1px solid var(--bm-border-strong);
    border-radius: var(--bm-radius-md);
    background: var(--bm-surface);
    box-shadow: var(--bm-shadow-md);
  }
  .thread-header[data-menu='open'] .thread-menu {
    display: flex;
  }
  .menu-item,
  .thread-menu #history-reread,
  .thread-menu #send-permission {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 100%;
    min-height: 40px;
    padding: 0 16px;
    border: 0;
    border-radius: 0;
    background: transparent;
    color: var(--bm-text);
    font: inherit;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 0;
    text-align: left;
    text-transform: none;
    translate: none;
  }
  .menu-item:hover,
  .thread-menu #history-reread:not(:disabled):hover,
  .thread-menu #send-permission:not(:disabled):hover {
    background: color-mix(in srgb, var(--bm-text) 7%, var(--bm-surface));
  }
  .thread-menu #history-reread,
  .thread-menu #send-permission {
    border-top: 1px solid var(--bm-border);
  }
  .thread-facts,
  .search-form {
    display: none;
  }
  #thread[data-info='open'] .thread-facts {
    display: grid;
  }
  #thread[data-search='open'] .search-form {
    display: flex;
  }
}

/* ---- scheduled sending (docs/SCHEDULED.md) ----------------------------------- */
/* «Отправить» and the clock are one split control: a long press on the send
   part or a tap on the clock part opens the time picker. */
.send-split {
  display: inline-flex;
  flex: 0 0 auto;
}
.send-split .send-button {
  border-right-width: 0;
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
  /* A long press opens the picker, never the system's callout or selection. */
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}
.schedule-button {
  width: 40px;
  padding: 0;
  border-left: 1px solid
    color-mix(in srgb, var(--bm-brass-deep) 70%, var(--bm-accent));
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
}
/* Armed: the clock part stays pressed. */
.send-split[data-armed='true'] .schedule-button {
  background: color-mix(in srgb, var(--bm-brass-deep) 30%, var(--bm-accent));
  box-shadow: inset 0 2px 3px
    color-mix(in srgb, var(--bm-on-accent) 22%, transparent);
}
.send-split[data-armed='true'] .schedule-button:focus-visible {
  box-shadow: var(--tb-ring);
}
/* One line above the composer while armed: when it goes, and ✕. */
.schedule-armed {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  min-width: 0;
}
.schedule-armed-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  min-height: 40px;
  padding: 0 8px 0 4px;
  border: 0;
  border-radius: var(--bm-radius-md);
  background: transparent;
  color: var(--bm-accent-ink);
  font: 600 14px/1.3 var(--bm-font-body);
  text-align: left;
}
.schedule-armed-text span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.schedule-armed-text[data-tone='warn'] {
  color: var(--bm-warn-ink);
}
.schedule-armed-text:not(:disabled):hover span {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.button.schedule-disarm {
  width: 40px;
  min-height: 40px;
  border-color: transparent;
  color: var(--bm-text-soft);
}

/* The popover: the time picker and the menu of a scheduled message. */
.pop {
  position: fixed;
  z-index: var(--bm-z-dropdown);
  display: grid;
  min-width: 220px;
  max-width: calc(100vw - 16px);
  padding: 6px 0;
  border: 1px solid var(--bm-border-strong);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-surface);
  box-shadow: var(--bm-shadow-md);
  color: var(--bm-text);
}
.pop-title {
  padding: 4px 14px 6px;
  color: var(--bm-text-soft);
  font: 600 11px/1.6 var(--bm-font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.pop-list {
  display: grid;
}
.pop-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: 100%;
  min-height: 40px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  color: var(--bm-text);
  font: 500 14px/1.3 var(--bm-font-body);
  text-align: left;
  white-space: nowrap;
  cursor: pointer;
}
.pop-item:hover,
.pop-item:focus-visible {
  background: color-mix(in srgb, var(--bm-text) 8%, var(--bm-surface));
}
.pop-item:focus-visible {
  box-shadow: inset 3px 0 0 var(--bm-focus);
}
.pop-item.danger {
  color: var(--bm-warn-ink);
}
.pop-aside {
  color: var(--bm-text-soft);
  font: 600 12px var(--bm-font-mono);
}
.pop-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 6px 8px;
  padding: 4px 10px 6px;
}
.pop-form input {
  min-width: 0;
  min-height: 40px;
}
.pop-form .button.small {
  min-height: 40px;
}
.pop-error {
  grid-column: 1 / -1;
  max-width: 260px;
  color: var(--bm-warn-ink);
  font-size: 13px;
  white-space: normal;
}
.pop-error:empty {
  display: none;
}

/* A scheduled message at the foot of the chat: an outgoing bubble with a
   dashed edge and its time under a clock; one that did not go says why. */
.sched-day {
  margin-top: 16px;
}
.bubble.scheduled {
  display: grid;
  gap: 2px;
  min-width: 140px;
  padding-bottom: 2px;
  background: color-mix(in srgb, var(--tb-bubble-out) 55%, var(--bm-surface));
  box-shadow: inset 0 0 0 1px
    color-mix(in srgb, var(--bm-accent-ink) 45%, transparent);
  color: var(--bm-text);
  cursor: default;
}
.bubble.scheduled + .bubble.scheduled {
  margin-top: 4px;
}
.bubble.scheduled:hover {
  background: color-mix(in srgb, var(--tb-bubble-out) 80%, var(--bm-surface));
}
.bubble.scheduled:focus-within {
  box-shadow: inset 0 0 0 1px var(--bm-accent-ink);
}
.bubble.scheduled[data-state='held'],
.bubble.scheduled[data-state='missed'] {
  box-shadow: inset 0 0 0 1px
    color-mix(in srgb, var(--bm-warn-ink) 55%, transparent);
}
.bubble.scheduled[aria-busy='true'] {
  opacity: 0.6;
  cursor: progress;
}
.bubble.scheduled .text {
  display: block;
}
.sched-file,
.sched-quote {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--bm-text-soft);
  font-size: 13px;
}
.sched-file span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.sched-note {
  display: flex;
  align-items: flex-start;
  gap: 5px;
  color: var(--bm-warn-ink);
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}
.sched-note svg {
  flex: none;
  margin-top: 2px;
}
.bubble.scheduled .sched-note:not(:has(svg)) {
  color: var(--bm-text-soft);
  font-weight: 500;
}
.sched-meta {
  display: inline-flex;
  align-items: center;
  justify-self: end;
  gap: 4px;
  max-width: 100%;
  min-width: 0;
  color: var(--bm-accent-ink);
  font: 600 12px/1.4 var(--bm-font-mono);
  white-space: nowrap;
}
.sched-meta svg {
  flex: none;
}
.sched-who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--bm-text-soft);
  font: 600 12px/1.4 var(--bm-font-body);
}
/* ⋮ on the time line: the bubble's actions by keyboard; a tap anywhere on
   the bubble that selects no text opens them too. */
.sched-dots {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 30px;
  margin: -2px 0;
  padding: 0;
  border: 0;
  border-radius: var(--bm-radius-md);
  background: transparent;
  color: var(--bm-text-soft);
  cursor: pointer;
}
.sched-dots:hover {
  background: color-mix(in srgb, var(--bm-text) 9%, transparent);
  color: var(--bm-text);
}
.bubble.scheduled[data-state='held'] .sched-meta,
.bubble.scheduled[data-state='missed'] .sched-meta {
  color: var(--bm-warn-ink);
}

/* A queue row: a clock while messages wait, a warning when one did not go. */
.chat-row-sched {
  display: inline-grid;
  color: var(--bm-accent-ink);
}
.chat-row-sched.attention {
  color: var(--bm-warn-ink);
}

/* «Черновики / Запланированные». */
.drafts-switch {
  justify-self: start;
  width: min(100%, 420px);
}
.drafts-switch button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 36px;
  padding: 0 8px;
}
.drafts-switch .count {
  line-height: 1.5;
}
#scheduled-count[data-attention='true'],
#drafts-count[data-attention='true'] {
  background: color-mix(in srgb, var(--bm-warn-ink) 16%, var(--bm-surface));
  color: var(--bm-warn-ink);
}
.drafts-pane {
  display: contents;
}
.scheduled-pane {
  display: grid;
  gap: 8px;
}
.sched-list {
  display: grid;
  gap: 6px;
}
.sched-row {
  display: flex;
  align-items: stretch;
  min-width: 0;
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius-lg);
  background: var(--bm-surface);
}
.sched-row[data-state='held'],
.sched-row[data-state='missed'] {
  border-color: color-mix(in srgb, var(--bm-warn-ink) 45%, var(--bm-border));
}
.sched-row[aria-busy='true'] {
  opacity: 0.6;
}
.sched-open {
  display: grid;
  flex: 1 1 auto;
  gap: 2px;
  min-width: 0;
  padding: 9px 4px 9px 14px;
  border: 0;
  border-radius: var(--bm-radius-lg) 0 0 var(--bm-radius-lg);
  background: transparent;
  color: var(--bm-text);
  font: inherit;
  text-align: left;
}
.sched-open:hover {
  background: color-mix(in srgb, var(--bm-text) 4%, transparent);
}
.sched-head {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.sched-head strong {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: 15px;
}
.sched-head .tag {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 40%;
  white-space: nowrap;
}
.sched-when {
  flex: none;
  margin-left: auto;
  color: var(--bm-accent-ink);
  font: 600 12px var(--bm-font-mono);
  white-space: nowrap;
}
.sched-row[data-state='held'] .sched-when,
.sched-row[data-state='missed'] .sched-when {
  color: var(--bm-warn-ink);
}
.sched-preview {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--bm-text-soft);
  font-size: 14px;
}
.sched-foot {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  color: var(--bm-text-soft);
  font-size: 13px;
}
.sched-foot.attention {
  color: var(--bm-warn-ink);
  font-weight: 600;
}
.sched-foot svg {
  flex: none;
}
.sched-foot span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.button.sched-more {
  flex: none;
  align-self: center;
  width: 40px;
  min-height: 40px;
  margin-right: 4px;
  border-color: transparent;
  color: var(--bm-text-soft);
}
/* The narrow send button (icon only) says the armed time itself. */
.send-time {
  display: none;
}
/* A dated draft says when it will go. */
.draft-when {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--bm-accent-ink);
  font-size: 14px;
  font-weight: 600;
}
.draft-when[data-tone='warn'] {
  color: var(--bm-warn-ink);
}

@media (max-width: 840px) and (min-width: 621px) {
  .send-split .send-button {
    width: var(--tb-control-h);
  }
}
@media (max-width: 840px), (max-height: 500px) and (pointer: coarse) {
  .send-split[data-armed='true'] .send-button {
    width: auto;
    padding: 0 12px 0 10px;
    gap: 5px;
  }
  .send-split[data-armed='true'] .send-time {
    display: inline;
    font: 700 13px/1 var(--bm-font-mono);
    white-space: nowrap;
  }
}
@media (max-width: 620px), (max-height: 500px) and (pointer: coarse) {
  .send-split .send-button {
    border-radius: 22px 0 0 22px;
  }
  .schedule-button {
    border-radius: 0 22px 22px 0;
    border-bottom-width: 1px;
  }
  .pop-item {
    min-height: 44px;
    font-size: 15px;
  }
  .drafts-switch {
    width: 100%;
  }
  .sched-open {
    gap: 1px;
    padding: 7px 2px 7px 12px;
  }
  .sched-head .tag {
    max-width: 30%;
  }
}
@media (pointer: coarse) {
  .drafts-switch button {
    min-height: 40px;
  }
  .schedule-armed-text,
  .button.schedule-disarm,
  .button.sched-more {
    min-height: 44px;
  }
}

/* ---- a draft's text: read first, edited on demand --------------------------
   The text as it would go, at a reading measure, with its line breaks and
   links; a long one folds to about eight lines behind «Показать полностью».
   «Изменить» opens a short text in place, in a field that grows with it,
   and a long one in the roomy editor (docs/SENDING.md, «Правка черновика»). */
.draft-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}
.draft-read {
  max-width: 68ch;
  font-size: 15px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.draft-read[hidden],
.draft-more[hidden],
.draft-tools [hidden],
.draft-conflict[hidden],
.draft-problem[hidden],
.draft-count[hidden],
.text-editor-banner[hidden],
.text-editor-problem[hidden],
.text-editor-original[hidden] {
  display: none;
}
.draft-read a {
  color: var(--bm-accent-ink);
  text-decoration: underline;
  text-underline-offset: 2px;
}
.draft-read[data-folded='true'] {
  max-height: calc(8 * 1.5em);
  overflow: hidden;
  mask-image: linear-gradient(
    to bottom,
    currentColor calc(100% - 3em),
    transparent
  );
}
.draft-more {
  min-height: 32px;
  font-size: 14px;
}
.draft-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
}
.draft-edit-button {
  gap: 6px;
  min-height: 36px;
  padding: 0 12px;
  font-size: 14px;
}
.draft-tools .link-button {
  min-height: 36px;
  font-size: 14px;
}
.draft-fold {
  margin-left: auto;
}
.draft-field {
  max-width: 68ch;
  min-height: calc(1.5em + 22px);
  font-size: 15px;
  line-height: 1.5;
  resize: none;
}
.draft-field[data-capped='true'] {
  resize: vertical;
}
/* 16px on a phone like every field there: a smaller one makes iOS Safari
   zoom the page when it takes focus. */
@media (max-width: 620px), (max-height: 500px) and (pointer: coarse) {
  .draft-field {
    font-size: 16px;
  }
}
.draft-inline {
  display: grid;
  gap: 4px;
  max-width: 68ch;
}
.draft-inline-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 4px 10px;
}
.draft-inline-tools .link-button,
.draft-inline-tools .button {
  min-height: 36px;
  font-size: 14px;
}
.draft-count,
.text-editor-count {
  margin-right: auto;
  color: var(--bm-text-soft);
  font: 500 12px/1.4 var(--bm-font-mono);
  font-variant-numeric: tabular-nums;
}
.draft-count[data-tone='warn'],
.text-editor-count[data-tone='warn'] {
  color: var(--bm-warn-ink);
  font-weight: 700;
}
.text-editor-count[data-tone='near'] {
  color: var(--bm-caution-ink);
}
.draft-subject {
  min-width: 0;
  font-size: 14px;
  overflow-wrap: anywhere;
}
.draft-problem {
  color: var(--bm-warn-ink);
  font-size: 14px;
  line-height: 1.4;
}
/* An edit the draft outgrew: the agent changed the draft, or it ended. */
.draft-conflict {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--bm-caution-ink) 34%, transparent);
  border-radius: var(--bm-radius-md);
  background: color-mix(in srgb, var(--bm-caution) 10%, var(--bm-surface));
  font-size: 14px;
  line-height: 1.4;
}
.draft-conflict-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
}
.draft-conflict-actions .button {
  min-height: 36px;
  font-size: 14px;
}
/* Where a draft goes: to whom, about what, from which account, when. */
.draft-route {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: baseline;
  gap: 4px 14px;
  margin: 0;
  font-size: 14px;
  line-height: 1.4;
}
.draft-route dt {
  color: var(--bm-text-soft);
  font: 600 11px/1.75 var(--bm-font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.draft-route dd {
  min-width: 0;
  margin: 0;
  overflow-wrap: anywhere;
}
.draft-from {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
}

/* The roomy editor: wide on a desk, the whole screen on a phone. */
.text-editor {
  width: min(100%, 760px);
}
.text-editor[data-size='long'] {
  height: min(92dvh, 820px);
}
.text-editor-body {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.text-editor-body > * {
  flex: 0 0 auto;
}
.text-editor-body > .text-editor-field {
  flex: 1 1 auto;
  min-height: 160px;
  padding: 14px 16px;
  font-size: 16px;
  line-height: 1.55;
  resize: none;
}
.text-editor-below {
  display: flex;
  align-items: center;
  gap: 10px;
}
.text-editor-banner {
  padding: 10px 12px;
  border: 1px solid color-mix(in srgb, var(--bm-caution-ink) 34%, transparent);
  border-radius: var(--bm-radius-md);
  background: color-mix(in srgb, var(--bm-caution) 10%, var(--bm-surface));
  font-size: 14px;
}
.text-editor-banner[data-tone='warn'] {
  border-color: color-mix(in srgb, var(--bm-warn-ink) 40%, transparent);
  background: color-mix(in srgb, var(--bm-warn) 10%, var(--bm-surface));
}
.text-editor-problem {
  color: var(--bm-warn-ink);
  font-size: 14px;
}
.text-editor-original {
  border: 1px solid var(--bm-border);
  border-radius: var(--bm-radius-md);
  background: var(--bm-bg);
}
.text-editor-original summary {
  min-height: 40px;
  padding: 10px 12px;
  color: var(--bm-accent-ink);
  font-weight: 600;
  cursor: pointer;
}
.text-editor-original[open] {
  display: grid;
  gap: 10px;
  padding-bottom: 12px;
}
.text-editor-original[open] > :not(summary) {
  margin: 0 12px;
}
.text-editor-original .button {
  justify-self: start;
}
.text-editor-original-text {
  max-height: 30dvh;
  overflow-y: auto;
  color: var(--bm-text-soft);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.text-editor-foot {
  align-items: center;
}
.text-editor-hint {
  margin-right: auto;
  font-size: 13px;
}
.dialog-scrim:has(.text-editor[data-mode='full']) {
  place-items: start stretch;
  padding: 0;
}
.text-editor[data-mode='full'] {
  width: 100%;
  height: var(--tb-vvh, 100dvh);
  max-height: none;
  margin-top: var(--tb-vvtop, 0);
  border-width: 0;
  border-radius: 0;
  translate: 0 16px;
}
.text-editor[data-mode='full'] .dialog-head {
  padding-top: max(12px, env(safe-area-inset-top));
}
.text-editor[data-mode='full'] .dialog-body {
  padding: 14px 16px;
}
.text-editor[data-mode='full'] .text-editor-hint {
  display: none;
}
.text-editor[data-mode='full'] .dialog-foot {
  padding: 10px max(16px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}
.text-editor[data-mode='full'] .dialog-foot .button {
  flex: 1 1 0;
  min-height: 48px;
}

/* The notices on a narrow screen (notices.js): the distance from the bottom
   is measured there and already counts the home indicator. */
body .bm-toasts[data-placement='bottom'] {
  bottom: var(--bm-toast-inset);
}
