:root {
  --background: #08080a;
  --foreground: #f4f4f5;
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-bg-strong: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.10);
  --glass-border-strong: rgba(255, 255, 255, 0.18);
  --muted: rgba(255, 255, 255, 0.55);
  --text-dim: rgba(255, 255, 255, 0.4);
  --danger: rgba(255, 255, 255, 0.7);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Inter", sans-serif;
  background: var(--background);
  color: var(--foreground);
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  letter-spacing: -0.005em;
}

a { color: inherit; text-decoration: none; }



body > * { position: relative; z-index: 1; }

/* === TOP BAR === */
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  background: rgba(8, 8, 10, 0.85);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border-bottom: 1px solid var(--glass-border);
  z-index: 50;
}

.tb-icon {
  background: transparent;
  border: 0;
  color: var(--foreground);
  width: 40px;
  height: 40px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tb-icon:hover { background: var(--glass-bg); }
.tb-icon .material-symbols-outlined { font-size: 24px; }

.tb-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 4px;
}
.tb-logo, .modal-logo { width: 28px; height: 28px; display: block; flex-shrink: 0; }
.tb-logo img, .modal-logo img { width: 100%; height: 100%; display: block; filter: brightness(0) invert(1); }
.tb-name {
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--foreground);
}

/* CENTER PILL STATS */
.tb-stats-pill {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  padding: 6px 16px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin-left: 8px;
}
.stat-pill-item {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: #fff;
}
.stat-pill-item.male { color: #c084fc; }
.stat-pill-item.female { color: #38bdf8; }
.stat-ic { font-size: 16px; }

.tb-spacer { flex: 1; }

/* AVATAR (Border & glowing color based on gender) */
.tb-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #ffffff;
  border: 2px solid rgba(255, 255, 255, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  font-size: 15px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  user-select: none;
  overflow: hidden;
  transition: all 0.15s ease;
}
.tb-avatar.gender-W, .am-avatar.gender-W {
  background: rgba(244, 114, 182, 0.15) !important;
  color: #f472b6 !important;
  border: 2px solid #f472b6 !important;

}
.tb-avatar.gender-M, .am-avatar.gender-M {
  background: rgba(96, 165, 250, 0.15) !important;
  color: #60a5fa !important;
  border: 2px solid #60a5fa !important;

}
.tb-avatar.gender-N, .am-avatar.gender-N {
  background: rgba(255, 255, 255, 0.1) !important;
  color: #ffffff !important;
  border: 2px solid rgba(255, 255, 255, 0.4) !important;
}
.tb-avatar:hover { transform: scale(1.05); }
.tb-avatar:active { transform: scale(0.95); }

/* === MAIN SHELL === */
.shell {
  display: grid;
  grid-template-columns: 240px 1fr;
  padding-top: 56px;
  height: 100vh;
  transition: grid-template-columns 0.3s ease;
}

.shell.nav-collapsed { grid-template-columns: 0 1fr; }
.shell.nav-collapsed .sidebar { opacity: 0; pointer-events: none; overflow: hidden; }

@media (max-width: 768px) {
  .shell { grid-template-columns: 1fr; }
  .shell.nav-collapsed .sidebar { display: none; }
}

/* === SIDEBAR (NAV RAIL) === */
.sidebar {
  display: flex;
  flex-direction: column;
  background: #08080a;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  padding: 16px 12px;
  overflow-y: auto;
  height: calc(100vh - 56px);
  gap: 16px;
}

.nav-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.nav-pill {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 44px;
  padding: 0 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.nav-pill:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.25);
}
.nav-pill.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.4);
  font-weight: 600;
}
.nav-pill .material-symbols-outlined { font-size: 20px; }

/* CHAT SUBLIST (Nested under "Чаты") */
.chat-sublist {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-left: 12px;
  margin-top: 2px;
}

