﻿:root {
  --bg: #0e1621;
  --panel: #17212b;
  --panel-2: #1e2a36;
  --hover: #202b36;
  --active: #2b5278;
  --out: #2b5278;
  --in: #182533;
  --text: #f5f5f5;
  --muted: #708499;
  --accent: #3390ec;
  --accent-2: #64b5ef;
  --green: #4fae4e;
  --red: #e53935;
  --radius: 12px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

button, input, textarea { font-family: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
.screen { height: 100vh; height: 100dvh; }

::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-thumb { background: #2b3a48; border-radius: 4px; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- Auth ---------- */

.auth {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: auto;
  padding: 20px;
}

.auth-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(900px 500px at 15% 10%, rgba(51, 144, 236, 0.18), transparent 60%),
    radial-gradient(700px 500px at 90% 90%, rgba(43, 82, 120, 0.35), transparent 60%),
    var(--bg);
}

.auth-card {
  position: relative;
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border-radius: 18px;
  padding: 28px 26px 24px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  border: 1px solid #22303d;
}

.auth-logo {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.5px;
  color: #fff;
}
.auth-logo span { color: var(--accent); }
.auth-sub { color: var(--muted); font-size: 13px; margin: 4px 0 22px; }
.auth-title { font-size: 19px; font-weight: 600; margin-bottom: 4px; }
.auth-note { color: var(--muted); font-size: 13px; margin-bottom: 12px; line-height: 1.4; }

.auth-download {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #22303d;
}
.auth-download-btn {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  text-decoration: none;
}
.auth-download-sub {
  color: var(--muted);
  font-size: 11px;
  font-weight: 400;
}

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  padding: 3px;
  border-radius: 10px;
  margin-bottom: 18px;
}
.auth-tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 8px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
}
.auth-tabs button.active { background: var(--panel-2); color: var(--text); }

.auth-form { display: flex; flex-direction: column; gap: 13px; }

