/* ===== Theme tokens ===== */
:root {
  --bg: #fafafa;
  --surface: #ffffff;
  --surface-2: #f5f5f5;
  --border: #ececec;
  --border-strong: #dcdcdc;
  --text: #0a0a0a;
  --text-soft: #555;
  --muted: #888;
  --hover: #f3f3f3;
  --accent: #0a0a0a;
  --accent-text: #ffffff;
  --accent-soft: #ededed;
  --bubble-me: #0a0a0a;
  --bubble-me-text: #ffffff;
  --bubble-peer: #f1f1f1;
  --bubble-peer-text: #0a0a0a;
  --danger: #e5484d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.04);
  --qr-fg: #0a0a0a;
  --qr-bg: #ffffff;
  --radius: 14px;
  --radius-sm: 10px;
  color-scheme: light;

  --icon-color: #0a0a0a;
  --icon-hover: #555;

  --bg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Ccircle cx='30' cy='30' r='2' fill='%23000000' fill-opacity='0.04'/%3E%3Ccircle cx='70' cy='80' r='1.5' fill='%23000000' fill-opacity='0.04'/%3E%3Ccircle cx='120' cy='150' r='2.5' fill='%23000000' fill-opacity='0.04'/%3E%3Ccircle cx='180' cy='40' r='1.8' fill='%23000000' fill-opacity='0.04'/%3E%3C/svg%3E");
}

:root[data-theme="dark"] {
  --bg: #0e0e0e;
  --surface: #161616;
  --surface-2: #1d1d1d;
  --border: #262626;
  --border-strong: #333333;
  --text: #f2f2f2;
  --text-soft: #b9b9b9;
  --muted: #7a7a7a;
  --hover: #1f1f1f;
  --accent: #f2f2f2;
  --accent-text: #0a0a0a;
  --accent-soft: #2a2a2a;
  --bubble-me: #f2f2f2;
  --bubble-me-text: #0a0a0a;
  --bubble-peer: #1f1f1f;
  --bubble-peer-text: #f2f2f2;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.3);
  --qr-fg: #f2f2f2;
  --qr-bg: #161616;

  --icon-color: #f2f2f2;
  --icon-hover: #b9b9b9;

  --bg-pattern: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 200 200'%3E%3Ccircle cx='30' cy='30' r='2' fill='%23ffffff' fill-opacity='0.06'/%3E%3Ccircle cx='70' cy='80' r='1.5' fill='%23ffffff' fill-opacity='0.05'/%3E%3Ccircle cx='120' cy='150' r='2.5' fill='%23ffffff' fill-opacity='0.05'/%3E%3Ccircle cx='180' cy='40' r='1.8' fill='%23ffffff' fill-opacity='0.06'/%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0;
  height: 100%;
  background-color: var(--bg);
  background-image: var(--bg-pattern);
  background-repeat: repeat;
  background-size: 32px 32px;
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, "SF Pro Text",
               "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  transition: background .2s ease, color .2s ease;
}
button { font: inherit; cursor: pointer; }
input, textarea { font: inherit; color: inherit; }
.hidden { display: none !important; }
.small { font-size: 13px; }
.muted { color: var(--muted); }

