.sidebar-back-btn {
  display: none;
  align-items: center;
  gap: 7px;
  font-size: 1rem;
  font-weight: 700;

  color: var(--text);
  background: none;
  border: none;
  padding: 0 4px 0 0;
  margin-right: 8px;
  cursor: pointer;
}

.sidebar-back-btn svg {
  stroke: var(--text-muted);
  margin-right: 2px;
}

.sidebar-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding-bottom: 18px;
}

@media (max-width: 980px) {
  .sidebar-back-btn {
    display: inline-flex;
    background: rgba(15, 23, 42, 0.7);
    border-radius: 999px;
    padding: 7px 14px 7px 7px;
    margin-left: -6px;
    font-size: 0.98rem;
    font-weight: 800;
    color: var(--text);
  }
}
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #090b12;
  --bg-soft: rgba(15, 18, 27, 0.92);
  --bg-panel: rgba(16, 19, 29, 0.9);
  --bg-elevated: rgba(24, 29, 41, 0.95);
  --border: rgba(148, 163, 184, 0.16);
  --accent-soft-2: rgba(56, 189, 248, 0.12);
  --success: #34d399;
  --danger: #f87171;
  --danger-soft: rgba(248, 113, 113, 0.16);
  --shadow: 0 20px 60px rgba(15, 23, 42, 0.35);
  --radius: 24px;
  --radius-sm: 18px;
  --font:
    "Inter", "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial,
    sans-serif;
  --sidebar-w: min(340px, 34vw);
  --transition: 160ms ease;
}

html {
  color-scheme: dark;
  font-size: 16px;
}

body {
  min-height: 100svh;
  font-family: var(--font);
  background:
    radial-gradient(
      circle at top left,
      rgba(56, 189, 248, 0.22),
      transparent 24%
    ),
    radial-gradient(
      circle at top right,
      rgba(139, 92, 246, 0.22),
      transparent 28%
    ),
    linear-gradient(135deg, #04060d, #0a0f18 45%, #111827 100%);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background: linear-gradient(
    120deg,
    transparent 0%,
    rgba(255, 255, 255, 0.03) 40%,
    transparent 70%
  );
  pointer-events: none;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

button,
input,
select,
textarea {
  font: inherit;
}

button,
.icon-btn,
.browse-btn,
.btn-sm,
.btn-primary,
.btn-auth,
.google-auth-btn,
.send-btn {
  touch-action: manipulation;
}

button:focus-visible,
input:focus-visible,
textarea:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid rgba(139, 92, 246, 0.9);
  outline-offset: 2px;
}

.auth-screen {
  /* height: 100%; */
  height: 100dvh;
  display: flex;
  place-items: center;
  padding: clamp(18px, 3vw, 36px);
  position: relative;
  isolation: isolate;
}

.auth-glow {
  position: absolute;
  inset: auto;
  width: min(70vw, 640px);
  aspect-ratio: 1;
  border-radius: 999px;
  background: radial-gradient(
    circle,
    rgba(56, 189, 248, 0.14),
    transparent 68%
  );
  filter: blur(10px);
  z-index: -1;
}

.auth-card {
  width: min(92vw, 440px);
  background: linear-gradient(
    180deg,
    rgba(16, 19, 29, 0.96),
    rgba(12, 15, 24, 0.92)
  );
  border: 1px solid var(--border);
  border-radius: 28px;
  padding: clamp(24px, 4vw, 34px);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  animation: fadeUp 280ms ease both;
}

.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 24px;
}

.logo-mark {
  width: 38px;
  height: 38px;
  border-radius: 13px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #ffffff;
  font-weight: 800;
  font-size: 1rem;
  box-shadow: 0 12px 30px rgba(139, 92, 246, 0.35);
}

.logo-mark.sm {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  font-size: 0.85rem;
}

.logo-text {
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.auth-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 20px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border);
}

.auth-tab {
  border: 0;
  padding: 11px 12px;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--text-muted);
  background: transparent;
  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition);
}

