/* Свои — мобильный интерфейс в духе iOS */
:root {
  --bg: #ffffff;
  --bg-2: #f2f2f7;
  --text: #111114;
  --muted: #8a8a8e;
  --line: rgba(60, 60, 67, 0.16);
  --accent: #2f7cf6;
  --accent-text: #ffffff;
  --bubble: #e9e9ee;
  --bubble-text: #111114;
  --danger: #ff3b30;
  --ok: #34c759;
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --ease: cubic-bezier(0.32, 0.72, 0, 1);
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-2: #1c1c1e;
    --text: #f2f2f7;
    --muted: #8e8e93;
    --line: rgba(84, 84, 88, 0.55);
    --accent: #3d8bff;
    --bubble: #262629;
    --bubble-text: #f2f2f7;
  }
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); }
body {
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}
button, input, textarea { font: inherit; color: inherit; }
button { border: 0; background: none; cursor: pointer; padding: 0; }
[hidden] { display: none !important; }
svg { fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Каркас: высота подстраивается под клавиатуру через visualViewport (см. app.js) */
#app {
  position: fixed; left: 0; right: 0; top: 0;
  height: var(--app-h, 100dvh);
  overflow: hidden;
  overflow: clip; /* clip не даёт браузеру прокручивать контейнер при фокусе на поле (важно для iPhone) */
  background: var(--bg);
}
.screen { position: absolute; inset: 0; display: flex; flex-direction: column; background: var(--bg); }
.tabscreen, .tabbar { transition: transform 0.35s var(--ease); }
#chat { z-index: 4; transition: transform 0.35s var(--ease), box-shadow 0.35s; transform: translateX(100%); }
#app.in-chat #chat { box-shadow: -8px 0 24px rgba(0,0,0,.08); }
#app.boot .screen, #app.boot .tabbar { transition: none !important; }
#app.in-chat .tabscreen, #app.in-chat .tabbar { transform: translateX(-28%); }
#app.in-chat #chat { transform: translateX(0); }
@media (min-width: 720px) {
  /* На компьютере: аккуратная колонка по центру, как «телефон» */
  #app { max-width: 480px; margin: 0 auto; border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* Шапка */
.bar {
  display: flex; align-items: center; gap: 4px;
  padding: calc(var(--sat) + 6px) calc(var(--sar) + 8px) 6px calc(var(--sal) + 8px);
  min-height: 52px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-bottom: 1px solid var(--line);
  z-index: 2;
}
.bar h2 { flex: 1; margin: 0; font-size: 20px; font-weight: 700; text-align: center; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; color: var(--accent); border-radius: 22px; }
.icon-btn:active { background: var(--bg-2); }
.icon-btn svg { width: 26px; height: 26px; }
.back svg { width: 28px; height: 28px; }
.title-block { flex: 1; min-width: 0; padding-right: 44px; text-align: center; }
.title { font-weight: 650; font-size: 17px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub { font-size: 12px; color: var(--muted); min-height: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sub.live { color: var(--accent); }

.banner { background: #ff9f0a; color: #000; text-align: center; font-size: 13px; padding: 6px; }
.scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }

/* Вход */
#auth { overflow-y: auto; padding: calc(var(--sat) + 24px) 20px calc(var(--sab) + 24px); }
.auth-card { width: 100%; max-width: 380px; margin: auto; text-align: center; }
.logo {
  width: 84px; height: 84px; margin: 0 auto 14px; border-radius: 22px;
  background: url(/icons/icon-192.png) center/cover; box-shadow: 0 6px 20px rgba(47,124,246,.35);
}
.auth-card h1 { margin: 0; font-size: 30px; }
.muted { color: var(--muted); }
.auth-card .muted { margin: 4px 0 20px; }
.segmented { display: grid; grid-template-columns: 1fr 1fr; background: var(--bg-2); border-radius: 10px; padding: 3px; margin-bottom: 14px; }
.segmented button { padding: 8px; border-radius: 8px; font-weight: 600; color: var(--muted); }
.segmented button.active { background: var(--bg); color: var(--text); box-shadow: 0 1px 3px rgba(0,0,0,.15); }
input, textarea {
  width: 100%; padding: 13px 14px; border-radius: 12px; border: 1px solid transparent;
  background: var(--bg-2); outline: none; font-size: 16px; /* 16px — иначе iOS увеличивает страницу при фокусе */
}
input:focus, textarea:focus { border-color: var(--accent); }
#authForm { display: grid; gap: 10px; }
.error { min-height: 18px; margin: 0; color: var(--danger); font-size: 14px; }
.primary { background: var(--accent); color: var(--accent-text); border-radius: 12px; padding: 14px; font-weight: 650; font-size: 17px; }
.primary:active { opacity: 0.8; }
.primary:disabled { opacity: 0.5; }

/* Список чатов */
.chat-row {
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  padding: 10px calc(var(--sar) + 14px) 10px calc(var(--sal) + 14px);
}
.chat-row:active { background: var(--bg-2); }
.avatar {
  position: relative; flex: none; width: 52px; height: 52px; border-radius: 50%;
  display: grid; place-items: center; color: #fff; font-weight: 650; font-size: 20px;
}
.avatar.sm { width: 40px; height: 40px; font-size: 16px; }
.avatar.xl { width: 104px; height: 104px; font-size: 42px; }
.avatar img { position: absolute; inset: 0; width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.dot { position: absolute; right: 0; bottom: 0; width: 13px; height: 13px; border-radius: 50%; background: var(--ok); border: 2.5px solid var(--bg); }
.row-main { flex: 1; min-width: 0; border-bottom: 1px solid var(--line); padding: 4px 0 10px; margin-bottom: -10px; }
.row-top { display: flex; justify-content: space-between; gap: 8px; align-items: baseline; }
.row-title { font-weight: 650; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-time { font-size: 13px; color: var(--muted); flex: none; }
.row-bottom { display: flex; justify-content: space-between; gap: 8px; align-items: center; margin-top: 2px; }
.row-preview { color: var(--muted); font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.badge { flex: none; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: #fff; font-size: 13px; font-weight: 650; display: grid; place-items: center; }
.empty { text-align: center; color: var(--muted); padding: 48px 24px; }

/* Сообщения */
#messages { display: flex; flex-direction: column; padding: 10px calc(var(--sar) + 10px) 8px calc(var(--sal) + 10px); background: var(--bg); }
.day { align-self: center; margin: 12px 0 6px; padding: 3px 12px; border-radius: 12px; background: var(--bg-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.msg-row { display: flex; margin-top: 2px; }
.msg-row.first { margin-top: 8px; }
.msg-row.mine { justify-content: flex-end; }
.bubble {
  max-width: 82%; padding: 7px 11px 6px; border-radius: 18px; background: var(--bubble); color: var(--bubble-text);
  overflow-wrap: anywhere; white-space: pre-wrap; position: relative;
}
.mine .bubble { background: var(--accent); color: var(--accent-text); }
.mine.pending .bubble { opacity: 0.6; }
.mine.failed .bubble { background: var(--danger); }
.who { display: block; font-size: 13px; font-weight: 650; margin-bottom: 1px; }
.meta { float: right; margin: 6px 0 0 10px; font-size: 11px; opacity: 0.65; line-height: 1; user-select: none; }
.ticks { margin-left: 4px; letter-spacing: -2px; font-weight: 700; opacity: .7; }
.ticks.read { color: #8fe3ff; opacity: 1; }
.ticks.wait { letter-spacing: 0; }
.bubble a { color: inherit; text-decoration: underline; }
.load-more { align-self: center; color: var(--accent); font-size: 14px; padding: 8px; }

.to-bottom {
  position: absolute; right: calc(var(--sar) + 14px); bottom: calc(var(--sab) + 70px);
  min-width: 42px; height: 42px; border-radius: 21px; padding: 0 10px;
  display: flex; align-items: center; justify-content: center; gap: 2px;
  background: var(--bg); border: 1px solid var(--line); box-shadow: 0 3px 12px rgba(0,0,0,.18); color: var(--accent);
}
.to-bottom svg { width: 22px; height: 22px; }
.to-bottom span { font-weight: 700; font-size: 14px; }
.to-bottom span:empty { display: none; }

/* Поле ввода */
.composer {
  padding: 8px calc(var(--sar) + 10px) calc(var(--sab) + 8px) calc(var(--sal) + 10px);
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  border-top: 1px solid var(--line);
}
.attach-strip:not([hidden]) + .composer { border-top: 0; }
.compose-row, .rec-row { display: flex; align-items: flex-end; gap: 6px; }
.rec-row { align-items: center; min-height: 40px; gap: 10px; }
.composer textarea {
  flex: 1; resize: none; max-height: 140px; min-height: 40px; border-radius: 20px; padding: 9px 14px;
  background: var(--bg-2); border: 1px solid var(--line); line-height: 1.3;
}
.attach { flex: none; width: 40px; height: 40px; display: grid; place-items: center; color: var(--accent); border-radius: 50%; }
.attach:active { background: var(--bg-2); }
.attach svg { width: 26px; height: 26px; }
.send { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.send svg { width: 22px; height: 22px; stroke-width: 2.6; }
.send:disabled { background: var(--bg-2); color: var(--muted); }
.icon-btn.danger { color: var(--danger); }

/* Запись голоса */
.rec-info { display: flex; align-items: center; gap: 8px; min-width: 52px; font-weight: 650; font-variant-numeric: tabular-nums; }
.rec-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
.rec-bars { flex: 1; height: 34px; display: flex; align-items: center; gap: 2px; overflow: hidden; }
.rec-bars i { flex: 1; min-width: 2px; max-width: 5px; height: 8%; border-radius: 2px; background: var(--accent); }
@keyframes blink { 50% { opacity: .25; } }

/* Выбранные фото перед отправкой */
.attach-strip {
  display: flex; gap: 8px; padding: 8px calc(var(--sar) + 10px) 0 calc(var(--sal) + 10px); overflow-x: auto;
  border-top: 1px solid var(--line); background: color-mix(in srgb, var(--bg) 92%, transparent);
}
.thumb { position: relative; flex: none; width: 68px; height: 68px; border-radius: 12px; overflow: hidden; background: var(--bg-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb-x { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 50%; background: rgba(0,0,0,.62); color: #fff; display: grid; place-items: center; }
.thumb-x svg { width: 12px; height: 12px; stroke-width: 3.2; }

/* Фото в переписке */
.bubble.media-bubble { padding: 3px; overflow: hidden; }
.mine.pending .bubble.media-bubble { opacity: 1; }
/* Фото без подписи — без рамки пузыря */
.bubble.media-bubble.bare { background: transparent; padding: 0; }
.bubble.media-bubble.bare .who { padding: 0 4px 2px; }
.img-wrap {
  position: relative; width: min(260px, 66vw); max-height: 360px; border-radius: 15px; overflow: hidden;
  background: var(--bg-2); cursor: zoom-in; -webkit-touch-callout: none;
}
.img-wrap img { width: 100%; height: 100%; object-fit: cover; display: block; user-select: none; }
.img-wrap.failed { outline: 2px solid var(--danger); outline-offset: -2px; }
.ring { display: none; position: absolute; inset: 0; place-items: center; background: rgba(0,0,0,.38); }
.img-wrap.pending .ring { display: grid; }
.ring span {
  width: 46px; height: 46px; border-radius: 50%;
  background: conic-gradient(#fff calc(var(--p, 0) * 360deg), rgba(255,255,255,.28) 0);
  -webkit-mask: radial-gradient(circle, transparent 15px, #000 16px); mask: radial-gradient(circle, transparent 15px, #000 16px);
  animation: spin 1.2s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.caption { padding: 5px 8px 3px; white-space: pre-wrap; overflow-wrap: anywhere; }
.meta.overlay {
  position: absolute; right: 9px; bottom: 8px; float: none; margin: 0; opacity: 1; color: #fff;
  background: rgba(0,0,0,.5); padding: 3px 7px; border-radius: 10px;
}

/* Видео в переписке: первый кадр, значок «играть» и длительность; воспроизведение — в окне просмотра */
.img-wrap.vid { cursor: pointer; background: #111; }
.img-wrap.vid video { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.vid-play {
  position: absolute; left: 50%; top: 50%; width: 54px; height: 54px; margin: -27px 0 0 -27px; border-radius: 50%;
  background: rgba(0,0,0,.5); color: #fff; display: grid; place-items: center; pointer-events: none;
}
.vid-play svg { width: 28px; height: 28px; margin-left: 2px; }
.img-wrap.pending .vid-play { display: none; }
.vid-dur {
  position: absolute; left: 8px; bottom: 8px; padding: 3px 7px; border-radius: 10px; background: rgba(0,0,0,.5); color: #fff;
  font-size: 12px; font-variant-numeric: tabular-nums; pointer-events: none;
}
.thumb.vid::after {
  content: ''; position: absolute; left: 50%; top: 50%; width: 26px; height: 26px; margin: -13px 0 0 -13px; border-radius: 50%;
  background: rgba(0,0,0,.55) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M9 6.5v11l9-5.5z' fill='%23fff'/%3E%3C/svg%3E") center / 20px no-repeat;
  pointer-events: none;
}
.thumb-dur { position: absolute; left: 4px; bottom: 4px; padding: 1px 5px; border-radius: 8px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; }

/* Голосовые сообщения */
.bubble.voice-bubble { display: flex; flex-direction: column; padding: 8px 12px 6px 8px; }
.voice-bubble .meta { float: none; align-self: flex-end; margin: 0; }
.voice { display: flex; align-items: center; gap: 10px; width: min(250px, 64vw); }
.v-play { flex: none; width: 40px; height: 40px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; }
.mine .v-play { background: #fff; color: var(--accent); }
.v-play svg { width: 20px; height: 20px; }
.v-main { flex: 1; min-width: 0; }
.v-wave { display: flex; align-items: center; gap: 2px; height: 30px; cursor: pointer; }
.v-wave i { flex: 1; min-width: 2px; border-radius: 2px; background: currentColor; opacity: .32; }
.v-wave i.on { opacity: 1; }
.v-row { display: flex; align-items: center; justify-content: space-between; margin-top: 2px; font-size: 12px; opacity: .8; font-variant-numeric: tabular-nums; }
.v-speed { font-size: 12px; font-weight: 700; padding: 1px 7px; border-radius: 9px; background: rgba(127,127,127,.24); }
.voice.pending { opacity: .7; }

/* Просмотр фото */
.lightbox { position: absolute; inset: 0; z-index: 30; background: rgba(0,0,0,.94); display: flex; align-items: center; justify-content: center; animation: fade .2s; }
.lightbox img, .lightbox video { max-width: 100%; max-height: 100%; object-fit: contain; }
.lightbox video { width: 100%; background: #000; }
.lb-btn { position: absolute; top: calc(var(--sat) + 12px); width: 44px; height: 44px; border-radius: 50%; background: rgba(255,255,255,.16); color: #fff; display: grid; place-items: center; z-index: 1; }
.lb-btn svg { width: 24px; height: 24px; }
#lbClose { right: 12px; }
#lbSave { left: 12px; }

/* Шторка */
.backdrop { position: absolute; inset: 0; background: rgba(0,0,0,.4); z-index: 10; animation: fade .2s; }
.sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 11; max-height: 88%; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 18px 18px 0 0; padding: 8px 0 calc(var(--sab) + 10px);
  animation: up 0.3s var(--ease); box-shadow: 0 -6px 30px rgba(0,0,0,.25);
}
.sheet::before { content: ""; width: 38px; height: 5px; border-radius: 3px; background: var(--line); margin: 0 auto 6px; flex: none; }
.sheet h3 { margin: 4px 16px 8px; font-size: 18px; }
.sheet .body { overflow-y: auto; padding: 0 16px 6px; display: grid; gap: 10px; align-content: start; }
.sheet .body.flush { padding: 0; gap: 0; }
.sheet .row { display: flex; align-items: center; gap: 12px; padding: 9px 16px; width: 100%; text-align: left; }
.sheet .row:active { background: var(--bg-2); }
.sheet .row .grow { flex: 1; min-width: 0; }
.sheet .row small { color: var(--muted); display: block; }
.check { width: 24px; height: 24px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; color: transparent; }
.check svg { width: 14px; height: 14px; stroke-width: 3.5; }
.selected .check { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn { background: var(--bg-2); border-radius: 12px; padding: 13px; font-weight: 600; text-align: center; }
.btn:active { opacity: .7; }
.btn.danger { color: var(--danger); }
.section-title { color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; margin: 6px 0 -2px; }
.code { font: 600 17px/1 ui-monospace, "SF Mono", Menlo, monospace; letter-spacing: .08em; }
.note { color: var(--muted); font-size: 14px; margin: 0; }

.toast {
  position: absolute; left: 50%; top: calc(var(--sat) + 14px); transform: translateX(-50%); z-index: 20;
  max-width: 88%; padding: 10px 16px; border-radius: 14px; background: rgba(30,30,32,.94); color: #fff; font-size: 14px; text-align: center;
  animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }

/* Контакты */
.add-form { display: flex; gap: 8px; }
.add-form input { flex: 1; min-width: 0; }
.add-btn { flex: none; padding: 0 16px; color: var(--accent); }
.add-btn:disabled { opacity: .5; }
.sheet .row.contact { padding-top: 0; padding-bottom: 0; }
.row-hit { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; text-align: left; padding: 9px 0; }
.remove { flex: none; color: var(--danger); font-weight: 600; padding: 12px 4px; }

/* Нижняя панель: контакты — чаты — профиль */
:root { --tabbar-h: 52px; }
.tabscreen { padding-bottom: calc(var(--tabbar-h) + var(--sab)); }
.tabbar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 1;
  display: grid; grid-template-columns: repeat(3, 1fr);
  height: calc(var(--tabbar-h) + var(--sab)); padding: 4px var(--sar) var(--sab) var(--sal);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(18px); backdrop-filter: saturate(180%) blur(18px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  color: var(--muted); font-size: 10.5px; font-weight: 600;
}
.tabbar button.active { color: var(--accent); }
.tabbar svg { width: 26px; height: 26px; }
.tab-badge {
  position: absolute; top: 0; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--danger); color: #fff; font: 700 11px/18px -apple-system, sans-serif; font-style: normal; text-align: center;
}

/* Шапка: боковые кнопки */
.bar-gap { flex: none; width: 44px; }
.text-btn { flex: none; min-width: 44px; height: 44px; padding: 0 6px; color: var(--accent); font-size: 16px; text-align: left; }
.pad { padding: 12px 16px; }
.add-wrap { padding: 10px 16px 6px; }

/* Контакты */
.person { display: flex; align-items: center; padding-right: calc(var(--sar) + 14px); }
.person-hit { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; text-align: left; padding: 8px 0 8px calc(var(--sal) + 14px); }
.person-hit:active { background: var(--bg-2); }
.person-main { flex: 1; min-width: 0; }
.person .remove { padding: 12px 0 12px 12px; }

/* Профиль */
.profile-head { display: flex; flex-direction: column; align-items: center; padding: 22px 16px 4px; text-align: center; }
.ava-btn { position: relative; display: block; border-radius: 50%; }
.ava-btn:active { opacity: .85; }
.cam {
  position: absolute; right: -2px; bottom: -2px; width: 34px; height: 34px; border-radius: 50%;
  background: var(--accent); color: #fff; border: 3px solid var(--bg); display: grid; place-items: center; z-index: 1;
}
.cam svg { width: 17px; height: 17px; }
.p-name { margin-top: 12px; font-size: 22px; font-weight: 700; overflow-wrap: anywhere; }
.p-tag { color: var(--muted); font-size: 16px; padding: 2px 8px; }
.chip { margin-top: 6px; padding: 2px 10px; border-radius: 10px; background: var(--bg-2); color: var(--muted); font-size: 12px; font-weight: 600; }
.ava-actions { display: flex; gap: 18px; margin-top: 8px; }
.link { color: var(--accent); font-size: 15px; padding: 6px 2px; }
.link.danger { color: var(--danger); }
.group-title { margin: 22px 28px 6px; color: var(--muted); font-size: 13px; text-transform: uppercase; letter-spacing: .04em; }
.group { margin: 0 14px; background: var(--bg-2); border-radius: 14px; overflow: hidden; }
.group-note { margin: 8px 28px 0; color: var(--muted); font-size: 13px; }
.field {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 0 14px; text-align: left;
  border-bottom: 1px solid var(--line);
}
.field:last-child { border-bottom: 0; }
button.field:active { background: rgba(127,127,127,.14); }
.field .grow { flex: 1; min-width: 0; }
.field small { color: var(--muted); display: block; }
.flabel { flex: none; width: 84px; color: var(--muted); font-size: 15px; }
.fval { flex: 1; min-width: 0; }
.field input { flex: 1; min-width: 0; background: transparent; border: 0; border-radius: 0; padding: 12px 0; }
.field input:focus { border-color: transparent; }
.field.invite { padding-top: 8px; padding-bottom: 8px; }
.field.invite:disabled { opacity: .55; }
.link-row { justify-content: center; color: var(--accent); font-weight: 600; }
.link-row.danger { color: var(--danger); }
.profile-form .pad { padding: 14px 14px 0; }
.field.toggle { justify-content: space-between; }
.switch {
  position: relative; flex: none; width: 51px; height: 31px; border-radius: 16px; background: rgba(120,120,128,.32);
  transition: background .2s;
}
.switch::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 27px; height: 27px; border-radius: 50%; background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.28); transition: transform .2s var(--ease);
}
.switch[aria-checked="true"] { background: var(--ok); }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:disabled { opacity: .45; }
.profile-body-end { height: 16px; }
#profileBody > :last-child { margin-bottom: 24px; }

/* Карточка контакта */
.sheet .body.card-center { justify-items: center; text-align: center; gap: 6px; }
.card-center .p-name { margin-top: 8px; }
.card-center > .primary, .card-center > .btn { width: 100%; margin-top: 8px; }
.card-center > .primary { margin-top: 14px; }
.phone-link { color: var(--accent); font-size: 17px; padding: 6px 0; text-decoration: none; }
.pad .primary { width: 100%; }

/* Канал «Регистрации»: записи от сервера, без поля ввода */
.msg-row.sys { justify-content: center; margin-top: 8px; }
.sys-note {
  max-width: 88%; padding: 8px 14px; border-radius: 16px; background: var(--bg-2); color: var(--text);
  text-align: center; font-size: 15px; overflow-wrap: anywhere; white-space: pre-wrap;
}
.sys-note .meta { display: block; float: none; margin: 3px 0 0; opacity: .55; text-align: center; }
#chat.ro .composer, #chat.ro .attach-strip { display: none; }
#chat.ro #messages { padding-bottom: calc(var(--sab) + 14px); }
#chat.ro .to-bottom { bottom: calc(var(--sab) + 20px); }

/* Подсказка про уведомления */
.push-prompt { display: flex; align-items: center; gap: 10px; margin: 8px 12px; padding: 10px 12px; border-radius: 14px; background: var(--surface, rgba(127,127,127,.14)); font-size: 14px; }
.push-prompt .pp-text { flex: 1; }
.push-prompt .pp-btn { background: var(--accent); color: #fff; border-radius: 10px; padding: 7px 12px; font-weight: 600; }
.push-prompt .pp-x { font-size: 22px; line-height: 1; color: var(--muted); padding: 0 4px; }

.group-note.center { text-align: center; margin-top: 14px; }
.group-note a { color: var(--accent); }

/* Окно «Доступна новая версия» */
.update-overlay { position: fixed; inset: 0; z-index: 10000; display: grid; place-items: center; padding: 24px; background: rgba(0,0,0,.55); }
.update-card { width: min(340px, 100%); background: var(--bg, #fff); color: inherit; border-radius: 20px; padding: 24px 20px 12px; text-align: center; box-shadow: 0 10px 40px rgba(0,0,0,.35); }
.update-title { font-size: 20px; font-weight: 700; margin-bottom: 6px; }
.update-card p { color: var(--muted); margin: 0 0 18px; font-size: 15px; }
.update-card .primary { width: 100%; padding: 14px; border-radius: 14px; background: var(--accent); color: #fff; font-size: 17px; font-weight: 600; }
.update-later { display: block; width: 100%; padding: 14px; color: var(--muted); font-size: 15px; }

.find-friends { display: block; width: 100%; margin-top: 8px; padding: 10px 0 2px; color: var(--accent); font-size: 15px; text-align: left; }
.ff-results { margin-top: 12px; }
.ff-results .row.contact { display: flex; align-items: center; gap: 12px; padding: 8px 0; }
.update-card input { width: 100%; margin: 0 0 10px; padding: 13px 14px; border-radius: 12px; background: var(--bg-2); font-size: 17px; text-align: center; }
.update-card .error { margin: 0 0 10px; min-height: 0; }

/* Реакции */
.bcol { display: flex; flex-direction: column; align-items: flex-start; max-width: 82%; min-width: 0; }
.mine .bcol { align-items: flex-end; }
.bcol .bubble { max-width: 100%; }
@media (pointer: coarse) { .bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; } }
.rx-row { display: flex; flex-wrap: wrap; gap: 4px; margin: 3px 2px 0; }
.rx { display: inline-flex; align-items: center; gap: 3px; padding: 2px 8px; border-radius: 12px; background: var(--bg-2); font-size: 14px; line-height: 20px; border: 1px solid transparent; }
.rx.me { background: color-mix(in srgb, var(--accent) 18%, var(--bg)); border-color: var(--accent); }
.rx-n { font-size: 12px; font-weight: 600; color: var(--muted); }
.rx.me .rx-n { color: var(--accent); }
.rx-backdrop { position: fixed; inset: 0; z-index: 9000; background: rgba(0,0,0,.18); }
.rx-pop { position: fixed; z-index: 9001; display: flex; flex-direction: column; gap: 4px; align-items: stretch; }
.rx-bar { display: flex; gap: 2px; padding: 6px 8px; background: var(--bg); border-radius: 26px; box-shadow: 0 6px 24px rgba(0,0,0,.3); }
.rx-pick { width: 38px; height: 38px; border-radius: 50%; font-size: 24px; line-height: 38px; text-align: center; }
.rx-pick.on { background: var(--bg-2); }
.rx-pick:active { transform: scale(1.25); }
.rx-copy { align-self: center; padding: 7px 18px; border-radius: 16px; background: var(--bg); box-shadow: 0 4px 16px rgba(0,0,0,.25); font-size: 15px; }

#chatTitle { cursor: pointer; }