/* ===== Onboarding ===== */
.onboard {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 20px 16px;
  padding-top: max(20px, env(safe-area-inset-top));
  gap: 16px;
  animation: fade .35s ease;
}
.card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1.5px solid var(--border-strong);
  border-radius: 24px;
  padding: 28px 24px 24px;
  box-shadow: var(--shadow);
  animation: rise .4s ease;
  transition: border-color .2s ease;
}
.card:hover {
  border-color: var(--accent);
}
.brand {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 6px;
  position: relative;
}
.brand h1 {
  font-size: 18px; margin: 0;
  font-weight: 600; letter-spacing: -0.01em;
  flex: 1;
  display: flex; align-items: center; gap: 8px;
}
.beta-badge {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 6px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  line-height: 1;
  text-transform: uppercase;
  vertical-align: middle;
}
.header-actions { display: flex; gap: 4px; }
.logo {
  width: 32px; height: 32px;
  display: grid; place-items: center;
  background: var(--accent); color: var(--accent-text);
  border-radius: 9px;
  transition: background .2s ease, color .2s ease;
}
.qr-wrap {
  margin: 18px auto 14px;
  width: 200px; height: 200px;
  padding: 10px;
  background: var(--qr-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  display: grid; place-items: center;
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}
.qr-wrap:hover { transform: translateY(-1px); }
.qr-wrap img { width: 100%; height: 100%; display: block; }

.code-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 12px 8px 16px;
  transition: background .2s ease, border-color .2s ease;
}
.code {
  flex: 1;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-align: center;
  user-select: all;
  cursor: pointer;
  padding: 6px 0;
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  color: var(--icon-color);
  transition: all .2s cubic-bezier(0.4, 0, 0.2, 1);
}
.icon-btn svg,
.icon-btn i {
  width: 18px;
  height: 18px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn i {
  font-size: 18px;
}
.icon-btn:hover {
  background: var(--hover);
  color: var(--icon-hover);
}
.icon-btn:active { transform: scale(0.92); }
.icon-btn.active { background: var(--accent-soft); color: var(--accent); }

.divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted);
  margin: 18px 0 12px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.divider::before, .divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.join-form input {
  width: 100%;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  font-family: "SF Mono", ui-monospace, Menlo, monospace;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  outline: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  color: var(--text);
}
.join-form input:focus {
  border-color: var(--border-strong);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(10,10,10,0.08);
}
.pass-wrap,
.pw-wrap {
  position: relative;
}
.pass-wrap input {
  width: 100%;
  padding: 14px 48px 14px 16px !important;
  box-sizing: border-box;
  text-align: left;
  letter-spacing: normal;
  text-transform: none;
  font-family: inherit;
  font-size: 15px;
  font-weight: 400;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  color: var(--text);
}
.pass-wrap input:focus {
  border-color: var(--border-strong);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(10,10,10,0.08);
}
.pass-toggle {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  color: var(--muted);
  font-size: 20px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  transition: color .15s ease, background .15s ease;
  z-index: 2;
}
.pass-toggle:hover {
  color: var(--text);
  background: var(--hover);
}
.pw-wrap input {
  width: 100%;
  padding: 14px 52px 14px 18px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-align: center;
  outline: none;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  color: var(--text);
}
.pw-wrap input:focus {
  border-color: var(--border-strong);
  background: var(--surface);
  box-shadow: 0 0 0 3px rgba(10,10,10,0.08);
}
.pw-eye {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  background: transparent;
  border: none;
  border-radius: 50%;
  color: var(--muted);
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
  z-index: 2;
}
.pw-eye:hover {
  color: var(--text);
  background: var(--hover);
}
.pw-eye i { font-size: 19px; }
.form-group input,
.input-row input {
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.form-group input:focus,
.input-row input:focus {
  box-shadow: 0 0 0 3px rgba(10,10,10,0.08);
}
.join-form button {
  width: 100%;
  padding: 14px 20px;
}

.primary {
  background: var(--accent);
  color: var(--accent-text);
  border: none;
  border-radius: var(--radius);
  padding: 12px 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform .12s ease, opacity .15s ease, background .2s ease, color .2s ease, box-shadow .15s ease;
}
.primary:hover {
  opacity: .95;
  box-shadow: 0 2px 8px rgba(10,10,10,0.15);
}
.primary:active { transform: scale(.975); }

.error {
  color: var(--danger);
  font-size: 13px;
  min-height: 18px;
  margin: 10px 0 0;
  text-align: center;
  animation: fade .2s ease;
}

input:focus, textarea:focus {
  box-shadow: 0 0 0 3px rgba(10,10,10,0.08);
}

/* Auth tabs */
.auth-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin: 0 -24px;
  padding: 0 24px;
  gap: 0;
}
.auth-tab {
  flex: 1;
  padding: 10px 4px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s ease;
  text-align: center;
}
.auth-tab:hover { color: var(--text); }
.auth-tab.active {
  color: var(--accent);
  border-bottom-color: var(--accent);
}
.auth-panel { display: none; }
.auth-panel.active { display: block; }