.auth-tab.active {
  background: linear-gradient(
    180deg,
    rgba(56, 189, 248, 0.28),
    rgba(139, 92, 246, 0.24)
  );
  color: var(--text);
}

.auth-tab:hover {
  color: var(--text);
}

.form-field {
  margin-bottom: 14px;
}

.form-field label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-soft);
}

input[type="text"],
input[type="email"],
input[type="password"] {
  width: 100%;
  min-height: 46px;
  padding: 0 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.88);
  color: var(--text);
  font-size: 1rem;
  transition:
    border-color var(--transition),
    background var(--transition),
    transform var(--transition);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus {
  border-color: var(--border-strong);
  background: rgba(15, 23, 42, 0.98);
}

input::placeholder {
  color: #6b7280;
}

.form-error {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 14px;
  background: var(--danger-soft);
  border: 1px solid rgba(248, 113, 113, 0.3);
  color: #fecaca;
  font-size: 0.92rem;
  margin-bottom: 12px;
}

.form-error::before {
  content: "!";
  width: 18px;
  height: 18px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  background: rgba(248, 113, 113, 0.24);
  color: #fecaca;
  font-size: 0.78rem;
  font-weight: 800;
  flex-shrink: 0;
}

.btn-auth,
.google-auth-btn,
.btn-primary,
.btn-sm,
.send-btn,
.browse-btn,
.icon-btn {
  border: 0;
  cursor: pointer;
}

.btn-auth {
  width: 100%;
  min-height: 46px;
  padding: 0 16px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  box-shadow: 0 16px 32px rgba(139, 92, 246, 0.24);
  transition:
    transform var(--transition),
    filter var(--transition),
    box-shadow var(--transition);
}

.btn-auth:hover,
.btn-primary:hover,
.btn-sm:hover,
.send-btn:hover,
.google-auth-btn:hover,
.browse-btn:hover,
.icon-btn:hover {
  filter: brightness(1.04);
}

.btn-auth:active,
.btn-primary:active,
.btn-sm:active,
.send-btn:active,
.google-auth-btn:active,
.browse-btn:active,
.icon-btn:active {
  transform: translateY(1px) scale(0.99);
}

.auth-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 0 14px;
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(148, 163, 184, 0.35),
    transparent
  );
}

.google-auth-btn {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--border);
  color: var(--text);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 0.95rem;
  font-weight: 700;
}

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr);
  gap: 0;
  height: 100dvh; /* ADD THIS */
  max-height: 100dvh; /* ADD THIS */
  min-height: 0; /* ADD THIS */
  padding: 14px;
  isolation: isolate;
}

.sidebar,
.chat-area {
  min-height: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  background: linear-gradient(
    180deg,
    rgba(11, 14, 23, 0.96),
    rgba(15, 18, 27, 0.9)
  );
  border: 1px solid var(--border);
  border-right: 0;
  border-radius: var(--radius) 0 0 var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.sidebar-header,
.sidebar-user,
.sidebar-section,
.chat-header,
.input-area {
  padding-left: 16px;
  padding-right: 16px;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.conn-indicator {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-muted);
  font-size: 0.75rem;
  font-weight: 700;
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--text-muted);
}

.conn-indicator.connected .conn-dot {
  background: var(--success);
}

.conn-indicator.connected #conn-label {
  color: var(--success);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.18),
    rgba(139, 92, 246, 0.22)
  );
  border: 1px solid rgba(56, 189, 248, 0.4);
  color: #bae6fd;
  font-weight: 800;
  text-transform: uppercase;
  flex-shrink: 0;
}

.avatar.sm {
  width: 28px;
  height: 28px;
  font-size: 0.82rem;
}

.sidebar-user-info {
  flex: 1;
  min-width: 0;
}

.sidebar-user-name,
.sidebar-user-email {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-name {
  font-size: 0.95rem;
  font-weight: 700;
}

.sidebar-user-email {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  display: inline-grid;
  place-items: center;
  color: var(--text-soft);
  background: rgba(15, 23, 42, 0.6);
  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition);
}

.icon-btn:hover {
  background: rgba(30, 41, 59, 0.9);
  color: var(--text);
}

