/* ===== RESET & VARIABLES ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-deep: #060612;
  --bg-card: rgba(12, 12, 30, 0.75);
  --bg-input: rgba(255, 255, 255, 0.04);
  --border: rgba(255, 255, 255, 0.07);
  --border-focus: rgba(99, 102, 241, 0.5);
  --text-primary: #f0f0f8;
  --text-secondary: rgba(255, 255, 255, 0.45);
  --text-muted: rgba(255, 255, 255, 0.25);
  --accent: #6366f1;
  --accent-bright: #818cf8;
  --cyan: #22d3ee;
  --cyan-dim: rgba(34, 211, 238, 0.15);
  --green: #34d399;
  --yellow: #f59e0b;
  --red: #f87171;
  --sent-gradient: linear-gradient(135deg, #6366f1, #8b5cf6);
  --received-bg: rgba(255, 255, 255, 0.05);
  --radius: 14px;
  --radius-sm: 10px;
  --radius-xs: 8px;
}

html,
body {
  height: 100%;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-deep);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

/* ===== ANIMATED BACKGROUND ===== */
body::before {
  content: '';
  position: fixed;
  inset: -50%;
  width: 200%;
  height: 200%;
  background:
    radial-gradient(ellipse at 20% 40%, rgba(99, 102, 241, 0.12), transparent 55%),
    radial-gradient(ellipse at 75% 20%, rgba(34, 211, 238, 0.08), transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(139, 92, 246, 0.09), transparent 50%);
  animation: bgDrift 20s ease-in-out infinite alternate;
  z-index: 0;
  pointer-events: none;
}

@keyframes bgDrift {
  0% {
    transform: translate(0, 0) rotate(0deg);
  }

  100% {
    transform: translate(-5%, 3%) rotate(3deg);
  }
}

/* ===== SCREENS ===== */
.screen {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

/* ===== CONNECTION SCREEN ===== */
#connect-screen {
  align-items: center;
  justify-content: center;
  z-index: 10;
  background: var(--bg-deep);
  padding: 20px;
}

.connect-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  backdrop-filter: blur(40px) saturate(1.4);
  -webkit-backdrop-filter: blur(40px) saturate(1.4);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 44px 36px 36px;
  position: relative;
  overflow: hidden;
  animation: cardEnter 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.connect-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(99, 102, 241, 0.4), rgba(34, 211, 238, 0.3), transparent);
}

@keyframes cardEnter {
  from {
    opacity: 0;
    transform: translateY(24px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Logo */
.logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-icon {
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  background: linear-gradient(135deg, var(--accent), var(--cyan));
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  box-shadow: 0 8px 32px rgba(99, 102, 241, 0.25);
  animation: logoPulse 3s ease-in-out infinite;
}

@keyframes logoPulse {

  0%,
  100% {
    box-shadow: 0 8px 32px rgba(99, 102, 241, 0.25);
  }

  50% {
    box-shadow: 0 8px 48px rgba(99, 102, 241, 0.4);
  }
}

.logo h1 {
  font-size: 26px;
  font-weight: 800;
  letter-spacing: 3px;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--text-primary), var(--accent-bright));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo p {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}

/* ===== INPUT GROUPS ===== */
.input-group {
  position: relative;
  margin-bottom: 14px;
}

.input-group label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.input-group .icon {
  position: absolute;
  left: 14px;
  bottom: 12px;
  font-size: 15px;
  opacity: 0.4;
  pointer-events: none;
}

.secret-group .icon {
  bottom: auto;
  top: 38px;
}

.input-group input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  padding: 12px 14px 12px 42px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.25s, box-shadow 0.25s, background 0.25s;
}

.secret-group input {
  padding-right: 48px;
}

.input-group input::placeholder {
  color: var(--text-muted);
}

.input-group input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.12);
  background: rgba(255, 255, 255, 0.06);
}

/* Toggle password */
.toggle-password {
  position: absolute;
  right: 12px;
  top: 34px;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: color 0.2s;
  line-height: 1;
}

.toggle-password:hover {
  color: var(--text-secondary);
}

