/* Flower — стили мессенджера. Дизайн-токены через CSS-переменные.
   Острые края везде (border-radius: 0), Geist sans, OKLCH-палитра, mobile-first. */

:root {
  /* Тема (по умолчанию — тёмная mint) */
  --bg: #0e1013;
  --surface: #161a1f;
  --surface-2: #1d2127;
  --surface-3: #252a31;
  --border: #262b32;
  --border-2: #2f353d;
  --text: #ecedee;
  --text-2: #c9ccd1;
  --muted: #7a818a;
  --muted-2: #5a6068;
  --inverse: #0e1013;
  --danger: oklch(0.68 0.18 25);
  --warn: oklch(0.78 0.15 80);

  /* Акцент */
  --accent: oklch(0.78 0.12 165);
  --accent-soft: oklch(0.78 0.12 165 / 0.12);
  --accent-strong: oklch(0.72 0.13 165);
  --accent-ink: #06130f;

  /* Типографика */
  --fs-xs: 11px;
  --fs-sm: 13px;
  --fs-md: 15px;
  --fs-lg: 17px;
  --fs-xl: 22px;
  --fs-2xl: 28px;
  --lh: 1.4;

  /* Плотность */
  --row-h: 64px;
  --pad: 20px;
  --pad-sm: 14px;
  --pad-lg: 24px;
  --gap: 10px;
  --hit: 48px;

  /* Радиусы баблов */
  --bubble-radius: 14px;
  --bubble-tail: 4px;

  --shadow-1: 0 1px 0 rgba(255,255,255,0.02) inset, 0 8px 30px rgba(0,0,0,0.35);

  color-scheme: dark;
  font-family: 'Geist', 'Manrope', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* === Размер шрифта S/M/L/XL === */
.fs-s {
  --fs-xs: 10px; --fs-sm: 12px; --fs-md: 13px; --fs-lg: 15px; --fs-xl: 19px; --fs-2xl: 24px;
}
.fs-l {
  --fs-xs: 12px; --fs-sm: 14px; --fs-md: 17px; --fs-lg: 19px; --fs-xl: 24px; --fs-2xl: 30px;
}
.fs-xl {
  --fs-xs: 13px; --fs-sm: 15px; --fs-md: 19px; --fs-lg: 22px; --fs-xl: 27px; --fs-2xl: 34px;
  --row-h: 76px;
}

/* === Плотность === */
.density-compact {
  --row-h: 56px; --pad: 16px; --pad-sm: 10px; --pad-lg: 18px; --gap: 8px;
}
.density-spacious {
  --row-h: 72px; --pad: 24px; --pad-sm: 18px; --pad-lg: 28px; --gap: 12px;
}

/* === Светлая тема === */
.theme-light {
  --bg: #f7f7f5;
  --surface: #ffffff;
  --surface-2: #f1f1ef;
  --surface-3: #e8e8e6;
  --border: #e2e2df;
  --border-2: #d1d1ce;
  --text: #16181b;
  --text-2: #2c3036;
  --muted: #6b7079;
  --muted-2: #8a8e95;
  --inverse: #ffffff;
  --accent-ink: #06130f;
  --shadow-1: 0 1px 0 rgba(0,0,0,0.02) inset, 0 6px 18px rgba(15,15,15,0.06);
  color-scheme: light;
}

/* === Акценты OKLCH === */
.accent-mint   { --accent: oklch(0.78 0.12 165); --accent-soft: oklch(0.78 0.12 165 / 0.12); --accent-strong: oklch(0.72 0.13 165); --accent-ink: #06130f; }
.accent-sky    { --accent: oklch(0.78 0.12 230); --accent-soft: oklch(0.78 0.12 230 / 0.14); --accent-strong: oklch(0.72 0.13 230); --accent-ink: #051324; }
.accent-coral  { --accent: oklch(0.78 0.13 25);  --accent-soft: oklch(0.78 0.13 25 / 0.14);  --accent-strong: oklch(0.72 0.14 25);  --accent-ink: #2a0808; }
.accent-amber  { --accent: oklch(0.82 0.14 80);  --accent-soft: oklch(0.82 0.14 80 / 0.14);  --accent-strong: oklch(0.76 0.15 80);  --accent-ink: #221306; }
.accent-lavender{ --accent: oklch(0.78 0.12 295); --accent-soft: oklch(0.78 0.12 295 / 0.14); --accent-strong: oklch(0.72 0.13 295); --accent-ink: #1a0a24; }
.accent-slate  { --accent: oklch(0.78 0.04 240); --accent-soft: oklch(0.78 0.04 240 / 0.14); --accent-strong: oklch(0.72 0.05 240); --accent-ink: #0c1218; }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-size: var(--fs-md);
  line-height: var(--lh);
  letter-spacing: -0.005em;
  -webkit-font-smoothing: antialiased;
}

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

:where(button) {
  background: transparent;
  border: 0;
  padding: 0;
  cursor: pointer;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 100ms ease, color 100ms ease, border-color 100ms ease, opacity 100ms ease;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 12px 13px;
  outline: 0;
  border-radius: 0;
  resize: none;
}

input::placeholder, textarea::placeholder { color: var(--muted-2); }

input:focus, textarea:focus, select:focus { border-color: var(--accent); }

button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:disabled { opacity: 0.55; cursor: not-allowed; }

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
label input, label textarea { text-transform: none; }

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

code, .mono {
  font-family: 'Geist Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* === Кнопки === */
.primary, .send-btn, .secondary, .danger {
  min-height: var(--hit);
  padding: 0 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid transparent;
  font-weight: 700;
  letter-spacing: 0.01em;
  font-size: var(--fs-md);
}
.primary, .send-btn {
  background: var(--accent);
  color: var(--accent-ink);
}
.primary:hover, .send-btn:hover { background: var(--accent-strong); }
.secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--text);
}
.secondary:hover { background: var(--surface-2); }
.danger {
  background: oklch(from var(--danger) calc(l - 0.2) c h);
  color: #ffe6e8;
  border-color: var(--danger);
}

.icon-btn {
  width: var(--hit);
  height: var(--hit);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--surface-2); }
.icon-btn:active { background: var(--surface-3); }
.icon-btn.muted { color: var(--muted); }

svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.6;
  stroke-linecap: square;
  stroke-linejoin: miter;
}

/* === Состояния === */
.error {
  min-height: 18px;
  color: var(--danger);
  font-size: var(--fs-sm);
}

.notice {
  min-height: 18px;
  color: var(--muted);
  font-size: var(--fs-sm);
}
.notice.success { color: var(--accent); }
.notice.error { color: var(--danger); }

/* === Транспорт-статус (бейдж сверху) === */
.transport-status {
  position: fixed;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  min-height: 24px;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  padding: 0 10px;
  font-size: var(--fs-xs);
  font-weight: 700;
  letter-spacing: 0.03em;
  pointer-events: none;
  text-transform: uppercase;
}
.transport-status::before {
  content: "";
  width: 7px; height: 7px;
  background: currentColor;
}
.transport-status.online { color: var(--accent); opacity: 0.85; }
.transport-status.degraded { color: var(--warn); }
.transport-status.reconnecting, .transport-status.offline { color: var(--danger); }

/* === Каркас приложения === */
.app-shell {
  height: 100dvh;
  min-height: 100vh;
  display: grid;
  grid-template-rows: 1fr auto;
  background: var(--bg);
  overflow: hidden;
}
@media (min-width: 880px) {
  .app-shell {
    width: min(440px, 100%);
    margin: 0 auto;
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
  }
}

.main {
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.scroll { flex: 1; min-height: 0; overflow-y: auto; }
.scroll::-webkit-scrollbar { width: 0; }

/* === Шапка экрана === */
.content-header,
.chat-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px var(--pad);
  background: var(--bg);
  min-height: 56px;
  flex-shrink: 0;
}
.chat-header { border-bottom: 1px solid var(--border); }

.content-header { padding-top: calc(10px + env(safe-area-inset-top)); display: grid; grid-template-columns: 1fr auto; align-items: end; }
.content-header h1, .chat-header h1 {
  font-size: var(--fs-xl);
  font-weight: 700;
  letter-spacing: -0.02em;
}
.content-header p, .chat-header p {
  color: var(--muted);
  font-size: var(--fs-xs);
}
.chat-header h1 { font-size: var(--fs-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-header { display: grid; grid-template-columns: var(--hit) minmax(0, 1fr) auto; gap: 6px; }
.chat-actions { display: flex; gap: 0; }

/* === Аватарка / инициалы (острая) === */
.avatar {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: var(--surface-3);
  color: var(--accent-ink);
  font-weight: 700;
  font-size: var(--fs-sm);
  letter-spacing: 0.02em;
  flex-shrink: 0;
  position: relative;
}
.avatar.lg { width: 84px; height: 84px; font-size: var(--fs-xl); }
.avatar.xl { width: 120px; height: 120px; font-size: var(--fs-2xl); }
.avatar.sm { width: 36px; height: 36px; font-size: var(--fs-xs); }

/* === Список чатов === */
.search-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 4px var(--pad) 6px;
  padding: 0 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  min-height: 44px;
}
.search-bar input {
  border: 0;
  background: transparent;
  padding: 10px 0;
}

.conversation-list, .contact-list {
  display: flex;
  flex-direction: column;
}
.conversation-row, .contact-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 14px;
  padding: var(--pad-sm) var(--pad);
  min-height: var(--row-h);
  align-items: center;
  text-align: left;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  width: 100%;
}
.conversation-row:hover, .contact-row:hover {
  background: var(--surface);
}
.conversation-row .body { min-width: 0; display: grid; gap: 4px; min-height: 0; }
.conversation-row strong, .contact-row strong {
  font-size: var(--fs-lg);
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.conversation-row small, .contact-row small {
  font-size: var(--fs-sm);
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat-row-actions {
  display: flex;
  gap: 0;
}
.empty {
  padding: 40px 24px;
  text-align: center;
  color: var(--muted);
  font-size: var(--fs-sm);
}

/* === Нижняя навигация === */
.nav {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  background: var(--bg);
  border-top: 1px solid var(--border);
  padding: 0 10px calc(env(safe-area-inset-bottom));
}
.nav button {
  min-height: 64px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 500;
  letter-spacing: 0.02em;
  position: relative;
}
.nav button.active { color: var(--text); }
.nav button.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 25%; right: 25%;
  height: 2px;
  background: var(--accent);
}
.nav button svg { width: 24px; height: 24px; }

.sidebar { display: none; }
.side-header, .side-brand { display: none; }
.debug-panel {
  position: fixed;
  right: 12px;
  bottom: calc(74px + env(safe-area-inset-bottom));
  z-index: 80;
  width: min(360px, calc(100vw - 24px));
  max-height: 38vh;
  overflow: auto;
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--muted);
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: var(--fs-xs);
}

/* === Сообщения === */
.message-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  padding: 14px var(--pad) 14px;
  gap: 6px;
  background: var(--bg);
}

.message {
  max-width: 82%;
  padding: 9px 12px 7px;
  background: var(--surface-2);
  color: var(--text);
  border-radius: var(--bubble-radius);
  border-bottom-left-radius: var(--bubble-tail);
  align-self: flex-start;
  display: grid;
  gap: 2px;
  position: relative;
  word-break: break-word;
  font-size: var(--fs-md);
  line-height: 1.4;
}
.message.mine {
  background: var(--accent-soft);
  border: 1px solid color-mix(in oklch, var(--accent) 35%, transparent);
  align-self: flex-end;
  border-radius: var(--bubble-radius);
  border-bottom-right-radius: var(--bubble-tail);
}
.message small {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
  margin-bottom: 2px;
}
.message.mine small { display: none; }
.message p { line-height: 1.35; overflow-wrap: anywhere; margin: 0; }
.message-status {
  justify-self: end;
  min-width: 18px;
  font-size: var(--fs-xs);
  color: var(--muted);
  user-select: none;
}
.message-status.delivered, .message-status.read { color: var(--accent); }

.missing-key {
  display: grid;
  gap: 4px;
  border: 1px dashed color-mix(in oklch, var(--accent) 55%, transparent);
  background: var(--accent-soft);
  padding: 9px;
}
.missing-key strong { color: var(--accent); font-size: var(--fs-sm); }
.missing-key span { color: var(--muted); font-size: var(--fs-xs); line-height: 1.3; }

.message-image {
  max-width: min(360px, 100%);
  max-height: 420px;
  object-fit: contain;
}
.message-audio { width: min(320px, 72vw); }
.media-download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  padding: 0 12px;
  text-decoration: none;
  font-weight: 600;
}
.message-image-preview {
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: zoom-in;
  max-width: 100%;
}
.message-image-preview img {
  display: block;
  max-width: 320px;
  max-height: 320px;
  width: auto;
  height: auto;
  object-fit: cover;
  filter: blur(0);
  transition: filter 120ms ease;
}
.message-image-preview.loading-full img {
  filter: blur(2px) brightness(0.85);
}
.image-placeholder { gap: 8px; }
.image-placeholder::before {
  content: "";
  width: 8px;
  height: 8px;
  background: var(--accent);
}
.image-placeholder.loading::before {
  animation: pulse 900ms ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 0.35; }
  50% { opacity: 1; }
}