.sidebar-toggle-btn {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 3px;
  width: 40px;
  height: 40px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.88);
  color: var(--text);
  flex-shrink: 0;
}

.sidebar-toggle-btn span {
  width: 15px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  display: block;
}

.sidebar-section {
  padding-top: 14px;
  padding-bottom: 14px;
}

.sidebar-section + .sidebar-section {
  border-top: 1px solid var(--border);
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 0 2px;
  color: var(--text-soft);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.channel-list {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding-right: 2px;
}

.channel-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 16px;
  cursor: pointer;
  transition:
    background var(--transition),
    color var(--transition),
    transform var(--transition);
  color: var(--text-soft);
}

.channel-item:hover {
  background: rgba(15, 23, 42, 0.88);
  color: var(--text);
}

.channel-item.active {
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 0.22),
    rgba(56, 189, 248, 0.16)
  );
  color: var(--text);
}

.ch-icon {
  width: 18px;
  font-family: var(--font);
  font-weight: 800;
  text-align: center;
  flex-shrink: 0;
}

.ch-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ch-badge {
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  color: var(--text-muted);
  font-size: 0.7rem;
  font-weight: 800;
}

.ch-badge.private {
  color: #fecaca;
  background: rgba(248, 113, 113, 0.14);
}

.browse-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: calc(100% - 4px);
  min-height: 44px;
  margin-top: 10px;
  border-radius: 16px;
  background: rgba(15, 23, 42, 0.88);
  border: 1px dashed rgba(148, 163, 184, 0.28);
  color: var(--text-soft);
  font-size: 0.9rem;
  font-weight: 700;
}

.chat-area {
  position: relative;
  display: flex;
  flex-direction: column;
  background: linear-gradient(
    180deg,
    rgba(10, 13, 21, 0.96),
    rgba(13, 17, 27, 0.92)
  );
  border: 1px solid var(--border);
  border-radius: 0 var(--radius) var(--radius) 0;
  box-shadow: var(--shadow);
  height: 100%;
  overflow: hidden;
}

.empty-state {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  color: var(--text-muted);
}

.empty-icon {
  width: 72px;
  height: 72px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 0.18),
    rgba(56, 189, 248, 0.14)
  );
  color: #dbeafe;
}

.empty-state h2 {
  font-size: 1.2rem;
  color: var(--text);
}

.empty-state p {
  max-width: 340px;
}

.empty-state .empty-state-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.8);
  color: var(--text-soft);
  font-size: 0.85rem;
}

.mobile-empty-nav-btn {
  display: none;
  min-height: 44px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 0.22),
    rgba(56, 189, 248, 0.18)
  );
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 800;
}

.chat-view {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  height: 100%;
}

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 16px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(17, 22, 33, 0.96), transparent);
}

.chat-header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.2),
    rgba(139, 92, 246, 0.2)
  );
  color: #bae6fd;
  font-weight: 800;
}

.chat-header-name {
  font-size: 1rem;
  font-weight: 800;
}

.chat-header-sub {
  font-size: 0.84rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.messages-area {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 18px 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.messages-area::-webkit-scrollbar,
.channel-list::-webkit-scrollbar,
.modal-list::-webkit-scrollbar {
  width: 6px;
}

.messages-area::-webkit-scrollbar-thumb,
.channel-list::-webkit-scrollbar-thumb,
.modal-list::-webkit-scrollbar-thumb {
  background: rgba(148, 163, 184, 0.2);
  border-radius: 999px;
}

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

.msg-row.mine {
  flex-direction: row-reverse;
}

.msg-avatar {
  width: 30px;
  height: 30px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    rgba(56, 189, 248, 0.18),
    rgba(139, 92, 246, 0.18)
  );
  color: #dbeafe;
  font-weight: 800;
  font-size: 0.8rem;
  flex-shrink: 0;
}

.msg-row.mine .msg-avatar {
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 0.24),
    rgba(56, 189, 248, 0.2)
  );
  color: #f5f3ff;
}

.msg-content {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: min(78%, 560px);
}

.msg-row.mine .msg-content {
  align-items: flex-end;
}

