/* TeamCraft UI – design tokens first, then layout, then components.
   Colours are tokens so light/dark (and later per-instance branding) only touch the first block. */

:root {
  color-scheme: light;
  --font-ui: system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", sans-serif;
  --font-mono: ui-monospace, "SF Mono", "JetBrains Mono", "Cascadia Mono", Menlo, Consolas, monospace;

  --bg: #f5f5f5;
  --surface: #ffffff;
  --surface-2: #f0f0f0;
  --surface-3: #e6e6e6;
  --border: #dddddd;
  /* Edges of controls (fields, switches, checkboxes): 3:1 against the surface (WCAG 1.4.11), as
     Android's outline. --border stays for dividers and cards, which need no contrast. */
  --border-strong: #858585;
  --text: #1d1d1d;
  /* Secondary text (#725): 6.1:1 on --surface-3, the darkest surface it sits on. */
  --text-muted: #545454;
  --accent: #005dfc;
  --accent-strong: #004bd3;
  --on-accent: #ffffff;
  --accent-soft: #e3edff;
  --focus: #005dfc;
  --danger: #c0392b;
  --on-danger: #ffffff;
  --mention-bg: #fff2cc;
  --mention-text: #6a4b00;
  /* Code fills (#843): 1.2:1 against the surface so a code block reads as one; text on it 13:1. */
  --code-bg: #ebebeb;
  /* The emoji skin tones (the Fitzpatrick modifiers' usual colours, and the yellow default) for the
     picker's swatches: the same in light and dark, like the emoji they stand for. */
  --skin-tone-default: #ffcc4d;
  --skin-tone-light: #f7dece;
  --skin-tone-medium-light: #f3d2a2;
  --skin-tone-medium: #d5ab88;
  --skin-tone-medium-dark: #af7e57;
  --skin-tone-dark: #7c533e;
  --shadow: 0 8px 28px rgba(16, 24, 40, 0.18);

  /* The rail and the top bar: the theme's or brand's colour, with light text, in both modes. */
  --chrome: #111926;
  --chrome-text: #c6cfdd;
  --chrome-strong: #ffffff;
  /* The navigation colour of the theme or brand (brand key `sidebar`). In light mode the sidebar is
     a light tint of it, set off from the white content by a hairline; in dark mode it is the
     sidebar itself. Every text colour below reads at 4.5:1 on a tint of any colour. */
  --nav: #1a2434;
  --sb-tint: 8%;
  --sb-bg: color-mix(in srgb, var(--nav) var(--sb-tint), #ffffff);
  --sb-border: rgba(0, 0, 0, 0.08);
  --sb-text: #2c3038;
  --sb-strong: #141414;
  --sb-hover: rgba(0, 0, 0, 0.06);
  /* Quiet fills on the sidebar: chips, inputs, dividers. */
  --sb-fill: rgba(0, 0, 0, 0.05);
  --sb-fill-strong: rgba(0, 0, 0, 0.09);
  --sb-edge: rgba(0, 0, 0, 0.12);
  /* 3:1 against --sb-bg in both themes and 4.5:1 with white text. */
  --sb-current: #0064fc;
  --sb-muted: #4b515c;
  /* Muted channels: dimmer than --sb-muted but still 4.5:1 on --sb-bg; the bell-off icon says why. */
  --sb-dim: #5c626c;
  /* White text on it needs 4.5:1 (WCAG AA). */
  --badge-bg: #c8441d;
  /* The system red of Apple's badges (#715): the rail's space tiles. */
  --dock-red: #ff3b30;

  --lvl-debug: #7c8798;
  --lvl-info: #1b6fb4;
  --lvl-warn: #a86400;
  --lvl-error: #c0392b;
  /* The downloads button's bar (#153): a download that broke off, and one that just finished. Bright
     enough on the dark top bar and on the popover's surface alike. */
  --download-attention: #f2a900;
  --download-done: #30b64f;
  /* The progress in the top bar's dark chrome, in both themes. */
  --download-progress: #5c9dff;

  --online: #2eb67d;
  --away: #e8a317;
  /* A "favourite" star that is on: 3:1 on the surface (--away is 2.2:1 on white). */
  --star: #b07a00;
  --dnd: #e0463a;
  --offline: #8e8e8e;

  --rail-w: 72px;
  --sidebar-w: 264px;
  --panel-w: 400px;
  --topbar-h: 44px;

  /* Behind photos and videos while they load or letterbox, in both themes. */
  --media-backdrop: #000;

  /* One scale each for type, spacing and radii; new code uses these, not raw values.
     Type (issue #370) is in rem, so the browser's default size and the text size setting
     (--text-scale) scale it. Each size has its leading and tracking: large text tighter, small
     text a little looser. Spacing next to text is rem too, so rows grow with their text. */
  --text-scale: 1;
  --text-2xs: 0.6875rem;
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.875rem;
  --text-md: 0.9375rem;
  --text-lg: 1rem;
  --text-xl: 1.125rem;
  --text-2xl: 1.5rem;
  --leading-2xs: 1.35;
  --leading-xs: 1.4;
  --leading-sm: 1.45;
  --leading-base: 1.45;
  --leading-md: 1.45;
  --leading-lg: 1.35;
  --leading-xl: 1.3;
  --leading-2xl: 1.25;
  --tracking-2xs: 0.01em;
  --tracking-xs: 0.005em;
  --tracking-lg: -0.005em;
  --tracking-xl: -0.01em;
  --tracking-2xl: -0.015em;
  --weight-regular: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  --space-1: 0.25rem;
  --space-2: 0.5rem;
  --space-3: 0.75rem;
  --space-4: 1rem;
  --space-5: 1.25rem;
  --space-6: 1.5rem;
  --space-8: 2rem;
  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  /* The band of chrome colour right of and below the workspace card (020-shell.css). */
  --frame-gap: 6px;
  --radius-pill: 999px;

  /* Motion (issue #273): three durations and three curves. Only transform and opacity animate
     (the compositor runs them; layout never does). Reduced motion keeps short fades and drops the
     movement (the block below, and the one at the end of "Motion"). */
  --dur-fast: 120ms;
  --dur-base: 180ms;
  --dur-slow: 260ms;
  /* Exits are quicker than entrances: what leaves should get out of the way. */
  --dur-exit: 100ms;
  --ease-standard: cubic-bezier(0.2, 0, 0, 1);
  --ease-emphasized: cubic-bezier(0.05, 0.7, 0.1, 1);
  /* A strong ease-out, not an ease-in: what leaves moves fastest in the first frame, the one the
     eye is on, and is gone before an accelerating curve would have started. */
  --ease-exit: cubic-bezier(0.23, 1, 0.32, 1);
  /* A small overshoot for things that pop (reactions, badges). */
  --ease-pop: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: var(--ease-standard);
  --press-scale: 0.98;
  /* One focus ring everywhere (issue #362): an outline in --focus, never a box-shadow alone, so it
     stays 3:1 and forced-colours mode (which drops shadows) keeps it. */
  --focus-width: 2px;
  --focus-offset: 2px;
  --danger-soft: color-mix(in srgb, var(--danger) 9%, transparent);
  /* Text and marks on strong fills that stay dark in both themes (avatars, badges, the current
     sidebar row, call tiles, media overlays). */
  --on-fill: #ffffff;
  --warn-soft: #fde7d9;
  --warn-text: #8a3b0a;
  /* The call screen and the lightbox are dark in both themes. */
  --call-bg: #0d1118;
  --call-surface: #161c28;
  --call-border: #2c3548;
  --call-text: #e8ecf3;
  --call-muted: #9aa6ba;
  --call-danger: #d64533;
  --call-danger-hover: #a93226;
  /* A control on the call's surfaces under the pointer, and while pressed or open. */
  --call-hover: #202838;
  --call-pressed: #2a3446;
  --call-switch-off: #3a4458;
  /* Notices that a call is not end-to-end encrypted towards someone (the notetaker, e2ee.md §8.2). */
  --call-notice-bg: #3a2614;
  --call-notice-text: #ffc58f;
  --lightbox-bg: #0b0d12;
  --lightbox-tip-text: #111111;
  --call-surface-solid: #141a26;
  --lightbox-text: #f2f2f2;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.05), 0 16px 40px rgba(16, 24, 40, 0.1);
  /* Dialogs (#706): a raised panel on a dimming scrim. Depth comes from a hairline edge and a
     layered shadow (a tight contact shadow under a wide soft one); fields are filled, not boxed,
     and every control in a dialog shares one height and radius. */
  --scrim: rgba(8, 12, 20, 0.42);
  --dialog-surface: var(--surface);
  --dialog-edge: rgba(16, 24, 40, 0.07);
  --dialog-highlight: transparent;
  --dialog-shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 12px 24px -8px rgba(16, 24, 40, 0.16), 0 32px 72px -16px rgba(16, 24, 40, 0.28);
  --dialog-radius: 20px;
  --dialog-pad: var(--space-6);
  --field-bg: var(--surface-2);
  --field-bg-hover: var(--surface-3);
  --control-h: 2.5rem;
  --control-radius: 10px;
}

/* Reduced motion means gentler, not none (#360): fades that explain a change stay, a little
   shorter; nothing moves (see "Motion"). */
@media (prefers-reduced-motion: reduce) {
  :root {
    --dur-fast: 120ms;
    --dur-base: 150ms;
    --dur-slow: 150ms;
    --dur-exit: 100ms;
    --press-scale: 1;
  }
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #161616;
    --surface: #1e1e1e;
    --surface-2: #262626;
    --surface-3: #303030;
    --border: #363636;
    --border-strong: #7a7a7a;
    --text: #f5f5f5;
    --text-muted: #b0b0b0;
    --accent: #5c9dff;
    --accent-strong: #8ab8ff;
    --on-accent: #04122e;
    --accent-soft: #182a47;
    --focus: #8ab8ff;
    --danger: #ff7a6b;
    --dock-red: #ff453a;
    --warn-soft: #4a2a14;
    --warn-text: #ffb27a;
    --on-danger: #2a0905;
    --star: #e8a317;
    --mention-bg: #4a3b10;
    --mention-text: #ffd978;
    --code-bg: #2a2a2a;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
    --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px rgba(0, 0, 0, 0.45);
    /* A raised surface is lighter in the dark, and its top edge catches the light. */
    --scrim: rgba(0, 0, 0, 0.56);
    --dialog-surface: #252525;
    --dialog-edge: rgba(255, 255, 255, 0.08);
    --dialog-highlight: rgba(255, 255, 255, 0.06);
    --dialog-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 24px -8px rgba(0, 0, 0, 0.5), 0 32px 72px -16px rgba(0, 0, 0, 0.7);
    --field-bg: #2c2c2c;
    --field-bg-hover: #343434;
    --chrome: #101010;
    --nav: #141414;
    --sb-bg: var(--nav);
    --sb-border: transparent;
    --sb-text: #c6cfdd;
    --sb-strong: #ffffff;
    --sb-hover: rgba(255, 255, 255, 0.07);
    --sb-fill: rgba(255, 255, 255, 0.08);
    --sb-fill-strong: rgba(255, 255, 255, 0.14);
    --sb-edge: rgba(255, 255, 255, 0.14);
    --sb-current: #0064fc;
    --sb-muted: #9aa6ba;
    --sb-dim: #8d99ae;
    --lvl-debug: #8591a4;
    --lvl-info: #6db3f2;
    --lvl-warn: #f0b04a;
    --lvl-error: #ff8a7a;
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #161616;
  --surface: #1e1e1e;
  --surface-2: #262626;
  --surface-3: #303030;
  --border: #363636;
  --border-strong: #7a7a7a;
  --text: #f5f5f5;
  --text-muted: #b0b0b0;
  --accent: #5c9dff;
  --accent-strong: #8ab8ff;
  --on-accent: #04122e;
  --accent-soft: #182a47;
  --focus: #8ab8ff;
  --danger: #ff7a6b;
  --dock-red: #ff453a;
  --warn-soft: #4a2a14;
  --warn-text: #ffb27a;
  --on-danger: #2a0905;
  --star: #e8a317;
  --mention-bg: #4a3b10;
  --mention-text: #ffd978;
  --code-bg: #2a2a2a;
  --shadow: 0 8px 28px rgba(0, 0, 0, 0.55);
  --shadow-card: 0 1px 2px rgba(0, 0, 0, 0.3), 0 16px 40px rgba(0, 0, 0, 0.45);
  /* A raised surface is lighter in the dark, and its top edge catches the light. */
  --scrim: rgba(0, 0, 0, 0.56);
  --dialog-surface: #252525;
  --dialog-edge: rgba(255, 255, 255, 0.08);
  --dialog-highlight: rgba(255, 255, 255, 0.06);
  --dialog-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 12px 24px -8px rgba(0, 0, 0, 0.5), 0 32px 72px -16px rgba(0, 0, 0, 0.7);
  --field-bg: #2c2c2c;
  --field-bg-hover: #343434;
  --chrome: #101010;
  --nav: #141414;
  --sb-bg: var(--nav);
  --sb-border: transparent;
  --sb-text: #c6cfdd;
  --sb-strong: #ffffff;
  --sb-hover: rgba(255, 255, 255, 0.07);
  --sb-fill: rgba(255, 255, 255, 0.08);
  --sb-fill-strong: rgba(255, 255, 255, 0.14);
  --sb-edge: rgba(255, 255, 255, 0.14);
  --sb-current: #0064fc;
  --sb-muted: #9aa6ba;
  --sb-dim: #8d99ae;
  --lvl-debug: #8591a4;
  --lvl-info: #6db3f2;
  --lvl-warn: #f0b04a;
  --lvl-error: #ff8a7a;
}

/* ---- Base ---- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

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

/* The text size setting (issue #370) scales the root, and with it every rem. */
html {
  font-size: calc(100% * var(--text-scale));
}

body {
  background: var(--bg);
  color: var(--text);
  font: var(--text-base) / var(--leading-base) var(--font-ui);
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  overscroll-behavior: none;
}

button,
input,
select,
textarea {
  font: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

/* No grey or blue flash on tap; every control shows its own pressed state (#364). */
html {
  -webkit-tap-highlight-color: transparent;
}

/* Long-pressing a control or a row selects nothing and opens no callout; message text and inputs
   stay selectable. */
button,
[role="button"],
[role="tab"],
[role="menuitem"],
.sb-item,
.reaction,
.chip,
.home-chip {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button:disabled {
  cursor: default;
}

h1,
h2,
p,
ul {
  margin: 0;
  padding: 0;
}

ul {
  list-style: none;
}

kbd {
  font: var(--text-2xs) var(--font-mono);
  padding: 1px 5px;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: var(--radius-xs);
  background: var(--surface-2);
  color: var(--text-muted);
}

:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: var(--focus-offset);
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

.skip-link {
  position: fixed;
  left: 8px;
  top: -60px;
  z-index: 100;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
}

.skip-link:focus {
  top: 8px;
}

.grow {
  flex: 1;
  min-width: 0;
}

.muted-text {
  color: var(--text-muted);
}

.icon {
  flex: none;
}

/* ---- Shell layout ---- */

.app {
  display: grid;
  /* Banners (unsigned bundle, offline, announcement, update) share the first row; it is empty
     without them. The row below the top bar holds a first sync's progress, empty without one. */
  grid-template-rows: auto var(--topbar-h) auto minmax(0, 1fr);
  /* Without it the column grows to the content's minimum and the page scrolls sideways (~1100px). */
  grid-template-columns: minmax(0, 1fr);
  height: 100dvh;
}

.app-body {
  display: flex;
  min-height: 0;
}

/* The rail and the top bar frame the workspace: sidebar, messages and side panel lie on the chrome
   as one card, with a thin band of the chrome colour to the right and below and rounded outer
   corners (the sidebar's left ones, or the main area's in views without a sidebar; the last pane's
   right ones). Phones show one pane at a time, edge to edge. */
:root:not([data-layout="compact"]) .app-body {
  padding: 0 var(--frame-gap) var(--frame-gap) 0;
  background: var(--chrome);
}

:root:not([data-layout="compact"]) .app-body > .space-rail + :is(.sidebar, .main) {
  border-top-left-radius: var(--radius-md);
  border-bottom-left-radius: var(--radius-md);
}

:root:not([data-layout="compact"]) .app-body > :is(.main, .side-panel):last-child {
  border-top-right-radius: var(--radius-md);
  border-bottom-right-radius: var(--radius-md);
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  background: var(--surface);
  /* Takes focus only from code (tabindex -1, after navigation), never from Tab: no ring. */
  outline: none;
}

.top-bar {
  display: grid;
  grid-template-columns: minmax(var(--rail-w), auto) minmax(0, 1fr) auto;
  align-items: center;
  background: var(--chrome);
  color: var(--chrome-text);
  padding-right: 12px;
}

/* The search and, in the desktop app, back and forward to its left (#874): one centred group in the
   middle column. */
.top-nav {
  grid-column: 2;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: 8px;
  width: min(560px, 100%);
  min-width: 0;
}

.top-nav.has-history {
  width: min(632px, 100%);
}

.top-nav .search-field {
  flex: 1;
  width: auto;
  min-width: 0;
}

.top-bar .history-buttons {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
}

.top-bar .history-buttons .icon-btn:disabled {
  opacity: 0.35;
}

.top-bar .brand {
  /* As wide as it needs, up to the sidebar's width; long names end in an ellipsis. */
  display: flex;
  align-items: center;
  gap: 8px;
  grid-column: 1;
  min-width: 0;
  max-width: calc(var(--rail-w) + var(--sidebar-w));
  padding: 0 12px;
  color: var(--chrome-strong);
  text-decoration: none;
  cursor: pointer;
  align-self: stretch;
}

.top-bar .brand:focus-visible {
  outline: var(--focus-width) solid var(--chrome-strong);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* No `display` here: `.brand-light`/`.brand-dark` switch the theme's variant. */
.top-bar .brand-logo {
  height: 24px;
  max-width: 120px;
  object-fit: contain;
  flex: none;
}

.top-bar .brand-name {
  font-weight: var(--weight-semibold);
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
}

/* The global search (#724): a field with the open conversation as a scope chip (picture or glyph,
   name, x to search everywhere) before a plain placeholder and the shortcut. The button is the
   control; a press anywhere on the field opens the search too. */
.search-field {
  grid-column: 2;
  justify-self: center;
  width: min(560px, 100%);
  display: flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 0 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.07);
  color: var(--chrome-text);
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .search-field:hover {
    background: rgba(255, 255, 255, 0.12);
  }
}

.search-field-icon {
  flex: none;
  display: grid;
}

.search-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 100%;
  padding: 0 10px 0 2px;
  border: 0;
  border-radius: inherit;
  background: transparent;
  color: inherit;
  text-align: left;
}

/* The field shows its icon outside the button; a phone shows the button as the icon alone. */
.search-btn > .icon {
  display: none;
}

/* Only the label grows; the shortcut's own spans (`.shortcut`, `.shortcut-plus`) stay compact. */
.search-btn-label {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.search-btn kbd {
  background: transparent;
  color: inherit;
  border-color: rgba(255, 255, 255, 0.25);
  opacity: 0.8;
}

/* The scope: a small tinted capsule, the conversation's picture and name, a round x. */
.search-field-scope {
  flex: 0 1 auto;
  min-width: 0;
  max-width: 50%;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 20px;
  padding: 0 2px 0 3px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.14);
  color: var(--chrome-strong);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
  cursor: default;
}

.search-field-scope > .icon,
.search-field-scope > .channel-glyph,
.search-field-scope > .avatar {
  flex: none;
  width: 16px;
  height: 16px;
}

.search-field-scope > .icon {
  margin-left: 2px;
}

.search-field-scope > .avatar .avatar-initials {
  font-size: var(--text-2xs);
  transform: scale(0.65);
}

.search-field-scope-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Small to look at, a finger's size to hit: the ring around it takes the press too. */
.search-field-scope-clear {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 16px;
  height: 16px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  color: inherit;
}

.search-field-scope-clear::before {
  content: "";
  position: absolute;
  inset: -6px;
}

.search-field-scope-clear .icon {
  width: 10px;
  height: 10px;
}

@media (hover: hover) and (pointer: fine) {
  .search-field-scope-clear:hover {
    background: rgba(255, 255, 255, 0.3);
  }
}

.search-field-scope-clear:active {
  transform: scale(var(--press-scale));
}

.top-actions {
  grid-column: 3;
  display: flex;
  align-items: center;
  gap: 8px;
}

.account {
  position: relative;
}

.avatar-btn {
  background: none;
  border: 0;
  padding: 2px;
  border-radius: 50%;
  display: block;
}

/* ---- Generic controls ---- */

.icon-btn {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn:hover:not(:disabled) {
    background: var(--surface-3);
    color: var(--text);
  }
}

.icon-btn.on-dark {
  color: var(--chrome-text);
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn.on-dark:hover {
    background: rgba(255, 255, 255, 0.12);
    color: var(--on-fill);
  }
}

.icon-btn-small {
  width: 22px;
  height: 22px;
}

.icon-btn[aria-pressed="true"] .icon {
  color: var(--star);
  fill: currentColor;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

@media (hover: hover) and (pointer: fine) {
  .btn:hover {
    background: var(--surface-2);
  }
}

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--on-accent);
  font-weight: var(--weight-semibold);
}

/* Hover and press only change the fill: the label stays `--on-accent`, at least 4.5:1 on both
   fills in light and dark. A container that restyles its buttons leaves `.btn-primary` out
   (`:not(.btn-primary)`), or its states would win over these (#1953). */
@media (hover: hover) and (pointer: fine) {
  .btn-primary:hover:not(:disabled) {
    background: var(--accent-strong);
    border-color: var(--accent-strong);
  }
}

.btn-primary:active:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn-quiet {
  border-color: transparent;
  color: var(--danger);
}

.input {
  min-height: 34px;
  padding: 0 10px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  min-width: 0;
}

@media (hover: hover) and (pointer: fine) {
  .input:hover {
    border-color: var(--text-muted);
  }
}

/* Fields: the ring hugs the box. */
.input:focus-visible {
  outline-offset: 0;
  border-color: var(--focus);
}

/* Placeholders in the secondary text colour at full strength (#725): the browsers' default is a
   faded grey under 4.5:1. */
.input::placeholder,
textarea::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

select.input {
  min-width: 200px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin: 0 0 var(--space-3);
  padding: 0;
  border: 0;
  min-width: 0;
}

.field label,
.field > legend {
  padding: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.field-row {
  display: flex;
  gap: 8px;
}

.radio,
.checkbox {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  cursor: pointer;
}

.badge {
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.04em;
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: var(--surface-3);
  color: var(--text-muted);
}

.badge-org {
  margin-inline-start: .35rem;
  background: var(--accent-soft);
  color: var(--text);
  white-space: nowrap;
  max-width: 12em;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-guest {
  background: var(--mention-bg);
  color: var(--mention-text);
}

.badge-count {
  min-width: 1.125rem;
  height: 1.125rem;
  padding: 0 5px;
  border-radius: var(--radius-pill);
  background: var(--badge-bg);
  color: var(--on-fill);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-2xs);
  font-weight: var(--weight-bold);
  line-height: 1.125rem;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

/* Plain unread: quiet, so red stays for mentions and direct messages (#366). */
.badge-count.is-quiet {
  background: color-mix(in srgb, var(--chrome-strong) 22%, transparent);
  color: var(--chrome-strong);
}

.sidebar .badge-count.is-quiet {
  background: color-mix(in srgb, var(--sb-strong) 22%, transparent);
  color: var(--sb-strong);
}

.main .badge-count.is-quiet,
.side-panel .badge-count.is-quiet {
  background: var(--surface-3);
  color: var(--text);
}

.empty-state {
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

/* The full empty state (components/empty_state.rs): icon, headline, one sentence, one action. */
.empty-state.is-rich {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  max-width: 420px;
  margin: 0 auto;
  padding: var(--space-8) var(--space-6);
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  margin-bottom: var(--space-2);
  border-radius: var(--radius-lg);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.empty-icon .icon {
  width: 26px;
  height: 26px;
}

.empty-title {
  color: var(--text);
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
  font-weight: var(--weight-bold);
}

.empty-body {
  font-size: var(--text-sm);
  line-height: 1.5;
}

.empty-state.is-rich .btn {
  margin-top: var(--space-2);
}

/* Underlined tabs of a view (Activity, a conversation's Messages and Files). The underline is the
   list's sliding `.tab-indicator` (see "Motion"). */
.view-tabs {
  position: relative;
  isolation: isolate;
  display: flex;
  gap: var(--space-1);
  padding: 0 var(--space-4);
  border-bottom: 1px solid var(--border);
}

.view-tabs [role="tab"] {
  position: relative;
  height: 36px;
  padding: 0 var(--space-3);
  border: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

@media (hover: hover) and (pointer: fine) {
  .view-tabs [role="tab"]:hover {
    color: var(--text);
    background: var(--surface-2);
  }
}

.view-tabs [role="tab"][aria-selected="true"] {
  color: var(--accent-strong);
}

.panel-header:has(+ .view-tabs) {
  border-bottom: 0;
}

/* Toggle buttons (Activity's "Unread"). */
.btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

/* In the channel header the tabs are the second row (#580): they scroll sideways, with the edges
   fading out, instead of wrapping or squeezing the first row. The row's padding keeps the fade off
   the tabs at rest. */
.view-tabs.header-tabs {
  flex: 1;
  min-width: 0;
  padding: 0 var(--space-4);
  border-bottom: 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, transparent, #000 var(--space-4), #000 calc(100% - var(--space-4)), transparent);
  mask-image: linear-gradient(to right, transparent, #000 var(--space-4), #000 calc(100% - var(--space-4)), transparent);
}

.view-tabs.header-tabs::-webkit-scrollbar {
  display: none;
}

.view-tabs.header-tabs [role="tab"] {
  flex: none;
  height: 36px;
  white-space: nowrap;
}

/* Inside the scroller the underline sits on its bottom edge, not below it. */
.view-tabs.header-tabs > .tab-indicator {
  bottom: 0;
}

/* A conversation's messages tab: feed, seen line and composer, laid out as before the tabs. */
.channel-messages {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

/* A conversation's files tab. */
.channel-files {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  animation: motion-view-in var(--dur-fast) var(--ease-standard);
}

.channel-files .files-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: var(--space-3);
  padding: var(--space-4);
}

.channel-files .file-card {
  max-width: none;
}

/* The tab's Files / Links switch and the links list. */
.channel-files .shared-kind {
  margin: var(--space-4) var(--space-4) 0;
  width: fit-content;
}

.links-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-4);
  list-style: none;
}

.link-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.link-row-icon {
  flex: none;
  color: var(--text-muted);
}

.link-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.link-row-title,
.link-row-url,
.link-row-meta {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.link-row-title {
  font-weight: var(--weight-semibold);
}

.link-row-url,
.link-row-meta {
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.links-more,
.files-more {
  display: flex;
  justify-content: center;
  padding: 0 var(--space-4) var(--space-4);
}

/* ---- Avatars and presence ---- */

.avatar {
  position: relative;
  display: inline-grid;
  place-items: center;
  flex: none;
  border-radius: 50%;
  /* Dark enough for white initials on every hue (at least 4.5:1). */
  background: hsl(var(--hue) 45% 32%);
  color: var(--on-fill);
  font-weight: var(--weight-semibold);
  user-select: none;
}

.avatar-sm {
  width: 20px;
  height: 20px;
  font-size: 11px;
  margin-left: -6px;
  box-shadow: 0 0 0 2px var(--surface);
}

.avatar-md {
  width: 30px;
  height: 30px;
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-2xs);
}

.avatar-lg {
  width: 38px;
  height: 38px;
  font-size: var(--text-sm);
  border-radius: var(--radius);
}

.avatar-xl {
  width: clamp(72px, 22vmin, 128px);
  height: clamp(72px, 22vmin, 128px);
  font-size: clamp(26px, 7vmin, 44px);
}

.avatar .presence {
  position: absolute;
  right: -2px;
  bottom: -2px;
  box-shadow: 0 0 0 2px var(--chrome);
}

.presence {
  display: inline-block;
  flex: none;
  width: 10px;
  height: 10px;
  border-radius: 50%;
}

.presence-online {
  background: var(--online);
}

/* Busy and do not disturb share red; only do not disturb carries the bar (issue #1578). */
.presence-busy {
  background: var(--dnd);
}

.presence-away {
  background: var(--away);
}

/* Be right back: the away colour with clock hands, so it reads apart from away without colour. */
.presence-brb {
  background-color: var(--away);
  background-image:
    linear-gradient(var(--on-fill), var(--on-fill)),
    linear-gradient(var(--on-fill), var(--on-fill));
  background-size: 1.5px 35%, 30% 1.5px;
  background-position: 50% 20%, 75% 52%;
  background-repeat: no-repeat;
}

.presence-dnd {
  background: var(--dnd);
  background-image: linear-gradient(var(--on-fill), var(--on-fill));
  background-size: 6px 2px;
  background-position: center;
  background-repeat: no-repeat;
}

.presence-offline {
  background: transparent;
  border: 2px solid var(--offline);
}

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

.space-rail {
  flex: none;
  width: var(--rail-w);
  min-height: 0;
  background: var(--chrome);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: 10px 0;
}

/* Only the spaces and "add space" scroll (#652); the destinations above and Focus at the foot stay
   put. An edge fades where spaces are scrolled out of sight (`.has-more-*`, rail.rs), instead of a
   hard cut. */
.rail-spaces {
  flex: 0 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  padding: 6px 0;
  overflow: hidden auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  --rail-fade-top: 0px;
  --rail-fade-bottom: 0px;
  -webkit-mask-image: linear-gradient(to bottom, transparent, black var(--rail-fade-top), black calc(100% - var(--rail-fade-bottom)), transparent);
  mask-image: linear-gradient(to bottom, transparent, black var(--rail-fade-top), black calc(100% - var(--rail-fade-bottom)), transparent);
}

.rail-spaces::-webkit-scrollbar {
  display: none;
}

.rail-spaces.has-more-above {
  --rail-fade-top: var(--space-6);
}

.rail-spaces.has-more-below {
  --rail-fade-bottom: var(--space-6);
}

.space-rail ul {
  flex: none;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
}

/* Global destinations: an icon with a short label under it (Home, Activity, Threads). */
.rail-destinations {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.rail-dest {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  width: 64px;
  padding: 4px 0 2px;
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--chrome-text);
}

.rail-dest-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 30px;
  border-radius: var(--radius);
}

@media (hover: hover) and (pointer: fine) {
  .rail-dest:hover {
    color: var(--chrome-strong);
  }
}

@media (hover: hover) and (pointer: fine) {
  .rail-dest:hover .rail-dest-icon {
    background: rgba(255, 255, 255, 0.1);
  }
}

.rail-dest.current {
  color: var(--chrome-strong);
}

.rail-dest.current .rail-dest-icon {
  background: var(--accent);
  color: var(--on-accent);
}

.rail-dest-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-2xs);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-2xs);
}

.rail-dest .badge-count {
  position: absolute;
  right: -8px;
  top: -5px;
  box-shadow: 0 0 0 2px var(--chrome);
}

.space-btn {
  position: relative;
  width: 40px;
  height: 40px;
  /* No button padding: the space picture fills the whole tile instead of being squeezed. */
  padding: 0;
  border: 0;
  border-radius: var(--radius-md);
  background: hsl(var(--hue) 40% 32%);
  color: var(--on-fill);
  font-weight: var(--weight-bold);
}

/* The pill at the rail's edge: half height on hover, full for the current space. Only its scale
   animates. */
.space-btn::before {
  content: "";
  position: absolute;
  left: -16px;
  top: 10px;
  bottom: 10px;
  width: 4px;
  border-radius: 0 4px 4px 0;
  background: var(--on-fill);
  transform: scaleY(0);
  transition: transform var(--dur-base) var(--ease-emphasized);
}

@media (hover: hover) and (pointer: fine) {
  .space-btn:hover::before {
    transform: scaleY(0.5);
  }
}

.space-btn.current::before {
  transform: scaleY(1);
}

/* Unread on a space tile (#715, #955), as on the macOS Dock: the number of unread messages, white
   and bold in a system-red bubble on the top-right corner, overlapping the tile. A ring in the rail's
   colour cuts it out of the tile, so it reads on any space picture and next to the current space's
   pill. The number is capped at "99+" (rail.rs), so the bubble keeps its size. */
.space-btn .badge-count {
  position: absolute;
  right: -5px;
  top: -5px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  background: var(--dock-red);
  color: #fff;
  font-size: var(--text-2xs);
  letter-spacing: 0;
  font-weight: var(--weight-bold);
  line-height: 18px;
  box-shadow: 0 0 0 2px var(--chrome);
}

.rail-add {
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px dashed rgba(255, 255, 255, 0.3);
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--chrome-text);
  display: grid;
  place-items: center;
  opacity: 0.6;
}

/* ---- Sidebar ---- */

.sidebar {
  flex: none;
  width: var(--sidebar-w);
  background: var(--sb-bg);
  /* The hairline that sets a light sidebar off from the white content; none in dark mode. */
  box-shadow: inset -1px 0 0 var(--sb-border);
  color: var(--sb-text);
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* The drag handle on the sidebar's right edge (#842): no width of its own, a wider hit area
   around the edge, and a line that shows on hover, focus and while dragging. */
.sidebar-resizer {
  position: relative;
  flex: none;
  width: 0;
  z-index: 2;
  outline: none;
}

.sidebar-resizer::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -4px;
  width: 8px;
  cursor: col-resize;
  touch-action: none;
}

.sidebar-resizer::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -1px;
  width: 2px;
  background: transparent;
  transition: background var(--dur-base) var(--ease-out);
  pointer-events: none;
}

.sidebar-resizer:focus-visible::after,
.sidebar-resizer.is-dragging::after {
  background: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .sidebar-resizer:hover::after {
    background: var(--accent);
  }
}

.sidebar-head {
  padding: 12px 16px 8px;
}

.space-name {
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
  font-weight: var(--weight-bold);
  color: var(--sb-strong);
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 16px;
  overscroll-behavior: contain;
}

.sb-section-head {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  padding: 14px 12px 4px 10px;
  border: 0;
  background: none;
  color: var(--sb-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
  text-align: left;
}

@media (hover: hover) and (pointer: fine) {
  .sb-section-head:hover {
    color: var(--sb-strong);
  }
}

.sb-section-head .badge-count {
  margin-left: auto;
}

.sb-section-head .badge-count + .badge-count {
  margin-left: 4px;
}

.sb-section-head .chevron {
  width: 14px;
  height: 14px;
}

.sb-section-head[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}

.sb-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 16px);
  margin: 0 8px;
  min-height: 32px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sb-muted);
  text-align: left;
}

@media (hover: hover) and (pointer: fine) {
  .sb-item:hover {
    background: var(--sb-hover);
    color: var(--sb-strong);
  }
}

.sb-item.unread {
  color: var(--sb-strong);
  font-weight: var(--weight-bold);
}

/* Muted: a dimmer colour that still reads at 4.5:1, plus the bell-off icon (not opacity). */
.sb-item.muted {
  color: var(--sb-dim);
}

.sb-muted-icon {
  display: inline-grid;
  place-items: center;
}

.sb-muted-icon .icon {
  width: 14px;
  height: 14px;
}

/* A draft waits here (#1220). */
.sb-draft {
  flex: none;
  display: inline-grid;
  place-items: center;
  color: var(--text-muted);
}

.sb-draft .icon {
  width: 14px;
  height: 14px;
}

/* A stable width for the count ("1" up to "99+"), so the name doesn't shift when it changes (#891). */
.sb-item .badge-count {
  flex: none;
  min-width: 1.75rem;
}

.sb-item.current {
  background: var(--sb-current);
  color: var(--on-fill);
}

.sb-name {
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* A channel listed outside its space (a favorite in Chats, #1152, #1346): the space after the name
   on the same line, so every row is as high as the others. The space shortens first, but keeps room
   for a few letters; the full name is its tooltip and the row's label. */
.sb-item .sb-name:has(+ .sb-space) {
  flex: 0 1 auto;
}

.sb-space {
  flex: 1 100 0;
  min-width: 3ch;
  overflow: hidden;
  color: var(--sb-dim);
  font-size: var(--text-2xs);
  font-weight: 400;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-item.current .sb-space {
  color: inherit;
}

/* The spaces under the list layout's list (#1151): the tile at the size of a row's icon. */
.sb-list-spaces .space-tile {
  flex: none;
  width: 20px;
  height: 20px;
  font-size: var(--text-2xs);
}

/* The list grouped by space (#1345): a section heading with the space's tile in front, small enough
   to stay a heading, not a row. A long name shortens. */
.sb-list-space-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.sb-list-space-title > span:last-child {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.sb-list-space-title .space-tile {
  flex: none;
  width: 16px;
  height: 16px;
  border-radius: 4px;
  font-size: var(--text-2xs);
}

.sb-status {
  font-size: var(--text-sm);
}

/* Still catching up after being away (issue #247): a still mark, no animation while it waits. */
.sb-catching-up {
  display: inline-grid;
  place-items: center;
  opacity: 0.6;
}

.sb-threads {
  width: calc(100% - 16px);
}

.dm-dot {
  display: inline-grid;
  place-items: center;
  width: 18px;
}

.space-rail :focus-visible,
.top-bar :focus-visible {
  outline-color: var(--chrome-strong);
}

.sidebar :focus-visible {
  outline-color: var(--sb-strong);
}


/* ---- Sidebar: Favorites' hint and drop target (issue #299) ---- */

.sb-empty-hint {
  margin: 2px 12px 4px 36px;
  color: var(--sb-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  line-height: 1.4;
}

/* A channel dragged over Favorites: the section lights up where it will land. */
.sb-section.is-drop-target {
  border-radius: var(--radius);
  box-shadow: inset 0 0 0 2px var(--accent);
}
/* ---- Custom title bar (desktop app, components/window_controls.rs) ----
   `data-titlebar="custom"` on <html> means the window has no native title bar and the top bar is
   one. `--window-controls-left/right` hold the number of buttons on each side. */

:root {
  /* Width of one window button (Windows' caption buttons; no target is smaller than 30px). */
  --window-btn-w: 46px;
  /* Margin between the controls and the window edge; it moves the window like the bar. */
  --window-controls-inset: 0px;
  /* Room for the macOS traffic lights (positioned by the shell). */
  --traffic-lights-w: 84px;
}

/* GNOME (libadwaita), also for Linux desktops without a style of their own: a 24px circle and
   an 8px gap per button, inside a target the full height of the bar. */
:root[data-platform="linux"] {
  --window-btn-w: 32px;
  --window-controls-inset: 4px;
}

/* KDE (Breeze): 24px circles 6px apart. */
:root[data-platform="linux"][data-linux-desktop="kde"] {
  --window-btn-w: 30px;
  --window-controls-inset: 5px;
}

/* The title bar is the window's top edge: banners go below it. */
:root[data-titlebar="custom"] .app {
  grid-template-rows: var(--topbar-h) auto auto minmax(0, 1fr);
}

:root[data-titlebar="custom"] .app > .top-bar {
  grid-row: 1;
}

:root[data-titlebar="custom"] .app > .app-banners {
  grid-row: 2;
}

:root[data-titlebar="custom"] .app > .first-sync-row {
  grid-row: 3;
}

:root[data-titlebar="custom"] .app > .app-body {
  grid-row: 4;
}

:root[data-titlebar="custom"] .top-bar {
  padding-left: calc(
    var(--window-controls-left, 0) * var(--window-btn-w) + var(--window-controls-inset)
  );
  padding-right: calc(
    12px + var(--window-controls-right, 0) * var(--window-btn-w) + var(--window-controls-inset)
  );
  -webkit-user-select: none;
  user-select: none;
}

/* However narrow the window, some of the title bar stays free to grab beside the search. */
:root[data-titlebar="custom"] .top-nav {
  width: min(560px, calc(100% - 32px));
}

:root[data-titlebar="custom"] .top-nav.has-history {
  width: min(632px, calc(100% - 32px));
}

:root[data-platform="macos"][data-titlebar="custom"]:not([data-window="fullscreen"]) .top-bar {
  grid-template-columns: var(--traffic-lights-w) minmax(0, 1fr) auto;
}

/* The traffic lights sit where the brand would be; fullscreen hides them and the brand returns. */
:root[data-platform="macos"][data-titlebar="custom"]:not([data-window="fullscreen"]) .top-bar .brand {
  visibility: hidden;
}

/* The controls draw in their text colour (`currentColor`), so fills and glyphs follow the bar
   in light and dark and the plain background of the screens without a top bar. */
.window-controls {
  --window-btn-ring: var(--chrome-strong);
  position: fixed;
  top: 0;
  z-index: 200;
  display: flex;
  box-sizing: border-box;
  height: var(--topbar-h);
}

.window-controls.left {
  left: 0;
  padding-left: var(--window-controls-inset);
}

.window-controls.right {
  right: 0;
  padding-right: var(--window-controls-inset);
}

.window-btn {
  display: grid;
  place-items: center;
  width: var(--window-btn-w);
  height: 100%;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  color: var(--chrome-text);
  transition:
    background-color var(--dur-fast) var(--ease-standard),
    color var(--dur-fast) var(--ease-standard);
}

.window-glyph {
  display: block;
  transition:
    background-color var(--dur-fast) var(--ease-standard),
    color var(--dur-fast) var(--ease-standard),
    box-shadow var(--dur-fast) var(--ease-standard);
}

.window-btn:active {
  color: var(--chrome-strong);
}

@media (hover: hover) and (pointer: fine) {
  .window-btn:hover {
    color: var(--chrome-strong);
  }
}

.window-btn:focus-visible {
  outline: var(--focus-width) solid var(--window-btn-ring);
  outline-offset: -2px;
}

/* Screens without the top bar (sign-in, guest join): the controls sit on the page background. */
:root:not(:has(.top-bar)) .window-controls {
  --window-btn-ring: var(--focus);
}

:root:not(:has(.top-bar)) .window-btn {
  color: var(--text-muted);
}

:root:not(:has(.top-bar)) .window-btn:active {
  color: var(--text);
}

@media (hover: hover) and (pointer: fine) {
  :root:not(:has(.top-bar)) .window-btn:hover {
    color: var(--text);
  }
}

/* Windows 11: 46×32 caption buttons flush with the top right corner, a light grey on hover,
   red behind close. */
:root[data-platform="windows"] .window-controls {
  height: 32px;
}

@media (hover: hover) and (pointer: fine) {
  :root[data-platform="windows"] .window-btn:hover,
  :root[data-platform="windows"] .window-btn.snap-hover {
    color: var(--chrome-strong);
    background-color: color-mix(in srgb, currentColor 9%, transparent);
  }
}

:root[data-platform="windows"] .window-btn:active {
  background-color: color-mix(in srgb, currentColor 6%, transparent);
}

@media (hover: hover) and (pointer: fine) {
  :root[data-platform="windows"] .window-btn.close:hover {
    background-color: #c42b1c;
    color: var(--on-fill);
  }
}

:root[data-platform="windows"] .window-btn.close:active {
  background-color: #c84031;
  color: var(--on-fill);
}

/* Linux: the button is a full-height target; the circle is the glyph's own box. A square never
   shows, so the focus ring is drawn round the circle too. */
:root[data-platform="linux"] .window-btn,
:root[data-platform="linux"] .window-btn:active {
  background: transparent;
}

@media (hover: hover) and (pointer: fine) {
  :root[data-platform="linux"] .window-btn:hover {
    background: transparent;
  }
}

:root[data-platform="linux"] .window-btn:focus-visible {
  /* The ring is drawn by .window-glyph below. */
  outline: none;
}

:root[data-platform="linux"] .window-glyph {
  box-sizing: content-box;
  padding: 4px;
  border-radius: 50%;
}

:root[data-platform="linux"] .window-btn:focus-visible .window-glyph {
  outline: var(--focus-width) solid var(--window-btn-ring);
  outline-offset: 0;
}

/* GNOME: a light fill at rest, stronger on hover and press; close is not red. */
:root[data-platform="linux"] .window-glyph {
  background-color: color-mix(in srgb, currentColor 10%, transparent);
}

@media (hover: hover) and (pointer: fine) {
  :root[data-platform="linux"] .window-btn:hover .window-glyph {
    background-color: color-mix(in srgb, currentColor 16%, transparent);
  }
}

:root[data-platform="linux"] .window-btn:active .window-glyph {
  background-color: color-mix(in srgb, currentColor 24%, transparent);
}

/* KDE: flat glyphs, a subtle circle on hover, a red circle with a white cross behind close. */
:root[data-platform="linux"][data-linux-desktop="kde"] .window-glyph {
  background-color: transparent;
}

@media (hover: hover) and (pointer: fine) {
  :root[data-platform="linux"][data-linux-desktop="kde"] .window-btn:hover .window-glyph {
    background-color: color-mix(in srgb, currentColor 15%, transparent);
  }
}

:root[data-platform="linux"][data-linux-desktop="kde"] .window-btn:active .window-glyph {
  background-color: color-mix(in srgb, currentColor 25%, transparent);
}

@media (hover: hover) and (pointer: fine) {
  :root[data-platform="linux"][data-linux-desktop="kde"] .window-btn.close:hover .window-glyph {
    background-color: #da4453;
    color: var(--on-fill);
  }
}

:root[data-platform="linux"][data-linux-desktop="kde"] .window-btn.close:active .window-glyph {
  background-color: #b83a47;
  color: var(--on-fill);
}

@media (prefers-reduced-motion: reduce) {
  .window-btn,
  .window-glyph {
    transition: none;
  }
}

/* Screens without the top bar (sign-in, guest join) get a strip to move the window by. */
.window-drag-strip {
  position: fixed;
  inset: 0 0 auto 0;
  z-index: 199;
  height: var(--topbar-h);
}

:root:has(.top-bar) .window-drag-strip {
  display: none;
}

/* Without a window manager frame the window needs its own edge (Windows draws one itself). Four
   one-pixel lines, not one bordered box over the window: WebKitGTK gives a fixed element its own
   compositing layer, and a window-sized one costs a window of GPU memory and a blend every frame. */
:root[data-titlebar="custom"][data-platform="linux"][data-window="normal"]::before,
:root[data-titlebar="custom"][data-platform="linux"][data-window="normal"]::after,
:root[data-titlebar="custom"][data-platform="linux"][data-window="normal"] body::before,
:root[data-titlebar="custom"][data-platform="linux"][data-window="normal"] body::after {
  content: "";
  position: fixed;
  z-index: 1000;
  background: rgba(128, 128, 128, 0.4);
  pointer-events: none;
}

:root[data-titlebar="custom"][data-platform="linux"][data-window="normal"]::before {
  inset: 0 0 auto;
  height: 1px;
}

:root[data-titlebar="custom"][data-platform="linux"][data-window="normal"]::after {
  inset: auto 0 0;
  height: 1px;
}

:root[data-titlebar="custom"][data-platform="linux"][data-window="normal"] body::before {
  inset: 1px auto 1px 0;
  width: 1px;
}

:root[data-titlebar="custom"][data-platform="linux"][data-window="normal"] body::after {
  inset: 1px 0 1px auto;
  width: 1px;
}

/* ---- Channel view ---- */

.channel-view {
  position: relative;
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

/* Dragging files over a conversation or thread (#484): a tab slides up out of the composer, where
   the dropped files will appear as chips, and the composer's frame turns to the accent. A
   zero-height anchor right above the composer holds it, so nothing in the layout moves; the
   composer paints over it, so the tab emerges from behind its top edge. */
.drop-strip-anchor {
  position: relative;
  flex: none;
  height: 0;
  z-index: 5;
}

.drop-strip-anchor + .composer {
  position: relative;
  z-index: 6;
}

.drop-strip {
  position: absolute;
  bottom: -1px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 8px;
  height: 40px;
  padding: 0 18px;
  border: 1px solid var(--accent);
  border-bottom: 0;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
  background: var(--accent);
  color: var(--on-fill);
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, 100%);
  transition:
    opacity var(--dur-exit) var(--ease-exit),
    transform var(--dur-exit) var(--ease-exit);
}

.drop-strip.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
  transition:
    opacity var(--dur-fast) var(--ease-out),
    transform var(--dur-slow) var(--ease-emphasized);
}

.drop-strip-anchor:has(.is-visible) + .composer .composer-box {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 25%, transparent);
}

@media (prefers-reduced-motion: reduce) {
  .drop-strip,
  .drop-strip.is-visible {
    transform: translate(-50%, 0);
  }
}

/* The header measures itself (#365): what fits depends on its own width, which the sidebar, the
   side panel and the lightbox's thread column narrow, not on the window's. */
.channel-header {
  flex: none;
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  container: channel-header / inline-size;
}

/* Two rows (#580): the name, topic and actions, then the tabs. */
.header-row {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 48px;
  padding: 0 16px;
}

.header-row.header-row-tabs {
  height: 36px;
  padding: 0;
}

@media (pointer: coarse) {
  .header-row.header-row-tabs {
    height: auto;
  }
}

/* Only the topic and then the name give way; tabs and buttons keep their size and never overlap. */
.header-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 6px;
}

.header-main > * {
  flex: none;
}

.header-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
  font-weight: var(--weight-bold);
  white-space: nowrap;
}

.channel-header .header-title {
  margin: 0;
}

/* The name, and in a direct conversation the person's status on a small line under it. Must stay
   after `.header-main > *` (same specificity): it is the one child that gives way. */
.header-main > .header-identity {
  flex: 0 1 auto;
  min-width: 3rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.header-identity > .header-title {
  line-height: 1.2;
}

.header-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  color: var(--text-muted);
  /* Status, last seen and local time are read, not glanced at (#725): body-adjacent size and a
     little weight, so they hold up in the dark. */
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  line-height: 1.3;
}

.header-sub > .last-seen {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-icon {
  color: var(--text-muted);
}

/* The listed name isn't the one members' apps hold (e2ee.md §4.6.5, #1749). */
.header-name-stale {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  color: var(--warn-text);
}

.header-name-stale > svg {
  flex: none;
}

.header-divider {
  width: 1px;
  height: 18px;
  background: var(--border);
  margin: 0 6px;
}

.header-main > .header-topic {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* A narrow header folds into "…" step by step: first the topic and the panel and settings
   buttons, then the favorite star, the date jump and a DM's presence details, last the tabs (Files
   is in the menu). The calls stay. A long name ellipsizes before the first step. With a finger the
   buttons are wider, so it folds earlier. Widths are the header's content box. */
@container channel-header (max-width: 680px) {
  .header-topic,
  .header-divider,
  .header-actions > .header-btn:not(.compact-keep) {
    display: none;
  }

  .channel-header .conversation-more {
    display: inline-grid;
  }
}

@container channel-header (max-width: 520px) {
  .header-main > .icon-btn,
  .header-main > .date-jump,
  .header-sub > .header-local-time {
    display: none;
  }
}

@media (pointer: coarse) {
  @container channel-header (max-width: 800px) {
    .header-topic,
    .header-divider,
    .header-actions > .header-btn:not(.compact-keep) {
      display: none;
    }

    .channel-header .conversation-more {
      display: inline-grid;
    }
  }

  @container channel-header (max-width: 620px) {
    .header-main > .icon-btn,
    .header-main > .date-jump,
    .header-sub > .header-local-time {
      display: none;
    }
  }
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
}

/* Members: overlapping pictures and the count; narrower, the pictures fold into the plain icon. */
.header-avatars {
  padding-left: 0;
}

.header-avatars > .avatar {
  margin-left: -6px;
  box-shadow: 0 0 0 2px var(--surface);
}

.header-avatars > .avatar:first-child {
  margin-left: 0;
}

.header-members-icon {
  display: none;
}

@container channel-header (max-width: 900px) {
  .header-avatars {
    display: none;
  }

  .header-members-icon {
    display: inline-block;
  }
}

.header-btn[aria-pressed="true"] {
  background: var(--surface-3);
  color: var(--text);
}

@media (hover: hover) and (pointer: fine) {
  .header-btn:hover {
    background: var(--surface-3);
    color: var(--text);
  }
}

.bookmarks-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 36px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}

.bookmark {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  flex: none;
  min-height: 24px;
  max-width: 220px;
  padding: 0 8px;
  border: 0;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  color: var(--text);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

@media (hover: hover) and (pointer: fine) {
  .bookmark:hover:not(:disabled) {
    background: var(--surface-3);
  }
}

.bookmark .icon {
  width: 13px;
  height: 13px;
  color: var(--text-muted);
}

.bookmark-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-add {
  background: transparent;
  color: var(--text-muted);
  border: 1px dashed var(--border);
}

/* ---- Message list ---- */

.message-list-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.message-list {
  /* The shared message toolbar is positioned in its scroll coordinates. */
  position: relative;
  flex: 1;
  min-height: 0;
  min-width: 0;
  overflow-y: auto;
  overflow-anchor: none;
  overscroll-behavior: contain;
  outline-offset: -2px;
  /* Breathing room between the newest message and the composer. */
  padding-bottom: var(--space-3);
}

.row {
  min-width: 0;
}

.date-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px 6px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
}

/* A day label that opens the jump menu (issue #300). */
.date-pill {
  padding: 3px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  transition: background var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}

@media (hover: hover) and (pointer: fine) {
  .date-pill:hover {
    border-color: var(--text-muted);
    background: var(--surface-2);
  }
}

.date-pill:active {
  background: var(--surface-2);
}

.date-pill:focus-visible {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: 2px;
}

.date-divider::before,
.date-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

/* "New messages": where the unread messages began when the conversation was opened. */
.new-divider {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px 4px;
  color: var(--danger);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-bold);
}

.new-divider::before,
.new-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: currentColor;
  opacity: 0.6;
}

.new-divider::after {
  flex: 0 0 24px;
}

.msg {
  position: relative;
  outline-offset: -2px;
}

/* Deleted with an undo window still open. */
.msg[hidden] {
  display: none;
}

.msg-user {
  display: flex;
  gap: 10px;
  padding: 6px 16px;
}

.msg-user:focus-within,
.msg-user:focus,
.msg-user.msg-active {
  background: var(--surface-2);
}

@media (hover: hover) and (pointer: fine) {
  .msg-user:hover {
    background: var(--surface-2);
  }
}

.msg-grouped {
  padding-top: 1px;
  padding-bottom: 1px;
}

.msg-gutter {
  flex: none;
  width: 38px;
}

.hover-time {
  display: block;
  visibility: hidden;
  padding-top: 3px;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  text-align: center;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.msg-user:focus .hover-time,
.msg-user.msg-active .hover-time {
  visibility: visible;
}

@media (hover: hover) and (pointer: fine) {
  .msg-user:hover .hover-time {
    visibility: visible;
  }
}

.msg-main {
  flex: 1;
  min-width: 0;
}

.msg-header {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
}

.msg-author {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  font-weight: var(--weight-bold);
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .msg-author:hover {
    text-decoration: underline;
  }
}

.msg-time,
.edited,
.system-time {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.edited {
  margin-left: 6px;
}

.msg-body > .md-p:has(+ .edited) {
  display: inline;
}

.msg-body {
  overflow-wrap: anywhere;
}

/* A message of only 1-3 emoji (jumbomoji, #1603). The steps mirror `jumbo_emoji_scale` in
   teamcraft-client-api; em keeps them following the user's font size. */
.msg-jumbo {
  line-height: 1.2;
}

.msg-jumbo-1 {
  font-size: 2.5em;
}

.msg-jumbo-2 {
  font-size: 2em;
}

.msg-jumbo-3 {
  font-size: 1.6em;
}

.md-p + .md-p,
.md-p + .md-code-wrap,
.md-code-wrap + .md-p {
  margin-top: 4px;
}

.md-code {
  margin: 4px 0 0;
  padding: 8px 12px;
  /* 3:1 against the surface, as in the composer (#843). */
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  font: var(--text-xs)/1.5 var(--font-mono);
  overflow-x: auto;
}

.md-code-wrap { position: relative; }

.md-code-copy {
  position: absolute;
  inset-block-start: 8px;
  inset-inline-end: 6px;
  opacity: 0;
  transition: opacity var(--dur-fast, .12s) ease;
}

.md-code-wrap:hover .md-code-copy,
.md-code-copy:focus-visible { opacity: 1; }

/* Touch has no hover: the button stays visible. */
@media (hover: none) { .md-code-copy { opacity: 1; } }

.md-inline-code {
  padding: 1px 5px;
  border-radius: var(--radius-xs);
  background: var(--code-bg);
  font: 0.9em var(--font-mono);
}

.md-link {
  color: var(--accent-strong);
}

.mention {
  padding: 0 3px;
  border-radius: 3px;
  background: var(--accent-soft);
  color: var(--accent-strong);
}

button.mention-link {
  border: 0;
  font: inherit;
  cursor: pointer;
  transition: filter var(--dur-fast, .12s) ease;
}

button.mention-link:hover { filter: brightness(.95); }
button.mention-link:active { opacity: .7; }

.mention-group {
  font-weight: 600;
}

.mention-me {
  background: var(--mention-bg);
  color: var(--mention-text);
}

.reactions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 24px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

@media (hover: hover) and (pointer: fine) {
  .reaction:not(:disabled):hover {
    border-color: var(--text-muted);
  }
}

/* Counts for people who may not react (issue #691): readable, not pressable. */
.reaction:disabled {
  cursor: default;
  opacity: 1;
  color: inherit;
}

.reaction-mine {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.reaction-count {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-variant-numeric: tabular-nums;
}

.reply-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
  padding: 2px 6px;
  margin-left: -6px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--accent-strong);
  font-weight: var(--weight-semibold);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

@media (hover: hover) and (pointer: fine) {
  .reply-count:hover {
    background: var(--accent-soft);
  }
}

.reply-count .icon {
  width: 14px;
  height: 14px;
}

/* One toolbar per message list, moved onto the hovered or focused message (#320). */
.msg-toolbar {
  position: absolute;
  right: 16px;
  z-index: 5;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  /* The same frame as the picture toolbar (.media-toolbar). */
  box-shadow: var(--shadow-card);
}

/* Its z-index makes the bar a stacking context, so its menus can't rise above the composer
   (z-index 6, .drop-strip-anchor + .composer) on their own: the bar rises with them. */
.msg-toolbar.has-open-menu {
  z-index: 41;
}

.msg-toolbar .icon-btn.is-on {
  color: var(--accent);
}

.msg-toolbar-sep {
  width: 1px;
  height: 18px;
  margin: 0 2px;
  background: var(--border);
}

.msg-toolbar .msg-menu {
  max-height: calc(100vh - 16px);
  overflow-y: auto;
}

.menu-shortcut {
  margin-inline-start: auto;
  padding: 0 var(--space-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  color: var(--text-muted);
  font: var(--text-xs) / 16px var(--font-ui);
}


/* A message this device can't read yet (issue #888): a normal bubble, its line muted, with a
   clock while its key may still come. No animation: rows can wait for days, and an endless one
   would keep the idle app drawing (robustness.md, idle CPU). It fills in place when the key
   arrives. */
.msg-placeholder .placeholder-text {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-style: italic;
}

.msg-placeholder .placeholder-icon {
  display: inline-flex;
  flex: none;
  opacity: 0.7;
}

.msg-placeholder .placeholder-icon svg {
  width: 14px;
  height: 14px;
}

/* A call in the timeline (docs/notifications.md, "Calls in the timeline"): one quiet tile at the call's
   start; only a call that goes on draws the eye, with its icon in the accent and a Join button. */
.msg-call {
  padding: 4px 16px;
}

.call-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 26rem;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.call-tile-icon {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  color: var(--text-muted);
}

.call-tile.is-ongoing .call-tile-icon {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.call-tile.is-missed .call-tile-icon,
.call-tile.is-missed .call-tile-title {
  color: var(--danger);
}

.call-tile-text {
  display: flex;
  flex: 1;
  min-width: 0;
  flex-direction: column;
}

.call-tile-title {
  font-weight: 600;
}

.call-tile-detail {
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.call-tile-join {
  flex: none;
}

.call-tile-time {
  flex: none;
  align-self: flex-start;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  letter-spacing: var(--tracking-xs);
}
/* ---- The bottom sheet of the phone layout (#368, components/sheet.rs) ----
   Message actions, the account menu, the composer's menus, the emoji picker and the conversation's
   "…" all use it. It rises from the bottom edge, follows a dragging finger (`translate`, set by the
   component; the enter and exit animations own `transform`) and springs back or leaves downwards. */
.sheet-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(8, 12, 20, 0.45);
  animation: motion-fade-in var(--dur-base) var(--ease-standard);
}

.sheet {
  position: fixed;
  inset: auto 0 0 0;
  z-index: 61;
  display: flex;
  flex-direction: column;
  max-height: 90dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 env(safe-area-inset-right) calc(var(--space-2) + env(safe-area-inset-bottom)) env(safe-area-inset-left);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  animation: sheet-in var(--dur-slow) var(--ease-emphasized);
  transition: translate var(--dur-base) var(--ease-emphasized);
}

.sheet:focus {
  /* The sheet takes focus only to move it inside; its items show the ring. */
  outline: none;
}

/* Nothing to scroll: every touch may become a drag. */
.sheet.is-static {
  touch-action: none;
}

.sheet.is-dragging {
  transition: none;
  user-select: none;
}

/* The handle: a 36x5 bar in a full-width strip a finger can grab; the strip never scrolls. */
.sheet-handle {
  flex: none;
  position: sticky;
  top: 0;
  z-index: 1;
  height: 24px;
  background: var(--surface);
  touch-action: none;
}

.sheet-handle::before {
  content: "";
  position: absolute;
  top: 8px;
  left: 50%;
  width: 36px;
  height: 5px;
  margin-left: -18px;
  border-radius: 3px;
  background: var(--border);
}

.sheet .menu-item {
  min-height: 48px;
}

/* Keyboard shortcuts mean nothing on a touch screen. */
.sheet .menu-shortcut {
  display: none;
}

.sheet .menu-heading {
  padding-inline: var(--space-4);
}

/* It leaves the way it came, from wherever the finger let go (the ghost starts there). */
.motion-ghost.sheet {
  z-index: 59;
  translate: none !important;
}

.motion-ghost.sheet-backdrop {
  z-index: 58;
}

.motion-ghost.is-leaving.sheet {
  animation: sheet-out var(--dur-exit) var(--ease-exit) forwards;
}

@keyframes sheet-in {
  from {
    transform: translateY(100%);
  }
}

@keyframes sheet-out {
  to {
    transform: translateY(100%);
  }
}

.sheet-reactions {
  display: flex;
  justify-content: space-around;
  padding: 0 12px 10px;
  border-bottom: 1px solid var(--border);
}

.sheet-reaction {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 22px;
}

/* The emoji picker in the sheet: the grid scrolls, the tabs and the search stay on top. */
.emoji-sheet {
  height: min(70dvh, 440px);
  overflow: hidden;
}

.emoji-sheet .emoji-search {
  flex: none;
  margin: 0 var(--space-3) var(--space-2);
}

.emoji-sheet .emoji-tabs,
.emoji-sheet .emoji-footer {
  margin-inline: var(--space-3);
}

.emoji-sheet .emoji-tabs {
  margin-bottom: var(--space-2);
}

.emoji-sheet .emoji-scroller {
  padding-inline: var(--space-2);
}

.msg-system {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 6px 16px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* The room a call moved into (issue #1290). */
.msg-system .system-link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  cursor: pointer;
}

.msg-system .system-link:hover {
  text-decoration: underline;
}

/* The log reads like a terminal (#702): a short log sits on the composer, where the next entry
   arrives, instead of floating in an empty pane; a long one scrolls as before. The leading
   pseudo-element takes the free space and none once the log overflows; nothing else may shrink,
   or the virtual list's spacers would. */
.message-list.log-view {
  display: flex;
  flex-direction: column;
}

.message-list.log-view::before {
  content: "";
  flex: 1 0 0;
}

.message-list.log-view > * {
  flex-shrink: 0;
}

/* A long entry is read by scrolling the log sideways, as in a terminal (#1744): rows keep their
   single 22px line (the virtual list's height estimate stays exact) and are as wide as their text.
   The scroll width is that of the widest row rendered now: rows outside the window are not in the
   DOM, so the bar may change while scrolling up or down, which a line of a terminal does too.
   `overscroll-behavior-x: contain` keeps a sideways swipe at the left edge from also triggering the
   browser's or system's back gesture; `pan-x pan-y` leaves both scroll axes to the browser. */
.message-list.log-view {
  overflow-x: auto;
  overscroll-behavior-x: contain;
  touch-action: pan-x pan-y;
}

/* Compact log view for integration channels. Rows have a fixed height so the estimate is exact. */
.msg-log,
.log-entry {
  display: flex;
  align-items: center;
  gap: 10px;
  height: 22px;
  padding: 0 16px;
  font: var(--text-xs)/22px var(--font-mono);
  white-space: nowrap;
  /* At least the pane wide (hover/focus background), wider for a long text. */
  width: max-content;
  min-width: 100%;
  /* What the pinned columns paint over the text scrolling beneath them: opaque, and the row's own
     background while it is hovered or focused (#1789). */
  --log-bg: var(--surface);
}

.msg-log-batch {
  width: max-content;
  min-width: 100%;
  padding: 0;
}

/* Rows of a batch are as wide as the batch, which is as wide as its widest row. */
.msg-log-batch > .log-entry {
  width: auto;
  min-width: 100%;
}

.msg-log:focus,
.msg-log-batch:focus,
.msg-log-batch:focus > .log-entry,
.msg-log:focus-within {
  --log-bg: var(--surface-2);
  background: var(--surface-2);
}

@media (hover: hover) and (pointer: fine) {
  .msg-log:hover {
    --log-bg: var(--surface-2);
    background: var(--surface-2);
  }
}

/* The time stays in view while the row is scrolled sideways. The row's left padding moves into the
   column, and the gap after it is covered too, so no text shows through beside the time. */
.log-time {
  position: sticky;
  left: 0;
  z-index: 1;
  flex: none;
  padding-inline: 16px 10px;
  margin-inline: -16px -10px;
  background: var(--log-bg);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

/* "Copy line": pinned to the right edge of the pane. Hidden until the row is hovered or focused,
   but always there on touch devices, where there is no hover. */
.log-copy {
  position: sticky;
  right: 0;
  z-index: 1;
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 22px;
  margin-inline: auto -16px;
  padding: 0;
  border: 0;
  background: var(--log-bg);
  color: var(--text-muted);
  cursor: pointer;
  opacity: 0;
}

.log-copy svg {
  width: 14px;
  height: 14px;
}

.msg-log:focus-within .log-copy,
.log-copy:focus-visible {
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .msg-log:hover .log-copy {
    opacity: 1;
  }
}

@media (hover: none) {
  .log-copy {
    opacity: 0.7;
  }
}

.log-author .badge { margin-inline-end: 4px; }

.log-author {
  flex: none;
  max-width: 150px;
  overflow: hidden;
  color: var(--text-muted);
  text-overflow: ellipsis;
}

.log-level {
  flex: none;
  width: 42px;
  font-weight: var(--weight-bold);
}

/* The whole text, never cut: the log scrolls sideways instead (see above). */
.log-text {
  flex: none;
}

.level-debug .log-level {
  color: var(--lvl-debug);
}

.level-info .log-level {
  color: var(--lvl-info);
}

.level-warn .log-level {
  color: var(--lvl-warn);
}

.level-error .log-level,
.level-error .log-text {
  color: var(--lvl-error);
}

/* A round button at the right edge of the feed, above the composer: it floats over the list and
   never takes room from it. A count badge shows the messages that arrived below. */
.jump-latest {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-3);
  z-index: 2;
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--accent-strong);
  box-shadow: var(--shadow-card);
  animation: jump-latest-in var(--dur-base) var(--ease-out);
}

.jump-latest-count {
  position: absolute;
  top: -0.375rem;
  right: -0.375rem;
  background: var(--accent);
}

@media (hover: hover) and (pointer: fine) {
  .jump-latest:hover {
    background: var(--surface-3);
  }
}

@keyframes jump-latest-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.9);
  }
}

/* Reduced motion: it fades in, nothing moves. */
@keyframes jump-latest-fade {
  from {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .jump-latest {
    animation-name: jump-latest-fade;
  }
}

/* "Jump to latest" and "jump to reaction" stack at the right edge, the newest-first one at the
   bottom; the stack lets clicks on the feed between them through. */
.jump-stack {
  position: absolute;
  right: var(--space-4);
  bottom: var(--space-3);
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-2);
  pointer-events: none;
}

.jump-stack > .jump-latest {
  position: relative;
  right: auto;
  bottom: auto;
  pointer-events: auto;
}

.jump-stack > .jump-latest:active {
  transform: scale(0.94);
  transition: transform var(--dur-fast) var(--ease-out);
}

.jump-reaction .badge-count {
  position: absolute;
  top: -0.375rem;
  right: -0.375rem;
}
/* ---- Composer ---- */

.composer {
  flex: none;
  padding: 0 16px 8px;
}

.composer-box {
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
  /* The frame lights up while files are dragged over the conversation (.drop-strip). */
  transition:
    border-color var(--dur-base) var(--ease-out),
    box-shadow var(--dur-base) var(--ease-out);
}

.composer-box:focus-within {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: -1px;
}

.composer-input {
  display: block;
  width: 100%;
  min-height: 44px;
  /* Grows with the window: 220px at least (as before), up to 480px in a tall window, so a long
     message or a code block stays readable while it is written (#842). */
  max-height: clamp(220px, 40dvh, 480px);
  padding: 11px 12px 4px;
  border: 0;
  background: transparent;
  resize: none;
  /* .composer-box draws the ring round the whole box. */
  outline: none;
}

/* The rich-text editor: spaces are kept as typed, it grows up to max-height and then scrolls. Only
   the text scrolls: the formatting buttons sit above it, outside this box, and stay in view. */
.composer-editor {
  position: relative;
  overflow-y: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  cursor: text;
}

.composer-editor.is-empty::before {
  content: attr(data-placeholder);
  position: absolute;
  inset: 11px 12px auto;
  color: var(--text-muted);
  pointer-events: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Editor content looks like the message it becomes (see the .md-* rules). */
.composer-editor p,
.composer-editor div {
  margin: 0;
}

.composer-editor strong,
.composer-editor b {
  font-weight: var(--weight-bold);
}

.composer-editor code {
  padding: 1px 5px;
  border-radius: 4px;
  background: var(--code-bg);
  font: 0.9em var(--font-mono);
}

.composer-editor pre {
  margin: 4px 0;
  padding: 8px 12px;
  /* The edge shows where the block ends while it is written (#843): 3:1 like a field's. */
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  font: var(--text-xs)/1.5 var(--font-mono);
  white-space: pre-wrap;
}

.composer-editor pre code {
  padding: 0;
  background: none;
}

.composer-editor a {
  color: var(--accent);
}

.composer-editor blockquote,
.md-quote {
  margin: 4px 0;
  padding: 0 0 0 10px;
  border-inline-start: 3px solid var(--border-strong);
  color: var(--text-muted);
}

.composer-editor ul,
.composer-editor ol,
.md-list {
  margin: 4px 0;
  padding-inline-start: 22px;
}

.composer-editor ul,
ul.md-list {
  list-style: disc;
}

.composer-editor ol,
ol.md-list {
  list-style: decimal;
}

.composer-editor h1,
.composer-editor h2,
.composer-editor h3,
.md-h {
  margin: 6px 0 2px;
  line-height: 1.3;
  font-weight: var(--weight-bold);
}

.composer-editor h1,
.md-h1 {
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-xl);
  line-height: var(--leading-xl);
}

.composer-editor h2,
.md-h2 {
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
}

.composer-editor h3,
.md-h3 {
  font-size: var(--text-md);
}

.md-h:first-child,
.md-quote:first-child,
.md-list:first-child {
  margin-top: 0;
}

/* Formatting toolbar ("Aa") above the text. */
.format-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px;
  padding: 4px 6px 0;
}

.format-btn {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 28px;
  padding: 0 6px;
  /* Transparent until pressed, so pressing doesn't move the glyph. */
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-base);
}

.format-btn:focus-visible {
  background: var(--surface-2);
  color: var(--text);
}

@media (hover: hover) and (pointer: fine) {
  .format-btn:hover {
    background: var(--surface-2);
    color: var(--text);
  }
}

.format-btn[aria-pressed="true"] {
  /* The fill alone is 1.2:1 against the toolbar; the edge makes the state 3:1 (WCAG 1.4.11, #843). */
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.format-sep {
  width: 1px;
  height: 18px;
  margin: 0 4px;
  background: var(--border);
}

.glyph-bold { font-weight: var(--weight-bold); }
.glyph-italic { font-style: italic; font-family: Georgia, serif; }
.glyph-underline { text-decoration: underline; }
.glyph-strike { text-decoration: line-through; }

.format-style {
  position: relative;
}

.format-style-btn {
  display: inline-flex;
  gap: 4px;
  font-size: var(--text-sm);
}

.composer .format-style-menu,
.composer .composer-attach-menu {
  left: 0;
  right: auto;
  top: auto;
  bottom: calc(100% + 6px);
  width: 220px;
}

.format-style-menu .format-style-h1 .menu-label { font-size: var(--text-xl); letter-spacing: var(--tracking-xl); line-height: var(--leading-xl); font-weight: var(--weight-bold); }
.format-style-menu .format-style-h2 .menu-label { font-size: var(--text-lg); letter-spacing: var(--tracking-lg); font-weight: var(--weight-bold); }
.format-style-menu .format-style-h3 .menu-label { font-weight: var(--weight-bold); }

.menu-item[aria-checked="true"] {
  color: var(--accent-strong);
}

.menu-heading {
  margin: 2px 14px 4px;
  font-size: var(--text-2xs);
  font-weight: var(--weight-bold);
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

/* Link dialog, between toolbar and text. */
.link-dialog {
  display: flex;
  flex-wrap: wrap;
  align-items: end;
  gap: 8px;
  margin: 6px 8px 0;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
}

.link-dialog label {
  display: grid;
  flex: 1 1 10rem;
  gap: 2px;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
}

.link-dialog input {
  min-width: 0;
}

.link-dialog-actions {
  display: flex;
  gap: 6px;
}

/* Bottom row: +, Aa, emoji, @, / … send with its options. */
.composer-menu-wrap {
  position: relative;
  display: inline-flex;
}

.composer-format-toggle span {
  font-weight: var(--weight-bold);
  font-size: var(--text-sm);
}

.composer-format-toggle[aria-pressed="true"] {
  color: var(--accent-strong);
}

.send-flags {
  display: inline-flex;
  gap: 4px;
}

.send-flag {
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-2xs);
  white-space: nowrap;
}

/* Always at the toolbar's right end, also where nothing grows in front of it (the hint is hidden on
   phones). */
.send-group {
  display: flex;
  margin-left: auto;
}

/* Send is the rightmost control (muscle memory: the thumb and the pointer go to the corner); the
   send options sit on its left. */
.send-group .send-btn {
  order: 2;
  border-start-start-radius: 0;
  border-end-start-radius: 0;
}

.send-menu-btn {
  order: 1;
  display: grid;
  place-items: center;
  width: 22px;
  height: 30px;
  border: 0;
  border-inline-end: 1px solid color-mix(in srgb, var(--on-accent) 35%, transparent);
  border-start-start-radius: var(--radius-sm);
  border-end-start-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
}

.send-menu-btn .icon {
  width: 14px;
  height: 14px;
}

.composer .send-options {
  top: auto;
  bottom: calc(100% + 6px);
  width: 260px;
}

.composer-toolbar {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px 6px;
}

.composer-group-outside {
  margin: 0 0 4px;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
}

.composer-hint {
  flex: 1;
  min-width: 0;
  padding: 0 8px;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.send-btn {
  display: grid;
  place-items: center;
  width: 32px;
  height: 30px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: var(--on-accent);
}

.send-btn:disabled {
  background: var(--surface-3);
  color: var(--text-muted);
}

.composer-readonly {
  padding: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  text-align: center;
}

.attachment-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-bottom: 6px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 48px;
  padding: 0 4px 0 6px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  font-weight: var(--weight-medium);
}

/* Files and images share one shape: a 36 px tile in front, the file icon on an accent tint or the
   picture's thumbnail, so a waiting attachment stands out from the feed above. */
.chip > .icon {
  box-sizing: content-box;
  padding: 9px;
  border-radius: var(--radius-xs);
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent-strong);
}

.chip-thumb {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-xs);
  object-fit: cover;
}

.chip-name {
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A draft's file that could not go up (#1220): marked, so the user removes it and attaches it again. */
.chip.chip-failed { border-color: var(--danger); }
.chip-status { color: var(--danger); font-size: var(--text-xs); white-space: nowrap; }


/* Recording a voice message (#204): a strip above the input while recording or reviewing. */
.voice-record-btn { touch-action: none; user-select: none; -webkit-user-select: none; }
.voice-record-btn.is-holding { background: var(--danger-soft); color: var(--danger); }
.voice-record-btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; }
.voice-strip { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 6px; padding: 6px 8px; border-radius: var(--radius); background: var(--surface-2); }
.voice-strip .voice-text { flex: 1 1 220px; margin: 0; font-size: var(--text-sm); }
.voice-strip .voice-live { flex: 1 1 120px; display: flex; align-items: center; gap: 2px; height: 24px; min-width: 0; overflow: hidden; }
.voice-strip .voice-hint { flex: 1 1 100%; order: 10; color: var(--text-muted); font-size: var(--text-xs); }
.voice-strip .send-btn { flex: none; }
.voice-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: voice-pulse 1.2s var(--ease-standard) infinite alternate; }
@keyframes voice-pulse { from { opacity: 1; } to { opacity: .35; } }
@media (prefers-reduced-motion: reduce) {
  .voice-dot { animation: none; }
}
/* ---- Side panels ---- */

.side-panel {
  flex: none;
  width: var(--panel-w);
  max-width: 45vw;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.side-panel.embedded {
  width: auto;
  max-width: none;
  flex: 1;
  border-left: 0;
}

.panel-header {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  padding: 0 12px 0 16px;
  border-bottom: 1px solid var(--border);
}

.panel-title {
  flex: 1;
  min-width: 0;
}

.panel-title h1,
.panel-title h2 {
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
  font-weight: var(--weight-bold);
}

.panel-subtitle {
  display: block;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.panel-scroll {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.thread-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px 4px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
}

.thread-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.member {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 16px;
}

.member-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member .avatar .presence {
  box-shadow: 0 0 0 2px var(--surface);
}

/* Segmented controls and stacked avatars. */

.segmented {
  position: relative;
  isolation: isolate;
  display: inline-flex;
  padding: 2px;
  border-radius: var(--radius-sm);
  background: var(--surface-3);
}

.segmented button {
  min-height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
}

.segmented button[aria-pressed="true"] {
  color: var(--text);
}

.avatar-stack {
  display: inline-flex;
  padding-left: 6px;
}

/* ---- Popover (status menu) ---- */

.popover-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
}

.popover {
  position: absolute;
  right: 0;
  top: calc(100% + 8px);
  z-index: 41;
  width: 18.125rem;
  padding: 6px 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* Right click on a link: opens at the pointer, not under a trigger (#548). */
.popover.link-menu {
  position: fixed;
  right: auto;
  left: var(--link-menu-x, 0);
  top: var(--link-menu-y, 0);
  width: auto;
  min-width: 11rem;
  --popover-origin: top left;
}

.menu-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px 10px;
}

.menu-user .avatar {
  box-shadow: none;
}

.menu-user-name {
  font-weight: var(--weight-bold);
}

.menu-user-sub {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
}

/* The current status under the name (#1578): its dot, its name, until when. */
.menu-user-status {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.menu-sep {
  height: 1px;
  margin: 6px 0;
  background: var(--border);
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  background: transparent;
  text-align: left;
}

.menu-item:focus-visible {
  background: var(--surface-2);
}

@media (hover: hover) and (pointer: fine) {
  .menu-item:hover:not(:disabled) {
    background: var(--surface-2);
  }
}

.menu-item:disabled {
  color: var(--text-muted);
}

.menu-item .icon {
  color: var(--text-muted);
}

.menu-item .icon:last-child:not(:first-child) {
  color: var(--accent);
}

.menu-label {
  flex: 1;
  min-width: 0;
}

.menu-label small {
  display: block;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
}

.menu-emoji {
  width: 18px;
  text-align: center;
}

/* ---- Modals ---- */

/* Dialogs (#706): one raised panel on a dimming scrim, without bars. The title leads in a larger
   weight, the content follows on one spacing rhythm (--dialog-pad around, --space-* inside), and
   the actions sit at the bottom edge: filled primary, tinted secondary, filled destructive. On a
   phone the panel is a bottom sheet (see "Dialogs and the search" under the compact layout). */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 12vh 16px 16px;
  background: var(--scrim);
  overscroll-behavior: contain;
}

.modal {
  width: min(560px, 100%);
  max-height: min(80vh, 760px);
  display: flex;
  flex-direction: column;
  border: 0;
  border-radius: var(--dialog-radius);
  background: var(--dialog-surface);
  box-shadow: inset 0 1px 0 var(--dialog-highlight), 0 0 0 1px var(--dialog-edge), var(--dialog-shadow);
  overflow: hidden;
  /* Takes focus only from code to hold the focus trap; its controls show the ring. */
  outline: none;
}

.modal form {
  display: contents;
}

.modal-small {
  width: min(460px, 100%);
}

.modal-switcher {
  width: min(600px, 100%);
}

.modal-head,
.modal-foot {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* No rule under the title: its weight and the space around it set it apart from the content. */
.modal-head {
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4) var(--space-2) var(--dialog-pad);
}

.modal-head h2 {
  min-width: 0;
  padding-top: var(--space-1);
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-xl);
  line-height: var(--leading-xl);
  font-weight: var(--weight-bold);
  overflow-wrap: anywhere;
}

/* Close and the other header buttons: small filled circles, quieter than any action. */
.modal-head > .icon-btn {
  flex: none;
  border-radius: var(--radius-pill);
  background: var(--field-bg);
}

@media (hover: hover) and (pointer: fine) {
  .modal-head > .icon-btn:hover:not(:disabled) {
    background: var(--field-bg-hover);
  }
}

/* No rule above the actions either; inside a form's body they follow its last field. */
.modal-foot {
  justify-content: flex-end;
  flex-wrap: wrap;
  padding: var(--space-2) var(--dialog-pad) var(--dialog-pad);
}

.modal-body {
  padding: var(--space-2) var(--dialog-pad) var(--dialog-pad);
  overflow-y: auto;
}

.modal-body:first-child {
  padding-top: var(--dialog-pad);
}

.modal-body + .modal-foot {
  padding-top: 0;
}

.modal-body .modal-foot {
  margin-top: var(--space-3);
  padding: var(--space-2) 0 0;
}

/* Actions: one height and radius, the hierarchy in the fill. A plain `.btn` is the secondary
   action (a tint, no outline); `.btn-primary` and `.btn-danger` are filled; `.btn-quiet` is text. */
.modal-foot .btn {
  min-height: var(--control-h);
  padding: 0 var(--space-5);
  border: 0;
  border-radius: var(--control-radius);
  background: var(--field-bg);
  font-weight: var(--weight-semibold);
}

.modal-foot .btn-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.modal-foot .btn-danger {
  background: var(--danger);
  color: var(--on-danger);
}

.modal-foot .btn-quiet {
  background: transparent;
}

@media (hover: hover) and (pointer: fine) {
  .modal-foot .btn:hover:not(:disabled) {
    background: var(--field-bg-hover);
  }

  .modal-foot .btn-primary:hover:not(:disabled) {
    background: var(--accent-strong);
  }

  .modal-foot .btn-danger:hover:not(:disabled) {
    background: color-mix(in srgb, var(--danger) 85%, black);
  }

  .modal-foot .btn-quiet:hover:not(:disabled) {
    background: var(--danger-soft);
  }
}

.modal-foot .btn:disabled {
  opacity: 0.45;
}

/* Buttons inside the content (upload a picture, reset a colour) are secondary actions too: the
   same tint and radius, at their own height. `:where` keeps pressed toggles and the filled kinds
   in charge. */
.modal-body :where(.btn:not(.btn-primary, .btn-danger, .btn-quiet)) {
  border-color: transparent;
  border-radius: var(--control-radius);
  background: var(--field-bg);
}

@media (hover: hover) and (pointer: fine) {
  .modal-body :where(.btn:not(.btn-primary, .btn-danger, .btn-quiet)):hover:not(:disabled) {
    background: var(--field-bg-hover);
  }
}

/* Fields: filled and rounded, not boxed; the label above names them, focus draws the edge and
   the ring. */
.modal-body .input:not(.input-small) {
  min-height: var(--control-h);
  padding: 0 var(--space-3);
  border-color: transparent;
  border-radius: var(--control-radius);
  background: var(--field-bg);
}

.modal-body textarea.input {
  padding: var(--space-2) var(--space-3);
}

@media (hover: hover) and (pointer: fine) {
  .modal-body .input:hover:not(:focus-visible, :disabled) {
    border-color: transparent;
    background: var(--field-bg-hover);
  }
}

.modal-body .input:focus-visible {
  border-color: var(--focus);
  background: var(--dialog-surface);
}

/* Checkboxes in a dialog are rows of one group: filled, a hairline between neighbours. */
.modal-body .check-row {
  min-height: var(--control-h);
  margin: var(--space-1) 0;
  padding: var(--space-2) var(--space-3);
  gap: var(--space-3);
  border-radius: var(--control-radius);
  background: var(--field-bg);
  cursor: pointer;
}

.modal-body .check-row:has(+ .check-row) {
  margin-bottom: 0;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.modal-body .check-row + .check-row {
  margin-top: 0;
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  box-shadow: inset 0 1px 0 var(--dialog-edge);
}

/* More contrast: a solid edge around the panel and the fields instead of tints alone. Forced
   colours drop shadows, so the panel keeps an outline there. */
@media (prefers-contrast: more) {
  .modal {
    border: 1px solid var(--border-strong);
  }

  .modal-body .input {
    border-color: var(--border-strong);
  }
}

@media (forced-colors: active) {
  .modal {
    border: 1px solid CanvasText;
  }
}

.emoji-input {
  width: 52px;
  text-align: center;
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-xl);
  line-height: var(--leading-xl);
}

/* The status emoji (#705): a square as tall as the text field beside it, which takes the rest of
   the row. It opens the emoji picker; the press answers at once. */
.emoji-pick-btn {
  flex: none;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text-muted);
  font-size: var(--text-xl);
  line-height: 1;
  transition: transform var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
}

.emoji-pick-btn:active:not(:disabled) {
  transform: scale(0.94);
}

.emoji-pick-btn:disabled {
  opacity: 0.6;
}

@media (hover: hover) and (pointer: fine) {
  .emoji-pick-btn:hover:not(:disabled) {
    border-color: var(--text-muted);
  }
}

@media (prefers-reduced-motion: reduce) {
  .emoji-pick-btn:active:not(:disabled) {
    transform: none;
  }
}

.preset-list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 12px 0 16px;
}

.preset {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
}

@media (hover: hover) and (pointer: fine) {
  .preset:hover {
    background: var(--surface-2);
  }
}

.shortcut-section {
  margin: 16px 0 6px;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.shortcut-table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
}

.shortcut-table th {
  padding: 8px 16px;
  font-weight: var(--weight-regular);
  text-align: left;
}

.shortcut-table td {
  padding: 8px 16px;
  text-align: right;
  white-space: nowrap;
}

.shortcut-table tr + tr {
  border-top: 1px solid var(--border);
}

/* The host in the question about a link (app_links.rs): the end that says who owns it first and large,
   then all of it, wrapped, so a long name can't push that end out of sight. */
.app-link-host { display: flex; flex-direction: column; gap: var(--space-1); }
.app-link-domain { font-size: var(--text-xl); letter-spacing: var(--tracking-xl); line-height: var(--leading-xl); font-weight: var(--weight-semibold); overflow-wrap: anywhere; }
.app-link-full-host { font-size: var(--text-sm); color: var(--text-muted); font-family: ui-monospace, monospace; overflow-wrap: anywhere; }
.modal-body .app-link-host { margin-block: var(--space-3); }
/* "Open in the app" (app_links.rs): a button in the banner row, not a link in a text. */
.open-in-app a.btn { text-decoration: none; }
/* Sentence, button and close: at phone width the sentence takes a line and the rest wraps below. */
.open-in-app { gap: var(--space-2) var(--space-3); }
.open-in-app-text { flex: 1 1 14rem; min-width: 0; overflow-wrap: anywhere; }
.open-in-app .grow { display: none; }
.open-in-app .icon-btn { margin-inline-start: auto; }

/* Sharing into the app (share_into.rs). */
.share-into-notice {
  position: fixed;
  inset-block-start: var(--space-3);
  inset-inline: var(--space-4);
  margin-inline: auto;
  width: fit-content;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  font-size: var(--text-sm);
  z-index: 60;
}
.share-into-notice[role="alert"] { background: var(--mention-bg); color: var(--mention-text); }
.share-into-summary { color: var(--text-muted); margin: 0 0 var(--space-2); overflow-wrap: anywhere; }
.share-into-targets { max-height: 22rem; overflow: auto; margin-top: var(--space-2); }
.share-into-targets .forward-list { max-height: none; overflow: visible; margin: 0; }
.share-into-section-title { margin: var(--space-2) 0 var(--space-1); font-size: var(--text-xs); font-weight: var(--weight-semibold); color: var(--text-muted); }
.share-into-files { list-style: none; margin: 0 0 var(--space-2); padding: 0; max-height: 7rem; overflow: auto; font-size: var(--text-sm); }
.share-into-files li { display: flex; justify-content: space-between; gap: var(--space-3); overflow-wrap: anywhere; }
.share-into-size { color: var(--text-muted); white-space: nowrap; }
/* ---- Quick switcher: the one search of the top bar ---- */

.switcher-input {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  padding: 0 16px;
  border-bottom: 1px solid var(--border);
  color: var(--text-muted);
}

/* The search's chips: the scope and other filters in front of the field, removable. */
.switcher-chips {
  display: contents;
  margin: 0;
  padding: 0;
  list-style: none;
}

.switcher-chips .token-chip {
  flex: none;
}

.switcher-input input {
  flex: 1;
  min-width: 8rem;
  height: 50px;
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
  /* The switcher's only field, focused whenever it is open: the caret marks it, a ring would only
     frame the whole dialog. */
  outline: none;
}

/* Filter buttons under the field; on a narrow screen they scroll sideways instead of wrapping. */
.switcher-filters {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  border-bottom: 1px solid var(--border);
}

.switcher-filters::-webkit-scrollbar {
  display: none;
}

.switcher-filters .chip-btn {
  flex: none;
  white-space: nowrap;
}

.chip-btn[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.chip-btn-icon {
  padding: 0 8px;
}

.switcher-results {
  overflow-y: auto;
  padding: 6px;
  max-height: 60vh;
}

.switcher-group {
  padding: 10px 10px 4px;
  font-size: var(--text-2xs);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.switcher-group:first-child {
  padding-top: 4px;
}

.switcher-row {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 36px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
}

/* The active row is tinted, not filled: names and context stay readable. */
.switcher-row.active {
  background: var(--accent-soft);
  box-shadow: inset 3px 0 0 var(--accent);
}

.switcher-lead {
  display: inline-flex;
  flex: none;
  justify-content: center;
  width: 24px;
  color: var(--text-muted);
}

.switcher-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.switcher-context {
  flex: none;
  max-width: 45%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
}

.switcher-action .switcher-name {
  color: var(--accent-strong);
}

.unread-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--badge-bg);
}

.switcher-empty {
  padding: 12px 10px 4px;
  color: var(--text-muted);
  cursor: default;
}

/* Every hint on one baseline with the same gaps; narrow windows wrap the hints, they don't shift. */
.switcher-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  column-gap: 16px;
  row-gap: 6px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  line-height: 18px;
  color: var(--text-muted);
}

.switcher-hint {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}

.switcher-hint .shortcut {
  gap: 2px;
}

.switcher-foot kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  box-sizing: border-box;
  padding: 0 5px;
  line-height: 1;
}

.switcher-foot kbd + kbd {
  margin-left: 2px;
}

.switcher-foot .shortcut-plus {
  color: inherit;
}

/* "Search messages" looks like the other hints; it is only a button. */
.switcher-hint-action {
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .switcher-hint-action:hover {
    color: var(--text);
  }
}

/* ---- Narrow windows ---- */

@media (max-width: 1100px) {
  .side-panel:not(.embedded) {
    position: fixed;
    right: 0;
    top: calc(var(--topbar-h) + var(--banners-h, 0px));
    bottom: 0;
    z-index: 30;
    max-width: 92vw;
    box-shadow: var(--shadow);
  }
}

@media (max-width: 760px) {
  :root {
    --sidebar-w: 210px;
  }

  .header-topic,
  .header-divider,
  .composer-hint {
    display: none;
  }
}

/* ---- Calls ---- */

.btn-small {
  min-height: 28px;
  padding: 0 10px;
  font-size: var(--text-sm);
}

.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--on-danger);
}

@media (hover: hover) and (pointer: fine) {
  .btn-danger:hover {
    background: color-mix(in srgb, var(--danger) 85%, black);
  }
}

.small {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.mono {
  font-family: var(--font-mono);
}

.huddle-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--accent-soft);
}

.huddle-icon {
  color: var(--accent-strong);
}

.huddle-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.huddle-names {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
}

.huddle-controls {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* In the call on another device: three choices don't fit next to the names on a phone; they move
   to their own row, the main one last (nearest the thumb). */
@media (max-width: 600px) {
  .huddle-bar-choices {
    flex-wrap: wrap;
    row-gap: 6px;
  }

  .huddle-bar-choices .huddle-info {
    flex-basis: calc(100% - 40px);
  }

  .huddle-bar-choices .huddle-controls {
    flex-basis: 100%;
    justify-content: flex-end;
  }
}

/* A minimized call (#1141): a bar above the app in every view, in the call's own dark colours, so
   the rest of the app stays usable. Selecting its name or the expand button returns to the call. */
.call-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 8px 4px 16px;
  background: var(--call-bg);
  color: var(--call-text);
}

.call-bar-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--online);
}

.call-bar-open {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 2px 4px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  text-align: left;
}

.call-bar-open > * {
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.call-bar-open .small {
  color: var(--call-muted);
}

.call-bar-controls {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
}

.call-bar .icon-btn[aria-pressed="true"] {
  color: var(--call-danger);
}

.call-bar .leave {
  background: var(--call-danger);
  color: var(--on-fill);
}

.hangup {
  transform: rotate(135deg);
}

/* Pre-join and call screens use their own dark surface in both themes. */
.prejoin,
.call-screen {
  position: fixed;
  inset: calc(var(--topbar-h) + var(--banners-h, 0px)) 0 0 0;
  z-index: 20;
  background: var(--call-bg);
  color: var(--call-text);
}

/* The pre-join screen (#1928): the title on top; the preview with its video options (and a
   guest's name) on the left, the audio options and the buttons on the right. */
.prejoin {
  --set-switch-w: 40px;
  --set-switch-h: 24px;
  --set-switch-off: var(--call-switch-off);
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(320px, 0.75fr);
  grid-template-areas:
    "head head"
    "video panel";
  column-gap: clamp(24px, 4vw, 56px);
  row-gap: 24px;
  align-items: start;
  align-content: start;
  /* No bottom padding: a sticky footer sticks inside the padding, not at the screen's edge. The
     panel keeps the space below it instead. */
  padding: 32px clamp(16px, 5vw, 72px) 0;
  overflow-y: auto;
  /* A control focused with the keyboard scrolls into view above the sticky footer, not under it. */
  scroll-padding-bottom: 96px;
}

.prejoin .muted-text,
.call-screen .muted-text {
  color: var(--call-muted);
}

.prejoin-head {
  grid-area: head;
  text-align: center;
}

.prejoin-head h1 {
  font-size: var(--text-2xl);
  letter-spacing: var(--tracking-2xl);
  line-height: var(--leading-2xl);
  margin: 0 0 4px;
}

.prejoin-video {
  grid-area: video;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 760px;
  width: 100%;
  justify-self: end;
}

.prejoin-preview {
  position: relative;
  width: 100%;
}

.prejoin-preview .tile {
  aspect-ratio: 16 / 10;
}

/* The own tile without a camera image: a calm surface with the user's picture, like a muted
   participant in a call, and what the camera does. */
.tile.prejoin-self {
  background: var(--call-surface-solid);
  outline-color: var(--call-border);
  outline-width: 1px;
  outline-offset: -1px;
}

.prejoin-self-body {
  position: absolute;
  inset: 0 0 56px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
}

.prejoin-self-status {
  color: var(--call-muted);
  font-size: var(--text-sm);
}

/* The camera's first picture takes over from the user's picture with a short fade (#442), an
   opacity change that stays with reduced motion. */
.prejoin-preview .live-video {
  animation: motion-fade-in var(--dur-base) var(--ease-standard);
}

.round-btn {
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 26, 38, 0.75);
  color: var(--on-fill);
  backdrop-filter: blur(6px);
}

@media (hover: hover) and (pointer: fine) {
  .round-btn:hover {
    background: rgba(60, 70, 90, 0.9);
  }
}

.round-btn.off {
  background: var(--danger);
}

.round-btn .icon {
  width: 20px;
  height: 20px;
}

.prejoin-panel {
  grid-area: panel;
  max-width: 480px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.prejoin-panel .field {
  margin-top: 16px;
  margin-bottom: 0;
}

.prejoin .input {
  background: var(--call-surface);
  border-color: var(--call-border);
  color: var(--call-text);
}

/* Secondary buttons on the call surface. The primary one keeps the shared filled style in every
   state: a dark hover behind its label (dark in the dark theme) made "Join now" unreadable (#1953). */
.prejoin .btn:not(.btn-primary) {
  background: var(--call-surface);
  border-color: var(--call-border);
  color: var(--call-text);
}

@media (hover: hover) and (pointer: fine) {
  .prejoin .btn:not(.btn-primary):hover:not(:disabled) {
    background: var(--call-hover);
  }
}

.prejoin .btn:not(.btn-primary):active:not(:disabled) {
  background: var(--call-pressed);
}

.field-title {
  font-weight: var(--weight-semibold);
}

.meter {
  display: flex;
  gap: 3px;
  height: 8px;
  margin-top: 4px;
}

.meter-bar {
  flex: 1;
  border-radius: 2px;
  background: #263044;
}

.meter-bar.lit {
  background: var(--online);
}

.e2ee-note {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  color: var(--call-muted);
  font-size: var(--text-sm);
}

/* "Join now" stays in view whatever the window's height (#820): when the screen scrolls, the
   buttons stick to its bottom edge, on a surface of their own so the settings pass behind them. */
.prejoin-actions {
  position: sticky;
  bottom: 0;
  z-index: 1;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 20px;
  padding: 12px 0 calc(12px + env(safe-area-inset-bottom));
  background: var(--call-bg);
}

/* A short fade instead of a hard edge where the settings go behind the footer. */
.prejoin-actions::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 100%;
  height: 16px;
  background: linear-gradient(to bottom, transparent, var(--call-bg));
  pointer-events: none;
}

.effect-more {
  margin-top: 8px;
}

/* The slim bar under the preview: camera, backgrounds, video settings. */
.prejoin-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--call-border);
  border-radius: var(--radius-lg);
  background: var(--call-surface);
}

.prejoin-bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 0 12px;
  border: 0;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--call-text);
  font: inherit;
  cursor: default;
  transition: background-color var(--dur-fast) var(--ease-standard);
}

.prejoin-bar-btn.icon-only {
  width: 40px;
  padding: 0;
  justify-content: center;
}

.prejoin-bar-btn .icon {
  width: 20px;
  height: 20px;
}

.prejoin-bar-btn.off .icon {
  color: var(--danger);
}

.prejoin-bar-btn[aria-expanded="true"] {
  background: var(--call-hover);
}

@media (hover: hover) and (pointer: fine) {
  .prejoin-bar-btn:hover:not(:disabled) {
    background: var(--call-hover);
  }
}

.prejoin-bar-btn:active:not(:disabled) {
  background: var(--call-pressed);
}

.prejoin-bar-btn:disabled {
  opacity: 0.45;
}

/* What the bar opens: the backgrounds or the camera choice, right below it. */
.prejoin-drawer {
  padding: 4px 4px 8px;
  animation: motion-fade-in var(--dur-base) var(--ease-standard);
}

.prejoin-drawer .field {
  margin: 0 0 12px;
}

/* A guest's name, under the video. */
.prejoin-identity {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.prejoin-identity .small {
  margin: 0;
}

.prejoin-status {
  margin: 0;
}

/* Audio as selectable cards: the chosen one opens with its settings. */
.audio-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.audio-options legend {
  padding: 0;
  margin-bottom: 8px;
  font-weight: var(--weight-semibold);
}

.audio-card {
  border: 1px solid var(--call-border);
  border-radius: var(--radius-lg);
  background: var(--call-surface);
  transition: border-color var(--dur-fast) var(--ease-standard);
}

.audio-card.selected {
  border-color: var(--accent);
}

.audio-card-head {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 48px;
  padding: 0 14px;
  font-weight: var(--weight-medium);
  cursor: default;
}

.audio-card-head input {
  accent-color: var(--accent);
  margin: 0;
}

.audio-card-head .icon {
  width: 20px;
  height: 20px;
  color: var(--call-muted);
}

.audio-card-body {
  padding: 0 14px 14px;
  animation: motion-fade-in var(--dur-base) var(--ease-standard);
}

.audio-card-body .field:first-child {
  margin-top: 0;
}

.audio-card-body.muted-text {
  margin: 0;
}

.field-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Before a guest turned the devices on: why the page asks (#1928), on the preview's surface. */
.prejoin-access {
  display: grid;
  place-items: center;
}

.prejoin-access-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 420px;
  padding: 24px;
  text-align: center;
}

.prejoin-access-body h2 {
  margin: 0;
  font-size: var(--text-lg);
}

.prejoin-access-body p {
  margin: 0;
}

.prejoin-access-icon {
  width: 32px;
  height: 32px;
  color: var(--call-muted);
}

.prejoin-access-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 6px;
}

/* The browser refused the devices: how to allow them, over the bottom of the preview. */
.prejoin-blocked {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: rgba(20, 26, 38, 0.92);
  color: var(--call-text);
  font-size: var(--text-sm);
}

.prejoin-blocked p {
  flex: 1;
  margin: 0;
}

.prejoin-blocked .icon {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--call-notice-text);
}

/* A guest's page has no app bar: the pre-join screen covers the window. */
.guest-prejoin .prejoin {
  inset: var(--banners-h, 0px) 0 0 0;
}

/* The small preview while a guest waits, and the options behind a disclosure. */
.guest-waiting-devices {
  margin-top: 16px;
}

.guest-waiting-devices .prejoin-preview {
  max-width: 280px;
  margin: 0 auto;
}

.guest-waiting-devices .prejoin-preview .tile {
  border-radius: var(--radius-lg);
}

.guest-device-settings {
  margin-top: 12px;
}

.guest-device-settings summary {
  cursor: default;
  font-weight: var(--weight-medium);
}

.guest-device-fields {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

/* The in-call popover is a dark surface like the pre-join screen, whose buttons are restyled. */
.effects-popover .effect-more {
  background: var(--call-surface);
  border-color: var(--call-border);
  color: var(--call-text);
}

.effect-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.effect-group {
  grid-column: 1 / -1;
  margin: 8px 0 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
}

.effect-photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.effect-tile {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: inherit;
  text-align: center;
}

.effect-tile[aria-checked="true"] {
  border-color: var(--accent);
}

.effect-tile:disabled {
  opacity: 0.55;
}

.effect-swatch {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 16 / 10;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #1d2535;
}

.effect-name {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  line-height: 1.2;
}

/* A long name breaks inside its tile instead of running into the next one. */
@media (max-width: 480px) {
  .effect-name {
    overflow-wrap: anywhere;
  }
}

/* Scenes: the room behind the user. Blur is applied to the scene only, never to the person. */
.scene {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, transparent 0 18%, rgba(255, 255, 255, 0.08) 18% 20%, transparent 20% 62%, rgba(255, 255, 255, 0.08) 62% 64%, transparent 64%),
    linear-gradient(180deg, #5b6b82 0 55%, #3c4658 55% 100%);
}

.effect-blur-light .scene {
  filter: blur(3px);
}

.effect-blur-strong .scene {
  filter: blur(11px);
}

.effect-office .scene {
  background: linear-gradient(180deg, #cfd8e3 0 60%, #8d99a8 60%), radial-gradient(circle at 70% 30%, #fff8, transparent 40%);
  background-blend-mode: normal;
}

.effect-bookshelf .scene {
  background:
    repeating-linear-gradient(90deg, #7a4f32 0 6px, #a06a42 6px 12px, #5f6f4a 12px 17px, #8a6a2f 17px 24px),
    #5b3d27;
  background-size: 100% 33.4%;
}

.effect-sunrise .scene {
  background: linear-gradient(180deg, #2f3e78 0%, #c0568a 45%, #f4a259 75%, #f7d57a 100%);
}

.effect-forest .scene {
  background:
    radial-gradient(ellipse at 20% 100%, #1f5a3a 0 40%, transparent 41%),
    radial-gradient(ellipse at 70% 110%, #164a30 0 45%, transparent 46%),
    linear-gradient(180deg, #86b7a0, #3f7a5c);
}

.effect-upload {
  border: 1px dashed #4a5670;
  background: transparent;
}

/* Tiles */
.tile {
  position: relative;
  min-width: 0;
  min-height: 0;
  border-radius: var(--radius-md);
  overflow: hidden;
  background: hsl(var(--hue) 28% 22%);
  outline: 3px solid transparent;
  outline-offset: -3px;
  transition: outline-color var(--dur-fast) var(--ease-standard);
}

.tile-speaking {
  outline-color: var(--accent);
}

/* Connection lost, rejoining: dimmed until the person is back. */
.tile-reconnecting .video-surface {
  opacity: 0.45;
}

.tile-status {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 2px 8px;
  border-radius: var(--radius-pill);
  background: rgb(0 0 0 / 0.6);
  color: var(--on-fill);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.tile-status-warning {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--danger);
}

.tile-status-warning .icon {
  width: 12px;
  height: 12px;
}

.video-surface {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.tile-initials {
  display: grid;
  place-items: center;
  width: clamp(48px, 28%, 120px);
  aspect-ratio: 1;
  border-radius: 50%;
  background: hsl(var(--hue) 45% 38%);
  color: var(--on-fill);
  font-size: clamp(18px, 3vw, 36px);
  font-weight: var(--weight-semibold);
  /* The profile picture fills the same circle. */
  overflow: hidden;
}

.silhouette {
  position: absolute;
  left: 50%;
  bottom: -6%;
  width: 46%;
  height: 78%;
  transform: translateX(-50%);
}

.silhouette.mirrored {
  transform: translateX(-50%) scaleX(-1);
}

/* Real call video (browser): fills the tile; a shared screen keeps its whole picture. */
.live-video {
  position: absolute;
  inset: 0;
  background: #05070b;
}

.live-video > canvas,
.live-video > video {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.live-video.mirrored {
  transform: scaleX(-1);
}

.shared-screen .live-video {
  position: static;
  width: 100%;
  height: 100%;
}

.shared-screen .live-video > canvas {
  object-fit: contain;
}

/* Another device's video got no new picture for a while (#921): a quiet note over the last one,
   styled like the tile's status. Reconnecting says more already. */
.video-stalled {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  max-width: calc(100% - 24px);
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: rgb(0 0 0 / 0.6);
  color: var(--on-fill);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
  animation: video-stalled-in var(--dur-base) var(--ease-standard);
}

@keyframes video-stalled-in {
  from {
    opacity: 0;
  }
}

.tile-reconnecting .video-stalled {
  display: none;
}

/* Stats for nerds (#938): compact monospace numbers over the video's top left corner, readable on
   any picture; a small tile scrolls them. */
.video-stats {
  position: absolute;
  top: 8px;
  left: 8px;
  z-index: 1;
  max-width: calc(100% - 16px);
  max-height: calc(100% - 52px);
  overflow: auto;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  background: rgb(0 0 0 / 0.72);
  color: var(--on-fill);
  font-family: var(--font-mono);
  font-size: var(--text-2xs);
  line-height: 1.35;
  font-variant-numeric: tabular-nums;
  text-align: start;
  user-select: text;
}

.video-stats-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 4px;
}

.video-stats-title {
  font-weight: var(--weight-semibold);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.video-stats-copy {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgb(255 255 255 / 0.12);
  color: inherit;
  cursor: pointer;
}

.video-stats-copy svg {
  width: 14px;
  height: 14px;
}

.video-stats-copy:hover {
  background: rgb(255 255 255 / 0.24);
}

.video-stats-copy:disabled {
  opacity: 0.4;
  cursor: default;
}

.video-stats-rows {
  display: grid;
  grid-template-columns: auto 1fr;
  column-gap: 10px;
  margin: 0;
}

.video-stats-rows dt {
  color: rgb(255 255 255 / 0.66);
  white-space: nowrap;
}

.video-stats-rows dd {
  margin: 0;
  white-space: nowrap;
}

.video-stats-waiting {
  margin: 0;
  color: rgb(255 255 255 / 0.66);
}

/* The quality menu's button on another person's video (#967), in the corner the name leaves
   free. With a mouse it shows while the pointer is over the video, like a player's controls;
   on touch it stays. */
.tile-quality {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: rgb(0 0 0 / 0.55);
  color: var(--on-fill);
  cursor: pointer;
  transition:
    opacity var(--dur-fast) var(--ease-standard),
    background-color 120ms ease-out;
}

.tile-quality svg {
  width: 16px;
  height: 16px;
}

.tile-quality:active,
.tile-quality.active {
  background: rgb(0 0 0 / 0.78);
}

@media (hover: hover) and (pointer: fine) {
  .tile-quality {
    opacity: 0;
  }

  :is(.tile, .shared-screen):hover .tile-quality,
  .tile-quality:focus-visible,
  .tile-quality.active {
    opacity: 1;
  }

  .tile-quality:hover:not(:active) {
    background: rgb(0 0 0 / 0.7);
  }
}

@media (prefers-reduced-motion: reduce) {
  .tile-quality {
    transition: none;
  }
}

.quality-popover {
  width: min(300px, calc(100% - 32px));
}

.quality-hint {
  margin: 10px 2px 0;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.silhouette::before,
.silhouette::after {
  content: "";
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  background: hsl(var(--hue) 35% 62%);
}

.silhouette::before {
  top: 4%;
  width: 36%;
  aspect-ratio: 1;
  border-radius: 50%;
}

.silhouette::after {
  top: 48%;
  width: 92%;
  height: 60%;
  border-radius: 50% 50% 0 0 / 70% 70% 0 0;
  background: hsl(var(--hue) 40% 48%);
}

.tile-label {
  position: absolute;
  left: 8px;
  bottom: 8px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: calc(100% - 16px);
  padding: 2px 8px;
  border-radius: var(--radius-sm);
  background: rgba(8, 12, 20, 0.62);
  color: var(--on-fill);
  font-size: var(--text-sm);
}

.tile-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-badge {
  width: 14px;
  height: 14px;
  color: #ff8a7a;
}

.tile-hand {
  position: absolute;
  top: 8px;
  right: 8px;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: #f0b04a;
  color: #231a05;
}

/* Call screen */
.call-screen {
  display: flex;
  flex-direction: column;
}

.call-header {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 20px;
}

.call-heading h1 {
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
}

.call-meta {
  display: flex;
  gap: 12px;
  font-size: var(--text-sm);
  color: var(--call-muted);
  font-variant-numeric: tabular-nums;
}

.e2ee-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: #16261f;
  color: #7be0b0;
  font-size: var(--text-sm);
}

.e2ee-pill .mono {
  color: #b7c4d8;
}

.call-stage-wrap {
  flex: 1;
  min-height: 0;
  padding: 0 20px;
  display: flex;
}

.stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: grid;
  gap: 10px;
}

.stage-gallery {
  grid-template-columns: repeat(var(--cols, 2), minmax(0, 1fr));
  grid-auto-rows: minmax(0, 1fr);
}

.stage-speaker {
  grid-template-rows: minmax(0, 1fr) 130px;
}

.speaker-main {
  min-height: 0;
  display: grid;
}

.filmstrip {
  display: flex;
  gap: 10px;
  min-width: 0;
  overflow-x: auto;
}

.filmstrip .tile {
  flex: none;
  aspect-ratio: 16 / 10;
  height: 100%;
}

/* The shared screen gets the room first (#1801): the people's strip goes beside it or below it,
   whichever leaves the screen the larger picture (share_stage.rs sets the class and
   --strip-size from the stage's size), and scrolls rather than growing. */
.stage-share {
  grid-template-columns: minmax(0, 1fr) var(--strip-size, 190px);
}

.stage-share.strip-bottom {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr) var(--strip-size, 28%);
}

.stage-share.strip-bottom .filmstrip-side {
  flex-direction: row;
  overflow-x: auto;
  overflow-y: visible;
}

.stage-share.strip-bottom .filmstrip-side .tile {
  height: 100%;
  width: auto;
}

.filmstrip-side {
  flex-direction: column;
  overflow-x: visible;
  overflow-y: auto;
}

.filmstrip-side .tile {
  height: auto;
  width: 100%;
}

.share-main {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.share-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: var(--radius);
  background: #1b2434;
  font-size: var(--text-sm);
}

.share-banner .btn {
  margin-left: auto;
  background: #2a3550;
  border-color: #3a4766;
  color: var(--on-fill);
}

.shared-screen {
  position: relative;
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(0, 1fr);
  place-items: center;
  border-radius: var(--radius-md);
  background: #05070b;
  padding: 16px;
}

.share-waiting {
  margin: 0;
  color: #b9c3d6;
  font-size: var(--text-sm);
  text-align: center;
}

/* What the own screen share sends, small on purpose (#1175): sharing the whole screen or this
   window must not fill the stage with mirrors of itself. Over another person's shared screen it
   sits in a corner. The stage is dark in both themes, like the rest of the call. */
.share-preview {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(100%, 320px);
  max-height: 100%;
  min-height: 0;
  padding: 8px;
  border: 1px solid #2a3550;
  border-radius: var(--radius-md);
  background: #1b2434;
}

.share-preview-over-picture {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 1;
  width: min(calc(100% - 24px), 240px);
  max-height: calc(100% - 24px);
}

.share-preview-picture {
  position: relative;
  flex: 0 1 auto;
  min-height: 0;
  overflow: hidden;
  /* In a short stage the picture gives way, never the button. */
  aspect-ratio: 16 / 9;
  border-radius: var(--radius-sm);
  background: #05070b;
}

.share-preview-picture .live-video > canvas,
.share-preview-picture .live-video > video {
  object-fit: contain;
}

/* No picture from the capture: the last one must not pass for a live one. */
.share-preview-picture .live-video:has(+ .video-stalled) {
  opacity: 0.3;
}

.share-preview-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: var(--text-sm);
}

.share-preview-bar > span {
  min-width: 0;
  flex: 1;
}

.share-preview-bar .icon {
  flex: none;
}

.share-preview-bar .btn {
  flex: none;
  background: #2a3550;
  border-color: #3a4766;
  color: var(--on-fill);
}

/* Wraps into a second row where the controls don't fit (a phone): centred and overflowing, the
   first and last of them (the microphone, the hang-up) were off the screen. */
.call-controls {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 18px;
}

.control-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border: 0;
  border-radius: 50%;
  background: #1f2736;
  color: var(--call-text);
}

@media (hover: hover) and (pointer: fine) {
  .control-btn:hover {
    background: #2c3649;
  }
}

.control-btn.off {
  background: #e0e4ec;
  color: #1b2230;
}

.control-btn.active {
  background: var(--accent);
  color: var(--on-accent);
}

/* Shown, but the policy doesn't let the user (issue #1290): a press says why. */
.control-btn.is-disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.control-btn .icon {
  width: 20px;
  height: 20px;
}

/* The chat's unread count on its button (#936); plain unread is light on the dark bar. */
.control-btn .badge-count {
  position: absolute;
  top: -3px;
  right: -3px;
}

.control-btn .badge-count.is-quiet {
  background: var(--call-text);
  color: var(--call-bg);
}

/* The chat next to the video (#936): the stage and the panel side by side. On a phone the panel
   covers the stage, and the control bar below stays to close it. The panel has the app's colours,
   not the call's, since its messages and composer are the conversation's. */
.call-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.call-chat {
  flex: none;
  width: var(--panel-w);
  max-width: 45vw;
  min-height: 0;
  margin-right: 20px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: var(--surface);
  color: var(--text);
  animation: motion-panel-in var(--dur-base) var(--ease-emphasized);
}

.call-chat .muted-text {
  color: var(--text-muted);
}

.call-chat :focus-visible {
  outline-color: var(--focus);
}

:root[data-layout="compact"] .call-chat {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: auto;
  max-width: none;
  margin: 0;
  border-radius: 0;
}

.call-chat-toasts {
  position: absolute;
  right: 20px;
  bottom: 12px;
  z-index: 2;
  pointer-events: none;
}

:root[data-layout="compact"] .call-chat-toasts {
  left: 16px;
  right: 16px;
}

.call-chat-toast {
  pointer-events: auto;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: min(360px, 100%);
  padding: 10px 14px;
  border: 1px solid var(--call-border);
  border-radius: var(--radius-md);
  background: var(--call-surface);
  color: var(--call-text);
  box-shadow: var(--shadow);
  text-align: left;
  animation: motion-toast-in var(--dur-base) var(--ease-emphasized);
}

.call-chat-toast .icon {
  flex: none;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  color: var(--accent);
}

.call-chat-toast-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  font-size: var(--text-sm);
}

.call-chat-toast-text > span {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--call-muted);
}

@media (prefers-reduced-motion: reduce) {
  .call-chat,
  .call-chat-toast {
    animation: motion-fade-in var(--dur-fast) var(--ease-standard);
  }
}

.leave-btn {
  --leave: var(--call-danger);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 46px;
  margin-left: 12px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--leave);
  color: var(--on-fill);
  font-weight: var(--weight-semibold);
}

@media (hover: hover) and (pointer: fine) {
  .leave-btn:hover,
  .leave-menu-btn:hover {
    background: var(--call-danger-hover);
  }
}

/* Hosts' hang-up (#1930): the red pill splits into "Leave" and an arrow that opens a drop-up with
   "Leave" and "End for everyone…", like the microphone's device arrow. One control in the bar. */
.leave-split {
  position: relative;
  display: flex;
  align-items: center;
  gap: 1px;
  margin-left: 12px;
}

.leave-split .leave-btn {
  margin-left: 0;
}

.leave-split.has-menu .leave-btn {
  padding-inline-end: 14px;
  border-start-end-radius: 0;
  border-end-end-radius: 0;
}

.leave-menu-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 46px;
  padding: 0 4px 0 0;
  border: 0;
  border-radius: 0 var(--radius-pill) var(--radius-pill) 0;
  background: var(--call-danger);
  color: var(--on-fill);
}

.leave-menu-btn .icon {
  width: 16px;
  height: 16px;
}

.leave-menu-btn[aria-expanded="true"] {
  background: var(--call-danger-hover);
}

/* Above the arrow, right-aligned with the hang-up. */
.popover.leave-menu {
  top: auto;
  bottom: calc(100% + 8px);
  right: 0;
}

.leave-menu .hangup {
  width: 18px;
  height: 18px;
}

.effects-popover {
  position: absolute;
  left: 50%;
  bottom: 84px;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  padding: 14px;
  border: 1px solid var(--call-border);
  border-radius: var(--radius-md);
  background: var(--call-surface);
  box-shadow: var(--shadow);
}

.effects-popover h2 {
  margin-bottom: 10px;
  font-size: var(--text-base);
}

.share-popover {
  width: min(380px, calc(100% - 32px));
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.share-popover .checkbox small {
  display: block;
  margin-top: 2px;
}

.share-popover .btn {
  align-self: flex-end;
}

.share-sound {
  color: #b9c3d6;
}

/* The camera menu of the call (#819): the cameras as a short list, the one in use checked. */
.camera-popover {
  width: min(340px, calc(100% - 32px));
}

.camera-options {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.camera-option {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 8px 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--call-text);
  text-align: left;
  transition: background-color 120ms ease-out;
}

.camera-option:active {
  background: var(--call-border);
}

@media (hover: hover) and (pointer: fine) {
  .camera-option:hover:not(:active) {
    background: rgba(255, 255, 255, 0.06);
  }
}

.camera-option.chosen {
  font-weight: var(--weight-semibold);
}

.camera-option-name {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.camera-option .icon {
  flex: none;
  width: 18px;
  height: 18px;
  color: var(--accent);
}

@media (prefers-reduced-motion: reduce) {
  .camera-option {
    transition: none;
  }
}

/* The microphone button with the arrow of its device menu (#986), one control in the bar. */
.control-split {
  display: flex;
  align-items: center;
  gap: 2px;
}

.control-btn.control-menu-btn {
  width: 28px;
  border-radius: 14px;
}

.control-menu-btn .icon {
  width: 16px;
  height: 16px;
}

/* The microphone and speaker menu (#986): two short lists, the level between them. */
.audio-popover {
  max-height: calc(100% - 100px);
  overflow-y: auto;
}

.audio-popover h2 + .camera-options {
  margin-bottom: 4px;
}

.audio-popover .camera-options + h2,
.audio-meter + h2 {
  margin-top: 14px;
}

.audio-meter {
  margin: 6px 10px 0;
}

.audio-test {
  margin-top: 10px;
}

.system-effects-hint {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 10px;
}

.system-effects-hint p {
  flex: 1;
}

.call-screen :focus-visible,
.prejoin :focus-visible {
  outline-color: var(--on-fill);
}


/* The notetaker (e2ee.md §8.2): the badge, the banner and its tile's label say that the call's
   audio leaves the end-to-end encryption while it is there. */
.e2ee-pill.is-notetaker {
  background: var(--call-notice-bg);
  color: var(--call-notice-text);
}

.call-notetaker-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 20px 0;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--call-notice-bg);
  color: var(--call-notice-text);
  font-size: var(--text-sm);
}

.call-notetaker-banner p {
  flex: 1;
  min-width: 12rem;
  margin: 0;
}

.call-notetaker-banner .btn {
  margin-left: auto;
}

.call-encryption-failed {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 20px 0;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--call-notice-bg);
  color: var(--call-notice-text);
  font-size: var(--text-sm);
}

.call-encryption-failed p {
  flex: 1;
  min-width: 12rem;
  margin: 0;
}

.call-encryption-actions {
  display: flex;
  gap: 8px;
  margin-left: auto;
}

.prejoin-notetaker {
  margin: 8px 0 0;
}

.tile-role {
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--call-notice-bg);
  color: var(--call-notice-text);
  font-size: var(--text-xs);
  white-space: nowrap;
}

/* Short windows (#1801): a laptop window next to a document, a phone on its side. The header,
   the controls and the frame around the shared screen give up padding before the stage loses
   height; the buttons keep a 44 px target. */
@media (max-height: 560px) {
  .call-header {
    padding: 4px 16px;
  }

  .call-controls {
    padding: 6px 16px 8px;
  }

  .control-btn {
    width: 44px;
    height: 44px;
  }

  .call-stage-wrap {
    padding: 0 12px;
  }

  .share-banner {
    padding: 4px 12px;
  }

  .shared-screen {
    padding: 8px;
  }
}

/* Call recording (#216, e2ee.md §8.3): a steady red dot, never animated (no looping motion), and
   text that names who records. The pill can't be closed. */
.recording-dot {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--danger);
}

.recording-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  background: var(--danger-soft);
  color: var(--text);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.tile-status-recording {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

/* Under the warning badge of the same corner. */
.tile-status-warning ~ .tile-status-recording {
  top: 36px;
}

.call-recording-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 20px 0;
  padding: 8px 12px;
  border-radius: var(--radius);
  background: var(--call-notice-bg);
  color: var(--call-notice-text);
  font-size: var(--text-sm);
}

.call-recording-banner p {
  flex: 1;
  min-width: 12rem;
  margin: 0;
}

.call-recording-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}

.call-recording-actions p {
  margin: 0;
}

/* The finished recording waits above the app's lower edge until it is posted or deleted. */
.call-recording-take {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 40;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 12px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 16px;
  border-radius: var(--radius-lg);
  background: var(--dialog-surface);
  box-shadow: var(--shadow-card);
}

.call-recording-take > .icon {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
  color: var(--danger);
}

.call-recording-take-text {
  flex: 1;
  min-width: 12rem;
}

.call-recording-take h2 {
  margin: 0 0 4px;
  font-size: var(--text-md);
}

.call-recording-take p {
  margin: 0;
  font-size: var(--text-sm);
}

.call-recording-take .call-recording-actions {
  flex-basis: 100%;
  justify-content: flex-end;
}

.recording-pill.is-warning {
  background: var(--call-notice-bg);
  color: var(--call-notice-text);
}

.recording-pill .icon {
  width: 14px;
  height: 14px;
}
/* Incoming call */
.incoming {
  position: fixed;
  top: calc(var(--topbar-h) + var(--banners-h, 0px) + 12px);
  right: 16px;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 14px;
  width: min(420px, calc(100vw - 32px));
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  box-shadow: var(--shadow);
}

.incoming .avatar-lg {
  width: 48px;
  height: 48px;
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
}

.incoming-ring {
  position: relative;
  border-radius: var(--radius-md);
}

/* The pulse is a ring that grows and fades (`transform` and `opacity`, on the compositor), not a
   box-shadow that is repainted every frame for as long as the call rings. */
.incoming-ring::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: 0 0 0 2px rgba(46, 182, 125, 0.5);
  pointer-events: none;
  animation: ring 1.4s var(--ease-standard) infinite;
}

@keyframes ring {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(1.4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .incoming-ring::after {
    animation: none;
  }
}

.incoming-body {
  flex: 1;
  min-width: 0;
}

.incoming-body h2 {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
  font-weight: var(--weight-semibold);
}

.incoming-body p {
  font-weight: var(--weight-bold);
}

.incoming-actions {
  display: flex;
  gap: 8px;
}

.incoming .round-btn {
  width: 40px;
  height: 40px;
  color: var(--on-fill);
}

.incoming .round-btn.accept {
  background: var(--online);
}

.incoming .round-btn.decline {
  background: var(--call-danger);
}

/* The desktop shell's incoming-call window (#650): the card fills a borderless window of its own;
   the system draws the window's shadow (and its rounded corners where it does). */
html.call-window,
html.call-window body {
  height: 100%;
  overflow: hidden;
  background: var(--surface);
}

.incoming.is-window {
  position: static;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  box-shadow: none;
  cursor: default;
  user-select: none;
}

.settings-heading {
  margin-top: 20px;
  font-size: var(--text-base);
}

@media (max-width: 900px) {
  .prejoin {
    /* `minmax(0, …)`: a plain `1fr` grows to the widest control and pushes the buttons off the
       screen on a phone. */
    grid-template-columns: minmax(0, 1fr);
    grid-template-areas:
      "head"
      "video"
      "panel";
  }

  .prejoin-video,
  .prejoin-panel {
    justify-self: stretch;
    max-width: none;
  }

  /* One column: the two buttons share the width, easy to hit with a thumb. */
  .prejoin-actions .btn {
    flex: 1;
  }
}


/* The desktop shell's small call window (#2077): who talks and the call's time on top, the
   controls below; the whole window can be dragged except its buttons. */
.call-mini {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
  height: 100%;
  padding: 12px 14px;
  cursor: default;
  user-select: none;
}

.call-mini-head {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.call-mini-glyph {
  display: grid;
  flex: none;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--online);
  color: var(--on-fill);
}

.call-mini-glyph .icon {
  width: 16px;
  height: 16px;
}

.call-mini-head .avatar.is-speaking {
  flex: none;
  box-shadow: 0 0 0 2px var(--online);
}

.call-mini-text {
  flex: 1;
  min-width: 0;
}

.call-mini-title,
.call-mini-status {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.call-mini-title {
  font-weight: var(--weight-semibold);
}

.call-mini-status {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.call-mini-back {
  flex: none;
}

.call-mini-controls {
  display: flex;
  gap: 8px;
}

.call-mini .round-btn {
  width: 36px;
  height: 36px;
}

.call-mini .round-btn .icon {
  width: 18px;
  height: 18px;
}

.call-mini .round-btn {
  transition: transform 100ms var(--ease-standard);
}

.call-mini .round-btn:active {
  transform: scale(0.94);
}

.call-mini .round-btn.call-mini-hangup {
  margin-left: auto;
  width: 52px;
  border-radius: var(--radius-pill);
  background: var(--call-danger);
}
/* ---- Administration ---- */

.admin {
  flex: 1;
  min-width: 0;
  display: flex;
}

.admin-nav {
  flex: none;
  width: 230px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
}

.admin-nav h1 {
  padding: 0 8px 10px;
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
}

.admin-nav-item,
.admin-back {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 34px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
}

@media (hover: hover) and (pointer: fine) {
  .admin-nav-item:hover,
  .admin-back:hover {
    background: var(--surface-3);
  }
}

.admin-nav-item[aria-current="page"] {
  background: var(--accent);
  color: var(--on-accent);
  font-weight: var(--weight-semibold);
}

.admin-back {
  color: var(--text-muted);
}

.flip {
  transform: rotate(180deg);
}

.rotate-up {
  transform: rotate(-90deg);
}

.rotate-down {
  transform: rotate(90deg);
}

.admin-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  padding: 20px 24px;
  overflow-y: auto;
}

.admin-section-head {
  flex: none;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.admin-section-head h2 {
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-xl);
  line-height: var(--leading-xl);
}

.metadata-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  flex: none;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.admin-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.admin-toolbar input[type="search"] {
  width: 260px;
}

.admin-split {
  flex: 1;
  min-height: 0;
  display: flex;
  gap: 16px;
}

.table-wrap {
  flex: 1;
  min-width: 0;
  overflow: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  align-self: flex-start;
  max-height: 100%;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--text-sm);
}

.data-table th,
.data-table td {
  padding: 8px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  font-weight: var(--weight-regular);
}

.data-table thead th {
  position: sticky;
  top: 0;
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
}

.data-table tbody tr:last-child th,
.data-table tbody tr:last-child td {
  border-bottom: 0;
}

.data-table tr.selected {
  background: var(--accent-soft);
}

.data-table tr.inactive {
  opacity: 0.6;
}

.data-table td,
.data-table th[scope="row"] {
  white-space: nowrap;
}

.data-table .num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.nowrap {
  white-space: nowrap;
}

.row-button {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 2px 4px;
  margin: -2px -4px;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  font-weight: var(--weight-semibold);
  text-align: left;
}

@media (hover: hover) and (pointer: fine) {
  .row-button:hover {
    background: var(--surface-3);
  }
}

.row-button .icon {
  color: var(--text-muted);
}

.row-button .avatar {
  margin-left: 0;
  box-shadow: none;
}

.badge-warn {
  background: var(--warn-soft);
  color: var(--warn-text);
}

.detail-pane {
  flex: none;
  width: 320px;
  align-self: flex-start;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.detail-pane h3 {
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
}

.detail-heading {
  margin: 16px 0 6px;
  font-size: var(--text-sm);
}

.meta-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  margin: 14px 0;
}

.meta-list dt {
  color: var(--text-muted);
}

.meta-list dd {
  margin: 0;
  text-align: right;
}

.no-content-note,
.signing-note {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.status-line {
  min-height: 20px;
  margin-top: 10px;
  color: var(--accent-strong);
  font-size: var(--text-sm);
}

.device-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.device {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.device-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.policy-form {
  max-width: 760px;
}

.policy-group {
  margin: 0 0 16px;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}


/* A refused save stays in view however far down the page its Save button is (forms.md, #1054). */
.admin-error {
  position: sticky;
  top: 0;
  z-index: 2;
  flex: none;
  margin-top: 0;
  margin-bottom: 12px;
  box-shadow: var(--shadow-card);
}

/* A retention limit: the choice, the number and its unit on one line; the field's error below. */
.retention-limit {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 8px;
}

.retention-limit .field-error {
  flex-basis: 100%;
  margin: 0;
}

/* The foot of a list that loads page by page. */
/* Watched for the next page of a list: starts it a screen before the foot is reached. */
.admin-more-sentinel {
  height: 240px;
  margin-top: -240px;
  pointer-events: none;
}

.admin-more {
  display: flex;
  justify-content: center;
  padding: 12px 0;
}

/* One rule of the identity provider group mapping (docs/provisioning.md §5). */
.settings-row-group {
  display: grid;
  gap: var(--space-2);
  padding-block: var(--space-3);
  border-top: 1px solid var(--border);
}

/* Legal hold (admin.md §3.14): below the retention table, the held channels and the form. */
.legal-holds {
  margin-top: 28px;
  max-width: 760px;
}

.legal-holds > h3 {
  margin: 0 0 4px;
}

.legal-hold-form {
  margin-top: 16px;
}

.legal-hold-form .field + .field {
  margin-top: 12px;
}

.legal-hold-form .btn-primary {
  margin-top: 16px;
}
/* Organization call backgrounds: the picture list and the upload row. */
.admin-list {
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.admin-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.admin-row-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-upload fieldset {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
  border: 0;
}

.policy-group legend {
  padding: 0 6px;
  font-weight: var(--weight-bold);
}

.policy-group .radio {
  align-items: flex-start;
}

.policy-group .radio > span {
  display: flex;
  flex-direction: column;
}

.policy-group .field {
  margin: 10px 0 0;
}

.field.inline {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.field.inline > label {
  font-weight: var(--weight-regular);
}

.policy-footer {
  position: sticky;
  bottom: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  background: var(--surface);
}

.policy-footer .signing-note {
  flex: 1;
}

.input.narrow {
  width: 110px;
}

.field-error {
  display: block;
  color: var(--danger);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.field-error:empty {
  display: none;
}

@media (max-width: 1100px) {
  .admin-split {
    flex-direction: column;
  }

  .detail-pane {
    width: auto;
    align-self: stretch;
  }
}

/* ---- Device approval, linking, key change ---- */

.modal-link {
  width: min(720px, 100%);
}

.approval-code {
  margin: 14px 0;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--surface-2);
  text-align: center;
  font: 700 34px var(--font-mono);
  letter-spacing: 0.5em;
  padding-left: calc(12px + 0.5em);
}

.approval-result {
  padding: 8px 0;
  font-size: var(--text-md);
}

.link-body {
  display: flex;
  gap: 28px;
  padding: 20px;
}

.link-qr {
  flex: none;
  width: 220px;
  text-align: center;
}

.qr {
  display: block;
  width: 220px;
  height: 220px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.link-steps {
  flex: 1;
  min-width: 0;
}

.link-steps ol {
  padding-left: 20px;
  list-style: decimal;
}

.link-steps li + li {
  margin-top: 8px;
}

.key-banner {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  border-bottom: 1px solid #e5c36b;
  background: var(--mention-bg);
  color: var(--mention-text);
}

.key-banner-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.key-banner .btn {
  background: transparent;
  border-color: currentColor;
  color: inherit;
}

/* The admin console's users left in encryption groups (#734): one banner, a compact row each. */
.leftover-list {
  align-items: flex-start;
}

.leftover-rows {
  margin: 8px 0 0;
  padding: 0;
  list-style: none;
}

.leftover-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0;
}

.leftover-row + .leftover-row {
  border-top: 1px solid var(--border);
}

.leftover-text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.fingerprint {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font: var(--text-md)/1.6 var(--font-mono);
  word-spacing: 0.4em;
  overflow-wrap: anywhere;
}

.fingerprint.muted {
  color: var(--text-muted);
  text-decoration: line-through;
}

@media (max-width: 760px) {
  .link-body {
    flex-direction: column;
    align-items: center;
  }
}

/* ---- Sign-in ----
   Every screen before the app (server entry, confirmation, sign-in, key setup) is one card with the
   same rhythm: brand, title, subtitle, content, actions, foot. Sizes come from the type, spacing
   and radius tokens at the top; nothing here picks its own colour. */

.auth-page {
  /* Pinned to the window's edges, not `min-height: 100dvh` (#1222): Safari keeps the `dvh` it
     computed with its toolbar expanded when the toolbar collapses, which left a band of the dark
     page background below the page. A fixed box follows the visible window. */
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: var(--space-6) var(--space-4);
  background:
    radial-gradient(900px 480px at 50% -12%, var(--accent-soft), transparent 70%),
    var(--bg);
  overflow-y: auto;
}

.auth-card {
  width: min(472px, 100%);
  padding: var(--space-8) var(--space-8) var(--space-6);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
  font-size: var(--text-md);
  line-height: 1.5;
}

/* A new screen fades in; the card itself stays put so switching screens does not jump. */
.auth-content {
  animation: auth-in var(--dur-base) var(--ease-out) both;
}

@keyframes auth-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
}

.auth-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  margin-bottom: var(--space-6);
  text-align: center;
}

/* A brand icon: a square beside the name. */
.auth-icon-img {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
}

/* The product mark (no server brand yet) above the wordmark (assets/brand). */
.auth-logo-img.auth-product-icon {
  width: 64px;
  height: 64px;
  max-height: none;
}

/* A server brand's icon (#1927): one mark, the size of the product's, on a calm tile. */
.auth-mark {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  overflow: hidden;
  border-radius: var(--radius-lg);
}

.auth-mark-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.auth-logo-img {
  display: block;
  max-width: 200px;
  max-height: 48px;
  object-fit: contain;
}

/* A brand's dark logo replaces the light one in the dark theme. */
.brand-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .brand-dark {
    display: block;
  }

  :root:not([data-theme="light"]) .brand-light:has(+ .brand-dark) {
    display: none;
  }
}

:root[data-theme="dark"] .brand-dark {
  display: block;
}

:root[data-theme="dark"] .brand-light:has(+ .brand-dark) {
  display: none;
}

/* The brand's own sign-in title under its mark, where it set one; the heading below says what to do. */
.auth-welcome {
  margin: calc(-1 * var(--space-2)) 0 var(--space-5);
  color: var(--text-muted);
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  line-height: var(--leading-lg);
  text-align: center;
  text-wrap: balance;
}

.auth-brand-text {
  margin: 0 0 var(--space-5);
  text-align: center;
}

.auth-card h1 {
  margin: 0 0 var(--space-2);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  line-height: 1.25;
  letter-spacing: -0.015em;
  text-align: center;
  text-wrap: balance;
}

.auth-subtitle {
  margin: 0 0 var(--space-6);
  text-align: center;
  text-wrap: pretty;
}

.auth-center {
  text-align: center;
}

/* Outside the card (settings, guest join, admin notes) these keep their simple form. */
.auth-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 20px 0 8px;
}

.auth-actions .btn {
  height: 40px;
  padding: 0 18px;
}

/* Another tab runs the app (#744, components/tab_elsewhere.rs): the title, one sentence, the choice. */
.tab-elsewhere h1 {
  text-wrap: balance;
}

.tab-elsewhere-body {
  margin: 8px 0 0;
  color: var(--text-muted);
}

.tab-elsewhere-error {
  margin: 12px 0 0;
  color: var(--danger);
  font-size: var(--text-sm);
}

.tab-elsewhere-hint {
  margin: 4px 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.auth-alert {
  display: flex;
  gap: 12px;
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: var(--radius);
  background: var(--mention-bg);
  color: var(--mention-text);
}

.auth-alert p {
  margin-top: 2px;
}

/* Forms: label above a full-width field, hint below. */
.auth-card .auth-form,
.auth-local {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0;
}

.auth-card .auth-form .field,
.auth-local .field {
  margin: 0;
}

.auth-card .field > label {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.auth-card .input {
  width: 100%;
  height: 44px;
  padding: 0 var(--space-3);
  border-radius: var(--radius-md);
  font-size: var(--text-md);
  transition:
    border-color var(--dur-fast) var(--ease-standard),
    box-shadow var(--dur-fast) var(--ease-standard);
}

.auth-card .input[aria-invalid="true"] {
  border-color: var(--danger);
}

.auth-card .input[readonly] {
  background: var(--surface-2);
}

.field-hint {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.auth-card .field-error {
  margin: 0;
  font-size: var(--text-sm);
}

.auth-card .field-error .mono {
  display: block;
}

.auth-card .input-with-action .btn {
  height: 44px;
}

/* Buttons: one height, full width for the main action, two equal halves for a choice. */
.auth-card .btn {
  min-height: 44px;
  padding: 0 var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-md);
}

.auth-card .btn:disabled {
  opacity: 0.7;
}

.auth-card .btn[aria-busy="true"] {
  cursor: progress;
}

.auth-card .btn .spinner {
  width: 16px;
  height: 16px;
  border-color: color-mix(in srgb, currentColor 30%, transparent);
  border-top-color: currentColor;
}

.auth-card .auth-actions {
  gap: var(--space-2);
  margin: var(--space-6) 0 0;
}

.auth-card .auth-actions .btn {
  flex: 1 1 auto;
  height: auto;
  padding: 0 var(--space-4);
}

.auth-card .auth-actions-split {
  flex-wrap: wrap;
}

/* The question before an action that can't be undone (setting a device up again). */
.auth-card .auth-confirm-text {
  margin: 0 0 var(--space-3);
  font-weight: 600;
}

/* Side by side while both labels fit on one line, stacked (full width) when not. */
.auth-card .auth-actions-split .btn {
  flex: 1 1 0;
  min-width: max-content;
  padding: 0 var(--space-3);
  font-size: var(--text-base);
  white-space: nowrap;
}

.auth-wide,
.auth-sso,
.auth-submit {
  width: 100%;
}

.auth-sso,
.auth-submit {
  font-weight: var(--weight-semibold);
}

.auth-submit {
  margin-top: var(--space-2);
}

.auth-sso {
  gap: var(--space-3);
}

.auth-sso-icon {
  width: 20px;
  height: 20px;
  padding: 1px;
  border-radius: var(--radius-sm);
  background: white;
  object-fit: contain;
}

/* Status lines with a spinner (checking, waiting for the browser, opening the data). */
.auth-status {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  margin: var(--space-4) 0 0;
  color: var(--text-muted);
  text-align: center;
}

/* A guest waiting in the lobby (#1927): one calm state on top, centered; the preview and the
   verification below. */
.lobby-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

/* A gentle pulse, not a stray spinner: the page is alive and waiting. Still with reduced motion. */
.lobby-pulse {
  position: relative;
  width: 12px;
  height: 12px;
  margin: var(--space-2) 0 var(--space-5);
  border-radius: 50%;
  background: var(--accent);
}

.lobby-pulse::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--accent);
  animation: lobby-pulse 2s var(--ease-out) infinite;
}

@keyframes lobby-pulse {
  from {
    opacity: 0.5;
    transform: scale(1);
  }

  to {
    opacity: 0;
    transform: scale(3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .lobby-pulse::after {
    animation: none;
    opacity: 0;
  }
}

.lobby-status {
  max-width: 34ch;
  margin: 0;
  color: var(--text-muted);
  text-wrap: balance;
}

.lobby-wait .guest-waiting-devices {
  align-self: stretch;
  margin-top: var(--space-5);
}

.lobby-wait .guest-device-settings,
.lobby-verify {
  align-self: stretch;
  text-align: start;
}

/* The key codes (#987), collapsed: whoever wants to compare opens them. */
.lobby-verify {
  margin-top: var(--space-4);
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.lobby-verify summary,
.guest-device-settings summary {
  color: var(--text-muted);
  font-weight: var(--weight-medium);
}

.lobby-verify p {
  margin: var(--space-2) 0 0;
}

.guest-codes {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-3) 0 0;
}

.guest-code {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-1) var(--space-3);
}

.guest-code dt {
  color: var(--text-muted);
}

.guest-code dd {
  margin: 0;
  font-size: var(--text-lg);
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  user-select: all;
}

/* A guest's part in the meeting is over (#1933): short, warm, one action at most. */
.guest-end {
  text-align: center;
}

.guest-end-line {
  margin: 0 0 var(--space-4);
  color: var(--text-muted);
}

.guest-end .auth-actions {
  justify-content: center;
}

.guest-end-quiet {
  margin: var(--space-5) 0 0;
}

/* The shared file's name on its download page. */
.share-page-name {
  margin: var(--space-3) 0;
  font-weight: 600;
  overflow-wrap: anywhere;
}

.auth-status-quiet {
  margin: var(--space-4) 0;
}

/* The local store's catalog being built: the core's number, set on the element. */
.store-build {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: var(--space-4) 0;
}

.store-build-track {
  flex: 1;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: var(--border);
}

.store-build-fill {
  --store-build-fraction: 0;
  height: 100%;
  background: var(--accent);
  transform: scaleX(var(--store-build-fraction));
  transform-origin: left;
  transition: transform var(--dur-fast) var(--ease-standard);
}

.store-build-percent {
  flex: none;
  min-width: 4ch;
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
  text-align: right;
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  .store-build-fill {
    transition: none;
  }
}

/* Problems: plain language first, the technical detail folded away. */
.auth-problem,
.auth-card .auth-alert {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.auth-card .auth-alert p {
  margin: 0;
}

.auth-card .auth-form .auth-problem,
.auth-card .auth-form .auth-alert,
.auth-local .auth-problem {
  margin: 0;
}

.auth-problem {
  border: 1px solid color-mix(in srgb, var(--danger) 30%, transparent);
  background: var(--danger-soft);
  color: var(--text);
}

.auth-problem > .icon {
  color: var(--danger);
}

.auth-problem-notice {
  border-color: var(--border);
  background: var(--surface-2);
}

.auth-problem-notice > .icon {
  color: var(--text-muted);
}

.auth-problem-text {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  min-width: 0;
}

.auth-problem-title {
  font-size: var(--text-md);
}

/* Warnings that are not failures (an identity provider on another domain, key setup). */
.auth-card .auth-alert {
  border: 1px solid color-mix(in srgb, var(--mention-text) 25%, transparent);
}

.auth-card .auth-alert > .icon,
.auth-problem > .icon {
  flex: none;
  margin-top: 2px;
}

.auth-details {
  margin-top: var(--space-1);
}

.auth-details summary {
  width: fit-content;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .auth-details summary:hover {
    color: var(--text);
  }
}

.auth-details p {
  margin-top: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  overflow-wrap: anywhere;
  user-select: text;
}

.auth-error {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
  margin: 0;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--danger-soft);
  color: var(--danger);
  font-size: var(--text-sm);
}

.auth-error .icon {
  flex: none;
  margin-top: 1px;
}

.auth-error .mono {
  display: block;
  margin-top: 2px;
  overflow-wrap: anywhere;
}

/* "Did you mean …?" under an address that does not exist. */
.auth-suggest {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0;
  font-size: var(--text-sm);
  color: var(--text-muted);
}

.auth-suggest .link-btn {
  margin: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--accent-strong);
  font-size: inherit;
  font-weight: var(--weight-semibold);
  text-decoration: underline;
  text-underline-offset: 2px;
}

.auth-suggest .spinner {
  width: 14px;
  height: 14px;
}

/* The server confirmation: the server's own brand, its host, and where the password goes. */
.auth-identity {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  margin-bottom: var(--space-6);
  text-align: center;
}

.auth-identity-logo {
  max-width: 220px;
  max-height: 56px;
  margin-bottom: var(--space-3);
  object-fit: contain;
}

.auth-identity-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
}

.auth-identity-name {
  font-size: var(--text-2xl);
  line-height: var(--leading-2xl);
  font-weight: var(--weight-semibold);
  letter-spacing: -0.015em;
  overflow-wrap: anywhere;
}

.auth-identity-host {
  color: var(--text-muted);
  font-size: var(--text-sm);
  overflow-wrap: anywhere;
}

.auth-identity + h1 {
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-xl);
  line-height: var(--leading-xl);
}

.auth-provider {
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  margin: 0 0 var(--space-4);
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.auth-provider > .icon {
  flex: none;
  margin-top: 3px;
  color: var(--accent-strong);
}

.auth-provider strong {
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
}

/* The sign-in card: methods in the server's order, "or" between them, help below. */
.auth-methods {
  display: flex;
  flex-direction: column;
  gap: var(--space-5);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--border);
}

.auth-password {
  position: relative;
}

.auth-card .auth-password .input {
  padding-right: 48px;
}

.auth-reveal {
  position: absolute;
  top: 50%;
  right: 4px;
  display: grid;
  place-items: center;
  width: 38px;
  height: 36px;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-muted);
  transform: translateY(-50%);
}

@media (hover: hover) and (pointer: fine) {
  .auth-reveal:hover {
    background: var(--surface-2);
    color: var(--text);
  }
}

.auth-reveal[aria-pressed="true"] {
  color: var(--accent-strong);
}

.auth-code {
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.15em;
}

.auth-help {
  margin-top: var(--space-5);
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: var(--text-sm);
}

.auth-help-text {
  margin: 0 0 var(--space-1);
  white-space: pre-line;
  overflow-wrap: anywhere;
}

.auth-help-text:last-child {
  margin: 0;
}

.auth-help a {
  color: var(--accent-strong);
  font-weight: var(--weight-semibold);
}

.auth-server {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 2px var(--space-3);
  margin-top: var(--space-5);
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
  overflow-wrap: anywhere;
}

.auth-server .link-btn {
  margin: 0;
  padding: 0;
  color: var(--accent-strong);
  font-size: inherit;
  font-weight: var(--weight-semibold);
}

.auth-content > .link-btn {
  display: block;
  margin: var(--space-4) auto 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.auth-organization {
  margin: var(--space-1) 0 0;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  text-align: center;
}

.auth-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1) var(--space-4);
  margin-top: var(--space-2);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.auth-links:empty {
  display: none;
}

.auth-links a {
  color: var(--text-muted);
}

@media (hover: hover) and (pointer: fine) {
  .auth-links a:hover {
    color: var(--text);
  }
}

@media (max-width: 520px) {
  .auth-page {
    place-items: start center;
    padding: var(--space-4);
    background: var(--surface);
  }

  .auth-card {
    padding: var(--space-6) var(--space-1) var(--space-4);
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .auth-content {
    animation: none;
  }

  .auth-card .input {
    transition: none;
  }
}

.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* A slow turn is not vestibular motion, and a still ring would look like a hang (#360). */
@media (prefers-reduced-motion: reduce) {
  .spinner {
    animation-duration: 1.6s;
  }
}

.link-btn {
  margin-top: 4px;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--accent-strong);
  text-decoration: underline;
}

.welcome-steps {
  display: flex;
  flex-direction: column;
  gap: 14px;
  margin: 20px 0 0;
  padding-left: 20px;
  list-style: decimal;
}

.welcome-steps li span {
  display: block;
}


/* The device options while waiting sit on the sign-in card, in its theme, not on the call's dark
   surfaces. */
.lobby-wait .prejoin-bar,
.lobby-wait .audio-card {
  border-color: var(--border);
  background: var(--surface-2);
}

.lobby-wait .audio-card.selected {
  border-color: var(--accent);
}

.lobby-wait .prejoin-bar-btn {
  color: var(--text);
}

.lobby-wait .prejoin-bar-btn[aria-expanded="true"] {
  background: var(--surface-3);
}

@media (hover: hover) and (pointer: fine) {
  .lobby-wait .prejoin-bar-btn:hover:not(:disabled) {
    background: var(--surface-3);
  }
}

/* "Rejoin" is a link to the meeting's page, shaped as the screen's one button. */
.guest-end a.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}
/* ---- Search ---- */

.search-page {
  flex: 1;
  min-width: 0;
  display: flex;
}

.search-side {
  flex: none;
  width: 260px;
  padding: 16px 12px;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
  overflow-y: auto;
}

.search-side h2 {
  margin: 4px 8px 8px;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
}

.search-side h2:not(:first-child) {
  margin-top: 20px;
}

.saved-list li {
  display: flex;
  align-items: center;
}

.saved-run {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
  padding: 6px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  text-align: left;
}

.saved-run[aria-pressed="true"] {
  background: var(--surface-3);
}

@media (hover: hover) and (pointer: fine) {
  .saved-run:hover {
    background: var(--surface-3);
  }
}

.saved-run span {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px 24px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  background: var(--surface);
}

.search-box:focus-within {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: -1px;
}

.search-box input {
  flex: 1;
  min-width: 0;
  height: 32px;
  border: 0;
  background: transparent;
  font-size: var(--text-md);
  /* .search-box draws the ring round the whole box. */
  outline: none;
}

.filter-buttons,
.token-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.chip-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 26px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  font-size: var(--text-sm);
}

@media (hover: hover) and (pointer: fine) {
  .chip-btn:hover {
    background: var(--surface-3);
  }
}

.chip-btn code {
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.token-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px 0 10px;
  min-height: 26px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--text-sm);
}

.token-chip.invalid {
  background: var(--mention-bg);
  color: var(--mention-text);
}

.search-syntax {
  margin-top: 10px;
}

.search-status {
  min-height: 24px;
  margin: 14px 0 6px;
  font-weight: var(--weight-semibold);
}

.warn-text {
  margin-left: 12px;
  color: var(--mention-text);
  font-weight: var(--weight-regular);
  font-size: var(--text-sm);
}

.hit {
  padding: 12px 4px;
  border-bottom: 1px solid var(--border);
}

.hit-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
  font-size: var(--text-sm);
}

.hit-snippet {
  margin: 6px 0 8px;
  overflow-wrap: anywhere;
}

.hit-snippet mark {
  padding: 0 2px;
  border-radius: 3px;
  background: var(--mention-bg);
  color: var(--mention-text);
}

.hit-actions {
  display: flex;
  gap: 8px;
}

@media (max-width: 900px) {
  .search-side {
    display: none;
  }
}

.sb-more {
  margin: 2px 8px 0 36px;
  padding: 2px 0;
  border: 0;
  background: none;
  color: var(--sb-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  text-decoration: underline;
  text-align: left;
}

@media (hover: hover) and (pointer: fine) {
  .sb-more:hover {
    color: var(--sb-strong);
  }
}

/* ---- Settings tabs ---- */

.settings-group {
  margin: 0 0 18px;
  padding: 12px 16px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.settings-group legend {
  padding: 0 6px;
  font-weight: var(--weight-bold);
}

.settings-check {
  align-items: flex-start;
}

.settings-check small {
  display: block;
}

.ok-text {
  color: var(--accent-strong);
}

.keyword-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

/* "Pause notifications": a title row, then its choices indented under it. */
.menu-group-title {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 34px;
  padding: 4px 14px;
  color: var(--text);
}

.menu-sub .menu-item {
  padding-left: 36px;
  min-height: 30px;
}

.menu-sub .menu-user-sub {
  padding: 2px 36px;
}

.menu-custom-until {
  padding: 4px 14px 4px 36px;
  gap: 6px;
}

/* Message layouts (issue #576). The base rules above are Compact; Comfortable is roomier with one
   step larger text (avatars stay); Bubbles is a chat-app layout. */
.bubble-time {
  display: none;
}

:root[data-density="comfortable"] .msg-user {
  gap: 12px;
  padding-top: 10px;
  padding-bottom: 10px;
}

:root[data-density="comfortable"] .msg-grouped {
  padding-top: 2px;
  padding-bottom: 2px;
}

:root[data-density="comfortable"] .msg-body {
  font-size: var(--text-lg);
  line-height: 1.6;
  letter-spacing: var(--tracking-lg);
}

:root[data-density="comfortable"] .md-p + .md-p {
  margin-top: 8px;
}

:root[data-density="bubbles"] .msg-user {
  padding: 1px 16px;
  gap: 8px;
}

:root[data-density="bubbles"] .msg-user:not(.msg-grouped) {
  padding-top: 8px;
}

/* The bubble carries the state; the row itself stays flat. */
:root[data-density="bubbles"] .msg-user:focus-within,
:root[data-density="bubbles"] .msg-user:focus,
:root[data-density="bubbles"] .msg-user.msg-active,
:root[data-density="bubbles"] .msg-user.is-pressing {
  background: transparent;
}

@media (hover: hover) and (pointer: fine) {
  :root[data-density="bubbles"] .msg-user:hover {
    background: transparent;
  }
}

:root[data-density="bubbles"] .msg-user.msg-active .msg-bubble,
:root[data-density="bubbles"] .msg-user.is-pressing .msg-bubble {
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 35%, transparent);
}

:root[data-density="bubbles"] .msg-user:focus-visible .msg-bubble {
  box-shadow: 0 0 0 2px var(--accent);
}

:root[data-density="bubbles"] .msg-user:focus-visible {
  outline: none;
}

:root[data-density="bubbles"] .msg-user.msg-mine {
  justify-content: flex-end;
}

/* Own messages show neither avatar nor name; a conversation of two shows no avatars at all. */
:root[data-density="bubbles"] .msg-mine .msg-gutter,
:root[data-density="bubbles"] .is-dm .msg-gutter,
:root[data-density="bubbles"] .msg-mine .msg-header {
  display: none;
}

/* In a conversation of two, left and right already say who wrote it: no name either (#735).
   Group DMs and channels keep name and avatar per sender group. */
:root[data-density="bubbles"] .is-dm .msg-header {
  display: none;
}

:root[data-density="bubbles"] .hover-time {
  display: none;
}

:root[data-density="bubbles"] .msg-main {
  flex: 0 1 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: min(70%, 40rem);
}

:root[data-density="bubbles"] .msg-mine .msg-main {
  align-items: flex-end;
}

:root[data-density="bubbles"] .msg-bubble {
  max-width: 100%;
  padding: 6px 12px;
  border-radius: 18px;
  background: var(--surface-2);
}

:root[data-density="bubbles"] .msg-mine .msg-bubble {
  background: var(--accent-soft);
}

:root[data-density="bubbles"] .msg-grouped .msg-bubble {
  border-start-start-radius: 6px;
}

:root[data-density="bubbles"] .msg-mine.msg-grouped .msg-bubble {
  border-start-start-radius: 18px;
  border-start-end-radius: 6px;
}

:root[data-density="bubbles"] .row:has(+ .row > .msg-grouped) > .msg-user:not(.msg-mine) .msg-bubble {
  border-end-start-radius: 6px;
}

:root[data-density="bubbles"] .row:has(+ .row > .msg-grouped) > .msg-mine .msg-bubble {
  border-end-end-radius: 6px;
}

:root[data-density="bubbles"] .msg-header {
  margin-bottom: 2px;
  font-size: var(--text-sm);
}

:root[data-density="bubbles"] .msg-header .msg-time {
  display: none;
}

/* Time, then the delivery state, in the bottom corner of the bubble (#735): the body is the
   bubble's last part, so its trailing float ends the bubble. */
:root[data-density="bubbles"] .bubble-meta {
  float: inline-end;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin: 8px 0 -3px;
  margin-inline-start: 8px;
  color: var(--text-muted);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-2xs);
  font-variant-numeric: tabular-nums;
}

:root[data-density="bubbles"] .bubble-time {
  display: inline;
}

:root[data-density="bubbles"] .msg-delivery:not(.msg-failed) {
  margin: 0;
  font-size: inherit;
  letter-spacing: inherit;
}

/* A refused message says so with its actions: on a line of its own, not squeezed in the corner. */
:root[data-density="bubbles"] .bubble-meta:has(> .msg-failed) {
  float: none;
  display: flex;
  flex-wrap: wrap;
  margin-inline-start: 0;
}

/* Media first, the text below as their caption, the time at the very bottom (#735). Link
   previews and the acknowledge button come between the media and the caption. */
:root[data-density="bubbles"] .msg-bubble {
  display: flex;
  flex-direction: column;
}

:root[data-density="bubbles"] .msg-bubble > .msg-files {
  order: 1;
}

:root[data-density="bubbles"] .msg-bubble > :is(.link-card, .linked-message, .msg-ack) {
  order: 2;
}

:root[data-density="bubbles"] .msg-bubble > .msg-ack {
  align-self: flex-start;
}

:root[data-density="bubbles"] .msg-bubble > .msg-body {
  order: 3;
}

/* With media, the bubble is as wide as they are and frames them evenly; the caption wraps to that
   width instead of widening the bubble. Inner corners are the bubble's radius minus the frame. */
:root[data-density="bubbles"] .msg-bubble:has(> .msg-files) {
  --bubble-frame: 4px;
  padding: var(--bubble-frame);
}

:root[data-density="bubbles"] .msg-bubble:has(> .msg-files) > .msg-files {
  align-items: stretch;
  margin-top: 0;
}

:root[data-density="bubbles"] .msg-bubble:has(> .msg-files) > :not(.msg-files) {
  margin-inline: 8px;
}

:root[data-density="bubbles"] .msg-bubble:has(> .msg-files) > .msg-header {
  margin-top: 2px;
}

:root[data-density="bubbles"] .msg-bubble:has(> .msg-files) > .msg-body {
  padding-block: 2px;
}

/* Pictures and videos set the width; file cards let a longer caption widen the bubble. */
:root[data-density="bubbles"] .msg-bubble:has(> .msg-files .media-tile) > .msg-body {
  inline-size: 0;
  min-inline-size: calc(100% - 16px);
}

:root[data-density="bubbles"] .msg-bubble > .msg-files :is(.media-tile, .media-grid, .file-card) {
  border-radius: calc(18px - var(--bubble-frame, 0px));
}

:root[data-density="bubbles"] .msg-bubble > .msg-files .media-grid .media-tile {
  border-radius: var(--radius-sm);
}

:root[data-density="bubbles"] .msg-body::after {
  content: "";
  display: table;
  clear: both;
}

:root[data-density="bubbles"] .msg-files,
:root[data-density="bubbles"] .msg-bubble .link-card {
  max-width: 100%;
}

:root[data-density="bubbles"] .reactions {
  margin-top: 2px;
}

:root[data-density="bubbles"] .reply-count {
  margin-left: 0;
  margin-inline-start: 4px;
}

@media (max-width: 600px) {
  :root[data-density="bubbles"] .msg-main {
    max-width: 85%;
  }
}

.auth-form {
  margin-top: 16px;
}

.auth-form .field {
  margin-bottom: 14px;
}

.auth-form .field-error {
  margin-top: 4px;
}

.auth-form .field-error .mono {
  display: block;
}

.seen-line {
  padding: 0 20px 4px;
  overflow-wrap: anywhere;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
  text-align: right;
}

/* "Alice is typing…" (#733). A zero-height anchor after the messages holds it, so it takes no room
   and nothing moves when someone starts or stops typing: the line sits in the space the list keeps
   under its newest message. Over messages scrolled beneath it, the surface fades in under the text
   (a scroll edge, not a divider). It only fades: it comes and goes every few seconds, and any
   movement there would pull the eye from the conversation. */
.typing-anchor {
  position: relative;
  flex: none;
  height: 0;
  z-index: 4;
}

.typing-line {
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 20px 0;
  background: linear-gradient(to top, var(--surface) 75%, transparent);
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  line-height: 1rem;
  pointer-events: none;
  opacity: 0;
  transition: opacity var(--dur-exit) var(--ease-exit);
}

.typing-line.is-visible {
  opacity: 1;
  transition: opacity var(--dur-base) var(--ease-out);
}

/* A thread keeps the same room under its newest reply as the conversation's list, for the line. */
.thread-panel .panel-scroll {
  padding-bottom: var(--space-3);
}

.typing-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.typing-dots {
  flex: none;
  display: inline-flex;
  gap: 3px;
}

.typing-dots span {
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.35;
}

/* The dots pulse one after the other, only while someone types: while the line shows, and in the
   chat list and a direct conversation's header, which only hold them then (#882). */
.typing-line.is-visible .typing-dots span,
.sb-typing .typing-dots span,
.header-typing .typing-dots span {
  animation: typing-dot 1.2s var(--ease-standard) infinite;
}

.typing-line.is-visible .typing-dots span:nth-child(2),
.sb-typing .typing-dots span:nth-child(2),
.header-typing .typing-dots span:nth-child(2) {
  animation-delay: 0.15s;
}

.typing-line.is-visible .typing-dots span:nth-child(3),
.sb-typing .typing-dots span:nth-child(3),
.header-typing .typing-dots span:nth-child(3) {
  animation-delay: 0.3s;
}

@keyframes typing-dot {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: none;
  }

  30% {
    opacity: 1;
    transform: translateY(-1px);
  }
}

/* "typing…" beside a chat list row's name, in place of nothing (the row has no preview line): the
   name keeps the room it needs first, the line takes what is left. */
.sb-typing {
  display: inline-flex;
  flex: 0 1 auto;
  align-items: center;
  gap: 5px;
  min-width: 0;
  max-width: 60%;
  font-size: var(--text-xs);
  font-weight: var(--weight-regular);
  letter-spacing: var(--tracking-xs);
}

.sb-typing-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* "typing…" under a direct conversation's name, for the few seconds it lasts. */
.header-typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

@media (prefers-reduced-motion: reduce) {
  .typing-line.is-visible .typing-dots span,
  .sb-typing .typing-dots span,
  .header-typing .typing-dots span {
    animation: none;
    opacity: 0.7;
  }
}

/* ---- Meetings ---- */

.meetings-view {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.meetings-view .panel-header .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}


.meetings-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 16px 24px;
}









.meeting-link {
  margin-top: 10px;
  display: grid;
  gap: 4px;
}

.meeting-link-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.meeting-link-row .input {
  min-width: 0;
}

.meeting-guest-links {
  margin-top: 10px;
  display: grid;
  gap: 4px;
}

.meeting-created {
  display: grid;
  gap: 8px;
}

.meeting-created-guests {
  margin: 8px 0 0;
  font-size: var(--text-sm);
}

.meetings-visit {
  margin: 8px 16px 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.meetings-visit p {
  margin: 2px 0 0;
}

.lobby {
  margin-top: 10px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--accent-soft);
}

.lobby ul {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}

.lobby-entry {
  display: flex;
  align-items: center;
  gap: 8px;
}

.lobby-entry span {
  flex: 1;
}

/* What a guest sees after being let in: a bar with the meeting's name and the chat below it. */
.app.guest-meeting {
  grid-template-rows: var(--topbar-h) minmax(0, 1fr);
}

.guest-meeting-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 12px;
  background: var(--chrome);
  color: var(--chrome-text);
}

.guest-meeting-bar[hidden] {
  display: none;
}

.guest-meeting-title {
  margin: 0;
  font-size: var(--text-lg);
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A guest's page has no app bar above the call: the pre-join and call screens cover the whole
   window, not the chat's header in the bar's row (#1929). */
.app.guest-meeting .prejoin,
.app.guest-meeting .call-screen {
  inset: var(--banners-h, 0px) 0 0 0;
}

.guest-meeting > .main {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.schedule-form {
  display: grid;
  gap: 12px;
}

.invite-list {
  list-style: none;
  margin: 0 0 6px;
  padding: 0;
  max-height: 140px;
  overflow-y: auto;
  display: grid;
  gap: 4px;
}

/* The notetaker heads the people to invite, set apart from them, with where its audio goes. */
.invite-notetaker {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.invite-notetaker .muted-text {
  margin: 0 0 0 26px;
}

.invite-external {
  display: flex;
  align-items: center;
  gap: 6px;
}

.invite-external span {
  flex: 1;
}

.modal-wide {
  width: min(680px, 100%);
}

.modal-wide > form {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

.modal-wide .modal-body {
  overflow-y: auto;
}

.schedule-form .input {
  min-width: 0;
  width: 100%;
  box-sizing: border-box;
}

.schedule-form .field-row > * {
  min-width: 0;
}

.link-code {
  word-break: break-all;
  max-width: 100%;
}

.composer-confirm {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--mention-bg);
  color: var(--mention-text);
  font-size: var(--text-sm);
}

.composer-confirm span {
  flex: 1;
}

.sb-external {
  display: inline-flex;
  margin-left: 4px;
  color: var(--away);
}

.date-jump {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.date-jump-input {
  width: 150px;
}

.bundle-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: var(--danger);
  color: var(--on-fill);
  font-size: var(--text-sm);
}


/* Repeat: "Every [2] weeks", the days as chips, how the series ends (issue #1006). */
.repeat-fields {
  display: grid;
  gap: 8px;
  border: 0;
  margin: 0;
  padding: 0;
}

.repeat-fields legend {
  padding: 0;
  margin-bottom: 4px;
}

.repeat-row,
.repeat-end {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.schedule-form .repeat-row .input.narrow,
.schedule-form .repeat-end .input.narrow {
  width: 5.5em;
}

.schedule-form .repeat-end .input[type="date"] {
  width: auto;
}

.repeat-ends {
  display: grid;
  gap: 6px;
  margin: 0;
}

.repeat-end .radio {
  min-width: 4.5em;
}

/* Scrolled to the middle of the dialog when a submit is refused; the focused field shows itself. */
.schedule-form [aria-invalid="true"] {
  border-color: var(--danger);
}

.schedule-form .set-chips[aria-invalid="true"],
.schedule-form fieldset[aria-invalid="true"] {
  border-radius: var(--radius-sm);
  outline: 1px solid var(--danger);
  outline-offset: 4px;
}
/* Message actions */
.msg-menu { right: 0; top: 100%; min-width: 14rem; }
.menu-danger { color: var(--danger); }
.msg-quote { margin: 0 0 .25rem; padding: .1rem .6rem; border-inline-start: 3px solid var(--border-strong); color: var(--text-muted); display: flex; flex-direction: column; font-size: var(--text-sm); }
.quote-author { font-weight: var(--weight-semibold); }
/* A reply to one picture: its thumbnail beside the lines; a button while the picture is there. */
.msg-quote-image { flex-direction: row; align-items: center; gap: .5rem; width: fit-content; max-width: 100%; padding-block: .25rem; text-align: start; }
button.msg-quote-image { border-block: 0; border-inline-end: 0; background: none; font: inherit; font-size: var(--text-sm); cursor: pointer; transition: color var(--dur-fast, .12s) ease; }
button.msg-quote-image:hover { color: var(--text); }
button.msg-quote-image:active, button.msg-quote-jump:active { opacity: .7; }
button.msg-quote-jump { border-block: 0; border-inline-end: 0; background: none; font: inherit; font-size: var(--text-sm); text-align: start; cursor: pointer; transition: color var(--dur-fast, .12s) ease; }
button.msg-quote-jump:hover { color: var(--text); }
.quote-lines { display: flex; flex-direction: column; min-width: 0; }
.quote-lines .quote-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.quote-thumb { display: grid; place-items: center; flex: none; width: 2.5rem; height: 2.5rem; border-radius: 6px; object-fit: cover; background: var(--surface-2, var(--border-strong)); }
.reply-banner .quote-thumb { width: 1.75rem; height: 1.75rem; border-radius: 4px; }
.msg-forwarded { display: flex; align-items: center; gap: .35rem; color: var(--text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); }
.msg-deleted { color: var(--text-muted); }
.edit-history { margin: .25rem 0; padding-inline-start: 1.2rem; color: var(--text-muted); font-size: var(--text-sm); }
.edit-history time { margin-inline-end: .5rem; }
.msg-edit { display: flex; flex-direction: column; gap: .35rem; }
.msg-edit-actions { display: flex; gap: .35rem; justify-content: flex-end; }
.badge-pin, .badge-saved, .badge-important { margin-inline-start: .35rem; }
.badge-urgent { margin-inline-start: .35rem; background: var(--danger); color: var(--on-danger); }
.forward-list { list-style: none; margin: .5rem 0; padding: 0; max-height: 16rem; overflow: auto; }
.forward-item { width: 100%; text-align: start; padding: .4rem .6rem; background: none; border: 0; border-radius: var(--radius-xs); cursor: pointer; color: inherit; }
.forward-item.current { background: var(--surface-2); }
@media (hover: hover) and (pointer: fine) { .forward-item:hover { background: var(--surface-2); } }
.saved-list { list-style: none; margin: 0; padding: .5rem 1rem; }
.saved-item { padding: .6rem 0; border-bottom: 1px solid var(--border); }
.saved-meta { display: flex; align-items: center; gap: .5rem; color: var(--text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); }
.saved-actions { display: flex; gap: .35rem; margin-top: .35rem; }
.reply-banner { display: flex; align-items: center; gap: .5rem; padding: .3rem .6rem; border-inline-start: 3px solid var(--border-strong); color: var(--text-muted); font-size: var(--text-sm); }
.reply-banner .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }


/* Selection mode (issue #2070): a bar above the feed, rows that take a tap, a mark at the end. */
.selection-bar { display: flex; align-items: center; flex-wrap: wrap; gap: .5rem; padding: .5rem 1rem; border-bottom: 1px solid var(--border); background: var(--surface-2); }
.selection-bar .btn { display: inline-flex; align-items: center; gap: .35rem; }
.selection-bar .btn .icon { width: 1rem; height: 1rem; }
.selection-count { font-weight: 600; font-variant-numeric: tabular-nums; }
.selection-hint { color: var(--text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); }
.msg-select-hit { position: absolute; inset: 0; z-index: 2; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; -webkit-tap-highlight-color: transparent; }
.msg-selecting .msg-main { user-select: none; }
.msg-select-mark { position: absolute; inset-inline-end: 1rem; top: 50%; z-index: 3; display: grid; place-items: center; width: 1.375rem; height: 1.375rem; margin-top: -.6875rem; border: 2px solid var(--border-strong); border-radius: 50%; color: var(--on-accent); pointer-events: none; transition: background-color var(--dur-fast, .12s) ease, border-color var(--dur-fast, .12s) ease; }
.msg-select-mark .icon { width: .875rem; height: .875rem; }
.msg-selected { background: var(--accent-soft); }
.msg-selected .msg-select-mark { border-color: var(--accent); background: var(--accent); }
.msg-selecting:active .msg-select-mark { transform: scale(.92); }
@media (prefers-reduced-motion: reduce) { .msg-select-mark { transition: none; } }
@media (hover: hover) and (pointer: fine) { .msg-selecting:hover { background: var(--surface-2); } .msg-selected:hover { background: var(--accent-soft); } }
/* Files: pictures inline (one large, several in a grid), other files as compact cards (issue #316) */
.msg-files { display: flex; flex-direction: column; align-items: flex-start; gap: 6px; margin-top: 6px; }
/* The toolbar's menu must not be clipped: the tile's button clips the picture, not the tile. No frame
   or background: a sticker with transparency stands free in the conversation. */
.media-tile { position: relative; border-radius: var(--radius-md); }
.media-grid .media-tile, .media-placeholder { background: var(--surface-3); }
.media-single { width: var(--media-w, 240px); height: var(--media-h, 180px); max-width: 100%; }
.media-single:not(.has-size) { width: auto; height: auto; min-width: 160px; min-height: 120px; max-height: 480px; }
.media-open { position: relative; display: block; width: 100%; height: 100%; padding: 0; border: 0; border-radius: inherit; overflow: hidden; background: none; cursor: zoom-in; }
.media-open img { display: block; width: 100%; height: 100%; object-fit: contain; transition: filter var(--dur-base) var(--ease-out); }
.media-single:not(.has-size) .media-open img { width: auto; height: auto; max-width: min(360px, 100%); max-height: 480px; }
/* The thumbnail scaled up until the full picture is there: softened so it doesn't look pixelated */
.media-open img.is-preview { filter: blur(1.5px); }
.media-open:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: -2px; }
.media-placeholder { display: grid; width: 100%; height: 100%; min-height: 120px; place-items: center; color: var(--text-muted); }
/* A picture that didn't arrive (offline, server trouble): try again from the tile */
.media-retry { position: absolute; left: 50%; bottom: 10px; z-index: 1; transform: translateX(-50%); display: inline-flex; align-items: center; gap: 6px; }
.media-play-badge { position: absolute; left: 50%; top: 50%; display: grid; place-items: center; width: 40px; height: 40px; margin: -20px 0 0 -20px; border-radius: 50%; background: rgba(0, 0, 0, .6); color: var(--on-fill); pointer-events: none; }
.media-play-badge svg { width: 18px; height: 18px; }
.media-duration { position: absolute; left: 8px; bottom: 8px; padding: 1px 6px; border-radius: 4px; background: rgba(0, 0, 0, .6); color: var(--on-fill); font-size: var(--text-xs); font-variant-numeric: tabular-nums; pointer-events: none; }
/* The player of a video playing in its row (#483) covers the tile; the tile's own button stays below it. */
.media-video { position: absolute; inset: 0; display: grid; place-items: center; border-radius: inherit; overflow: hidden; background: var(--media-backdrop); }
.media-video .video-player { width: 100%; height: 100%; }
/* While the player's chunk loads (areas.rs), or when it can't: centred in the tile. */
.media-video > .lazy-area { width: 100%; height: 100%; }
.media-video > .lazy-area-failed { overflow: auto; }

/* The app's own video player (#638), inline and in the lightbox, the same on every platform: the
   video letterboxed in the player's box, a translucent bar floating over its bottom edge. With a
   precise pointer the bar steps aside while the video plays and the pointer is elsewhere. */
.video-player { position: relative; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); container-type: inline-size; color: var(--on-fill); -webkit-user-select: none; user-select: none; }
.video-player > * { grid-area: 1 / 1; }
.video-player:focus-visible { outline: var(--focus-width) solid var(--on-fill); outline-offset: calc(-1 * var(--focus-width)); }
.video-player-video { width: 100%; height: 100%; min-height: 0; object-fit: contain; }
.video-player.is-fullscreen { background: rgba(0, 0, 0, 1); }
.video-big-play { place-self: center; display: grid; place-items: center; width: 56px; height: 56px; padding: 0; border: 0; border-radius: 50%; background: rgba(20, 22, 30, .55); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); color: var(--on-fill); box-shadow: 0 2px 12px rgba(0, 0, 0, .35); cursor: pointer; transition: opacity var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-out); }
.video-big-play .icon { width: 24px; height: 24px; margin-left: 3px; fill: currentColor; }
.video-big-play:active { transform: scale(.94); }
.video-big-play.is-hidden { opacity: 0; pointer-events: none; }
.video-controls { place-self: end stretch; display: flex; align-items: center; gap: 6px; margin: 0 10px 10px; padding: 4px 8px; border-radius: 12px; background: rgba(20, 22, 30, .6); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); box-shadow: 0 2px 12px rgba(0, 0, 0, .3); transition: opacity var(--dur-base) var(--ease-standard); }
@media (hover: hover) and (pointer: fine) {
  .video-player.is-playing:not(:hover, :has(:focus-visible)) .video-controls { opacity: 0; }
  .video-player.is-playing:not(:hover, :has(:focus-visible)) { cursor: none; }
  .video-player.is-playing.is-idle:not(:has(:focus-visible, .video-controls:hover)) .video-controls { opacity: 0; }
  .video-player.is-playing.is-idle:not(:has(:focus-visible, .video-controls:hover)) { cursor: none; }
}
.video-btn { flex: none; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 8px; background: transparent; color: inherit; cursor: pointer; transition: background-color var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-out); }
@media (hover: hover) and (pointer: fine) { .video-btn:hover { background: rgba(255, 255, 255, .14); } }
.video-btn:active { transform: scale(.92); }
@media (pointer: coarse) { .video-btn { width: 44px; height: 44px; } }
.video-speed { width: auto; min-width: 36px; padding: 0 4px; font-size: var(--text-xs); font-variant-numeric: tabular-nums; }
.video-repeat[aria-pressed="true"] { background: rgba(255, 255, 255, .22); }
.video-btn:focus-visible, .video-scrubber:focus-visible, .video-volume:focus-visible { outline: var(--focus-width) solid var(--on-fill); outline-offset: 1px; }
.video-time { flex: none; min-width: 2.75em; font-size: var(--text-xs); font-variant-numeric: tabular-nums; text-align: center; color: rgba(255, 255, 255, .85); }
/* Scrubber and volume: a thin track, white up to the position, lighter over what is buffered; the
   knob shows where the pointer or the focus is. */
.video-scrubber, .video-volume { --media-buffered: 0%; height: 24px; margin: 0; padding: 0; border: 0; border-radius: 4px; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
.video-scrub { position: relative; flex: 1; display: flex; min-width: 48px; }
.video-scrubber { flex: 1; min-width: 0; }
/* The time under the pointer, above the scrubber. */
.video-pointer-time { position: absolute; bottom: 100%; margin-bottom: 6px; padding: 2px 6px; border-radius: 6px; background: rgba(20, 22, 30, .85); font-size: var(--text-xs); font-variant-numeric: tabular-nums; white-space: nowrap; transform: translateX(-50%); pointer-events: none; }
.video-volume { flex: none; width: 72px; }
.video-scrubber::-webkit-slider-runnable-track, .video-volume::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--on-fill) var(--media-played), rgba(255, 255, 255, .5) var(--media-played) var(--media-buffered), rgba(255, 255, 255, .22) var(--media-buffered)); }
.video-scrubber::-moz-range-track, .video-volume::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--on-fill) var(--media-played), rgba(255, 255, 255, .5) var(--media-played) var(--media-buffered), rgba(255, 255, 255, .22) var(--media-buffered)); }
.video-scrubber::-webkit-slider-thumb, .video-volume::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -4px; border: 0; border-radius: 50%; background: var(--on-fill); box-shadow: 0 1px 4px rgba(0, 0, 0, .4); -webkit-appearance: none; appearance: none; transform: scale(.5); transition: transform var(--dur-fast) var(--ease-out); }
.video-scrubber::-moz-range-thumb, .video-volume::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--on-fill); box-shadow: 0 1px 4px rgba(0, 0, 0, .4); transform: scale(.5); transition: transform var(--dur-fast) var(--ease-out); }
.video-scrubber:is(:hover, :active, :focus-visible)::-webkit-slider-thumb, .video-volume:is(:hover, :active, :focus-visible)::-webkit-slider-thumb { transform: scale(1); }
.video-scrubber:is(:hover, :active, :focus-visible)::-moz-range-thumb, .video-volume:is(:hover, :active, :focus-visible)::-moz-range-thumb { transform: scale(1); }
/* Touch sets the volume with the device's buttons; a small player keeps the essentials. */
@media not ((hover: hover) and (pointer: fine)) { .video-volume { display: none; } }
@container (max-width: 480px) { .video-speed, .video-repeat { display: none; } }
@container (max-width: 360px) { .video-volume, .video-duration { display: none; } }
@container (max-width: 240px) { .video-time { display: none; } }
@media (prefers-reduced-transparency: reduce) { .video-controls, .video-big-play { background: rgba(20, 22, 30, .92); -webkit-backdrop-filter: none; backdrop-filter: none; } }
/* An animated picture: its moving copy over the still frame, and the button that stops or starts it
   (top left, the toolbar has the right). Over the picture on hover or focus; always on a touch screen,
   and on a still picture that only starts from here. */
.media-open img.media-moving { position: absolute; inset: 0; transition: none; }
.media-open img.is-under-moving { visibility: hidden; }
.media-motion { position: absolute; top: 6px; left: 6px; z-index: 1; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: rgba(20, 22, 30, .55); -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%); color: var(--on-fill); cursor: pointer; opacity: 0; transition: opacity var(--dur-fast, .12s) var(--ease-out), transform var(--dur-fast, .12s) var(--ease-out); }
.media-motion .icon { width: 16px; height: 16px; fill: currentColor; }
.media-motion .spinner { width: 16px; height: 16px; }
.media-motion:active { transform: scale(.94); }
.media-motion:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }
.media-motion.is-needed, .media-tile:focus-within .media-motion { opacity: 1; }
@media (hover: hover) and (pointer: fine) { .media-tile:hover .media-motion { opacity: 1; } }
@media not ((hover: hover) and (pointer: fine)) { .media-motion { width: 44px; height: 44px; opacity: 1; } .media-motion .icon { width: 20px; height: 20px; } }
@media (prefers-reduced-motion: reduce) { .media-motion { transition: opacity var(--dur-fast, .12s); } .media-motion:active { transform: none; } }
@media (prefers-reduced-transparency: reduce) { .media-motion { background: rgba(20, 22, 30, .92); -webkit-backdrop-filter: none; backdrop-filter: none; } }
.media-gif-badge { position: absolute; left: 8px; bottom: 8px; padding: 1px 6px; border-radius: 4px; background: rgba(0, 0, 0, .6); color: var(--on-fill); font-size: var(--text-xs); font-weight: var(--weight-bold); letter-spacing: .04em; pointer-events: none; }
.media-more { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(0, 0, 0, .5); color: var(--on-fill); font-size: var(--text-2xl); letter-spacing: var(--tracking-2xl); line-height: var(--leading-2xl); font-weight: var(--weight-semibold); pointer-events: none; }
/* A picture of the user's own message still going up: its local thumbnail; only one that failed
   for good says so on its tile. How far the message got is its one upload pill. */
.media-tile.is-uploading .media-open { cursor: default; }
.upload-state { position: absolute; left: 50%; top: 50%; z-index: 1; transform: translate(-50%, -50%); display: inline-flex; align-items: center; gap: 8px; padding: 8px; border-radius: 999px; background: rgba(0, 0, 0, .6); color: var(--on-fill); }
.upload-state.is-failed { flex-direction: column; max-width: calc(100% - 16px); padding: 10px 12px; border-radius: var(--radius-md); font-size: var(--text-sm); text-align: center; }
/* How far a transfer got: a ring filled to --media-progress percent */
.transfer-ring { flex: none; width: 22px; height: 22px; border-radius: 50%; background: conic-gradient(var(--on-fill) calc(var(--media-progress, 0) * 1%), rgba(255, 255, 255, .35) 0); mask: radial-gradient(farthest-side, transparent calc(100% - 3px), black calc(100% - 2px)); }
/* A message's pictures with its one upload pill over their top-start corner. */
.msg-media { position: relative; max-width: 100%; }
/* One control per message while its files go up (Signal-style): a ring for all of them with a stop
   square, and "Processing…" or "3.2 MB / 70 MB"; "Try again" once it stopped. Over pictures a
   translucent pill in the corner; under documents a row in the bubble. */
.upload-pill { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; padding: 2px 10px 2px 2px; border-radius: 999px; font-size: var(--text-xs); letter-spacing: var(--tracking-xs); font-variant-numeric: tabular-nums; white-space: nowrap; animation: upload-pill-in var(--dur-base) var(--ease-standard); }
.upload-pill.is-corner { position: absolute; inset-inline-start: 6px; top: 6px; z-index: 2; max-width: calc(100% - 12px); background: rgba(0, 0, 0, .5); -webkit-backdrop-filter: blur(16px) saturate(1.6); backdrop-filter: blur(16px) saturate(1.6); color: var(--on-fill); }
.upload-pill.is-row { align-self: flex-start; background: var(--surface-2); color: var(--text); }
.upload-pill.is-failed { padding-inline-start: 4px; padding-inline-end: 2px; }
.upload-pill-text { overflow: hidden; text-overflow: ellipsis; }
.upload-stop { position: relative; display: grid; place-items: center; flex: none; width: 28px; height: 28px; padding: 0; border: 0; border-radius: 50%; background: transparent; color: inherit; cursor: pointer; }
.upload-stop > * { grid-area: 1 / 1; }
.upload-stop:focus-visible, .upload-retry:focus-visible, .upload-dismiss:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 1px; }
.upload-stop-square { width: 8px; height: 8px; border-radius: 2px; background: currentColor; transition: transform var(--dur-fast) var(--ease-standard); }
.upload-stop:active .upload-stop-square { transform: scale(.8); }
.upload-ring { width: 24px; height: 24px; transform: rotate(-90deg); fill: none; stroke-width: 2.5; stroke-linecap: round; }
.upload-ring-track { stroke: currentColor; opacity: .3; }
.upload-ring-fill { stroke: currentColor; stroke-dasharray: 100; transition: stroke-dashoffset var(--dur-slow) var(--ease-standard); }
/* Before the first byte: a quarter arc that turns. */
.upload-ring.is-turning .upload-ring-fill { stroke-dashoffset: 75; transition: none; }
.upload-ring.is-turning { animation: upload-ring-turn 1s linear infinite; }
.upload-retry, .upload-dismiss { display: inline-flex; align-items: center; gap: 4px; min-height: 28px; padding: 0 8px 0 4px; border: 0; border-radius: 999px; background: transparent; color: inherit; font: inherit; font-weight: var(--weight-semibold); cursor: pointer; }
.upload-retry .icon { width: 16px; height: 16px; }
.upload-dismiss { justify-content: center; width: 28px; padding: 0; opacity: .8; }
.upload-dismiss .icon { width: 14px; height: 14px; }
@media (hover: hover) and (pointer: fine) { :is(.upload-stop, .upload-retry, .upload-dismiss):hover { background: rgba(127, 127, 127, .2); } }
@media not ((hover: hover) and (pointer: fine)) { .upload-pill { min-height: 36px; } .upload-stop, .upload-dismiss { width: 32px; height: 32px; } }
@keyframes upload-ring-turn { from { transform: rotate(-90deg); } to { transform: rotate(270deg); } }
@keyframes upload-pill-in { from { opacity: 0; transform: scale(.92); } }
@media (prefers-reduced-motion: reduce) {
  .upload-pill { animation-name: upload-pill-fade; }
  .upload-ring-fill { transition: none; }
  .upload-ring.is-turning { animation: none; }
  .upload-ring.is-turning .upload-ring-fill { stroke-dashoffset: 0; opacity: .6; }
}
@keyframes upload-pill-fade { from { opacity: 0; } }
@media (prefers-reduced-transparency: reduce) { .upload-pill.is-corner { background: rgba(0, 0, 0, .78); -webkit-backdrop-filter: none; backdrop-filter: none; } }
.media-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px; width: min(360px, 100%); }
.media-grid .media-tile { aspect-ratio: 1; border-radius: var(--radius-sm); }
.media-grid .media-open img { object-fit: cover; }
/* Settings > Display > Image size: Standard */
:root[data-image-size="standard"] .media-grid { width: min(240px, 100%); }
:root[data-image-size="standard"] .media-single:not(.has-size) .media-open img { max-width: min(240px, 100%); max-height: 320px; }
.media-grid[data-tiles="3"] .media-tile:first-child { grid-row: span 2; aspect-ratio: auto; }
/* Actions float over the picture's top right on hover, focus or long-press; never shown permanently */
.media-toolbar { position: absolute; top: 6px; right: 6px; z-index: 1; display: flex; gap: 2px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); box-shadow: var(--shadow-card); opacity: 0; visibility: hidden; transform: translateY(-2px); transition: opacity var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard), visibility 0s linear var(--dur-fast); }
.media-tile:focus-within .media-toolbar, .media-tile.actions-pinned .media-toolbar, .media-toolbar:has([aria-expanded="true"]) { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; }
@media (hover: hover) and (pointer: fine) { .media-tile:hover .media-toolbar { opacity: 1; visibility: visible; transform: none; transition-delay: 0s; } }
.media-tool { width: 28px; height: 28px; }
.media-tool svg { width: 16px; height: 16px; }
.media-tool.is-active { color: var(--accent); }
.file-menu-wrap { position: relative; }
.file-menu { right: 0; left: auto; top: calc(100% + 4px); min-width: 14rem; }
/* Reduced motion: the toolbar still fades, without the 2px drop. */
@media (prefers-reduced-motion: reduce) {
  .media-toolbar { transform: none; transition: opacity var(--dur-fast, .12s), visibility 0s linear var(--dur-fast, .12s); }
  .media-open img { transition: none; }
}
.file-card { display: flex; align-items: center; gap: 10px; width: min(360px, 100%); padding: 8px 8px 8px 10px; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--surface); }
@media (hover: hover) and (pointer: fine) { .file-card:hover { background: var(--surface-2); } }
.file-icon { flex: none; display: grid; place-items: center; width: 36px; height: 36px; border-radius: var(--radius-sm); background: var(--accent-soft); color: var(--accent); }
.file-thumb { position: relative; flex: none; padding: 0; border: 0; background: none; cursor: zoom-in; }
.file-thumb.is-static { cursor: default; }
.file-thumb img { display: block; width: 36px; height: 36px; object-fit: cover; border-radius: var(--radius-sm); }
.file-meta { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.3; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: var(--weight-medium); }
.file-size, .file-state { color: var(--text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); }
.file-progress { width: 100%; height: 4px; margin-top: 4px; }
/* An audio attachment that plays in the conversation (#802): the card, and its player's row once
   the file is loaded. */
.audio-card { flex-wrap: wrap; row-gap: 4px; width: min(400px, 100%); }
.audio-play { flex: none; display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: var(--accent); color: var(--on-accent); cursor: pointer; transition: background-color var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-out); }
.audio-play svg { width: 16px; height: 16px; }
/* The triangle's weight sits left of its box: nudged so it looks centred. */
.audio-play:not(.is-playing) svg { transform: translateX(1px); }
@media (hover: hover) and (pointer: fine) { .audio-play:hover:not(:disabled) { background: var(--accent-strong); } }
.audio-play:active:not(:disabled) { transform: scale(.92); }
.audio-play:disabled { background: var(--surface-3); color: var(--text-muted); cursor: default; }
.audio-play:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }
.audio-play .spinner { width: 20px; height: 20px; border-color: rgba(255, 255, 255, .35); border-top-color: var(--on-accent); }
.audio-play .transfer-ring { width: 20px; height: 20px; background: conic-gradient(var(--on-accent) calc(var(--media-progress, 0) * 1%), rgba(255, 255, 255, .35) 0); }
.audio-controls { flex: 1 0 100%; display: flex; align-items: center; gap: 8px; min-width: 0; padding-left: 46px; }
.audio-scrubber, .audio-volume { height: 24px; margin: 0; padding: 0; border: 0; border-radius: 4px; background: transparent; -webkit-appearance: none; appearance: none; cursor: pointer; }
.audio-scrubber { flex: 1; min-width: 48px; }
.audio-volume { flex: none; width: 64px; }
.audio-scrubber::-webkit-slider-runnable-track, .audio-volume::-webkit-slider-runnable-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--media-played), var(--surface-3) var(--media-played)); }
.audio-scrubber::-moz-range-track, .audio-volume::-moz-range-track { height: 4px; border-radius: 2px; background: linear-gradient(to right, var(--accent) var(--media-played), var(--surface-3) var(--media-played)); }
.audio-scrubber::-webkit-slider-thumb, .audio-volume::-webkit-slider-thumb { width: 12px; height: 12px; margin-top: -4px; border: 0; border-radius: 50%; background: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); -webkit-appearance: none; appearance: none; transform: scale(.6); transition: transform var(--dur-fast) var(--ease-out); }
.audio-scrubber::-moz-range-thumb, .audio-volume::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--accent); box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transform: scale(.6); transition: transform var(--dur-fast) var(--ease-out); }
.audio-scrubber:is(:hover, :active, :focus-visible)::-webkit-slider-thumb, .audio-volume:is(:hover, :active, :focus-visible)::-webkit-slider-thumb { transform: scale(1); }
.audio-scrubber:is(:hover, :active, :focus-visible)::-moz-range-thumb, .audio-volume:is(:hover, :active, :focus-visible)::-moz-range-thumb { transform: scale(1); }
.audio-scrubber:focus-visible, .audio-volume:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 1px; }
.audio-time { flex: none; color: var(--text-muted); font-size: var(--text-xs); font-variant-numeric: tabular-nums; letter-spacing: var(--tracking-xs); }
.audio-mute { flex: none; width: 28px; height: 28px; }
.audio-mute svg { width: 16px; height: 16px; }
/* Touch screens set the volume with the device's buttons. */
@media not ((hover: hover) and (pointer: fine)) { .audio-volume { display: none; } }
@media (prefers-reduced-motion: reduce) {
  .audio-play { transition: none; }
  .audio-scrubber::-webkit-slider-thumb, .audio-volume::-webkit-slider-thumb { transition: none; }
}
/* The preview of a Markdown, HTML or PDF file (#557) */
.modal.file-preview { width: min(960px, 100%); height: min(88vh, 900px); max-height: none; }
.preview-head { gap: 12px; justify-content: flex-start; }
.preview-name { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-size { flex: none; color: var(--text-muted); font-size: var(--text-xs); }
.preview-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.preview-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: auto; }
.preview-status { display: grid; place-items: center; gap: 12px; align-content: center; flex: 1; padding: 32px; text-align: center; }
.preview-markdown { padding: 16px 20px; overflow-wrap: anywhere; }
.preview-source { margin: 0; padding: 16px 20px; white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-mono); font-size: var(--text-sm); }
.preview-note { flex: none; margin: 0; padding: 6px 16px; color: var(--text-muted); font-size: var(--text-xs); border-bottom: 1px solid var(--border); }
.preview-frame-host { flex: 1; min-height: 240px; display: flex; background: white; }
.preview-frame { flex: 1; width: 100%; border: 0; background: white; color-scheme: light; }
.preview-links { flex: none; padding: 8px 16px; border-top: 1px solid var(--border); font-size: var(--text-sm); }
.preview-links ul { max-height: 160px; overflow: auto; margin: 6px 0 0; padding-left: 18px; overflow-wrap: anywhere; }
.pdf-tools { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.pdf-tools[hidden] { display: none; }
.pdf-page-field { display: flex; align-items: center; gap: 4px; color: var(--text-muted); }
.pdf-page-input { width: 5em; }
.pdf-find { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.pdf-find-state { color: var(--text-muted); font-size: var(--text-xs); }
/* The pages, and over them what the app shows while the document opens (#835) */
.pdf-stage { position: relative; flex: 1; min-height: 0; display: flex; flex-direction: column; }
.pdf-pages { flex: 1; min-height: 0; overflow: auto; padding: 12px; background: var(--surface-2); outline-offset: -2px; }
.pdf-opening { position: absolute; inset: 0; }
.pdf-page { position: relative; margin: 0 auto 12px; background: white; box-shadow: var(--shadow); }
.pdf-page.is-broken { outline: 2px solid var(--danger); }
.pdf-page canvas { display: block; }
/* Selectable text over the page's canvas (the text layer PDF.js fills in) */
.pdf-text { position: absolute; inset: 0; overflow: clip; line-height: 1; text-size-adjust: none; forced-color-adjust: none; transform-origin: 0 0; }
.pdf-text :is(span, br) { position: absolute; color: transparent; white-space: pre; cursor: text; transform-origin: 0 0; }
.pdf-text ::selection { background: color-mix(in srgb, var(--accent) 35%, transparent); }
/* The text viewer of file previews (#821): monospace rows one text line high (the virtual list's
   arithmetic rests on it), line numbers drawn from `data-n` so they are never selected or copied,
   and the sixteen terminal colours as tokens that read on light and dark. */
.modal.file-preview.is-text { width: min(1200px, 100%); }
.preview-status-title { margin: 0; font-weight: var(--weight-semibold); font-size: var(--text-md); }
.tv {
  --tv-line: calc(var(--text-sm) * 1.6);
  --ansi-0: #24292f; --ansi-1: #c4262e; --ansi-2: #116329; --ansi-3: #7d4e00;
  --ansi-4: #0550ae; --ansi-5: #8250df; --ansi-6: #1b7c83; --ansi-7: #6e7781;
  --ansi-8: #57606a; --ansi-9: #a40e26; --ansi-10: #1a7f37; --ansi-11: #633c01;
  --ansi-12: #0969da; --ansi-13: #8250df; --ansi-14: #1b7c83; --ansi-15: #8c959f;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .tv {
    --ansi-0: #8b949e; --ansi-1: #ff7b72; --ansi-2: #3fb950; --ansi-3: #d29922;
    --ansi-4: #58a6ff; --ansi-5: #bc8cff; --ansi-6: #39c5cf; --ansi-7: #b1bac4;
    --ansi-8: #6e7681; --ansi-9: #ffa198; --ansi-10: #56d364; --ansi-11: #e3b341;
    --ansi-12: #79c0ff; --ansi-13: #d2a8ff; --ansi-14: #56d4dd; --ansi-15: #f0f6fc;
  }
}
:root[data-theme="dark"] .tv {
  --ansi-0: #8b949e; --ansi-1: #ff7b72; --ansi-2: #3fb950; --ansi-3: #d29922;
  --ansi-4: #58a6ff; --ansi-5: #bc8cff; --ansi-6: #39c5cf; --ansi-7: #b1bac4;
  --ansi-8: #6e7681; --ansi-9: #ffa198; --ansi-10: #56d364; --ansi-11: #e3b341;
  --ansi-12: #79c0ff; --ansi-13: #d2a8ff; --ansi-14: #56d4dd; --ansi-15: #f0f6fc;
}
.tv-tools { flex: none; display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 6px 12px; border-bottom: 1px solid var(--border); }
.tv-find { position: relative; display: flex; align-items: center; gap: 2px; flex: 1 1 280px; min-width: 0; }
.tv-find-icon { position: absolute; left: 9px; width: 15px; height: 15px; color: var(--text-muted); z-index: 1; pointer-events: none; }
.tv-find-input { flex: 1; min-width: 0; padding-left: 30px; }
.tv-find-count { flex: none; min-width: 5.5em; padding: 0 4px; color: var(--text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); font-variant-numeric: tabular-nums; text-align: end; }
.icon.is-flipped { transform: rotate(180deg); }
.tv-go-to { display: flex; align-items: center; gap: 6px; color: var(--text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); font-variant-numeric: tabular-nums; }
.tv-go-to-input { width: 6.5em; }
select.tv-level { min-width: 0; }
/* At phone width the level filter shares a row with "go to line". */
@media (max-width: 600px) { select.tv-level { flex: 1 1 8rem; } }
.tv-toggles { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; margin-left: auto; }
.tv-toggles [aria-pressed="true"] { background: var(--accent-soft); color: var(--accent-strong); }
.tv-toggles [aria-busy="true"] { cursor: progress; }
.tv-scroller {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--surface);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: var(--tv-line);
  tab-size: 4;
  outline-offset: -2px;
}
.tv-canvas { position: relative; min-width: 100%; }
.tv-scroller:not(.is-wrapped) .tv-canvas { min-width: max(100%, calc((var(--tv-digits) + 3.5 + var(--tv-columns)) * 1ch)); }
.tv-window { position: absolute; top: 0; right: 0; left: 0; }
.tv-row {
  display: grid;
  grid-template-columns: calc((var(--tv-digits) + 2.5) * 1ch) minmax(0, 1fr);
  min-height: var(--tv-line);
  padding-right: 1ch;
  color: var(--text);
  white-space: pre;
}
.tv-scroller.is-wrapped .tv-row { white-space: pre-wrap; word-break: break-all; overflow-wrap: anywhere; }
/* The line number stays at the left edge while the text scrolls sideways. */
.tv-row::before {
  content: attr(data-n);
  position: sticky;
  left: 0;
  z-index: 1;
  padding: 0 1.5ch 0 1ch;
  background: var(--surface);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  text-align: right;
  user-select: none;
}
.tv-row.is-target, .tv-row.is-target::before { background: var(--accent-soft); }
.tv-row.is-target::before { color: var(--accent-strong); }
.tv-row.level-debug .tv-text { color: var(--text-muted); }
.tv-row.level-error .tv-text { color: var(--lvl-error); }
.tv-level { font-weight: var(--weight-bold); }
.level-debug .tv-level { color: var(--lvl-debug); }
.level-info .tv-level { color: var(--lvl-info); }
.level-warn .tv-level { color: var(--lvl-warn); }
.level-error .tv-level { color: var(--lvl-error); }
.tv-time { color: var(--text-muted); }
.tv-match { border-radius: 2px; background: var(--mention-bg); color: var(--mention-text); }
.tv-match.is-current { background: var(--accent); color: var(--on-accent); }
.tv-probe { position: absolute; top: 0; left: 0; visibility: hidden; white-space: pre; pointer-events: none; }
.tv-empty { margin: 0; padding: 32px 16px; color: var(--text-muted); font-family: var(--font-ui); text-align: center; }
.ansi-fg-0 { color: var(--ansi-0); }
.ansi-fg-1 { color: var(--ansi-1); }
.ansi-fg-2 { color: var(--ansi-2); }
.ansi-fg-3 { color: var(--ansi-3); }
.ansi-fg-4 { color: var(--ansi-4); }
.ansi-fg-5 { color: var(--ansi-5); }
.ansi-fg-6 { color: var(--ansi-6); }
.ansi-fg-7 { color: var(--ansi-7); }
.ansi-fg-8 { color: var(--ansi-8); }
.ansi-fg-9 { color: var(--ansi-9); }
.ansi-fg-10 { color: var(--ansi-10); }
.ansi-fg-11 { color: var(--ansi-11); }
.ansi-fg-12 { color: var(--ansi-12); }
.ansi-fg-13 { color: var(--ansi-13); }
.ansi-fg-14 { color: var(--ansi-14); }
.ansi-fg-15 { color: var(--ansi-15); }
.ansi-bg-0 { background: color-mix(in srgb, var(--ansi-0) 28%, transparent); }
.ansi-bg-1 { background: color-mix(in srgb, var(--ansi-1) 28%, transparent); }
.ansi-bg-2 { background: color-mix(in srgb, var(--ansi-2) 28%, transparent); }
.ansi-bg-3 { background: color-mix(in srgb, var(--ansi-3) 28%, transparent); }
.ansi-bg-4 { background: color-mix(in srgb, var(--ansi-4) 28%, transparent); }
.ansi-bg-5 { background: color-mix(in srgb, var(--ansi-5) 28%, transparent); }
.ansi-bg-6 { background: color-mix(in srgb, var(--ansi-6) 28%, transparent); }
.ansi-bg-7 { background: color-mix(in srgb, var(--ansi-7) 28%, transparent); }
.ansi-bg-8 { background: color-mix(in srgb, var(--ansi-8) 28%, transparent); }
.ansi-bg-9 { background: color-mix(in srgb, var(--ansi-9) 28%, transparent); }
.ansi-bg-10 { background: color-mix(in srgb, var(--ansi-10) 28%, transparent); }
.ansi-bg-11 { background: color-mix(in srgb, var(--ansi-11) 28%, transparent); }
.ansi-bg-12 { background: color-mix(in srgb, var(--ansi-12) 28%, transparent); }
.ansi-bg-13 { background: color-mix(in srgb, var(--ansi-13) 28%, transparent); }
.ansi-bg-14 { background: color-mix(in srgb, var(--ansi-14) 28%, transparent); }
.ansi-bg-15 { background: color-mix(in srgb, var(--ansi-15) 28%, transparent); }
.ansi-fg-inverse { color: var(--surface); }
.ansi-bg-inverse { background: var(--text); }
.ansi-bold { font-weight: var(--weight-bold); }
.ansi-dim { opacity: .65; }
.ansi-italic { font-style: italic; }
.ansi-underline { text-decoration: underline; }
.ansi-strike { text-decoration: line-through; }
.file-error { color: var(--danger); font-size: var(--text-2xs); letter-spacing: var(--tracking-2xs); }
/* A file going up or down: bar, how far ("37 %", "12 MB / 48 MB") and, for uploads, cancel */
.file-transfer { display: flex; align-items: center; gap: 8px; margin-top: 4px; }
.file-transfer .file-progress { flex: 1; margin-top: 0; }
.file-transfer .upload-cancel { width: 24px; height: 24px; }
.file-transfer .upload-cancel svg { width: 14px; height: 14px; }
.file-meta .link-btn { align-self: flex-start; font-size: var(--text-2xs); letter-spacing: var(--tracking-2xs); }
.file-action { flex: none; }
.files-list { display: flex; flex-direction: column; gap: .5rem; padding: .5rem 1rem; }
.files-list .file-card { width: 100%; }

/* Voice messages (#204): the sender's waveform is the scrubber; bars fill as they play. */
.voice-card { width: min(360px, 100%); }
.voice-body { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.voice-wave { display: flex; align-items: center; gap: 2px; height: 28px; border-radius: var(--radius-xs); cursor: pointer; touch-action: none; }
.voice-wave:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }
.voice-bar { flex: 1 1 0; min-width: 2px; max-width: 4px; height: var(--media-bar-height, 20%); border-radius: 1px; background: var(--surface-3); transition: background-color var(--dur-fast) var(--ease-standard); }
.voice-bar.is-played { background: var(--accent); }
.voice-meta { display: flex; align-items: center; gap: 8px; min-width: 0; color: var(--text-muted); font-size: var(--text-xs); }
.voice-time { flex: none; font-variant-numeric: tabular-nums; letter-spacing: var(--tracking-xs); }
.voice-speed { flex: none; min-width: 40px; height: 28px; padding: 0 8px; border: 0; border-radius: 14px; background: var(--surface-2); color: var(--text); font-size: var(--text-xs); font-weight: 600; font-variant-numeric: tabular-nums; cursor: pointer; }
@media (hover: hover) and (pointer: fine) { .voice-speed:hover { background: var(--surface-3); } }
.voice-speed:active { transform: scale(.94); }
.voice-speed:focus-visible { outline: var(--focus-width) solid var(--focus); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  .voice-bar, .voice-speed { transition: none; }
}
/* One card for linked messages and link previews (#372). */
.embed-card, .linked-message {
  display: flex;
  gap: var(--space-3);
  max-width: 36rem;
  margin-top: 6px;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
}
.embed-card.has-wide-image { flex-direction: column; gap: var(--space-2); }
.embed-text { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.embed-card .embed-site { color: var(--text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); }
.embed-card .embed-title { font-weight: var(--weight-semibold); }
.embed-card .embed-description { color: var(--text-muted); font-size: var(--text-sm); }
.embed-thumb { flex: none; width: 64px; height: 64px; border-radius: var(--radius-xs); object-fit: cover; background: var(--surface-3); }
.embed-wide { display: block; width: 100%; max-height: 200px; border-radius: var(--radius-xs); object-fit: cover; background: var(--surface-3); }


/* The link preview under the composer's draft (#2073): what the message will carry, compact,
   with a button that takes it away. It fades in where it will stay; nothing slides. */
.composer-link-preview {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  margin: 0 0 var(--space-2);
  padding: var(--space-2);
  padding-inline-start: var(--space-3);
  border: 1px solid var(--border);
  border-inline-start: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--surface);
  animation: motion-fade-in var(--dur-base) var(--ease-standard);
}
.composer-link-preview.is-loading { border-inline-start-color: var(--border-strong); }
.composer-link-thumb {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-xs);
  object-fit: cover;
  background: var(--surface-3);
}
.composer-link-thumb-empty { display: grid; place-items: center; color: var(--text-muted); }
.composer-link-thumb-empty .icon { width: 1.25rem; height: 1.25rem; }
.composer-link-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.3; }
.composer-link-site, .composer-link-loading {
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}
.composer-link-title { font-weight: var(--weight-semibold); }
.composer-link-site, .composer-link-title, .composer-link-description {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.composer-link-description { color: var(--text-muted); font-size: var(--text-sm); }
.composer-link-remove { flex: none; align-self: flex-start; }
@media (prefers-reduced-motion: reduce) {
  .composer-link-preview { animation-duration: 150ms; }
}
/* Lightbox: one image or video over the whole window, on a blurred backdrop tinted by the picture */
/* The lightbox's own backdrop is the dark layer: it fades while a picture is dragged away, showing
   the conversation behind. */
.modal-backdrop:has(> .modal-lightbox) { padding: 0; background: transparent; }
.modal.modal-lightbox { width: 100%; height: 100%; max-height: none; border: 0; border-radius: 0; background: transparent; box-shadow: none; color: var(--lightbox-text); overflow: hidden; }
/* Two columns: the picture takes what is left, the thread panel a clamped width. Nothing is wider
   than its column, so nothing reaches past the window. */
.lightbox { display: grid; grid-template-columns: minmax(0, 1fr); height: 100%; position: relative; isolation: isolate; }
.lightbox.with-thread { grid-template-columns: minmax(0, 1fr) clamp(320px, 28vw, 420px); }
/* Takes focus only from code for the arrow keys; its controls show the (white) ring. */
.lightbox:focus { outline: none; }
/* The backdrop is opaque (#711): a solid layer the size of the window, the picture's blurred tint
   on it, a dimming scrim on top. The blur alone, on a layer only 10% larger than the window, faded
   to transparent at the edges, and the app showed through at the top. The element keeps the
   picture (`background-image`, set from Rust) but doesn't paint it (`background-size: 0 0`); its
   `::before` takes it over and is the one that is blurred. Its opacity is what a lift-off fades. */
.lightbox-backdrop { position: absolute; inset: 0; z-index: -1; overflow: hidden; background-color: var(--lightbox-bg); background-repeat: no-repeat; background-size: 0 0; transform: translateZ(0); }
/* The blur is computed on a layer 1/16 the size and scaled up 16 times: the same soft tint, but the
   software renderer (WebKitGTK without DMABUF, #805) blurs 1/256 of the pixels. A 48px blur on a
   layer 120% of a 2560x1396 window made opening a picture take seconds. */
.lightbox-backdrop::before { content: ""; position: absolute; top: -10%; left: -10%; width: 7.5%; height: 7.5%; transform-origin: 0 0; transform: scale(16); background-image: inherit; background-position: center; background-size: cover; filter: blur(3px) saturate(1.3) brightness(.4); }
.lightbox-backdrop::after { content: ""; position: absolute; inset: 0; background: rgba(8, 10, 16, .55); }
/* The desktop app's own title bar (#711): the window controls and a strip that moves the window
   keep the top of the window; the picture, its header and the thread panel start below it. */
:root[data-titlebar="custom"]:not([data-window="fullscreen"]) .lightbox { padding-top: var(--topbar-h); }
:root[data-titlebar="custom"]:not([data-window="fullscreen"]) .lightbox-thread { top: var(--topbar-h); }
:root[data-titlebar="custom"]:not([data-window="fullscreen"]):has(.modal-lightbox) .window-drag-strip { display: block; }
.lightbox-main { min-width: 0; min-height: 0; display: flex; flex-direction: column; position: relative; }
.lightbox-top { display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.lightbox-origin { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; }
.lightbox-origin-text { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.lightbox-sender { font-weight: var(--weight-semibold); font-size: var(--text-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-context { display: flex; align-items: baseline; gap: 6px; min-width: 0; font-size: var(--text-sm); color: rgba(255, 255, 255, .72); white-space: nowrap; }
.lightbox-dot { opacity: .6; }
.lightbox-name { margin: 0; min-width: 0; font-size: inherit; font-weight: var(--weight-regular); overflow: hidden; text-overflow: ellipsis; }
.lightbox-top-actions { display: flex; align-items: center; gap: 8px; }
.lightbox-count { margin: 0; font-size: var(--text-base); color: rgba(255, 255, 255, .72); white-space: nowrap; font-variant-numeric: tabular-nums; }
.lightbox-main .icon-btn { position: relative; width: 36px; height: 36px; border-radius: var(--radius); color: rgba(255, 255, 255, .85); }
@media (hover: hover) and (pointer: fine) { .lightbox-main .icon-btn:hover:not(:disabled) { background: rgba(255, 255, 255, .14); color: var(--on-fill); } }
.lightbox-main .icon-btn:disabled { opacity: .35; }
.lightbox-main .icon-btn.is-active { background: rgba(255, 255, 255, .2); color: var(--on-fill); }
.lightbox-main .icon-btn:focus-visible, .lightbox-main .btn:focus-visible, .lightbox-nav:focus-visible, .lightbox-strip-tile:focus-visible, .lightbox-slider:focus-visible { outline: var(--focus-width) solid var(--on-fill); outline-offset: var(--focus-offset); }
/* Secondary buttons tinted on the dark stage; a primary one keeps its fill (#1953). */
.lightbox-main .btn:not(.btn-primary) { background: rgba(255, 255, 255, .08); border-color: rgba(255, 255, 255, .2); color: inherit; }
@media (hover: hover) and (pointer: fine) { .lightbox-main .btn:not(.btn-primary):hover:not(:disabled) { background: rgba(255, 255, 255, .16); } }
.lightbox-main .btn[aria-pressed="true"] { background: rgba(255, 255, 255, .24); }
.lightbox-zoom { min-width: 4.5rem; font-variant-numeric: tabular-nums; }
.lightbox-body { flex: 1; min-height: 0; position: relative; display: flex; }
.lightbox-stage { position: relative; flex: 1; min-width: 0; display: flex; align-items: center; justify-content: center; overflow: hidden; touch-action: none; user-select: none; cursor: zoom-in; padding: 0 64px; }
.lightbox-stage.zoomed { cursor: grab; }
.lightbox-stage.zoomed:active { cursor: grabbing; }
.lightbox-stage.is-video { cursor: default; touch-action: auto; }
/* No box behind the picture (#727): a transparent PNG or SVG floats on the backdrop. Its shadow is a
   `drop-shadow`, which follows the picture's alpha, not a `box-shadow` around its rectangle. */
.lightbox-image { max-width: 100%; max-height: 100%; background: none; transform-origin: center; -webkit-user-drag: none; filter: drop-shadow(0 8px 28px rgba(0, 0, 0, .4)); }
/* Zoomed, the picture is laid out at its real size, set from Rust (#1089). A transform of an image
   with a `filter` is a magnified bitmap in WebKit, about half as sharp (measured in the PR), and a
   filter's buffer of a picture this large would be huge; the shadow is off-stage anyway. */
.lightbox-stage.zoomed .lightbox-image:not(.lightbox-placeholder) { filter: none; }
.lightbox-image.is-laid-out { max-width: none; max-height: none; }
/* A layer only while a gesture moves the picture, rasterised at the size it is laid out at, so a pan
   stays sharp and a pinch scales only what it added. Afterwards it is laid out and painted anew. */
.lightbox-stage.is-live .lightbox-image { will-change: transform; }
/* The previous, current and next picture side by side; the track moves as one while paging, and
   carries the picture into and out of its tile. Its transform and opacity are written per frame. */
.lightbox-track { position: absolute; inset: 0; padding: inherit; transform-origin: center; will-change: transform; }
.lightbox-track.is-pending { visibility: hidden; }
/* Opening, closing or lifted, the picture travels alone, and may leave the stage for its tile. */
.lightbox.is-flying .lightbox-slot:not(.is-current) { visibility: hidden; }
.lightbox.is-flying .lightbox-stage { overflow: visible; }
.lightbox-track.is-fading-in { animation: motion-fade-in var(--dur-base) var(--ease-standard); }
/* One cell: the current file lies over its placeholder until it is decoded, then they cross-fade. */
.lightbox-slot { position: absolute; inset: 0; box-sizing: border-box; padding: inherit; display: grid; grid-template: minmax(0, 1fr) / minmax(0, 1fr); place-items: center; }
.lightbox-slot > * { grid-area: 1 / 1; }
.lightbox-stage:not(.zoomed, .is-live) .lightbox-slot.is-current > .lightbox-image:not(.lightbox-placeholder) { transition: opacity var(--dur-base) var(--ease-standard); }
/* Zoom follows its spring; only a quarter turn of the fitted picture is the stylesheet's to animate. */
.lightbox-stage.is-turning .lightbox-slot.is-current > .lightbox-image:not(.lightbox-placeholder) { transition: transform var(--dur-fast) var(--ease-out), opacity var(--dur-base) var(--ease-standard); }
.lightbox-slot.is-current > .lightbox-image.is-arriving { opacity: 0; }
.lightbox-slot.is-current > .lightbox-placeholder.is-hidden { opacity: 0; visibility: hidden; transition: opacity var(--dur-base) var(--ease-standard), visibility 0s linear var(--dur-base); }
.lightbox-slot.is-previous { transform: translateX(calc(-100% - 24px)); }
.lightbox-slot.is-next { transform: translateX(calc(100% + 24px)); }
/* The player takes the slot; the video is letterboxed inside it, the controls float over its foot. */
.lightbox-video { width: 100%; height: 100%; }
/* The thumbnail, scaled up to the size the picture will have, while the full file loads */
.lightbox-placeholder { width: min(100%, 48rem); max-height: 100%; object-fit: contain; filter: blur(2px); }
.lightbox-loading { position: absolute; right: 16px; bottom: 16px; z-index: 2; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 50%; background: rgba(0, 0, 0, .55); }
.lightbox-loading .spinner { width: 16px; height: 16px; border-color: rgba(255, 255, 255, .3); border-top-color: var(--on-fill); }
/* Previous and next: round buttons at the sides, shown while the pointer is over the picture */
.lightbox-nav { position: absolute; top: 50%; z-index: 2; display: grid; place-items: center; width: 44px; height: 44px; margin-top: -22px; border: 0; border-radius: 50%; background: rgba(20, 22, 30, .72); color: var(--on-fill); box-shadow: 0 2px 12px rgba(0, 0, 0, .4); cursor: pointer; opacity: 0; transition: opacity var(--dur-fast) var(--ease-standard); }
@media (hover: hover) and (pointer: fine) { .lightbox-nav:hover { background: rgba(40, 44, 58, .92); } }
.lightbox-previous { left: 12px; }
.lightbox-next { right: 12px; }
.lightbox-nav:focus-visible { opacity: 1; }
@media (hover: hover) and (pointer: fine) { .lightbox-body:hover .lightbox-nav { opacity: 1; } }
.lightbox-nav:disabled { visibility: hidden; }
/* Touch has no hover: the arrows stay, quieter, and step aside while a picture is zoomed. */
@media not ((hover: hover) and (pointer: fine)) {
  .lightbox-nav { opacity: 1; background: rgba(20, 22, 30, .55); }
  .lightbox-stage.zoomed ~ .lightbox-nav { opacity: 0; pointer-events: none; }
}
/* A picture dragged away to close takes the stage alone. */
.lightbox-top, .lightbox-strip, .lightbox-controls, .lightbox-thread, .lightbox-loading, .lightbox-status { transition: opacity var(--dur-fast) var(--ease-standard); }
.lightbox.is-lifted :is(.lightbox-top, .lightbox-strip, .lightbox-controls, .lightbox-thread, .lightbox-loading, .lightbox-status, .lightbox-nav) { opacity: 0; pointer-events: none; }
.lightbox-status { position: absolute; left: 50%; bottom: 24px; z-index: 2; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 14px; border-radius: var(--radius-pill); background: rgba(0, 0, 0, .7); font-size: var(--text-base); }
.lightbox-progress { width: 6rem; }
.lightbox-error { color: #ffb4a8; }
/* A video the webview can't play (#804): a card over the video's placeholder */
.lightbox-unplayable { transition: opacity var(--dur-fast) var(--ease-standard); position: absolute; left: 50%; top: 50%; z-index: 2; transform: translate(-50%, -50%); width: min(26rem, calc(100% - 32px)); display: flex; flex-direction: column; gap: 6px; padding: 16px 18px; border-radius: 14px; background: rgba(20, 20, 22, .78); backdrop-filter: blur(20px) saturate(140%); box-shadow: 0 12px 40px rgba(0, 0, 0, .45); text-align: center; }
.lightbox-unplayable-title { margin: 0; font-size: var(--text-base); font-weight: 600; }
.lightbox-unplayable-hint { margin: 0; font-size: var(--text-sm); line-height: 1.4; color: rgba(255, 255, 255, .78); overflow-wrap: anywhere; }
.lightbox-unplayable-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 8px; }
.lightbox.is-lifted .lightbox-unplayable { opacity: 0; pointer-events: none; }
@media (prefers-reduced-transparency: reduce) { .lightbox-unplayable { background: rgb(28, 28, 30); backdrop-filter: none; } }
/* Thumbnails of the album or conversation */
.lightbox-strip { display: flex; justify-content: center; gap: 6px; padding: 8px 14px 0; overflow: hidden; }
.lightbox-strip-tile { position: relative; flex: none; display: grid; place-items: center; width: 52px; height: 52px; padding: 0; border: 2px solid transparent; border-radius: var(--radius); overflow: hidden; background: rgba(255, 255, 255, .08); color: rgba(255, 255, 255, .7); cursor: pointer; opacity: .6; }
@media (hover: hover) and (pointer: fine) { .lightbox-strip-tile:hover { opacity: .9; } }
.lightbox-strip-tile[aria-current="true"] { border-color: var(--on-fill); opacity: 1; }
.lightbox-strip-tile img { width: 100%; height: 100%; object-fit: cover; }
.lightbox-strip-badge { position: absolute; inset: auto 3px 3px auto; display: grid; place-items: center; width: 18px; height: 18px; border-radius: 50%; background: rgba(0, 0, 0, .7); }
.lightbox-strip-badge svg { width: 10px; height: 10px; }
/* The toolbar: view tools on the left, actions on the right */
.lightbox-controls { position: relative; display: flex; align-items: center; gap: 12px; padding: 10px 14px; }
.lightbox-controls-start, .lightbox-controls-end { display: flex; align-items: center; gap: 4px; }
.lightbox-controls-end { margin-left: auto; }
.lightbox-zoom-group { display: flex; align-items: center; gap: 2px; margin-left: 8px; padding: 2px; border-radius: 10px; background: rgba(255, 255, 255, .08); }
.lightbox-slider { width: 120px; accent-color: var(--on-fill); }
.lightbox-slider:disabled { opacity: .35; }
.lightbox-notice { flex: 1; min-width: 0; text-align: center; font-size: var(--text-base); color: rgba(255, 255, 255, .8); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox-menu-wrap { position: relative; }
.lightbox .lightbox-menu { top: auto; bottom: calc(100% + 8px); width: 260px; color: var(--text); }
.lightbox-details { position: absolute; right: 14px; bottom: calc(100% + 8px); z-index: 3; width: min(320px, calc(100vw - 28px)); padding: 10px 14px 12px; border-radius: 12px; background: rgba(20, 22, 30, .94); box-shadow: 0 8px 32px rgba(0, 0, 0, .5); }
.lightbox-details-head { display: flex; align-items: center; justify-content: space-between; }
.lightbox-details-head h3 { margin: 0; font-size: var(--text-md); }
.lightbox-facts { display: grid; grid-template-columns: max-content 1fr; gap: 4px 12px; margin: 6px 0 0; font-size: var(--text-base); }
.lightbox-facts dt { color: rgba(255, 255, 255, .6); }
.lightbox-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
/* The conversation's thread beside the picture */
/* The panel shrinks to its column (a flex item defaults to its content's width, and a wide image
   in the thread would push it past the window) and long words wrap; menus inside may still overlap
   the picture, so nothing clips them. */
.lightbox-thread { min-width: 0; min-height: 0; display: flex; color: var(--text); }
.lightbox-thread .side-panel { flex: 1; min-width: 0; border-left: 1px solid var(--border); overflow-wrap: anywhere; }
.lightbox-thread .side-panel > * { max-width: 100%; }
/* Tooltips that name the key: shown on hover and on keyboard focus */
.lightbox-main [data-tip]:focus-visible::after {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  z-index: 5;
  transform: translateX(-50%);
  padding: 4px 8px;
  border-radius: 6px;
  background: var(--lightbox-text);
  color: var(--lightbox-tip-text);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-medium);
  line-height: 1.3;
  white-space: nowrap;
  pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
  .lightbox-main [data-tip]:hover::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    z-index: 5;
    transform: translateX(-50%);
    padding: 4px 8px;
    border-radius: 6px;
    background: var(--lightbox-text);
    color: var(--lightbox-tip-text);
    font-size: var(--text-xs);
    letter-spacing: var(--tracking-xs);
    font-weight: var(--weight-medium);
    line-height: 1.3;
    white-space: nowrap;
    pointer-events: none;
  }
}
.lightbox-top [data-tip]:focus-visible::after { top: calc(100% + 8px); bottom: auto; left: auto; right: 0; transform: none; }
@media (hover: hover) and (pointer: fine) { .lightbox-top [data-tip]:hover::after { top: calc(100% + 8px); bottom: auto; left: auto; right: 0; transform: none; } }
.lightbox-controls-end [data-tip]:focus-visible::after { left: auto; right: 0; transform: none; }
@media (hover: hover) and (pointer: fine) { .lightbox-controls-end [data-tip]:hover::after { left: auto; right: 0; transform: none; } }
.lightbox-controls-start [data-tip]:focus-visible::after { left: 0; transform: none; }
@media (hover: hover) and (pointer: fine) { .lightbox-controls-start [data-tip]:hover::after { left: 0; transform: none; } }
.lightbox-nav[data-tip]:focus-visible::after { bottom: auto; top: calc(100% + 8px); }
@media (hover: hover) and (pointer: fine) { .lightbox-nav[data-tip]:hover::after { bottom: auto; top: calc(100% + 8px); } }
.lightbox-previous[data-tip]:focus-visible::after { left: 0; transform: none; }
@media (hover: hover) and (pointer: fine) { .lightbox-previous[data-tip]:hover::after { left: 0; transform: none; } }
.lightbox-next[data-tip]:focus-visible::after { left: auto; right: 0; transform: none; }
@media (hover: hover) and (pointer: fine) { .lightbox-next[data-tip]:hover::after { left: auto; right: 0; transform: none; } }
/* Narrow windows: the picture keeps the whole width, the panel slides over it as a sheet. */
@media (max-width: 900px) {
  .lightbox.with-thread { grid-template-columns: minmax(0, 1fr); }
  .lightbox-thread { position: absolute; inset: 0 0 0 auto; z-index: 4; width: min(380px, 100%); }
}
@media (max-width: 640px) {
  .lightbox-stage { padding: 0; }
  /* On a phone the arrows sit low and small, off the middle of the picture. */
  .lightbox-nav { top: auto; bottom: 12px; width: 36px; height: 36px; margin-top: 0; }
  .lightbox-context { flex-wrap: wrap; white-space: normal; }
  .lightbox-slider { display: none; }
  .lightbox-strip { display: none; }
  .lightbox-controls { flex-wrap: wrap; }
  .lightbox-notice { order: 3; flex-basis: 100%; }
  .lightbox-main [data-tip]::after { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .lightbox-nav { transition: none; }
}
.composer-error { color: var(--danger); margin: .25rem 0; }

/* Workspace dialogs */
.check-row { display: flex; align-items: center; gap: .5rem; margin: .5rem 0; }
.browse-list, .category-list { list-style: none; margin: .5rem 0; padding: 0; }
.browse-row, .category-row { display: flex; align-items: center; gap: .5rem; padding: .4rem 0; border-bottom: 1px solid var(--border); }
.browse-text { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.browse-topic { color: var(--text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); }
.inline-form { display: flex; gap: .5rem; }
.inline-form .input { flex: 1; min-width: 0; }

/* Settings dialogs in sections (channel and space settings) */
.modal-settings { width: min(720px, calc(100vw - 32px)); }
.modal-settings .modal-body { min-height: 420px; }
.settings-subject { margin: 0 0 var(--space-2); }
.section-tabs { padding: 0; margin: 0 0 var(--space-3); overflow-x: auto; overflow-y: hidden; scrollbar-width: none; }
.section-panel > h3:first-child { margin-top: 0; }
/* `.modal form` is `display: contents`; a settings form keeps its own column. */
.settings-form, .modal form.settings-form { display: flex; flex-direction: column; gap: 6px; margin-bottom: var(--space-3); }
.settings-form label { font-weight: var(--weight-semibold); font-size: var(--text-sm); }
.settings-row { display: flex; align-items: center; gap: var(--space-2); margin-bottom: var(--space-2); }
.settings-member-list { list-style: none; margin: 0; padding: 0; }

/* Channel settings, Integrations (issue #764): label above each field, hints spaced from what
   follows. */
.channel-integrations {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.channel-integrations .detail-heading {
  margin: var(--space-4) 0 0;
}

.channel-integrations .detail-heading:first-child {
  margin-top: 0;
}

.channel-integrations .field {
  margin: 0;
}

.channel-integrations .hint {
  margin: 0 0 var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.45;
}

.settings-member .member-name { flex: none; }
/* Under a pending invitation: its e-mail did not go out (the resend sits in the row above). */
.settings-member-note { flex-basis: 100%; margin: 0; }
.settings-member { display: flex; align-items: center; gap: var(--space-2); padding: 6px 0; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
/* A bridge source: its name over who added it when (channel settings, Integrations). */
.source-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.source-meta > span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.source-meta .muted-text { font-size: var(--text-xs); letter-spacing: var(--tracking-xs); }
/* Its own row under the source, so a long error or hint doesn't squeeze the name. */
.source-rename, .source-picture-actions { flex-basis: 100%; }
.source-picture-actions { display: flex; flex-wrap: wrap; align-items: center; gap: var(--space-2); }
.source-picture-actions .field-error { flex-basis: 100%; margin: 0; }
.plain-fieldset { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.plain-fieldset:disabled { opacity: .7; }
.radio-explained { align-items: flex-start; }
.radio-explained > span { display: flex; flex-direction: column; gap: 2px; }
.input-small { width: auto; padding: 2px 8px; font-size: var(--text-sm); }
.settings-row .grow { flex: 1; min-width: 0; }
.inline-actions { display: flex; gap: var(--space-2); margin: 6px 0; }
.switch-row { display: flex; align-items: flex-start; gap: 10px; margin: var(--space-3) 0; cursor: pointer; }
.switch-row input[role="switch"] { appearance: none; flex: none; width: 34px; height: 20px; margin-top: 2px; border-radius: 10px; background: var(--border-strong); position: relative; }
.switch-row input[role="switch"]::after { content: ""; position: absolute; top: 2px; left: 2px; width: 16px; height: 16px; border-radius: 50%; background: var(--on-fill); transition: transform var(--dur-fast) var(--ease-standard); }
.switch-row input[role="switch"]:checked { background: var(--accent); }
.switch-row input[role="switch"]:checked::after { transform: translateX(14px); }
@media (prefers-reduced-motion: reduce) { .switch-row input[role="switch"]::after { transition: none; } }
.switch-text { display: flex; flex-direction: column; gap: 2px; }


/* New user group: each field keeps its message directly below it (forms.md). */
.group-create .inline-form { align-items: flex-start; }
.group-create-field { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }

/* A channel name members' apps don't hold (#1749): under the name field. */
.field-note-warn {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  color: var(--warn-text);
}

.field-note-warn > svg {
  flex: none;
  margin-top: 2px;
}

/* A space's deletion: its channels, each with who last named it (#1727). */
.space-deletion-list { list-style: none; margin: 0 0 var(--space-2); padding: 0; max-height: 14rem; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.space-deletion-list li { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.space-deletion-name { font-weight: 600; overflow-wrap: anywhere; }
/* Browse spaces and invitations */
.space-row .space-tile { width: 36px; height: 36px; flex: none; font-size: 14px; }
.space-row.highlighted { background: var(--accent-soft); border-radius: 6px; padding-inline: .4rem; }
.browse-meta { font-size: var(--text-xs); letter-spacing: var(--tracking-xs); }
.radio-group { border: 0; margin: .5rem 0; padding: 0; }
.radio-group legend { padding: 0; font-weight: var(--weight-semibold); }
.invite-form h3, .modal-body > h3 { margin: 1rem 0 .25rem; font-size: var(--text-md); }
@media (max-width: 600px) {
  .space-row { flex-wrap: wrap; }
  .space-row .browse-text { flex-basis: calc(100% - 48px); }
}
.sidebar-head { display: flex; align-items: center; gap: .25rem; }
.sidebar-head .space-name { flex: 1; }

/* Toolbar of integration channels: Log/Chat switch, level and text filter, follow. */
.log-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--border);
}

.log-mode {
  display: flex;
  gap: 4px;
}

.log-mode [aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.log-filter-text {
  flex: 1 1 160px;
  min-width: 120px;
}

.log-follow {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
}

.log-notice {
  margin: 0;
  padding: 4px 16px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* Profiles and directory */
.avatar-img { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: block; }
/* Without a picture the element stays (avatar.rs), hidden; `display: block` above beats `[hidden]`. */
.avatar-img[hidden] { display: none; }

/* Space pictures: the rail button, the sidebar head and the quick switcher; letters until loaded. */
.space-image { width: 100%; height: 100%; border-radius: inherit; object-fit: cover; display: block; }
.space-tile {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: hsl(var(--hue) 40% 32%);
  color: var(--on-fill);
  font-size: 11px;
  font-weight: var(--weight-bold);
  vertical-align: middle;
}
.sidebar-head .space-name { display: flex; align-items: center; gap: 8px; min-width: 0; }
.switcher-space { display: inline-flex; align-items: center; gap: 4px; }
.switcher-space .space-tile { width: 18px; height: 18px; border-radius: var(--radius-xs); font-size: 11px; }
.space-image-row { display: flex; align-items: center; gap: .75rem; margin-bottom: .5rem; }
.space-image-preview .space-tile { width: 64px; height: 64px; border-radius: var(--radius-lg); font-size: 22px; }
.channel-glyph { display: inline-grid; flex: none; width: 20px; height: 20px; overflow: hidden; border-radius: var(--radius-sm); }
.channel-glyph-image { width: 100%; height: 100%; object-fit: cover; }
.header-title .channel-glyph { width: 28px; height: 28px; }
.channel-image-preview { display: grid; place-items: center; width: 64px; height: 64px; overflow: hidden; border-radius: var(--radius-lg); background: var(--surface-3); color: var(--text-muted); }
.channel-image-preview .icon { width: 28px; height: 28px; }
.channel-image-preview .space-image { width: 100%; height: 100%; object-fit: cover; }
.space-image-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.color-input { width: 48px; height: 32px; padding: 2px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: none; }

/* Crop dialog (issue #323): above the dialog that opened it. The stage shows the picture behind a
   square frame; outside the frame it is dimmed. Only the picture's transform changes while
   cropping; keyboard and button steps glide (reduced motion: the durations are ~0). */
.crop-backdrop {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(8, 12, 20, 0.6);
  overscroll-behavior: contain;
  animation: motion-fade-in var(--dur-base) var(--ease-standard);
}

.crop-dialog {
  width: min(440px, 100%);
  max-height: calc(100dvh - 32px);
}

.crop-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  overflow-y: auto;
}

.crop-stage {
  position: relative;
  width: min(328px, 100%);
  aspect-ratio: 1;
  flex: none;
  overflow: hidden;
  border-radius: var(--radius-md);
  background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--surface) 0 50%) 0 0 / 16px 16px;
  cursor: grab;
  touch-action: none;
  user-select: none;
}

.crop-stage:focus-visible {
  outline-offset: var(--focus-offset);
}

.crop-stage.is-dragging {
  cursor: grabbing;
}

.crop-image {
  position: absolute;
  top: 0;
  left: 0;
  max-width: none;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
  -webkit-user-drag: none;
}

.crop-stage.is-animated .crop-image {
  transition: transform var(--dur-base) var(--ease-standard);
}

@media (prefers-reduced-motion: reduce) {
  .crop-stage.is-animated .crop-image {
    transition: none;
  }
}

.crop-mask {
  position: absolute;
  border-radius: var(--radius-lg);
  box-shadow: 0 0 0 999px rgba(8, 12, 20, 0.62);
  outline: 2px solid rgba(255, 255, 255, 0.9);
  pointer-events: none;
}

.crop-stage.is-round .crop-mask {
  border-radius: 50%;
}

/* Thirds while dragging, to line up eyes and horizons. */
.crop-mask::before,
.crop-mask::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  opacity: 0;
  transition: opacity var(--dur-fast) var(--ease-standard);
}

.crop-mask::before {
  background:
    linear-gradient(to right, transparent calc(100% / 3 - 0.5px), rgba(255, 255, 255, 0.45) 0, rgba(255, 255, 255, 0.45) calc(100% / 3 + 0.5px), transparent 0,
      transparent calc(200% / 3 - 0.5px), rgba(255, 255, 255, 0.45) 0, rgba(255, 255, 255, 0.45) calc(200% / 3 + 0.5px), transparent 0);
}

.crop-mask::after {
  background:
    linear-gradient(to bottom, transparent calc(100% / 3 - 0.5px), rgba(255, 255, 255, 0.45) 0, rgba(255, 255, 255, 0.45) calc(100% / 3 + 0.5px), transparent 0,
      transparent calc(200% / 3 - 0.5px), rgba(255, 255, 255, 0.45) 0, rgba(255, 255, 255, 0.45) calc(200% / 3 + 0.5px), transparent 0);
}

.crop-stage.is-dragging .crop-mask::before,
.crop-stage.is-dragging .crop-mask::after {
  opacity: 1;
}

.crop-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: var(--on-fill);
  font-size: var(--text-sm);
}

.crop-help {
  max-width: 328px;
  margin: 0;
  text-align: center;
}

.crop-controls {
  display: flex;
  align-items: center;
  gap: 4px;
  width: min(328px, 100%);
}

.crop-zoom {
  flex: 1;
  min-width: 0;
  accent-color: var(--accent);
}

.crop-controls-gap {
  width: 8px;
}

.crop-previews {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 20px;
  width: 100%;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.crop-preview {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  margin: 0;
}

.crop-preview-frame {
  position: relative;
  display: block;
  overflow: hidden;
  background: var(--surface-2);
  box-shadow: 0 0 0 1px var(--border);
}

.crop-preview figcaption {
  color: var(--text-muted);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-2xs);
}

.crop-apply {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.crop-apply .spinner {
  width: 14px;
  height: 14px;
  border-color: color-mix(in srgb, currentColor 40%, transparent);
  border-top-color: currentColor;
}
.profile-facts { display: grid; grid-template-columns: max-content 1fr; gap: .25rem .75rem; margin: .75rem 0; }
.profile-facts dt { color: var(--text-muted); }
.profile-facts dd { margin: 0; overflow-wrap: anywhere; }


/* A failed crop or upload, beside the buttons that retry it. */
.crop-error {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
}
/* ---- Profile card (profile_views.rs) ----
   The person first: picture, name, presence and status centred on one axis; then the actions;
   then the quieter facts and what the user shares with them. Weight and size carry the
   hierarchy, the facts step back in colour. A centred dialog on wide screens, a sheet that rises
   from the bottom on a phone (below, compact layout). */
.modal-profile {
  position: relative;
}

.profile-close {
  position: absolute;
  top: var(--space-2);
  right: var(--space-2);
  z-index: 1;
}

.modal-profile .profile-card {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  padding: var(--space-8) var(--space-6) var(--space-6);
  overflow-y: auto;
}

.profile-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  text-align: center;
}

/* The profile card's picture; the pre-join tile sizes .avatar-xl on its own (above). */
.profile-hero .avatar-xl {
  width: 88px;
  height: 88px;
  margin-bottom: var(--space-2);
  font-size: var(--text-2xl);
  border-radius: var(--radius-lg);
}

.profile-hero .avatar-xl .presence {
  width: 16px;
  height: 16px;
  box-shadow: 0 0 0 3px var(--surface);
}

.profile-name {
  margin: 0;
  font-size: var(--text-2xl);
  line-height: var(--leading-2xl);
  letter-spacing: var(--tracking-2xl);
  font-weight: var(--weight-bold);
  overflow-wrap: anywhere;
}

.profile-handle {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-md);
  letter-spacing: var(--tracking-xs);
}

.profile-presence {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.profile-presence > .presence {
  position: static;
}

.profile-badges {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px;
  margin: var(--space-1) 0 0;
}

.custom-status-line {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0 6px;
  margin: 0;
  min-width: 0;
}

.custom-status-text {
  overflow-wrap: anywhere;
}

.custom-status-until {
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

/* The status is the one thing a person said about themselves right now: a quiet card of its own. */
.profile-status {
  justify-content: center;
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-md);
  background: var(--surface-2);
  font-size: var(--text-md);
  text-align: center;
}

.profile-status .custom-status-emoji {
  font-size: var(--text-xl);
}

.profile-status .custom-status-until {
  flex-basis: 100%;
}

.profile-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.modal-profile .profile-facts {
  margin: 0;
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
  font-size: var(--text-sm);
}

.profile-section-title {
  margin: 0 0 var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
}

.profile-shared {
  padding-top: var(--space-4);
  border-top: 1px solid var(--border);
}

.profile-chips,
.profile-channels {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 var(--space-2);
  padding: 0;
  list-style: none;
}

.profile-chip {
  padding: 2px 10px;
  border-radius: var(--radius-pill);
  background: var(--surface-2);
  font-size: var(--text-sm);
}

.profile-channel {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: none;
  color: inherit;
  font: inherit;
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}

.profile-channel:hover {
  background: var(--surface-2);
}

.profile-channel:active {
  transform: scale(var(--press-scale));
}

.profile-channel .icon {
  color: var(--text-muted);
}

.profile-more {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* The person in the header of a direct conversation and in the member list opens their card. */
.header-person,
.member-person {
  display: flex;
  align-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  text-align: left;
  cursor: pointer;
}

.header-person {
  gap: 6px;
}

.member-person {
  flex: 1;
  gap: 10px;
}

.header-person:hover .header-name,
.member-person:hover .member-name {
  text-decoration: underline;
  text-underline-offset: 2px;
}

.header-status {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  max-width: 16rem;
  color: var(--text);
}

.header-status-text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.header-local-time { color: var(--text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); }

/* Syntax highlighting (code blocks); every colour 4.5:1 on --code-bg (#843). */
.md-code .tok-keyword { color: var(--tok-keyword, #6b3bc4); font-weight: var(--weight-semibold); }
.md-code .tok-string { color: var(--tok-string, #0a7336); }
.md-code .tok-comment { color: var(--tok-comment, #5c6570); font-style: italic; }
.md-code .tok-number { color: var(--tok-number, #9a4d00); }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .md-code { --tok-keyword: #d2a8ff; --tok-string: #7ee787; --tok-comment: #8b949e; --tok-number: #ffa657; }
}
:root[data-theme="dark"] .md-code { --tok-keyword: #d2a8ff; --tok-string: #7ee787; --tok-comment: #8b949e; --tok-number: #ffa657; }

/* Markdown tables in messages and in the composer (#1565). Quiet hairlines, a header told apart by
   weight and a light fill, numbers in even columns. A table wider than the bubble scrolls sideways
   inside it instead of widening the message. While a long table scrolls past the top of the message
   list, its header row stays there (#1602): the list moves it by --md-head-shift, since the
   sideways scroller would hold a `position: sticky` header to itself. */
.md-table-wrap {
  max-width: 100%;
  margin: 4px 0 0;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.md-table-wrap:first-child {
  margin-top: 0;
}

.md-table-wrap:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.md-table,
.composer-editor table {
  border-collapse: collapse;
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  font-variant-numeric: tabular-nums;
}

.md-table {
  min-width: 100%;
}

.md-table th,
.md-table td,
.composer-editor th,
.composer-editor td {
  padding: 5px 10px;
  border-bottom: 1px solid var(--border);
  text-align: start;
  vertical-align: top;
  /* Cells keep their words together; the wrapper scrolls instead of breaking every letter. */
  overflow-wrap: normal;
  min-width: 4ch;
  max-width: 32ch;
}

.md-table th + th,
.md-table td + td,
.composer-editor th + th,
.composer-editor td + td {
  border-inline-start: 1px solid var(--border);
}

.md-table th,
.composer-editor th {
  background: var(--surface-2);
  font-weight: var(--weight-semibold);
}

/* A moved cell leaves its border behind under border-collapse; the inset shadow moves with it. */
.md-table thead th {
  position: relative;
  z-index: 1;
  transform: translateY(var(--md-head-shift, 0));
  border-bottom: none;
  box-shadow: inset 0 -1px 0 var(--border);
}

.md-table tbody tr:last-child td {
  border-bottom: none;
}

.md-table .md-align-left,
.composer-editor [data-align="left"] {
  text-align: left;
}

.md-table .md-align-center,
.composer-editor [data-align="center"] {
  text-align: center;
}

.md-table .md-align-right,
.composer-editor [data-align="right"] {
  text-align: right;
}

.md-p + .md-table-wrap,
.md-table-wrap + .md-p {
  margin-top: 4px;
}

/* In the composer the table is written into: every cell shows its edge, so an empty one can be
   found and clicked. */
.composer-editor table {
  margin: 4px 0;
  border: 1px solid var(--border-strong);
}

.composer-editor th,
.composer-editor td {
  border: 1px solid var(--border-strong);
  min-width: 8ch;
}

@media (prefers-contrast: more) {
  .md-table-wrap,
  .md-table th,
  .md-table td {
    border-color: var(--border-strong);
  }

  .md-table thead th {
    box-shadow: inset 0 -1px 0 var(--border-strong);
  }
}
/* Composer extras */
.suggestions { list-style: none; margin: 0 0 .25rem; padding: .25rem; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); max-height: 14rem; overflow: auto; }
.suggestion { display: flex; align-items: center; gap: .5rem; width: 100%; text-align: start; background: none; border: 0; color: inherit; padding: .3rem .4rem; border-radius: var(--radius-xs); cursor: pointer; }
.suggestion.current { background: var(--surface-2); }
@media (hover: hover) and (pointer: fine) { .suggestion:hover { background: var(--surface-2); } }
.suggestion-detail { color: var(--text-muted); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); margin-inline-start: auto; }
.composer-notice { margin: .25rem 0; padding: .3rem .6rem; border-inline-start: 3px solid var(--accent); color: var(--text-muted); }
/* The commands of /help: one grid of equal cells read row by row, as many columns as fit. */
.composer-help-head { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); }
.composer-help ul { display: grid; grid-template-columns: repeat(auto-fill, minmax(13rem, 1fr)); gap: 2px var(--space-4); margin: .25rem 0 0; padding: 0; list-style: none; }
.composer-help li { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.toasts { position: fixed; inset-inline-end: var(--space-4); bottom: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); z-index: 1100; /* above dialogs: an error must show over the dialog that caused it */ }
.toast { display: flex; align-items: center; gap: var(--space-2); padding: 10px var(--space-3); border-radius: var(--radius-md); background: var(--surface); color: var(--text); border: 1px solid var(--border); box-shadow: var(--shadow); }
.toast-body { display: flex; flex-direction: column; gap: .25rem; min-width: 0; max-width: min(28rem, calc(100vw - 6rem)); }
/* A failed action (issue #322): stays until closed, with the details behind a toggle. */
.toast-error { border-color: var(--danger); border-inline-start-width: 4px; }
.toast-details summary { cursor: pointer; font-size: var(--text-xs); letter-spacing: var(--tracking-xs); color: var(--text-muted); }
.toast-detail-text { display: block; margin-top: .25rem; font-size: var(--text-xs); letter-spacing: var(--tracking-xs); white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; }

/* A button whose work runs (PendingAction): disabled, with a spinner in front of its label. */
.btn[aria-busy="true"] { cursor: progress; }
.btn .spinner { display: inline-block; width: 14px; height: 14px; margin-inline-end: .4rem; vertical-align: -2px; border-color: color-mix(in srgb, currentColor 30%, transparent); border-top-color: currentColor; }

/* After a panic the app can't go on; this covers everything and only offers a reload. It is built
   without the app's code (which is dead by then), so it keeps its look without the theme too. */
.panic-overlay { position: fixed; inset: 0; z-index: 2147483647; display: flex; align-items: center; justify-content: center; padding: 16px; background: rgba(0, 0, 0, .55); }
.panic-card { display: flex; flex-direction: column; gap: 12px; width: min(32rem, 100%); padding: 24px; border-radius: 12px; background: var(--surface, Canvas); color: var(--text, CanvasText); box-shadow: 0 12px 40px rgba(0, 0, 0, .4); font: var(--text-md)/1.45 system-ui, sans-serif; }
.panic-card h2 { margin: 0; font-size: var(--text-xl); letter-spacing: var(--tracking-xl); line-height: var(--leading-xl); }
.panic-card p { margin: 0; }
.panic-details { width: 100%; min-height: 6rem; resize: vertical; font: var(--text-xs)/1.4 ui-monospace, monospace; }
.panic-reload { align-self: flex-start; padding: 8px 16px; border-radius: 8px; background: var(--accent, #2563eb); color: var(--on-accent, #fff); text-decoration: none; font-weight: var(--weight-semibold); }

/* Meeting responses and host controls */
.host-controls { margin-top: .5rem; padding: .5rem; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.host-buttons { display: flex; gap: .35rem; flex-wrap: wrap; }
/* Muting and locking without a call (#1931): visibly off; the note below says why. */
.host-buttons .btn:disabled { opacity: .45; }
.host-participants { list-style: none; margin: .5rem 0 0; padding: 0; }
.host-participants li { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: .35rem; padding: .15rem 0; }
/* Co-hosts and the handover (#1720): the part in the meeting next to the name, the organizer's buttons after it. */
.host-participant-name { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.host-participant-actions { display: flex; gap: .35rem; flex-wrap: wrap; }
.badge-host { background: var(--accent-soft); color: var(--text); white-space: nowrap; }
.host-confirm { flex-basis: 100%; display: flex; gap: .35rem; align-items: center; flex-wrap: wrap; }
.host-confirm p { flex-basis: 100%; margin: .25rem 0; }
.rsvp-list h4 { margin: .5rem 0 .15rem; }
.rsvp-list ul { margin: 0; padding-inline-start: 1.2rem; }
.call-host { position: absolute; inset-inline-end: 1rem; top: 3.5rem; z-index: 5; }
.in-meeting-badge { color: var(--accent); font-size: var(--text-xs); letter-spacing: var(--tracking-xs); }

.bookmark-edit-list { list-style: none; margin: 0 0 .5rem; padding: 0; }
.bookmark-row { display: flex; gap: .35rem; align-items: center; margin-bottom: .35rem; }
.bookmark-row .emoji-input { width: 3.5rem; text-align: center; }

.history-versions { list-style: none; margin: 0; padding: 0 1rem 1rem; }
.history-versions h3 { font-size: var(--text-xs); letter-spacing: var(--tracking-xs); color: var(--text-muted); margin: .75rem 0 .15rem; }
.diff-added { background: rgba(46, 160, 67, .25); border-radius: 2px; }
.diff-removed { background: rgba(248, 81, 73, .25); text-decoration: line-through; border-radius: 2px; }
/* The lobby on the call screen: readable over video, below the host's button. */
.call-host .lobby { max-width: 22rem; background: var(--surface); box-shadow: var(--shadow-card); }
/* The organizer leaving with people in the lobby is asked to hand the meeting over (#1720). */
.leave-prompt {
  position: absolute;
  inset-inline: 1rem;
  bottom: 5.5rem;
  z-index: 6;
  max-width: 26rem;
  margin-inline: auto;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-card);
}
.leave-prompt h2 { font-size: var(--text-md); margin: 0 0 .35rem; }
.leave-prompt p { margin: 0 0 .5rem; }
.leave-prompt-choices { display: flex; flex-wrap: wrap; gap: .35rem; }
/* Own background pictures: the delete button sits in the corner of the tile. */
.effect-cell {
  position: relative;
  min-width: 0;
}

.effect-cell > .effect-tile {
  width: 100%;
}

.effect-delete {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 22px;
  height: 22px;
  padding: 3px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.6);
  color: var(--on-fill);
  opacity: 0;
}

.effect-cell:focus-within .effect-delete {
  opacity: 1;
}

@media (hover: hover) and (pointer: fine) {
  .effect-cell:hover .effect-delete {
    opacity: 1;
  }
}

.effect-custom .scene {
  background: linear-gradient(135deg, #6b7a90, #2d3646);
}

/* Administration console: permissions, people, announcement, instance */
.hint-line { display: block; }
.permission-matrix th[scope="row"] { min-width: 14rem; font-weight: var(--weight-medium); }
.permission-matrix td.num { text-align: center; white-space: nowrap; }
.permission-matrix td.num input { vertical-align: middle; }
.permission-matrix td.overridden { background: var(--accent-soft); }
.permission-matrix .group-row th {
  background: var(--surface-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  text-align: start;
}
.badge-small { margin-inline-start: 4px; }
.moderation, .owner-assign { margin-top: 16px; }
.moderation-table td { text-align: center; }

.preset-editor { margin-top: 12px; }
.preset-editor .preset-list { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 6px; }
.preset-row { display: flex; gap: 6px; align-items: center; }
.preset-emoji { width: 4rem; text-align: center; }
.preset-text { flex: 1; min-width: 0; }

.announcement-admin { display: grid; gap: 16px; max-width: 46rem; }
.announcement-banner {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: var(--text-sm);
  background: var(--accent-soft);
  color: var(--text);
  border-bottom: 1px solid var(--border);
}
.announcement-banner .announcement-text { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.announcement-warning { background: var(--mention-bg); color: var(--mention-text); }
.announcement-critical { background: var(--danger); color: var(--on-danger); border-color: transparent; }
.announcement-critical .icon-button { color: inherit; }
.announcement-admin .announcement-banner { border: 1px solid var(--border); border-radius: var(--radius); }


/* Guests ending soon, above the app (issue #212), and the console's guest overview. */
.guest-notice .announcement-text p { margin: 0; }
.guest-notice-list { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.guest-notice-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.guest-notice-row > span { flex: 1 1 12rem; min-width: 0; overflow-wrap: anywhere; }
.guest-filters .field-inline { display: inline-flex; align-items: center; gap: 6px; }
.guest-bulk { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 8px; }
.guest-bulk p { flex: 1 1 100%; margin: 0; }
/* Desktop updates (docs/updates.md §4.3) */
.update-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: var(--text-sm);
  background: var(--accent-soft);
  color: var(--text);
  border-bottom: 1px solid var(--border);
  /* One banner changes its content (#1044): from "available" to its progress to "ready" the
     colours cross-fade, nothing moves. */
  transition: background-color 200ms ease-out, color 200ms ease-out, border-color 200ms ease-out;
}
.update-banner-error { color: var(--danger); }
.update-banner[role="alert"] { background: var(--mention-bg); color: var(--mention-text); }
/* A ready update (#729): the accent colour, the restart as a white button on it. It stays until
   the restart; in a call the button waits, disabled, and says so. */
.update-banner.is-ready { background: var(--accent); color: var(--on-accent); border-bottom-color: transparent; font-weight: var(--weight-semibold); }
.update-banner.is-ready a { color: inherit; text-decoration: underline; }
.update-banner.is-ready .update-banner-restart { border: 0; background: var(--on-accent); color: var(--accent); font-weight: var(--weight-semibold); }
.update-banner.is-ready .update-banner-restart:disabled { opacity: 0.75; cursor: default; }
@media (hover: hover) and (pointer: fine) { .update-banner.is-ready .update-banner-restart:hover:not(:disabled) { background: color-mix(in srgb, var(--on-accent) 88%, var(--accent)); } }
/* "Hide" and other quiet buttons on the accent: the accent's text colour, an outline of it. */
.update-banner.is-ready .update-banner-quiet { background: transparent; color: var(--on-accent); border-color: color-mix(in srgb, var(--on-accent) 55%, transparent); }
@media (hover: hover) and (pointer: fine) { .update-banner.is-ready .update-banner-quiet:hover { background: color-mix(in srgb, var(--on-accent) 14%, transparent); } }
.update-banner.is-ready .update-banner-error { color: var(--on-accent); text-decoration: underline; }
.update-command {
  padding: 2px 6px;
  border-radius: var(--radius);
  background: var(--bg);
  border: 1px solid var(--border);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  user-select: all;
  overflow-wrap: anywhere;
}

.instance-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(20rem, 1fr));
  gap: 16px;
  align-items: start;
}
.instance-card {
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  display: grid;
  gap: 8px;
}
.instance-card h3 { display: flex; align-items: center; gap: 8px; font-size: var(--text-md); margin: 0; }
.health-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  margin-inline-end: 8px;
  border-radius: 50%;
  background: var(--offline);
}
.health-ok { background: var(--online); }
.health-silent { background: var(--dnd); }
.health-unknown { background: var(--away); }
.badge-active { background: var(--accent-soft); color: var(--accent-strong); }
.badge-failing, .badge-unknown { background: var(--warn-soft); color: var(--warn-text); }
.badge-not-configured { background: var(--surface-3); color: var(--text-muted); }

/* Activity (#752): its list is a sidebar like a space's, on the sidebar's dark material. Each entry
   says what happened and where in two lines, the start of the message below, the time last; the
   one open beside it is marked like the current channel. Call history and last seen below. */
.activity-home,
.calls-view {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.activity-home {
  justify-content: center;
}

.activity-list,
.calls-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.activity-list {
  padding: 0 var(--space-2);
}

.activity-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin: 1px 0;
  padding: 8px 8px 8px 8px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--sb-muted);
  text-align: left;
}

@media (hover: hover) and (pointer: fine) {
  .activity-item:hover {
    background: var(--sb-hover);
    color: var(--sb-strong);
  }
}

.activity-item.unread {
  color: var(--sb-strong);
}

.activity-item.current {
  background: var(--sb-current);
  color: var(--on-fill);
}

.activity-avatar {
  flex: none;
  padding-top: 1px;
}

.activity-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.activity-summary {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
  font-size: var(--text-sm);
  line-height: 1.3;
}

.activity-item.unread .activity-summary {
  font-weight: var(--weight-semibold);
}

.activity-excerpt {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--sb-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

/* A thread's first message as rich text, kept to one line. */
.activity-excerpt .md-p {
  display: inline;
  margin: 0;
}

.activity-item.current .activity-excerpt,
.activity-item.current .activity-time {
  color: color-mix(in srgb, var(--on-fill) 80%, transparent);
}

.activity-time {
  color: var(--sb-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-variant-numeric: tabular-nums;
}

.activity-item .unread-dot {
  flex: none;
  margin-top: 6px;
  background: var(--accent);
}

.activity-item .unread-dot.mention {
  background: var(--badge-bg);
}

/* The filters' row: the kinds, a thin rule, then "Unread" on its own. */
.home-chips-divider {
  flex: none;
  width: 1px;
  margin: 4px 2px;
  background: var(--sb-edge);
}

/* The empty state sits in the sidebar: the shared card, in the sidebar's colours. */
.activity-empty {
  padding: var(--space-6) var(--space-3);
  color: var(--sb-muted);
}

.activity-sidebar .list-failed {
  padding: var(--space-6) var(--space-3);
  color: var(--sb-muted);
}

.activity-empty .empty-title,
.activity-sidebar .list-failed .empty-title {
  color: var(--sb-strong);
}

.activity-empty .empty-body,
.activity-sidebar .list-failed .empty-body {
  color: var(--sb-muted);
}

.call-detail,
.last-seen {
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

/* Grouped sidebar: one header per space with its mute and settings buttons. */
.sb-space-head {
  padding-top: 10px;
  padding-bottom: 2px;
}

.sb-space-toggle {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 4px;
  min-width: 0;
  padding: 4px 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: left;
}

.sb-space-toggle[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}

.sb-space-group.muted .sb-space-toggle {
  opacity: 0.6;
}

.sb-space-head .icon-btn[aria-pressed="true"] {
  color: var(--accent);
}

.space-btn.muted {
  opacity: 0.55;
}

.search-scope {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.search-scope .input {
  width: auto;
  min-width: 12em;
}

/* ---- Section header with an action (mark all as read) ---- */

.sb-section-row {
  display: flex;
  align-items: flex-end;
}

.sb-section-row .sb-section-head {
  flex: 1;
  min-width: 0;
}

.sb-section-action {
  margin: 0 8px 2px 0;
  color: var(--sb-muted);
}

/* ---- Emoji picker ---- */

.emoji-picker {
  position: fixed;
  z-index: 41;
  display: flex;
  flex-direction: column;
  gap: 6px;
  /* rem: grows with the text size; emoji_picker.rs places it with the same size. */
  width: 22.5rem;
  height: 26rem;
  padding: 4px 8px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

/* One tab per section; the one in view is marked. They jump, so they are buttons, not tabs. */
.emoji-tabs {
  display: flex;
  flex: none;
  justify-content: space-between;
  border-bottom: 1px solid var(--border);
}

.emoji-tab {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2.25rem;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  transition: color 120ms ease-out, transform 100ms ease-out;
}

.emoji-tab:hover {
  color: var(--text);
}

.emoji-tab:active {
  transform: scale(0.94);
}

.emoji-tab.current {
  color: var(--accent);
  box-shadow: inset 0 -2px 0 var(--accent);
}

.emoji-search {
  flex: none;
}

.emoji-scroller {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* Virtualised: the list has the full height, only the rows in view are in it, each moved to its
   place (emoji_picker.rs, ROW_REM and SECTION_REM are these heights). */
.emoji-grid {
  position: relative;
  margin: 0;
  padding: 0;
  list-style: none;
}

.emoji-row,
.emoji-section {
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
}

.emoji-row {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  align-items: center;
  height: 2.375rem;
}

.emoji-section {
  display: flex;
  align-items: flex-end;
  height: 1.75rem;
  padding: 0 4px 4px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
}

.emoji-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 2.25rem;
  border-radius: var(--radius-sm);
  font-size: var(--text-2xl);
  line-height: 1;
  cursor: pointer;
}

.emoji-cell.active {
  background: var(--accent-soft);
}

.emoji-cell:active {
  transform: scale(0.92);
}

.emoji-grid .emoji-empty {
  padding: 12px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* The emoji under the pointer or keyboard with its shortcode, and the skin tone. */
.emoji-footer {
  display: flex;
  flex: none;
  align-items: center;
  gap: 8px;
  height: 2.25rem;
  padding: 4px 4px 0;
  border-top: 1px solid var(--border);
}

.emoji-preview {
  font-size: var(--text-2xl);
  line-height: 1;
}

.emoji-preview-code {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.emoji-tones {
  display: flex;
  flex: 1;
  gap: 8px;
}

.emoji-tone-swatch {
  flex: none;
  width: 1.25rem;
  height: 1.25rem;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 100ms ease-out;
}

.emoji-tone-swatch:active {
  transform: scale(0.9);
}

.emoji-tone-swatch[aria-checked="true"],
.emoji-tone-button[aria-expanded="true"] {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.emoji-tone-button {
  margin-left: auto;
}

.tone-default { background: var(--skin-tone-default); }
.tone-light { background: var(--skin-tone-light); }
.tone-medium-light { background: var(--skin-tone-medium-light); }
.tone-medium { background: var(--skin-tone-medium); }
.tone-medium-dark { background: var(--skin-tone-medium-dark); }
.tone-dark { background: var(--skin-tone-dark); }

@media (prefers-reduced-motion: reduce) {
  .emoji-tab,
  .emoji-tone-swatch {
    transition: none;
  }
}

.msg-toolbar .quick-reaction {
  font-size: var(--text-lg);
  letter-spacing: var(--tracking-lg);
  line-height: 1;
}


/* ---- Custom emoji (issue #207) ---- */

/* A workspace emoji's picture at text size: in messages, the jumbo sizes grow it with the text.
   The negative margin keeps the line as high as the text around it. */
.custom-emoji {
  display: inline-block;
  width: auto;
  max-width: 2.75em;
  height: 1.375em;
  margin: -0.2em 0.05em;
  object-fit: contain;
  vertical-align: middle;
}

.custom-emoji-text {
  white-space: nowrap;
}

.emoji-cell .custom-emoji,
.emoji-preview .custom-emoji {
  max-width: 1.75rem;
  height: 1.75rem;
  margin: 0;
}

.reaction .custom-emoji {
  max-width: 2.25rem;
  height: 1.125rem;
  margin: 0;
}

.suggestion-emoji {
  display: inline-flex;
  flex: none;
}

.suggestion-emoji .custom-emoji {
  height: 1.25rem;
  margin: 0;
}

/* Admin console: the list of emoji and the form that adds one. */
.admin-emoji-add {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-3);
  margin-bottom: var(--space-4);
}

.admin-emoji-add .field {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 12rem;
}

.admin-emoji-add > .btn {
  align-self: flex-end;
}

.admin-emoji-row {
  flex-wrap: wrap;
}

.admin-emoji-picture {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
}

.admin-emoji-picture .custom-emoji {
  max-width: 2.25rem;
  height: 2.25rem;
  margin: 0;
}

.admin-emoji-rename {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}
/* The connection state (#718). Reconnecting is the app's job: a slim muted line along the lower
   edge of the top bar (or the page header in its place on a phone), out of the layout so nothing
   moves when it comes or goes, and out of the pointer's way. A light sweeps along it while the app
   works on it; offline it rests. Only what the user must act on, or a connection down long, is a
   notice in the banner row (offline_banner.rs). */
.connection-hint {
  position: fixed;
  top: calc(var(--banners-h, 0px) + var(--topbar-h) - 2px);
  left: 0;
  right: 0;
  z-index: 55;
  height: 2px;
  overflow: hidden;
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  pointer-events: none;
}

/* It fades in where it is; the banners' slide would move it off the edge it marks. */
.app-banners > .connection-hint {
  animation: motion-fade-in var(--dur-base) var(--ease-standard);
}

.connection-hint::after {
  content: "";
  position: absolute;
  inset: 0;
  width: 40%;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--accent) 80%, transparent), transparent);
  transform: translateX(-100%);
  animation: connection-hint-sweep 1.6s var(--ease-standard) infinite;
}

.connection-hint.is-offline {
  background: color-mix(in srgb, var(--chrome-text) 35%, transparent);
}

.connection-hint.is-offline::after {
  display: none;
}

/* Slow but connected: a resting line, nothing is being retried. */
.connection-hint.is-slow::after {
  display: none;
}

/* The title bar is the window's top edge: the banners are below it, the line at its foot. */
:root[data-titlebar="custom"] .connection-hint {
  top: calc(var(--topbar-h) - 2px);
}

:root[data-layout="compact"] .connection-hint {
  top: calc(env(safe-area-inset-top) + var(--banners-h, 0px) + var(--topbar-h) - 2px);
}

@keyframes connection-hint-sweep {
  to {
    transform: translateX(250%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .connection-hint::after {
    display: none;
  }
}

@media (forced-colors: active) {
  .connection-hint {
    background: Highlight;
    forced-color-adjust: none;
  }
}

.connection-notice {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
}

.connection-notice > .icon {
  flex: none;
  color: var(--star);
}

.connection-notice-text {
  flex: 1;
  min-width: 0;
}

.connection-notice > .btn {
  flex: none;
}

/* Long messages start collapsed; "Show more" expands them. */
.msg-long.collapsed {
  max-height: 16em;
  overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 75%, transparent);
  mask-image: linear-gradient(to bottom, #000 75%, transparent);
}

.msg-expand {
  margin: 2px 0 4px;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

/* Placeholders for content that is still loading (components/skeleton.rs). */
.list-skeleton {
  display: block;
}

.msg-skeleton {
  display: flex;
  gap: 12px;
  padding: 8px 16px;
}

.skeleton-avatar,
.skeleton-lines span {
  background: var(--surface-3);
  border-radius: var(--radius-sm);
  /* A few pulses, then still: a placeholder left in the overscan must not keep the page busy. */
  animation: skeleton-pulse 1.4s ease-in-out 6;
}

.skeleton-avatar {
  flex: none;
  width: 36px;
  height: 36px;
}

.skeleton-lines {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 6px;
  padding-top: 4px;
}

.skeleton-lines span {
  height: 10px;
  width: 30%;
}

.skeleton-lines span + span {
  width: 65%;
}

@keyframes skeleton-pulse {
  50% {
    opacity: 0.5;
  }
}

@media (prefers-reduced-motion: reduce) {
  .skeleton-avatar,
  .skeleton-lines span {
    animation: none;
  }
}

/* The day of the top message while scrolled up (the dividers scroll away with their rows). */
.floating-day {
  /* The pinned day (#1046): a strip over the top of the feed that clips the pill as the next
     day's divider pushes it out. Its padding is PINNED_DAY_TOP_PX in message_list.rs. */
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 5;
  display: flex;
  justify-content: center;
  padding: 8px 0 6px;
  overflow: hidden;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
  transition: opacity var(--dur-base) var(--ease-standard);
  pointer-events: none;
}

/* How a request for older history stands, over the top of the feed: the rows don't move for it. */
.older-history {
  position: absolute;
  top: 40px;
  left: 50%;
  z-index: 6;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 32px);
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface);
  box-shadow: var(--shadow-card);
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.older-history-retry {
  flex: none;
  border: none;
  background: none;
  color: var(--accent);
  font: inherit;
  font-weight: var(--weight-semibold);
  cursor: pointer;
}

/* A translucent material over the text scrolling underneath; fades out once the feed rests. */
.floating-day .date-pill {
  background: color-mix(in srgb, var(--surface) 72%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  backdrop-filter: saturate(180%) blur(12px);
  box-shadow: 0 1px 4px rgba(16, 24, 40, 0.12);
  pointer-events: auto;
}

.floating-day.is-idle {
  opacity: 0;
}

.floating-day.is-idle .date-pill {
  pointer-events: none;
}

@media (prefers-reduced-transparency: reduce) {
  .floating-day .date-pill {
    background: var(--surface);
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
  }
}

.popover.date-jump-menu {
  position: fixed;
  right: auto;
  left: var(--date-jump-x, 0);
  top: var(--date-jump-y, 0);
  width: 14.5rem;
  --popover-origin: top left;
}

.date-jump-pick {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding: var(--space-2) 14px 6px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* Thread summary: who replied, how many, when. */
.reply-avatars {
  display: inline-flex;
}

.reply-avatars .avatar-sm:first-child {
  margin-left: 0;
}

.reply-last {
  color: var(--text-muted);
  font-weight: var(--weight-regular);
}

/* Several attachments: their count and one button to save them all. */
.files-bar {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.files-bar .link-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
}

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

/* A message still in the outbox. */
.msg-delivery {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 6px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.msg-delivery .icon {
  width: 14px;
  height: 14px;
}

.msg-delivery.is-pending .icon,
.msg-delivery.is-sent .icon {
  width: 12px;
  height: 12px;
}

/* Ticks: one when the server has it, two blue ones when everyone read it. */
.msg-delivery.is-sent {
  margin-left: 4px;
}

.msg-delivery.is-read {
  color: var(--accent);
}

/* Comfortable and Compact: the tick or clock sits at the body's trailing edge on its last line, in
   space the body keeps free for it, never on a row of its own (#634). It takes the body's font and
   line height so `1lh` is one line of text; the icon has a fixed size. Bubbles float it instead. */
/* The meta wrapper only groups time and ticks for the bubbles; here it adds no box. */
:root:not([data-density="bubbles"]) .bubble-meta {
  display: contents;
}

:root:not([data-density="bubbles"]) .msg-body:has(> .bubble-meta > .msg-delivery.is-sent, > .bubble-meta > .msg-delivery.is-pending:not(.msg-delayed)) {
  position: relative;
  padding-inline-end: 22px;
}

:root:not([data-density="bubbles"]) .msg-body > .bubble-meta > .msg-delivery:is(.is-sent, .is-pending:not(.msg-delayed)) {
  position: absolute;
  inset-inline-end: 0;
  bottom: 0;
  height: 1lh;
  margin: 0;
  font-size: inherit;
  letter-spacing: inherit;
}

/* Not confirmed after a while: still retried by itself, so muted, not an error. */
.msg-delayed {
  color: var(--text-muted);
}

/* Refused by the server for good: says so, with "Try again" and "Delete". */
.msg-delivery.msg-failed {
  color: var(--danger);
  font-weight: var(--weight-semibold);
}

.msg-failed .link-btn {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-medium);
}

/* Card over a person's name while the pointer rests on it. */
.hover-card {
  position: fixed;
  z-index: 42;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 280px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
}

.hover-card-head {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}

.hover-card-head p {
  margin: 2px 0 0;
}

.hover-card-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
}


/* Last messages of a conversation beside its sidebar row (#2078). */
.conversation-preview {
  gap: 8px;
  width: 320px;
  pointer-events: auto;
}

.conversation-preview-line p {
  margin: 0;
}

.conversation-preview-meta {
  display: flex;
  gap: 8px;
  align-items: baseline;
}

.conversation-preview-body {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (prefers-reduced-motion: no-preference) {
  .conversation-preview {
    animation: conversation-preview-in 120ms ease-out;
  }
}

@keyframes conversation-preview-in {
  from {
    opacity: 0;
  }
}
/* A message opened from search, a link or the activity list lights up briefly. */
/* The tint is an overlay behind the content that fades out (`opacity`, on the compositor), not a
   background repainted for 2.5 s. */
.msg-highlight {
  isolation: isolate;
}

.msg-highlight::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: var(--mention-bg);
  pointer-events: none;
  animation: msg-highlight 2.5s var(--ease-standard) forwards;
}

@keyframes msg-highlight {
  0%,
  40% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .msg-highlight::before {
    animation: none;
  }
}

.composer .also-send {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 2px 0;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
  cursor: pointer;
}

/* Forms in the workspace dialogs (new space, new channel, settings): one field under the other. */
.modal-body > form {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* Labels are captions of the field below: smaller and muted, so the fields carry the form. */
.modal-body > form > label:not(.check-row) {
  margin-top: var(--space-3);
  padding-inline: 2px;
  font-size: var(--text-sm);
  letter-spacing: 0;
  font-weight: var(--weight-semibold);
  color: var(--text-muted);
}

.modal-body > form > label:first-child {
  margin-top: 0;
}

/* ---- Getting started (empty workspace or space) ---- */

.getting-started {
  max-width: 560px;
  margin: 48px auto;
  padding: 0 24px;
  overflow-y: auto;
}

.getting-started h1 {
  margin: 0 0 6px;
  font-size: var(--text-2xl);
  letter-spacing: var(--tracking-2xl);
  line-height: var(--leading-2xl);
}

.start-steps {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 24px 0 0;
  padding: 0;
  list-style: none;
}

.start-step {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

@media (hover: hover) and (pointer: fine) {
  .start-step:hover {
    background: var(--surface-2);
  }
}

.start-step > .icon {
  flex: none;
  width: 24px;
  height: 24px;
  color: var(--accent);
}

.start-step-text {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* An input with a button beside it (show/hide the passphrase). */
.input-with-action {
  display: flex;
  gap: 6px;
  align-items: center;
}

.input-with-action .input {
  flex: 1;
  min-width: 0;
}

.start-heading {
  margin: 24px 0 8px;
  font-size: var(--text-md);
}

/* Runtime settings of the admin console: brands, mail, calendar, instance settings. */
.field-unit {
  white-space: nowrap;
  align-self: center;
}

.field-row .input {
  flex: 1;
  min-width: 0;
}

.settings-source {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
}

.check-field {
  align-items: flex-start;
}

.check-field > span {
  display: flex;
  flex-direction: column;
}

.settings-status {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0 0 12px;
}

.settings-status dt {
  color: var(--text-muted);
}

.settings-status dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
}

.brand-editor {
  max-width: 760px;
}

.brand-editor .policy-group {
  min-width: 0;
}

.brand-row {
  flex-wrap: wrap;
}

.brand-row .admin-row-name {
  white-space: normal;
}

.brand-hosts .admin-row {
  justify-content: space-between;
}

.brand-colors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.brand-color-column h4 {
  margin: 0 0 8px;
}

.brand-color-field {
  margin: 6px 0 0;
}

.brand-color-picker {
  width: 40px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: none;
  cursor: pointer;
}

.brand-theme-custom {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px 16px;
  margin-top: 8px;
}

.brand-theme-presets {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 2px 16px;
}

.brand-theme-presets h5 {
  grid-column: 1 / -1;
  margin: 8px 0 2px;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.brand-preview {
  --bp-bg: #fff;
  --bp-text: #1a1d21;
  margin: 12px 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bp-bg);
  color: var(--bp-text);
}

.brand-preview.is-dark {
  --bp-bg: #1b1d21;
  --bp-text: #e8eaed;
}

.brand-preview-chrome {
  height: 14px;
  background: var(--chrome);
}

.brand-preview-body {
  display: flex;
  min-height: 72px;
}

.brand-preview-sidebar {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 30%;
  padding: 8px;
  /* As in the app (000-tokens.css): a light tint of the navigation colour, the colour itself in the
     dark. The brand's colours are set on the preview, so the tint is mixed here, not inherited. */
  background: color-mix(in srgb, var(--nav) var(--sb-tint), #ffffff);
  box-shadow: inset -1px 0 0 rgba(0, 0, 0, 0.08);
}

.brand-preview.is-dark .brand-preview-sidebar {
  background: var(--nav);
  box-shadow: none;
}

.brand-preview-sidebar span {
  display: block;
  height: 10px;
  border-radius: 3px;
  background: rgba(127, 127, 127, 0.35);
}

.brand-preview-sidebar .brand-preview-current {
  background: var(--sb-current);
}

.brand-preview-main {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 8px;
}

.brand-preview-button,
.brand-preview-soft {
  padding: 4px 10px;
  border-radius: var(--radius);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.brand-preview-button {
  background: var(--accent);
  color: var(--on-accent);
}

.brand-preview-soft {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.brand-contrast {
  margin: 0 0 8px;
  padding: 0;
  list-style: none;
}

.brand-asset-row {
  flex-wrap: wrap;
}

.brand-asset-row .admin-row-name {
  white-space: normal;
}

.brand-asset-preview {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 56px;
  height: 40px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: #fff;
}

.brand-asset-preview.is-dark {
  background: #1b1d21;
}

.brand-asset-img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

@media (max-width: 720px) {
  .brand-colors {
    grid-template-columns: minmax(0, 1fr);
  }

  .settings-status {
    grid-template-columns: minmax(0, 1fr);
  }
}


/* A refused image's message sits on its own line inside its slot's row (forms.md). */
.brand-asset-error {
  flex-basis: 100%;
}
/* Keyboard shortcut: one <kbd> per key cap, "+" between them except on macOS. */
.shortcut {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.shortcut-plus {
  opacity: 0.6;
}

/* ---- Direct messages page (rail entry, sidebar, start page, new message) ---- */

.rail-divider {
  width: 24px;
  height: 2px;
  border-radius: 1px;
  background: rgba(255, 255, 255, 0.18);
}

.space-rail ul .space-btn:has(> .icon) {
  display: grid;
  place-items: center;
}

/* Inputs in the sidebar's colours. */
.dm-options .input {
  border: 1px solid var(--sb-edge);
  background: var(--sb-fill);
  color: var(--sb-strong);
}

.dm-options option {
  background: var(--sb-bg);
  color: var(--sb-strong);
}

.dm-options .muted-text {
  color: var(--sb-muted);
}

.dm-options {
  display: grid;
  gap: 4px;
  margin: 0 12px 8px;
  padding: 8px;
  border-radius: var(--radius-sm);
  background: var(--sb-fill);
  font-size: var(--text-sm);
}

.sb-section-title {
  margin: 0;
  padding: 14px 12px 4px 16px;
  color: var(--sb-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  letter-spacing: 0.02em;
}

.sb-empty {
  display: grid;
  gap: 10px;
  margin: 16px;
  color: var(--sb-muted);
  font-size: var(--text-sm);
}

.dm-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  max-width: 420px;
  margin: 15vh auto 0;
  padding: 0 24px;
  text-align: center;
}

.dm-home h1 {
  margin: 0;
  font-size: var(--text-2xl);
  letter-spacing: var(--tracking-2xl);
  line-height: var(--leading-2xl);
}

.dm-home-icon {
  width: 48px;
  height: 48px;
  color: var(--accent);
}


/* One compact row; a narrow sidebar scrolls it instead of adding a second row. */
.home-chips {
  display: flex;
  flex-wrap: nowrap;
  gap: 6px;
  margin: 0 12px 8px;
  overflow-x: auto;
  scrollbar-width: none;
}

/* The list layout has one chip more: all of them stay in sight, on two lines where they must. */
.dm-sidebar.is-list .home-chips {
  flex-wrap: wrap;
}

/* Quiet until selected: a tinted pill without an outline, like the filters of a mail app. */
.home-chip {
  flex: none;
  min-height: 26px;
  padding: 0 10px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--sb-fill);
  color: var(--sb-text);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
  transition: background-color 120ms ease-out;
}

@media (hover: hover) and (pointer: fine) {
  .home-chip:hover {
    background: var(--sb-fill-strong);
  }
}

.home-chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

.home-avatar {
  display: inline-flex;
  flex: none;
}

.home-avatar-group {
  width: 24px;
  height: 24px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--sb-fill-strong);
}

.home-avatar-group .icon {
  width: 14px;
  height: 14px;
}

.dm-sidebar .sb-item .badge {
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-2xs);
}

/* Single avatars in lists, not the overlapping stack the small size is made for. */
.home-avatar .avatar-sm,
.person-item .avatar-sm {
  width: 24px;
  height: 24px;
  margin-left: 0;
  box-shadow: none;
}


/* Chats without direct messages yet, or nothing unread (issue #301): a drawing, a headline, a
   sentence and "New message", centred in the sidebar. */
.dm-empty {
  justify-items: center;
  margin: var(--space-6) 16px;
  text-align: center;
  line-height: 1.5;
}

.dm-empty .dm-empty-title {
  color: var(--sb-strong);
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
}

.dm-empty .illustration {
  margin-bottom: var(--space-1);
}

/* The drawings of components/illustration.rs, in the theme's colours. */
.illustration-back {
  /* Works on the dark sidebar and on light pages alike. */
  fill: color-mix(in srgb, var(--accent) 32%, transparent);
}

.illustration-front {
  fill: var(--accent);
}

.illustration-mark {
  fill: var(--on-accent);
}

.illustration-check {
  fill: none;
  stroke: var(--accent);
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
/* ---- Motion (issue #273) ----
   Every transition and entrance of the shell in one place, all on the tokens of the first block.
   Rules: only transform and opacity move (compositor work, no layout); entrances run once when an
   element mounts; exits are played by inert copies (`.motion-ghost.is-leaving`, src/motion.rs) so
   the real element is gone at once; nothing loops while it isn't visible. Reduced motion keeps the
   fades and turns every movement into one (end of this section). */

/* Press: a slight shrink, so a click is felt before the result shows. Hover and focus change
   colour at once (no paint transitions); the focus ring is the outline from "Base". */
:is(
    .btn,
    .icon-btn,
    .header-btn,
    .space-btn,
    .rail-add,
    .rail-dest,
    .reaction,
    .reply-count,
    .segmented button,
    .view-tabs [role="tab"],
    .preset,
    .format-btn,
    .send-btn,
    .bottom-nav-tab,
    .home-chip,
    .quick-reaction,
    .sheet-reaction,
    .media-tool,
    .sb-item,
    .sb-section-head,
    .menu-item,
    .switcher-row,
    .activity-item
  ) {
  transition: transform var(--dur-fast) var(--ease-standard);
}

:is(
    .btn,
    .icon-btn,
    .header-btn,
    .space-btn,
    .rail-add,
    .reaction,
    .reply-count,
    .segmented button,
    .view-tabs [role="tab"],
    .preset,
    .format-btn,
    .send-btn,
    .bottom-nav-tab,
    .home-chip,
    .quick-reaction,
    .sheet-reaction,
    .media-tool
  ):active:not(:disabled) {
  transform: scale(var(--press-scale));
}

/* Rows shrink less, or wide rows would look like they jump. */
:is(.sb-item, .sb-section-head, .menu-item, .switcher-row, .activity-item):active:not(:disabled) {
  transform: scale(0.995);
}

.rail-dest:active .rail-dest-icon {
  transform: scale(0.94);
}

.rail-dest-icon {
  transition: transform var(--dur-fast) var(--ease-standard);
}

/* The end of a move: WebKit (the desktop webview) draws a moving element in a layer of its own and
   paints it back into the page when the motion ends, which can shift or sharpen it in that one
   frame, a snap after the motion. Short-lived surfaces keep their layer while they are up, so
   nothing is handed back; long-lived ones (the main column) only fade, which hands back unchanged.
   Indicators are small and slide often. `opacity`, not `transform`: it keeps the layer without
   making the surface the containing block of fixed menus inside it (the emoji picker, hover cards). */
:is(.popover, .emoji-picker, .modal, .toast, .sheet, .motion-ghost) {
  will-change: opacity;
}

.tab-indicator.is-live {
  will-change: transform;
}

/* Views: the main column cross-fades in on a switch (channel to channel, to threads, …) and the
   side panel slides in. Short, so a cached channel still feels instant. */
.main > * {
  animation: motion-view-in var(--dur-fast) var(--ease-standard);
}

.side-panel:not(.embedded) {
  animation: motion-panel-in var(--dur-base) var(--ease-emphasized);
}

/* Only a fade: the column stays put, so its end hands nothing back (above). */
@keyframes motion-view-in {
  from {
    opacity: 0;
  }
}

@keyframes motion-panel-in {
  from {
    opacity: 0;
    transform: translateX(16px);
  }
}

/* Dialogs scale and fade in; their exit is faster and smaller. The quick switcher is opened from
   the keyboard many times a day, so it appears and goes at once (any motion there reads as
   latency); `Modal` leaves no exit ghost for it either. */
.modal-backdrop {
  animation: motion-fade-in var(--dur-base) var(--ease-standard);
}

.modal {
  animation: motion-dialog-in var(--dur-base) var(--ease-emphasized);
}

.modal-backdrop:has(> .modal-switcher),
.modal.modal-switcher {
  animation: none;
}

/* The lightbox's picture grows out of its tile (or its track fades in) and the chrome fades in
   around it; the backdrop's fade is driven with the picture (lightbox_motion.rs). */
.modal.modal-lightbox {
  animation: none;
}

.lightbox-top,
.lightbox-strip,
.lightbox-controls {
  animation: motion-fade-in var(--dur-base) var(--ease-standard);
}

/* Reduced motion: nothing moves, the new picture cross-fades in briefly. */
@media (prefers-reduced-motion: reduce) {
  .lightbox-slot.is-current .lightbox-image,
  .lightbox-track.is-fading-in {
    animation: motion-fade-in 150ms var(--ease-standard);
  }

  /* The full file replaces its placeholder at once. */
  .lightbox-stage:not(.zoomed, .is-live) .lightbox-slot.is-current > .lightbox-image:not(.lightbox-placeholder),
  .lightbox-stage.is-turning .lightbox-slot.is-current > .lightbox-image:not(.lightbox-placeholder),
  .lightbox-slot.is-current > .lightbox-placeholder.is-hidden {
    transition: none;
  }
}

.motion-ghost {
  position: fixed !important;
  z-index: 59;
  margin: 0 !important;
  pointer-events: none;
}

.motion-ghost.is-leaving {
  animation: motion-fade-out var(--dur-exit) var(--ease-exit) forwards;
}

/* A deep copy starts its parts' entrances again (`.main > *`, the lightbox's chrome, unread dots):
   they would fade in while the copy leaves. Only the exits below play. */
.motion-ghost * {
  animation: none;
}

/* Exit played: hidden with the exit still holding, removed two frames later (motion.rs). */
.motion-ghost.is-gone {
  visibility: hidden;
}

/* The lightbox's full image is released with it; its ghost fades the backdrop only. A lightbox that
   closed into its tile has nothing left to fade. */
.motion-ghost .lightbox-image {
  visibility: hidden;
}

.motion-ghost:has(.lightbox.is-closed) {
  display: none;
}

.motion-ghost.is-leaving .modal {
  animation: motion-dialog-out var(--dur-exit) var(--ease-exit) forwards;
}

@keyframes motion-fade-in {
  from {
    opacity: 0;
  }
}

@keyframes motion-fade-out {
  to {
    opacity: 0;
  }
}

@keyframes motion-dialog-in {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
}

@keyframes motion-dialog-out {
  to {
    opacity: 0;
    transform: scale(0.97);
  }
}

/* Popovers and menus grow out of the edge that touches their trigger and shrink back into it.
   The default hangs below the trigger, right-aligned; `.opens-up` sits above it, `.align-start`
   aligns its left edge. Menus that place themselves (message menu, emoji picker) set the class
   when they flip. */
.popover,
.emoji-picker {
  animation: motion-popover-in var(--dur-fast) var(--ease-emphasized);
  transform-origin: var(--popover-origin, top right);
}

:is(.popover, .emoji-picker).align-start {
  --popover-origin: top left;
}

:is(.popover, .emoji-picker).opens-up {
  --popover-origin: bottom right;
  --popover-dy: 4px;
}

:is(.popover, .emoji-picker).opens-up.align-start {
  --popover-origin: bottom left;
}

.motion-ghost.is-leaving:is(.popover, .emoji-picker) {
  animation: motion-popover-out var(--dur-exit) var(--ease-exit) forwards;
}

@keyframes motion-popover-in {
  from {
    opacity: 0;
    transform: translateY(var(--popover-dy, -4px)) scale(0.96);
  }
}

@keyframes motion-popover-out {
  to {
    opacity: 0;
    transform: translateY(var(--popover-dy, -4px)) scale(0.97);
  }
}

/* Toasts rise in and sink back out the same way; banners settle in from above. The others glide
   to their new places when one comes or goes (`translate`, played from src/toast_motion.rs), and
   on touch a toast follows the finger and is swiped away. */
.toast {
  animation: motion-toast-in var(--dur-base) var(--ease-emphasized);
  transition:
    translate var(--dur-base) var(--ease-standard),
    transform var(--dur-base) var(--ease-standard),
    opacity var(--dur-base) var(--ease-standard);
}

.toast.is-flipping,
.toast.is-dragging {
  transition: none;
}

.toast.is-swiped {
  transition:
    transform var(--dur-exit) var(--ease-exit),
    opacity var(--dur-exit) var(--ease-exit);
  pointer-events: none;
}

/* Not only under (pointer: coarse): a touch laptop has a fine primary pointer, and without this
   the browser takes the horizontal pan and fires pointercancel. It only affects touch input. */
.toast {
  touch-action: pan-y;
}

.motion-ghost.is-leaving.toast {
  animation: motion-toast-out var(--dur-exit) var(--ease-exit) forwards;
}

.app-banners > *,
.key-banner {
  animation: motion-banner-in var(--dur-base) var(--ease-emphasized);
}

@keyframes motion-toast-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
}

@keyframes motion-toast-out {
  to {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
}

@keyframes motion-banner-in {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* Sidebar sections: the chevron turns, the rows of a section the user opens slide down into place
   and slide back up when they close it (`.is-opening`/`.is-closing` only follow a click, not a
   re-render; the list is hidden once the exit played). */
.sb-section-head .chevron,
.sb-space-head .chevron {
  transition: transform var(--dur-base) var(--ease-emphasized);
}

.sb-section ul.is-opening {
  animation: motion-section-open var(--dur-base) var(--ease-emphasized);
  transform-origin: top;
}

@keyframes motion-section-open {
  from {
    opacity: 0;
    transform: translateY(-6px);
  }
}

.sb-section ul.is-closing {
  animation: motion-section-close var(--dur-exit) var(--ease-exit) forwards;
  transform-origin: top;
  pointer-events: none;
}

@keyframes motion-section-close {
  to {
    opacity: 0;
    transform: translateY(-6px);
  }
}

/* Messages: one that arrives while the conversation is open rises in; the user's own message is
   shown at once (optimistic) and dimmed until the server has it, then settles to full strength. */
.msg.msg-arriving {
  animation: motion-message-in var(--dur-slow) var(--ease-emphasized);
}

.msg.msg-pending .msg-main {
  opacity: 0.7;
}

.msg.msg-settling .msg-main {
  animation: motion-message-settle var(--dur-slow) var(--ease-standard);
}

.new-divider {
  animation: motion-fade-in var(--dur-slow) var(--ease-standard);
}

@keyframes motion-message-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
}

@keyframes motion-message-settle {
  from {
    opacity: 0.7;
  }
}

/* Reactions pop when the count changes; badges when their number goes up. */
.reaction.is-popping {
  animation: motion-pop var(--dur-slow) var(--ease-pop);
}

.badge-count.is-bumped {
  animation: motion-pop var(--dur-slow) var(--ease-pop);
}

.unread-dot {
  animation: motion-dot-in var(--dur-base) var(--ease-pop);
}

/* One segment: --ease-pop already overshoots the end (about 1.17 from 0.7). A middle keyframe at
   1.12 would run the curve once per segment and wobble the count (overshoot, then undershoot). */
@keyframes motion-pop {
  from {
    transform: scale(0.7);
  }
}

@keyframes motion-dot-in {
  from {
    opacity: 0;
    transform: scale(0.4);
  }
}

/* Selection indicators: one per tab list, segmented control and the bottom navigation, sliding
   from the old item to the new one (src/components/sliding_indicator.rs sets the variables).
   It is laid out once at the selected item's width and only translates and scales after that. */
.tab-indicator {
  position: absolute;
  left: 0;
  top: 0;
  z-index: -1;
  width: var(--indicator-base-w, 0px);
  height: var(--indicator-h, 0px);
  transform: translate(var(--indicator-x, 0px), var(--indicator-y, 0px)) scaleX(var(--indicator-sx, 1));
  transform-origin: 0 0;
  opacity: 0;
  pointer-events: none;
}

.tab-indicator.has-selection {
  opacity: 1;
}

.tab-indicator.is-live {
  transition:
    transform var(--dur-base) var(--ease-standard),
    opacity var(--dur-fast) var(--ease-standard);
}

.view-tabs > .tab-indicator {
  top: auto;
  bottom: -1px;
  z-index: 1;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--accent);
  transform: translateX(var(--indicator-x, 0px)) scaleX(var(--indicator-sx, 1));
}

.segmented > .tab-indicator {
  border-radius: var(--radius-xs);
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.15);
}

.bottom-nav > .tab-indicator {
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.14);
}

/* Reduced motion (#360): every entrance and exit becomes a plain fade on the shortened tokens;
   pops and presses go. Spinners keep turning (slower, see .spinner). */
@media (prefers-reduced-motion: reduce) {
  .main > *,
  .channel-files,
  .preview-details,
  .side-panel:not(.embedded),
  .modal,
  .popover,
  .emoji-picker,
  .toast,
  .app-banners > *,
  .key-banner,
  .msg.msg-arriving,
  .sb-section ul.is-opening,
  .sheet {
    animation-name: motion-fade-in;
  }

  .sb-section ul.is-closing {
    animation-name: motion-fade-out;
  }

  /* Indicators jump; toasts fade but don't glide or fly (a swipe still follows the finger). */
  .tab-indicator.is-live {
    transition: none;
  }

  .toast,
  .toast.is-swiped {
    transition: opacity var(--dur-exit) var(--ease-exit);
  }

  .motion-ghost.is-leaving,
  .motion-ghost.is-leaving:is(.popover, .emoji-picker, .toast),
  .motion-ghost.is-leaving .modal {
    animation-name: motion-fade-out;
  }

  .reaction.is-popping,
  .badge-count.is-bumped,
  .unread-dot {
    animation: none;
  }

  :is(.sb-item, .sb-section-head, .menu-item, .switcher-row, .activity-item):active:not(:disabled),
  .rail-dest:active .rail-dest-icon {
    transform: none;
  }

  .space-btn::before,
  .sb-section-head .chevron,
  .sb-space-head .chevron {
    transition: none;
  }
}

/* Reduced transparency: no blur, solid surfaces (#360). */
@media (prefers-reduced-transparency: reduce) {
  .round-btn {
    backdrop-filter: none;
    background: var(--call-surface-solid);
  }

  .lightbox-backdrop::before {
    display: none;
  }
}

/* ---- Compact layout (phones, issue #307) ----
   `data-layout` on <html> comes from viewport.rs (below 768px wide, or short and not wide): one
   pane at a time. `.app[data-pane]` says which: the list (Home's DMs or a space's channels), the
   main column, or the side panel over its conversation. The top bar and the bottom navigation
   show on the top-level pages only; deeper pages have a back button in their header. */

.compact-back,
.bottom-nav,
.compact-only {
  display: none;
}

:root[data-layout="compact"] {
  --topbar-h: 52px;
  --touch: 44px;
  --sidebar-w: 100%;
  /* No room to scroll the page itself: everything scrolls inside its pane. */
  overflow: hidden;
  overscroll-behavior: none;
}

:root[data-layout="compact"] body {
  overflow: hidden;
  /* Behind the shell: should any edge of the screen ever be left uncovered (#709), it shows the
     tab bar's colour, not a band of page background. */
  background: var(--chrome);
}

/* The visible part of the window: it ends at the on-screen keyboard (viewport.rs). Without the
   keyboard it is pinned to all four edges, not given a height (#709): in an installed web app iOS
   computes `100dvh` (and `100vh`) shorter than the screen, which left an empty band under the tab
   bar; the edges of the fixed containing block are the screen's in Safari. An installed iOS app
   whose layout viewport is still short gets the screen's height in `--vv-height` (viewport.rs,
   #1222). No `vh` unit here: scripts/check-css.py keeps the shell off them, and the bottom safe
   area is the tab bar's padding alone. */
:root[data-layout="compact"] .app {
  position: fixed;
  top: var(--vv-top, 0px);
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--vv-height, auto);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
  background: var(--chrome);
}

:root[data-layout="compact"] .app > .app-banners {
  grid-row: 1;
}

/* A phone on its side is only about 400px high: a few banners at once (an unanswered notification
   prompt, the owner's roster reminder) would push a conversation's composer off the screen. The
   banners keep a quarter of the height and scroll within it. */
@media (max-height: 500px) {
  :root[data-layout="compact"] .app > .app-banners {
    max-height: 25dvh;
    overflow-y: auto;
    overscroll-behavior: contain;
  }
}

:root[data-layout="compact"] .app > .top-bar {
  grid-row: 2;
  height: var(--topbar-h);
}

:root[data-layout="compact"] .app > .first-sync-row {
  grid-row: 3;
}

:root[data-layout="compact"] .app > .app-body {
  grid-row: 4;
  background: var(--surface);
}

:root[data-layout="compact"] .app > .bottom-nav {
  grid-row: 5;
}

/* Pages without the bottom navigation end above the home indicator. `--vv-short` is how much of the
   screen lies below the layout viewport in an iOS home screen app (viewport.rs): the web view may
   not draw there, so the content ends above it and only the background reaches it. With the keyboard
   up there is no home indicator. */
:root[data-layout="compact"] .app:not(.has-bottom-nav) {
  padding-bottom: max(env(safe-area-inset-bottom), var(--vv-short, 0px));
  background: var(--surface);
}

:root[data-layout="compact"][data-keyboard] .app:not(.has-bottom-nav) {
  padding-bottom: 0;
}

/* Deeper pages have their own header with a back button instead of the top bar. The desktop
   app's own title bar (window controls) always stays. */
:root[data-layout="compact"]:not([data-titlebar="custom"]) .app:not(.has-bottom-nav) > .top-bar {
  display: none;
}

/* The top bar: brand, the search as an icon, nothing else (the account is "You" below). */
:root[data-layout="compact"] .top-bar {
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: var(--space-2);
  padding: 0 var(--space-2) 0 0;
}

:root[data-layout="compact"] .top-bar .brand {
  max-width: none;
}

:root[data-layout="compact"] .top-nav {
  grid-column: 2;
  justify-self: end;
  width: auto;
}

:root[data-layout="compact"] .search-field {
  grid-column: 2;
  justify-self: end;
  width: auto;
  height: var(--touch);
  padding: 0;
  border: 0;
  background: transparent;
}

:root[data-layout="compact"] .search-btn {
  flex: none;
  justify-content: center;
  width: var(--touch);
  height: var(--touch);
  padding: 0;
}

:root[data-layout="compact"] .search-btn > .icon {
  display: block;
}

:root[data-layout="compact"] .search-field-icon,
:root[data-layout="compact"] .search-field-scope,
:root[data-layout="compact"] .search-btn > span,
:root[data-layout="compact"] .search-btn kbd,
:root[data-layout="compact"] .search-btn .shortcut,
:root[data-layout="compact"] .top-actions {
  display: none;
}

/* Panes: exactly one fills the body. */
:root[data-layout="compact"] .app-body > * {
  display: none;
}

:root[data-layout="compact"] .app[data-pane="list"] > .app-body > .sidebar,
:root[data-layout="compact"] .app[data-pane="main"] > .app-body > .main,
:root[data-layout="compact"] .app[data-pane="panel"] > .app-body > .side-panel {
  display: flex;
}

/* A space's list keeps the rail beside it to switch spaces; Home's list stands alone. */
:root[data-layout="compact"] .app[data-pane="list"][data-rail="space"] > .app-body > .space-rail {
  display: flex;
}

:root[data-layout="compact"] .rail-destinations,
:root[data-layout="compact"] .rail-divider {
  display: none;
}

:root[data-layout="compact"] .sidebar {
  flex: 1;
  width: auto;
  min-width: 0;
}

:root[data-layout="compact"] .side-panel,
:root[data-layout="compact"] .side-panel:not(.embedded) {
  position: static;
  flex: 1;
  width: auto;
  max-width: none;
  border-left: 0;
  box-shadow: none;
}

/* Going deeper slides the new page in from the trailing edge; going back slides the parent in from
   the leading edge while the page that is left slides out as a ghost (#368: `data-nav` from app.rs,
   the ghost from motion.rs). Between the bottom navigation's tabs nothing slides. */
:root[data-layout="compact"] .app[data-nav="push"] > .app-body > .main > *,
:root[data-layout="compact"] .app[data-nav="push"] > .app-body > .side-panel {
  animation: pane-push var(--dur-base) var(--ease-emphasized);
}

:root[data-layout="compact"] .app[data-nav="pop"] > .app-body > .main > *,
:root[data-layout="compact"] .app[data-nav="pop"] > .app-body > .sidebar,
:root[data-layout="compact"] .app[data-nav="pop"] > .app-body > .space-rail {
  animation: pane-pop var(--dur-base) var(--ease-emphasized);
}

.motion-ghost.is-leaving.pane-ghost {
  animation: pane-leave var(--dur-exit) var(--ease-exit) forwards;
}

@keyframes pane-push {
  from {
    opacity: 0;
    transform: translateX(24px);
  }
}

@keyframes pane-pop {
  from {
    opacity: 0;
    transform: translateX(-24px);
  }
}

@keyframes pane-leave {
  to {
    opacity: 0;
    transform: translateX(30%);
  }
}

/* Swiping back from the leading edge (components/edge_swipe.rs): the page follows the finger, its
   parent shows underneath and peeks out from -30 % (the component sets their `translate`). */
:root[data-layout="compact"] .app.is-swiping-back > .app-body {
  position: relative;
  overflow: hidden;
}

:root[data-layout="compact"] .app.is-swiping-back > .app-body > *,
:root[data-layout="compact"] .app.is-swiping-back > .app-body > .main > * {
  animation: none;
}

:root[data-layout="compact"] .app.is-swiping-back[data-pane="main"] > .app-body > .main,
:root[data-layout="compact"] .app.is-swiping-back[data-pane="panel"] > .app-body > .side-panel {
  position: absolute;
  inset: 0;
  z-index: 2;
  box-shadow: -8px 0 24px rgba(8, 12, 20, 0.18);
}

:root[data-layout="compact"] .app.is-swiping-back[data-pane="main"] > .app-body > .sidebar,
:root[data-layout="compact"] .app.is-swiping-back[data-pane="main"][data-rail="space"] > .app-body > .space-rail,
:root[data-layout="compact"] .app.is-swiping-back[data-pane="panel"] > .app-body > .main {
  display: flex;
}

/* A sideways touch on a page is the swipe's, not the browser's: pages pan vertically only. What
   scrolls sideways itself (code, tables, tabs, the picture strip) and text input keep their own
   gestures. */
@media (pointer: coarse) {
  :root[data-layout="compact"] .app-body > :is(.main, .side-panel),
  :root[data-layout="compact"] .app-body > :is(.main, .side-panel) :not(:is(pre, .md-code, table, .table-wrap, .bookmarks-bar, .filmstrip, .section-tabs, .view-tabs, .composer, .sheet, input, textarea, [contenteditable]), :is(pre, .md-code, table, .table-wrap, .bookmarks-bar, .filmstrip, .section-tabs, .view-tabs, .composer, .sheet, [contenteditable]) *) {
    touch-action: pan-y pinch-zoom;
  }
}

:root[data-layout="compact"] .app.is-swipe-settling > .app-body > * {
  transition: translate var(--dur-base) var(--ease-emphasized);
}

@media (prefers-reduced-motion: reduce) {
  :root[data-layout="compact"] .app[data-nav] > .app-body > .main > *,
  :root[data-layout="compact"] .app[data-nav] > .app-body > :is(.side-panel, .sidebar, .space-rail) {
    animation-name: motion-fade-in;
  }

  .motion-ghost.is-leaving.pane-ghost {
    animation-name: motion-fade-out;
  }
}

:root[data-layout="compact"] .compact-back,
:root[data-layout="compact"] .compact-only {
  display: inline-grid;
}

/* The bottom navigation: up to five tabs (iOS tab bar), each a full-height touch target. */
:root[data-layout="compact"] .bottom-nav {
  position: relative;
  isolation: isolate;
  display: flex;
  padding-bottom: max(env(safe-area-inset-bottom), var(--vv-short, 0px));
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: var(--chrome);
}

.bottom-nav-tab {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 56px;
  padding: 6px 0 4px;
  border: 0;
  background: transparent;
  color: var(--chrome-text);
  font-size: var(--text-2xs);
  letter-spacing: var(--tracking-2xs);
  font-weight: var(--weight-semibold);
  -webkit-tap-highlight-color: transparent;
}

.bottom-nav-icon {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 30px;
  border-radius: var(--radius-pill);
}

.bottom-nav-tab.current {
  color: var(--chrome-strong);
}

.bottom-nav-label {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bottom-nav .badge-count {
  position: absolute;
  right: 6px;
  top: -4px;
  box-shadow: 0 0 0 2px var(--chrome);
}

/* Headers: the back button first, everything sized for a finger. */
:root[data-layout="compact"] .channel-header .header-row:not(.header-row-tabs),
:root[data-layout="compact"] .panel-header {
  gap: var(--space-1);
  min-height: var(--topbar-h);
  height: auto;
  padding: 0 var(--space-1) 0 var(--space-1);
}

:root[data-layout="compact"] .channel-header .header-main > :not(.header-identity):not(.compact-back),
:root[data-layout="compact"] .channel-header .header-actions > .header-btn:not(.compact-keep) {
  display: none;
}

:root[data-layout="compact"] .header-title {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Touch targets follow the pointer, not the layout (#364): 44px wherever a finger is the pointer,
   on a phone as on a tablet or a touch laptop in the wide layout. Small controls that sit in rows
   (reactions, a toast's close) get 32px and at least 8px between them. A mouse keeps its sizes. */
@media (pointer: coarse) {
  :root {
    --touch: 44px;
    /* Controls in dialogs (#706) grow to the touch size too. */
    --control-h: var(--touch);
  }

  .icon-btn,
  .header-btn,
  .format-btn,
  .media-tool,
  .send-btn {
    min-width: var(--touch);
    min-height: var(--touch);
  }

  .sb-item,
  .switcher-row,
  .menu-item,
  .home-chip,
  .btn {
    min-height: var(--touch);
  }

  .space-btn {
    width: var(--touch);
    height: var(--touch);
  }

  .icon-btn-small {
    min-width: 32px;
    min-height: 32px;
  }

  .reactions {
    gap: var(--space-2);
  }

  .reaction {
    min-height: 32px;
    padding: 0 10px;
  }

  .segmented button {
    min-height: 36px;
  }
}

:root[data-layout="compact"] .space-rail {
  width: 64px;
}

/* The composer: wide send button, no keyboard hints, room for the home indicator. */
:root[data-layout="compact"] .composer {
  padding: 0 var(--space-2) var(--space-2);
}

:root[data-layout="compact"] .composer-hint:not(.also-send),
:root[data-layout="compact"] .markdown-hint {
  display: none;
}

:root[data-layout="compact"] .composer-toolbar {
  gap: 0;
}

:root[data-layout="compact"] .composer-toolbar .also-send {
  flex: 1;
  min-width: 0;
}

:root[data-layout="compact"] .send-group .send-btn {
  width: var(--touch);
  height: var(--touch);
}

:root[data-layout="compact"] .send-menu-btn {
  width: 28px;
  height: var(--touch);
}

/* Phones (#662): send is the composer's main target, half again as wide as a touch target; same
   height, and the options button keeps its size. A desktop window as narrow as a phone has a fine
   pointer and keeps the square button. On the narrowest phones it gives way down to the touch
   target instead of pushing the toolbar off the screen. */
@media (pointer: coarse) {
  :root[data-layout="compact"] .send-group {
    min-width: 0;
  }

  :root[data-layout="compact"] .send-menu-btn {
    flex-shrink: 0;
  }

  :root[data-layout="compact"] .send-group .send-btn {
    width: calc(var(--touch) * 1.5);
  }
}

/* iOS zooms into fields with text under 16px and doesn't zoom back out: the conversation then looks
   wider than the screen, its lines and the composer cut off at the right edge. The composer is a
   contenteditable, not a textarea, so it is listed too. On a touch screen the wide layout (a
   tablet) gets the same. */
:root[data-layout="compact"] :is(input, textarea, select, [contenteditable]) {
  font-size: max(16px, 1em);
}

@media (pointer: coarse) {
  :root :is(input, textarea, select, [contenteditable]) {
    font-size: max(16px, 1em);
  }
}

/* Messages on a touch screen (#364): a tap does nothing, a long press opens the action sheet. The
   row tints from the first touch, so the press is felt before the sheet comes; a tap's focus
   doesn't leave the row tinted. */
@media (hover: none) {
  .msg-user {
    -webkit-touch-callout: none;
  }

  .msg-user:focus:not(:focus-visible):not(.msg-active):not(.is-pressing):not(.msg-highlight),
  .msg-user:focus-within:not(:has(:focus-visible)):not(.msg-active):not(.is-pressing):not(.msg-highlight) {
    background: transparent;
  }

  .msg-user:focus:not(:focus-visible):not(.msg-active):not(.is-pressing) .hover-time {
    visibility: hidden;
  }
}

.msg-user.is-pressing {
  background: var(--surface-2);
}

/* Dialogs on a phone (#706) are bottom sheets that leave what opened them visible above; the big
   ones (settings, the meeting form, file preview, the search, the lightbox) fill the screen. The
   backdrop is the visual viewport, so a sheet with a field rides on top of the keyboard; without
   the keyboard it is pinned to the edges like the shell (#709). */
:root[data-layout="compact"] .modal-backdrop {
  inset: var(--vv-top, 0px) 0 0;
  height: var(--vv-height, auto);
  align-items: flex-end;
  padding: 0;
}

:root[data-layout="compact"] .modal {
  width: 100%;
  max-width: none;
  max-height: calc(100% - max(env(safe-area-inset-top), var(--space-3)) - var(--space-8));
  padding: 0 env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  border-radius: var(--dialog-radius) var(--dialog-radius) 0 0;
}

:root[data-layout="compact"] .modal:is(.set-modal, .modal-settings, .modal-wide, .file-preview, .modal-switcher, .modal-lightbox) {
  height: 100%;
  max-height: none;
  padding-top: env(safe-area-inset-top);
  border-radius: 0;
  box-shadow: none;
}

/* A sheet's actions share its width (the longer label takes more) and grow to a thumb's size. */
:root[data-layout="compact"] .modal-foot .btn {
  flex: 1 1 auto;
  min-height: 3rem;
  white-space: nowrap;
}

:root[data-layout="compact"] .modal-foot > .grow {
  display: none;
}

/* They rise as sheets and fall back out (the lightbox fades, the switcher doesn't move). A sheet
   travels further than a centred dialog, so it takes the slower duration. */
:root[data-layout="compact"] .modal:not(.modal-switcher, .modal-lightbox) {
  animation-name: sheet-in;
  animation-duration: var(--dur-slow);
}

:root[data-layout="compact"] .motion-ghost.is-leaving .modal:not(.modal-lightbox) {
  animation-name: sheet-out;
}

/* The crop dialog opens over another sheet and comes up the same way. */
:root[data-layout="compact"] .crop-backdrop {
  align-items: flex-end;
  padding: 0;
}

/* Popovers that stay popovers on a phone (the lightbox's menus) dim what is behind them. */
:root[data-layout="compact"] .popover-backdrop {
  background: rgba(8, 12, 20, 0.45);
}

:root[data-layout="compact"] .modal-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
}

:root[data-layout="compact"] .switcher-results {
  flex: 1;
  max-height: none;
}

:root[data-layout="compact"] .switcher-foot {
  display: none;
}

@media (prefers-reduced-motion: reduce) {
  :root[data-layout="compact"] .modal:not(.modal-switcher, .modal-lightbox),
  .sheet {
    animation-name: motion-fade-in;
  }

  :root[data-layout="compact"] .motion-ghost.is-leaving .modal:not(.modal-lightbox),
  .motion-ghost.is-leaving.sheet {
    animation-name: motion-fade-out;
  }

  .sheet {
    transition: none;
  }
}

/* Nothing scrolls sideways: long words, code and tables wrap or scroll inside themselves. */
:root[data-layout="compact"] .msg-body,
:root[data-layout="compact"] .rich-text {
  overflow-wrap: anywhere;
}

:root[data-layout="compact"] .rich-text pre,
:root[data-layout="compact"] .rich-text table {
  max-width: 100%;
  overflow-x: auto;
}

/* On a phone notices come from the top edge, as the system's banners do (#367): at the bottom they
   would cover the composer in a conversation and the bottom navigation elsewhere. */
:root[data-layout="compact"] .toasts {
  top: calc(var(--space-2) + env(safe-area-inset-top));
  bottom: auto;
  left: var(--space-2);
  right: var(--space-2);
}

/* The exit is the motion module's (.motion-ghost.is-leaving). */
:root[data-layout="compact"] .toast:not(.is-leaving) {
  animation-name: motion-toast-in-top;
}

@keyframes motion-toast-in-top {
  from {
    opacity: 0;
    transform: translateY(-12px) scale(0.98);
  }
}

:root[data-layout="compact"] .main,
:root[data-layout="compact"] .side-panel {
  min-width: 0;
}

.conversation-more {
  position: relative;
}

.conversation-menu {
  width: min(280px, calc(100vw - var(--space-4)));
}

/* The header's bell: the menu hangs from it; a muted conversation shows it dimmed. On a phone the
   "…" menu has the mute toggle instead. */
.conversation-bell {
  position: relative;
}

.conversation-bell > .header-btn.is-muted {
  opacity: 0.6;
}

:root[data-layout="compact"] .conversation-bell {
  display: none;
}

:root[data-layout="compact"] .switcher-input {
  padding: 0 var(--space-2) 0 var(--space-1);
}

:root[data-layout="compact"] .switcher-search-icon {
  display: none;
}

/* A phone in landscape: little height, so the bars get slimmer and the tabs lose their labels. */
@media (max-height: 499.98px) {
  :root[data-layout="compact"] {
    --topbar-h: 44px;
  }

  :root[data-layout="compact"] .bottom-nav-tab {
    min-height: var(--touch);
    padding: 2px 0;
  }

  :root[data-layout="compact"] .bottom-nav-label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
  }
}

/* The administration console: its side navigation becomes a strip of tabs that scrolls sideways
   on its own, above the content. */
:root[data-layout="compact"] .admin {
  flex-direction: column;
  min-height: 0;
  flex: 1;
}

:root[data-layout="compact"] .admin-nav,
:root[data-layout="compact"] .admin-nav ul {
  flex-direction: row;
  align-items: center;
}

:root[data-layout="compact"] .admin-nav {
  width: auto;
  padding: var(--space-1) var(--space-2);
  overflow-x: auto;
  border-right: 0;
  border-bottom: 1px solid var(--border);
  scrollbar-width: none;
}

:root[data-layout="compact"] .admin-nav ul {
  display: flex;
  gap: 2px;
}

:root[data-layout="compact"] .admin-nav h1 {
  display: none;
}

:root[data-layout="compact"] .admin-nav-item,
:root[data-layout="compact"] .admin-back {
  flex: none;
  width: auto;
  height: auto;
  min-height: var(--touch);
  white-space: nowrap;
}

:root[data-layout="compact"] .admin-content {
  flex: 1;
  min-height: 0;
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
}

/* The search page: saved searches and mentions stay on wider screens; the search itself fills the
   window with a back button in its field. */
:root[data-layout="compact"] .search-side {
  display: none;
}

:root[data-layout="compact"] .search-main {
  padding: var(--space-2) var(--space-3);
}

/* A short notice stays a card, also on phones. */
.modal-notice {
  width: min(440px, 100%);
}

:root[data-layout="compact"] .modal-backdrop:has(.modal-notice) {
  align-items: center;
  padding: var(--space-4);
}

:root[data-layout="compact"] .modal.modal-notice {
  max-height: 100%;
  padding: 0;
  border-radius: var(--dialog-radius);
}

/* A card in the middle appears like a dialog, not like a sheet from the bottom edge. */
@media (prefers-reduced-motion: no-preference) {
  :root[data-layout="compact"] .modal.modal-notice {
    animation-name: motion-dialog-in;
    animation-duration: var(--dur-base);
  }

  :root[data-layout="compact"] .motion-ghost.is-leaving .modal.modal-notice {
    animation-name: motion-dialog-out;
  }
}

/* Previews of linked messages (#319). */
.linked-message {
  flex-direction: column;
  gap: 2px;
}

.linked-unavailable .icon {
  flex: none;
  width: 14px;
  height: 14px;
}

.linked-unavailable,
.linked-deleted,
.linked-not-loaded {
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  border-inline-start-color: var(--border);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.linked-unavailable {
  flex-wrap: nowrap;
}

.linked-head {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.linked-author {
  font-weight: var(--weight-bold);
}

.linked-time,
.linked-source {
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.linked-body {
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
  overflow: hidden;
}

.linked-body .md-p {
  margin: 0;
}

.linked-files {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.linked-file {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  max-width: 14rem;
  padding: 2px 6px;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.linked-file img {
  width: 24px;
  height: 24px;
  border-radius: 3px;
  object-fit: cover;
}

.linked-file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.linked-jump {
  align-self: flex-start;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

/* ---- Increase contrast and forced colours (issues #361, #362) ---- */

/* "Increase contrast": edges and secondary text take the strong values. Listed with the dark
   selectors so it also wins over the dark blocks above. */
@media (prefers-contrast: more) {
  :root,
  :root:not([data-theme="light"]) {
    --border: var(--border-strong);
    --text-muted: var(--text);
    /* Muted channels keep only their bell-off icon. */
    --sb-dim: var(--sb-muted);
  }
}

/* Windows High Contrast and other forced palettes drop every box-shadow and background image, so
   rings are outlines (above) and the few things drawn only with fills get a system colour. */
@media (forced-colors: active) {
  :focus-visible {
    outline-color: Highlight;
  }

  .badge-count,
  .unread-dot {
    forced-color-adjust: none;
  }

  /* The switch is drawn from fills only: draw it in system colours ourselves. */
  .switch-row input[role="switch"],
  .switch-row input[role="switch"]::after {
    forced-color-adjust: none;
  }

  .switch-row input[role="switch"] {
    border: 1px solid CanvasText;
    background: Canvas;
  }

  .switch-row input[role="switch"]::after {
    top: 1px;
    left: 1px;
    background: CanvasText;
  }

  .switch-row input[role="switch"]:checked {
    border-color: Highlight;
    background: Highlight;
  }

  .switch-row input[role="switch"]:checked::after {
    background: HighlightText;
  }
}

/* Compact toasts come from the top, so they leave upwards; reduced motion only fades (#359, #364). */
:root[data-layout="compact"] .motion-ghost.is-leaving.toast { animation-name: motion-toast-out-top; }
@keyframes motion-toast-out-top { to { opacity: 0; transform: translateY(-8px) scale(0.98); } }
@media (prefers-reduced-motion: reduce) {
  :root[data-layout="compact"] .toast:not(.is-leaving) { animation-name: motion-fade-in; }
  :root[data-layout="compact"] .motion-ghost.is-leaving.toast { animation-name: motion-fade-out; }
}

/* ==========================================================================================
   User settings (#327): a section list with search on the left, the section on the right; on
   phones the list is a page of its own. Sections are cards of rows: label and hint on the left,
   the control on the right. Everything here is scoped to `.set-*`.
   ========================================================================================== */

.set-modal {
  /* How long a row found by the search stays highlighted; FOUND_HIGHLIGHT in settings_modal.rs. */
  --set-found-dur: 1600ms;
  /* The theme tiles draw each theme as it looks, whatever theme is active. */
  --tile-light-bg: #f5f5f5;
  --tile-dark-bg: #1e1e1e;
  --tile-mid: #a0a0a0;
  --set-nav-w: 236px;
  --set-row-min-h: 52px;
  --set-switch-w: 40px;
  --set-switch-h: 24px;
  --set-switch-off: color-mix(in srgb, var(--text-muted) 45%, var(--surface-3));
  width: min(920px, 100%);
  height: min(720px, 86vh);
  max-height: none;
}

.set-shell {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* The section list. */
.set-nav {
  flex: none;
  width: var(--set-nav-w);
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--border);
  background: var(--surface-2);
}

.set-nav-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  padding: var(--space-4) var(--space-4) var(--space-2);
}

.set-nav-head h2 {
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
}

/* Wide layouts close from the section's header; the list has its own close only on phones. */
.set-nav-close,
.set-back {
  display: none;
}

.set-search {
  position: relative;
  padding: 0 var(--space-3) var(--space-2);
}

.set-search .input {
  width: 100%;
  padding-left: 32px;
  border-radius: var(--radius);
  background: var(--surface);
}

.set-search-icon {
  position: absolute;
  top: 50%;
  left: calc(var(--space-3) + 9px);
  width: 16px;
  height: 16px;
  color: var(--text-muted);
  transform: translateY(calc(-50% - var(--space-1)));
  pointer-events: none;
}

.set-nav-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 var(--space-2) var(--space-3);
}

.set-sections {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.set-section {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 38px;
  padding: var(--space-1) var(--space-2);
  border: 0;
  border-radius: var(--radius);
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background-color var(--dur-fast) var(--ease-standard);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.set-section:active {
  background: var(--surface-3);
}

.set-section[aria-current="page"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.set-section-icon {
  --set-hue: var(--accent);
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--set-hue) 15%, transparent);
  color: var(--set-hue);
}

.set-section-icon svg {
  width: 16px;
  height: 16px;
}

.set-section-icon.is-appearance { --set-hue: var(--away); }
.set-section-icon.is-notifications { --set-hue: var(--dnd); }
.set-section-icon.is-preferences { --set-hue: var(--text-muted); }
.set-section-icon.is-keyboard { --set-hue: var(--text-muted); }
.set-section-icon.is-audio-video { --set-hue: var(--online); }
.set-section-icon.is-devices { --set-hue: var(--lvl-info); }
.set-section-icon.is-security { --set-hue: var(--accent-strong); }
.set-section-icon.is-about { --set-hue: var(--lvl-info); }

.set-section-name {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  overflow-wrap: anywhere;
}

.set-section-name small {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 400;
}

.set-section-chevron {
  display: none;
  color: var(--text-muted);
}

/* The section. */
.set-page {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.set-page-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-3) var(--space-6);
  border-bottom: 1px solid var(--border);
}

.set-page-head h2 {
  flex: 1;
  min-width: 0;
  font-size: var(--text-xl);
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}

.set-page-body {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--space-5) var(--space-6) var(--space-8);
  scroll-padding-top: var(--space-4);
}

.set-page-body > * + * {
  margin-top: var(--space-5);
}

/* Cards and rows. */
.set-card {
  min-width: 0;
}

.set-card-title {
  margin: 0 0 var(--space-2) var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.set-card-hint {
  margin: calc(-1 * var(--space-1)) 0 var(--space-2) var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.set-rows,
.set-card > .set-row,
.set-about {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  overflow: hidden;
}

.set-about {
  padding: var(--space-1) var(--space-4) var(--space-4);
}

/* What a card holds besides rows gets the rows' inner spacing. */
.set-rows > .set-themes,
.set-rows > .set-card-actions,
.set-rows > .set-progress,
.set-rows > .set-empty,
.set-rows > .set-note,
.set-rows > p,
.set-rows > .effect-grid {
  margin: 0;
  padding: var(--space-3) var(--space-4);
}

.set-rows > .set-themes {
  padding: var(--space-4);
}

.set-rows > .set-subform {
  border: 0;
  border-radius: 0;
}

.set-row {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  min-height: var(--set-row-min-h);
  padding: var(--space-3) var(--space-4);
  scroll-margin: var(--space-6);
  transition: background-color var(--dur-slow) var(--ease-standard);
}

.set-rows > * + * {
  border-top: 1px solid var(--border);
}

.set-row.is-stacked {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-2);
}

.set-row.is-field {
  flex-direction: column;
  align-items: stretch;
  gap: var(--space-1);
}

.set-row.is-switch {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.set-row.is-disabled {
  cursor: default;
}

.set-row.is-disabled .set-row-text {
  opacity: 0.55;
}

.set-inline {
  display: inline-flex;
  scroll-margin: var(--space-6);
}

.set-modal .is-found {
  animation: set-found var(--set-found-dur) var(--ease-standard);
}

@keyframes set-found {
  0%,
  40% {
    background: var(--accent-soft);
  }
}

.set-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.set-row-label {
  color: var(--text);
  font-size: var(--text-base);
  font-weight: 500;
  overflow-wrap: anywhere;
}

.set-row-hint {
  color: var(--text-muted);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.set-row-control {
  flex: none;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  max-width: 100%;
}

.set-row.is-stacked .set-row-control {
  flex-direction: column;
  align-items: stretch;
}

.set-select {
  flex: none;
  width: auto;
  max-width: min(260px, 45%);
  min-width: 140px;
}

/* The message sound and its preview, side by side: the button next to what it plays. */
.set-sound-picker {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.set-sound-picker .set-select {
  max-width: 220px;
}

/* Nothing to play (the system's sound, none): the button says so by fading back. */
.set-sound-picker .btn:disabled {
  opacity: 0.45;
}

/* The switch: the thumb slides, the track fills; both follow the reduced-motion durations. */
.set-switch {
  appearance: none;
  flex: none;
  position: relative;
  width: var(--set-switch-w);
  height: var(--set-switch-h);
  margin: 0;
  border-radius: var(--radius-pill);
  background: var(--set-switch-off);
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-standard);
}

.set-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: calc(var(--set-switch-h) - 4px);
  height: calc(var(--set-switch-h) - 4px);
  border-radius: 50%;
  background: var(--surface);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.3);
  transition: transform var(--dur-base) var(--ease-emphasized);
}

.set-switch:checked {
  background: var(--accent);
}

.set-switch:checked::after {
  transform: translateX(calc(var(--set-switch-w) - var(--set-switch-h)));
}

.set-switch:active::after {
  width: calc(var(--set-switch-h) + 2px);
}

.set-switch:checked:active::after {
  transform: translateX(calc(var(--set-switch-w) - var(--set-switch-h) - 6px));
}

.set-switch:disabled {
  cursor: default;
  opacity: 0.5;
}

.set-switch:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Two or three choices side by side. */
.set-segmented {
  flex: none;
  display: inline-flex;
  gap: 2px;
  padding: 2px;
  border-radius: var(--radius);
  background: var(--surface-2);
}

.set-segment {
  position: relative;
}

.set-segment input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.set-segment span {
  display: block;
  padding: 5px var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  transition: background-color var(--dur-fast) var(--ease-standard), color var(--dur-fast) var(--ease-standard);
}

.set-segment input:checked + span {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
}

.set-segment input:focus-visible + span {
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

.set-choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.set-choice {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.set-choice input {
  accent-color: var(--accent);
}

.set-note,
.set-empty {
  margin: var(--space-2) var(--space-1) 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.set-empty {
  padding: var(--space-3) var(--space-4);
}

.set-card-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-3) 0 0;
}

.set-card > .set-card-actions {
  padding-left: var(--space-1);
}

.set-modal .btn-danger-quiet {
  color: var(--danger);
}

.set-badge {
  display: inline-block;
  margin-left: var(--space-2);
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--text-xs);
  font-weight: 600;
  vertical-align: 1px;
}

/* Account: the profile header. */
.set-profile {
  display: flex;
  align-items: center;
  gap: var(--space-5);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.set-profile-avatar .avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  font-size: var(--text-2xl);
}

.set-profile-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.set-profile-name {
  font-size: var(--text-2xl);
  letter-spacing: -0.015em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.set-profile-handle {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  color: var(--text-muted);
}

.set-profile-handle .mono {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-profile-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.set-name-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  margin-top: var(--space-1);
}

.set-modal form.set-form,
.set-modal form.set-subform {
  display: flex;
  flex-direction: column;
}

.set-form {
  gap: var(--space-5);
}

.set-form-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-3);
}

.set-saved {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  color: var(--online);
  font-size: var(--text-sm);
  font-weight: 500;
}

.set-saved svg {
  width: 16px;
  height: 16px;
}

.set-hours {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

/* Weekdays as toggle chips. */
.set-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
}

.set-chip {
  min-width: 44px;
  height: 32px;
  padding: 0 var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-pill);
  background: var(--surface);
  color: var(--text);
  font-size: var(--text-sm);
  transition: background-color var(--dur-fast) var(--ease-standard), border-color var(--dur-fast) var(--ease-standard);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.set-chip[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 600;
}

.set-chip:active {
  transform: scale(var(--press-scale));
}

.set-inline-form {
  display: flex;
  gap: var(--space-2);
}

/* Do not disturb ranges. */
.set-ranges {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.set-range {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border-radius: var(--radius);
  background: var(--surface-2);
}

.set-range-times {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.set-range-times .input {
  width: auto;
}

.set-range-times .icon-btn {
  margin-left: auto;
}

/* Per-conversation levels. */
.set-conversations {
  max-height: 320px;
  margin: 0;
  padding: 0;
  overflow-y: auto;
  list-style: none;
}

.set-conversation {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  border-top: 1px solid var(--border);
}

.set-conversation-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.set-conversation .set-select {
  min-width: 0;
  max-width: 34%;
}

/* Devices and people. */
.set-devices {
  margin: 0;
  padding: 0;
  list-style: none;
}

.set-devices > li + li {
  border-top: 1px solid var(--border);
}

.set-rows > .set-devices:empty {
  display: none;
}

.set-device {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
}

.set-device.is-current {
  background: color-mix(in srgb, var(--accent-soft) 55%, var(--surface));
}

.set-device-icon {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: var(--text-muted);
}

.set-device.is-current .set-device-icon {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.set-device-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.set-device-name {
  font-weight: 500;
  overflow-wrap: anywhere;
}

/* Devices: what this device verified, the push state and the actions (issue #409). */
.set-device-check {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  line-height: 1.4;
}

.set-device-check svg {
  flex: none;
  width: 14px;
  height: 14px;
}

.set-device-check.is-verified {
  color: var(--accent-strong);
}

.set-device-check.is-pending {
  color: var(--text-muted);
}

.set-device-check.is-unverified {
  color: var(--danger);
  font-weight: 500;
}

.set-device-test.is-warn {
  color: var(--warn-text);
}

.set-device-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: var(--space-2);
}

.set-device-rename {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  width: 100%;
  animation: motion-fade-in var(--dur-fast) var(--ease-standard);
}

.set-device-rename .input {
  flex: 1 1 14rem;
  min-width: 0;
}

/* Security: the key backup in plain words (issue #410). */
.set-backup {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--border);
}

.set-backup-icon {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-2);
}

.set-backup.is-ok .set-backup-icon {
  color: var(--online);
  background: color-mix(in srgb, var(--online) 12%, var(--surface));
}

.set-backup.is-warn .set-backup-icon {
  color: var(--away);
  background: color-mix(in srgb, var(--away) 14%, var(--surface));
}

/* Help & about: the instance's links. */
.set-links {
  margin: 0;
  padding: 0;
  list-style: none;
}

.set-links > li + li {
  border-top: 1px solid var(--border);
}

.set-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  color: var(--text);
  text-decoration: none;
}

.set-link:hover,
.set-link:focus-visible {
  background: var(--surface-2);
}

.set-link svg {
  flex: none;
  width: 16px;
  height: 16px;
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  .set-device-rename {
    animation: none;
  }
}

/* An inline confirm step for destructive actions. */
.set-confirm {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  width: 100%;
  padding: var(--space-3);
  border: 1px solid color-mix(in srgb, var(--danger) 35%, var(--border));
  border-radius: var(--radius);
  background: var(--danger-soft);
  animation: motion-fade-in var(--dur-fast) var(--ease-standard);
}

.set-confirm p {
  margin: 0;
  font-size: var(--text-sm);
}

.set-confirm-actions {
  display: flex;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Security: the state in plain words. */
.set-status {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.set-status.is-ok {
  border-color: color-mix(in srgb, var(--online) 40%, var(--border));
  background: color-mix(in srgb, var(--online) 8%, var(--surface));
}

.set-status.is-warn {
  border-color: color-mix(in srgb, var(--away) 50%, var(--border));
  background: color-mix(in srgb, var(--away) 10%, var(--surface));
}

.set-status-icon {
  flex: none;
  display: inline-grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--surface);
  color: var(--online);
}

.set-status.is-warn .set-status-icon {
  color: var(--away);
}

.set-status-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.set-status-text span {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.set-progress {
  margin: 0 0 var(--space-2) var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.set-subform {
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4) var(--space-4);
  border: 1px solid var(--border);
  border-top: 0;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  background: var(--surface);
}

.set-details > summary {
  width: max-content;
  padding: var(--space-1) var(--space-1);
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-weight: 500;
  cursor: pointer;
}

.set-details[open] > summary {
  margin-bottom: var(--space-3);
}

/* Appearance: theme tiles. */
.set-themes {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--space-3);
}

.set-theme {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.set-theme-preview {
  --tile-bg: var(--tile-light-bg);
  --tile-rail: #111926;
  --tile-side: #eff0f1;
  --tile-line: #dddddd;
  --tile-strong: #566175;
  --tile-bubble: #dff3f1;
  display: flex;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  border: 2px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--tile-bg);
  transition: border-color var(--dur-fast) var(--ease-standard), transform var(--dur-fast) var(--ease-standard);
}

.set-theme-preview.is-dark {
  --tile-bg: var(--tile-dark-bg);
  --tile-rail: #101010;
  --tile-side: #141414;
  --tile-line: #363636;
  --tile-strong: var(--tile-mid);
  --tile-bubble: #123a38;
}

.set-theme-preview.is-system {
  background: linear-gradient(135deg, var(--tile-light-bg) 50%, var(--tile-dark-bg) 50%);
}

/* The rail in the chrome colour, then the sidebar: light in light mode, dark in dark mode. */
.set-theme-rail {
  flex: none;
  width: 22%;
  background: linear-gradient(90deg, var(--tile-rail) 0 32%, var(--tile-side) 32%);
}

.set-theme-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8%;
  padding: 10% 9%;
}

.set-theme-line {
  height: 7%;
  min-height: 4px;
  border-radius: var(--radius-pill);
  background: var(--tile-line);
}

.set-theme-line.is-strong {
  width: 45%;
  background: var(--tile-strong);
}

.set-theme-line.is-short {
  width: 60%;
}

.set-theme-bubble {
  width: 55%;
  height: 22%;
  margin-top: auto;
  border-radius: var(--radius-sm);
  background: var(--tile-bubble);
}

.set-theme-preview.is-system .set-theme-line,
.set-theme-preview.is-system .set-theme-bubble {
  background: color-mix(in srgb, var(--tile-mid) 55%, transparent);
}

.set-theme:active .set-theme-preview {
  transform: scale(var(--press-scale));
}

.set-theme.is-chosen .set-theme-preview {
  border-color: var(--accent);
}

.set-theme input:focus-visible + .set-theme-preview {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.set-theme-name {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-size: var(--text-sm);
  font-weight: 500;
}

.set-theme-check {
  display: none;
  color: var(--accent);
}

.set-theme-check svg {
  width: 14px;
  height: 14px;
}

.set-theme.is-chosen .set-theme-check {
  display: inline-flex;
}

/* Appearance: colour themes (#202). Each swatch draws a tiny sidebar in the theme's colours of the
   current light/dark mode: a selected row, two name lines, the presence dot and a badge. The
   colours come in as custom properties (CSSOM, CSP-safe). */
.set-swatches {
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.set-swatch-group {
  margin: var(--space-4) 0 var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-xs);
}

.set-swatch-row {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: var(--space-3);
}

.set-swatch {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.set-swatch-tile {
  --sw-chrome: var(--chrome);
  --sw-nav: var(--sb-bg);
  --sw-sel: var(--sb-current);
  --sw-dot: var(--online);
  --sw-badge: var(--badge-bg);
  --sw-text: var(--sb-muted);
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  aspect-ratio: 16 / 10;
  padding: 10px 9px 10px 21px;
  overflow: hidden;
  border-radius: var(--radius-md);
  /* The rail's strip in the chrome colour, then the sidebar, as the theme paints them. */
  background: linear-gradient(90deg, var(--sw-chrome) 0 12px, var(--sw-nav) 12px);
  box-shadow: inset 0 0 0 1px var(--border);
  transition: transform var(--dur-fast) var(--ease-standard);
}

.set-swatch-line {
  width: 70%;
  height: 5px;
  border-radius: var(--radius-pill);
  background: var(--sw-text);
}

.set-swatch-line.is-short {
  width: 45%;
}

.set-swatch-sel {
  height: 9px;
  border-radius: 3px;
  background: var(--sw-sel);
}

.set-swatch-dot,
.set-swatch-badge {
  position: absolute;
  bottom: 9px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.set-swatch-dot {
  left: 21px;
  background: var(--sw-dot);
}

.set-swatch-badge {
  right: 9px;
  width: 15px;
  border-radius: var(--radius-pill);
  background: var(--sw-badge);
}

.set-swatch:active .set-swatch-tile {
  transform: scale(var(--press-scale));
}

.set-swatch.is-chosen .set-swatch-tile {
  box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent);
}

.set-swatch input:focus-visible + .set-swatch-tile {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: 5px;
}

/* Two lines at most: "Server default" and longer translations wrap instead of being cut. */
.set-swatch-name {
  display: -webkit-box;
  overflow: hidden;
  font-size: var(--text-sm);
  line-height: var(--leading-sm);
  text-align: center;
  text-wrap: balance;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.set-swatch.is-chosen .set-swatch-name {
  font-weight: var(--weight-semibold);
}

.set-custom-theme {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4) var(--space-4);
}

.set-custom-colors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--space-3) var(--space-4);
}

.set-color-picker {
  flex: none;
  width: var(--control-h);
  height: var(--control-h);
  padding: 0;
  border: 1px solid var(--border-strong);
  border-radius: var(--control-radius);
  background: none;
  cursor: pointer;
}

.set-color-hex {
  font-family: var(--font-mono);
}

.set-custom-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

@media (max-width: 560px) {
  .set-custom-colors {
    grid-template-columns: minmax(0, 1fr);
  }
}

/* Appearance: a message drawn with the chosen density and image size; the text size scales it
   with the rest of the app. */
.set-preview {
  padding: var(--space-4);
  background: var(--bg);
  font-size: var(--text-base);
}

.set-preview-msg {
  display: flex;
  gap: var(--space-3);
}

.set-preview-msg + .set-preview-msg {
  margin-top: var(--space-3);
}

.set-preview-avatar {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: var(--radius);
  background: color-mix(in srgb, var(--accent) 55%, var(--surface-3));
}

.set-preview[data-density="comfortable"] .set-preview-text {
  font-size: var(--text-lg);
  line-height: 1.6;
}

.set-preview[data-density="comfortable"] .set-preview-msg + .set-preview-msg {
  margin-top: var(--space-4);
}

.set-preview[data-density="compact"] {
  padding: var(--space-2) var(--space-4);
}

.set-preview[data-density="compact"] .set-preview-msg {
  gap: var(--space-2);
}

.set-preview[data-density="compact"] .set-preview-msg + .set-preview-msg {
  margin-top: var(--space-1);
}

.set-preview[data-density="bubbles"] .set-preview-msg {
  gap: var(--space-2);
}

.set-preview[data-density="bubbles"] .set-preview-msg + .set-preview-msg {
  margin-top: var(--space-1);
}

.set-preview[data-density="bubbles"] .set-preview-msg.is-own {
  justify-content: flex-end;
}

.set-preview[data-density="bubbles"] .set-preview-msg.is-own .set-preview-body {
  flex: 0 1 auto;
}

.set-preview[data-density="bubbles"] .set-preview-body {
  flex: 0 1 auto;
  max-width: 70%;
  padding: 6px 12px;
  border-radius: 18px;
  background: var(--surface-2);
}

.set-preview[data-density="bubbles"] .is-own .set-preview-body {
  background: var(--accent-soft);
}

.set-preview[data-density="bubbles"] .is-own .set-preview-head strong,
.set-preview[data-density="bubbles"] .set-preview-avatar {
  display: none;
}

.set-preview[data-density="compact"] .set-preview-avatar {
  width: 30px;
  height: 30px;
}

.set-preview-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.set-preview-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.set-preview-time {
  color: var(--text-muted);
  font-size: var(--text-xs);
}

.set-preview-text {
  margin: 0;
  line-height: 1.45;
}

.set-preview-image {
  width: min(120px, 60%);
  aspect-ratio: 4 / 3;
  margin-top: var(--space-1);
  border-radius: var(--radius);
  background: linear-gradient(160deg, color-mix(in srgb, var(--accent) 30%, var(--surface-3)), var(--surface-3));
}

.set-preview.is-large-image .set-preview-image {
  width: min(200px, 100%);
}

/* The text size slider. */
.set-slider {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.set-slider input[type="range"] {
  width: 160px;
  accent-color: var(--accent);
}

.set-slider-end {
  color: var(--text-muted);
  font-weight: 600;
  line-height: 1;
}

.set-slider-end.is-small {
  font-size: var(--text-xs);
}

.set-slider-end.is-large {
  font-size: var(--text-xl);
}

.set-slider-value {
  min-width: 4ch;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
  text-align: right;
}

@media (hover: hover) and (pointer: fine) {
  .set-section:hover {
    background: var(--surface-3);
  }

  .set-section[aria-current="page"]:hover {
    background: var(--accent-soft);
  }

  .set-row.is-switch:not(.is-disabled):hover {
    background: var(--surface-2);
  }

  .set-chip:hover {
    border-color: var(--text-muted);
  }

  .set-theme:hover .set-theme-preview {
    border-color: color-mix(in srgb, var(--accent) 50%, var(--border));
  }

  .set-theme.is-chosen:hover .set-theme-preview {
    border-color: var(--accent);
  }

  .set-segment span:hover {
    color: var(--text);
  }
}

@media (pointer: coarse) {
  .set-section {
    min-height: var(--touch, 44px);
  }

  .set-switch {
    --set-switch-w: 51px;
    --set-switch-h: 31px;
  }
}

/* Narrow sections: controls drop below their label instead of squeezing it. */
@container (max-width: 520px) {
  .set-row:not(.is-switch) {
    flex-direction: column;
    align-items: stretch;
    gap: var(--space-2);
  }

  .set-row:not(.is-switch) .set-select,
  .set-row:not(.is-switch) .set-segmented {
    max-width: none;
    width: 100%;
  }

  /* The sound list takes the width, its preview stays beside it. */
  .set-sound-picker {
    display: flex;
    width: 100%;
  }

  .set-row:not(.is-switch) .set-sound-picker .set-select {
    flex: 1;
    width: auto;
    min-width: 0;
  }

  .set-segment {
    flex: 1;
    text-align: center;
  }

  .set-profile {
    flex-direction: column;
    text-align: center;
  }

  .set-profile-handle,
  .set-profile-actions {
    justify-content: center;
  }

  .set-hours {
    grid-template-columns: auto minmax(0, 1fr);
  }

  .set-conversation {
    flex-wrap: wrap;
  }

  .set-conversation-name {
    flex-basis: 100%;
  }

  .set-conversation .set-select {
    flex: 1;
    max-width: none;
  }
}

.set-page-body {
  container-type: inline-size;
}

/* Phones: the section list is a page of its own, a section opens over it with Back. */
:root[data-layout="compact"] .set-modal {
  --set-row-min-h: 56px;
}

:root[data-layout="compact"] .set-nav {
  width: 100%;
  border-right: 0;
  background: var(--bg);
}

:root[data-layout="compact"] .set-shell[data-page="list"] .set-page,
:root[data-layout="compact"] .set-shell[data-page="section"] .set-nav {
  display: none;
}

:root[data-layout="compact"] .set-shell[data-page="section"] .set-page {
  animation: set-push var(--dur-base) var(--ease-emphasized);
}

:root[data-layout="compact"] .set-shell[data-page="list"] .set-nav {
  animation: motion-fade-in var(--dur-fast) var(--ease-standard);
}

@keyframes set-push {
  from {
    transform: translateX(24px);
    opacity: 0;
  }
}

:root[data-layout="compact"] .set-nav-close,
:root[data-layout="compact"] .set-back {
  display: inline-grid;
}

:root[data-layout="compact"] .set-nav-head h2 {
  font-size: var(--text-2xl);
}

:root[data-layout="compact"] .set-nav-list {
  padding: var(--space-1) var(--space-3) var(--space-6);
}

:root[data-layout="compact"] .set-sections {
  gap: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

:root[data-layout="compact"] .set-sections > li + li {
  border-top: 1px solid var(--border);
}

:root[data-layout="compact"] .set-section {
  min-height: var(--touch, 44px);
  padding: var(--space-2) var(--space-3);
  border-radius: 0;
  font-size: var(--text-md);
}

:root[data-layout="compact"] .set-section-chevron {
  display: inline-flex;
}

:root[data-layout="compact"] .set-page-head {
  padding: var(--space-2) var(--space-2);
}

:root[data-layout="compact"] .set-page-head h2 {
  font-size: var(--text-lg);
  text-align: center;
}

:root[data-layout="compact"] .set-page-body {
  padding: var(--space-4) var(--space-3) calc(var(--space-8) + env(safe-area-inset-bottom));
  background: var(--bg);
}

/* Inputs of 16 px keep iOS from zooming into the field. */
@media (pointer: coarse) {
  .set-modal .input,
  .set-modal select {
    font-size: max(16px, 1em);
  }
}

@media (prefers-reduced-motion: reduce) {
  .set-modal .is-found {
    animation: none;
    background: var(--accent-soft);
  }

  :root[data-layout="compact"] .set-shell[data-page="section"] .set-page {
    animation: motion-fade-in var(--dur-fast) var(--ease-standard);
  }
}

/* High contrast: the switch and the chosen chip or segment are drawn from fills only, which forced
   colours remove; draw them in system colours. */
@media (forced-colors: active) {
  .set-switch,
  .set-switch::after,
  .set-chip[aria-pressed="true"],
  .set-segment input:checked + span {
    forced-color-adjust: none;
  }

  .set-switch {
    border: 1px solid CanvasText;
    background: Canvas;
  }

  .set-switch::after {
    top: 1px;
    left: 1px;
    background: CanvasText;
    box-shadow: none;
  }

  .set-switch:checked {
    border-color: Highlight;
    background: Highlight;
  }

  .set-switch:checked::after {
    background: HighlightText;
  }

  .set-chip[aria-pressed="true"],
  .set-segment input:checked + span {
    border-color: Highlight;
    background: Highlight;
    color: HighlightText;
  }

  .set-section[aria-current="page"] {
    outline: 2px solid Highlight;
    outline-offset: -2px;
  }
}


/* The font menu (#1494): a button showing the chosen font in its own face, and below it a list of
   the fonts, each in its own face, grouped. It opens from the button (the popover's motion, from
   its top right corner) and scrolls when it is taller than the space. */
.set-font {
  position: relative;
  flex: none;
}

.set-font-button {
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  width: 15rem;
  max-width: 100%;
  color: var(--text);
  text-align: start;
  cursor: pointer;
}

.set-font-button:active {
  transform: scale(var(--press-scale));
}

.set-font-current {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.set-font-chevron {
  display: inline-flex;
  flex: none;
  color: var(--text-muted);
}

/* Fixed to the window, so the card doesn't clip it; settings_font.rs places it at its button. */
.set-font-menu {
  position: fixed;
  z-index: 80;
  width: min(18.125rem, calc(100vw - 32px));
  max-height: min(26rem, 60vh);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 4px 0;
}

.set-font-menu:focus-visible {
  outline: none;
}

.set-font-group + .set-font-group {
  margin-top: 4px;
  padding-top: 4px;
  border-top: 1px solid var(--border);
}

.set-font-group-title {
  padding: 6px 14px 2px;
  font-family: var(--font-ui);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
}

.set-font-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  min-height: 36px;
  margin: 0 4px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  font-size: var(--text-md);
  cursor: pointer;
}

.set-font-option.is-active {
  background: var(--accent-soft);
}

.set-font-option-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.set-font-check {
  display: inline-flex;
  flex: none;
  width: 16px;
  color: var(--accent);
}

/* A narrow section stacks the row (above); the button takes the width. */
@container (max-width: 520px) {
  .set-font,
  .set-font-button {
    width: 100%;
  }

}

/* Your data (#211): the export's bar above its buttons. */
.data-export-controls { display: flex; flex-direction: column; gap: var(--space-2); width: 100%; }
.data-export-buttons { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.data-export-progress { width: 100%; height: 4px; }
/* Parts of the app that load when first used (areas.rs, #334). The spinner shows only when the
   chunk takes a moment, so a quick load doesn't flash. */
.lazy-area {
  display: flex;
  align-items: center;
  justify-content: center;
}

.lazy-area .spinner {
  opacity: 0;
  animation:
    spin 0.8s linear infinite,
    lazy-area-show var(--dur-base) var(--ease-standard) 0.3s forwards;
}

@keyframes lazy-area-show {
  to {
    opacity: 1;
  }
}

.lazy-area-pane {
  flex: 1;
  min-width: 0;
  min-height: 0;
  height: 100%;
}

.lazy-area-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.lazy-area-screen {
  min-height: 100dvh;
}

/* A part of a view (a bar, a toolbar, a prompt) on its way: a line, not a box. */
.lazy-area-inline {
  min-height: 24px;
}

/* A popover on its way floats like a dialog; its error keeps the app usable around the card. */
.lazy-area-popover {
  position: fixed;
  inset: 0;
  z-index: 60;
  pointer-events: none;
}

.lazy-area-failed {
  padding: 16px;
  pointer-events: auto;
}

.lazy-area-failed.lazy-area-popover {
  pointer-events: none;
}

.lazy-area-popover .lazy-area-card {
  pointer-events: auto;
}

.lazy-area-failed.lazy-area-overlay {
  background: rgba(8, 12, 20, 0.55);
}

.lazy-area-card {
  max-width: 420px;
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  box-shadow: var(--shadow);
  text-align: center;
}

.lazy-area-actions {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
}

.call-move-banner { display: flex; flex-wrap: wrap; gap: .5rem 1rem; align-items: center; justify-content: center; margin: .5rem 1rem 0; padding: .6rem 1rem; border-radius: var(--radius); background: var(--surface-2); color: var(--text); }

/* ---- People picker (#540): one token field, rows that highlight instead of a checkbox ---- */
.token-field {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  min-height: 40px;
  margin: 0 0 8px;
  padding: 5px 8px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--surface);
  list-style: none;
  cursor: text;
}

.token-field:focus-within {
  outline: var(--focus-width) solid var(--focus);
  outline-offset: -1px;
}

.token {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  min-height: 28px;
  padding: 0 4px 0 3px;
  border-radius: 14px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: var(--weight-medium);
}

.token .avatar-sm {
  width: 22px;
  height: 22px;
  margin-left: 0;
  box-shadow: none;
}

.token-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.token-remove {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  color: inherit;
  cursor: pointer;
}

.token-remove svg {
  width: 12px;
  height: 12px;
}

@media (hover: hover) and (pointer: fine) {
  .token-remove:hover {
    background: color-mix(in srgb, currentColor 16%, transparent);
  }
}

.token-entry {
  flex: 1 1 8rem;
  min-width: 0;
}

.token-input {
  width: 100%;
  min-height: 28px;
  padding: 0;
  border: 0;
  background: none;
  outline: none;
}

.people-picker {
  position: relative;
  max-height: 14rem;
  margin: 0;
}

.person-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 10px;
  border-radius: var(--radius-xs);
  cursor: pointer;
}

.person-item.is-active {
  background: var(--surface-2);
}

.person-item.is-picked {
  background: var(--accent-soft);
}

.person-item.is-member {
  opacity: 0.55;
  cursor: default;
}

/* The ring of the presence dot matches the row, not the app chrome, and the avatar leaves room for it. */
.person-item .avatar {
  margin-right: 2px;
}

.person-item .avatar .presence {
  right: -3px;
  bottom: -3px;
  box-shadow: 0 0 0 2px var(--surface);
}

.person-item.is-picked .avatar .presence {
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.person-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-handle {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-note {
  margin-left: auto;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.person-check {
  display: inline-grid;
  place-items: center;
  flex: none;
  width: 18px;
  margin-left: auto;
  color: var(--accent);
}

.person-note + .person-check {
  margin-left: 0;
}

.person-check svg {
  width: 16px;
  height: 16px;
}

/* Feedback on press, not on release (apple-design: response). */
.person-item:not(.is-member):active {
  background: color-mix(in srgb, var(--accent) 18%, var(--surface-2));
}

.chats-filter {
  margin: 0 12px 6px;
}

.chats-filter .input {
  width: 100%;
}

/* The top of a sidebar on a phone (#703): the list should start near the top, not halfway down.
   The global entries become one row of pills that scrolls sideways (as the filter chips do), and
   the filter waits behind the search button in the header until it is used (sidebar.rs,
   `ListFilter`). Wide layouts keep the list of entries and the visible field. */
.sidebar-head .sb-filter-toggle {
  display: none;
}

:root[data-layout="compact"] .sidebar-head .sb-filter-toggle {
  display: inline-grid;
}

:root[data-layout="compact"] .sidebar-head .sb-filter-toggle[aria-expanded="true"] {
  background: var(--sb-hover);
  color: var(--sb-strong);
}

/* The chevron right after the title folds the entries away (and back), remembered on the device:
   down while they show, pointing at the title's end while they are folded, like a disclosure row. */
.sidebar-head .sb-entries-toggle {
  display: none;
}

:root[data-layout="compact"] .sidebar-head .space-name {
  flex: 0 1 auto;
}

/* A space's head holds five buttons beside its name next to the rail: they sit closer (still the
   full touch height), and the name keeps one line. */
:root[data-layout="compact"] .sidebar-head {
  gap: 0;
  padding-inline: 12px 4px;
}

:root[data-layout="compact"] .sidebar-head > .icon-btn:not(.sb-entries-toggle) {
  min-width: 40px;
  width: 40px;
}

:root[data-layout="compact"] .sidebar-head .space-name-entry > span:not(.space-tile) {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

:root[data-layout="compact"] .sidebar-head .sb-entries-toggle {
  display: inline-grid;
  min-width: 32px;
  margin-inline-end: auto;
  color: var(--sb-text);
}

:root[data-layout="compact"] .sb-entries-toggle .icon {
  width: 18px;
  height: 18px;
  transition: transform var(--dur-base) var(--ease-emphasized);
}

:root[data-layout="compact"] .sb-entries-toggle.is-collapsed .icon {
  transform: rotate(-90deg);
}

:root[data-layout="compact"] .sb-entries.is-collapsed {
  display: none;
}

:root[data-layout="compact"] .sb-entries:not(.is-collapsed) {
  animation: motion-fade-in var(--dur-fast) var(--ease-standard);
}

:root[data-layout="compact"] .chats-filter:not(.is-open, .has-query) {
  display: none;
}

:root[data-layout="compact"] .chats-filter {
  margin-bottom: var(--space-2);
  animation: motion-fade-in var(--dur-fast) var(--ease-standard);
}

:root[data-layout="compact"] .sb-entries {
  display: flex;
  flex-wrap: nowrap;
  gap: var(--space-2);
  padding: 0 12px var(--space-2);
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
}

:root[data-layout="compact"] .sb-entries .sb-item {
  flex: none;
  width: auto;
  margin: 0;
  padding: 0 var(--space-3);
  gap: var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--sb-fill);
  color: var(--sb-text);
  font-size: var(--text-sm);
  letter-spacing: 0;
  font-weight: var(--weight-semibold);
}

:root[data-layout="compact"] .sb-entries .sb-item.current {
  background: var(--sb-current);
  color: var(--on-fill);
}

:root[data-layout="compact"] .sb-entries .sb-item .icon {
  width: 16px;
  height: 16px;
}

/* Pills shrink like the chips beside them, not like the slight press of a full-width row. */
:root[data-layout="compact"] .sb-entries .sb-item:active:not(:disabled) {
  transform: scale(var(--press-scale));
}

.skeleton-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---- Home pages: Calls, Meetings, People, Saved (issue #585) ----
   One centred column, one header, one row and card language. The gutter keeps the header and the
   scrolling content aligned to the same column at any width. */

.page-view {
  --page-width: 760px;
  --page-gutter: max(var(--space-4), calc((100% - var(--page-width)) / 2));
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.page-view .panel-header {
  min-height: 60px;
  padding-inline: var(--page-gutter);
  border-bottom-color: transparent;
}

.page-view .panel-title h1 {
  font-size: var(--text-2xl);
  letter-spacing: var(--tracking-2xl);
  line-height: 1.15;
}

.page-view .panel-scroll {
  padding: var(--space-2) var(--page-gutter) var(--space-8);
}

.page-view .segmented button {
  min-height: 28px;
  padding: 0 var(--space-3);
}

.page-view .segmented button[aria-selected="true"] {
  color: var(--text);
}

.page-view .panel-header .btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.page-view .empty-state.is-rich {
  margin-top: var(--space-8);
}

.page-day + .page-day {
  margin-top: var(--space-4);
}

.page-day-title {
  position: sticky;
  top: calc(-1 * var(--space-2));
  z-index: 1;
  padding: var(--space-3) var(--space-3) var(--space-1);
  background: var(--bg, var(--surface));
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
}

.page-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}

.page-row {
  position: relative;
  display: flex;
  align-items: center;
  gap: var(--space-1);
  border-radius: var(--radius-md);
}

.page-row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 60px;
  padding: var(--space-2) var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: inherit;
  text-align: start;
  transition: background-color 120ms ease-out;
}

.page-row-main:active {
  background: var(--surface-3);
}

@media (hover: hover) and (pointer: fine) {
  .page-row:hover .page-row-main,
  .page-row:focus-within .page-row-main {
    background: var(--surface-2);
  }
}

.page-row-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.page-row-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.page-row-detail {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.page-row-detail .icon {
  flex: none;
  width: 14px;
  height: 14px;
}

.page-row-time {
  flex: none;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.page-row-action {
  flex: none;
  color: var(--accent);
}

.page-row-action.is-primary {
  background: var(--accent);
  color: var(--on-accent);
}

.page-row-actions {
  flex: none;
  display: flex;
  gap: 2px;
  padding-inline-end: var(--space-2);
}

/* Actions of a directory row appear on hover and focus; touch screens always show them. */
@media (hover: hover) and (pointer: fine) {
  .page-row-actions {
    opacity: 0;
    transition: opacity 120ms ease-out;
  }

  .page-row:hover .page-row-actions,
  .page-row:focus-within .page-row-actions {
    opacity: 1;
  }
}

.page-portrait {
  flex: none;
  display: inline-flex;
}

.page-portrait-group {
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--surface-3);
  color: var(--text-muted);
}

.page-tools {
  display: flex;
  gap: var(--space-2);
  padding: var(--space-1) 0 var(--space-3);
}

.page-search {
  position: relative;
  flex: 1;
  min-width: 0;
}

.page-search .icon {
  position: absolute;
  inset-block: 0;
  inset-inline-start: var(--space-3);
  margin-block: auto;
  color: var(--text-muted);
  pointer-events: none;
}

.page-search .input {
  width: 100%;
  padding-inline-start: 38px;
  border-radius: var(--radius-pill);
}

.page-select {
  flex: none;
  max-width: 40%;
}

.page-cards {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.page-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  padding: var(--space-3) var(--space-4);
}

/* Calls */

.call-item .page-row-title {
  color: var(--text);
}

.call-item.missed .page-row-title,
.call-item.missed .page-row-detail {
  color: var(--danger);
}

.call-item .icon.is-incoming,
.call-item .icon.is-missed {
  transform: rotate(45deg);
}

.call-item .icon.is-outgoing {
  transform: rotate(-135deg);
}

.call-live {
  color: var(--accent);
  font-weight: var(--weight-semibold);
}

/* Meetings (#956): views, now / next, answers, compact rows under sticky days. The page uses
   the width: at a wide pane the now / next and the answers sit beside the list. */

.meetings-view {
  --page-width: 1120px;
}

.meetings-error {
  margin: var(--space-2) var(--page-gutter) 0;
}

.meetings-toolbar {
  padding: 0 var(--page-gutter) var(--space-2);
  overflow-x: auto;
  scrollbar-width: none;
}

.meetings-tabs {
  width: max-content;
}

.meetings-list {
  container-type: inline-size;
}

.meetings-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: var(--space-4);
}

.meetings-aside {
  display: grid;
  gap: var(--space-4);
  align-content: start;
}

.meetings-aside:empty {
  display: none;
}

@container (min-width: 900px) {
  .meetings-layout.has-aside {
    grid-template-columns: minmax(0, 1fr) minmax(280px, 340px);
    gap: var(--space-6);
  }

  .meetings-layout.has-aside .meetings-aside {
    grid-column: 2;
    grid-row: 1;
    align-self: start;
    position: sticky;
    top: var(--space-2);
  }

  .meetings-layout.has-aside .meetings-main {
    grid-column: 1;
    grid-row: 1;
  }
}

.meetings-main {
  min-width: 0;
}

/* Now / next: the one meeting that matters most, with a large Join. */
.meetings-hero {
  display: grid;
  gap: var(--space-1);
  padding: var(--space-5);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--shadow-card);
}

.meetings-hero.is-running {
  border-color: var(--accent);
  background: linear-gradient(var(--accent-soft), var(--accent-soft)), var(--surface);
}

.meetings-hero-eyebrow {
  margin: 0;
  color: var(--accent-strong);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
}

.meetings-hero-title {
  margin: 0;
  font-size: var(--text-xl);
  letter-spacing: var(--tracking-xl);
  line-height: 1.2;
  font-weight: var(--weight-bold);
  overflow-wrap: anywhere;
}

.meetings-hero-when,
.meetings-hero-people {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  font-variant-numeric: tabular-nums;
}

.meetings-hero-when {
  color: var(--text);
}

.meetings-hero-actions {
  display: flex;
  margin-top: var(--space-3);
}

.meetings-hero-actions .btn {
  flex: 1;
  justify-content: center;
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.meetings-hero-actions .btn-large {
  min-height: 44px;
  font-size: var(--text-md);
}

/* Invitations still waiting for an answer: a labelled section, not a red link. */
.meetings-answers {
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
}

.meetings-section-title {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.meetings-section-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: var(--text-xs);
  line-height: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.meetings-answer-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.meetings-answer {
  display: grid;
  gap: var(--space-2);
  padding: var(--space-3) 0;
}

.meetings-answer + .meetings-answer {
  border-top: 1px solid var(--border);
}

.meetings-answer-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.meetings-answer-title {
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
}

.meetings-answer-meta {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.meetings-answer-series {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.meetings-answer-series .icon {
  width: 14px;
  height: 14px;
}

.meetings-answer-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Days and rows. */
.meetings-day-group + .meetings-day-group {
  margin-top: var(--space-4);
}

.meetings-day-title {
  font-size: var(--text-sm);
}

.meeting-rows {
  list-style: none;
  margin: 0;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.meeting-row + .meeting-row {
  border-top: 1px solid var(--border);
}

.meeting-row.is-running {
  box-shadow: inset 3px 0 0 var(--accent);
}

.meeting-row:first-child {
  border-start-start-radius: var(--radius-md);
  border-start-end-radius: var(--radius-md);
}

.meeting-row:last-child {
  border-end-start-radius: var(--radius-md);
  border-end-end-radius: var(--radius-md);
}

.meeting-row-line {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: 0 var(--space-3);
  min-height: 60px;
}

.meeting-row-toggle {
  flex: 1;
  min-width: 0;
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) 0;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: start;
  font: inherit;
  cursor: pointer;
}

.meeting-row-toggle > .icon {
  color: var(--text-muted);
  transition: transform var(--dur-fast) var(--ease-standard);
}

.meeting-row.is-open .meeting-row-toggle > .icon {
  transform: rotate(180deg);
}

.meeting-row-toggle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}

.meeting-row-time {
  display: grid;
  font-variant-numeric: tabular-nums;
}

.meeting-row-start {
  font-weight: var(--weight-semibold);
}

.meeting-row-length {
  white-space: nowrap;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.meeting-row-text {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.meeting-row-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-semibold);
}

.meeting-row-sub {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.meeting-row-who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meeting-row-series {
  flex: none;
  display: inline-flex;
}

.meeting-row-series .icon {
  width: 14px;
  height: 14px;
}

.meeting-row.is-over .meeting-row-toggle {
  opacity: 0.6;
}

.meeting-row.is-cancelled .meeting-row-title {
  color: var(--text-muted);
  text-decoration: line-through;
}

.meeting-chip {
  flex: none;
  padding: 0 6px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-muted);
  font-size: var(--text-xs);
  line-height: 18px;
  font-weight: var(--weight-semibold);
  white-space: nowrap;
}

.meeting-chip.is-running,
.meeting-chip.is-waiting {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.meeting-chip.is-soon {
  background: transparent;
  padding: 0;
  color: var(--accent-strong);
}

.meeting-row-faces {
  flex: none;
  align-items: center;
}

.meeting-row-more {
  margin-inline-start: 4px;
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.meeting-row-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.menu-anchor {
  position: relative;
}

.menu-popover {
  width: auto;
  min-width: 13rem;
}

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

.menu-check {
  display: inline-flex;
  width: 16px;
}

.rsvp-button {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.rsvp-button .icon {
  width: 14px;
  height: 14px;
}

.rsvp-button.is-accepted {
  color: var(--accent-strong);
}

.rsvp-button.is-none {
  border-color: var(--accent);
  color: var(--accent-strong);
}

/* The detail opens in place, aligned with the title column. */
.meeting-detail {
  display: grid;
  gap: var(--space-3);
  padding: 0 var(--space-3) var(--space-4) calc(76px + 2 * var(--space-3));
  animation: meeting-detail-in var(--dur-base) var(--ease-emphasized);
}

@keyframes meeting-detail-in {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
}

.meeting-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  gap: 4px var(--space-3);
  margin: 0;
  font-size: var(--text-sm);
}

.meeting-facts dt {
  color: var(--text-muted);
}

.meeting-facts dd {
  margin: 0;
}

.meeting-description {
  margin: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.meeting-detail-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
}

.meeting-detail-heading {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-weight: var(--weight-semibold);
}

.meetings-more {
  display: block;
  margin: var(--space-4) auto 0;
}

.meetings-reach,
.meetings-loading {
  margin: var(--space-4) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
  text-align: center;
}

/* Still used by the meeting dialogs and the guest links. */
.meeting-title {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
}

.meeting-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.avatar-stack {
  flex: none;
  display: inline-flex;
}

.avatar-stack .avatar + .avatar {
  margin-inline-start: -8px;
}

.avatar-stack .avatar {
  box-shadow: 0 0 0 2px var(--surface);
}

@container (max-width: 640px) {
  .meeting-row-faces {
    display: none;
  }
}

@media (max-width: 520px) {
  /* The title keeps its room: the header's buttons show their icons, their text stays for screen
     readers. */
  .meetings-view .panel-header .btn > span {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
  }

  .meeting-row-line {
    gap: var(--space-2);
    padding-inline: var(--space-2) var(--space-1);
  }

  .meeting-row-toggle {
    grid-template-columns: 56px minmax(0, 1fr) auto;
    gap: var(--space-2);
  }

  .meeting-row-toggle > .icon {
    display: none;
  }

  .rsvp-button > span,
  .rsvp-button > .icon:last-child {
    display: none;
  }

  .meeting-detail {
    padding-inline-start: var(--space-3);
  }

  .meetings-hero {
    padding: var(--space-4);
  }
}

@media (prefers-reduced-motion: reduce) {
  .meeting-detail {
    animation-name: motion-fade-in;
  }

  .meeting-row-toggle > .icon {
    transition: none;
  }
}

/* People */

.person-name .badge {
  vertical-align: middle;
}

.group-row {
  border-radius: var(--radius-md);
}

.group-row > .person-main {
  width: 100%;
  min-height: 56px;
  padding: var(--space-2) var(--space-3);
  display: flex;
  align-items: center;
  gap: var(--space-3);
  border: 0;
  border-radius: var(--radius-md);
  background: none;
  color: inherit;
  text-align: start;
}

.group-row > .person-main .person-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.person-facts {
  color: var(--text-muted);
  font-size: var(--text-sm);
}

@media (hover: hover) and (pointer: fine) {
  .group-row > .person-main:hover {
    background: var(--surface-2);
  }
}

.group-members {
  list-style: none;
  margin: 0;
  padding: 0 var(--space-3) var(--space-3) var(--space-8);
}

.group-members li {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) 0;
}

.directory .inline-form {
  margin-top: var(--space-4);
}

/* Scheduled messages */

.scheduled-note {
  margin: 0 0 var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.scheduled-status {
  margin: var(--space-1) 0 0;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.scheduled-status.needs-you {
  color: var(--danger);
}

.scheduled-confirm {
  align-self: center;
  font-size: var(--text-sm);
}

.scheduled-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

.send-later-label {
  display: block;
  padding: 4px 14px 0 36px;
  font-size: var(--text-xs);
}

.send-later-hint {
  margin: 0;
  padding: 0 14px 4px;
  color: var(--text-muted);
  font-size: var(--text-xs);
}

/* Saved */

.saved-card .saved-meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.saved-card .saved-author {
  color: var(--text);
  font-weight: var(--weight-semibold);
}

.saved-card .saved-where {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.saved-card .saved-time {
  margin-inline-start: auto;
  flex: none;
  font-size: var(--text-xs);
}

.saved-card .saved-body {
  margin-top: var(--space-2);
}

.saved-card .saved-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-3);
}

/* Drafts & sent (#1220) */

.saved-card .draft-body {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 4;
  line-clamp: 4;
}

.draft-delete-question {
  flex-basis: 100%;
  font-size: var(--text-sm);
}

.sent-files {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.sent-files .icon {
  width: 14px;
  height: 14px;
}

.drafts-more {
  display: block;
  margin: var(--space-4) auto 0;
}

.drafts-note {
  margin: var(--space-4) 0 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  text-align: center;
}

/* The share link dialog: the file's live links, then the options of a new one. */
.share-dialog {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.share-heading {
  margin: var(--space-2) 0 0;
  font-size: var(--text-lg);
}

.share-links {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.share-link {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.share-link-info {
  flex: 1;
  min-width: 0;
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.share-form {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.share-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: var(--space-2);
}

.link-prompts { position: fixed; inset-inline-end: var(--space-4); top: var(--space-4); display: flex; flex-direction: column; gap: var(--space-2); z-index: 1000; max-width: min(24rem, calc(100vw - 2 * var(--space-4))); }
.link-prompts:empty { display: none; }
.link-prompt { display: flex; flex-direction: column; gap: var(--space-2); padding: var(--space-3); border-radius: var(--radius-md); background: var(--surface); color: var(--text); border: 1px solid var(--border); border-inline-start: 4px solid var(--accent); box-shadow: var(--shadow); }
.link-prompt h2 { margin: 0; font-size: var(--text-md); }
.link-prompt p { margin: 0; }
.link-prompt-actions { display: flex; justify-content: flex-end; gap: var(--space-2); }

/* ---- Quick menus: create beside the rail, focus mode under the top bar (issue #299) ---- */

/* Beside the rail, level with the button that opened it. */
.popover.rail-menu {
  position: fixed;
  left: calc(var(--rail-w) + var(--space-2));
  right: auto;
  top: var(--rail-menu-top, 0);
  width: 15rem;
  --popover-origin: top left;
}

/* Under the top bar (Focus): hanging from the button, right edges in line, growing out of it. */
.popover.rail-menu.opens-below {
  left: auto;
  right: var(--rail-menu-right, 0);
  top: calc(var(--rail-menu-below, 0) + var(--space-2));
  --popover-origin: top right;
}

.focus-menu {
  position: relative;
}

/* While notifications are paused the button stays lit, so the pause can't be forgotten. */
.icon-btn.on-dark.focus-btn.is-on {
  background: var(--accent);
  color: var(--on-accent);
}

@media (hover: hover) and (pointer: fine) {
  .icon-btn.on-dark.focus-btn.is-on:hover {
    background: var(--accent-strong);
    color: var(--on-accent);
  }
}

.rail-menu .menu-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

/* ---- Files view (issue #301) ---- */

.files-view {
  flex: 1;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.files-view-body {
  padding: var(--space-2) max(var(--space-4), calc((100% - 760px) / 2)) var(--space-8);
}


/* Filters and the order share the header's row and wrap under the title where it is narrow. */
.files-view-header {
  flex-wrap: wrap;
  row-gap: var(--space-2);
  padding-block: var(--space-2);
}

.files-view-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
}

.files-sort {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.files-sort .input {
  width: auto;
}

/* Name and size order only the files loaded so far (#1509): said once, quietly, above the list. */
.files-sort-note {
  margin: 0 0 var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-sm);
}

/* The star of a file: outlined until starred, then filled in the star colour. */
.file-star[aria-pressed="true"] {
  color: var(--star);
}

.file-star[aria-pressed="true"] .icon {
  fill: currentColor;
}

/* ---- The Files place's sidebar (#1510): filters, then the scopes ---- */

.files-kinds {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding-top: var(--space-1);
}

.files-scope-title {
  margin: 0;
}

.files-scopes [role="group"] {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* A space's tile at the size of a row's icon, as under the list layout's list. */
.files-scopes .space-tile {
  flex: none;
  width: 20px;
  height: 20px;
  font-size: var(--text-2xs);
}

/* ---- Files on a phone (#1510): a tab of its own, laid out like the Photos and Files apps ---- */

/* A large title on the page's 16px gutter; no back button in front of a tab. */
:root[data-layout="compact"] .files-view-header {
  min-height: 0;
  padding: var(--space-3) var(--space-4) var(--space-2);
  border-bottom: 0;
}

:root[data-layout="compact"] .files-view-header h1 {
  font-size: var(--text-2xl);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: var(--weight-bold);
}

.files-phone-bar {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border);
}

/* The filters: one row of pills that scrolls sideways, edge to edge, the first on the gutter. */
.files-chips {
  display: flex;
  gap: var(--space-2);
  padding: 0 var(--space-4);
  overflow-x: auto;
  scrollbar-width: none;
  overscroll-behavior-x: contain;
}

.files-chips::-webkit-scrollbar {
  display: none;
}

.files-chip {
  flex: none;
  min-height: 34px;
  padding: 0 14px;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text);
  font-size: var(--text-md);
  font-weight: var(--weight-medium);
  -webkit-tap-highlight-color: transparent;
  transition: background-color 120ms ease-out, color 120ms ease-out;
}

.files-chip[aria-pressed="true"] {
  background: var(--accent);
  color: var(--on-accent);
}

/* Where and the order: two menus side by side, each its value with a chevron, the native picker
   behind it. 16px text, so focusing them doesn't zoom the page. */
.files-menus {
  display: flex;
  gap: var(--space-2);
  padding: 0 var(--space-4);
}

.files-menu {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
}

.files-menu select {
  width: 100%;
  min-height: 36px;
  padding: 0 32px 0 12px;
  border: 0;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--accent);
  font: inherit;
  font-size: var(--text-lg);
  font-weight: var(--weight-medium);
  appearance: none;
  -webkit-appearance: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.files-menu .icon {
  position: absolute;
  right: 10px;
  width: 16px;
  height: 16px;
  color: var(--accent);
  pointer-events: none;
}

/* The list: on the gutter, no extra inset; the name gets the room, downloading stays in the menu. */
:root[data-layout="compact"] .files-view-body {
  padding: var(--space-2) 0 var(--space-6);
}

/* One inset group, rows divided by a hairline that starts after the icon, as in iOS lists. */
:root[data-layout="compact"] .files-view .files-list {
  gap: 0;
  margin: 0 var(--space-4);
  padding: 0;
  border-radius: var(--radius-md);
  background: var(--surface-2);
  overflow: hidden;
}

:root[data-layout="compact"] .files-view .files-list:empty {
  display: none;
}

:root[data-layout="compact"] .files-view .file-card {
  position: relative;
  min-height: 60px;
  padding: 8px 2px 8px 12px;
  gap: 0;
  border: 0;
  border-radius: 0;
  background: transparent;
}

:root[data-layout="compact"] .files-view .file-card + .file-card::before {
  content: "";
  position: absolute;
  top: 0;
  right: 0;
  left: 60px;
  border-top: 1px solid var(--border);
}

/* The icon, then the name with the room, then the actions close together: 40 by 44 each, still a
   finger's target, without the gap the card puts between its parts elsewhere. */
:root[data-layout="compact"] .files-view .file-card > :first-child {
  margin-right: var(--space-3);
}

:root[data-layout="compact"] .files-view .file-meta {
  margin-right: var(--space-1);
}

:root[data-layout="compact"] .files-view .file-card .icon-btn {
  min-width: 40px;
  width: 40px;
  height: 44px;
  padding: 0;
  color: var(--text-muted);
}

/* One size for every action, the menu's dots too (the viewer's 16px tools are too faint here). */
:root[data-layout="compact"] .files-view .file-card .icon-btn svg {
  width: 20px;
  height: 20px;
}

:root[data-layout="compact"] .files-view .file-download {
  display: none;
}

:root[data-layout="compact"] .files-sort-note {
  padding: 0 var(--space-4);
}

@media (prefers-reduced-motion: reduce) {
  .files-chip {
    transition: none;
  }
}

/* The menu's dots are round stroke caps: a thicker stroke draws them large enough to find. */
:root[data-layout="compact"] .files-view .file-menu-wrap .icon-btn svg {
  stroke-width: 4;
}
/* ---- Setup checklist on Chats (issue #301) ---- */

.setup-checklist {
  width: 100%;
  margin-top: var(--space-6);
  padding: var(--space-4);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  text-align: start;
}

.setup-head {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.setup-head h2 {
  flex: 1;
  font-size: var(--text-md);
  font-weight: var(--weight-bold);
}

.setup-progress-text {
  color: var(--text-muted);
  font-size: var(--text-xs);
  font-variant-numeric: tabular-nums;
}

.setup-progress {
  height: 4px;
  margin: var(--space-3) 0;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}

.setup-progress-bar {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform: scaleX(var(--setup-done, 0));
  transform-origin: left center;
  transition: transform 240ms var(--ease-standard, ease-out);
}

.setup-steps {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-1);
}

.setup-step {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  width: 100%;
  min-height: 52px;
  padding: var(--space-2) var(--space-2);
  border: 0;
  border-radius: var(--radius);
  background: none;
  color: inherit;
  font: inherit;
  text-align: start;
  text-decoration: none;
}

@media (hover: hover) and (pointer: fine) {
  .setup-step:hover {
    background: var(--surface-2);
  }
}

.setup-step:active {
  background: var(--surface-3);
}

.setup-step > .icon {
  flex: none;
  color: var(--text-muted);
}

.setup-step-text {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setup-mark {
  flex: none;
  display: grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--border-strong, var(--text-muted));
  border-radius: 50%;
  color: var(--on-accent);
}

.setup-mark .icon {
  width: 14px;
  height: 14px;
}

.setup-step.is-done .setup-mark {
  border-color: var(--accent);
  background: var(--accent);
}

.setup-step.is-done .setup-step-text strong {
  color: var(--text-muted);
  font-weight: var(--weight-semibold);
}

.integration-create { display: grid; grid-template-columns: 1fr auto; gap: var(--space-2); align-items: end; max-width: 36rem; }
.integration-create label { grid-column: 1 / -1; }
.integration-reveal { display: grid; gap: var(--space-2); max-width: 46rem; padding: var(--space-4); border: 1px solid var(--border); border-radius: var(--radius-md); margin-bottom: var(--space-4); }
.integration-copy-row { display: flex; gap: var(--space-2); align-items: center; }
.integration-copy-row .input { flex: 1; min-width: 0; }


/* Outgoing webhooks (docs/webhooks.md): long URLs wrap instead of widening the page. */
.webhook-card .webhook-url { overflow-wrap: anywhere; margin: 0; }
.webhook-health { display: grid; grid-template-columns: max-content 1fr; gap: var(--space-1) var(--space-3); margin: 0; }
.webhook-health dt { color: var(--text-muted); }
.webhook-health dd { margin: 0; overflow-wrap: anywhere; }
/* Admins' requests to join a private channel the user owns (admin.md §2.4, issue #776): above the
   activity entries and in the channel settings. A row says who asks, where and what approving
   means; the decision sits right under it, Approve first. */
.join-requests {
  margin: 0 0 var(--space-3);
}

.join-requests-title {
  margin: 0 0 var(--space-1);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  letter-spacing: var(--tracking-xs);
  text-transform: uppercase;
}

.join-request-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.join-request {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: var(--space-2);
  border-radius: var(--radius-sm);
}

.join-request-avatar {
  flex: none;
  padding-top: 1px;
}

.join-request-body {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.join-request-summary {
  overflow-wrap: anywhere;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
}

.join-request-time,
.join-request-hint {
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.join-request-time {
  font-variant-numeric: tabular-nums;
}

.join-request-hint {
  margin: 2px 0 0;
  color: var(--text-muted);
}

.join-request-history {
  margin: var(--space-2) 0 0;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.join-request-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* In the (always dark) sidebar: muted text in its tones, a quiet secondary button on the material. */
.activity-sidebar .join-requests {
  padding: 0 var(--space-2);
}

.activity-sidebar .join-requests-title,
.activity-sidebar .join-request-time,
.activity-sidebar .join-request-hint {
  color: var(--sb-muted);
}

.activity-sidebar .join-requests-title {
  padding: 0 var(--space-2);
}

.activity-sidebar .join-request {
  background: var(--sb-hover);
  color: var(--sb-strong);
}

.activity-sidebar .join-request + .join-request {
  margin-top: var(--space-1);
}

.activity-sidebar .join-request .btn:not(.btn-primary) {
  border-color: transparent;
  background: var(--sb-hover);
  color: var(--sb-strong);
}

/* In the channel settings: cards above the member list. */
.modal .join-requests {
  padding-top: var(--space-2);
}

.modal .join-request {
  background: var(--surface-2);
}

.modal .join-request + .join-request {
  margin-top: var(--space-1);
}

/* The role review (e2ee.md 4.6.1): one group with what it asks and what it offers. */
.role-review {
  margin: 0 0 var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}

.role-review-list {
  margin-top: var(--space-2);
}

.role-review-list:focus {
  outline: none;
}

.role-review-actions {
  display: flex;
  gap: var(--space-2);
  margin-top: var(--space-2);
}

/* A list that can't be confirmed must not look as if it could. */
.role-review-actions .btn:disabled {
  opacity: 0.45;
}
/* Making and opening a recovery kit (e2ee.md §6.5): the key in large groups, its buttons, and
   the check of one group. Shared by the first sign-in and Settings > Security & privacy. */
.kit-setup {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  margin: var(--space-2) 0;
}

.kit-setup p {
  margin: 0;
}

/* The key: monospace groups that wrap as whole groups on a phone. */
.kit-key {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2) var(--space-4);
  padding: var(--space-4);
  border-radius: var(--radius-lg);
  background: var(--surface-2);
  font: 600 var(--text-xl) var(--font-mono);
  letter-spacing: 0.06em;
  user-select: all;
}

.kit-group {
  white-space: nowrap;
}

.kit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.kit-actions .btn {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.kit-group-input {
  max-width: 10ch;
  font-family: var(--font-mono);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* Desktop: this computer kept the account's backup key in its keychain. */
.kit-device-restore {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: flex-start;
  margin: var(--space-3) 0;
  padding: var(--space-3);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.kit-device-restore p {
  margin: 0;
}

.kit-status {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-1);
  align-items: center;
}

.kit-status .icon {
  color: var(--online);
}

/* "or [Open recovery kit…]" under the group field. */
.kit-or,
.kit-open {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  align-items: center;
}

.kit-check {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

/* The guided first run (onboarding.rs, #1701): a step indicator, a heading and a lead, the
   step's content and one action row. */
.onboarding {
  display: flex;
  flex-direction: column;
}

.step-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  margin: 0 0 var(--space-4);
}

.step-progress-bar {
  display: flex;
  gap: var(--space-1);
  width: min(160px, 60%);
}

.step-progress-segment {
  flex: 1 1 0;
  height: 4px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  transition: background-color var(--dur-base) var(--ease-standard);
}

.step-progress-segment.is-done {
  background: var(--accent);
}

.step-progress-label {
  margin: 0;
  color: var(--text-muted);
  font-weight: var(--weight-medium);
}

/* Each step's content arrives with the card's own entrance; the heading takes the focus, but a
   focus ring around a heading would only distract. */
.step-body {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  animation: auth-in var(--dur-base) var(--ease-out) both;
}

.step-body > h1 {
  margin: 0;
}

.step-body > h1:focus {
  outline: none;
}

.step-body p {
  margin: 0;
}

.step-lead {
  color: var(--text-muted);
  text-align: center;
}

.step-points {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
  margin: 0;
  padding: 0;
  list-style: none;
}

.step-point,
.step-choice {
  display: flex;
  gap: var(--space-3);
  align-items: flex-start;
}

.step-point-icon {
  display: inline-flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-md);
  background: var(--accent-soft);
  color: var(--accent);
}

.step-point-text {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.step-point-text strong {
  font-weight: var(--weight-semibold);
}

/* The ways to unlock: full-width rows like a settings list, the recommended one tinted. */
.step-choices {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.step-choice {
  width: 100%;
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--surface);
  color: var(--text);
  text-align: left;
  transition:
    background-color var(--dur-fast) var(--ease-standard),
    transform var(--dur-fast) var(--ease-out);
}

.step-choice.is-recommended {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
}

@media (hover: hover) and (pointer: fine) {
  .step-choice:hover:not(:disabled) {
    background: var(--surface-2);
  }
}

.step-choice:active:not(:disabled) {
  transform: scale(var(--press-scale));
}

.step-choice:disabled {
  cursor: progress;
}

.step-choice-chevron,
.step-choice .spinner {
  flex: 0 0 auto;
  align-self: center;
  color: var(--text-muted);
}

.step-badge {
  display: inline-block;
  margin-inline-start: var(--space-2);
  padding: 1px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--accent-soft);
  color: var(--accent);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  vertical-align: 2px;
}

.step-numbered {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding-inline-start: var(--space-5);
}

.step-aside {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  align-items: center;
  text-align: center;
}

/* One action row per step: the main action filled and widest, the other one quiet (text in the
   accent colour, no border), so the next step is obvious. The main action comes first in the
   document (focus order); on a wide card it sits on the right, on a phone on top. */
.auth-card .step-actions {
  display: flex;
  flex-direction: row-reverse;
  gap: var(--space-2);
  margin: var(--space-2) 0 0;
}

.auth-card .step-actions .btn-primary {
  flex: 1 1 auto;
}

/* Only a way back (linking waits on the other device): it sits where "Back" always sits. */
.auth-card .step-actions:not(:has(.btn-primary)) {
  justify-content: flex-end;
}

.auth-card .step-actions .btn:not(.btn-primary) {
  flex: 0 0 auto;
  border-color: transparent;
  background: transparent;
  color: var(--accent);
  font-weight: var(--weight-medium);
}

@media (hover: hover) and (pointer: fine) {
  .auth-card .step-actions .btn:not(.btn-primary):hover {
    background: var(--surface-2);
  }
}

@media (max-width: 420px) {
  .auth-card .step-actions {
    flex-direction: column;
  }
}

.onboarding-exit {
  margin: var(--space-6) 0 0;
  text-align: center;
}

.onboarding-exit .link-btn {
  color: var(--text-muted);
}

@media (prefers-reduced-motion: reduce) {
  .step-body {
    animation: none;
  }

  .step-choice {
    transition: none;
  }

  .step-choice:active:not(:disabled) {
    transform: none;
  }
}

/* Recovery through the organization (org_recovery_setup.rs, #1705): the code to read out is
   eight groups of four, so it wraps by group and stays readable at phone width. */
.org-recovery-code {
  font-size: var(--text-2xl);
  letter-spacing: 0.08em;
  padding-left: 12px;
  line-height: 1.5;
  overflow-wrap: anywhere;
  user-select: all;
}

.onboarding .status-line {
  display: flex;
  align-items: center;
  gap: 8px;
}
/* ---- The menu of a sidebar entry (#903): a channel, chat or space ---- */

/* It grows from the pointer (or from under the entry, for the keyboard), like the link menu. */
.popover.entry-menu {
  min-width: 15rem;
  max-width: min(20rem, calc(100vw - 16px));
  max-height: calc(100dvh - 16px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* The sheet names what it is about; the popover sits on its entry, which already does. */
.entry-menu-title {
  margin-top: 6px;
  text-transform: none;
  letter-spacing: var(--tracking-xs);
  font-size: var(--text-xs);
}

.entry-menu .menu-item .icon:last-child:not(:first-child) {
  margin-inline-start: auto;
  color: var(--text-muted);
}

.entry-menu .menu-item.is-destructive {
  color: var(--danger);
}

/* "Leave" where it can't be done yet: readable, but plainly not an action, with the reason. */
.entry-menu .menu-item[aria-disabled="true"] {
  color: var(--text-muted);
  cursor: default;
}

.entry-menu .menu-hint,
.entry-menu .menu-confirm {
  margin: 0 14px 6px;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
  max-width: 18rem;
}

.entry-menu .menu-hint {
  margin-inline-start: 40px;
}

.entry-menu .menu-confirm {
  margin-block: 6px 8px;
  color: var(--text);
}

.sheet.entry-menu .menu-hint,
.sheet.entry-menu .menu-confirm {
  margin-inline: var(--space-4);
  max-width: none;
}

/* A finger resting on an entry tints it before the menu comes. */
:is(.sb-item, .sb-space-toggle, .space-btn).is-pressing {
  background: var(--surface-2);
}

.space-name-entry {
  display: contents;
}

/* The head's space name opens its menu on a long-press: it selects no text and opens no callout. */
.sidebar-head .space-name {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
/* ---- Downloads of the desktop app (#153): the top bar's button and its list ---- */

.downloads {
  position: relative;
}

/* The arrow drops onto a bar, like a browser's: the bar is the tray it lands in and the progress. */
.downloads-btn {
  position: relative;
  grid-auto-flow: row;
  gap: 1px;
}

.downloads-arrow {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.downloads-bar {
  position: relative;
  width: 16px;
  height: 2px;
  border-radius: 1px;
  overflow: hidden;
  background: currentColor;
}

/* The fill grows with scaleX (the compositor runs it), from the left edge. */
.downloads-bar-fill {
  position: absolute;
  inset: 0;
  background: var(--download-progress);
  transform: scaleX(var(--downloads-progress, 0));
  transform-origin: left center;
  opacity: 0;
  transition:
    transform var(--dur-slow) var(--ease-standard),
    opacity var(--dur-base) var(--ease-standard);
}

.downloads-btn.is-active .downloads-bar {
  background: color-mix(in srgb, currentColor 35%, transparent);
}

.downloads-btn.is-active .downloads-bar-fill {
  opacity: 1;
}

/* A download broke off since the list was last opened. */
.downloads-btn.is-attention {
  color: var(--download-attention);
}

.downloads-btn.is-attention .downloads-bar-fill {
  background: var(--download-attention);
}

/* One finished: the bar fills green and the arrow nods once, then everything settles back. */
.downloads-btn.is-done {
  animation: downloads-done 1.2s var(--ease-standard);
}

.downloads-btn.is-done .downloads-arrow {
  animation: downloads-nod 420ms var(--ease-pop);
}

@keyframes downloads-done {
  0%,
  70% {
    color: var(--download-done);
  }
}

@keyframes downloads-nod {
  40% {
    transform: translateY(2px);
  }
}

/* ---- The list ---- */

.popover.downloads-menu {
  width: 24rem;
  max-width: calc(100vw - 16px);
  padding: 4px 0 6px;
}

.downloads-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 8px 6px 14px;
}

.downloads-heading {
  margin: 0;
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
}

.downloads-list {
  max-height: min(24rem, calc(100dvh - 120px));
  margin: 0;
  padding: 0 6px;
  overflow-y: auto;
  overscroll-behavior: contain;
  list-style: none;
}

.download-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.download-icon {
  display: grid;
  place-items: center;
  color: var(--text-muted);
}

.download-row.is-broken .download-icon {
  color: var(--lvl-warn);
}

.download-main {
  min-width: 0;
}

.download-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: var(--weight-semibold);
}

.download-status {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.download-progress {
  position: relative;
  display: block;
  height: 3px;
  margin-top: 6px;
  border-radius: 2px;
  overflow: hidden;
  background: var(--surface-2);
}

.download-progress-fill {
  position: absolute;
  inset: 0;
  background: var(--accent);
  transform: scaleX(var(--downloads-progress, 0));
  transform-origin: left center;
  transition: transform var(--dur-slow) var(--ease-standard);
}

.download-row.is-paused .download-progress-fill {
  background: var(--text-muted);
}

.download-actions {
  display: flex;
  gap: 2px;
}

/* The actions come up under the pointer or the keyboard; on touch screens they always show. */
@media (hover: hover) and (pointer: fine) {
  .download-row:hover {
    background: var(--surface-2);
  }

  .download-actions {
    opacity: 0;
    transition: opacity var(--dur-fast) var(--ease-standard);
  }

  .download-row:hover .download-actions,
  .download-row:focus-within .download-actions {
    opacity: 1;
  }
}

.download-row:focus-within {
  background: var(--surface-2);
}

@media (prefers-reduced-motion: reduce) {
  .downloads-bar-fill,
  .download-progress-fill {
    transition: opacity var(--dur-base) var(--ease-standard);
  }

  .downloads-btn.is-done .downloads-arrow {
    animation: none;
  }
}
/* ---- A first sync's progress under the top bar ---- */

.first-sync-bar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.first-sync-text {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 12px;
  font-size: var(--text-xs);
  color: var(--text-muted);
  white-space: nowrap;
}

.first-sync-text > :first-child {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.first-sync-count {
  flex: none;
  font-variant-numeric: tabular-nums;
}

.first-sync-track {
  height: 2px;
  overflow: hidden;
}

.first-sync-fill {
  /* The core's number, set on the element. */
  --first-sync-fraction: 0;
  height: 100%;
  background: var(--accent);
  transform: scaleX(var(--first-sync-fraction));
  transform-origin: left;
  transition: transform var(--dur-fast) var(--ease-standard);
}

.first-sync-bar.is-indeterminate .first-sync-fill {
  width: 30%;
  transform: none;
  transition: none;
  animation: first-sync-slide 1.4s var(--ease-standard) infinite;
}

/* While the connection is down the banner above says why nothing moves. */
.app:has(.connection-hint:not(.is-slow), .connection-notice) .first-sync-row {
  display: none;
}

@keyframes first-sync-slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(340%);
  }
}

@media (prefers-reduced-motion: reduce) {
  .first-sync-bar.is-indeterminate .first-sync-fill {
    width: 100%;
    opacity: 0.4;
    animation: none;
  }
}
/* ---- A channel's shared notes: the Notes tab (#1221) ---- */

.channel-canvas {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  animation: motion-view-in var(--dur-fast) var(--ease-standard);
}

.canvas-view {
  width: 100%;
  max-width: 760px;
  margin: 0 auto;
  padding: var(--space-4) var(--space-4) var(--space-8);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.canvas-bar {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: var(--space-2);
  background: var(--surface);
}

.canvas-toolbar {
  flex: 1 1 auto;
  padding: 0;
}

.canvas-toolbar .format-btn[aria-disabled="true"] {
  opacity: 0.45;
}

.canvas-toolbar .format-style-menu {
  left: 0;
  right: auto;
  top: calc(100% + 6px);
  bottom: auto;
  width: 220px;
}

.canvas-link-dialog {
  flex: 1 1 100%;
  margin: 0;
}

.canvas-history-button {
  margin-left: auto;
  flex: none;
}

.canvas-note {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.canvas-page {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* The page gives way to the version history; `display: flex` above would keep it on screen. */
.canvas-page[hidden] {
  display: none;
}

.canvas-block {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.canvas-marker {
  flex: none;
  min-width: 1.25rem;
  padding-top: 5px;
  text-align: right;
  color: var(--text-muted);
  font-size: var(--text-md);
  font-variant-numeric: tabular-nums;
  user-select: none;
}

.canvas-check {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 7px 2px 0 4px;
  accent-color: var(--accent);
}

.canvas-input {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text);
  font: inherit;
  font-size: var(--text-md);
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 1.5em;
  outline: none;
}

textarea.canvas-input {
  resize: none;
  overflow: hidden;
  field-sizing: content;
}

.canvas-input[contenteditable="true"]:hover {
  background: var(--surface-2);
}

.canvas-input:focus-visible {
  outline: none;
  border-color: var(--accent);
  background: var(--surface);
}

.canvas-input[contenteditable="false"] {
  cursor: text;
}

.canvas-block-heading .canvas-input {
  padding-top: var(--space-3);
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
}

.canvas-block-heading2 .canvas-input {
  padding-top: var(--space-2);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
}

.canvas-block-heading3 .canvas-input {
  padding-top: var(--space-1);
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  line-height: 1.3;
}

.canvas-block-quote .canvas-input {
  border-radius: 0;
  border-inline-start: 3px solid var(--border-strong);
  color: var(--text-muted);
}

.canvas-block-code .canvas-input {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  background: var(--code-bg);
  font: var(--text-xs)/1.5 var(--font-mono);
}

.canvas-block-code .canvas-input[contenteditable="true"]:hover {
  background: var(--code-bg);
}

.canvas-input .canvas-link {
  text-decoration: underline;
}

/* A done item is crossed out, the box says so too. */
.canvas-block-check:has(.canvas-check:checked) .canvas-input {
  color: var(--text-muted);
  text-decoration: line-through;
}

.canvas-first {
  min-height: 6rem;
  border-color: var(--border);
}

/* Who else is editing, from the page's recent edits (#1245). */
.canvas-presence {
  margin: 0;
  font-size: var(--text-xs);
  color: var(--accent);
}

.canvas-presence:empty {
  display: none;
}

/* ---- Version history of the notes (#1245) ---- */

.canvas-history {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.canvas-history-empty {
  margin: 0;
  color: var(--text-muted);
}

.canvas-history-body {
  display: flex;
  align-items: flex-start;
  gap: var(--space-4);
}

.canvas-versions {
  flex: none;
  width: 14rem;
  max-height: 60vh;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.canvas-version {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px var(--space-2);
  cursor: pointer;
}

.canvas-version:hover {
  background: var(--surface-2);
}

.canvas-version:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.canvas-version[aria-pressed="true"] {
  background: var(--surface-2);
  border-color: var(--border);
}

.canvas-version-when {
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  font-variant-numeric: tabular-nums;
}

.canvas-version-who {
  flex-basis: 100%;
  font-size: var(--text-xs);
  color: var(--text-muted);
  overflow-wrap: anywhere;
}

.canvas-version-current {
  font-size: var(--text-xs);
  color: var(--accent);
}

.canvas-history-preview {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.canvas-preview {
  padding: var(--space-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
}

.canvas-preview-text {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  min-height: 1.5em;
}

.canvas-history-actions {
  display: flex;
  justify-content: flex-end;
}

@media (max-width: 640px) {
  .canvas-history-body {
    flex-direction: column;
  }

  .canvas-versions {
    width: 100%;
    max-height: 30vh;
  }
}

/* ---- Pages, moving blocks and files in the notes (#1456) ---- */

.canvas-page-editor {
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
}

.canvas-pages {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

/* One row that scrolls sideways at phone width instead of wrapping into several. */
.canvas-page-tabs {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  gap: 2px;
  overflow-x: auto;
  scrollbar-width: none;
}

.canvas-page-tab {
  flex: none;
  max-width: 14rem;
  padding: var(--space-1) var(--space-3);
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  font: inherit;
  font-size: var(--text-sm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: pointer;
}

.canvas-page-tab:hover {
  background: var(--surface-2);
  color: var(--text);
}

.canvas-page-tab:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.canvas-page-tab[aria-selected="true"] {
  background: var(--surface-2);
  color: var(--text);
  font-weight: var(--weight-semibold);
}

.canvas-page-actions {
  flex: none;
  display: flex;
  gap: 2px;
}

.canvas-page-dialog {
  flex: 1 1 100%;
  margin: 0;
}

.canvas-page-dialog-title {
  margin: 0;
  font-weight: var(--weight-semibold);
  overflow-wrap: anywhere;
}

/* The handle shows where the pointer or the focus is; touch screens always show it. */
.canvas-handle {
  flex: none;
  width: 20px;
  height: 28px;
  margin-top: 2px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text-muted);
  display: grid;
  place-items: center;
  cursor: grab;
  opacity: 0;
  touch-action: none;
  transition: opacity var(--dur-fast) var(--ease-standard);
}

.canvas-block:hover .canvas-handle,
.canvas-block:focus-within .canvas-handle,
.canvas-handle:focus-visible {
  opacity: 1;
}

.canvas-handle:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

@media (hover: none) {
  .canvas-handle {
    opacity: 0.6;
  }
}

.canvas-page.is-dragging,
.canvas-page.is-dragging .canvas-handle {
  cursor: grabbing;
  user-select: none;
}

.canvas-block {
  position: relative;
}

/* The dragged block follows the pointer 1:1 (its transform is set while dragging), lifted. */
.canvas-block.is-dragged {
  z-index: 2;
  opacity: 0.85;
  border-radius: var(--radius-xs);
  background: var(--surface);
  box-shadow: var(--shadow);
}

/* Where it lands: a line in the gap. */
.canvas-block.is-drop-before::before,
.canvas-block.is-drop-after::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 2px;
  border-radius: 1px;
  background: var(--accent);
  pointer-events: none;
}

.canvas-block.is-drop-before::before {
  top: -2px;
}

.canvas-block.is-drop-after::after {
  bottom: -2px;
}

.canvas-embed {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  outline: none;
}

.canvas-embed:focus-visible {
  border-color: var(--accent);
}

.canvas-file .msg-files {
  margin: 0;
}

.canvas-file-missing {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.canvas-file-name {
  min-width: 0;
  overflow-wrap: anywhere;
  color: var(--text);
}

.canvas-file-picker {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
}

.canvas-file-picker-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
}

.canvas-file-picker-head h3 {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.canvas-file-list {
  max-height: 40vh;
  margin: 0;
  padding: 0;
  list-style: none;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.canvas-file-choice {
  width: 100%;
  padding: var(--space-2);
  border: 1px solid transparent;
  border-radius: var(--radius-xs);
  background: transparent;
  color: var(--text);
  font: inherit;
  text-align: left;
  display: flex;
  align-items: center;
  gap: var(--space-2);
  cursor: pointer;
}

.canvas-file-choice:hover {
  background: var(--surface-2);
}

.canvas-file-choice:focus-visible {
  outline: none;
  border-color: var(--accent);
}

.canvas-file-choice .canvas-file-name {
  flex: 1;
}

.canvas-file-size {
  flex: none;
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

@media (prefers-reduced-motion: reduce) {
  .canvas-handle {
    transition: none;
  }

  /* No travelling block: the line alone shows where it lands. */
  .canvas-block.is-dragged {
    transform: none !important;
  }
}

/* Under the tabs, on a line of its own, when no page can be added. */
.canvas-pages-full {
  flex: 1 1 100%;
}
/* The system health page of the admin console (issue #213) and its badges. */

.health-summary {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
}
.health-summary .icon { flex: none; margin-top: 2px; color: var(--online); }
.health-summary p { margin: 2px 0 0; }
.health-summary-alert {
  border-color: var(--danger);
  background: var(--danger-soft);
}
.health-summary-alert .icon { color: var(--danger); }
.health-summary-failing { border-color: var(--warn-text); background: var(--warn-soft); }
.health-summary-failing .icon { color: var(--warn-text); }

.health-checks,
.health-alert-list {
  display: grid;
  gap: 0;
  margin: 0;
  padding: 0;
  list-style: none;
}
.health-check {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 0;
  border-top: 1px solid var(--border);
}
.health-check:first-child { border-top: 0; }
.health-check-text {
  display: grid;
  gap: 2px;
  min-width: 0;
  overflow-wrap: anywhere;
}
.health-check .badge {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  white-space: nowrap;
}
.health-check .badge .icon { width: 12px; height: 12px; }
.badge-health-ok { background: var(--accent-soft); color: var(--accent-strong); }
.badge-health-failing { background: var(--warn-soft); color: var(--warn-text); }
.badge-health-alert { background: var(--danger); color: var(--on-danger); }
.badge-health-no-data,
.badge-health-not-configured { background: var(--surface-3); color: var(--text-muted); }
.health-check-not-configured .health-check-text > strong { color: var(--text-muted); }

.health-alert-list li { padding: 8px 0; border-top: 1px solid var(--border); }
.health-alert-list li:first-child { border-top: 0; }

.oidc-sync-held {
  display: grid;
  gap: 4px;
  margin: 8px 0;
  padding: 0;
  list-style: none;
  overflow-wrap: anywhere;
}
.oidc-sync-run {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 4px 16px;
  margin: 0 0 12px;
}
.oidc-sync-run dt { color: var(--text-muted); }
.oidc-sync-run dd { margin: 0; overflow-wrap: anywhere; }
.oidc-sync-preview { margin-top: 12px; }

.admin-nav-item .badge-count { margin-inline-start: auto; }
.menu-item .badge-count { margin-inline-start: auto; }

.admin-content .instance-card + .instance-card { margin-top: 16px; }

@media (max-width: 480px) {
  .health-check { flex-direction: column-reverse; align-items: flex-start; gap: 6px; }
}
/* The directory (#298): five tabs that may not fit a phone, and the people grid. */

.directory .panel-header {
  flex-wrap: wrap;
}

/* The title keeps its width; the tabs move below it instead. */
.directory .panel-title {
  flex-shrink: 0;
}

.directory .segmented {
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.directory .segmented button {
  flex: none;
}

.directory-tools {
  flex-wrap: wrap;
}

.directory-tools .page-search {
  flex-basis: 220px;
}

.directory-tools .page-select {
  flex: 0 1 auto;
  max-width: 200px;
}

.directory-invite {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  flex: none;
}

.people-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--space-3);
  list-style: none;
  margin: 0;
  padding: 0;
}

.people-grid:empty {
  display: none;
}

.person-card {
  position: relative;
  display: flex;
  flex-direction: column;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
  transition: background-color 120ms ease-out;
}

.person-card-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-1);
  min-width: 0;
  padding: var(--space-4) var(--space-3) var(--space-3);
  border: 0;
  border-radius: inherit;
  background: none;
  color: inherit;
  text-align: center;
  transition: transform 100ms ease-out;
}

.person-card-main:active {
  transform: scale(0.98);
}

.person-card-main .avatar {
  margin-bottom: var(--space-2);
}

.person-card-name {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
}

.person-card-facts,
.person-card-presence {
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-muted);
  font-size: var(--text-sm);
}

.person-card-facts:empty {
  display: none;
}

.person-card-badges {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: var(--space-1);
}

.person-card-badges:empty {
  display: none;
}

.person-card-actions {
  display: flex;
  justify-content: center;
  gap: var(--space-1);
  padding: 0 var(--space-3) var(--space-3);
}

@media (hover: hover) and (pointer: fine) {
  .person-card:hover,
  .person-card:focus-within {
    background: var(--surface-2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .person-card-main:active {
    transform: none;
  }
}

.directory-channel,
.directory-invitation {
  flex-wrap: wrap;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
}

.directory-row-text {
  flex-basis: 200px;
}

.directory-invitation-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.directory-more {
  display: flex;
  justify-content: center;
  padding: var(--space-4) 0;
  text-align: center;
}

.directory-offline {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  margin-bottom: var(--space-3);
  color: var(--text-muted);
  font-size: var(--text-sm);
}
/* Editing a picture before it is sent (#1354): dark over the whole window like a photo viewer, the
   crop frame dims what is cut away with its own shadow, corners large enough for a finger. */
.picture-editor {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  flex-direction: column;
  background: var(--lightbox-bg);
  color: var(--lightbox-text);
}

.picture-editor-stage {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.picture-editor-picture {
  position: relative;
  max-width: 100%;
  max-height: 100%;
  overflow: hidden;
  touch-action: none;
  user-select: none;
}

.picture-editor-image {
  display: block;
  max-width: 100%;
  max-height: calc(100vh - 140px);
  pointer-events: none;
}

.picture-editor-frame {
  position: absolute;
  box-sizing: border-box;
  border: 1px solid var(--on-fill);
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 55%);
  cursor: move;
  outline-offset: 3px;
}

.picture-editor-handle {
  position: absolute;
  width: 22px;
  height: 22px;
  border: 3px solid var(--on-fill);
}

.picture-editor-handle.is-top-left { top: -3px; left: -3px; border-right: 0; border-bottom: 0; cursor: nwse-resize; }
.picture-editor-handle.is-top-right { top: -3px; right: -3px; border-left: 0; border-bottom: 0; cursor: nesw-resize; }
.picture-editor-handle.is-bottom-left { bottom: -3px; left: -3px; border-right: 0; border-top: 0; cursor: nesw-resize; }
.picture-editor-handle.is-bottom-right { bottom: -3px; right: -3px; border-left: 0; border-top: 0; cursor: nwse-resize; }

.picture-editor-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
}

.picture-editor-bar .btn:not(.btn-primary),
.picture-editor-bar .icon-btn {
  color: var(--lightbox-text);
}

.picture-editor-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

.picture-editor-failed {
  max-width: 32em;
  text-align: center;
}

/* The chip of a picture opens the editor. */
.chip-thumb-button {
  display: inline-flex;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  border-radius: var(--radius-sm);
}
/* ---- Report a problem (docs/bug-reports.md, #1362) ---- */

/* Wide enough for the log lines of the preview; a bottom sheet on a phone like every dialog. */
.report-dialog {
  width: min(620px, 100%);
}

.report-description {
  resize: vertical;
  min-height: 7.5em;
}

.report-screenshot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  border-radius: var(--radius-sm);
}

.report-screenshot-label {
  flex-basis: 100%;
  font-weight: var(--weight-semibold);
}

.report-screenshot-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.report-preview {
  margin-top: var(--space-4);
}

.report-preview summary {
  cursor: pointer;
  font-weight: var(--weight-semibold);
}

/* Exactly the text that is sent: monospace, scrolled within, never wider than the dialog. */
.report-text {
  max-height: 16rem;
  margin: var(--space-2) 0 0;
  padding: var(--space-3);
  overflow: auto;
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  line-height: 1.45;
  white-space: pre;
}

.report-alert {
  margin: var(--space-3) 0 0;
  color: var(--danger);
  font-size: var(--text-sm);
}
/* Several accounts in the desktop app (#214): the account menu's entries, the badge on the account
   button, the accounts dialog and the way back to them on the sign-in screens. */

.account-item .badge-count,
.account-item .unread-dot {
  flex: none;
}

/* Another account has something unread: on the account button's corner, over the avatar. */
.account-others-badge {
  position: absolute;
  top: -2px;
  right: -4px;
  pointer-events: none;
  box-shadow: 0 0 0 2px var(--surface);
}

.accounts-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: var(--space-3) 0 0;
  padding: 0;
  list-style: none;
}

.accounts-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2) var(--space-3);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.accounts-name {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  overflow-wrap: anywhere;
}

.accounts-name small {
  font-size: var(--text-xs);
}

.accounts-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.accounts-confirm {
  flex-basis: 100%;
  font-size: var(--text-sm);
}

.auth-accounts {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin-top: var(--space-5);
  text-align: center;
}

.auth-account {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  flex-wrap: wrap;
  overflow-wrap: anywhere;
}
/* Polls in messages and the dialog that makes them (issue #205). Every bar carries its count and
   share as text next to it: the bar only repeats what the numbers say. */

.poll {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  max-width: 28rem;
  margin-top: var(--space-1);
  padding: var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.poll-head {
  display: flex;
  align-items: flex-start;
  gap: var(--space-2);
}

.poll-icon {
  display: inline-flex;
  flex: none;
  margin-top: 2px;
  color: var(--accent-strong);
}

.poll-question {
  margin: 0;
  font-size: var(--text-md);
  font-weight: var(--weight-semibold);
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.poll-mode {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.poll-options {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0;
  padding: 0;
  list-style: none;
}

.poll-option {
  --poll-share: 0;
  display: grid;
  grid-template-columns: 1.25rem minmax(0, 1fr) auto;
  grid-template-rows: auto 4px;
  align-items: center;
  column-gap: var(--space-2);
  row-gap: 6px;
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: transparent;
  color: inherit;
  text-align: start;
}

@media (hover: hover) and (pointer: fine) {
  .poll-option:not(:disabled):hover {
    border-color: var(--text-muted);
  }
}

.poll-option:not(:disabled):active {
  transform: scale(0.99);
}

/* Results stay readable where nobody may vote (closed, no right to): not pressable, not dimmed. */
.poll-option:disabled {
  cursor: default;
  opacity: 1;
  color: inherit;
}

.poll-option.is-chosen {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.poll-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border: 1.5px solid var(--text-muted);
  border-radius: var(--radius-pill);
  color: var(--surface);
}

.poll-option.is-chosen .poll-mark {
  border-color: var(--accent);
  background: var(--accent);
}

.poll-mark svg {
  width: 0.875rem;
  height: 0.875rem;
}

.poll-option-text {
  overflow-wrap: anywhere;
}

.poll-option.is-leader .poll-option-text {
  font-weight: var(--weight-semibold);
}

.poll-option-count {
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

/* Counts held back until the user votes or the poll closes: no empty bar row. */
.poll-options:not(.is-counting) .poll-option {
  grid-template-rows: auto;
}

.poll-bar {
  grid-column: 2 / 4;
  height: 4px;
  overflow: hidden;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
}

.poll-bar-fill {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--accent);
  transform: scaleX(var(--poll-share));
  transform-origin: left center;
}

.poll-voters {
  margin: 4px 0 0 calc(1.25rem + var(--space-2) + var(--space-3));
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
  overflow-wrap: anywhere;
}

.poll-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-2);
  color: var(--text-muted);
  font-size: var(--text-xs);
  letter-spacing: var(--tracking-xs);
}

.poll-total {
  display: inline-flex;
  gap: var(--space-2);
  font-variant-numeric: tabular-nums;
}

.poll-closed {
  font-weight: var(--weight-semibold);
}

.poll-close-confirm {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-2);
}

.poll-edit-options {
  margin: var(--space-3) 0;
  padding: 0;
  border: 0;
}

.poll-edit-options legend {
  margin-bottom: var(--space-1);
  padding: 0;
}

.poll-edit-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  margin: 0 0 var(--space-2);
  padding: 0;
  list-style: none;
}

.poll-edit-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

.poll-edit-row .input {
  flex: 1;
  min-width: 0;
}

/* The question's label above its field, which takes the dialog's width. */
.poll-dialog .modal-body > label[for] {
  display: block;
  margin-bottom: var(--space-1);
}

.poll-dialog .modal-body > .input {
  width: 100%;
}