/* Legal warning block */
.legal-block {
  width: 100%;
  max-width: 400px;
  background: linear-gradient(135deg, #fff7ed, #fff3e0);
  border: 1px solid #f97316;
  border-radius: 16px;
  padding: 16px 18px;
  animation: rise .6s ease both;
  animation-delay: .15s;
  opacity: 0;
  flex-shrink: 0;
}
:root[data-theme="dark"] .legal-block {
  background: linear-gradient(135deg, #291a08, #1f1508);
  border-color: #ea580c;
}
.legal-block-head {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 8px;
}
.legal-block-head i {
  color: #f97316;
  font-size: 18px;
}
.legal-block-title {
  font-size: 13px;
  font-weight: 700;
  color: #c2410c;
}
:root[data-theme="dark"] .legal-block-title {
  color: #fb923c;
}
.legal-block p {
  margin: 0 0 6px;
  font-size: 11.5px;
  line-height: 1.5;
  color: #9a3412;
}
:root[data-theme="dark"] .legal-block p {
  color: #d4a373;
}
.legal-block ul {
  margin: 4px 0 0;
  padding-left: 16px;
}
.legal-block li {
  font-size: 11px;
  line-height: 1.5;
  color: #9a3412;
  margin-bottom: 2px;
}
:root[data-theme="dark"] .legal-block li {
  color: #d4a373;
}
.about-link {
  display: block;
  margin-top: 10px;
  font-size: 12px;
  font-weight: 600;
  color: #c2410c;
  text-decoration: none;
  transition: color .15s ease;
}
.about-link:hover {
  color: #9a3412;
  text-decoration: underline;
}
:root[data-theme="dark"] .about-link {
  color: #fb923c;
}
:root[data-theme="dark"] .about-link:hover {
  color: #fdba74;
}

/* Online counter */
.online-counter {
  width: 100%;
  max-width: 400px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 13px;
  color: var(--text-soft);
  animation: rise .6s ease both;
  animation-delay: .25s;
  opacity: 0;
}
.online-counter .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  animation: pulse-green 2s infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ===== Messenger layout ===== */
.app {
  height: 100vh;
  height: 100dvh;
  display: grid;
  grid-template-columns: clamp(280px, 30vw, 360px) 1fr;
  background-color: var(--bg);
  background-image: var(--bg-pattern);
  background-repeat: repeat;
  background-size: 32px 32px;
  overflow: hidden;
}
.sidebar {
  border-right: 1px solid var(--border);
  background: var(--surface);
  display: flex; flex-direction: column;
  min-height: 0;
  overflow: hidden;
  transition: background .2s ease, border-color .2s ease;
}
.me { padding: 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.me-row { display: flex; align-items: center; gap: 8px; }
.me-code {
  flex: 1;
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.18em;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  text-align: center;
  cursor: pointer;
  transition: background .15s ease, border-color .2s ease;
  color: var(--text);
}
.me-code:hover { background: var(--hover); }
.qr-small {
  width: 100%;
  margin-top: 10px;
  border-radius: var(--radius-sm);
  background: var(--qr-bg);
  padding: 8px;
  border: 1px solid var(--border);
  display: none;
}
.qr-small.show { display: block; animation: rise .2s ease; }

/* Avatar */
.me-avatar-wrap {
  width: 40px; height: 40px;
  border-radius: 50%;
  cursor: pointer;
  overflow: hidden;
  flex-shrink: 0;
  transition: opacity .15s ease;
  position: relative;
}
.me-avatar-wrap:hover { opacity: .85; }
.me-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600; font-size: 16px;
  overflow: hidden;
}
.me-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.me-avatar-wrap::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity .15s ease;
  pointer-events: none;
}
.me-avatar-wrap:hover::after { opacity: 1; }

.avatar {
  border-radius: 50%;
  object-fit: cover;
  display: block;
  flex-shrink: 0;
}
.avatar-letter {
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.room-avatar {
  flex-shrink: 0;
  margin-right: 10px;
}
.room-avatar .avatar {
  width: 40px; height: 40px;
}
.room-avatar .avatar-letter {
  width: 40px; height: 40px;
  font-size: 16px;
}

.room {
  flex-direction: row;
  align-items: center;
}
.room-info {
  flex: 1;
  min-width: 0;
  display: flex; flex-direction: column; gap: 2px;
}

.room-right {
  display: flex; align-items: center; gap: 6px;
  flex-shrink: 0;
  margin-left: 8px;
}
.unread-badge {
  background: var(--accent);
  color: var(--accent-text);
  font-size: 11px;
  font-weight: 600;
  min-width: 20px; height: 20px;
  border-radius: 10px;
  display: grid; place-items: center;
  padding: 0 6px;
}

/* Read indicators / checkmarks */
.msg-footer {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  margin-top: 3px;
}
.check {
  display: inline-flex;
  align-items: center;
  line-height: 1;
}
.check.sent { opacity: .45; }
.check.delivered { opacity: .65; }
.check.read { color: #4fa3ff; opacity: 1; }

/* Typing indicator */
.typing-bar {
  flex-shrink: 0;
  min-height: 0;
  max-height: 0;
  overflow: hidden;
  transition: max-height .2s ease, min-height .2s ease;
}
.typing-bar.visible {
  min-height: 36px;
  max-height: 50px;
}
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 18px;
  font-size: 13px;
  color: var(--muted);
  animation: fadeIn .2s ease;
  background-color: var(--bg);
  background-image: var(--bg-pattern);
  background-repeat: repeat;
  background-size: 32px 32px;
}
.typing-name {
  font-weight: 500;
  color: var(--text-soft);
}
.typing-dots {
  display: inline-flex;
  gap: 3px;
  align-items: center;
  height: 18px;
}
.typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: typingBounce 1.4s ease-in-out infinite;
}
.typing-dots span:nth-child(2) { animation-delay: .15s; }
.typing-dots span:nth-child(3) { animation-delay: .3s; }
@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Bot thinking indicator — pulse animation */
.bot-typing .typing-dots span {
  animation: botPulse 1.2s ease-in-out infinite;
  width: 6px; height: 6px;
}
.bot-typing .typing-dots span:nth-child(2) { animation-delay: .2s; }
.bot-typing .typing-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes botPulse {
  0%, 100% { transform: scale(1); opacity: .3; }
  50% { transform: scale(1.3); opacity: 1; }
}

.rooms-head {
  padding: 14px 16px 8px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  flex-shrink: 0;
}
.rooms {
  list-style: none;
  margin: 0; padding: 0 8px;
  overflow-y: auto;
  overflow-x: visible;
  flex: 1;
  min-height: 0;
}
.room {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex; flex-direction: row; align-items: center;
  transition: background .15s ease, transform .2s ease;
  position: relative;
}
.room.swiped {
  background: var(--hover);
}
.room-swipe-delete {
  position: absolute;
  right: -60px;
  top: 0; bottom: 0;
  width: 60px;
  background: var(--danger);
  border: none;
  display: grid; place-items: center;
  cursor: pointer;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: white;
}
.room:hover { background: var(--hover); }
.room.active { background: var(--accent-soft); }
.room .peer-line {
  display: flex; justify-content: space-between; align-items: center;
}
.room .peer-label {
  font-weight: 600; font-size: 14px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.room .room-time {
  font-size: 11px; color: var(--muted);
  flex-shrink: 0;
}
.room .preview {
  font-size: 13px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.room .preview.kind-file::before { content: "\1F4C4 "; }
.room .preview.kind-image::before { content: "\1F4F7 "; }
.room .preview.kind-audio::before { content: "\1F3A4 "; }
.room .preview.kind-video::before { content: "\1F3AC "; }

.sidebar-foot { padding: 12px; border-top: 1px solid var(--border); display: flex; flex-direction: column; gap: 0; flex-shrink: 0; }
.sidebar-foot .ghost + .ghost,
.sidebar-foot .ghost + .sidebar-sep + .ghost { margin-top: 0; }
.sidebar-foot .sidebar-sep { height: 1px; background: var(--border); margin: 8px 0; }
.ghost {
  width: 100%;
  background: transparent;
  border: 1px dashed var(--border-strong);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 10px;
  font-weight: 500;
  transition: background .15s ease, border-color .15s ease;
}
.ghost:hover { background: var(--hover); border-color: var(--border-strong); }
.ghost-red {
  background: rgba(220,38,38,0.08);
  border: 1px solid rgba(220,38,38,0.3);
  color: #dc2626;
}
.ghost-red:hover {
  background: rgba(220,38,38,0.15);
  border-color: rgba(220,38,38,0.5);
}

/* Add chat circle button in rooms head */
.rooms-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.add-chat-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: #dc2626;
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 16px;
  transition: transform .15s, opacity .15s;
  flex-shrink: 0;
}
.add-chat-circle:hover { transform: scale(1.1); opacity: 0.9; }
.add-chat-circle:active { transform: scale(0.92); }
.add-chat-circle i { font-size: 16px; line-height: 1; }

/* ===== Chat panel ===== */
.chat {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg);
  background-image: var(--bg-pattern);
  background-repeat: repeat;
  background-size: 32px 32px;
}
.chat-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
  transition: background .2s ease, border-color .2s ease;
  flex-shrink: 0;
  z-index: 2;
}
.peer { display: flex; flex-direction: column; min-width: 0; }
.peer-name { font-weight: 600; }
.peer-code { font-size: 12px; color: var(--muted); font-family: "SF Mono", monospace; letter-spacing: 0.12em; }
.spacer { flex: 1; }
.only-mobile { display: none; }