.msg-sender {
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--text-muted);
  padding: 0 4px;
}

.msg-bubble {
  padding: 10px 14px;
  border-radius: 20px;
  font-size: 0.95rem;
  line-height: 1.6;
  word-break: break-word;
  box-shadow: 0 10px 30px rgba(15, 23, 42, 0.2);
}

.msg-row.theirs .msg-bubble {
  background: rgba(15, 23, 42, 0.88);
  border: 1px solid rgba(148, 163, 184, 0.14);
  border-bottom-left-radius: 8px;
}

.msg-row.mine .msg-bubble {
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 0.95),
    rgba(59, 130, 246, 0.85)
  );
  color: #fff;
  border-bottom-right-radius: 8px;
}

.msg-time {
  font-size: 0.72rem;
  color: var(--text-muted);
  padding: 0 4px;
}

.msg-system {
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
  padding: 10px 0;
}

.input-area {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 14px;
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent, rgba(9, 11, 18, 0.94));
}

.msg-input {
  flex: 1;
  min-height: 48px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.88);
  color: var(--text);
  font-size: 1rem;
}

.msg-input:focus {
  border-color: rgba(139, 92, 246, 0.75);
}

.send-btn {
  width: 46px;
  height: 46px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 16px 30px rgba(139, 92, 246, 0.28);
}

.mobile-sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.58);
  backdrop-filter: blur(6px);
  z-index: 24;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(2, 6, 23, 0.68);
  backdrop-filter: blur(10px);
  z-index: 100;
  animation: fadeIn 180ms ease;
}

.modal {
  width: min(92vw, 460px);
  background: linear-gradient(
    180deg,
    rgba(16, 19, 31, 0.98),
    rgba(12, 15, 24, 0.96)
  );
  border: 1px solid var(--border);
  border-radius: 24px;
  box-shadow: var(--shadow);
  overflow: hidden;
  animation: scaleIn 180ms ease;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-header h3 {
  font-size: 1.02rem;
  font-weight: 800;
}

.modal-body,
.modal-list {
  padding: 16px 18px 18px;
}

.modal-list {
  max-height: 64vh;
  overflow-y: auto;
}

.channel-empty,
.browse-empty,
.browse-loading {
  padding: 18px 14px;
  border-radius: 18px;
  border: 1px dashed rgba(148, 163, 184, 0.2);
  background: rgba(15, 23, 42, 0.7);
  color: var(--text-soft);
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
}

.channel-empty p,
.browse-empty p,
.browse-loading p {
  font-weight: 800;
  color: var(--text);
}

.channel-empty span,
.browse-empty span,
.browse-loading span {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.browse-empty.error {
  border-color: rgba(248, 113, 113, 0.24);
}

.browse-loading {
  align-items: center;
}

.browse-loading-spinner {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: 2px solid rgba(148, 163, 184, 0.25);
  border-top-color: var(--accent);
  animation: spin 1s linear infinite;
}

.channel-skeleton {
  gap: 10px;
  pointer-events: none;
}

.skeleton-chip,
.skeleton-avatar,
.skeleton-line {
  display: block;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(148, 163, 184, 0.18),
    rgba(148, 163, 184, 0.08),
    rgba(148, 163, 184, 0.18)
  );
  background-size: 200% 100%;
  animation: shimmer 1.2s linear infinite;
}

.skeleton-chip {
  width: 44px;
  height: 16px;
}

.skeleton-avatar {
  width: 20px;
  height: 20px;
}

.skeleton-line {
  height: 12px;
  flex: 1;
}

.skeleton-line.full {
  max-width: 100%;
}

.room-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border);
  border-radius: 18px;
  margin-bottom: 10px;
}

.room-card-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.room-card-icon {
  width: 36px;
  height: 36px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  background: linear-gradient(
    135deg,
    rgba(139, 92, 246, 0.2),
    rgba(56, 189, 248, 0.16)
  );
  color: #dbeafe;
  font-weight: 800;
}

.room-card-name {
  font-size: 0.96rem;
  font-weight: 800;
}