.chat-capsule {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  transition: all 0.15s ease;
}
.chat-capsule:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.22);
}
.chat-capsule.active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}
.capsule-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.capsule-avatar .material-symbols-outlined { font-size: 18px; }
.capsule-info { display: flex; flex-direction: column; min-width: 0; }
.capsule-name { font-size: 13px; font-weight: 600; color: #fff; }
.capsule-preview { font-size: 10.5px; color: var(--muted); margin-top: 1px; }

/* === MAIN CHAT STAGE === */
.stage {
  display: flex;
  flex-direction: column;
  background: #08080a;
  height: calc(100vh - 56px);
  overflow: hidden;
}

.stage-placeholder {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  font-size: 14px;
}

/* CHAT LIST VIEW (Stretched Capsule across Stage) */
.chat-list-view {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px 20px;
  width: 100%;
  box-sizing: border-box;
  overflow-y: auto;
}

/* NEKTO.ME ROULETTE CARD */
.nekto-container {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 24px 16px;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  box-sizing: border-box;
}

.nekto-card {
  width: min(560px, 100%);
  background: #0d0d12;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.6);
}

.nekto-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  padding-bottom: 12px;
}

.nekto-title {
  font-size: 16px;
  font-weight: 700;
  color: #ffffff;
}

.nekto-subtitle {
  font-size: 13px;
  color: var(--muted);
}

.nekto-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.nekto-label {
  font-size: 13px;
  font-weight: 600;
  color: #ffffff;
}

.nekto-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.nekto-btn-group {
  display: flex;
  gap: 6px;
}

.nekto-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.n-btn {
  flex: 1;
  padding: 9px 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
}

.n-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
}

.n-btn.active {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  color: #ffffff;
  font-weight: 600;
}

/* Green Start Chat Button */
.nekto-start-btn {
  width: 220px;
  height: 48px;
  margin: 8px auto 0 auto;
  background: transparent;
  border: 2px solid #10b981;
  border-radius: 999px;
  color: #34d399;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;

}

.nekto-start-btn:hover {
  background: #10b981;
  color: #000000;

  transform: scale(1.02);
}

/* Online stats pill inside nekto card */
.nekto-stats-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 20px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  margin: 4px auto 0 auto;
}

.nekto-footer {
  text-align: center;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  padding-top: 12px;
}
.nekto-footer b { color: #ffffff; }

.stage-chat-grid {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
}

.stage-chat-capsule {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  height: 64px;
  padding: 0 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
}

.stage-chat-capsule:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.s-capsule-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #ffffff;
}

.s-capsule-avatar .material-symbols-outlined { font-size: 22px; }

.s-capsule-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.s-capsule-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

.s-capsule-title {
  font-size: 17px;
  font-weight: 700;
  color: #ffffff;
}

.s-capsule-tag {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.15);
  color: #34d399;
  border: 1px solid rgba(16, 185, 129, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.s-capsule-desc {
  font-size: 13px;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.s-capsule-action {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.stage-chat-capsule:hover .s-capsule-action {
  background: #ffffff;
  color: #000000;
  border-color: #ffffff;
}

.chat-active {
  display: flex;
  flex-direction: column;
  flex: 1;
  height: 100%;
  padding: 16px 20px;
  min-height: 0;
}

/* WIDE ROOM CAPSULE HEADER */
.chat-room-capsule {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  height: 56px;
  padding: 0 24px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(255, 255, 255, 0.12);
  margin-bottom: 16px;
  flex-shrink: 0;
}
.room-icon { font-size: 26px; color: #fff; }
.room-title { font-size: 18px; font-weight: 700; color: #fff; letter-spacing: -0.01em; }

.messages {
  flex: 1;
  overflow-y: auto;
  padding: 10px 4px 20px 4px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* === MESSAGES BUBBLES === */
.msg {
  display: flex;
  gap: 10px;
  max-width: 80%;
}
.msg.me {
  align-self: flex-end;
  flex-direction: row-reverse;
}
.msg.peer { align-self: flex-start; }

.msg-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid var(--glass-border);
}
.msg-avatar.gender-W { background: rgba(244, 114, 182, 0.2); color: #f472b6; border-color: rgba(244, 114, 182, 0.4); }
.msg-avatar.gender-M { background: rgba(96, 165, 250, 0.2); color: #60a5fa; border-color: rgba(96, 165, 250, 0.4); }

.msg-body { display: flex; flex-direction: column; gap: 4px; }
.msg-meta { display: flex; align-items: center; gap: 8px; font-size: 11px; }
.msg-author { font-weight: 600; }
.msg-time { color: var(--text-dim); }

.msg-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.45;
  word-break: break-word;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--glass-border);
}
.msg.me .msg-bubble {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.25);
}

.msg.time {
  align-self: center;
  font-size: 12px;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
}

/* === COMPOSER === */
.composer {
  display: flex;
  gap: 10px;
  padding-top: 14px;
  flex-shrink: 0;
}
.composer input {
  flex: 1;
  height: 48px;
  padding: 0 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  outline: none;
  transition: all 0.15s ease;
}
.composer input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.3);
}
.composer button {
  height: 48px;
  padding: 0 24px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 999px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}
.composer button:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
}

/* === AVATAR POPOVER (WIDENED TO 420px FOR SINGLE-LINE GENDER BUTTONS) === */
.avatar-menu {
  position: fixed;
  top: 64px;
  right: 16px;
  z-index: 200;
  width: min(420px, calc(100vw - 32px));
  background: #121218;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px;
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 1px rgba(255, 255, 255, 0.2);
}
.avatar-menu.hidden { display: none !important; }

.am-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--glass-border);
}
.am-avatar {
  flex-shrink: 0;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
}
.am-info {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.am-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--foreground);
}
.am-status {
  font-size: 12px;
  color: var(--muted);
}