.chat-head-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600; font-size: 14px;
}
.chat-head-avatar img {
  width: 100%; height: 100%; object-fit: cover; display: block;
}

#chatMenuBtn {
  position: relative;
}

.messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
  position: relative;
}
.msg {
  max-width: min(560px, 78%);
  padding: 9px 13px;
  border-radius: 16px;
  font-size: 14.5px;
  line-height: 1.35;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: pop .18s ease;
  position: relative;
}
.msg.me {
  align-self: flex-end;
  background: var(--bubble-me);
  color: var(--bubble-me-text);
  border-bottom-right-radius: 6px;
}
.msg.peer {
  align-self: flex-start;
  background: var(--bubble-peer);
  color: var(--bubble-peer-text);
  border-bottom-left-radius: 6px;
}
.qr-small.qr-empty { display: none; }

.msg .time {
  display: block;
  font-size: 10.5px;
  opacity: .55;
  margin-top: 3px;
}

.msg-text {
  white-space: pre-wrap;
  word-break: break-word;
}

/* Markdown in messages */
.msg-text h2, .msg-text h3, .msg-text h4 {
  margin: 6px 0 4px; font-weight: 600;
}
.msg-text h2 { font-size: 16px; }
.msg-text h3 { font-size: 15px; }
.msg-text h4 { font-size: 14px; }
.msg-text p { margin: 4px 0; }
.msg-text ul { margin: 4px 0; padding-left: 18px; }
.msg-text li { margin: 2px 0; }
.msg-text strong { font-weight: 700; }
.msg-text em { font-style: italic; }
.msg-text del { text-decoration: line-through; opacity: .7; }
.msg-text blockquote {
  border-left: 3px solid var(--border-strong);
  margin: 6px 0; padding: 4px 10px;
  color: var(--text-soft);
  font-style: italic;
}
.md-table {
  width: 100%;
  border-collapse: collapse;
  margin: 6px 0;
  font-size: 13px;
}
.md-table th, .md-table td {
  border: 1px solid var(--border);
  padding: 6px 10px;
  text-align: left;
}
.md-table th {
  background: var(--surface-2);
  font-weight: 600;
}
.md-table tr:nth-child(even) {
  background: var(--surface-2);
}
.md-code {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
  overflow-x: auto;
  margin: 6px 0;
  position: relative;
}
.md-code-lang {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 10px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  pointer-events: none;
  user-select: none;
}
.md-inline {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
  font-size: 12.5px;
}
.md-img {
  max-width: 100%;
  max-height: 300px;
  border-radius: 8px;
  margin: 4px 0;
}
.md-link {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Link preview in messages */
.link-preview {
  margin-top: 6px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  max-width: 360px;
  transition: background .15s ease;
  text-decoration: none !important;
  color: inherit !important;
  display: block;
  background: var(--surface-2);
}
.link-preview:hover {
  background: var(--hover);
}
.link-preview-img {
  width: 100%;
  height: 140px;
  object-fit: cover;
  display: block;
}
.link-preview-body {
  padding: 8px 10px;
}
.link-preview-domain {
  font-size: 10.5px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 2px;
}
.link-preview-title {
  font-size: 13px;
  font-weight: 600;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.link-preview-desc {
  font-size: 11.5px;
  color: var(--text-soft);
  line-height: 1.35;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.msg-media {
  margin: 0 -4px;
}

.msg img.media {
  display: block; max-width: 100%; max-height: 320px;
  border-radius: 10px; margin-top: 4px;
  cursor: zoom-in;
  transition: transform .15s ease;
}
.msg img.media:hover { transform: scale(1.01); }

.msg video.media {
  display: block; max-width: 100%; max-height: 360px;
  border-radius: 10px; margin-top: 4px;
  background: #000;
}

/* Audio message */
.msg-audio {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 240px;
}
.audio-cover {
  width: 48px; height: 48px;
  border-radius: 8px;
  object-fit: cover;
  flex-shrink: 0;
}
.audio-cover-placeholder {
  width: 48px; height: 48px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
:root[data-theme="dark"] .audio-cover-placeholder {
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.msg-audio .audio-info {
  display: flex; flex-direction: column; gap: 2px;
  min-width: 0; flex: 1;
}
.msg-audio .audio-title {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-audio .audio-artist {
  font-size: 11px; color: var(--muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.msg-audio audio {
  width: 100%; min-width: 160px; height: 32px;
  outline: none;
  border-radius: 8px;
}
:root[data-theme="dark"] .msg-audio audio {
  filter: invert(0.88) hue-rotate(180deg);
}

/* File link */
.file-link {
  display: flex; align-items: center; gap: 10px;
  text-decoration: none;
  color: inherit;
  padding: 6px 0;
}
.file-icon {
  width: 36px; height: 36px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  font-size: 18px;
  flex-shrink: 0;
}
:root[data-theme="dark"] .file-icon {
  background: var(--surface-2);
  border: 1px solid var(--border);
}
.file-name {
  font-size: 13.5px; font-weight: 500;
  max-width: 200px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

/* Empty state */
.empty-chat {
  margin: auto;
  text-align: center;
  color: var(--muted);
  padding: 40px 20px;
  animation: fade .3s ease;
}
.empty-chat h2 { font-weight: 600; margin: 0 0 6px; color: var(--text); }

/* ===== Composer ===== */
.composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  background: var(--surface);
  border-top: 1px solid var(--border);
  transition: background .2s ease, border-color .2s ease;
  flex-shrink: 0;
}
.composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--border);
  background: var(--surface-2);
  border-radius: var(--radius);
  padding: 10px 12px;
  max-height: 120px;
  min-height: 40px;
  outline: none;
  transition: border-color .15s ease, background .15s ease;
  line-height: 1.4;
  color: var(--text);
  font-size: 14px;
}
.composer textarea:focus { border-color: var(--border-strong); background: var(--surface); }
.composer .send {
  padding: 10px 12px;
  border-radius: 12px;
  align-self: flex-end;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.composer .send i {
  font-size: 18px;
  line-height: 1;
}
.composer .send svg {
  width: 18px;
  height: 18px;
}
.composer-actions .icon-btn {
  width: 40px; height: 40px;
}
.composer-actions .icon-btn i {
  font-size: 18px;
}

.composer-actions {
  display: flex;
  gap: 4px;
  align-items: flex-start;
  padding-top: 8px;
}

/* Optimistic / temp bubbles */
.msg[data-temp-id] {
  opacity: 0.7;
  animation: pulse 1s ease-in-out infinite;
}

/* Recording button */
#audioRecordBtn.active {
  background: var(--danger);
  color: white;
  position: relative;
}
#audioRecordBtn.active::after {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 50%;
  border: 2px solid var(--danger);
  animation: mic-pulse-ring 1.2s ease-out infinite;
}
#audioRecordBtn.active .mic-icon {
  animation: mic-pulse 1.2s ease-in-out infinite;
}
@keyframes mic-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
@keyframes mic-pulse-ring {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ===== Toast ===== */
.toast-container {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  pointer-events: none;
  max-width: 380px;
  width: 90%;
}
.toast-top { top: 16px; }
.toast-bottom { bottom: 16px; }
.toast-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 12px;
  font-size: 13.5px;
  font-weight: 500;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(-12px);
  transition: opacity .25s ease, transform .25s ease;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}
.toast-top .toast-item { transform: translateY(-12px); }
.toast-bottom .toast-item { transform: translateY(12px); }
.toast-item.show { opacity: 1; transform: translateY(0); }
.toast-info {
  background: var(--accent);
  color: var(--accent-text);
}
.toast-success {
  background: #22c55e;
  color: #fff;
}

/* ===== Consent overlay ===== */
.consent-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.consent-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 28px 24px;
  max-width: 440px;
  width: 100%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}
.consent-icon {
  font-size: 36px;
  color: var(--accent);
  text-align: center;
  margin-bottom: 12px;
}
.consent-card h2 {
  font-size: 18px;
  font-weight: 700;
  margin: 0 0 12px;
  text-align: center;
}
.consent-desc {
  font-size: 13px;
  color: var(--muted);
  margin: 0 0 10px;
  line-height: 1.5;
}
.consent-list {
  font-size: 13px;
  color: var(--text);
  margin: 0 0 12px;
  padding-left: 18px;
  line-height: 1.7;
}
.consent-list li {
  margin-bottom: 4px;
}
.consent-list strong {
  font-weight: 600;
}
.consent-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}
.consent-accept {
  width: 100%;
  padding: 12px;
}
.consent-reject {
  width: 100%;
  padding: 10px;
}
.toast-error {
  background: #ef4444;
  color: #fff;
}
.toast-warning {
  background: #f59e0b;
  color: #fff;
}
.toast-qr {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
}

/* ===== Fullscreen media viewer ===== */
.media-viewer {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.92);
  z-index: 6000;
  display: none;
  align-items: center;
  justify-content: center;
  animation: fade .2s ease;
}
.media-viewer.media-viewer--open {
  display: flex;
}
.media-viewer-close {
  position: absolute;
  top: 16px; right: 16px;
  width: 44px; height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: none;
  color: #fff;
  display: grid; place-items: center;
  cursor: pointer;
  z-index: 1;
  transition: background .15s ease;
}
.media-viewer-close:hover { background: rgba(255,255,255,0.2); }
.media-viewer-content {
  max-width: 95vw;
  max-height: 90vh;
  display: flex;
  align-items: center;
  justify-content: center;
}
.media-viewer-content img {
  max-width: 95vw;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 4px;
  cursor: zoom-out;
  animation: pop .2s ease;
}
.media-viewer-content video {
  max-width: 95vw;
  max-height: 90vh;
  border-radius: 8px;
  outline: none;
}

/* ===== Animations ===== */
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes pop { from { opacity: 0; transform: translateY(4px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes pulse-green {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes pulse-red {
  0%, 100% { background: var(--danger); }
  50% { background: #ff4d4d; }
}
@keyframes pulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 0.5; }
}

/* ===== Mobile ===== */
@media (max-width: 760px) {
  .onboard {
    padding: 16px;
    align-items: center;
    padding-top: max(24px, env(safe-area-inset-top));
    padding-bottom: max(24px, env(safe-area-inset-bottom));
  }
  .card {
    padding: 22px 18px;
    max-width: 100%;
    border-radius: 20px;
    margin: 0 auto;
  }

  .auth-tabs {
    margin: 0 -18px;
    padding: 0 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
  }
  .auth-tabs::-webkit-scrollbar { display: none; }
  .auth-tab {
    padding: 10px 8px;
    font-size: 12px;
    white-space: nowrap;
    min-width: 0;
    flex: 0 0 auto;
  }

  .join-form { gap: 12px; }
  .join-form input { padding: 13px 16px; font-size: 16px; }
  .pass-wrap input { padding: 13px 48px 13px 16px; font-size: 16px; }
  .pass-toggle,
  .pw-eye { right: 4px; width: 36px; height: 36px; }
  .pw-wrap input { padding-right: 48px; }
  .join-form button { padding: 12px; }

  .qr-wrap { width: 180px; height: 180px; margin: 14px auto; }
  .code { font-size: 17px; letter-spacing: 0.14em; }

  .app {
    grid-template-columns: 1fr;
    position: relative;
  }

  .sidebar {
    position: absolute;
    inset: 0 auto 0 0;
    width: 100%;
    max-width: 340px;
    z-index: 10;
    transform: translateX(0);
    transition: transform .25s ease;
  }
  .app.chat-open .sidebar { transform: translateX(-100%); }

  .sidebar-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,0.4);
    z-index: 9;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
  }
  .app.sidebar-open .sidebar-overlay {
    opacity: 1;
    pointer-events: auto;
  }

  .chat {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    height: 100dvh;
    transform: translateX(0);
    transition: transform .25s ease;
  }
  .app.sidebar-closed .chat { transform: translateX(100%); }
  .app.chat-open.sidebar-closed .chat { transform: translateX(0); }
  .only-mobile { display: flex; }

  .messages {
    padding: 12px;
    -webkit-overflow-scrolling: touch;
  }

  .composer {
    padding: 10px 12px;
    padding-bottom: max(12px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--border);
  }
  .composer textarea { font-size: 16px; padding: 10px; }
  .msg { max-width: 88%; }
  .msg-audio { min-width: 0; width: 100%; }

  body, .app, .chat, .sidebar { overflow-x: hidden; }
  .me-code { font-size: 13px; letter-spacing: 0.12em; }
  .icon-btn { width: 38px; height: 38px; }

  .msg-audio { min-width: 180px; }
  .msg-audio audio { width: 150px; }

  .md-table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  .link-preview {
    max-width: 100%;
  }
  .link-preview-img {
    height: 100px;
  }
  .file-name {
    max-width: 160px;
  }
}

/* ===== Tablet ===== */
@media (min-width: 761px) and (max-width: 1024px) {
  .app {
    grid-template-columns: 300px 1fr;
  }
}

/* ===== Large desktop ===== */
@media (min-width: 1200px) {
  .app {
    grid-template-columns: 360px 1fr;
  }
  .messages {
    padding: 24px 32px;
  }
}

/* ===== Room context menu ===== */
.room-context-menu {
  position: fixed;
  z-index: 4000;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  padding: 6px;
  min-width: 150px;
  animation: rise .15s ease;
}
.room-context-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 10px 12px;
  background: none;
  border: none;
  border-radius: 8px;
  color: var(--text);
  font-size: 13.5px;
  cursor: pointer;
  transition: background .1s ease;
  text-align: left;
}
.room-context-item:hover {
  background: var(--hover);
}
.room-context-item.danger {
  color: var(--danger);
}
.room-context-item.danger:hover {
  background: rgba(229,72,77,0.1);
}

/* ===== Slash command popup ===== */
.cmd-popup {
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  max-height: 280px;
  overflow-y: auto;
  z-index: 3000;
  animation: rise .15s ease;
  padding: 6px;
}
.cmd-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  transition: background .1s ease;
}
.cmd-item:hover, .cmd-item.selected {
  background: var(--hover);
}
.cmd-name {
  font-family: "SF Mono", ui-monospace, monospace;
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  white-space: nowrap;
}
.cmd-desc {
  font-size: 12px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ===== Modals ===== */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: grid; place-items: center;
  z-index: 2000;
  animation: fade .2s ease;
  padding: 20px;
  overflow-y: auto;
}
.modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  width: 100%; max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  animation: rise .3s ease;
}
.modal-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px 0;
  position: sticky; top: 0;
  background: var(--surface);
  border-radius: 20px 20px 0 0;
  z-index: 1;
}
.modal-head h2 { margin: 0; font-size: 17px; font-weight: 600; }
.modal-body {
  padding: 18px 24px 24px;
}
.form-group {
  margin-bottom: 16px;
}
.form-group label {
  display: block;
  font-size: 12px; font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 6px;
}
.form-group input, .form-group textarea {
  width: 100%;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease;
  color: var(--text);
  font-size: 14px;
}
.form-group input:focus, .form-group textarea:focus {
  border-color: var(--border-strong);
}
.form-group textarea {
  resize: vertical;
  min-height: 60px;
  line-height: 1.4;
}
.input-row {
  display: flex; gap: 8px;
  align-items: stretch;
}
.input-row input {
  flex: 1; min-width: 0;
  padding: 11px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color .15s ease, background .15s ease;
  color: var(--text);
  font-size: 14px;
}
.input-row input:focus {
  border-color: var(--border-strong);
  background: var(--surface);
}
.input-row input::placeholder {
  color: var(--muted);
}
@media (max-width: 480px) {
  .input-row {
    flex-direction: column;
    gap: 10px;
  }
  .input-row .small-btn {
    width: 100%;
    text-align: center;
  }
}
.small-btn {
  padding: 9px 16px;
  font-size: 13px;
  white-space: nowrap;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}
