:root {
  --bs-body-font-family: 'Outfit', sans-serif;
  --bs-primary: #6366f1;
  --bs-secondary: #64748b;
  --bs-accent: #ffc107;
  --bs-dark: #0f172a;
  --bs-body-bg: #0f172a;
  --bs-body-color: #f8fafc;
  --bs-gradient-brand: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
  --bs-gradient-vibrant: linear-gradient(135deg, #2563eb 0%, #4f46e5 100%);
  --bs-gradient-dark: linear-gradient(145deg, #1e293b 0%, #0f172a 100%);
}

body {
  background-color: #0f172a;
  background-image:
    radial-gradient(at 0% 0%, rgba(99, 102, 241, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 0%, rgba(168, 85, 247, 0.15) 0px, transparent 50%),
    radial-gradient(at 100% 100%, rgba(236, 72, 153, 0.1) 0px, transparent 50%);
  background-attachment: fixed;
  font-family: var(--bs-body-font-family);
  color: var(--bs-body-color);
  -webkit-font-smoothing: antialiased;
}

/* Navbar Glassmorphism */
.navbar {
  background-color: rgba(15, 23, 42, 0.7) !important;
  backdrop-filter: blur(16px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  z-index: 1050;
  position: sticky;
  top: 0;
}

.navbar-brand {
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(to right, #fff, #94a3b8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* Form Controls */
.form-control,
.form-select,
.input-group-text {
  background-color: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #fff !important;
  border-radius: 0.75rem;
  transition: all 0.2s ease;
}

.form-control::placeholder {
  color: rgba(255, 255, 255, 0.6) !important;
  opacity: 1;
}

.form-control:focus,
.form-select:focus {
  background-color: rgba(15, 23, 42, 0.8);
  border-color: var(--bs-primary);
  color: #fff;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.15);
  transform: translateY(-1px);
}

.form-control:disabled,
.form-control[readonly] {
  background-color: rgba(15, 23, 42, 0.4);
  color: rgba(255, 255, 255, 0.5);
  border-color: rgba(255, 255, 255, 0.05);
}

/* File Input Styling */
.form-control::file-selector-button {
  background-color: rgba(255, 255, 255, 0.08);
  color: #fff;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.1);
  padding: 0.5rem 1rem;
  margin-right: 1rem;
  transition: background-color 0.2s;
}

.form-control:hover::file-selector-button {
  background-color: rgba(255, 255, 255, 0.15);
}

/* Form Helper Text */
.form-text {
  color: rgba(248, 250, 252, 0.6) !important;
}

/* Cards */
.card {
  background-color: rgba(30, 41, 59, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  color: #f8fafc;
  border-radius: 1rem;
}

/* Unified Glass Card for Comments, Replies, and Content */
.card-glass {
  background-color: rgba(30, 41, 59, 0.4) !important;
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 1rem;
  transition: all 0.3s ease;
}

.card-glass:hover {
  background-color: rgba(30, 41, 59, 0.5) !important;
  border-color: rgba(255, 255, 255, 0.15);
}

/* Premium Card Utility - The "Stand Out" Card */
.premium-card {
  background: rgba(30, 41, 59, 0.4) !important;
  border: 1px solid rgba(255, 255, 255, 0.08) !important;
  backdrop-filter: blur(12px) !important;
  border-radius: 1rem;
  position: relative;
}

.premium-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 1rem;
  padding: 1px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.1), transparent);
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
  pointer-events: none;
}

.premium-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 30px -10px rgba(0, 0, 0, 0.5);
  border-color: rgba(99, 102, 241, 0.4) !important;
}

.premium-card:hover::before {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.5), transparent);
}

/* Vibrant Gradient Utility */
.bg-gradient-vibrant {
  background: var(--bs-gradient-vibrant) !important;
  position: relative;
  overflow: hidden;
}

.bg-gradient-vibrant::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(to bottom, transparent 0%, rgba(15, 23, 42, 0.4) 100%);
  pointer-events: none;
}

.card-title a {
  transition: color 0.2s;
  color: #fff !important;
}

.card-title a:hover {
  color: #818cf8 !important;
}

/* Buttons */
.btn-primary,
.btn-brand {
  background: var(--bs-gradient-brand);
  border: none;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  color: #fff;
  position: relative;
  overflow: hidden;
  z-index: 1;
}

.btn-primary::before,
.btn-brand::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  z-index: -1;
  transition: opacity 0.2s;
  opacity: 0;
}

.btn-primary:hover::before,
.btn-brand:hover::before {
  opacity: 1;
}

.btn-primary:hover,
.btn-brand:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(99, 102, 241, 0.4);
  color: #fff;
}

.btn-accent {
  background-color: var(--bs-accent);
  border: none;
  color: #0f172a;
  font-weight: 700;
  transition: all 0.2s;
  box-shadow: 0 4px 12px rgba(255, 193, 7, 0.2);
}

.btn-accent:hover {
  background-color: #fbbf24;
  transform: translateY(-2px);
  box-shadow: 0 8px 16px rgba(255, 193, 7, 0.4);
  color: #0f172a;
}