/* === Композер === */
.composer {
  display: grid;
  grid-template-columns: var(--hit) minmax(0, 1fr) var(--hit);
  align-items: end;
  gap: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 4px;
  margin: 8px var(--pad-sm) calc(10px + env(safe-area-inset-bottom));
  min-height: 56px;
}
.composer textarea {
  border: 0;
  background: transparent;
  padding: 12px 6px;
  font-size: var(--fs-md);
  line-height: 1.4;
  max-height: 120px;
  min-height: 40px;
}
.composer textarea:focus { border: 0; }

.composer .icon-btn.recording { color: var(--accent); background: var(--surface-2); }
.composer:not(.has-text) .send-btn { display: none; }
.composer.has-text [data-record-audio] { display: none; }

.attach-menu {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 8px var(--pad-sm);
  background: var(--surface);
  border-top: 1px solid var(--border);
}
.attach-menu[hidden] { display: none; }
.attach-menu button {
  min-height: 76px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: var(--fs-xs);
}
.attach-menu button:hover { background: var(--surface-3); }

.send-btn {
  background: var(--accent);
  color: var(--accent-ink);
  width: var(--hit);
  height: var(--hit);
  padding: 0;
}
.send-btn:disabled { opacity: 0.55; cursor: wait; }

.composer-error {
  grid-column: 1 / -1;
  min-height: 0;
  color: var(--danger);
  font-size: var(--fs-xs);
  padding: 0 6px;
}

