:root {
  --bg: #0f0f0f;
  --sidebar: #212121;
  --hover: #2a2a2a;
  --active: #2c2c2c;
  --line: rgba(255, 255, 255, 0.06);
  --text: #ffffff;
  --muted: #aaaaaa;
  --accent: #8774e1;
  --accent-2: #b39ddb;
  --out: #8774e1;
  --in: #212121;
  --danger: #e75c5c;
  --search: transparent;
  --app-height: 100dvh;
  color-scheme: dark;
  font-family: Roboto, "Segoe UI", Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background-color: #000;
  background-image: url("/static/wallpaper.svg");
  background-size: 420px 420px;
  color: var(--text);
}

button, input, textarea { font: inherit; color: inherit; }

.screen { display: none; height: var(--app-height); }
.screen.active { display: flex; }

.weba-login {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.login-card {
  width: min(360px, 100%);
  padding: 36px 28px 28px;
  border-radius: 24px;
  background: #212121;
  text-align: center;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.45);
}

.qr-mark {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  border-radius: 18px;
  display: grid;
  place-items: center;
  color: #8774e1;
  background: #2a2a2a;
}

h1, h2 { margin: 0 0 8px; font-weight: 500; }
h1 { font-size: 22px; }
h2 { font-size: 20px; }
.lede { color: var(--muted); line-height: 1.45; margin: 0 0 18px; font-size: 14px; }
.fine { color: var(--muted); font-size: 13px; }

.account-chip {
  display: inline-flex;
  flex-direction: column;
  gap: 2px;
  margin: 0 auto 16px;
  padding: 10px 14px;
  border-radius: 14px;
  background: #2a2a2a;
  text-align: left;
}
.account-chip span { color: var(--muted); font-size: 13px; }

.primary, .send-btn, .icon-btn, .text-btn { cursor: pointer; }
.primary {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 12px 18px;
  background: var(--accent);
  color: white;
  font-weight: 500;
  font-size: 16px;
}
.primary:hover { filter: brightness(1.06); }
.primary:disabled { opacity: 0.55; cursor: default; }

.text-btn, .icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 0;
}
.icon-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: var(--muted);
  flex: none;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }

.setup-card { text-align: left; }
.setup-card label { display: block; margin-bottom: 12px; font-size: 13px; color: var(--muted); }
.setup-card input {
  width: 100%;
  margin-top: 6px;
  border: 0;
  border-radius: 12px;
  padding: 12px 14px;
  background: #2a2a2a;
  outline: none;
}
.error { min-height: 1.2em; color: var(--danger); }

#client.active {
  display: grid;
  grid-template-columns: 420px minmax(0, 1fr);
  background: transparent;
}

.pane-list, .pane-chat { min-height: 0; min-width: 0; }
.pane-list {
  display: flex;
  flex-direction: column;
  background: var(--sidebar);
}
.pane-chat {
  display: flex;
  flex-direction: column;
  background-color: transparent;
}

.list-head, .chat-head {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 56px;
  padding: 6px 10px;
  background: var(--sidebar);
}
.chat-head { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28); z-index: 1; }
.chat-title { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.chat-title strong, .name-line strong, .menu-account strong {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 16px;
  font-weight: 500;
}
.name-line { display: flex; align-items: center; gap: 6px; min-width: 0; }
#selfUser, #chatKind { color: var(--muted); font-size: 13px; }

.search-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border-radius: 20px;
  background: #181818;
  color: var(--muted);
}
.search-wrap input {
  flex: 1;
  border: 0;
  outline: none;
  background: transparent;
  padding: 8px 0;
  font-size: 16px;
}
.search-wrap input::placeholder { color: #8e8e8e; }

.side-menu {
  display: flex;
  flex-direction: column;
  padding: 8px 0 16px;
  overflow: auto;
}
.settings { display: flex; flex-direction: column; min-height: 0; overflow: auto; }
.settings-note { color: var(--muted); font-size: 13px; padding: 8px 20px 16px; margin: 0; }
.menu-account {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px 20px 20px;
}
.side-menu button, .menu-row {
  display: flex;
  align-items: center;
  width: 100%;
  border: 0;
  background: transparent;
  color: var(--text);
  text-align: left;
  padding: 13px 20px;
  font-size: 16px;
  cursor: pointer;
}
.side-menu button:hover, .menu-row:hover { background: var(--hover); }
.menu-row { justify-content: space-between; cursor: pointer; }
.toggle {
  width: 34px;
  height: 18px;
  border-radius: 9px;
  background: #555;
  position: relative;
}
.toggle.on { background: var(--accent); }
.toggle::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #fff;
}
.toggle.on::after { left: 18px; }

