:root {
  --bg: #0e1016;
  --panel: #151821;
  --panel-2: #1b1f2b;
  --line: #242938;
  --text: #e8eaf2;
  --muted: #8b91a7;
  --accent: #7c5cff;
  --accent-hover: #8c70ff;
  --bubble: #1e2331;
  --bubble-mine: #6a4dff;
  --input: #1b1f2b;
  --hover: #1c2130;
  --active: #262c40;
  --danger: #ff5d6c;
  --online: #3ddc84;
  --shadow: 0 10px 40px rgb(0 0 0 / .45);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eceff5;
    --panel: #ffffff;
    --panel-2: #f3f4f9;
    --line: #e1e4ee;
    --text: #161923;
    --muted: #6b7185;
    --bubble: #ffffff;
    --input: #f0f2f7;
    --hover: #f3f4f9;
    --active: #e8e6ff;
    --shadow: 0 10px 40px rgb(20 20 60 / .18);
    color-scheme: light;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 15px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; padding: 0; }
input, textarea { font: inherit; color: inherit; }
a { color: var(--accent-hover); }

#app { height: 100dvh; display: flex; flex-direction: column; }

.ic { width: 22px; height: 22px; flex-shrink: 0; }

/* ---------- Desktop overlay window ---------- */

html.overlay, html.overlay body { background: transparent; }
html.overlay #app {
  height: 100vh;
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: var(--bg);
}
.overlay-bar {
  display: flex;
  align-items: center;
  gap: 2px;
  height: 34px;
  padding: 0 4px 0 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  -webkit-app-region: drag;
  user-select: none;
  flex-shrink: 0;
}
.overlay-bar .ob-title { flex: 1; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--muted); }
.overlay-bar .ob-title .ic { width: 15px; height: 15px; color: var(--accent); }
.overlay-bar .icon-btn { -webkit-app-region: no-drag; width: 30px; height: 28px; }
.overlay-bar .icon-btn .ic { width: 16px; height: 16px; }

/* ---------- Common controls ---------- */

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--muted);
  flex-shrink: 0;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.round { border-radius: 50%; }
.icon-btn.accent { background: var(--accent); color: #fff; }
.icon-btn.accent:hover { background: var(--accent-hover); color: #fff; }

.primary {
  height: 44px;
  padding: 0 18px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}
.primary:hover { background: var(--accent-hover); }
.primary:disabled { opacity: .5; cursor: default; }
.link { color: var(--accent-hover); font-weight: 600; margin-top: 6px; }

.field {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--input);
  outline: none;
  font-size: 16px;
}
.field:focus { border-color: var(--accent); }

.seg { display: flex; padding: 3px; border-radius: 12px; background: var(--input); gap: 3px; }
.seg button { flex: 1; height: 34px; border-radius: 9px; color: var(--muted); font-weight: 600; font-size: 14px; }
.seg button.active { background: var(--panel); color: var(--text); box-shadow: 0 1px 4px rgb(0 0 0 / .2); }

.hint { color: var(--muted); text-align: center; padding: 24px 16px; font-size: 14px; }
.hint.small { padding: 8px; font-size: 12px; }

.avatar {
  --h: 250;
  position: relative;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-weight: 700;
  font-size: 16px;
  color: #fff;
  background: linear-gradient(135deg, hsl(var(--h) 70% 62%), hsl(calc(var(--h) + 30) 65% 48%));
}
.avatar.sm { width: 38px; height: 38px; font-size: 14px; }
.avatar .dot {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--online);
  border: 2px solid var(--panel);
}

.logo-big {
  width: 64px;
  height: 64px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #8f74ff, #5a3cf0);
  color: #fff;
  margin: 0 auto 12px;
}
.logo-big .ic { width: 34px; height: 34px; }

.center-screen { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; padding: 24px; text-align: center; color: var(--muted); }

/* ---------- Auth ---------- */

.auth { flex: 1; display: flex; align-items: center; justify-content: center; padding: 16px; overflow-y: auto; }
.auth-card {
  width: 100%;
  max-width: 380px;
  padding: 28px 22px;
  border-radius: 20px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.auth-card h1 { text-align: center; font-size: 22px; margin: 0 0 18px; }
.auth-card form { display: flex; flex-direction: column; gap: 12px; margin-top: 16px; }
.auth-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.form-error { color: var(--danger); font-size: 13px; min-height: 18px; }

/* ---------- Layout ---------- */

.layout { flex: 1; display: flex; min-height: 0; }
.sidebar { width: 100%; display: flex; flex-direction: column; min-height: 0; background: var(--panel); }
.chat { display: none; flex: 1; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); position: relative; }
.layout.chat-open .sidebar { display: none; }
.layout.chat-open .chat { display: flex; }

@media (min-width: 760px) {
  .sidebar { width: 340px; flex-shrink: 0; border-right: 1px solid var(--line); }
  .layout.chat-open .sidebar { display: flex; }
  .chat { display: flex; }
  .back { display: none; }
}