.profile-code {
  font-family: "SF Mono", monospace;
  font-size: 20px; font-weight: 600;
  letter-spacing: 0.18em;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  text-align: center;
  user-select: all;
  cursor: pointer;
}
.profile-section {
  margin-bottom: 20px;
}
.profile-section-title {
  font-size: 11px; font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.profile-avatar-big {
  width: 72px; height: 72px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 28px; font-weight: 700;
  margin: 0 auto 16px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
  transition: opacity .15s ease;
}
.profile-avatar-big:hover { opacity: .85; }
.profile-avatar-big img {
  width: 100%; height: 100%; object-fit: cover;
}
.profile-avatar-big::after {
  content: "";
  position: absolute; inset: 0;
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  opacity: 0;
  transition: opacity .15s ease;
}
.profile-avatar-big:hover::after { opacity: 1; }
.profile-avatar-hint {
  text-align: center;
  font-size: 12px;
  color: var(--muted);
  margin-top: -10px;
  margin-bottom: 16px;
}
.admin-divider {
  height: 1px;
  background: var(--border);
  margin: 20px 0;
}

/* Gender selector */
.gender-select {
  display: flex;
  gap: 8px;
}

.gender-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px 8px;
  background: var(--surface-2);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-soft);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s ease;
}

.gender-option .gender-icon {
  font-size: 22px;
  line-height: 1;
}

