@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
  --bg-main: #0a0c10;
  --bg-sidebar: #0e121a;
  --bg-card: #131924;
  --border-color: #232c3d;
  --accent-green: #10b981;
  --danger-red: #ef4444;
  --discord-red: #f87171;
  --amber-gold: #f59e0b;
  --text-main: #e2e8f0;
  --text-muted: #94a3b8;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  height: 100vh;
  height: 100dvh;
  width: 100vw;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: fixed;
  inset: 0;
}

/* Rock-Solid App Viewport Container */
#chat-screen {
  position: fixed;
  inset: 0;
  height: 100%;
  height: 100dvh;
  width: 100%;
  display: flex;
  overflow: hidden;
}

#chat-screen.hidden {
  display: none !important;
}

.chat-main-area {
  flex: 1 1 0%;
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
  min-width: 0;
  overflow: hidden;
  position: relative;
}

#message-feed {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.composer-footer {
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}

/* Scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--bg-main);
}
::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--accent-green);
}

/* Jumbo Emoji for emoji-only messages */
.jumbo-emoji {
  font-size: 2.2rem;
  line-height: 1.2;
  display: inline-block;
  vertical-align: middle;
}

/* Emoji Picker Popover */
#emoji-picker-popover {
  position: absolute;
  bottom: 50px;
  right: 16px;
  width: 320px;
  max-height: 280px;
  background-color: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.7);
  z-index: 40;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#emoji-picker-popover.hidden {
  display: none !important;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 8px;
  overflow-y: auto;
}

.emoji-btn {
  font-size: 1.25rem;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s ease;
  user-select: none;
}

.emoji-btn:hover {
  background-color: #1e293b;
  transform: scale(1.2);
}

/* ⚡ Emoji Autocomplete Dropdown - Positioned DIRECTLY ABOVE Textarea */
#emoji-autocomplete-popup {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 320px;
  max-height: 220px;
  background-color: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.85);
  z-index: 60;
  overflow-y: auto;
  padding: 6px;
}

#emoji-autocomplete-popup.hidden {
  display: none !important;
}

.autocomplete-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-family: 'Fira Code', monospace;
  font-size: 0.8rem;
  color: #cbd5e1;
  transition: all 0.1s ease;
}

.autocomplete-item:hover, .autocomplete-item.selected {
  background-color: #1e293b;
  color: #34d399;
}

/* Discord Hover Actions Bar */
.msg-card-container {
  position: relative;
}

.message-hover-actions {
  position: absolute;
  top: -10px;
  right: 12px;
  background-color: #0f172a;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 2px 6px;
  display: none;
  align-items: center;
  gap: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  z-index: 25;
}

.msg-card-container:hover .message-hover-actions {
  display: flex;
}

.btn-msg-react {
  font-size: 0.85rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.btn-msg-react:hover {
  background-color: #1e293b;
  color: #f1f5f9;
  transform: scale(1.05);
}

/* 😃 Message Reaction Picker Popover */
#reaction-picker-popover {
  position: fixed;
  width: 290px;
  max-height: 250px;
  background-color: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9);
  z-index: 70;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#reaction-picker-popover.hidden {
  display: none !important;
}

/* Reaction Pills */
.reaction-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background-color: rgba(30, 41, 59, 0.7);
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 2px 7px;
  font-size: 0.75rem;
  font-family: 'Fira Code', monospace;
  color: #94a3b8;
  cursor: pointer;
  user-select: none;
  transition: all 0.15s ease;
}

.reaction-pill:hover {
  border-color: #475569;
  background-color: #1e293b;
  color: #f1f5f9;
}

.reaction-pill.active {
  background-color: rgba(16, 185, 129, 0.15);
  border-color: rgba(16, 185, 129, 0.5);
  color: #34d399;
}

.reactions-bar:empty {
  display: none !important;
}

/* Tools Menu Popover */
#tools-menu-popover {
  position: absolute;
  bottom: calc(100% + 8px);
  left: 0;
  width: 220px;
  background-color: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9);
  z-index: 60;
  padding: 6px;
}

#tools-menu-popover.hidden {
  display: none !important;
}

/* Glow PC Popover */
#glow-pc-popover {
  position: absolute;
  bottom: calc(100% + 44px);
  left: 120px;
  width: 190px;
  background-color: #0f172a;
  border: 1px solid #334155;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.9);
  z-index: 70;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

#glow-pc-popover.hidden {
  display: none !important;
}