.btn-outline-light {
  border-color: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
}

.btn-outline-light:hover {
  background-color: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.8);
  color: #fff;
  box-shadow: 0 0 20px rgba(255, 255, 255, 0.1);
}

/* Custom Utilities */
.text-light-50 {
  color: rgba(248, 250, 252, 0.5) !important;
}

.text-light-75 {
  color: rgba(248, 250, 252, 0.75) !important;
}

a {
  text-decoration: none;
}

/* Dropdown Menus */
.dropdown-menu {
  background-color: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.4);
  padding: 0.5rem;
  border-radius: 0.75rem;
  z-index: 2050 !important;
}

.dropdown-item {
  color: #e2e8f0;
  border-radius: 0.5rem;
  padding: 0.5rem 1rem;
  transition: all 0.15s;
}

.dropdown-item:hover,
.dropdown-item:focus {
  background-color: rgba(99, 102, 241, 0.15);
  color: #fff;
}

.dropdown-divider {
  border-top-color: rgba(255, 255, 255, 0.1);
  margin: 0.5rem 0;
}

/* Fix generic Bootstrap text colors */
.text-muted {
  color: rgba(248, 250, 252, 0.6) !important;
}

.text-dark {
  color: #f8fafc !important;
}

/* Markdown Styling */
.markdown-content ul,
.markdown-content ol {
  padding-left: 1.5rem;
  margin-bottom: 1rem;
}

.markdown-content ul {
  list-style-type: disc;
}

.markdown-content li {
  margin-bottom: 0.25rem;
}

.markdown-content a {
  color: #818cf8;
  text-decoration: none;
  font-weight: 500;
  transition: color 0.2s ease;
  border-bottom: 1px solid rgba(129, 140, 248, 0.3);
}

.markdown-content a:hover {
  color: #a5b4fc;
  border-bottom-color: #a5b4fc;
  text-decoration: none;
}

.markdown-content p:last-child {
  margin-bottom: 0;
}

/* Force wrapping for all markdown content */
.markdown-content {
  overflow-wrap: break-word;
  word-wrap: break-word;
  word-break: break-word;
}

/* Ensure links break if they are too long */
.markdown-content a {
  word-break: break-all;
}

.markdown-content li {
  word-break: break-all !important;
  white-space: normal !important;
}

.markdown-content pre {
  white-space: pre-wrap !important;
  word-break: break-all !important;
  background: rgba(0, 0, 0, 0.3);
  padding: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.05);
  border-radius: 0.75rem;
}

.markdown-content li pre {
  background: transparent !important;
  padding: 0 !important;
  border-radius: 0 !important;
  margin: 0 !important;
  border: none !important;
}

.markdown-content li pre code {
  background: transparent !important;
  padding: 0 !important;
}

.markdown-content code {
  white-space: pre-wrap !important;
  word-break: break-all !important;
  color: #e2e8f0;
  background: rgba(255, 255, 255, 0.1);
  padding: 0.1em 0.3em;
  border-radius: 0.25em;
}

/* Search Bar Styling */
.search-wrapper {
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-wrapper:focus-within {
  border-color: #818cf8 !important;
  background-color: rgba(15, 23, 42, 0.8) !important;
  box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.25);
  transform: translateY(-1px);
}

.search-wrapper.has-dropdown {
  border-bottom-left-radius: 0 !important;
  border-bottom-right-radius: 0 !important;
  border-color: #818cf8 !important;
  /* Unified outline */
  border-bottom-color: transparent !important;
  background-color: rgba(15, 23, 42, 0.95) !important;
  transform: none !important;
  box-shadow: none !important;
  z-index: 2001;
  /* Higher than dropdown */
}

.search-input::placeholder {
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.95rem;
}

/* Footer Styling */
.site-footer {
  background-color: rgba(15, 23, 42, 0.8) !important;
  backdrop-filter: blur(16px);
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.9rem;
}

.footer-link {
  color: #94a3b8;
  transition: all 0.2s ease;
  position: relative;
}

.footer-link:hover {
  color: #fff;
  text-decoration: none;
}