.gender-option:hover {
  background: var(--hover);
  border-color: var(--border-strong);
}

.gender-option.active {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent);
}

.gender-option.active .gender-icon {
  transform: scale(1.15);
}

@media (max-width: 480px) {
  .gender-select {
    flex-wrap: wrap;
  }
  .gender-option {
    flex: 1 1 calc(50% - 4px);
    min-width: 0;
  }
}
.admin-badge {
  display: inline-flex;
  align-items: center; gap: 6px;
  margin-top: 8px;
  padding: 5px 12px;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-radius: 8px;
  font-size: 12px; font-weight: 600;
}
.admin-section {
  margin-bottom: 20px;
}
.admin-section h3 {
  margin: 0 0 12px;
  font-size: 14px; font-weight: 600;
}
.form-divider {
  display: flex; align-items: center; gap: 10px;
  color: var(--muted);
  margin: 16px 0 12px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.form-divider::before, .form-divider::after {
  content: ""; flex: 1; height: 1px; background: var(--border);
}

/* ===== Bot list ===== */
.bot-list {
  display: flex; flex-direction: column; gap: 8px;
}
.bot-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}
.bot-item-avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600; font-size: 15px;
  overflow: hidden;
  flex-shrink: 0;
}
.bot-item-avatar img {
  width: 100%; height: 100%; object-fit: cover;
}
.bot-item-info { flex: 1; min-width: 0; }
.bot-item-name { font-weight: 600; font-size: 14px; }
.bot-item-meta { font-size: 12px; color: var(--muted); }
.bot-avatar-row {
  display: flex; align-items: center; gap: 10px;
}
.bot-avatar-preview {
  width: 40px; height: 40px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600; font-size: 16px;
  overflow: hidden;
  flex-shrink: 0;
}
.bot-avatar-preview img {
  width: 100%; height: 100%; object-fit: cover;
}
.danger-icon { color: var(--danger); }
.danger-icon:hover { background: rgba(229,72,77,0.1); color: var(--danger); }
.edit-icon { color: var(--accent); }
.edit-icon:hover { background: rgba(29,185,84,0.1); color: var(--accent); }