.side-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 8px 10px 14px;
  padding-top: max(10px, env(safe-area-inset-top));
}
.me { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.me b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me small { color: var(--muted); font-size: 12px; }
.me small.offline { color: #f5a524; }

.search {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 12px 8px;
  padding: 0 12px;
  height: 40px;
  border-radius: 12px;
  background: var(--input);
  color: var(--muted);
}
.search .ic { width: 18px; height: 18px; }
.search input { flex: 1; min-width: 0; border: 0; background: none; outline: none; font-size: 16px; }

.chat-list { flex: 1; overflow-y: auto; padding: 0 6px 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
.chat-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 10px;
  border-radius: 12px;
  text-align: left;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.ci-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ci-row { display: flex; align-items: center; gap: 8px; }
.ci-title { flex: 1; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ci-time { font-size: 12px; color: var(--muted); }
.ci-preview { flex: 1; font-size: 14px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.typing { color: var(--accent-hover); font-style: normal; }
.badge {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Chat ---------- */

.empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; color: var(--muted); }

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px 8px 6px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
@media (min-width: 760px) { .chat-head { padding-left: 16px; } }
.chat-head .avatar { width: 40px; height: 40px; font-size: 15px; }
.ch-info { flex: 1; min-width: 0; }
.ch-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-status { font-size: 13px; color: var(--muted); }
.ch-status.online, .ch-status.typing { color: var(--accent-hover); }

.messages { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px 12px; }
.msg-inner { max-width: 860px; margin: 0 auto; display: flex; flex-direction: column; }

.day { display: flex; justify-content: center; margin: 14px 0 6px; position: sticky; top: 0; z-index: 1; }
.day span { font-size: 12px; padding: 3px 10px; border-radius: 10px; background: var(--panel-2); color: var(--muted); }

.msg { display: flex; margin-top: 8px; }
.msg.grouped { margin-top: 2px; }
.msg.mine { justify-content: flex-end; }

.bubble {
  position: relative;
  max-width: min(80%, 540px);
  padding: 6px 10px;
  border-radius: 16px;
  background: var(--bubble);
  overflow-wrap: anywhere;
  box-shadow: 0 1px 1px rgb(0 0 0 / .08);
}
.mine .bubble { background: var(--bubble-mine); color: #fff; }
.mine .bubble a { color: #fff; }
.sender { font-size: 13px; font-weight: 600; margin-bottom: 2px; color: hsl(var(--h) 75% 68%); }
.text { white-space: pre-wrap; display: inline; }

.meta {
  float: right;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 11px;
  line-height: 1;
  margin: 8px 0 -2px 10px;
  opacity: .65;
  user-select: none;
}
.tick .ic { width: 15px; height: 15px; }
.tick.read { opacity: 1; }

.type-image .bubble, .type-video .bubble { padding: 3px; }
.type-image .text, .type-video .text { display: block; padding: 4px 7px 0; }
.media {
  display: block;
  max-width: min(340px, 100%);
  max-height: 420px;
  border-radius: 13px;
  background: rgb(0 0 0 / .2);
}
img.media { cursor: zoom-in; min-width: 120px; min-height: 80px; object-fit: cover; }
video.media { width: 340px; }
.type-image:not(.has-text) .meta {
  position: absolute;
  right: 9px;
  bottom: 9px;
  margin: 0;
  padding: 3px 6px;
  border-radius: 10px;
  background: rgb(0 0 0 / .55);
  color: #fff;
  opacity: 1;
}
.type-image.has-text .meta, .type-video .meta { margin-right: 7px; margin-bottom: 4px; }

.file { display: flex; align-items: center; gap: 10px; text-decoration: none; color: inherit; padding: 4px 0; min-width: 200px; }
.file-ico {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}
.mine .file-ico { background: rgb(255 255 255 / .2); }
.file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-meta b { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }
.file-meta small { opacity: .7; }

.audio-file { display: flex; flex-direction: column; gap: 6px; padding: 4px 0; }
.audio-file audio { width: 260px; max-width: 100%; height: 36px; }
.file-name { font-size: 14px; font-weight: 600; }

.voice { --p: 0%; display: flex; align-items: center; gap: 10px; width: 250px; max-width: 100%; padding: 3px 0; }
.voice .play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  flex-shrink: 0;
}
.mine .voice .play { background: #fff; color: var(--bubble-mine); }
.voice .play .ic { width: 18px; height: 18px; }
.wave { flex: 1; height: 30px; position: relative; cursor: pointer; }
.bars { position: absolute; inset: 0; display: flex; align-items: center; gap: 2px; }
.bars i { flex: 1; height: var(--b); border-radius: 2px; background: currentColor; opacity: .3; }
.bars.fill { clip-path: inset(0 calc(100% - var(--p)) 0 0); }
.bars.fill i { opacity: 1; }
.theirs .bars.fill i { background: var(--accent); }
.vdur { font-size: 12px; opacity: .8; min-width: 32px; font-variant-numeric: tabular-nums; }

/* ---------- Uploads ---------- */

.uploads { display: flex; flex-direction: column; gap: 4px; padding: 0 12px; }
.uploads:not(:empty) { padding-bottom: 6px; }
.upload {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel);
  font-size: 13px;
}
.up-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.progress { width: 90px; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.progress i { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.up-pct { width: 36px; text-align: right; color: var(--muted); font-variant-numeric: tabular-nums; }

/* ---------- Composer ---------- */

.composer {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 8px;
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  background: var(--panel);
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.composer textarea {
  flex: 1;
  min-width: 0;
  resize: none;
  max-height: 160px;
  min-height: 40px;
  padding: 9px 14px;
  border-radius: 20px;
  border: 0;
  outline: none;
  background: var(--input);
  font-size: 16px;
  line-height: 22px;
}
.composer .send { display: none; }
.composer.has-text .send { display: inline-flex; }
.composer.has-text .mic { display: none; }

.rec-panel { display: none; }
.composer.recording > :not(.rec-panel) { display: none !important; }
.composer.recording .rec-panel { display: flex; flex: 1; align-items: center; gap: 10px; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-hint { flex: 1; color: var(--muted); font-size: 14px; }
@keyframes pulse { 50% { opacity: .25; } }

.chat.drop::after {
  content: 'Отпустите, чтобы отправить';
  position: absolute;
  inset: 10px;
  border: 2px dashed var(--accent);
  border-radius: 16px;
  background: rgb(124 92 255 / .12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  pointer-events: none;
}

/* ---------- Modal ---------- */

.backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgb(0 0 0 / .5);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: max(40px, env(safe-area-inset-top)) 12px 12px;
}
.overlay .backdrop { padding-top: 44px; }
.modal {
  width: 100%;
  max-width: 440px;
  max-height: calc(100dvh - 60px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px;
  border-radius: 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.modal[data-mode="direct"] .group-only { display: none; }
.modal-head { display: flex; align-items: center; gap: 8px; }
.modal-head .seg { flex: 1; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { padding: 5px 10px; border-radius: 14px; background: var(--active); font-size: 13px; cursor: pointer; }
.user-results { overflow-y: auto; min-height: 80px; }
.user-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: 12px; text-align: left; }
.user-row:hover { background: var(--hover); }
.user-row .avatar { width: 40px; height: 40px; font-size: 15px; }
.ur-meta { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ur-meta small { color: var(--muted); }
.check { width: 22px; height: 22px; border-radius: 50%; border: 2px solid var(--line); }
.user-row.selected .check { background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 3px var(--panel); }

/* ---------- Popover, viewer, toast ---------- */

.popover {
  position: fixed;
  z-index: 60;
  width: 220px;
  padding: 6px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.popover button { width: 100%; display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 9px; text-align: left; }
.popover button:hover { background: var(--hover); }
.popover .ic { width: 18px; height: 18px; color: var(--muted); }
.popover .danger, .popover .danger .ic { color: var(--danger); }

.viewer {
  position: fixed;
  inset: 0;
  z-index: 70;
  background: rgb(0 0 0 / .92);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: zoom-out;
}
.viewer img { max-width: 100%; max-height: 100%; object-fit: contain; }
.viewer-dl { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; color: #fff; background: rgb(255 255 255 / .12); }

#toast {
  position: fixed;
  left: 50%;
  bottom: calc(90px + env(safe-area-inset-bottom));
  z-index: 80;
  max-width: calc(100% - 32px);
  padding: 10px 16px;
  border-radius: 12px;
  background: #2a2f40;
  color: #fff;
  font-size: 14px;
  box-shadow: var(--shadow);
  transform: translate(-50%, 20px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s, transform .2s;
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Avatars ---------- */

.avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.avatar:has(img) { background: var(--panel-2); }
.avatar.saved { background: linear-gradient(135deg, #5fb8ff, #3a7bff); }
.avatar.saved .ic { width: 22px; height: 22px; }
.avatar.lg { width: 56px; height: 56px; font-size: 20px; }
.avatar.xl { width: 112px; height: 112px; font-size: 40px; }
.avatar.xl .dot { width: 22px; height: 22px; border-width: 4px; border-color: var(--bg); }
.avatar.xl.saved .ic { width: 48px; height: 48px; }

.me-btn {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 8px 4px 4px;
  margin-left: -4px;
  border-radius: 12px;
  text-align: left;
}
.me-btn:hover { background: var(--hover); }

.ch-click {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 3px 8px 3px 3px;
  border-radius: 12px;
  text-align: left;
}
.ch-click:not(:disabled):hover { background: var(--hover); }
.ch-click:disabled { cursor: default; }
.ch-info { display: flex; flex-direction: column; }

.fwd { font-size: 12px; font-weight: 600; color: var(--accent-hover); margin-bottom: 2px; }
.mine .fwd { color: rgb(255 255 255 / .85); }
.type-image .fwd, .type-video .fwd { padding: 4px 7px 2px; }

@media (pointer: coarse) {
  .bubble { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
}

.popover a { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 9px; color: inherit; text-decoration: none; }
.popover a:hover { background: var(--hover); }
.popover a .ic { width: 18px; height: 18px; color: var(--muted); }

.viewer video { max-width: 100%; max-height: 100%; cursor: default; }
.viewer-close { position: absolute; top: max(12px, env(safe-area-inset-top)); left: 12px; color: #fff; background: rgb(255 255 255 / .12); }

/* ---------- Pages (profile, Mail, settings) ---------- */

.page-backdrop { display: none; }
.page {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  animation: page-in .18s ease-out;
}
.page-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px 8px 6px;
  padding-top: max(8px, env(safe-area-inset-top));
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.page-title { flex: 1; font-weight: 600; font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.page-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding-bottom: env(safe-area-inset-bottom); }
@keyframes page-in { from { transform: translateX(24px); opacity: 0; } }
@keyframes pop-in { from { transform: scale(.97); opacity: 0; } }

@media (min-width: 760px) {
  html:not(.overlay) .page-backdrop { display: block; position: fixed; inset: 0; z-index: 39; background: rgb(0 0 0 / .5); }
  html:not(.overlay) .page {
    top: 20px;
    bottom: 20px;
    left: 50%;
    right: auto;
    width: 580px;
    margin-left: -290px;
    border-radius: 18px;
    overflow: hidden;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    animation: pop-in .18s ease-out;
  }
}
html.overlay .page { top: 35px; left: 1px; right: 1px; bottom: 1px; border-radius: 0 0 13px 13px; }

/* ---------- Profile ---------- */

.profile { max-width: 580px; margin: 0 auto; padding-bottom: 24px; }
.profile-cover {
  --h: 250;
  height: 120px;
  background:
    radial-gradient(circle at 20% 10%, hsl(var(--h) 85% 70% / .8), transparent 55%),
    radial-gradient(circle at 90% 90%, hsl(calc(var(--h) + 80) 80% 60% / .6), transparent 50%),
    linear-gradient(135deg, hsl(var(--h) 65% 42%), hsl(calc(var(--h) + 50) 60% 30%));
}
.profile-card { display: flex; flex-direction: column; align-items: center; text-align: center; padding: 0 16px; margin-top: -60px; }
.profile-avatar { border-radius: 50%; padding: 4px; background: var(--bg); }
.profile-avatar[data-p] { cursor: zoom-in; }
.profile-name { margin: 10px 0 2px; font-size: 22px; overflow-wrap: anywhere; }
.profile-sub { color: var(--muted); font-size: 14px; }
.online { color: var(--online); }
.profile-actions { display: flex; gap: 8px; margin-top: 16px; flex-wrap: wrap; justify-content: center; }

.pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 20px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.pill:hover { background: var(--hover); }
.pill .ic { width: 18px; height: 18px; }
.pill[hidden] { display: none; }
.pill.primary-pill { background: var(--accent); border-color: var(--accent); color: #fff; }
.pill.primary-pill:hover { background: var(--accent-hover); }
.pill.ghost { background: transparent; }
.pill.sm { height: 34px; padding: 0 12px; font-size: 13px; }
.pill-count {
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-size: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.pill-count:empty { display: none; }
.mail-pill { background: linear-gradient(135deg, rgb(124 92 255 / .2), rgb(95 184 255 / .2)); border-color: rgb(124 92 255 / .5); }

.card { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; margin: 12px 12px 0; overflow: hidden; }
.card.pad { padding: 14px; }
.card-title { display: flex; align-items: center; gap: 8px; font-size: 15px; margin: 0 0 12px; }
.card-title .ic { width: 18px; height: 18px; color: var(--accent-hover); }

.section-title { margin: 20px 16px 0; font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.section-title small { text-transform: none; letter-spacing: 0; font-weight: 400; margin-left: 6px; }
.section-title.row { display: flex; justify-content: space-between; align-items: center; }

.info-row { display: flex; align-items: center; gap: 12px; padding: 12px 8px 12px 14px; }
.info-row + .info-row { border-top: 1px solid var(--line); }
.info-ico {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(124 92 255 / .15);
  color: var(--accent-hover);
  flex-shrink: 0;
}
.info-ico .ic { width: 18px; height: 18px; }
.info-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.info-text > a { color: var(--text); text-decoration: none; font-weight: 600; font-size: 16px; }
.info-text small { color: var(--muted); font-size: 12px; }
.bio { white-space: pre-wrap; overflow-wrap: anywhere; }

.links-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; margin: 10px 12px 0; }
.link-tile {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 12px 10px 10px;
  border-radius: 14px;
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--text);
  text-decoration: none;
  transition: transform .15s, border-color .15s;
}
.link-tile:hover { transform: translateY(-1px); border-color: var(--accent); }
.lt-ico {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: -.02em;
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / .12);
}
.lt-ico .ic { width: 20px; height: 20px; }
.lt-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lt-text b, .lt-text small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lt-text small { color: var(--muted); }
.link-tile > .ic { width: 16px; height: 16px; color: var(--muted); }
.empty-links { width: calc(100% - 24px); display: flex; align-items: center; gap: 12px; padding: 14px; color: var(--muted); text-align: left; border-style: dashed; }

.menu-card button { width: 100%; display: flex; align-items: center; gap: 12px; padding: 14px; text-align: left; }
.menu-card button + button { border-top: 1px solid var(--line); }
.menu-card button:hover { background: var(--hover); }
.menu-card button span { flex: 1; }
.menu-card .ic { width: 20px; height: 20px; color: var(--muted); }
.menu-card .danger, .menu-card .danger .ic { color: var(--danger); }

.list-card .user-row { border-radius: 0; padding: 10px 14px; }
.list-card .user-row + .user-row { border-top: 1px solid var(--line); }
.user-row > .ic { width: 18px; height: 18px; color: var(--muted); }

/* ---------- Forms ---------- */

.form-page { max-width: 580px; margin: 0 auto; padding-bottom: 24px; display: flex; flex-direction: column; }
.form-pad { padding: 16px; gap: 14px; }
.form-pad .section-title { margin: 8px 0 0; }
.form-label { position: relative; display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.field.textarea { height: auto; min-height: 44px; padding: 10px 14px 22px; resize: vertical; line-height: 1.4; }
.counter { position: absolute; right: 12px; bottom: 6px; font-size: 11px; }
.switch-row { display: flex; align-items: center; gap: 12px; cursor: pointer; font-size: 14px; }
.switch-row input { display: none; }
.switch { position: relative; width: 44px; height: 26px; border-radius: 13px; background: var(--line); flex-shrink: 0; transition: background .2s; }
.switch::after { content: ''; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .2s; }
.switch-row input:checked + .switch { background: var(--accent); }
.switch-row input:checked + .switch::after { transform: translateX(18px); }
.avatar-edit { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.avatar-edit.busy { opacity: .6; pointer-events: none; }
.avatar-edit-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.link-edit { display: flex; align-items: flex-start; gap: 10px; padding: 10px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.link-edit + .link-edit { margin-top: 8px; }
.link-edit-fields { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 6px; }
.link-edit .field { height: 38px; }
.links-editor .hint { padding: 8px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.muted { color: var(--muted); }
.note { display: flex; gap: 10px; margin: 16px; font-size: 13px; }
.note .ic { width: 18px; height: 18px; flex-shrink: 0; }
.danger-link { color: var(--danger); text-transform: none; letter-spacing: 0; font-size: 13px; margin: 0; }
.danger-link[hidden] { display: none; }

.session { display: flex; align-items: center; gap: 12px; padding: 12px 14px; }
.session + .session { border-top: 1px solid var(--line); }
.session-ico { width: 38px; height: 38px; border-radius: 10px; background: var(--panel-2); display: flex; align-items: center; justify-content: center; color: var(--muted); flex-shrink: 0; }
.session-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.session-info small { color: var(--muted); }

/* ---------- Mail ---------- */

.mail { max-width: 640px; margin: 0 auto; padding-bottom: 24px; }
.mail-hero { display: flex; align-items: center; gap: 12px; padding: 16px 16px 4px; }
.mail-hero-text { display: flex; flex-direction: column; min-width: 0; }
.mail-hero-text b { font-size: 17px; }
.mail-hero-text small { color: var(--muted); }

.mail-composer { padding: 12px; transition: border-color .15s; }
.mail-composer.drop { border-color: var(--accent); border-style: dashed; }
.mc-text { width: 100%; min-height: 48px; border: 0; outline: none; background: transparent; resize: none; font-size: 16px; line-height: 1.45; }
.mc-files { display: flex; flex-wrap: wrap; gap: 8px; }
.mc-files:not(:empty) { margin: 6px 0 10px; }
.mc-thumb { position: relative; width: 76px; height: 76px; border-radius: 12px; overflow: hidden; }
.mc-thumb img { width: 100%; height: 100%; object-fit: cover; }
.mc-thumb button, .mc-chip button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgb(0 0 0 / .6);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mc-thumb button .ic, .mc-chip button .ic { width: 14px; height: 14px; }
.mc-chip { position: relative; display: flex; align-items: center; gap: 8px; height: 40px; max-width: 240px; padding: 0 36px 0 10px; border-radius: 12px; background: var(--panel-2); font-size: 13px; }
.mc-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mc-chip > .ic { width: 18px; height: 18px; color: var(--accent-hover); flex-shrink: 0; }
.mc-chip button { top: 9px; right: 8px; }
.mc-bar { display: flex; align-items: center; gap: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.mc-progress { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.mc-progress[hidden] { display: none; }
.mc-progress i { display: block; width: 0; height: 100%; background: var(--accent); transition: width .2s; }
.mc-bar .primary { margin-left: auto; }
.primary.sm { height: 34px; padding: 0 14px; border-radius: 10px; font-size: 14px; }

.mail-tabs { margin: 14px 12px 0; }
.mail .more { display: flex; margin: 14px auto 0; }
.mail-empty { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 40px 24px; color: var(--muted); text-align: center; }
.mail-empty .ic { width: 40px; height: 40px; color: var(--accent-hover); margin-bottom: 6px; }
.mail-empty b { color: var(--text); font-size: 16px; }

.post { padding: 10px 14px 14px; }
.post-head { display: flex; align-items: center; justify-content: space-between; min-height: 30px; }
.post-date { font-size: 12px; color: var(--muted); }
.icon-btn.sm { width: 30px; height: 30px; }
.icon-btn.sm .ic { width: 16px; height: 16px; }
.post-text { margin: 2px 0; font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.post-media { display: grid; grid-template-columns: repeat(2, 1fr); grid-auto-rows: 180px; gap: 4px; margin-top: 10px; border-radius: 12px; overflow: hidden; }
.post-media > * { display: block; width: 100%; height: 100%; object-fit: cover; background: rgb(0 0 0 / .25); }
.post-media img { cursor: zoom-in; }
.post-media.n-1 { grid-template-columns: 1fr; grid-auto-rows: auto; }
.post-media.n-1 > * { height: auto; max-height: 520px; object-fit: contain; }
.post-media.n-3 > :first-child { grid-row: span 2; }
.post-files { display: flex; flex-direction: column; margin-top: 10px; border-radius: 12px; background: var(--panel-2); overflow: hidden; }

.file-row { display: flex; align-items: center; gap: 12px; padding: 10px 12px; color: inherit; text-decoration: none; }
.file-row + .file-row { border-top: 1px solid var(--line); }
a.file-row:hover { background: var(--hover); }
.file-row > .ic { width: 18px; height: 18px; color: var(--muted); }
.file-row .file-ico { width: 40px; height: 40px; }
.file-row .file-ico .ic { width: 20px; height: 20px; }
.file-row .file-meta { flex: 1; }
.file-row .file-meta b { max-width: none; }
.audio-row audio { width: 100%; height: 34px; margin-top: 4px; }

.gallery { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 12px 12px 0; border-radius: 14px; overflow: hidden; }
.g-item { position: relative; aspect-ratio: 1; overflow: hidden; background: var(--panel-2); cursor: zoom-in; }
.g-item img, .g-item video { display: block; width: 100%; height: 100%; object-fit: cover; }
.g-play {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgb(0 0 0 / .55);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.g-play .ic { width: 18px; height: 18px; }

/* ---------- Connection indicator ---------- */

.net-line { display: flex; align-items: center; gap: 5px; white-space: nowrap; overflow: hidden; }
.net-sep { opacity: .5; }
.net-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
  background: #5b6072;
  transition: background .3s, box-shadow .3s;
}
.net-dot.green { background: #3ddc84; box-shadow: 0 0 6px rgb(61 220 132 / .7); }
.net-dot.yellow { background: #f5c542; box-shadow: 0 0 6px rgb(245 197 66 / .6); }
.net-dot.red { background: #ff5d6c; box-shadow: 0 0 6px rgb(255 93 108 / .6); }
.net-dot.black { background: #14161c; box-shadow: 0 0 0 2px #5b6072; }
.chat-head > .net-dot { margin: 0 8px 0 4px; }

/* ---------- Editing, deleted and edited messages ---------- */

.edit-bar {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 6px 8px 6px 14px;
  background: var(--panel);
  border-top: 1px solid var(--line);
}
.edit-bar.show { display: flex; }
.edit-ico { display: flex; color: var(--accent-hover); }
.edit-ico .ic { width: 18px; height: 18px; }
.edit-text { flex: 1; min-width: 0; display: flex; flex-direction: column; font-size: 13px; }
.edit-text b { color: var(--accent-hover); }
.edit-text small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.edit-bar.show + .composer { border-top: 0; }
.composer.editing .attach, .composer.editing .mic { display: none; }
.composer.editing .send { display: inline-flex; }

.msg.deleted .bubble { background: transparent; border: 1px dashed var(--line); color: var(--muted); box-shadow: none; }
.deleted-text { display: inline-flex; align-items: center; gap: 6px; font-style: italic; font-size: 14px; }
.deleted-text .ic { width: 15px; height: 15px; }
.edited { font-style: italic; margin-right: 3px; }
.ci-lock { display: inline-flex; margin-right: 4px; color: var(--muted); vertical-align: -2px; }
.ci-lock .ic { width: 13px; height: 13px; }

/* ---------- New chat / groups search ---------- */

.newchat:not([data-tab="create"]) .tab-create { display: none; }
.newchat .seg button { font-size: 13px; }
.prefix-field {
  display: flex;
  align-items: center;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--input);
  overflow: hidden;
}
.prefix-field:focus-within { border-color: var(--accent); }
.prefix-field > span { padding: 0 2px 0 12px; color: var(--accent-hover); font-weight: 700; }
.prefix-field input { flex: 1; min-width: 0; height: 100%; padding-right: 12px; border: 0; outline: none; background: transparent; font-size: 16px; color: var(--text); }
.section-label { font-size: 12px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .05em; }
.small-text { font-size: 13px; }
.field.sm { height: 34px; padding: 0 10px; font-size: 14px; }
.field[hidden] { display: none; }
.tag { padding: 2px 8px; border-radius: 10px; background: var(--panel-2); border: 1px solid var(--line); font-size: 11px; color: var(--muted); white-space: nowrap; }
.tag.role-owner { color: #f5c542; border-color: rgb(245 197 66 / .4); }
.tag.role-admin { color: #ff8a65; border-color: rgb(255 138 101 / .4); }
.tag.role-moderator { color: #5fb8ff; border-color: rgb(95 184 255 / .4); }

.group-hit { padding: 10px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel-2); }
.group-hit + .group-hit { margin-top: 8px; }
.gh-head { display: flex; align-items: center; gap: 12px; }
.gh-head .avatar { width: 40px; height: 40px; font-size: 15px; }
.gh-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.gh-actions:empty { display: none; }
.join-password { display: flex; flex: 1; gap: 6px; min-width: 220px; }
.join-password input { flex: 1; min-width: 0; }
.gh-error { min-height: 0; margin-top: 6px; }
.gh-error:empty { display: none; }

/* ---------- Dialogs ---------- */

.dialog-backdrop { z-index: 90; align-items: center; }
.dialog { max-width: 380px; gap: 12px; padding: 18px; }
.dialog h3 { margin: 0; font-size: 17px; }
.dialog p { margin: 0; font-size: 14px; }
.dialog-buttons { display: flex; flex-direction: column; gap: 8px; margin-top: 4px; }
.dialog-buttons .pill, .dialog-buttons .primary { width: 100%; }
.danger-btn { background: var(--danger); }
.danger-btn:hover { background: #ff7582; }
.danger-text { color: var(--danger); }

/* ---------- Group page ---------- */

.privacy { display: flex; align-items: center; justify-content: center; gap: 6px; margin-top: 4px; }
.privacy .ic { width: 14px; height: 14px; }
.member-row { gap: 8px; }
.member-main { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; }
.member-main .avatar { width: 40px; height: 40px; font-size: 15px; }
.section-title.row .link { margin: 0; text-transform: none; letter-spacing: 0; font-size: 13px; }
.row-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.small-note { margin: 0 0 10px; font-size: 13px; }
.password-card { margin-bottom: 24px; }

/* ---------- Goals ---------- */

.goals { max-width: 640px; margin: 0 auto; padding-bottom: 24px; }
.goals-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px 0; }
.switch-row.small { font-size: 13px; }
.switch-row.small .switch { width: 36px; height: 22px; }
.switch-row.small .switch::after { width: 16px; height: 16px; }
.switch-row.small input:checked + .switch::after { transform: translateX(14px); }
.goal { padding: 14px; }
.goal.archived { opacity: .6; }
.goal-head { display: flex; align-items: center; gap: 8px; }
.goal-head h3 { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; margin: 0; font-size: 16px; }
.goal-head h3 .ic { width: 18px; height: 18px; flex-shrink: 0; color: var(--accent-hover); }
.goal-head h3 span { overflow-wrap: anywhere; }
.goal-desc { margin-top: 6px; color: var(--muted); font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; }
.goal-media { display: block; max-width: 100%; max-height: 220px; margin-top: 10px; border-radius: 12px; cursor: zoom-in; }
.goal-file { margin-top: 10px; border-radius: 12px; background: var(--panel-2); }
.goal-progress { position: relative; height: 12px; margin-top: 14px; border-radius: 6px; background: var(--panel-2); overflow: hidden; }
.goal-progress i {
  display: block;
  height: 100%;
  border-radius: 6px;
  background: linear-gradient(90deg, var(--accent), #5fb8ff);
  transition: width .4s ease;
}
.goal.completed .goal-progress i { background: linear-gradient(90deg, #2fbf71, #3ddc84); }
.goal.overdue .goal-progress i { background: linear-gradient(90deg, #ff5d6c, #ff8a65); }
.goal-numbers { display: flex; align-items: baseline; justify-content: space-between; margin-top: 6px; font-size: 13px; color: var(--muted); }
.goal-numbers b { font-size: 18px; color: var(--text); }
.goal-foot { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; margin-top: 10px; font-size: 13px; }
.goal-deadline { color: var(--muted); }
.goal-status { display: inline-flex; align-items: center; gap: 4px; color: var(--accent-hover); }
.goal-status .ic { width: 14px; height: 14px; }
.goal-status.done { color: var(--online); }
.goal-status.overdue { color: var(--danger); }
.goal-controls { display: flex; align-items: center; gap: 4px; margin-left: auto; }
.goal-value { width: 96px; text-align: center; }
.form-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 10px; }
.goal-form:not([data-deadline="date"]) .deadline-date { display: none; }
.goal-form:not([data-deadline="timer"]) .deadline-timer { display: none; }
.goal-current-file:empty { display: none; }
.goal-current-file .mc-chip { display: inline-flex; margin-bottom: 8px; }

/* ---------- Group Mail ---------- */

.gm-intro { display: flex; gap: 10px; margin: 14px 16px 0; font-size: 13px; }
.gm-intro .ic { width: 18px; height: 18px; flex-shrink: 0; }
.gm-new summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px;
  cursor: pointer;
  font-weight: 600;
  list-style: none;
}
.gm-new summary::-webkit-details-marker { display: none; }
.gm-new summary .ic { width: 18px; height: 18px; color: var(--accent-hover); }
.gm-new[open] summary { border-bottom: 1px solid var(--line); }
.gm-composer, .reply-composer { display: flex; flex-direction: column; gap: 8px; padding: 12px; }
.reply-composer { margin-bottom: 24px; }
.gm-composer.drop, .reply-composer.drop { outline: 2px dashed var(--accent); }
.gm-subject { font-weight: 600; }
.gm-thread { display: block; width: calc(100% - 24px); padding: 12px 14px; text-align: left; }
.gm-thread:hover { border-color: var(--accent); }
.gm-head, .letter-head { display: flex; align-items: center; gap: 10px; }
.gm-preview {
  display: -webkit-box;
  margin-top: 8px;
  overflow: hidden;
  color: var(--muted);
  font-size: 14px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.gm-meta { display: flex; align-items: center; gap: 12px; margin-top: 8px; font-size: 12px; color: var(--muted); }
.gm-meta span { display: inline-flex; align-items: center; gap: 4px; }
.gm-meta .ic { width: 13px; height: 13px; }
.gm-activity { margin-left: auto; }
.letter { padding: 14px; }
.letter.reply { margin-left: 28px; }
.letter-subject { margin: 0 0 12px; font-size: 20px; overflow-wrap: anywhere; }
.letter-head .ur-meta { flex: 1; }
.letter-body { margin-top: 10px; line-height: 1.55; white-space: pre-wrap; overflow-wrap: anywhere; }

/* ---------- Notifications, block list, server status ---------- */

.badge.muted { background: var(--muted); }
.ci-mute { display: inline-flex; vertical-align: -2px; margin-left: 6px; color: var(--muted); }
.ci-mute .ic { width: 14px; height: 14px; }

.pop-label { display: flex; flex-direction: column; line-height: 1.25; }
.pop-label small { color: var(--muted); font-size: 12px; }
.pop-note { padding: 0 10px 6px 38px; margin-top: -4px; font-size: 12px; color: var(--muted); }

.composer.hidden { display: none; }
.blocked-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}
.blocked-bar[hidden] { display: none; }
.blocked-bar span { display: inline-flex; align-items: center; gap: 8px; }
.blocked-bar .ic { width: 18px; height: 18px; color: var(--danger); }

button.switch { padding: 0; border: 0; cursor: pointer; }
.switch.on { background: var(--accent); }
.switch.on::after { transform: translateX(18px); }

.notify-state { display: flex; align-items: center; gap: 12px; }
.notify-state > div { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.notify-state b { font-size: 16px; }
.notify-ico {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: rgb(124 92 255 / .15);
  color: var(--accent-hover);
}
.notify-ico .ic { width: 22px; height: 22px; }
.notify-card.is-off .notify-ico { background: var(--panel-2); color: var(--muted); }
.notify-card .section-title { margin: 16px 0 8px; }
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-row .pill { height: 36px; font-size: 14px; }
.note.warn .ic { color: var(--danger); }
.card > .note { margin: 14px; }

.session-user { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; }

.status-hero { display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.status-hero > div:not(.status-uptime) { flex: 1; min-width: 150px; display: flex; flex-direction: column; gap: 2px; }
.status-hero b { font-size: 16px; }
.status-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--online);
  box-shadow: 0 0 0 5px rgb(61 220 132 / .18);
  animation: pulse 2s infinite;
}
.status-hero.down .status-dot { background: var(--danger); box-shadow: 0 0 0 5px rgb(255 93 108 / .18); }
.status-uptime { display: flex; flex-direction: column; align-items: flex-end; }
.status-uptime small { color: var(--muted); font-size: 12px; }
.status-uptime b { font-size: 26px; font-variant-numeric: tabular-nums; letter-spacing: -.01em; }
.stat-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; margin: 10px 12px 0; }
.stat-grid.four { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 560px) { .stat-grid.four { grid-template-columns: 1fr 1fr; } }
.stat { display: flex; flex-direction: column; gap: 2px; min-width: 0; padding: 12px 14px; border-radius: 14px; background: var(--panel); border: 1px solid var(--line); }
.stat small { color: var(--muted); font-size: 12px; }
.stat b { font-size: 20px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.stat span { font-size: 12px; }
.kv { display: flex; justify-content: space-between; gap: 12px; padding: 11px 14px; font-size: 14px; }
.kv + .kv { border-top: 1px solid var(--line); }
.kv b { font-weight: 600; text-align: right; overflow-wrap: anywhere; }
@media (max-width: 420px) {
  .status-uptime { align-items: flex-start; width: 100%; }
  .stat-grid { grid-template-columns: 1fr 1fr; }
}

/* ---------- Розовая тема ---------- */
/* Каждый цвет — смесь «полностью розового» и стандартного: долю задаёт ползунок (--pink-k, 0.2…1).
   Селектор с атрибутом «сильнее» обычного :root, поэтому светлый вариант описан ниже отдельно. */

:root[data-theme="pink"] {
  --pink-k: .8;
  --k: calc(var(--pink-k) * 100%);
  --bg: color-mix(in srgb, #1b060e var(--k), #0e1016);
  --panel: color-mix(in srgb, #290f1d var(--k), #151821);
  --panel-2: color-mix(in srgb, #331526 var(--k), #1b1f2b);
  --line: color-mix(in srgb, #4a2035 var(--k), #242938);
  --text: color-mix(in srgb, #ffe9f2 var(--k), #e8eaf2);
  --muted: color-mix(in srgb, #cf8dab var(--k), #8b91a7);
  --accent: color-mix(in srgb, #ff3d91 var(--k), #7c5cff);
  --accent-hover: color-mix(in srgb, #ff63a8 var(--k), #8c70ff);
  --bubble: color-mix(in srgb, #331526 var(--k), #1e2331);
  --bubble-mine: color-mix(in srgb, #e63a86 var(--k), #6a4dff);
  --input: color-mix(in srgb, #331526 var(--k), #1b1f2b);
  --hover: color-mix(in srgb, #38182a var(--k), #1c2130);
  --active: color-mix(in srgb, #4a2035 var(--k), #262c40);
  --shadow: 0 10px 40px rgb(40 0 20 / .5);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root[data-theme="pink"] {
    --bg: color-mix(in srgb, #fde7f0 var(--k), #eceff5);
    --panel: #ffffff;
    --panel-2: color-mix(in srgb, #fff2f7 var(--k), #f3f4f9);
    --line: color-mix(in srgb, #f6d3e2 var(--k), #e1e4ee);
    --text: color-mix(in srgb, #2a1020 var(--k), #161923);
    --muted: color-mix(in srgb, #a06b81 var(--k), #6b7185);
    --bubble: #ffffff;
    --bubble-mine: color-mix(in srgb, #f0569a var(--k), #6a4dff);
    --input: color-mix(in srgb, #fff0f6 var(--k), #f0f2f7);
    --hover: color-mix(in srgb, #fff0f6 var(--k), #f3f4f9);
    --active: color-mix(in srgb, #ffdbeb var(--k), #e8e6ff);
    --accent: color-mix(in srgb, #e6357f var(--k), #7c5cff);
    --accent-hover: color-mix(in srgb, #f0569a var(--k), #8c70ff);
    --shadow: 0 10px 40px rgb(120 20 70 / .18);
    color-scheme: light;
  }
}

/* ---------- Сердечки ---------- */

.hearts-layer { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 60; }
.heart {
  position: absolute;
  bottom: -40px;
  color: var(--accent);
  line-height: 1;
  will-change: transform;
  animation-name: heart-float;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
}
@keyframes heart-float {
  from { transform: translate3d(0, 0, 0) rotate(0deg); }
  to { transform: translate3d(var(--drift, 0), calc(-100vh - 80px), 0) rotate(var(--spin, 0deg)); }
}
@media (prefers-reduced-motion: reduce) {
  .hearts-layer { display: none; }
}

/* ---------- Ползунок ---------- */

.range-row { display: flex; align-items: center; gap: 12px; font-size: 12px; }
.range-row input[type="range"] { flex: 1; accent-color: var(--accent); height: 24px; }

/* ---------- Выбор темы ---------- */

.theme-row { width: 100%; display: flex; align-items: center; gap: 12px; padding: 12px 14px; text-align: left; }
.theme-row + .theme-row { border-top: 1px solid var(--line); }
.theme-row:hover { background: var(--hover); }
.theme-preview {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  flex-shrink: 0;
  border: 1px solid var(--line);
  background: linear-gradient(135deg, var(--b) 0 45%, var(--p) 45% 72%, var(--a) 72% 100%);
}
.theme-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.theme-text small { color: var(--muted); }
.theme-check .ic { width: 22px; height: 22px; color: var(--accent); }
.theme-row.active .theme-text b { color: var(--accent-hover); }

/* ---------- Админ ---------- */

.admin-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 4px;
  padding: 10px 12px;
  overflow-x: auto;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.admin-tabs button { flex: 0 0 auto; height: 36px; padding: 0 14px; border-radius: 18px; color: var(--muted); font-weight: 600; }
.admin-tabs button:hover { background: var(--hover); color: var(--text); }
.admin-tabs button.active { background: var(--accent); color: #fff; }
.admin-search { margin: 12px 12px 0; }

.admin-user { width: 100%; display: flex; align-items: center; gap: 12px; padding: 10px 14px; text-align: left; }
.admin-user + .admin-user { border-top: 1px solid var(--line); }
.admin-user:hover { background: var(--hover); }
.admin-user.deleted { opacity: .55; }
.admin-user > .ic { width: 18px; height: 18px; color: var(--muted); }
.admin-user-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.admin-user-info b, .admin-user-info small { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.admin-user-head { display: flex; align-items: center; gap: 14px; }
.admin-user-head h3 { margin: 0 0 2px; font-size: 18px; }
.more-btn { align-self: center; margin-top: 10px; }
.more-btn[hidden] { display: none; }

.tags { display: flex; flex-wrap: wrap; gap: 4px; }
.tags:empty { display: none; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 10px; background: var(--panel-2); color: var(--muted); }
.tag.accent { background: rgb(124 92 255 / .18); color: var(--accent-hover); }
.tag.danger { background: rgb(255 93 108 / .15); color: var(--danger); }

.row-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.perms .switch-row { font-size: 14px; }

.usage-head { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 6px; }
.warn-text { color: var(--danger); }
.stack-bar { display: flex; height: 14px; border-radius: 7px; overflow: hidden; background: var(--panel-2); }
.stack-bar i { display: block; height: 100%; }
.stack-bar i + i { box-shadow: -1px 0 0 var(--panel); }
.legend { display: flex; flex-direction: column; gap: 2px; }
.legend-row { display: flex; align-items: center; gap: 10px; padding: 5px 0; font-size: 14px; }
.legend-row + .legend-row { border-top: 1px dashed var(--line); }
.legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }
.legend-label { flex: 1; min-width: 0; }
.legend-row b { font-variant-numeric: tabular-nums; white-space: nowrap; }
.section-title .link { display: inline-flex; align-items: center; gap: 6px; text-transform: none; letter-spacing: 0; font-size: 13px; }
.section-title .link .ic { width: 14px; height: 14px; }

.log-row { display: flex; flex-direction: column; gap: 2px; padding: 10px 14px; font-size: 14px; }
.log-row + .log-row { border-top: 1px solid var(--line); }

/* ---------- Обновление приложения ---------- */

.app-update { display: flex; flex-direction: column; gap: 12px; }
.update-row { display: flex; align-items: center; gap: 12px; }
.app-update > button { align-self: flex-start; }
.download-link { display: inline-flex; align-items: center; gap: 8px; margin-top: 18px; color: var(--muted); font-size: 14px; text-decoration: none; }
.download-link:hover { color: var(--accent-hover); }
.download-link[hidden] { display: none; }
.download-link .ic { width: 16px; height: 16px; }