.room-card-meta {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.btn-sm {
  min-height: 40px;
  padding: 0 14px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-size: 0.92rem;
  font-weight: 800;
}

.btn-primary {
  width: 100%;
  min-height: 46px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  color: #fff;
  font-size: 1rem;
  font-weight: 800;
  margin-top: 8px;
}

.input-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.input-row input {
  flex: 1;
}

.search-result {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  margin-top: 12px;
  border-radius: 18px;
  background: rgba(15, 23, 42, 0.84);
  border: 1px solid var(--border);
}

.search-result-info {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.search-result-name {
  font-size: 0.95rem;
  font-weight: 800;
}

.search-result-email {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.radio-group {
  display: flex;
  gap: 18px;
  margin-top: 6px;
}

.radio-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-soft);
  font-size: 0.95rem;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: min(92vw, 360px);
  padding: 12px 16px;
  border-radius: 16px;
  border: 1px solid var(--border);
  background: rgba(15, 23, 42, 0.97);
  color: var(--text);
  box-shadow: var(--shadow);
  z-index: 200;
  animation: slideUp 220ms ease;
}

.toast.success {
  border-color: rgba(52, 211, 153, 0.4);
}

.toast.error {
  border-color: rgba(248, 113, 113, 0.4);
}

@media (max-width: 980px) {
  .app {
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 12px;
  }

  .sidebar,
  .chat-area {
    border-radius: 24px;
  }

  .sidebar {
    position: fixed;
    top: 12px;
    left: 12px;
    bottom: 12px;
    width: min(86vw, 340px);
    z-index: 30;
    max-height: calc(100dvh - 24px);
    min-height: 0;
    transform: translateX(calc(-100% - 16px));
    opacity: 0;
    visibility: hidden;
    transition:
      transform 240ms cubic-bezier(0.16, 1, 0.3, 1),
      opacity 220ms ease,
      visibility 0s linear 240ms;
  }

  .sidebar.sidebar-open {
    transform: translateX(0);
    opacity: 1;
    visibility: visible;
    transition:
      transform 240ms cubic-bezier(0.16, 1, 0.3, 1),
      opacity 220ms ease;
  }

  .sidebar-toggle-btn {
    display: inline-flex;
  }

  .mobile-empty-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .chat-area {
    min-height: 0;
    flex: 1;
  }
}

@media (max-width: 640px) {
  :root {
    --sidebar-w: 100%;
  }

  body {
    overflow: hidden;
  }

  .auth-card {
    width: min(96vw, 420px);
    padding: 22px 18px;
    border-radius: 22px;
  }

  .sidebar {
    max-height: 34vh;
  }

  .sidebar-header,
  .sidebar-user,
  .sidebar-section,
  .chat-header,
  .input-area {
    padding-left: 14px;
    padding-right: 14px;
  }

  .channel-item {
    min-height: 46px;
  }

  .messages-area {
    padding: 14px 14px 16px;
  }

  .msg-content {
    max-width: min(92%, 320px);
  }

  .msg-bubble {
    font-size: 0.92rem;
    padding: 9px 12px;
  }

  .msg-input {
    min-height: 46px;
    font-size: 1rem;
  }

  .send-btn {
    width: 46px;
    height: 46px;
  }

  .modal {
    width: min(96vw, 460px);
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    transform: none;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .sidebar {
    max-height: 30vh;
  }

  .sidebar-user {
    gap: 10px;
  }

  .sidebar-user-name {
    font-size: 0.9rem;
  }

  .sidebar-user-email {
    font-size: 0.74rem;
  }

  .chat-header {
    padding-top: 12px;
    padding-bottom: 12px;
  }

  .messages-area {
    padding: 12px;
  }

  .msg-bubble {
    font-size: 0.9rem;
    padding: 8px 11px;
  }

  .input-area {
    gap: 8px;
  }

  .modal-body,
  .modal-list {
    padding: 14px;
  }

  .input-row {
    flex-direction: column;
    align-items: stretch;
  }

  .input-row .btn-sm {
    width: 100%;
  }
}

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

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.98);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

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

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes shimmer {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}