/* Key strength meter */
.key-strength {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 8px;
  opacity: 0;
  transition: opacity 0.3s;
}

.key-strength.visible {
  opacity: 1;
}

.strength-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 4px;
  overflow: hidden;
}

.strength-fill {
  height: 100%;
  width: 0;
  border-radius: 4px;
  transition: width 0.35s, background 0.35s;
}

.strength-fill.weak {
  width: 25%;
  background: var(--red);
}

.strength-fill.fair {
  width: 50%;
  background: var(--yellow);
}

.strength-fill.good {
  width: 75%;
  background: #3b82f6;
}

.strength-fill.strong {
  width: 100%;
  background: var(--green);
}

.strength-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}

/* Key requirements hint */
.key-requirements {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* Connect button */
.btn-connect {
  width: 100%;
  margin-top: 22px;
  padding: 14px;
  font-size: 14px;
  font-weight: 700;
  font-family: inherit;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  border: none;
  border-radius: var(--radius-sm);
  background: var(--sent-gradient);
  color: #fff;
  cursor: pointer;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s, box-shadow 0.2s;
}

.btn-connect:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(99, 102, 241, 0.35);
}

.btn-connect:active {
  transform: translateY(0);
}

.btn-connect:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.connect-footer {
  text-align: center;
  margin-top: 24px;
  font-size: 11.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ===== LOADING OVERLAY ===== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6, 6, 18, 0.92);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.35s;
}

.loading-overlay.active {
  opacity: 1;
  pointer-events: all;
}

.loading-spinner {
  width: 56px;
  height: 56px;
  border: 3px solid rgba(255, 255, 255, 0.08);
  border-top-color: var(--accent-bright);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 28px;
}

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

.loading-text {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  text-align: center;
}

.loading-step {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 10px;
}

/* ===== CHAT HEADER ===== */
.chat-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  padding: 16px 24px;
  background: rgba(10, 10, 28, 0.7);
  backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  gap: 14px;
}

.chat-header-logo {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-bright);
}

.header-divider {
  width: 1px;
  height: 24px;
  background: var(--border);
}

.room-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  border-radius: 20px;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.room-badge .hash {
  color: var(--cyan);
  font-weight: 700;
}

.status-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 12px;
  font-weight: 500;
  color: var(--green);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  animation: statusPulse 2s ease-in-out infinite;
}

.status-dot.degraded {
  background: var(--yellow);
  animation: none;
}

.status-dot.offline {
  background: var(--red);
  animation: none;
}

@keyframes statusPulse {

  0%,
  100% {
    opacity: 1;
    box-shadow: 0 0 0 0 rgba(52, 211, 153, 0.4);
  }

  50% {
    opacity: 0.7;
    box-shadow: 0 0 0 6px rgba(52, 211, 153, 0);
  }
}

.btn-disconnect {
  background: rgba(248, 113, 113, 0.1);
  border: 1px solid rgba(248, 113, 113, 0.2);
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  padding: 7px 16px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}

.btn-disconnect:hover {
  background: rgba(248, 113, 113, 0.18);
  border-color: rgba(248, 113, 113, 0.35);
}

/* Encryption banner */
.encryption-banner {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
  background: var(--cyan-dim);
  border-bottom: 1px solid rgba(34, 211, 238, 0.1);
  font-size: 11.5px;
  font-weight: 500;
  color: var(--cyan);
}

.banner-sep {
  opacity: 0.4;
}

.fingerprint {
  font-size: 13px;
  letter-spacing: 2px;
  cursor: help;
}

/* ===== MEMBERS BUTTON ===== */
.btn-members {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-secondary);
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-members:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
}

.btn-members.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--accent-bright);
}

.btn-members span {
  min-width: 14px;
  text-align: center;
  font-weight: 600;
}

/* ===== PRESENCE PANEL ===== */
.presence-panel {
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.02);
  padding: 10px 24px;
  animation: slideDown 0.2s ease-out;
}