.media-draft {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.media-draft small {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.media-draft img { width: 48px; height: 48px; object-fit: cover; }
.media-draft audio { width: 100%; }

/* === Звонок overlay === */
.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 40;
  background:
    radial-gradient(circle at 20% 30%, oklch(0.3 0.08 240) 0%, transparent 50%),
    radial-gradient(circle at 80% 70%, oklch(0.35 0.06 180) 0%, transparent 50%),
    var(--bg);
  color: var(--text);
  display: grid;
  grid-template-rows: 1fr auto;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}
.call-overlay > div:first-of-type:not(.call-actions):not(.call-video-stage) {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 32px var(--pad);
  text-align: center;
}
.call-overlay strong { font-size: var(--fs-2xl); font-weight: 700; letter-spacing: -0.02em; }
.call-overlay span { color: var(--muted); font-size: var(--fs-md); }

.call-video-stage {
  position: relative;
  flex: 1;
  background: #05080a;
  overflow: hidden;
}
.call-video-stage [data-remote-video] {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.call-video-stage [data-local-video] {
  position: absolute;
  right: 10px; bottom: 10px;
  width: min(34%, 150px);
  aspect-ratio: 3 / 4;
  object-fit: cover;
  border: 1px solid rgba(255,255,255,0.1);
}

.call-actions {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  padding: 20px var(--pad) 28px;
}
.call-overlay.incoming .call-actions {
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  padding: 24px var(--pad) 32px;
}
.call-btn {
  min-height: 64px;
  display: grid;
  place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
}
.call-btn.mute.active, .call-btn.video-toggle.active {
  background: var(--text);
  color: var(--inverse);
}
.call-btn.accept {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
  min-height: 72px;
}
.call-btn.end {
  background: var(--danger);
  color: #fff;
  border-color: var(--danger);
  min-height: 72px;
}
.call-output {
  grid-column: 1 / -1;
  display: grid;
  gap: 6px;
  padding: 0 var(--pad);
}
.call-output span { font-size: var(--fs-xs); color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.call-output select { background: var(--surface); }

.call-overlay.incoming, .call-overlay.calling {
  animation: call-pulse 1.6s ease-in-out infinite;
}
@keyframes call-pulse {
  0%, 100% { box-shadow: inset 0 0 0 0 color-mix(in oklch, var(--accent) 45%, transparent); }
  50% { box-shadow: inset 0 0 60px 4px color-mix(in oklch, var(--accent) 25%, transparent); }
}
@media (prefers-reduced-motion: reduce) {
  .call-overlay.incoming, .call-overlay.calling { animation: none; }
}

.call-toast {
  position: fixed;
  bottom: calc(80px + env(safe-area-inset-bottom));
  left: 16px;
  right: 16px;
  z-index: 41;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 12px 14px;
  text-align: center;
  font-size: var(--fs-sm);
}

/* === Авторизация / шлюзы === */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}
.auth-panel {
  width: min(420px, 100%);
  display: grid;
  gap: 18px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 28px;
}
.auth-panel h1 { font-size: var(--fs-2xl); letter-spacing: -0.02em; }
.auth-panel p { color: var(--muted); font-size: var(--fs-md); }
.migration-card {
  display: grid;
  gap: 6px;
  padding: 14px;
  border: 1px solid var(--border);
  background: var(--surface-2);
}
.migration-card strong {
  font-size: var(--fs-md);
}
.migration-card span {
  color: var(--muted);
  font-size: var(--fs-sm);
  line-height: 1.45;
}
.migration-link {
  text-decoration: none;
}
.brand-mark {
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  color: var(--accent);
}
form { display: grid; gap: 14px; }

/* === Панели настроек === */
.panel {
  display: grid;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  padding: 16px var(--pad);
  margin: 0 0 var(--gap);
}
.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}
.panel h2 {
  font-size: var(--fs-lg);
  font-weight: 700;
  letter-spacing: -0.01em;
}
.panel-note {
  color: var(--muted);
  font-size: var(--fs-sm);
}
.security-badge {
  display: inline-grid;
  min-height: 30px;
  place-items: center;
  padding: 0 10px;
  border: 1px solid var(--border);
  color: var(--muted);
  font-size: var(--fs-xs);
  font-weight: 700;
  white-space: nowrap;
}
.security-badge.ok {
  border-color: color-mix(in oklch, var(--accent), var(--border) 40%);
  color: var(--accent);
  background: var(--accent-soft);
}
.security-badge.warn {
  border-color: color-mix(in oklch, var(--danger), var(--border) 40%);
  color: var(--danger);
}

.device-row, .table-row, .invite-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.device-row:first-child, .table-row:first-child { border-top: 0; }
.device-row strong, .table-row strong {
  font-size: var(--fs-md);
  font-weight: 600;
}
.device-row small, .table-row small {
  display: block;
  font-size: var(--fs-xs);
  color: var(--muted);
}
.device-row-detailed {
  align-items: start;
}
.invite-box {
  grid-template-columns: 1fr;
  padding: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
}
code {
  display: block;
  overflow-x: auto;
  font-family: 'Geist Mono', ui-monospace, monospace;
  color: var(--accent);
  font-size: var(--fs-sm);
  letter-spacing: 0.02em;
}
.status {
  min-height: 26px;
  display: inline-grid;
  place-items: center;
  padding: 0 10px;
  font-size: var(--fs-xs);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}
.status.active { background: var(--accent-soft); color: var(--accent); }
.status.blocked { background: oklch(0.4 0.05 25 / 0.2); color: var(--danger); }

.key-package {
  min-height: 92px;
  font-family: 'Geist Mono', ui-monospace, monospace;
  font-size: var(--fs-xs);
}
.key-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.recovery-code-box {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 10px 0;
  padding: 12px;
  border: 1px solid var(--border, #2f2f2f);
  background: var(--surface, #161616);
}

.admin-user-devices {
  margin-bottom: 12px;
  padding: 8px 0;
  border-top: 1px solid var(--border, #2f2f2f);
}
.admin-user-devices:first-child { border-top: none; }
.admin-user-devices h3 {
  font-size: 0.95em;
  margin: 6px 0 8px;
  color: var(--muted, #aaa);
}

.avatar.has-image { padding: 0; overflow: hidden; }
.avatar.has-image img { width: 100%; height: 100%; object-fit: cover; display: block; }

.online-dot {
  display: inline-block;
  width: 8px; height: 8px;
  background: #5fd6b2;
  border-radius: 999px;
  vertical-align: middle;
  margin-left: 6px;
}

.profile-avatar-row {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 10px;
}
.profile-avatar-row .avatar { width: 64px; height: 64px; font-size: 24px; }
.profile-avatar-actions { display: flex; flex-wrap: wrap; gap: 6px; }

.reply-quote {
  display: block;
  width: 100%;
  text-align: left;
  border: none;
  border-left: 3px solid var(--accent, #5fd6b2);
  background: var(--surface-alt, rgba(95, 214, 178, 0.08));
  padding: 4px 8px;
  margin-bottom: 4px;
  cursor: pointer;
  color: inherit;
  font-family: inherit;
}
.reply-quote strong { display: block; font-size: 0.85em; color: var(--accent, #5fd6b2); }
.reply-quote span { display: block; font-size: 0.85em; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.message { position: relative; }
.message-reply-btn {
  position: absolute;
  top: 4px; right: 4px;
  background: transparent;
  border: none;
  padding: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 120ms;
  color: var(--muted, #888);
}
.message-reply-btn svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.message:hover .message-reply-btn { opacity: 1; }
.message.highlighted { animation: msg-flash 1.5s ease; }
@keyframes msg-flash {
  0%, 100% { background: transparent; }
  20%, 60% { background: rgba(95, 214, 178, 0.18); }
}

.reply-draft {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-left: 3px solid var(--accent, #5fd6b2);
  background: var(--surface-alt, rgba(95, 214, 178, 0.08));
}
.reply-draft div { flex: 1; min-width: 0; }
.reply-draft strong { display: block; font-size: 0.85em; color: var(--accent, #5fd6b2); }
.reply-draft small { display: block; opacity: 0.7; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.recovery-code-value {
  display: block;
  font-family: ui-monospace, "JetBrains Mono", monospace;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  word-break: break-all;
  text-align: center;
  padding: 14px;
  background: var(--surface-alt, #0f0f0f);
  border: 1px solid var(--border, #2f2f2f);
  user-select: all;
}

/* === UI-настройки: палитра, размер шрифта, плотность === */
.ui-settings {
  display: grid;
  gap: 14px;
}
.segment {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  border: 1px solid var(--border);
}
.segment button {
  min-height: 44px;
  font-size: var(--fs-sm);
  color: var(--muted);
  font-weight: 700;
  border-right: 1px solid var(--border);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.segment button:last-child { border-right: 0; }
.segment button.active { background: var(--accent); color: var(--accent-ink); }

.palette {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 10px;
}
.palette button {
  aspect-ratio: 1;
  background: var(--swatch);
  border: 1px solid var(--border);
  position: relative;
}
.palette button.active::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid var(--text);
}

/* === Update banner === */
.update-banner {
  position: fixed;
  left: 12px;
  right: 12px;
  bottom: calc(80px + env(safe-area-inset-bottom));
  z-index: 50;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  background: var(--surface);
  border: 1px solid var(--accent);
  color: var(--text);
  box-shadow: var(--shadow-1);
}
.update-banner > div { display: grid; gap: 2px; min-width: 0; }
.update-banner strong { font-size: var(--fs-md); font-weight: 700; }
.update-banner span { font-size: var(--fs-xs); color: var(--muted); }
.update-banner .primary { min-height: 38px; padding: 0 12px; }

/* === Утилиты === */
.spacer { flex: 1; }
.row { display: flex; align-items: center; gap: 10px; }
.col { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.label-mini { font-size: var(--fs-xs); color: var(--muted); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