.dialog-list, .messages { flex: 1; overflow: auto; min-height: 0; }
.dialog-list::-webkit-scrollbar, .messages::-webkit-scrollbar { width: 4px; }
.dialog-list::-webkit-scrollbar-thumb, .messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.12);
  border-radius: 4px;
}

.dialog {
  width: 100%;
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr);
  gap: 12px;
  padding: 8px 14px;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.dialog { position: relative; }
.dialog:hover { background: var(--hover); }
.dialog.active { background: rgba(135, 116, 225, 0.18); box-shadow: inset 3px 0 0 var(--accent); }
#chatKind.online { color: #0ac630; }
.dialog::after {
  content: "";
  position: absolute;
  left: 80px;
  right: 12px;
  bottom: 0;
  height: 1px;
  background: var(--line);
}
.dialog:hover::after, .dialog.active::after { opacity: 0; }
.dialog.unread .name-line strong { font-weight: 700; }
.dialog-top, .dialog-bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}
.dialog-top { margin-bottom: 2px; }
.dialog-top strong, .preview {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 500;
}
.preview { color: var(--muted); font-size: 15px; min-width: 0; font-weight: 400; }
.preview b { color: #d0d0d0; font-weight: 500; }
.when { color: var(--muted); font-size: 13px; flex: none; }
.dialog.unread .when { color: var(--accent); }
.badge {
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 11px;
  background: var(--accent);
  color: white;
  font-size: 12px;
  font-weight: 500;
  line-height: 22px;
  text-align: center;
  flex: none;
}

.kind-tag {
  flex: none;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.03em;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 3px;
  text-transform: uppercase;
  background: var(--accent);
  color: #fff;
}
.kind-tag.channel,
.kind-tag.saved,
.kind-tag.group { display: none; }

.avatar {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  overflow: hidden;
  font-weight: 500;
  font-size: 18px;
  color: white;
  flex: none;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.avatar.sm { width: 42px; height: 42px; font-size: 15px; }
.avatar.xs { width: 32px; height: 32px; font-size: 12px; }

.messages {
  padding: 10px 8px 12px;
  display: flex;
  flex-direction: column;
}
.empty-chat, .hint-row {
  color: var(--muted);
  text-align: center;
  margin: 18px 8px;
  font-size: 15px;
}
.day, .service {
  align-self: center;
  width: fit-content;
  max-width: 86%;
  margin: 8px auto;
  padding: 4px 11px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  color: #ddd;
  font-size: 13px;
  text-align: center;
}

.msg-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin: 2px 8px;
  max-width: 100%;
}
.msg-row.out { justify-content: flex-end; }
.msg-row.cont { margin-top: 1px; }
.msg-row .avatar.xs { visibility: hidden; }
.msg-row:not(.cont) .avatar.xs { visibility: visible; }

.bubble {
  position: relative;
  width: fit-content;
  max-width: min(65%, 480px);
  padding: 6px 9px 5px;
  border-radius: 16px;
  line-height: 1.35;
  font-size: 16px;
  white-space: pre-wrap;
  word-break: break-word;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.18);
}
.bubble.out {
  background: var(--out);
  border-bottom-right-radius: 6px;
}
.bubble.in {
  background: var(--in);
  border-bottom-left-radius: 6px;
}
.bubble.channel { max-width: min(86%, 640px); }
.bubble .who {
  display: block;
  color: #c5b6f2;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 1px;
}
.bubble .time {
  display: inline-block;
  float: right;
  margin: 5px 0 0 10px;
  color: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  position: relative;
  top: 2px;
}

.composer {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 6px 8px calc(6px + env(safe-area-inset-bottom));
  background: var(--sidebar);
}
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  min-height: 44px;
  margin: 0;
  border: 0;
  outline: none;
  border-radius: 22px;
  padding: 12px 16px;
  background: #2c2c2c;
  line-height: 1.3;
  font-size: 16px;
}
.send-btn {
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  display: grid;
  place-items: center;
  flex: none;
}

