@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

:root {
  /* Dark Glass Theme (Default) */
  --topbar-bg: rgba(11, 15, 25, 0.8);
  --bg-base: #0B0F19;
  --bg-gradient: radial-gradient(circle at 15% 15%, rgba(139, 92, 246, 0.22) 0%, transparent 45%),
                 radial-gradient(circle at 85% 85%, rgba(236, 72, 153, 0.15) 0%, transparent 45%),
                 radial-gradient(circle at 50% 50%, rgba(14, 165, 233, 0.08) 0%, transparent 60%),
                 #0B0F19;
  
  --surface: rgba(17, 24, 39, 0.75);
  --surface-soft: rgba(30, 41, 59, 0.5);
  --surface-hover: rgba(30, 41, 59, 0.8);
  --surface-muted: rgba(15, 23, 42, 0.9);
  
  --text: #F8FAFC;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  
  --border: rgba(255, 255, 255, 0.09);
  --border-hover: rgba(139, 92, 246, 0.4);
  --border-focus: #8B5CF6;
  
  --btn-a: #8B5CF6;
  --btn-b: #EC4899;
  --btn-grad: linear-gradient(135deg, #8B5CF6 0%, #D946EF 100%);
  --btn-grad-hover: linear-gradient(135deg, #7C3AED 0%, #C026D3 100%);
  
  --xp-grad: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
  --pts-grad: linear-gradient(135deg, #06B6D4 0%, #2563EB 100%);
  
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, 0.15);
  --success: #10B981;
  --success-soft: rgba(16, 185, 129, 0.15);
  
  --radius: 16px;
  --radius-sm: 10px;
  --radius-pill: 9999px;
  
  --font-display: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
  --shadow-glow: 0 0 25px rgba(139, 92, 246, 0.25);
  --glass-blur: blur(16px);
  --scrollbar-track: rgba(15, 23, 42, 0.4);
  --scrollbar-thumb: rgba(255, 255, 255, 0.15);
  --scrollbar-thumb-hover: rgba(139, 92, 246, 0.5);
}

[hidden] {
  display: none !important;
}

[hidden] {
  display: none !important;
}

/* ---------- Presence dots (used anywhere someone else's online status is shown) ---------- */
.presence-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--success);
  flex-shrink: 0;
}

.presence-dot.offline {
  background: #64748B;
}

.presence-dot-inline {
  margin-right: 2px;
}

.presence-dot-corner {
  position: absolute;
  bottom: -1px;
  right: -1px;
  width: 10px;
  height: 10px;
  border: 2px solid var(--surface);
  box-sizing: content-box;
}

/* ---------- Rich text: links, @mentions, #hashtags (chat, posts, comments, problems) ---------- */
.rich-link {
  color: #38BDF8;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.rich-link:hover { color: #7DD3FC; }

.rich-mention {
  color: var(--btn-a);
  font-weight: 600;
  background: rgba(139, 92, 246, 0.12);
  border-radius: 4px;
  padding: 0 3px;
}

.rich-hashtag {
  color: #EC4899;
  font-weight: 600;
}

/* ---------- Desktop-only gate ---------- */
#mobile-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 40px 28px;
  text-align: center;
  background: var(--bg-gradient);
  color: var(--text);
}

#mobile-gate svg {
  width: 46px;
  height: 46px;
  color: var(--btn-a);
}

#mobile-gate h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.01em;
}

#mobile-gate p {
  margin: 0;
  max-width: 320px;
  color: var(--text-dim);
  font-size: 14px;
  line-height: 1.6;
}