@keyframes slideDown {
  from {
    opacity: 0;
    max-height: 0;
    padding: 0 24px;
  }

  to {
    opacity: 1;
    max-height: 200px;
    padding: 10px 24px;
  }
}

.presence-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.presence-list {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.presence-list li {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border);
  font-size: 12px;
  color: var(--text-secondary);
}

.presence-list li.self {
  background: rgba(99, 102, 241, 0.1);
  border-color: rgba(99, 102, 241, 0.2);
  color: var(--accent-bright);
}

.presence-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}

/* ===== MESSAGES ===== */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 24px 24px 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scroll-behavior: smooth;
}

.messages-container::-webkit-scrollbar {
  width: 5px;
}

.messages-container::-webkit-scrollbar-track {
  background: transparent;
}

.messages-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 10px;
}

.message {
  display: flex;
  flex-direction: column;
  max-width: 72%;
  animation: msgIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.message.sent {
  align-self: flex-end;
  align-items: flex-end;
}

.message.received {
  align-self: flex-start;
  align-items: flex-start;
}

.message.ephemeral {
  opacity: 0.85;
}

@keyframes msgIn {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.97);
  }

  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes msgFade {
  to {
    opacity: 0;
    transform: scale(0.95);
    height: 0;
    margin: 0;
    padding: 0;
    overflow: hidden;
  }
}

.message-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-bright);
  margin-bottom: 4px;
  padding: 0 4px;
}

.message.sent .message-sender {
  color: rgba(255, 255, 255, 0.4);
}

.message-bubble {
  padding: 11px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
}

.message.sent .message-bubble {
  background: var(--sent-gradient);
  color: #fff;
  border-bottom-right-radius: 6px;
}

.message.received .message-bubble {
  background: var(--received-bg);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
}

/* Links in messages */
.message-bubble a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  opacity: 0.9;
}

.message-bubble a:hover {
  opacity: 1;
}

.message-time {
  font-size: 10.5px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

.message.sent .message-time {
  color: rgba(255, 255, 255, 0.25);
}

.ephemeral-badge {
  font-size: 10px;
  opacity: 0.5;
  margin-left: 6px;
}

.message-bubble.error {
  background: rgba(248, 113, 113, 0.08) !important;
  border: 1px solid rgba(248, 113, 113, 0.2) !important;
  color: var(--red) !important;
  font-size: 12.5px;
  font-style: italic;
}

.system-message {
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
  padding: 12px 0;
  animation: msgIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.system-message span {
  background: rgba(255, 255, 255, 0.04);
  padding: 5px 14px;
  border-radius: 20px;
  border: 1px solid var(--border);
  white-space: nowrap;
  display: inline-block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== TYPING INDICATOR ===== */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 24px;
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.typing-dots {
  display: flex;
  gap: 3px;
  align-items: center;
}

.typing-dots i {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: bounce 1.4s ease-in-out infinite;
}

.typing-dots i:nth-child(2) {
  animation-delay: 0.2s;
}

.typing-dots i:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes bounce {

  0%,
  60%,
  100% {
    transform: translateY(0);
  }

  30% {
    transform: translateY(-5px);
  }
}

/* ===== MESSAGE INPUT ===== */
.chat-input-area {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  padding: 0;
  background: rgba(10, 10, 28, 0.6);
  backdrop-filter: blur(20px);
  border-top: 1px solid var(--border);
  width: 100%;
  box-sizing: border-box;
}

.input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 20px;
  width: 100%;
  box-sizing: border-box;
}

.btn-icon {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s, color 0.2s;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.06);
  border-color: rgba(255, 255, 255, 0.12);
}

.btn-icon.active {
  background: rgba(99, 102, 241, 0.15);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--accent-bright);
}

#message-input {
  flex: 1 1 0;
  min-width: 0;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: inherit;
  color: var(--text-primary);
  outline: none;
  resize: none;
  overflow-y: auto;
  line-height: 1.45;
  max-height: 120px;
  transition: border-color 0.25s, box-shadow 0.25s;
}

#message-input::placeholder {
  color: var(--text-muted);
}

#message-input:focus {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: none;
  background: var(--sent-gradient);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.18s, box-shadow 0.18s;
}