.field { display: flex; flex-direction: column; gap: 6px; }
.field span {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
.field input, .field textarea {
  background: var(--bg);
  border: 1px solid #263442;
  color: var(--text);
  border-radius: 10px;
  padding: 11px 12px;
  font-size: 15px;
  outline: none;
  width: 100%;
  transition: border-color 0.15s;
}
.field input:focus, .field textarea:focus { border-color: var(--accent); }

.btn {
  border: 0;
  border-radius: 10px;
  padding: 11px 16px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  background: var(--panel-2);
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:hover { background: #2b82d9; }
.btn.danger { background: #b3352f; color: #fff; }
.btn.ghost { background: transparent; border: 1px solid #2b3a48; }
.btn.small { padding: 7px 10px; font-size: 13px; border-radius: 8px; }
.btn:disabled { opacity: 0.5; cursor: default; }

.link {
  border: 0;
  background: transparent;
  color: var(--accent-2);
  font-size: 13px;
  padding: 2px;
  align-self: center;
}
.link.muted { color: var(--muted); }
.link:hover { text-decoration: underline; }

.form-error { color: #ff7b72; font-size: 13px; min-height: 0; line-height: 1.35; }
.form-error:empty { display: none; }
.demo-code {
  background: rgba(51, 144, 236, 0.12);
  border: 1px dashed rgba(100, 181, 239, 0.5);
  color: var(--accent-2);
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

/* ---------- Layout ---------- */

.app { display: flex; overflow: hidden; }

.sidebar {
  width: 380px;
  max-width: 42vw;
  flex: 0 0 auto;
  background: var(--panel);
  border-right: 1px solid #0a1119;
  display: flex;
  flex-direction: column;
  min-width: 0;
  position: relative;
  z-index: 10;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 10px 7px;
  background: var(--panel);
  border-bottom: 1px solid #101a24;
}
.brand { font-size: 17px; font-weight: 700; flex: 1; letter-spacing: -0.2px; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
}
.icon-btn:hover { background: var(--hover); color: var(--text); }
.icon-btn.small { width: 26px; height: 26px; font-size: 16px; }

.chat-list { flex: 1; overflow-y: auto; padding: 2px 0 10px; }

.chat-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 11px;
  margin: 1px 6px;
  border-radius: 10px;
  cursor: pointer;
  min-width: 0;
}
.chat-item:hover { background: var(--hover); }
.chat-item.active { background: var(--active); }
.chat-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.chat-top { display: flex; align-items: center; gap: 6px; }
.chat-name {
  font-weight: 600;
  font-size: 15px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-time { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.chat-item.active .chat-time, .chat-item.active .chat-preview { color: #b8d4ef; }
.chat-bottom { display: flex; align-items: center; gap: 5px; min-width: 0; }
.chat-preview {
  flex: 1;
  min-width: 0;
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-preview.deleted { font-style: italic; }
.chat-preview .sender { color: #8bb8e8; }
.chat-item.active .chat-preview .sender { color: #d6e9fb; }
.unread {
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  min-width: 19px;
  height: 19px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  flex: 0 0 auto;
}
.unread.muted { background: #2c3b4a; color: #9fb3c6; }

.avatar {
  width: 52px;
  height: 52px;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 19px;
  flex: 0 0 auto;
  position: relative;
  user-select: none;
  border: 0;
  padding: 0;
  line-height: 1;
}
.avatar.small { width: 38px; height: 38px; font-size: 14px; }
.avatar.big { width: 76px; height: 76px; font-size: 28px; }
.avatar.has-avatar { background: transparent; }
.avatar-img {
  width: 100%;
  height: 100%;
  min-width: 100%;
  min-height: 100%;
  flex: 0 0 100%;
  object-fit: cover;
  object-position: center;
  border-radius: 50%;
  display: block;
}
.online-dot {
  position: absolute;
  right: 1px;
  bottom: 1px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--panel);
  z-index: 2;
}
.chat-item.active .online-dot { border-color: var(--active); }

.sidebar-foot { padding: 6px 12px; font-size: 11px; color: #4d6175; text-align: center; }

/* ---------- Stories strip ---------- */

.stories {
  display: flex;
  gap: 12px;
  padding: 10px 12px 8px;
  overflow-x: auto;
  border-bottom: 1px solid #101a24;
  flex: 0 0 auto;
  min-height: 92px;
}
.stories:empty { display: none; }
.story-item { width: 60px; flex: 0 0 auto; text-align: center; cursor: pointer; }
.story-ring {
  width: 58px;
  height: 58px;
  margin: 0 auto;
  border-radius: 50%;
  padding: 2px;
  background: linear-gradient(135deg, #3390ec, #64b5ef 60%, #a0d0f5);
}
.story-ring.viewed { background: #35485a; }
.story-ring.add {
  background: transparent;
  border: 2px dashed #3a4d5f;
  padding: 2px;
  color: var(--accent-2);
  font-size: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.story-inner {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background: var(--panel);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 17px;
  color: #fff;
  border: 2px solid var(--panel);
}
.story-name {
  font-size: 11px;
  color: var(--muted);
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Chat pane ---------- */

.chat-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  position: relative;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  gap: 8px;
}
.empty-logo { font-size: 34px; font-weight: 700; color: #2f4356; letter-spacing: -1px; }
.empty-note { font-size: 14px; }

.chat-view { flex: 1; display: flex; flex-direction: column; min-height: 0; }

.chat-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid #101a24;
  flex: 0 0 auto;
  min-height: 58px;
}
.back { display: none; }
.chat-head-info { flex: 1; min-width: 0; }
.chat-head-title {
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}
.chat-head-title span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-status { font-size: 12.5px; color: var(--muted); min-height: 17px; }
.chat-status.online { color: var(--accent-2); }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  font-size: 10px;
  font-weight: 700;
  flex: 0 0 auto;
}
.badge.verified { background: #3f8fd8; color: #fff; }
.badge.plus { background: #b8862e; color: #ffe9b0; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  background-image:
    radial-gradient(700px 400px at 12% 0%, rgba(51, 144, 236, 0.06), transparent 70%),
    radial-gradient(700px 400px at 90% 100%, rgba(43, 82, 120, 0.12), transparent 70%);
}

.messages-empty {
  margin: auto;
  color: var(--muted);
  font-size: 13px;
  background: rgba(23, 33, 43, 0.7);
  padding: 8px 14px;
  border-radius: 20px;
}

.day-divider {
  align-self: center;
  margin: 12px 0 8px;
  background: rgba(23, 33, 43, 0.85);
  color: #9fb3c6;
  font-size: 12px;
  padding: 4px 12px;
  border-radius: 14px;
}

.msg-row { display: flex; justify-content: flex-start; margin-top: 2px; }
.msg-row.own { justify-content: flex-end; }
.msg-row.first { margin-top: 8px; }

.msg-bubble {
  max-width: min(74%, 560px);
  background: var(--in);
  border-radius: 12px;
  padding: 7px 10px 5px;
  min-width: 76px;
  position: relative;
}
.msg-row.own .msg-bubble { background: var(--out); border-bottom-right-radius: 4px; }
.msg-row:not(.own) .msg-bubble { border-bottom-left-radius: 4px; }

.msg-author {
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 2px;
  color: #8bb8e8;
}
.msg-text {
  font-size: 15px;
  line-height: 1.35;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.msg-text.deleted { color: #9aa8b6; font-style: italic; font-size: 13.5px; }
.msg-reply {
  border-left: 2px solid var(--accent-2);
  background: rgba(0, 0, 0, 0.18);
  border-radius: 5px;
  padding: 3px 8px;
  margin-bottom: 4px;
  font-size: 12.5px;
  min-width: 0;
}
.reply-author { color: var(--accent-2); font-weight: 600; }
.msg-reply .reply-text {
  color: #c5d3e0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 340px;
}
.msg-reply.deleted .reply-text { font-style: italic; color: #93a3b2; }

.msg-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  font-size: 11px;
  color: #9bb0c4;
  margin-top: 2px;
  line-height: 1;
}
.msg-row.own .msg-meta { color: #b8d4ef; }
.tick { letter-spacing: -3px; padding-right: 2px; }
.tick.read { color: var(--accent-2); }

.typing-bar {
  height: 20px;
  padding: 0 18px;
  font-size: 12px;
  color: var(--accent-2);
  flex: 0 0 auto;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.reply-preview {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 14px;
  background: var(--panel);
  border-top: 1px solid #101a24;
}
.reply-line { width: 3px; align-self: stretch; background: var(--accent); border-radius: 3px; }
.reply-body { flex: 1; min-width: 0; }
.reply-preview .reply-author { font-size: 12.5px; }
.reply-preview .reply-text {
  font-size: 13px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 9px 12px calc(10px + env(safe-area-inset-bottom));
  background: var(--panel);
  flex: 0 0 auto;
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 0;
  outline: none;
  background: var(--bg);
  color: var(--text);
  border-radius: 20px;
  padding: 11px 15px;
  font-size: 15px;
  line-height: 1.35;
  max-height: 150px;
  min-height: 42px;
}
.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: var(--accent);
  color: #fff;
  font-size: 17px;
  flex: 0 0 auto;
}
.send-btn:hover { background: #2b82d9; }

/* ---------- Message context menu ---------- */

.msg-menu {
  position: fixed;
  z-index: 95;
  background: var(--panel-2);
  border: 1px solid #263442;
  border-radius: 10px;
  padding: 4px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
  min-width: 160px;
}
.msg-menu button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 8px 11px;
  border-radius: 7px;
  font-size: 14px;
}
.msg-menu button:hover { background: var(--hover); }
.msg-menu button.danger { color: #ff8a80; }

/* ---------- Modal ---------- */

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 90;
  background: rgba(4, 9, 14, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  width: 100%;
  max-width: 440px;
  max-height: 88vh;
  overflow-y: auto;
  background: var(--panel);
  border-radius: 14px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
  border: 1px solid #22303d;
}
.modal.wide { max-width: 760px; }
.modal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid #101a24;
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
}
.modal-title { font-size: 17px; font-weight: 600; flex: 1; }
.modal-body { padding: 16px; }
.modal-body .field { margin-bottom: 12px; }

.tabs {
  display: flex;
  gap: 3px;
  background: var(--bg);
  padding: 3px;
  border-radius: 9px;
  margin-bottom: 14px;
  overflow-x: auto;
}
.tabs button {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--muted);
  padding: 7px 9px;
  border-radius: 7px;
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.tabs button.active { background: var(--panel-2); color: var(--text); }

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 6px;
  border-radius: 9px;
  cursor: pointer;
}
.user-row:hover { background: var(--hover); }
.user-row .chat-body { gap: 2px; }
.user-row .chat-name { font-size: 14px; }
.user-row .chat-preview { font-size: 12px; }
.user-row .mini-action {
  border: 1px solid #33506b;
  background: transparent;
  color: var(--accent-2);
  border-radius: 8px;
  padding: 5px 9px;
  font-size: 12px;
  flex: 0 0 auto;
}
.user-row .mini-action:hover { background: rgba(51, 144, 236, 0.12); }
.user-row .mini-action.danger { border-color: #5a2b2a; color: #ff8a80; }
.user-row .mini-action.danger:hover { background: rgba(179, 53, 47, 0.16); }

.chat-edit-avatar { display: flex; align-items: center; gap: 14px; margin-bottom: 16px; }
.avatar-actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.member-box { margin-top: 10px; }
.member-list { display: flex; flex-direction: column; gap: 2px; margin-top: 8px; }
.member-actions { display: flex; gap: 6px; margin-left: auto; flex-wrap: wrap; justify-content: flex-end; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel-2);
  border-radius: 14px;
  padding: 4px 6px 4px 10px;
  font-size: 12.5px;
}
.chip button { border: 0; background: transparent; color: var(--muted); font-size: 14px; padding: 0 3px; }

.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid #263442;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font-size: 14px;
  outline: none;
  margin-bottom: 10px;
}
.search-input:focus { border-color: var(--accent); }

.hint { font-size: 12px; color: var(--muted); line-height: 1.4; }
.empty-list { text-align: center; color: var(--muted); font-size: 13px; padding: 18px 4px; }

.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
}
.swatch.active { border-color: #fff; }

.story-bg-0 { background: linear-gradient(135deg, #ff8a65, #c2185b); }
.story-bg-1 { background: linear-gradient(135deg, #42a5f5, #1a237e); }
.story-bg-2 { background: linear-gradient(135deg, #66bb6a, #1b5e20); }
.story-bg-3 { background: linear-gradient(135deg, #ab47bc, #4a148c); }
.story-bg-4 { background: linear-gradient(135deg, #37474f, #000000); }
.story-bg-5 { background: linear-gradient(135deg, #ffb300, #e65100); }
.story-bg-6 { background: linear-gradient(135deg, #26c6da, #00695c); }

.story-swatches { display: flex; gap: 10px; margin: 12px 0; }
.story-swatches .swatch { width: 44px; height: 44px; }
.story-compose-media {
  display: flex;
  align-items: center;
  justify-content: center;
  max-height: 280px;
  margin: 10px 0;
  overflow: hidden;
  border-radius: 10px;
  background: #000;
}
.story-compose-media img,
.story-compose-media video { display: block; max-width: 100%; max-height: 280px; }

.admin-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}
.stat {
  background: var(--bg);
  border-radius: 10px;
  padding: 9px 11px;
}
.stat b { display: block; font-size: 20px; }
.stat span { font-size: 11px; color: var(--muted); }

.admin-row {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 9px 6px;
  border-bottom: 1px solid #1d2a36;
  flex-wrap: wrap;
}
.admin-row .chat-body { min-width: 140px; }
.admin-actions { display: flex; gap: 5px; flex-wrap: wrap; margin-left: auto; }
.admin-actions button {
  border: 1px solid #2b3a48;
  background: transparent;
  color: #b9c9d8;
  font-size: 11.5px;
  border-radius: 7px;
  padding: 4px 7px;
}
.admin-actions button.on { background: rgba(51, 144, 236, 0.18); border-color: #33506b; color: #9fcbf0; }
.admin-actions button.danger { color: #ff8a80; border-color: #5a2a2a; }
.admin-role { font-size: 11px; color: #b8862e; font-weight: 600; }

/* ---------- Story viewer ---------- */

.story-viewer {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.story-shell { width: 100%; max-width: 430px; height: 100%; max-height: 760px; display: flex; flex-direction: column; }
.story-progress { display: flex; gap: 4px; padding: 4px 2px 10px; }
.story-progress i { flex: 1; height: 3px; background: rgba(255, 255, 255, 0.25); border-radius: 2px; overflow: hidden; }
.story-progress i b { display: block; height: 100%; width: 0; background: #fff; }
.story-frame {
  flex: 1;
  border-radius: 14px;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding: 18px;
  min-height: 300px;
}
.story-top { display: flex; align-items: center; gap: 9px; position: relative; z-index: 3; }
.story-top .avatar { width: 36px; height: 36px; font-size: 13px; }
.story-top-name { font-weight: 600; font-size: 14px; text-shadow: 0 1px 4px rgba(0, 0, 0, 0.4); }
.story-top-time { font-size: 11px; color: rgba(255, 255, 255, 0.75); }
.story-close {
  margin-left: auto;
  border: 0;
  background: rgba(0, 0, 0, 0.25);
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 18px;
}
.story-text {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: 24px;
  line-height: 1.35;
  font-weight: 500;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-y: auto;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.25);
  padding: 20px 4px;
}
.story-media {
  position: absolute;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: #000;
}
.story-caption {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2;
  flex: none;
  max-height: 45%;
  padding: 26px 16px 36px;
  font-size: 16px;
  line-height: 1.4;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.82));
  overflow-y: auto;
}
.story-views {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 8px;
  z-index: 3;
  text-align: center;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.85);
}
.story-nav { position: absolute; top: 60px; bottom: 40px; z-index: 4; width: 32%; cursor: pointer; }
.story-nav.left { left: 0; }
.story-nav.right { right: 0; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  background: #263442;
  color: var(--text);
  padding: 10px 18px;
  border-radius: 10px;
  font-size: 13.5px;
  z-index: 120;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.45);
  max-width: 90vw;
  text-align: center;
}

/* ---------- Mobile ---------- */

@media (max-width: 760px) {
  .sidebar { width: 100%; max-width: none; border-right: 0; }
  .chat-pane {
    position: fixed;
    inset: 0;
    z-index: 30;
    transform: translateX(103%);
    transition: transform 0.22s ease;
    visibility: hidden;
  }
  .app.chat-open .chat-pane { transform: translateX(0); visibility: visible; }
  .app.chat-open .sidebar { visibility: hidden; }
  .back { display: inline-flex; }
  .empty-state { display: none; }
  .chat-head { padding-top: calc(8px + env(safe-area-inset-top)); }
  .messages { padding: 10px 8px 6px; }
  .msg-bubble { max-width: 84%; }
  .story-shell { max-height: none; height: 100%; }
  .story-frame { border-radius: 10px; }
  .modal { max-height: 92vh; }
  .auth-card { padding: 22px 18px; }
}

@media (max-width: 420px) {
  .brand { font-size: 16px; }
  .chat-name { font-size: 14px; }
  .msg-text { font-size: 14.5px; }
}

/* ---------- Вложения, стикеры и эмодзи ---------- */

.composer-icon {
  width: 38px;
  height: 44px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.composer-icon:hover { color: var(--accent-2); background: var(--hover); }
.composer-icon.active { color: var(--accent-2); }
.composer-icon:disabled { opacity: 0.45; }

.msg-bubble.media-bubble { padding: 4px; }
.msg-photo,
.msg-video {
  display: block;
  width: 100%;
  max-width: 320px;
  max-height: 380px;
  border-radius: 9px;
  background: #000;
  object-fit: contain;
}
.msg-photo { cursor: zoom-in; }

.msg-bubble.sticker-bubble,
.msg-row.own .msg-bubble.sticker-bubble {
  background: transparent;
  padding: 0;
  min-width: 0;
}
.msg-bubble.sticker-bubble .msg-meta {
  background: rgba(0, 0, 0, 0.28);
  border-radius: 8px;
  padding: 1px 5px;
  align-self: flex-end;
}
.msg-sticker {
  display: block;
  width: 160px;
  height: 160px;
  object-fit: contain;
}
.msg-sticker.emoji { width: 72px; height: 72px; }

.sticker-panel {
  flex: 0 0 auto;
  max-height: 42vh;
  overflow-y: auto;
  background: var(--panel);
  border-top: 1px solid #101a24;
  padding: 8px 10px 10px;
}
.sticker-tabs {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}
.sticker-tabs button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: 8px;
}
.sticker-tabs button.active { background: var(--bg); color: var(--text); }
.sticker-note { margin-left: auto; font-size: 11px; color: var(--muted); }

.sticker-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 6px;
  align-items: start;
}
.emoji-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  padding-bottom: 6px;
  margin-bottom: 4px;
  border-bottom: 1px solid #1b2836;
}
.emoji-btn {
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.emoji-btn:hover { background: var(--hover); }

.sticker-item { position: relative; aspect-ratio: 1; }
.sticker-use {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 10px;
  background: var(--bg);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.sticker-use img { max-width: 100%; max-height: 100%; object-fit: contain; }
.sticker-item.locked .sticker-use { opacity: 0.55; }
.sticker-delete {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: #e05252;
  color: #fff;
  font-size: 14px;
  line-height: 1;
  display: none;
}
.sticker-item:hover .sticker-delete { display: block; }
.sticker-lock {
  position: absolute;
  left: 4px;
  bottom: 4px;
  padding: 1px 4px;
  border-radius: 5px;
  background: rgba(0, 0, 0, 0.6);
  color: #ffd77a;
  font-size: 9px;
  font-weight: 700;
  pointer-events: none;
}
.sticker-add {
  aspect-ratio: 1;
  border: 1px dashed #33506b;
  border-radius: 10px;
  background: transparent;
  color: var(--accent-2);
  font-size: 26px;
  cursor: pointer;
}
.sticker-add:hover { background: rgba(51, 144, 236, 0.1); }
.sticker-empty { grid-column: 1 / -1; color: var(--muted); font-size: 12px; padding: 6px 2px; }

.media-viewer {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.media-viewer img,
.media-viewer video {
  max-width: 94vw;
  max-height: 92vh;
  border-radius: 8px;
}

@media (max-width: 760px) {
  .msg-photo,
  .msg-video { max-width: 100%; max-height: 320px; }
  .msg-sticker { width: 140px; height: 140px; }
  .msg-sticker.emoji { width: 64px; height: 64px; }
  .sticker-panel { max-height: 36vh; }
  .composer-icon { width: 34px; }
}

.call-overlay {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(5, 10, 16, 0.88);
}
.call-card {
  width: min(540px, 100%);
  background: #17212b;
  border: 1px solid #263747;
  border-radius: 18px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.55);
}
.call-peer { font-size: 20px; font-weight: 650; }
.call-state { color: #708499; font-size: 13px; margin: 6px 0 14px; }
.call-group {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  margin: 0 0 12px;
}
.call-group-member {
  padding: 6px 10px;
  border-radius: 999px;
  background: #243647;
  color: #dce7f2;
  font-size: 12px;
}
.call-group-audio { display: none; }
.call-audio { display: none; }
.call-media {
  position: relative;
  min-height: 180px;
  background: #0e1621;
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.call-remote {
  width: 100%;
  max-height: 46vh;
  object-fit: contain;
  background: #0e1621;
}
.call-local {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 112px;
  height: 82px;
  object-fit: cover;
  border-radius: 8px;
  background: #000;
  border: 1px solid #2b3f52;
}
.call-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}
.call-btn {
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  background: #243647;
  color: var(--text);
  font-size: 13px;
  cursor: pointer;
}
.call-btn:hover { background: #2d4357; }
.call-btn.accept { background: #2f9e62; }
.call-btn.reject { background: #d95656; }
.call-btn:disabled { opacity: 0.45; cursor: default; }
@media (max-width: 760px) {
  .call-overlay { padding: 10px; }
  .call-card { padding: 14px; }
  .call-local { width: 86px; height: 64px; }
}