@media (max-width: 780px) {
  #mobile-gate { display: flex; }
  body > *:not(#mobile-gate) { display: none !important; }
}

:root[data-theme="default"] {
  /* Default Theme (Dark Glass Violet) */
  --topbar-bg: rgba(11, 15, 25, 0.8);
  --bg-base: #0B0F19;
  --bg-gradient: radial-gradient(circle at 15% 15%, rgba(139, 92, 246, 0.22) 0%, transparent 45%),
                 radial-gradient(circle at 85% 85%, rgba(236, 72, 153, 0.15) 0%, transparent 45%),
                 radial-gradient(circle at 50% 50%, rgba(14, 165, 233, 0.08) 0%, transparent 60%),
                 #0B0F19;
  
  --surface: rgba(17, 24, 39, 0.75);
  --surface-soft: rgba(30, 41, 59, 0.5);
  --surface-hover: rgba(30, 41, 59, 0.8);
  --surface-muted: rgba(15, 23, 42, 0.9);
  
  --text: #F8FAFC;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  
  --border: rgba(255, 255, 255, 0.09);
  --border-hover: rgba(139, 92, 246, 0.4);
  --border-focus: #8B5CF6;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.4);
}

:root[data-theme="midnight"] {
  /* Midnight Dark Theme (Deep Onyx) */
  --topbar-bg: rgba(6, 9, 17, 0.85);
  --bg-base: #060911;
  --bg-gradient: radial-gradient(circle at 50% 0%, rgba(99, 102, 241, 0.18) 0%, transparent 60%),
                 radial-gradient(circle at 80% 80%, rgba(168, 85, 247, 0.12) 0%, transparent 50%),
                 #060911;
  
  --surface: rgba(15, 23, 42, 0.8);
  --surface-soft: rgba(30, 41, 59, 0.6);
  --surface-hover: rgba(51, 65, 85, 0.6);
  --surface-muted: rgba(15, 23, 42, 0.95);
  
  --text: #F1F5F9;
  --text-dim: #94A3B8;
  --text-muted: #64748B;
  
  --border: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(99, 102, 241, 0.4);
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 10px 30px -5px rgba(0, 0, 0, 0.6);
}

:root[data-theme="light"] {
  /* Light Theme */
  --topbar-bg: rgba(255, 255, 255, 0.85);
  --bg-base: #F8FAFC;
  --bg-gradient: radial-gradient(circle at 10% 10%, rgba(139, 92, 246, 0.12) 0%, transparent 50%),
                 radial-gradient(circle at 90% 90%, rgba(236, 72, 153, 0.08) 0%, transparent 50%),
                 #F1F5F9;
  
  --surface: rgba(255, 255, 255, 0.9);
  --surface-soft: rgba(248, 250, 252, 0.85);
  --surface-hover: rgba(241, 245, 249, 1);
  --surface-muted: rgba(226, 232, 240, 0.6);
  
  --text: #0F172A;
  --text-dim: #475569;
  --text-muted: #94A3B8;
  
  --border: rgba(226, 232, 240, 0.9);
  --border-hover: rgba(139, 92, 246, 0.4);
  --border-focus: #8B5CF6;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 10px 30px -5px rgba(15, 23, 42, 0.08);
  --scrollbar-track: rgba(15, 23, 42, 0.06);
  --scrollbar-thumb: rgba(15, 23, 42, 0.22);
  --scrollbar-thumb-hover: rgba(139, 92, 246, 0.45);
}

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

html, body {
  min-height: 100vh;
  font-family: var(--font-display);
  color: var(--text);
  background: var(--bg-gradient);
  background-attachment: fixed;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}
::-webkit-scrollbar-track {
  background: var(--scrollbar-track);
}
::-webkit-scrollbar-thumb {
  background: var(--scrollbar-thumb);
  border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--scrollbar-thumb-hover);
}

/* Base Utility Components */
.card {
  background: var(--surface);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-md);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, transform 0.2s ease;
}

.field {
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.field input, .field select, .field textarea {
  width: 100%;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 11px 14px;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 14px;
  outline: none;
  transition: all 0.2s ease;
}

.field input::placeholder, .field textarea::placeholder {
  color: var(--text-muted);
}

.field input:focus, .field select:focus, .field textarea:focus {
  border-color: var(--border-focus);
  background: var(--surface-hover);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

/* Primary Button */
.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--btn-grad);
  color: #FFFFFF;
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 20px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.35);
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  user-select: none;
  text-decoration: none;
}

.primary-btn:hover {
  background: var(--btn-grad-hover);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.primary-btn:active {
  transform: translateY(0) scale(0.98);
}

.primary-btn.small {
  padding: 7px 14px;
  font-size: 12.5px;
  border-radius: 8px;
}

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

/* Text / Ghost Button */
.text-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  text-decoration: none;
}

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

.danger-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--danger-soft);
  color: var(--danger);
  border: 1px solid rgba(239, 68, 68, 0.35);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
}

.danger-btn:hover {
  background: rgba(239, 68, 68, 0.24);
}

.danger-btn.small {
  padding: 7px 12px;
  font-size: 12px;
}

.danger-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.security-backdrop {
  position: fixed;
  inset: 0;
  z-index: 250;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 12, 0.78);
}

.security-card {
  width: min(100%, 380px);
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-muted);
  box-shadow: var(--shadow-md);
}

.security-card h3 {
  margin: 0 0 8px;
  color: var(--text);
}

.security-card > p {
  color: var(--text-dim);
}

.security-card .g-recaptcha {
  margin: 16px 0;
}