.tool-menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border-radius: 6px;
  color: #cbd5e1;
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  text-align: left;
  transition: all 0.1s ease;
  background: transparent;
  border: none;
  cursor: pointer;
}

.tool-menu-item:hover {
  background-color: #1e293b;
  color: #ffffff;
}

.msg-actions-toolbar {
  position: absolute;
  top: -12px;
  right: 4px;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  transform: translateY(2px);
  background: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(8px);
  border: 1px solid rgba(51, 65, 85, 0.8);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.6);
  border-radius: 6px;
  padding: 1px 3px;
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

/* On Desktop: Show on Hover */
@media (hover: hover) {
  .group\/msg:hover .msg-actions-toolbar,
  .msg-card-container:hover .msg-actions-toolbar,
  .msg-consecutive-line:hover .msg-actions-toolbar {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
  }
}

/* On Click / Active Selection (Mobile & Desktop) */
.group\/msg.active-msg .msg-actions-toolbar,
.msg-card-container.active-msg .msg-actions-toolbar,
.msg-consecutive-line.active-msg .msg-actions-toolbar {
  opacity: 1 !important;
  pointer-events: auto !important;
  transform: translateY(0) !important;
}

.group\/msg.active-msg,
.msg-card-container.active-msg,
.msg-consecutive-line.active-msg {
  background-color: rgba(30, 41, 59, 0.4);
  border-radius: 8px;
}

.btn-inline-react,
.btn-inline-info,
.btn-inline-delete {
  padding: 2px 4px;
  border-radius: 4px;
  font-size: 12px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #94a3b8;
  background: transparent;
  border: none;
  cursor: pointer;
  transition: all 0.1s ease;
}