.am-pubkey-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  padding: 10px 12px;
}
.pubkey-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}
.pubkey-val-box {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.pubkey-text {
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 12px;
  color: var(--foreground);
  word-break: break-all;
}
.pubkey-copy-btn {
  background: transparent;
  border: 0;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
}
.pubkey-copy-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--foreground); }
.pubkey-copy-btn .material-symbols-outlined { font-size: 16px; }

.am-section-title {
  font-size: 11px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.gender-selector {
  display: flex;
  gap: 6px;
}
.g-btn {
  flex: 1;
  padding: 8px 4px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 10px;
  color: var(--muted);
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
  text-align: center;
  white-space: nowrap;
}
.g-btn:hover { background: rgba(255, 255, 255, 0.1); color: var(--foreground); }
.g-btn.active {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--foreground);
}

.am-divider { height: 1px; background: var(--glass-border); }

.am-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 11px 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 12px;
  color: var(--foreground);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
}
.am-item:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
}
.am-item.danger {
  color: #f87171;
  background: rgba(239, 68, 68, 0.08);
  border-color: rgba(239, 68, 68, 0.2);
}
.am-item.danger:hover {
  background: rgba(239, 68, 68, 0.16);
  border-color: rgba(239, 68, 68, 0.35);
}
.am-item .material-symbols-outlined { font-size: 18px; }

/* === MODAL === */
.modal {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(20px);
}
.modal.hidden { display: none !important; }
.modal-card {
  width: min(440px, 100%);
  background: #121218;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 24px;
  padding: 24px;
}
.modal-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}
.brand-title { font-size: 18px; font-weight: 700; color: #fff; }
.brand-subtitle { font-size: 12px; color: var(--muted); display: block; }
.onb-section-title { font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; margin-bottom: 8px; }
.onb-divider { height: 1px; background: var(--glass-border); margin: 16px 0; }
.muted-title { font-size: 13px; font-weight: 600; color: var(--foreground); margin-bottom: 6px; }
.muted { font-size: 12px; color: var(--muted); line-height: 1.4; }
.ts-wrapper { margin: 12px 0; min-height: 65px; }

.modal-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.btn-primary {
  width: 100%;
  height: 46px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 12px;
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}
.btn-secondary {
  width: 100%;
  height: 46px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  color: var(--foreground);
  font-size: 14px;
  cursor: pointer;
}
.seed-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin: 14px 0;
}
.seed-grid div {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--glass-border);
  border-radius: 8px;
  padding: 8px;
  font-size: 12px;
  font-family: monospace;
}
.pubid-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 12px;
}
.pubid-box b { font-family: monospace; font-size: 11px; word-break: break-all; flex: 1; }
.pubid-box .copy { background: transparent; border: 0; color: var(--muted); cursor: pointer; }
.restore-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 12px;
  padding: 12px;
  color: #fff;
  font-family: monospace;
  font-size: 13px;
  outline: none;
  resize: vertical;
}
.hidden { display: none !important; }