:root {
  --bg: #0c0c0b;
  --rail: #0a0a09;
  --side: #121211;
  --panel: #171716;
  --raised: #1d1d1b;
  --hover: #222220;
  --line: rgba(255, 248, 235, .07);
  --text: #ece8e1;
  --dim: #8d8880;
  --accent: #c6a36a;
  --accent-dim: rgba(198, 163, 106, .14);
  --out: #2a261c;
  --in: #1a1a18;
  --good: #9cba8c;
  --warn: #c6a36a;
  --bad: #c77b74;
  --on-accent: #1a160f;
  --shadow: 0 24px 60px rgba(0, 0, 0, .55);
  color-scheme: dark;
}

html[data-theme="violet"] {
  --bg: #0c0b10; --rail: #09080e; --side: #13121a; --panel: #181622; --raised: #1e1c28;
  --hover: #242230; --line: rgba(236, 230, 255, .08); --text: #ece8f4; --dim: #8d8898;
  --accent: #9b8cff; --accent-dim: rgba(155, 140, 255, .16); --out: #242038; --in: #1a1820;
  --warn: #9b8cff; --on-accent: #14121c;
}
html[data-theme="teal"] {
  --bg: #0b0e0d; --rail: #080b0a; --side: #111615; --panel: #161c1b; --raised: #1c2322;
  --hover: #222a28; --line: rgba(220, 245, 238, .08); --text: #e4eeeb; --dim: #84918d;
  --accent: #5dad9a; --accent-dim: rgba(93, 173, 154, .16); --out: #1c2a26; --in: #161a19;
  --warn: #5dad9a; --on-accent: #0c1412;
}
html[data-theme="rose"] {
  --bg: #100c0c; --rail: #0c0909; --side: #181212; --panel: #1e1616; --raised: #251c1c;
  --hover: #2c2222; --line: rgba(255, 232, 232, .08); --text: #f0e6e4; --dim: #958886;
  --accent: #d08a84; --accent-dim: rgba(208, 138, 132, .16); --out: #2c201f; --in: #1c1716;
  --warn: #d08a84; --on-accent: #1a1211;
}
html[data-theme="steel"] {
  --bg: #0c0e11; --rail: #090b0d; --side: #12151a; --panel: #171b21; --raised: #1c2128;
  --hover: #232830; --line: rgba(230, 238, 248, .08); --text: #e6ebf1; --dim: #86909c;
  --accent: #8aa0b8; --accent-dim: rgba(138, 160, 184, .16); --out: #1e252e; --in: #16191d;
  --warn: #8aa0b8; --on-accent: #10141a;
}
html[data-theme="snow"] {
  --bg: #f3eee4; --rail: #ebe4d6; --side: #f7f2e8; --panel: #fffaf1; --raised: #fffdf8;
  --hover: #efe8db; --line: rgba(40, 32, 20, .12); --text: #1c1914; --dim: #7a7368;
  --accent: #8b5a2b; --accent-dim: rgba(139, 90, 43, .14); --out: #e8d4b0; --in: #ffffff;
  --good: #4f7a45; --warn: #8b5a2b; --bad: #b4544c; --on-accent: #fff8ee;
  --shadow: 0 24px 60px rgba(40, 28, 12, .12);
  color-scheme: light;
}
html[data-theme="snow"] .bubble {
  border: 1px solid rgba(40, 32, 20, .2);
  box-shadow: 0 1px 2px rgba(40, 32, 20, .06);
}
html[data-theme="snow"] .bubble-line:not(.mine) .bubble {
  background: #fff;
  border-color: rgba(40, 32, 20, .28);
}
html[data-theme="snow"] .bubble-line.mine .bubble {
  border-color: rgba(139, 90, 43, .35);
}
html[data-theme="snow"] .bubble .meta { color: #8a8070; }
html[data-theme="snow"] .post-main {
  background: #fff;
  border-color: rgba(40, 32, 20, .28);
}
html[data-theme="snow"] ::-webkit-scrollbar-thumb { background: #cfc4b0; }
html[data-theme="snow"] input::placeholder,
html[data-theme="snow"] textarea::placeholder { color: #9a9184; }

* { box-sizing: border-box; margin: 0; padding: 0; }
html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  touch-action: manipulation;
}
html, body {
  height: 100%;
  min-height: 100%;
  min-height: -webkit-fill-available;
}
body {
  font: 400 16.5px/1.5 "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
  padding: 0;
  height: 100%;
  height: 100dvh;
  min-height: -webkit-fill-available;
  touch-action: manipulation;
}
@media (max-width: 720px) {
  html, body { background: var(--side); }
}
button, input, textarea, select {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  color: inherit;
}
button { cursor: pointer; }
h1, h2, h3, .chip-top b, .post-who b, .head-text h2 {
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-weight: 560;
  letter-spacing: -.01em;
}
input::placeholder, textarea::placeholder { color: #6f6b64; opacity: 1; }
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-thumb { background: #2c2c28; }
.hidden { display: none !important; }

.app {
  display: grid;
  grid-template-columns: 68px 340px minmax(0, 1fr) 360px;
  height: 100%;
  min-height: 0;
  background: var(--bg);
}
.app > * { min-height: 0; min-width: 0; }
.app.no-thread { grid-template-columns: 68px 340px minmax(0, 1fr) 0; }
.app.no-thread .thread { display: none; }

.rail {
  background: var(--rail);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; align-items: center;
  gap: 4px; padding: 18px 0 14px;
}
.brand {
  width: 36px; height: 36px; border-radius: 8px;
  border: 0; color: var(--accent);
  display: grid; place-items: center; margin-bottom: 14px; background: #000;
  overflow: hidden;
}
.brand img { width: 100%; height: 100%; object-fit: cover; display: block; }
.auth-card .brand {
  width: 56px; height: 56px; margin: 0 0 22px; border-radius: 12px;
}
.rail-btn {
  width: 40px; height: 40px; border: 0; border-radius: 4px;
  background: transparent; color: #6d6962;
  display: grid; place-items: center; position: relative;
}
#navSecurity[hidden] { display: none !important; }
.rail-btn:hover { color: var(--text); background: var(--hover); }
.rail-btn.on { color: var(--accent); background: var(--accent-dim); }
.rail-btn small {
  position: absolute; top: 3px; right: 3px;
  min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px;
  background: var(--bad); color: #fff; font-size: 9px; font-weight: 700;
  font-family: "Avenir Next", sans-serif; display: grid; place-items: center;
}
.rail .spacer { flex: 1; }
.rail-label { display: none; }
.rail .me-btn {
  width: 36px; height: 36px; border-radius: 50%; border: 0; overflow: hidden;
  background: none; display: grid; place-items: center; position: relative; color: var(--dim);
}

.sidebar {
  background: var(--side);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; min-width: 0; min-height: 0; overflow: hidden;
}
.side-top { padding: 22px 20px 8px; }
.side-top.hidden { display: none !important; }
.side-top h1 { font-size: 16px; font-weight: 600; letter-spacing: .18em; text-transform: uppercase; }
.side-top p { font-size: 13px; color: var(--dim); margin-top: 6px; letter-spacing: .04em; }
.finder {
  margin: 8px 16px 12px; padding: 8px 10px;
  border-bottom: 1px solid var(--line); background: transparent;
  display: flex; align-items: center; gap: 8px; color: var(--dim); flex-shrink: 0;
}
.finder input { flex: 1; background: none; border: 0; outline: none; font-size: 16px; }
.chat-tabs {
  display: flex; align-items: center; gap: 4px;
  padding: 0 12px 10px; flex-shrink: 0;
}
.chat-tabs.hidden { display: none !important; }
.chat-tabs [data-chat-tab] {
  flex: 1; min-width: 0; border: 0; border-radius: 8px;
  padding: 8px 6px; background: transparent; color: var(--dim);
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  font-size: 13px; font-weight: 560; letter-spacing: -.01em;
}
.chat-tabs [data-chat-tab].on {
  background: var(--accent-dim); color: var(--accent);
}
.chat-tabs-add {
  width: 34px; height: 34px; flex-shrink: 0; border: 0; border-radius: 8px;
  background: transparent; color: var(--dim); display: grid; place-items: center;
}
.chat-tabs-add:hover { color: var(--accent); background: var(--hover); }
.list { flex: 1 1 0; min-height: 0; overflow: auto; padding-bottom: 24px; }
.group-head {
  display: flex; align-items: center; gap: 8px;
  padding: 18px 20px 6px; color: #6d6962;
  font-family: "Avenir Next", sans-serif;
  font-size: 11px; font-weight: 600; letter-spacing: .16em; text-transform: uppercase;
}
.group-head button {
  margin-left: auto; width: 22px; height: 22px; border: 0; border-radius: 3px;
  background: transparent; color: var(--dim); display: grid; place-items: center;
}
.group-head button:hover { color: var(--text); background: var(--hover); }
.blank { padding: 8px 20px; font-size: 14.5px; color: var(--dim); }

.chip {
  display: grid; grid-template-columns: 36px 1fr; gap: 10px; align-items: center;
  width: calc(100% - 12px); margin: 0 6px; padding: 8px 10px;
  border: 0; border-radius: 0; background: transparent; color: var(--text); text-align: left;
}
.chip:hover { background: var(--hover); }
.chip.on { background: var(--accent-dim); }
.chip-body { min-width: 0; }
.chip-top { display: flex; align-items: baseline; gap: 8px; }
.chip-top b {
  flex: 1; min-width: 0; font-size: 15.5px; font-weight: 560;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip-top span { font-size: 12.5px; color: var(--dim); flex-shrink: 0; font-variant-numeric: tabular-nums; }
.chip-bottom { display: flex; align-items: center; gap: 6px; margin-top: 2px; }
.chip-bottom p {
  flex: 1; min-width: 0; font-size: 14px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.chip mark { background: var(--accent-dim); color: var(--accent); padding: 0 1px; }
.chip-where { display: block; margin-top: 3px; font-size: 11px; color: #6d6962; }
.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--accent); color: var(--on-accent); font-size: 10px; font-weight: 700;
  font-family: "Avenir Next", sans-serif; display: grid; place-items: center; flex-shrink: 0;
}
.badge.at { background: var(--bad); color: #fff; }

.ava {
  width: 36px; height: 36px; border-radius: 50%;
  display: grid; place-items: center;
  font-family: "Avenir Next", sans-serif; font-weight: 600; font-size: 11px; color: #f4efe6;
  flex-shrink: 0; letter-spacing: .04em;
}
.ava.sm { width: 28px; height: 28px; font-size: 10px; }
.ava.lg { width: 48px; height: 48px; font-size: 14px; }
.ava.round { border-radius: 50%; }
.tint-violet { background: #4a4458; }
.tint-teal { background: #35524c; }
.tint-amber { background: #6a5433; }
.tint-rose { background: #5c3d42; }
.tint-sky { background: #3a4a5c; }
.tint-lime { background: #46543a; }

.main {
  display: flex; flex-direction: column;
  min-width: 0; min-height: 0; height: 100%;
  overflow: hidden; background: var(--bg);
}
.main-head {
  min-height: 52px; padding: 8px 16px; flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px;
}
.head-text { flex: 1; min-width: 0; }
.head-text h2 { font-size: 17px; line-height: 1.2; }
.head-text p { font-size: 13px; color: var(--dim); margin-top: 2px; line-height: 1.25; }
.head-text p:empty,
.head-text p.hidden { display: none; }
.head-actions { display: flex; align-items: center; gap: 4px; }
.icon-btn {
  width: 34px; height: 34px; border: 0; border-radius: 4px;
  background: transparent; color: var(--dim); display: grid; place-items: center;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.on { color: var(--accent); }
.pill {
  height: 28px; padding: 0 10px; border-radius: 2px; border: 1px solid var(--line);
  background: transparent; color: var(--dim); font-size: 11px; font-weight: 560;
  display: inline-flex; align-items: center; gap: 6px; letter-spacing: .02em;
}
.pill.safe { color: var(--good); border-color: rgba(156, 186, 140, .3); }
.pill.warn { color: var(--accent); border-color: rgba(198, 163, 106, .35); }
.pill.bad { color: var(--bad); border-color: rgba(199, 123, 116, .4); }

.stream {
  flex: 1 1 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 20px 24px 28px;
}
.stream.bubbles { padding: 20px 22px 28px; }
.day-split { display: flex; justify-content: center; margin: 22px 0 14px; }
.day-split span {
  font-family: "Avenir Next", sans-serif; font-size: 10px; letter-spacing: .14em;
  text-transform: uppercase; color: #6d6962;
}
.notice {
  max-width: 420px; margin: 80px auto; text-align: center; color: var(--dim); font-size: 16px;
}
.notice strong { display: block; margin-bottom: 8px; color: var(--text); font-size: 17px; }
@keyframes flash-hit {
  0%, 35% { background: var(--accent-dim); box-shadow: inset 0 0 0 1px var(--accent); }
  100% { background: transparent; box-shadow: none; }
}
.flash { animation: flash-hit 2.2s ease; }

.post {
  position: relative; display: grid; grid-template-columns: 32px 1fr; gap: 12px;
  padding: 6px 8px; border-radius: 0;
}
.post:hover { background: transparent; }
.post.tight { padding-top: 1px; }
.post.tight .ava { visibility: hidden; height: 0; }
.post-who { display: flex; align-items: baseline; gap: 8px; margin-bottom: 4px; }
.post-who b { font-size: 15px; }
.post-who span, .edited { font-size: 12.5px; color: var(--dim); font-weight: 400; }
.post-body { font-size: 17.5px; line-height: 1.55; white-space: pre-wrap; word-break: break-word; }
.post.gone .post-body { color: var(--dim); font-style: italic; }
.mention { color: var(--accent); background: var(--accent-dim); border-radius: 2px; padding: 0 3px; }
.mention.self { color: #e8c48a; }
.thread-open {
  margin-top: 6px; padding: 0; border: 0; background: none;
  color: var(--accent); font-size: 12px; letter-spacing: .04em;
}

.bubble-line { display: flex; margin: 3px 0; position: relative; }
.bubble-line.mine { justify-content: flex-end; }
.bubble-col { max-width: min(74%, 520px); position: relative; }
.bubble {
  position: relative;
  padding: 10px 14px 8px; border-radius: 2px;
  background: var(--in);
}
.bubble-line.mine .bubble { background: var(--out); }
.bubble .text { font-size: 17.5px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.bubble .meta { display: flex; justify-content: flex-end; align-items: center; gap: 6px; margin-top: 5px; font-size: 12px; color: #8a857c; }
.bubble-line.gone .text { font-style: italic; opacity: .65; }
.bubble-line.mine .reacts { justify-content: flex-end; }

.reacts { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.react {
  height: 24px; padding: 0 7px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); font-size: 12px;
  display: inline-flex; align-items: center; gap: 4px;
}
.react.on { border-color: var(--accent); background: var(--accent-dim); }
.react b { font-size: 11px; color: var(--dim); font-weight: 560; }
.emoji-menu {
  position: fixed; z-index: 80; display: flex; gap: 2px; padding: 6px;
  background: var(--raised); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow);
}
.emoji-menu button {
  width: 34px; height: 34px; border: 0; border-radius: 4px; background: none; font-size: 18px;
}
.emoji-menu button:hover, .emoji-menu button.on { background: var(--hover); }

.post-main {
  position: relative; min-width: 0;
  background: var(--in);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 10px 12px 8px;
}
.post-main::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -40px;
  height: 40px;
}
.tools {
  position: absolute; right: 0; top: 0;
  transform: translateY(calc(-100% - 4px));
  display: none; gap: 1px; z-index: 6;
  padding: 2px; border-radius: 6px; background: var(--raised); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.tools::after {
  content: "";
  position: absolute;
  left: 0; right: 0; top: 100%;
  height: 8px;
}
/* В личке — кнопки сбоку у нижнего края, чтобы не наезжали на соседнее сообщение */
.bubble-line .tools {
  top: auto;
  bottom: 0;
  transform: none;
}
.bubble-line:not(.mine) .tools {
  left: auto;
  right: 0;
  transform: translateX(calc(100% + 6px));
}
.bubble-line.mine .tools {
  right: auto;
  left: 0;
  transform: translateX(calc(-100% - 6px));
}
.bubble-line:not(.mine) .tools::after {
  left: auto; right: 100%; top: 0; bottom: 0;
  width: 10px; height: auto;
}
.bubble-line.mine .tools::after {
  left: 100%; right: auto; top: 0; bottom: 0;
  width: 10px; height: auto;
}
.post:hover .tools,
.post-main:hover .tools,
.bubble-line:hover .tools,
.bubble-col:hover .tools,
.t-post:hover .tools,
.t-root:hover .tools,
.tools:hover {
  display: flex;
}
.tools button {
  width: 30px; height: 28px; border: 0; border-radius: 4px;
  background: transparent; color: var(--dim); display: grid; place-items: center;
}
.tools button:hover { background: var(--hover); color: var(--text); }

.ticks {
  display: inline-flex; align-items: center; margin-left: 4px; vertical-align: middle;
}
.ticks.sent { color: #8d8880; }
.ticks.read { color: #8eb4c9; }
.ticks svg { display: block; }

.readonly {
  padding: 12px 20px 18px; color: var(--dim); font-size: 15px;
  border-top: 1px solid var(--line); text-align: center;
}
.composer { flex-shrink: 0; padding: 10px 18px 16px; }
.reply-to {
  display: flex; align-items: center; gap: 8px; margin-bottom: 8px;
  padding: 6px 0; border-left: 1px solid var(--accent); padding-left: 10px;
  font-size: 12.5px; color: var(--dim);
}
.reply-to b { color: var(--text); }
.reply-to button { margin-left: auto; border: 0; background: none; color: var(--dim); }
.field {
  position: relative; display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 8px 8px 0; border-bottom: 1px solid var(--line);
}
.field:focus-within { border-color: var(--accent); }
.field textarea {
  flex: 1; max-height: 140px; min-height: 28px; padding: 4px 0;
  background: none; border: 0; outline: none; resize: none; font-size: 17.5px; line-height: 1.5;
  font-family: "Iowan Old Style", Palatino, Georgia, serif;
}
.send-btn {
  width: 32px; height: 32px; border: 0; border-radius: 2px; flex-shrink: 0;
  background: var(--accent); color: var(--on-accent); display: grid; place-items: center;
}
.send-btn:disabled { opacity: .35; }
.attach-btn { flex-shrink: 0; color: var(--dim); }
.attach-btn:hover { color: var(--accent); }
.attach-preview {
  display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px;
}
.pending-file {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 8px; border: 1px solid var(--line); background: var(--raised); font-size: 12px;
}
.pending-file button {
  border: 0; background: none; color: var(--dim); font-size: 16px; line-height: 1;
}
.attach-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.attach-chip {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 6px 8px; border: 1px solid var(--line); background: var(--raised);
  color: var(--text); text-align: left; font-size: 13px;
}
.attach-chip:hover { border-color: var(--accent); }
.attach-chip span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-chip small { color: var(--dim); flex-shrink: 0; }
.attach-photo {
  display: block; width: 100%; max-width: 320px; padding: 0; border: 1px solid var(--line);
  background: var(--raised); text-align: left; overflow: hidden;
}
.attach-photo:hover { border-color: var(--accent); }
.attach-photo-img {
  display: block; width: 100%; max-height: 360px; object-fit: contain; background: #0c0c0a;
  min-height: 80px;
}
html[data-theme="snow"] .attach-photo-img { background: #ebe4d6; }
.attach-photo-cap {
  display: block; padding: 6px 8px; font-size: 12px; color: var(--dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.pending-file.photo {
  padding: 0; overflow: hidden; max-width: 120px;
}
.pending-file.photo img {
  display: block; width: 120px; height: 80px; object-fit: cover;
}
.pending-file.photo .pending-meta {
  display: flex; align-items: center; gap: 4px; padding: 4px 6px;
}
.composer .hint { margin-top: 8px; font-size: 12.5px; color: #6d6962; display: flex; align-items: center; gap: 6px; }
.suggest {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 8px);
  background: var(--raised); border: 1px solid var(--line); max-height: 240px; overflow: auto; z-index: 20;
}
.suggest button {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 12px; border: 0; background: none; text-align: left;
}
.suggest button:hover, .suggest button.on { background: var(--hover); }
.suggest b { font-size: 13px; }
.suggest small { color: var(--dim); font-size: 12px; }

.thread {
  background: var(--side); border-left: 1px solid var(--line);
  display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; overflow: hidden;
}
.thread-head {
  min-height: 58px; padding: 0 16px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.thread-head strong { font-size: 13px; letter-spacing: .12em; text-transform: uppercase; }
.thread-head p { font-size: 12px; color: var(--dim); margin-top: 3px; }
.thread-head button { margin-left: auto; }
.thread-stream {
  flex: 1 1 0; min-height: 0; overflow-x: hidden; overflow-y: auto;
  overscroll-behavior: contain; padding: 16px;
}
.t-root {
  position: relative; padding: 12px 0 16px; border-bottom: 1px solid var(--line);
  display: grid; grid-template-columns: 32px 1fr; gap: 10px;
}
.t-post { position: relative; display: grid; grid-template-columns: 28px 1fr; gap: 10px; padding: 8px 0; }
.t-count { margin: 16px 0 6px; font-size: 10px; letter-spacing: .14em; text-transform: uppercase; color: #6d6962; }

.scrim {
  position: fixed; inset: 0; z-index: 60; background: rgba(8, 8, 7, .72);
  display: grid; place-items: center; padding: 24px;
}
.sheet {
  width: 100%; max-width: 440px; max-height: 86vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--line); padding: 28px 26px; box-shadow: var(--shadow);
}
.sheet h2, .sheet h3 { font-size: 18px; }
.sheet .sub { font-size: 13px; color: var(--dim); margin-top: 8px; line-height: 1.55; }
.sheet-head { display: flex; align-items: flex-start; gap: 14px; margin-bottom: 16px; }
.sheet-head .grow { flex: 1; }
label.lbl {
  display: block; font-family: "Avenir Next", sans-serif;
  font-size: 10px; color: var(--dim); margin: 18px 0 7px;
  letter-spacing: .14em; text-transform: uppercase; font-weight: 600;
}
label.check-row {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0 12px; font-size: 15px; color: var(--text);
  font-family: "Avenir Next", system-ui, sans-serif;
  letter-spacing: 0; text-transform: none; font-weight: 500;
}
label.check-row input { width: 18px; height: 18px; accent-color: var(--accent); flex-shrink: 0; }
.sheet input[type="text"], .sheet input[type="password"], .sheet textarea, .sheet select,
.auth-card input[type="text"], .auth-card input[type="password"],
.lock-card input {
  width: 100%; padding: 10px 0; border-radius: 0;
  background: transparent; border: 0; border-bottom: 1px solid var(--line);
  outline: none; font-size: 16px;
}
.sheet input:focus, .sheet textarea:focus, .sheet select:focus,
.auth-card input:focus, .lock-card input:focus { border-color: var(--accent); }
.auth-card input:-webkit-autofill,
.auth-card input:-webkit-autofill:hover,
.auth-card input:-webkit-autofill:focus {
  -webkit-text-fill-color: var(--text);
  caret-color: var(--text);
  transition: background-color 99999s ease-out;
  box-shadow: 0 0 0 1000px var(--panel) inset;
}
.sheet textarea { min-height: 72px; resize: vertical; }
.row-btns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 22px; }
.primary {
  padding: 10px 18px; border: 0; border-radius: 2px;
  background: var(--accent); color: var(--on-accent); font-weight: 600; font-size: 13px;
}
.primary:disabled { opacity: .5; }
.ghost {
  padding: 10px 16px; border: 1px solid var(--line); border-radius: 2px;
  background: transparent; color: var(--text); font-size: 13px; font-weight: 560;
}
.ghost:hover { background: var(--hover); }
.danger {
  padding: 10px 16px; border: 0; border-radius: 2px;
  background: transparent; color: var(--bad); font-weight: 600; font-size: 13px;
  border: 1px solid rgba(199, 123, 116, .35);
}
.people { display: flex; flex-direction: column; gap: 1px; margin-top: 8px; max-height: 38vh; overflow: auto; }
.person {
  display: flex; align-items: center; gap: 10px; width: 100%;
  padding: 8px 4px; border: 0; border-radius: 0; background: transparent; color: var(--text); text-align: left;
}
.person:hover { background: var(--hover); }
.person .grow { flex: 1; min-width: 0; }
.person b { display: block; font-size: 13.5px; }
.person small { display: block; color: var(--dim); font-size: 12px; }
.person .tick { width: 16px; height: 16px; border: 1px solid var(--line); display: grid; place-items: center; color: transparent; }
.person.picked .tick { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.role {
  font-family: "Avenir Next", sans-serif; font-size: 10px; letter-spacing: .1em;
  text-transform: uppercase; color: var(--dim); margin-left: 6px;
}
.role.owner { color: var(--accent); }
.role.moderator { color: var(--good); }
.mini {
  border: 0; background: none; color: var(--dim); font-size: 11px; padding: 4px 6px;
}
.mini:hover { color: var(--text); }
.danger-mini { color: var(--bad); }
.seg { display: grid; gap: 6px; }
.seg button {
  text-align: left; padding: 10px 12px; border: 1px solid var(--line); background: transparent; border-radius: 2px;
}
.seg button.on { border-color: var(--accent); background: var(--accent-dim); }
.seg b { display: block; font-size: 13px; }
.seg small { display: block; color: var(--dim); font-size: 12px; margin-top: 3px; }
.safety {
  margin-top: 16px; padding: 16px 8px; border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  font-family: ui-monospace, "SF Mono", Menlo, monospace; font-size: 15px; line-height: 1.9;
  letter-spacing: .12em; white-space: pre-line; text-align: center; color: var(--accent);
}
.howto { margin-top: 16px; display: grid; gap: 12px; }
.howto p { font-size: 13.5px; color: var(--dim); line-height: 1.55; }
.howto b { color: var(--text); display: block; margin-bottom: 3px; font-size: 12px; letter-spacing: .04em; }
.fp { font-family: ui-monospace, Menlo, monospace; font-size: 11px; color: var(--dim); }
.err { margin-top: 12px; min-height: 16px; color: var(--bad); font-size: 13px; }
.note { margin-top: 14px; font-size: 12.5px; color: var(--dim); line-height: 1.5; }

.notes {
  position: fixed; right: 20px; bottom: 20px; z-index: 90;
  display: flex; flex-direction: column; gap: 8px; width: min(360px, calc(100vw - 40px));
}
.note-card {
  display: grid; grid-template-columns: 8px 1fr auto; gap: 10px; align-items: start;
  padding: 12px 12px 12px 10px; background: var(--raised); border: 1px solid var(--line);
  box-shadow: var(--shadow);
}
.note-card.out { opacity: 0; transform: translateY(6px); transition: .2s; }
.note-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); margin-top: 6px; }
.note-card.good .note-dot { background: var(--good); }
.note-card.bad .note-dot { background: var(--bad); }
.note-text b { display: block; font-size: 13px; margin-bottom: 3px; }
.note-text p { font-size: 13px; color: var(--dim); line-height: 1.4; }
.note-x { border: 0; background: none; color: var(--dim); padding: 2px; }

.dialog h3 { margin-bottom: 8px; }
.dialog p { color: var(--dim); font-size: 14px; line-height: 1.5; }

.lock-screen {
  position: fixed; inset: 0; z-index: 100; background: var(--bg);
  display: grid; place-items: center; padding: 24px;
}
.lock-card { width: min(380px, 100%); }
.lock-card h2 { font-size: 20px; margin-bottom: 10px; }
.lock-card p { color: var(--dim); margin-bottom: 18px; }
.lock-card .primary { width: 100%; margin-top: 18px; }

.auth { height: 100%; display: grid; place-items: center; padding: 24px; overflow: auto; background: var(--bg); }
.auth-card { width: 100%; max-width: 400px; padding: 8px 4px; }
.auth-card .brand { margin: 0 0 22px; }
.auth-card h1 { font-size: 26px; font-weight: 500; }
.auth-card .sub { margin-top: 10px; color: var(--dim); font-size: 14px; line-height: 1.55; }
.auth-card .primary { width: 100%; margin-top: 22px; padding: 12px; }
.qr {
  margin: 18px 0 8px; padding: 16px; background: #fff;
  display: grid; place-items: center;
}
.qr img, .qr svg {
  width: 280px; max-width: 100%; height: auto; aspect-ratio: 1;
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.secret-row { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.secret-row .secret { flex: 1; margin: 0; }
.secret-row .ghost { flex-shrink: 0; padding: 8px 12px; }
.autofill-trap {
  position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none;
  border: 0; padding: 0;
}
.finder { position: relative; }
.theme-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; }
.theme-pick {
  border: 1px solid var(--line); background: var(--raised); color: var(--text);
  padding: 10px 12px; text-align: left; font-size: 13px; font-weight: 560;
}
.theme-pick i { display: block; height: 8px; margin-bottom: 8px; background: var(--accent); }
.theme-pick i[data-swatch="gold"] { background: #c6a36a; }
.theme-pick i[data-swatch="violet"] { background: #9b8cff; }
.theme-pick i[data-swatch="teal"] { background: #5dad9a; }
.theme-pick i[data-swatch="rose"] { background: #d08a84; }
.theme-pick i[data-swatch="steel"] { background: #8aa0b8; }
.theme-pick i[data-swatch="snow"] { background: #8b5a2b; }
.theme-pick.on { border-color: var(--accent); background: var(--accent-dim); }
.contact-row {
  display: flex; align-items: center; gap: 8px; width: 100%;
  padding: 8px 10px; border: 0; background: transparent; text-align: left; color: inherit;
}
.contact-row:hover { background: var(--hover); }
.contact-row .grow { min-width: 0; }
.contact-row b { display: block; font-size: 14px; }
.contact-row small { color: var(--dim); font-size: 12px; }
.contact-row .icon-btn {
  flex-shrink: 0; width: 28px; height: 28px; border: 1px solid var(--line);
  background: var(--raised); color: var(--dim); display: grid; place-items: center;
}
.contact-row .icon-btn:hover { color: var(--accent); border-color: var(--accent); }
.contact-row .icon-btn.add { color: var(--accent); }
.chip-actions { display: flex; gap: 4px; margin-left: auto; flex-shrink: 0; }
.secret { letter-spacing: .12em; font-size: 13px; word-break: break-all; }
.switch { margin-top: 18px; font-size: 13px; color: var(--dim); }
.switch button { border: 0; background: none; color: var(--accent); font-weight: 560; }
.facts { margin-top: 28px; display: grid; gap: 10px; }
.fact { font-size: 12.5px; color: var(--dim); line-height: 1.5; padding-left: 12px; border-left: 1px solid var(--line); }
.demo { margin-top: 22px; font-size: 12px; color: var(--dim); }
.api-box {
  margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line);
  color: var(--dim); font-size: 13px;
}
.api-box summary {
  cursor: pointer; color: var(--text); font-weight: 560;
  font-family: "Avenir Next", "Segoe UI", system-ui, sans-serif;
  list-style: none;
}
.api-box summary::-webkit-details-marker { display: none; }
.api-box[open] summary { margin-bottom: 10px; }
.api-box #apiStatus { margin-top: 10px; line-height: 1.45; }
.demo b { color: var(--text); }
.progress { margin-top: 12px; font-size: 12.5px; color: var(--accent); }
.log { margin-top: 8px; display: grid; gap: 8px; }
.log p { display: flex; gap: 12px; justify-content: space-between; font-size: 13px; color: var(--dim); }
.log b { color: var(--text); font-weight: 560; }

.ava.xl { width: 88px; height: 88px; font-size: 28px; }
.call-stage {
  position: fixed; inset: 0; z-index: 80;
  background: radial-gradient(120% 90% at 50% 0%, #1a1814 0%, #0b0b0a 55%, #070706 100%);
  display: flex; flex-direction: column;
}
.call-stage.hidden { display: none; }
.call-remote {
  flex: 1; position: relative; min-height: 0;
  display: grid; place-items: center; overflow: hidden;
}
.call-remote video {
  width: 100%; height: 100%; object-fit: cover; background: #0a0a09;
}
.call-placeholder {
  display: grid; justify-items: center; gap: 12px; text-align: center; color: var(--text);
  animation: callPulse 1.8s ease-in-out infinite;
}
.call-placeholder p { color: var(--dim); font-size: 14px; }
.call-local {
  position: absolute; right: 20px; bottom: 108px; width: 148px; height: 210px;
  object-fit: cover; background: #141412; border: 1px solid var(--line);
  box-shadow: var(--shadow); z-index: 2;
}
.call-bar {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 3;
  display: flex; justify-content: center; gap: 12px;
  padding: 22px 20px 28px;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,.55));
}
.call-ctrl {
  min-width: 108px; height: 44px; padding: 0 16px;
  border: 1px solid rgba(255,248,235,.14); border-radius: 2px;
  background: rgba(20,20,18,.78); color: var(--text); font-size: 13px; font-weight: 560;
}
.call-ctrl.on { color: var(--accent); border-color: rgba(198,163,106,.45); }
.call-ctrl.end {
  background: #9a3f39; border-color: transparent; color: #fff8f2;
}
.call-ctrl.end:hover { filter: brightness(1.08); }
.call-ring {
  position: fixed; inset: 0; z-index: 90;
  display: grid; place-items: center; padding: 24px;
  background: rgba(8, 8, 7, .78);
}
.call-ring.hidden { display: none; }
.call-ring-card {
  width: min(100%, 380px); padding: 28px 24px;
  background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow);
  display: grid; gap: 16px; justify-items: center; text-align: center;
}
.call-ring-card p { color: var(--dim); font-size: 14px; margin-top: 4px; }
@keyframes callPulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.02); opacity: .88; }
}
@media (max-width: 720px) {
  .call-local { width: 104px; height: 148px; right: 12px; bottom: 96px; }
  .call-ctrl { min-width: 0; flex: 1; }
}

.media-btn { flex-shrink: 0; }
.record-bar {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 0 4px; border-bottom: 1px solid var(--line);
}
.record-bar.hidden { display: none; }
.record-pulse {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--bad);
  animation: recordBlink 1s ease-in-out infinite;
}
.record-pulse.video { background: var(--accent); }
.record-label { flex: 1; color: var(--dim); font-size: 14px; }
@keyframes recordBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: .35; }
}

.voice-note {
  display: flex; align-items: center; gap: 10px;
  min-width: 220px; max-width: 280px; margin-top: 4px;
}
.voice-play {
  width: 36px; height: 36px; border: 0; border-radius: 50%; flex-shrink: 0;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; position: relative;
}
.voice-play::before {
  content: "";
  border-style: solid;
  border-width: 6px 0 6px 10px;
  border-color: transparent transparent transparent currentColor;
  margin-left: 2px;
}
.voice-play.playing::before {
  width: 3px; height: 12px; margin: 0;
  border: 0; background: currentColor;
  box-shadow: 5px 0 0 currentColor;
}
.voice-play.loading { opacity: .55; }
.voice-wave {
  flex: 1; height: 28px; display: flex; align-items: center; gap: 2px;
}
.voice-wave i {
  flex: 1; height: 30%; border-radius: 1px; background: var(--accent);
  opacity: .55; transform-origin: center;
}
.voice-note:hover .voice-wave i,
.voice-play.playing + .voice-wave i {
  animation: voiceBar 1.1s ease-in-out infinite;
}
.voice-wave i:nth-child(2) { height: 55%; animation-delay: .05s; }
.voice-wave i:nth-child(3) { height: 80%; animation-delay: .1s; }
.voice-wave i:nth-child(4) { height: 45%; animation-delay: .15s; }
.voice-wave i:nth-child(5) { height: 95%; animation-delay: .2s; }
.voice-wave i:nth-child(6) { height: 60%; animation-delay: .25s; }
.voice-wave i:nth-child(7) { height: 35%; animation-delay: .3s; }
.voice-wave i:nth-child(8) { height: 70%; animation-delay: .35s; }
.voice-wave i:nth-child(9) { height: 50%; animation-delay: .4s; }
.voice-wave i:nth-child(10) { height: 85%; animation-delay: .45s; }
.voice-wave i:nth-child(11) { height: 40%; animation-delay: .5s; }
.voice-wave i:nth-child(12) { height: 65%; animation-delay: .55s; }
.voice-time {
  font-size: 12px; color: var(--dim); font-variant-numeric: tabular-nums; min-width: 34px; text-align: right;
}
.voice-audio { display: none; }
@keyframes voiceBar {
  0%, 100% { transform: scaleY(1); }
  50% { transform: scaleY(1.45); }
}

.circle-note {
  position: relative; width: 220px; height: 220px; padding: 0; border: 0;
  border-radius: 50%; overflow: hidden; background: #111; cursor: pointer;
  margin: 2px 0 4px; box-shadow: 0 0 0 2px var(--line);
}
.circle-note-video {
  width: 100%; height: 100%; object-fit: cover; display: block;
  transform: scaleX(-1);
}
.circle-note-play {
  position: absolute; inset: 0; margin: auto; width: 48px; height: 48px;
  border-radius: 50%; background: rgba(0,0,0,.45);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,.18);
}
.circle-note-play::before {
  content: ""; position: absolute; left: 19px; top: 16px;
  border-style: solid; border-width: 8px 0 8px 14px;
  border-color: transparent transparent transparent #fff;
}
.circle-note.playing .circle-note-play { opacity: 0; pointer-events: none; }
.circle-note.loading { opacity: .7; }
.circle-note-time {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  font-size: 12px; color: #fff; background: rgba(0,0,0,.45);
  padding: 2px 8px; border-radius: 10px; font-variant-numeric: tabular-nums;
}
.bubble-line.circle-only .bubble {
  background: transparent; padding: 0; box-shadow: none; border: 0;
}
.bubble-line.circle-only .bubble .meta {
  justify-content: flex-start; margin-top: 8px; padding: 0 4px;
}
.bubble-line.circle-only.mine .bubble .meta { justify-content: flex-end; }
html[data-theme="snow"] .bubble-line.circle-only .bubble {
  background: transparent; border: 0; box-shadow: none;
}

.circle-rec {
  position: fixed; inset: 0; z-index: 95;
  display: grid; place-items: center; gap: 18px;
  background: rgba(6, 6, 5, .88); padding: 24px; text-align: center;
}
.circle-rec.hidden { display: none; }
.circle-rec-frame {
  position: relative; width: min(72vw, 320px); aspect-ratio: 1;
  border-radius: 50%; overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255,248,235,.12);
}
.circle-rec-frame video {
  width: 100%; height: 100%; object-fit: cover; transform: scaleX(-1);
}
.circle-rec-ring {
  position: absolute; inset: -4px; width: calc(100% + 8px); height: calc(100% + 8px);
  transform: rotate(-90deg); pointer-events: none;
}
.circle-rec-ring circle {
  fill: none; stroke: var(--accent); stroke-width: 3;
  stroke-linecap: round; stroke-dasharray: 100; stroke-dashoffset: 100;
  transition: stroke-dashoffset .2s linear;
}
.circle-rec p { color: var(--dim); font-size: 14px; }
.circle-rec .row-btns { justify-content: center; }

.back-btn { display: none; }

@media (max-width: 720px) {
  .circle-note { width: 180px; height: 180px; }
  .voice-note { min-width: 180px; }

  html, body {
    height: 100%;
    height: -webkit-fill-available;
    min-height: 100%;
    min-height: -webkit-fill-available;
    overscroll-behavior: none;
    background: var(--side);
  }
  body {
    height: 100%;
    height: -webkit-fill-available;
    min-height: -webkit-fill-available;
    background: var(--side);
  }
  .app,
  .app.no-thread,
  .app.show-list {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    height: 100svh;
    min-height: -webkit-fill-available;
    max-height: 100%;
    background: var(--side);
  }

  /* Bottom tab bar: only the button row — same color as list, no black bands */
  .app > .rail {
    grid-column: 1;
    grid-row: 1;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    flex-direction: row;
    justify-content: space-around;
    align-items: center;
    gap: 0;
    width: 100%;
    height: calc(52px + env(safe-area-inset-bottom, 0px));
    min-height: 0;
    margin: 0;
    padding: 0 2px env(safe-area-inset-bottom, 0px);
    border-right: 0;
    border-top: 1px solid var(--line);
    background: var(--side);
    box-shadow: none;
    backdrop-filter: none;
    -webkit-backdrop-filter: none;
  }
  .app.show-list > .sidebar {
    display: flex;
    border-right: 0;
    padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    background: var(--side);
  }

  .app > .sidebar,
  .app > .main,
  .app > .thread {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    width: 100%;
  }

  .brand,
  .rail .spacer,
  #navSecurity {
    display: none !important;
  }

  .rail-btn,
  .rail .me-btn {
    flex: 1;
    align-self: stretch;
    width: auto;
    height: 52px;
    min-height: 52px;
    max-height: 52px;
    border-radius: 10px;
    gap: 2px;
    padding: 6px 0 4px;
    place-items: center;
    grid-template-rows: auto auto;
    box-sizing: border-box;
  }

  .rail-label {
    display: block;
    font-family: "Avenir Next", system-ui, sans-serif;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: .02em;
    line-height: 1.1;
  }

  .rail .me-btn {
    overflow: visible;
    border-radius: 10px;
  }
  .rail .me-btn .ava {
    width: 22px;
    height: 22px;
    font-size: 10px;
  }

  .rail-btn small {
    top: 2px;
    right: calc(50% - 18px);
  }

  /* List mode (Telegram chats) */
  .app.show-list > .sidebar {
    display: flex;
    border-right: 0;
    padding-bottom: calc(52px + env(safe-area-inset-bottom, 0px));
    background: var(--side);
  }
  .app.show-list > .main,
  .app.show-list > .thread {
    display: none;
  }

  /* Chat mode — fullscreen, hide bottom tabs */
  .app:not(.show-list) > .sidebar,
  .app:not(.show-list) > .thread {
    display: none;
  }
  .app:not(.show-list) > .rail {
    display: none;
  }
  .app:not(.show-list) > .main {
    display: flex;
    flex-direction: column;
  }

  .app .thread { display: none; }
  .back-btn { display: grid; flex-shrink: 0; }

  .side-top {
    display: none !important;
  }
  .sidebar {
    padding-top: max(10px, env(safe-area-inset-top));
    background: var(--side);
  }
  .finder {
    margin: 4px 12px 6px;
    padding: 10px 12px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
  }
  .chat-tabs {
    padding: 0 10px 8px;
  }
  .chip {
    width: 100%;
    margin: 0;
    padding: 12px 16px;
    grid-template-columns: 44px 1fr;
    gap: 12px;
    border-radius: 0;
  }
  .chip .ava { width: 44px; height: 44px; }
  .list { padding-bottom: 8px; }

  .main-head {
    padding: max(8px, env(safe-area-inset-top)) 10px 10px 6px;
  }
  .stream { padding: 12px 12px 16px; }
  .composer {
    padding: 8px 10px max(10px, env(safe-area-inset-bottom));
  }
  .head-text h2 { font-size: 16px; }
  .pill span { display: none; }
  .notes {
    left: 12px;
    right: 12px;
    bottom: calc(60px + env(safe-area-inset-bottom));
  }
  .app:not(.show-list) .notes {
    bottom: max(16px, env(safe-area-inset-bottom));
  }
}