.btn-inline-react:hover { color: #facc15; background-color: #1e293b; }
.btn-inline-info:hover { color: #38bdf8; background-color: #1e293b; }
.btn-inline-delete:hover { color: #f87171; background-color: #1e293b; }

.username-target {
  cursor: pointer;
  user-select: none;
  transition: color 0.1s ease;
}

.username-target:hover {
  text-decoration: underline;
  opacity: 0.85;
}

/* 🛑 RED Discord Style Pings & @Mentions */
.mention-card {
  background-color: rgba(239, 68, 68, 0.12) !important;
  border-color: rgba(239, 68, 68, 0.6) !important;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.15);
}

.mention-tag {
  background-color: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  font-weight: 600;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Admin Badge */
.admin-tag {
  background-color: rgba(245, 158, 11, 0.15);
  color: #f59e0b;
  font-size: 0.65rem;
  font-family: 'Fira Code', monospace;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 4px;
  border: 1px solid rgba(245, 158, 11, 0.4);
}

/* Clickable Links */
a.app-link {
  color: #34d399;
  text-decoration: underline;
  word-break: break-all;
  transition: color 0.15s ease;
}
a.app-link:hover {
  color: #6ee7b7;
  text-shadow: 0 0 8px rgba(52, 211, 153, 0.4);
}

/* Nuclear Glow Effects */
.glow-cia, .nuclear-glow {
  color: #f4ffb3;
  font-weight: 600;
  text-shadow: 0 0 6px #39ff14, 0 0 12px #39ff14, 0 0 20px #22c55e, 0 0 30px #15803d;
  background: none;
  border: none;
  padding: 0;
  display: inline;
}

.glow-trvth {
  color: #e0f2fe;
  font-weight: 600;
  text-shadow: 0 0 6px #38bdf8, 0 0 14px #0284c7, 0 0 22px #0369a1, 0 0 32px #0284c7;
  background: none;
  border: none;
  padding: 0;
  display: inline;
}

.glow-gold {
  color: #fef9c3;
  font-weight: 600;
  text-shadow: 0 0 6px #facc15, 0 0 14px #eab308, 0 0 22px #ca8a04, 0 0 32px #a16207;
  background: none;
  border: none;
  padding: 0;
  display: inline;
}

/* Rainbow Animated Text */
.rainbow-text {
  background-image: linear-gradient(90deg, #ff2a2a, #ff7f00, #ffff00, #00ff66, #00e5ff, #3b82f6, #a855f7, #ff2a2a);
  background-size: 200% auto;
  color: transparent;
  -webkit-background-clip: text;
  background-clip: text;
  font-weight: 700;
  animation: rainbow-shift 3s linear infinite;
  display: inline-block;
}

@keyframes rainbow-shift {
  0% { background-position: 0% 50%; }
  100% { background-position: 200% 50%; }
}

/* SCP Redaction */
.scp-redact {
  background-color: #000000;
  color: #ffffff;
  padding: 1px 5px;
  border-radius: 2px;
  font-family: 'Fira Code', monospace;
  font-weight: 600;
  border: 1px solid #222;
  box-shadow: 0 1px 3px rgba(0,0,0,0.8);
}

/* Spoiler */
.spoiler {
  background-color: #27272a;
  color: transparent;
  border-radius: 3px;
  padding: 0 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  user-select: none;
}
.spoiler:hover, .spoiler.revealed {
  background-color: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  user-select: text;
}

/* Greentext */
.greentext {
  color: #4ade80;
  font-family: 'Fira Code', monospace;
}

/* Sidebar Channels & DMs */
.sidebar {
  background-color: var(--bg-sidebar);
  border-color: var(--border-color);
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px 6px 12px;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 0.85rem;
  transition: all 0.15s ease;
  cursor: pointer;
  text-align: left;
  position: relative;
}

/* Discord-Style Left-Edge Pill Indicator */
.nav-btn::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleX(1);
  width: 4px;
  height: 0;
  border-radius: 0 3px 3px 0;
  background-color: #ef4444;
  transition: height 0.2s ease;
  z-index: 1;
}

.nav-btn:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: #f1f5f9;
}
.nav-btn.active {
  background-color: rgba(16, 185, 129, 0.15);
  color: #34d399;
  font-weight: 600;
}
.nav-btn.active::before {
  height: 70%;
  background-color: #10b981;
}

.nav-btn.has-unread {
  color: #ffffff;
  font-weight: 600;
}
.nav-btn.has-unread::before {
  height: 8px;
  background-color: #ffffff;
}

.nav-btn.has-ping {
  color: #fca5a5;
  font-weight: 700;
}
.nav-btn.has-ping::before {
  height: 70%;
  background-color: #ef4444;
}

/* Discord-Style Unread Count Badge (grey square) */
.nav-unread-badge {
  margin-left: auto;
  background-color: #4b5563;
  color: #e2e8f0;
  font-size: 0.65rem;
  font-weight: 800;
  font-family: 'Fira Code', monospace;
  line-height: 1;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  flex-shrink: 0;
}

/* Discord-Style Red Mention Ping Badge (red square) */
.nav-ping-badge {
  margin-left: auto;
  background-color: #ef4444;
  color: #ffffff;
  font-size: 0.65rem;
  font-weight: 800;
  font-family: 'Fira Code', monospace;
  line-height: 1;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  flex-shrink: 0;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
  animation: discord-ping-pulse 2s infinite ease-in-out;
}

@keyframes discord-ping-pulse {
  0%, 100% { box-shadow: 0 0 6px rgba(239, 68, 68, 0.5); }
  50%       { box-shadow: 0 0 14px rgba(239, 68, 68, 0.9); }
}

.mobile-ping-indicator {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background-color: #ef4444;
  border: 1.5px solid #0f172a;
}

.avatar-badge {
  width: 28px;
  height: 28px;
  border-radius: 6px; /* Discord-style square avatar icon */
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  flex-shrink: 0;
}

/* Markdown Headers */
.md-h1 {
  font-size: 1.25rem;
  font-weight: 700;
  color: #34d399;
  margin-top: 4px;
  margin-bottom: 2px;
}
.md-h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: #6ee7b7;
  margin-top: 4px;
  margin-bottom: 2px;
}
.md-h3 {
  font-size: 1rem;
  font-weight: 700;
  color: #a7f3d0;
  margin-top: 2px;
  margin-bottom: 2px;
}

/* Context Menu */
.username-target {
  cursor: context-menu;
  user-select: none;
}
.username-target:hover {
  text-decoration: underline;
}

/* Raw Ciphertext Inspector View */
.raw-packet-view {
  background-color: #080c14;
  border: 1px dashed var(--accent-green);
  border-radius: 6px;
  padding: 8px 12px;
  font-size: 0.75rem;
  color: #6ee7b7;
  word-break: break-all;
  margin-top: 8px;
}

/* Chat Embedded Video Player Constraints */
.video-container-wrapper {
  max-width: min(100%, 420px);
  width: 100%;
}

.chat-video-player {
  max-width: 100% !important;
  max-height: 280px !important;
  width: 100%;
  height: auto;
  object-fit: contain;
  border-radius: 12px;
  background-color: #000;
  display: block;
}

@media (max-width: 640px) {
  .video-container-wrapper {
    max-width: 100%;
  }
  .chat-video-player {
    max-height: 220px !important;
  }
}

