:root { --bg:#0b0c10; --card:#121420; --text:#e8e8ea; --muted:#a7a7ad; --line:#24273a; }
*{box-sizing:border-box}
body{margin:0;font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial;background:linear-gradient(180deg,#0b0c10,#0f1220);color:var(--text)}
a{color:inherit;text-decoration:none}
.wrap{max-width:920px;margin:24px auto;padding:0 16px}

/* ===== Old header (можно оставить, если где-то используется) ===== */
.top{position:sticky;top:0;backdrop-filter: blur(10px);background:rgba(10,11,16,.6);border-bottom:1px solid var(--line);display:flex;align-items:center;justify-content:space-between;padding:12px 16px}
.logo{font-weight:700}
.nav a{margin-left:14px;color:var(--muted)}
.nav a:hover{color:var(--text)}
.linkbtn{background:transparent;border:0;color:var(--muted);cursor:pointer;margin-left:14px}
.linkbtn:hover{color:var(--text)}

/* ===== New header (topbar) ===== */
.topbar{
  position:sticky;
  top:0;
  backdrop-filter: blur(10px);
  background:rgba(10,11,16,.6);
  border-bottom:1px solid var(--line);
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:12px 16px;
  z-index: 1200;
}

.brand{font-weight:700}

.topnav{
  display:flex;
  align-items:center;
  gap:14px;
}

.navlink{color:var(--muted)}
.navlink:hover{color:var(--text)}

/* ===== UI ===== */
.card{background:rgba(18,20,32,.9);border:1px solid var(--line);border-radius:16px;padding:18px;box-shadow:0 8px 24px rgba(0,0,0,.25)}
.card.mini{margin-top:12px;padding:14px}
.row{display:flex;gap:12px;align-items:center}
.row.space{justify-content:space-between}

.btn{display:inline-block;background:#ffffff;color:#0b0c10;border:0;border-radius:12px;padding:10px 14px;font-weight:650;cursor:pointer}
.btn.ghost{background:transparent;color:var(--text);border:1px solid var(--line)}

.form{display:flex;flex-direction:column;gap:10px;margin-top:10px}
label{display:flex;flex-direction:column;gap:6px;color:var(--muted);font-size:14px}
input,textarea{background:#0f1220;border:1px solid var(--line);border-radius:12px;padding:10px 12px;color:var(--text);outline:none}
input:focus,textarea:focus{border-color:#3b82f6}
h1,h2,h3{margin:0 0 10px 0}
.muted{color:var(--muted)}
.err{color:#ff6b6b}
.ok{color:#63e6be}
.foot{max-width:920px;margin:18px auto 30px auto;padding:0 16px;color:var(--muted)}

/* chat */
.chatbox{border:1px solid var(--line);border-radius:14px;padding:12px;height:360px;overflow:auto;background:#0f1220;margin-bottom:12px}
.msg{padding:10px;border-radius:12px;background:#121420;border:1px solid var(--line);margin-bottom:10px}
.msg.me{margin-left:auto;max-width:80%;background:#111a2e}
.meta{color:var(--muted);font-size:12px;margin-bottom:4px}
.text{white-space:pre-wrap}

/* notice */
.notice{
  margin:12px 0 0 0;
  padding:10px 12px;
  border-radius:12px;
  border:1px solid var(--line);
  background:rgba(255,255,255,.06);
  color:var(--text);
}

/* ===== Badge (ОДИН вариант, без дубля) ===== */
.badge{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  min-width:20px;
  height:20px;
  padding:0 6px;
  border-radius:999px;
  font-size:12px;
  font-weight:700;
  margin-left:6px;
  background:#ffffff;
  color:#0b0c10;
}

/* ===== Dropdown Profile ===== */
.dropdown { position: relative; display: inline-block; }

.dropdown-btn{
  display:flex;
  align-items:center;
  gap:8px;
  padding:8px 10px;
  border:1px solid var(--line);
  border-radius:14px;
  background: rgba(255,255,255,.06);
  color: inherit;
  cursor:pointer;
  user-select:none;
}

.dropdown-btn:hover { background: rgba(255,255,255,.10); }

.dropdown-btn .caret { opacity:.8; font-size:12px; }

/* мини-аватар */
.avatar{
  width:28px;
  height:28px;
  border-radius:999px;
  overflow:hidden;
  border:1px solid var(--line);
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.25);
}
.avatar img{
  width:100%;
  height:100%;
  object-fit:cover;
  display:block;
}

.dropdown-menu{
  position:absolute;
  top: calc(100% + 10px);
  right: 0;
  width: 240px;
  background: rgba(25,25,30,.95);
  border:1px solid var(--line);
  border-radius:14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  padding:10px;
  display:none;
  z-index: 2000;
}

.dropdown.open .dropdown-menu{ display:block; }

.dropdown-item{
  width:100%;
  display:flex;
  align-items:center;
  gap:10px;
  padding:10px 12px;
  border-radius:12px;
  text-decoration:none;
  color: inherit;
  background: transparent;
  border: 0;
  cursor:pointer;
  font: inherit;
  text-align:left;
}

.dropdown-item:hover{ background: rgba(255,255,255,.08); }
.dropdown-item.danger{ color:#ffb3b3; }
.dropdown-item.danger:hover{ background: rgba(255,77,77,.15); }

.dropdown-sep{
  height:1px;
  background: rgba(255,255,255,.10);
  margin:8px 2px;
}
.mini-avatar{
  width:22px;
  height:22px;
  border-radius:999px;
  object-fit:cover;
  border:1px solid var(--line);
}
.flash-match {
  background: #ffebf0;
  border: 2px solid #ff6699;
  padding: 12px 16px;
  border-radius: 10px;
  margin: 10px auto;
  max-width: 600px;
  text-align: center;
  font-family: sans-serif;
  animation: fadeIn 0.6s ease-in;
}

.flash-match strong {
  color: #cc0066;
}

.flash-match .btn-chat {
  display: inline-block;
  margin-top: 8px;
  background: #ff6699;
  color: white;
  padding: 6px 14px;
  border-radius: 6px;
  text-decoration: none;
}

.flash-match .btn-chat:hover {
  background: #e25588;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
.badge{
  display:inline-block;
  min-width:22px;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  line-height:18px;
  text-align:center;
  background:#ff4d6d;
  color:#fff;
  font-weight:700;
}
.topNotify{
  position: sticky;
  top: 10px;
  z-index: 999;
  margin: 10px 0;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
}

.topNotify.blink{ animation: topBlink 1s steps(2,end) infinite; }
@keyframes topBlink{ 50% { opacity: .25; } }

/* если badge ещё нет — добавь */
.badge{
  display:inline-block;
  min-width:22px;
  padding:2px 8px;
  border-radius:999px;
  font-size:12px;
  line-height:18px;
  text-align:center;
  background:#ff4d6d;
  color:#fff;
  font-weight:700;
}
.topNotify{
  position: sticky;
  top: 10px;
  z-index: 999;
  margin: 10px auto;
  max-width: 1100px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
}

.topNotify.blink{ animation: topBlink 1s steps(2,end) infinite; }
@keyframes topBlink{ 50% { opacity: .25; } }
.toast-host{
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: min(360px, calc(100vw - 36px));
}

.toast{
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 14px;
  box-shadow: 0 10px 30px rgba(0,0,0,.35);
  cursor: pointer;
  animation: toastPop .18s ease-out;
}

@keyframes toastPop{
  from { transform: translateY(10px); opacity: .4; }
  to   { transform: translateY(0); opacity: 1; }
}

.toast-hide{
  opacity: 0;
  transform: translateY(8px);
  transition: .25s ease;
}

.toast-ava{
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid var(--line);
  flex: 0 0 auto;
}

.toast-body{
  min-width: 0;
  flex: 1 1 auto;
}

.toast-title{
  font-weight: 700;
  line-height: 1.2;
}

.toast-text{
  opacity: .85;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.toast-close{
  border: 0;
  background: transparent;
  color: inherit;
  opacity: .65;
  font-size: 20px;
  line-height: 1;
  padding: 6px 8px;
  cursor: pointer;
}
.toast-close:hover{ opacity: 1; }
/* ===== CHAT (telegram-like) ===== */
.chat{
  display:flex;
  flex-direction:column;
  gap:12px;
  border-radius:18px;
}

.chat__head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:14px 16px;
  border:1px solid var(--line);
  border-radius:18px;
  background:rgba(255,255,255,0.03);
}

.chat__who{display:flex; align-items:center; gap:12px;}
.chat__whoAva{
  width:44px;height:44px;border-radius:50%;
  object-fit:cover; border:1px solid var(--line);
}
.chat__title{font-weight:700; font-size:18px; line-height:1.2;}
.chat__sub{opacity:.7; font-size:13px; margin-top:2px;}

.chat__body{
  border:1px solid var(--line);
  border-radius:18px;
  padding:14px;
  background:rgba(0,0,0,0.18);
  height: calc(100vh - 260px);
  min-height: 360px;
  overflow:auto;
}

.msg{
  display:flex;
  align-items:flex-end;
  gap:10px;
  margin:10px 0;
}

.msg__ava{
  width:34px;height:34px;border-radius:50%;
  object-fit:cover;
  border:1px solid var(--line);
  flex:0 0 auto;
}

/* bubble */
.msg__bubble{
  position:relative;
  max-width:min(560px, 78%);
  padding:10px 12px;
  border-radius:14px;
  word-break:break-word;
  overflow-wrap:anywhere;
  line-height:1.25;
}

/* incoming */
.msg--in{justify-content:flex-start;}
.msg--in .msg__bubble{
  background:#ffffff;
  color:#111;
  border:1px solid rgba(0,0,0,0.08);
  border-bottom-left-radius:6px;
}
.msg--in .msg__bubble::after{
  content:"";
  position:absolute;
  left:-6px;
  bottom:10px;
  width:12px;height:12px;
  background:#fff;
  border-left:1px solid rgba(0,0,0,0.08);
  border-bottom:1px solid rgba(0,0,0,0.08);
  transform:rotate(45deg);
  border-bottom-left-radius:3px;
}

/* outgoing */
.msg--out{
  justify-content:flex-end;
}
.msg--out .msg__bubble{
  background:#dfffcf;
  color:#111;
  border:1px solid rgba(0,0,0,0.06);
  border-bottom-right-radius:6px;
}
.msg--out .msg__bubble::after{
  content:"";
  position:absolute;
  right:-6px;
  bottom:10px;
  width:12px;height:12px;
  background:#dfffcf;
  border-right:1px solid rgba(0,0,0,0.06);
  border-bottom:1px solid rgba(0,0,0,0.06);
  transform:rotate(45deg);
  border-bottom-right-radius:3px;
}

.msg__name{
  font-weight:700;
  font-size:13px;
  opacity:.85;
  margin-bottom:4px;
}

.msg__text{
  font-size:15px;
}

.msg__time{
  margin-top:6px;
  font-size:12px;
  opacity:.6;
}

/* input bar */
.chat__form{
  display:flex;
  align-items:center;
  gap:10px;
  padding:12px 12px;
  border:1px solid var(--line);
  border-radius:18px;
  background:rgba(255,255,255,0.03);
}

.chat__input{
  flex:1;
  border:0;
  outline:none;
  background:transparent;
  color:inherit;
  font-size:15px;
  padding:10px 12px;
  border-radius:14px;
}

.chat__send{
  width:44px;height:44px;
  border-radius:50%;
  border:1px solid var(--line);
  background:rgba(255,255,255,0.06);
  color:inherit;
  cursor:pointer;
  font-size:18px;
}
.chat__send:hover{ background:rgba(255,255,255,0.10); }
/* зелёная подсветка аватарки "в сети" */
.is-online {
  box-shadow: 0 0 6px 4px rgba(0, 255, 120, 0.65), 0 0 14px rgba(0, 255, 120, 0.35);
}
.match-ava { border-radius: 50%; }
/* Универсальная пульсация для всех бейджей */
.pulse {
  animation: badgePulse 1.4s ease-in-out infinite;
  transform-origin: center;
}

@keyframes badgePulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255, 60, 90, 0.0);
  }
  50% {
    transform: scale(1.25);
    box-shadow: 0 0 14px rgba(255, 60, 90, 0.55);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255, 60, 90, 0.0);
  }
}

/* если у пользователя включено "уменьшить анимации" */
@media (prefers-reduced-motion: reduce) {
  .pulse {
    animation: none;
  }
}
.pulse-once {
  animation: badgeOnce 1.2s ease-in-out infinite;
}

@keyframes badgeOnce {
  0%   { transform: scale(1);   box-shadow: 0 0 0 rgba(255, 60, 90, 0.0); }
  50%  { transform: scale(1.25); box-shadow: 0 0 16px rgba(255, 60, 90, 0.65); }
  100% { transform: scale(1);   box-shadow: 0 0 0 rgba(255, 60, 90, 0.0); }
}