/* ===== Upload progress ===== */
.upload-progress {
  position: fixed;
  left: 50%; bottom: 80px;
  transform: translateX(-50%) translateY(0);
  width: 340px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  z-index: 3000;
  transition: opacity .3s ease, transform .3s ease;
}
.upload-progress-inner {
  display: flex; align-items: center; gap: 10px;
}
.upload-progress-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  display: grid; place-items: center;
  background: var(--accent-soft);
  color: var(--accent);
  flex-shrink: 0;
}
.upload-progress-info {
  flex: 1; min-width: 0;
}
.upload-progress-name {
  font-size: 13px; font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  display: block;
}
.upload-progress-bar-wrap {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 6px 0 4px;
  overflow: hidden;
}
.upload-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 2px;
  transition: width .15s ease;
}
.upload-progress-stats {
  display: flex; gap: 8px;
  font-size: 11px; color: var(--muted);
}
.upload-progress-speed {
  margin-left: auto;
  color: var(--accent);
  font-weight: 500;
}
.upload-progress-cancel {
  background: transparent;
  border: none;
  color: var(--muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 50%;
  flex-shrink: 0;
}
.upload-progress-cancel:hover { background: var(--hover); color: var(--text); }

@media (max-width: 760px) {
  .upload-progress {
    width: calc(100% - 32px);
    bottom: 20px;
  }
  .modal {
    max-width: 100%;
    border-radius: 16px;
  }
  .consent-card {
    padding: 20px 16px;
    max-height: 85vh;
  }
  .consent-card h2 {
    font-size: 16px;
  }
  .consent-list {
    font-size: 12px;
  }
  .legal-block {
    padding: 12px 14px;
  }
  .legal-block p {
    font-size: 11px;
  }
  .legal-block li {
    font-size: 10.5px;
  }
}

/* ===== Reduced motion ===== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .messages { scroll-behavior: auto; }
}

/* ===== Touch devices — remove sticky hover ===== */
@media (hover: none) and (pointer: coarse) {
  .room:hover, .music-track:hover, .card:hover { transform: none; }
  .music-track:hover .music-track-play-overlay { opacity: 0; }
  .music-track:hover .music-track-cover img { transform: none; }
}

/* ===== Support chat ===== */
.support-notice {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px 18px;
  margin: 12px auto;
  max-width: 420px;
  background: var(--surface2, rgba(99,102,241,0.08));
  border: 1px solid var(--border, rgba(99,102,241,0.2));
  border-radius: 12px;
  color: var(--text-secondary, #888);
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
}

.room.is-support .peer-label {
  font-weight: 600;
}