.mute-bar, .channel-bar {
  text-align: center;
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom));
  background: #1a1a1a;
  color: var(--text);
  font-size: 16px;
  font-weight: 500;
}
.channel-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #212121;
}
.channel-bar strong { flex: 1; text-align: center; font-weight: 500; }
.channel-bar-icon, .channel-bar-share { color: var(--muted); width: 28px; }

.pin-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #212121;
  border-bottom: 1px solid var(--line);
  min-height: 52px;
}
.pin-mark {
  width: 3px;
  align-self: stretch;
  margin: 4px 0;
  border-radius: 2px;
  background: var(--accent-2);
  flex: none;
}
.pin-bar > div { min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.pin-label { color: var(--accent-2); font-size: 13px; font-weight: 500; }
#pinText {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.messages.channel-feed {
  align-items: center;
  padding: 16px 14px 22px;
}
.post {
  width: min(100%, 520px);
  margin: 10px 0;
  background: #212121;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}
.post-media { position: relative; }
.post-media img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: cover;
}
.post-stamp {
  position: absolute;
  right: 10px;
  bottom: 8px;
  padding: 2px 6px;
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.45);
  color: #fff;
  font-size: 12px;
}
.post-body { padding: 10px 12px 8px; }
.post-text { font-size: 16px; line-height: 1.4; white-space: pre-wrap; word-break: break-word; }
.post-page {
  margin-top: 10px;
  padding: 16px 16px 14px;
  border-radius: 16px;
  background: #fff;
  color: #111;
}
.post-page h3 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.post-page p { margin: 0; font-size: 15px; line-height: 1.45; color: #333; }
.post-reacts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}
.react {
  padding: 4px 8px;
  border-radius: 14px;
  background: #2c2c2c;
  font-size: 14px;
}
.post-foot {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
  color: #8b8b8b;
  font-size: 13px;
}

.reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 7px 10px;
  border-left: 3px solid var(--accent);
  border-radius: 8px;
  background: #2c2c2c;
}
.reply-bar strong { display: block; font-size: 13px; color: var(--accent-2); }
.reply-bar span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  max-width: 62vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bubble-reply {
  display: block;
  margin: 0 0 5px;
  padding: 3px 7px;
  border-left: 2px solid #c5b6f2;
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.bubble-photo, .bubble-sticker {
  display: block;
  max-width: min(68vw, 320px);
  max-height: 280px;
  margin: 2px 0 4px;
  border-radius: 10px;
}
.bubble-file { display: block; margin: 4px 0; color: #efe8ff; text-decoration: none; }

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(12px);
  max-width: min(520px, calc(100% - 24px));
  padding: 10px 14px;
  border-radius: 12px;
  background: #2a2a2a;
  color: white;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.mobile-only { display: none; }

.folders {
  display: flex;
  gap: 4px;
  padding: 0 10px 8px;
  overflow: auto;
}
.folders::-webkit-scrollbar { display: none; }
.folders button {
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 6px 12px;
  border-radius: 16px;
  cursor: pointer;
  font-size: 14px;
  white-space: nowrap;
}
.folders button.on { background: rgba(135, 116, 225, 0.2); color: #fff; }

.menu-ico {
  width: 28px;
  height: 28px;
  margin-right: 14px;
  border-radius: 8px;
  display: inline-grid;
  place-items: center;
  color: #fff;
  flex: none;
  font-size: 15px;
}
.menu-ico::before { line-height: 1; }
.menu-ico.saved { background: #5aa7e6; }
.menu-ico.saved::before { content: "★"; }
.menu-ico.contacts { background: #6cc259; }
.menu-ico.contacts::before { content: "☺"; }
.menu-ico.gear { background: #e17076; }
.menu-ico.gear::before { content: "⚙"; }
.side-menu button { gap: 0; }

.settings-block {
  margin: 4px 12px 8px;
  border-radius: 14px;
  overflow: hidden;
  background: #1a1a1a;
}
.settings-block .menu-row:hover { background: #242424; }

.chat-more { margin-left: auto; }
.pane-chat { position: relative; }

.placeholder {
  margin: auto;
  width: min(320px, calc(100% - 48px));
  padding: 28px 26px 24px;
  border-radius: 18px;
  background: rgba(0, 0, 0, 0.42);
  text-align: center;
  backdrop-filter: blur(10px);
}
.placeholder-mark { color: #fff; margin-bottom: 8px; }
.placeholder strong { display: block; font-size: 18px; font-weight: 500; }
.placeholder p { margin: 8px 0 0; color: rgba(255, 255, 255, 0.72); font-size: 14px; line-height: 1.4; }

.verified {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #4eb4f5;
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  display: inline-grid;
  place-items: center;
  flex: none;
}
.checks { margin-right: 3px; color: #8ab4f8; font-size: 13px; }
.time .checks { margin: 0 0 0 3px; color: rgba(255, 255, 255, 0.72); }

.msg-row.tail .bubble.out::after,
.msg-row.tail .bubble.in::after {
  content: "";
  position: absolute;
  bottom: 0;
  width: 0;
  height: 0;
}
.msg-row.tail .bubble.out::after {
  right: -6px;
  border-width: 0 0 10px 8px;
  border-style: solid;
  border-color: transparent transparent var(--out) transparent;
}
.msg-row.tail .bubble.in::after {
  left: -6px;
  border-width: 0 8px 10px 0;
  border-style: solid;
  border-color: transparent transparent var(--in) transparent;
}
.bubble.plain {
  background: transparent;
  box-shadow: none;
  padding: 0;
}
.bubble.plain::after { display: none; }
.bubble-reacts {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.avatar.saved { box-shadow: inset 0 0 0 2px #e8b84a; }
.avatar.xl { width: 96px; height: 96px; font-size: 32px; }

.peer-info {
  position: absolute;
  top: 64px;
  right: 12px;
  z-index: 4;
  width: min(280px, calc(100% - 24px));
  padding: 16px 16px 22px;
  border-radius: 16px;
  background: #212121;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
}
.peer-info .icon-btn { position: absolute; top: 6px; right: 6px; }
#peerInfoSub { color: var(--muted); font-size: 14px; }

.jump {
  position: absolute;
  right: 18px;
  bottom: 78px;
  z-index: 3;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  background: #2a2a2a;
  color: var(--muted);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  display: grid;
  place-items: center;
  cursor: pointer;
}
.emoji-panel {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 2px;
  padding: 6px;
  border-radius: 16px;
  background: #181818;
}
.emoji-panel button {
  border: 0;
  background: transparent;
  height: 36px;
  border-radius: 8px;
  font-size: 22px;
  cursor: pointer;
}
.emoji-panel button:hover { background: #2a2a2a; }
.channel-bar-icon::before { content: "🔔"; }
.channel-bar-share::before { content: "↗"; }
.post-comments:not(:empty)::before { content: "💬 "; }
.post-views::before { content: "👁 "; }

html.day {
  --sidebar: #ffffff;
  --hover: #f4f4f5;
  --active: #3390ec;
  --text: #222;
  --muted: #707579;
  --accent: #3390ec;
  --accent-2: #3390ec;
  --out: #eeffde;
  --in: #ffffff;
  --line: rgba(0, 0, 0, 0.08);
}
html.day body {
  background-color: #8eaae6;
  background-image: none;
}
html.day .search-wrap,
html.day .settings-block,
html.day .emoji-panel,
html.day .composer textarea { background: #f1f1f1; color: #222; }
html.day .login-card,
html.day .composer,
html.day .list-head,
html.day .chat-head,
html.day .pin-bar,
html.day .channel-bar,
html.day .peer-info { background: #fff; color: #222; }
html.day .dialog.active {
  background: #3390ec;
  box-shadow: none;
  color: #fff;
}
html.day .dialog.active .preview,
html.day .dialog.active .when,
html.day .dialog.active .preview b,
html.day .dialog.active .checks { color: rgba(255, 255, 255, 0.86); }
html.day .bubble.out { color: #222; }
html.day .bubble.out .time,
html.day .bubble.out .time .checks { color: rgba(0, 0, 0, 0.45); }
html.day .bubble.in { box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06); }
html.day .folders button.on { background: rgba(51, 144, 236, 0.14); color: #3390ec; }
html.day .placeholder { background: rgba(255, 255, 255, 0.86); color: #222; }
html.day .placeholder p { color: #707579; }
html.day .placeholder-mark { color: #3390ec; }
html.day .post,
html.day .jump { background: #fff; color: #222; }
html.no-motion *,
html.no-motion *::before,
html.no-motion *::after { animation: none !important; transition: none !important; }

@media (max-width: 760px) {
  #client.active { grid-template-columns: 1fr; }
  #client .pane-chat { display: none; }
  #client.show-chat .pane-list { display: none; }
  #client.show-chat .pane-chat { display: flex; }
  .mobile-only { display: grid; }
  .bubble { max-width: 82%; }
}