.btn-send:hover {
  transform: scale(1.06);
  box-shadow: 0 4px 20px rgba(99, 102, 241, 0.35);
}

.btn-send:active {
  transform: scale(0.96);
}

.btn-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ===== REPLY PREVIEW BAR ===== */
.reply-preview {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 20px;
  background: rgba(99, 102, 241, 0.08);
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
  animation: slideUp 0.2s ease;
}

.reply-preview.hidden {
  display: none;
}

.reply-preview-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
  border-left: 3px solid var(--accent-bright);
  padding-left: 10px;
}

.reply-preview-sender {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-bright);
}

.reply-preview-text {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-preview-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 16px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  transition: color 0.15s;
}

.reply-preview-close:hover {
  color: var(--text-primary);
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ===== REPLY QUOTE IN MESSAGE ===== */
.reply-quote {
  background: rgba(255, 255, 255, 0.04);
  border-left: 3px solid var(--accent-bright);
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s;
}

.reply-quote:hover {
  background: rgba(255, 255, 255, 0.07);
}

.reply-quote-sender {
  font-weight: 600;
  color: var(--accent-bright);
  font-size: 11px;
}

.reply-quote-text {
  color: var(--text-muted);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ===== REACTIONS ===== */
.reactions-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 7px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.04);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  user-select: none;
}

.reaction-pill:hover {
  background: rgba(255, 255, 255, 0.08);
}

.reaction-pill.own {
  border-color: rgba(99, 102, 241, 0.3);
  background: rgba(99, 102, 241, 0.1);
}

.reaction-pill .reaction-count {
  font-size: 11px;
  color: var(--text-muted);
}

/* ===== MESSAGE ACTION MENU ===== */
.msg-action-menu {
  position: fixed;
  z-index: 300;
  background: rgba(15, 15, 40, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  min-width: 140px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: menuIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.msg-action-menu.hidden {
  display: none;
}

.msg-action-menu button {
  background: none;
  border: none;
  color: var(--text-primary);
  padding: 9px 14px;
  font-size: 13px;
  font-family: inherit;
  text-align: left;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s;
}

.msg-action-menu button:hover {
  background: rgba(255, 255, 255, 0.07);
}

.msg-action-menu button.own-only.hidden-own {
  display: none;
}

@keyframes menuIn {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(5px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* ===== EMOJI PICKER ===== */
.emoji-picker {
  position: fixed;
  z-index: 310;
  background: rgba(15, 15, 40, 0.96);
  backdrop-filter: blur(20px);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  gap: 4px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  animation: menuIn 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.emoji-picker.hidden {
  display: none;
}

.emoji-picker button {
  background: none;
  border: none;
  font-size: 22px;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s, transform 0.12s;
}

.emoji-picker button:hover {
  background: rgba(255, 255, 255, 0.1);
  transform: scale(1.2);
}

/* ===== EDITED BADGE ===== */
.edited-badge {
  font-size: 10px;
  color: var(--text-muted);
  font-style: italic;
  margin-left: 4px;
}

/* ===== MESSAGE ACTION BUTTON ===== */
.message {
  position: relative;
}

.msg-action-btn {
  position: absolute;
  top: 0;
  opacity: 0;
  background: rgba(15, 15, 40, 0.85);
  backdrop-filter: blur(8px);
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-size: 16px;
  width: 28px;
  height: 22px;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  padding: 0;
  line-height: 1;
  letter-spacing: 1px;
}

.message.sent .msg-action-btn {
  left: -6px;
}

.message.received .msg-action-btn {
  right: -6px;
}

.message:hover .msg-action-btn {
  opacity: 1;
}

.msg-action-btn:hover {
  background: rgba(99, 102, 241, 0.2);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--accent-bright);
}

/* ===== DELETED MESSAGE ===== */
.message-bubble.deleted {
  font-style: italic;
  color: var(--text-muted);
  opacity: 0.6;
  background: rgba(255, 255, 255, 0.03) !important;
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  padding: 12px 20px;
  background: rgba(15, 15, 35, 0.9);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text-primary);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: toastIn 0.35s cubic-bezier(0.16, 1, 0.3, 1);
  max-width: 340px;
}

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

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

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(20px);
  }

  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(20px);
  }
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .connect-card {
    max-width: 380px;
    padding: 36px 28px 30px;
  }

  .message {
    max-width: 80%;
  }
}