.footer-link::after {
  content: '';
  position: absolute;
  width: 0;
  height: 1px;
  bottom: -2px;
  left: 0;
  background: var(--bs-gradient-brand);
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.footer-link:hover::after {
  width: 100%;
}

.btn-discord {
  background-color: #5865F2;
  color: #fff;
  border: none;
  font-weight: 500;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-discord:hover {
  background-color: #4752c4;
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(88, 101, 242, 0.3);
}

.community-text {
  background: var(--bs-gradient-brand);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
  font-weight: 600;
}

/* Search Autocomplete */
.search-dropdown {
  position: absolute;
  top: calc(100% - 1px);
  left: -1px;
  right: -1px;
  z-index: 2000;
  background-color: rgba(15, 23, 42, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid #818cf8;
  /* Unified outline */
  border-top: none !important;
  border-radius: 0 0 1.25rem 1.25rem !important;
  overflow: hidden;
  display: none;
  /* Hidden by default */
  box-shadow: 0 20px 40px -5px rgba(0, 0, 0, 0.5);
  animation: dropdownFadeIn 0.2s ease;
}

@keyframes dropdownFadeIn {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

.search-dropdown.show {
  display: block;
}

.search-section-title {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(255, 255, 255, 0.4);
  padding: 0.75rem 1rem 0.25rem;
  font-weight: 700;
}

.search-item {
  display: flex !important;
  align-items: center;
  width: 100%;
  padding: 0.75rem 1rem;
  color: #e2e8f0 !important;
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.search-item:last-child {
  border-bottom: none;
}

.search-item:hover {
  background-color: rgba(99, 102, 241, 0.1);
  padding-left: 1.25rem;
}

.search-item a:hover {
  color: #fff !important;
}

.search-delete-btn {
  opacity: 0;
  transition: opacity 0.2s, color 0.2s;
  cursor: pointer;
  color: rgba(255, 255, 255, 0.4);
  height: 32px;
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  flex-shrink: 0;
  font-size: 14px;
  margin-left: 8px;
}

.search-delete-btn i {
  margin: 0 !important;
  width: auto !important;
}

.search-item:hover .search-delete-btn {
  opacity: 1;
}

.search-delete-btn:hover {
  color: #ef4444;
  /* Red-500 */
  background: rgba(255, 255, 255, 0.1);
}

.search-item i {
  width: 20px;
  text-align: center;
  margin-right: 0.75rem;
  opacity: 0.7;
  color: #818cf8;
}

.text-xs {
  font-size: 0.75rem !important;
}

.letter-spacing-1 {
  letter-spacing: 0.05em;
}

/* Custom Upload Button */
.btn-upload-cool {
  display: flex !important;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1.1;
  padding: 0.5rem 1rem;
  border: 1px solid #a855f7;
  /* Purple-500 */
  border-radius: 8px;
  color: #e9d5ff;
  /* Purple-100 */
  text-decoration: none;
  transition: all 0.3s ease;
  font-weight: 500;
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  background: transparent;
}

.btn-upload-cool:hover {
  border-color: #c084fc;
  /* Purple-400 */
  color: #fff;
  background: rgba(168, 85, 247, 0.15);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(168, 85, 247, 0.3);
}

.btn-upload-cool span {
  display: block;
}

@media (max-width: 991.98px) {

  /* --- Mobile Header Layout (Left-Center-Right) --- */

  /* 1. Toggler on the Left */
  .navbar-toggler {
    order: -1;
    margin-right: auto;
    /* Push others to right if needed, though flex spread handles it */
  }

  /* 2. Brand in the Center */
  .navbar-brand {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    margin: 0;
  }

  /* 3. User Tools on the Right */
  .user-tools {
    order: 2;
    margin-left: auto;
  }

  /* Premium Floating Mobile Menu Container */
  .navbar-collapse {
    background-color: rgba(15, 23, 42, 0.95);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 1.5rem;
    margin: 1rem;
    /* Floating effect */
    padding: 1rem;
    /* Reduced padding to allow more width for items */
    box-shadow: 0 20px 50px -10px rgba(0, 0, 0, 0.5);
    position: absolute;
    /* Float over content */
    top: 100%;
    left: 0;
    right: 0;
    z-index: 2000;
    overflow: visible !important;

    /* Flex Column for content ordering */
    display: flex;
    flex-direction: column;
    text-align: center;

    /* Smooth fade animation */
    opacity: 0;
    transition: opacity 0.15s ease;
  }

  .navbar-collapse.show {
    opacity: 1;
  }

  /* Nav Links Styling (Centered Pills) */
  .navbar-nav {
    width: 100%;
    justify-content: center;
    align-items: center;
  }

  .navbar-nav .nav-link {
    padding: 0.75rem 1rem;
    border-radius: 2rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.8) !important;
    display: block;
    /* Ensure it takes full width set below */
    width: 100%;
    /* Fill the container (minus padding) */
    max-width: none;
    /* Allow full stretch */
  }

  .navbar-nav .nav-link:hover,
  .navbar-nav .nav-link:focus {
    background-color: rgba(255, 255, 255, 0.1);
    color: #fff !important;
    transform: scale(1.05);
    /* Subtle pop */
  }

  /* Search Bar (Bottom) */
  .navbar-collapse form {
    order: 10;
    /* Push to bottom */
    margin-top: 1.5rem;
    margin-bottom: 0.5rem;
  }

  .search-wrapper {
    margin: 0;
  }

  /* Mobile User Dropdown (Hidden here, usually handled in header now, but just in case) */
  /* The extracted user tools means this selector might not be relevant for User Profile anymore, 
     but kept for safety if any dropdowns remain */
  .navbar-nav .dropdown-menu {
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    /* Center dropdown */
    width: 90%;
    margin-top: 0.5rem;
    background: #1e293b;
    border-radius: 1rem;
    z-index: 2050;
  }
}