.error {
  color: var(--danger);
  background: var(--danger-soft);
  border: 1px solid rgba(239, 68, 68, 0.3);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  margin: 6px 0;
}

.success {
  color: var(--success);
  background: var(--success-soft);
  border: 1px solid rgba(16, 185, 129, 0.3);
  padding: 8px 12px;
  border-radius: 8px;
  font-size: 12.5px;
  margin: 6px 0;
}

.empty-note {
  color: var(--text-muted);
  font-size: 13px;
  text-align: center;
  padding: 24px 12px;
  font-style: italic;
}

/* Modals */
.modal-backdrop[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.75);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  z-index: 250;
  animation: fadeIn 0.2s ease;
}

.modal {
  width: 100vw !important;
  max-width: none !important;
  height: 100dvh;
  max-height: 100dvh !important;
  padding: clamp(24px, 5vw, 64px);
  border-radius: 0 !important;
  overflow-y: auto;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-back-link {
  align-self: flex-start;
  min-height: 48px;
  margin: 0 0 20px;
  font-size: 15px;
}

.modal .field input,
.modal .field select,
.modal .field textarea,
.modal input:not([type="checkbox"]):not([type="file"]),
.modal select,
.modal textarea {
  min-height: 52px;
  font-size: 16px;
}

.modal button:not(.modal-x):not(.profile-link) {
  min-height: 48px;
  font-size: 15px;
}

.modal .small { padding: 11px 18px; }

.modal h3 {
  margin: 0 0 20px;
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--text);
}

.cost-tag {
  font-family: var(--font-mono);
  font-size: 11px;
  color: #38BDF8;
  background: rgba(56, 189, 248, 0.12);
  border: 1px solid rgba(56, 189, 248, 0.25);
  padding: 3px 8px;
  border-radius: 99px;
  font-weight: 500;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 20px;
}

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

@keyframes modalPop {
  from { opacity: 0; transform: scale(0.95) translateY(12px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.4); }
  50% { box-shadow: 0 0 0 6px rgba(16, 185, 129, 0); }
}

@media (max-width: 600px) {
  .modal { padding: 22px 18px; }
  .modal-back-link { margin-bottom: 14px; }
}

/* ---------- Global Chat Interface & DM Modal Styles ---------- */
.messages {
  flex: 1;
  background: var(--surface-soft);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  transition: background 0.2s ease;
}

.message-row:hover {
  background: var(--surface-hover);
}

.message-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-dim);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.message-meta strong {
  color: #38BDF8;
  font-family: var(--font-display);
  font-size: 13px;
}

.message-content {
  font-size: 14px;
  color: var(--text);
  line-height: 1.5;
  word-break: break-word;
}

.message-form {
  display: flex;
  gap: 10px;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
  align-items: center;
}

.message-form input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 8px 6px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  font-family: var(--font-display);
}

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

/* ---------- Mini Popup / Toast Notifications ---------- */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-popup {
  pointer-events: auto;
  min-width: 260px;
  max-width: 380px;
  padding: 12px 18px;
  background: rgba(17, 24, 39, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 600;
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 0 15px rgba(139, 92, 246, 0.2);
  display: flex;
  align-items: center;
  gap: 10px;
  animation: toastIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  transition: all 0.3s ease;
}

.toast-popup.info {
  border-color: rgba(139, 92, 246, 0.5);
}

.toast-popup.warning {
  border-color: rgba(245, 158, 11, 0.5);
  color: #FBBF24;
}

.toast-popup.success {
  border-color: rgba(16, 185, 129, 0.5);
  color: #34D399;
}

@keyframes toastIn {
  from { opacity: 0; transform: translateY(16px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

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




/* ---------- Loading overlay (js/loading.js) ---------- */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(3, 7, 18, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 14px;
  z-index: 500;
  animation: fadeIn 0.15s ease;
}
.loading-overlay[hidden] { display: none; }

.loading-spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--btn-a, #8B5CF6);
  animation: spin 0.8s linear infinite;
}

.loading-overlay-text {
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--text-dim, #94A3B8);
}

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

/* Inline spinner variant, for a specific card/list while it loads */
.inline-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px 12px;
  color: var(--text-dim);
  font-size: 13px;
}
.inline-loading .loading-spinner {
  width: 18px;
  height: 18px;
  border-width: 2px;
}

/* Button-level loading state */
.primary-btn.is-loading {
  color: transparent !important;
  pointer-events: none;
  position: relative;
}
.primary-btn.is-loading::after {
  content: "";
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  animation: spin 0.7s linear infinite;
}