@media (max-width: 600px) {
  #connect-screen {
    padding: 16px;
  }

  .connect-card {
    padding: 28px 20px 24px;
    border-radius: 16px;
  }

  .logo {
    margin-bottom: 24px;
  }

  .logo-icon {
    width: 48px;
    height: 48px;
    font-size: 22px;
    border-radius: 14px;
  }

  .logo h1 {
    font-size: 22px;
    letter-spacing: 2px;
  }

  .logo p {
    font-size: 12px;
  }

  .input-group {
    margin-bottom: 12px;
  }

  .input-group input {
    padding: 14px 14px 14px 42px;
    font-size: 16px;
    border-radius: var(--radius-sm);
  }

  .secret-group input {
    padding-right: 48px;
  }

  .btn-connect {
    margin-top: 18px;
    padding: 16px;
    font-size: 13px;
    border-radius: var(--radius-sm);
  }

  .connect-footer {
    margin-top: 18px;
    font-size: 11px;
  }

  .chat-header {
    padding: 10px 14px;
    gap: 8px;
    flex-wrap: wrap;
  }

  .chat-header-logo {
    font-size: 14px;
    letter-spacing: 1.5px;
  }

  .header-divider {
    height: 18px;
  }

  .room-badge {
    padding: 4px 10px;
    font-size: 12px;
  }

  .status-indicator {
    font-size: 11px;
    gap: 5px;
  }

  .status-dot {
    width: 6px;
    height: 6px;
  }

  .btn-disconnect {
    padding: 6px 12px;
    font-size: 11px;
  }

  .encryption-banner {
    font-size: 10px;
    padding: 6px 10px;
    gap: 4px;
  }

  .messages-container {
    padding: 14px 12px 8px;
    gap: 4px;
  }

  .message {
    max-width: 88%;
  }

  .message-bubble {
    padding: 10px 14px;
    font-size: 14px;
    border-radius: 16px;
  }

  .message.sent .message-bubble {
    border-bottom-right-radius: 5px;
  }

  .message.received .message-bubble {
    border-bottom-left-radius: 5px;
  }

  .typing-indicator {
    padding: 4px 14px;
    font-size: 11px;
  }

  .input-row {
    padding: 8px 10px;
    padding-bottom: calc(8px + env(safe-area-inset-bottom, 0px));
    gap: 6px;
  }

  .btn-send {
    width: 36px;
    height: 36px;
    flex-shrink: 0;
  }

  .btn-icon {
    width: 30px;
    height: 30px;
    font-size: 13px;
    flex-shrink: 0;
  }

  .system-message {
    padding: 8px 8px;
  }

  .system-message span {
    font-size: 10px;
    padding: 4px 8px;
    white-space: nowrap;
  }

  #message-input {
    padding: 8px 12px;
    font-size: 16px;
    border-radius: 18px;
  }

  .reply-preview {
    padding: 6px 10px;
  }

  .msg-action-menu {
    min-width: 120px;
  }

  .emoji-picker button {
    font-size: 20px;
    padding: 5px 6px;
  }

  .msg-action-btn {
    opacity: 0.75;
  }


  .toast-container {
    top: 12px;
    right: 12px;
    left: 12px;
  }

  .toast {
    max-width: 100%;
    font-size: 12px;
    padding: 10px 16px;
  }
}

@media (max-width: 380px) {
  .connect-card {
    padding: 24px 16px 20px;
  }

  .logo-icon {
    width: 42px;
    height: 42px;
    font-size: 20px;
  }

  .logo h1 {
    font-size: 20px;
  }

  .chat-header-logo {
    display: none;
  }

  .header-divider {
    display: none;
  }

  .room-badge {
    font-size: 11px;
  }
}
