.header {
  background-color: rgba(88, 26, 26, 0.943);
  padding: 10px 30px;
  z-index: 1000;
  justify-content: space-between;
  align-items: center;
  display: flex;
  flex-wrap: wrap;
}

#headerLink {
  text-decoration: none;
}

#headerName {
  margin: 0;
  color: white;
  font-family: "Playfair Display", serif;
  font-weight: 550; 
  font-size: 20px;
  padding-left: 10px;
}

.menu {
  text-align: center;
  flex-grow: 1;
  display: flex;
  justify-content: center;
  font-family: "Noto Sans Sunuwar", sans-serif;
  font-weight: 400;
  font-style: normal;
  font-size: 14px;
}

.menu ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  justify-content: center;
  gap: 20px;
}

.menu li {
  position: relative;
}

.menu a {
  display: block;
  padding: 10px 15px;
  color: white;
  font-weight: 547;
  text-decoration: none;
}

.menu a:hover,
.menu .active,
.dropdown-link-desktop:hover,
.dropdown-link-desktop:focus-visible {
  background-color: #333333dc;
  color: white;
  border-radius: 4px;
}

/* Dropdown submenu */
.dropdown-content {
  display: none;
  position: absolute;
  background-color: rgb(36, 35, 35);
  top: 100%;
  left: 0;
  box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  min-width: 180px;
  visibility: hidden;
  z-index: 9999;
}

.dropdown:hover .dropdown-content {
  visibility: visible;
  display: block;
  border-radius: 5px;
}

.dropdown-content li a {
  padding: 10px 16px;
  text-align: left;
  white-space: nowrap;
}

.login {
  padding: 8px 16px;
  background-color: #1D2433;
  color: white;
  border: none;
  border-radius: 4px;
  font-family: "Roboto", sans-serif;
  cursor: pointer;
}

.user-chip {
  margin-right: 10px;
  color: #fff;
  font-family: "Roboto", sans-serif;
  font-size: 14px;
}

body {
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

/* --- HIDE ALL MOBILE INTERFACE ELEMENTS ON PC --- */
#menu-toggle, 
.submenu-toggle-cb,
.hamburger-label, 
.dropdown-label-mobile,
.mobile-auth,
.mobile-spacer {
  display: none !important; /* Forces layout isolation on desktop view */
}
.dropdown-link-desktop {
  display: block;
}

.dropdown-link-desktop {
  display: block;
  padding: 10px 15px;
  background: none;
  border: 0;
  font: inherit;
  color: white;
  font-weight: 547;
  text-decoration: none;
  cursor: pointer;
  width: auto;
  line-height: inherit;
  appearance: none;
  -webkit-appearance: none;
}


/* ==========================================================================
   2. MOBILE OVERRIDES (Only runs on screens smaller than 768px)
   ========================================================================== */
@media screen and (max-width: 768px) {
  
  /* Layout balancing for mobile header bar */
  .header {
    position: sticky;
    top: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    z-index: 100200;
  }

  .left {
    order: 2; /* Title to center slot */
    flex-grow: 0;
  }

  #headerName {
    padding-left: 0;
    font-size: 18px;
  }

  /* Hamburger position */
  .hamburger-label {
    order: 1; /* Hamburger to left slot */
    display: flex !important; /* Overrides desktop visibility suppression */
    flex-direction: column;
    justify-content: space-between;
    width: 22px;
    height: 16px;
    cursor: pointer;
    z-index: 100300; /* Layer explicitly above side drawer panel */
  }

  /* Blank spacer weight helper */
  .mobile-spacer {
    order: 3; /* Spacer to right slot */
    display: block !important;
    width: 22px;
    height: 16px;
  }

  .desktop-auth {
    display: none !important;
  }

  /* Render hamburger horizontal lines */
  .hamburger-label span {
    display: block;
    height: 2px;
    width: 100%;
    background-color: white;
    border-radius: 1px;
    transition: all 0.25s ease-in-out;
  }

  /* FIXED: Turn menu bar into a full-height left side panel drawer */
  .menu {
    position: fixed;
    top: 0;
    left: -280px; /* Completely hidden off-screen left */
    width: 280px;
    height: 100dvh;
    background-color: rgb(36, 35, 35);
    padding: 72px 0 0 0;
    transition: left 0.3s ease-in-out;
    box-shadow: 4px 0 15px rgba(0, 0, 0, 0.4);
    z-index: 100250;
    display: flex !important; /* Enforces block layout alignment over desktop rule */
    flex-direction: column;
    justify-content: flex-start;
    box-sizing: border-box;
    text-align: left;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* FIXED: Targets the menu wrapper directly using the target parent structure */
  .header #menu-toggle:checked ~ .menu {
    left: 0;
  }

  /* Stack menu list links cleanly */
  .menu ul.nav-links {
    flex: 1 1 auto;
    flex-direction: column;
    justify-content: flex-start;
    gap: 0;
    width: 100%;
    padding: 0;
    margin: 0;
  }

  .menu li {
    width: 100%;
  }

  .menu a, .dropdown-label-mobile, .dropdown-link-desktop {
    padding: 14px 24px;
    display: block;
    color: white;
    font-size: 15px;
    text-align: left;
    box-sizing: border-box;
  }

  /* Toggle display options for Form menu styles */
  .dropdown-link-desktop {
    display: none !important;
  }

  .dropdown-label-mobile {
    display: block !important;
    cursor: pointer;
    width: 100%;
  }

  /* Format mobile submenus safely inside drawer */
  .dropdown-content {
    display: none;
    visibility: visible !important; /* FIXED: Forces visibility to turn back on for mobile on initial load */
    position: relative;
    top: 0;
    left: 0;
    box-shadow: none;
    background-color: #1a1a1a;
    width: 100%;
    border-radius: 0 !important;
  }

  /* FIXED: Stops the menu items from floating side-by-side or overflowing */
.dropdown-content {
    display: none !important; /* Strictly hide it on page load */
    visibility: visible !important; /* Eliminate the hidden conflict */
    position: relative !important;
    top: 0 !important;
    left: 0 !important;
    box-shadow: none !important;
    background-color: #1a1a1a !important;
    width: 100% !important;
    border-radius: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
    
    /* Crucial fix to kill desktop row alignment */
    flex-direction: column !important; 
    justify-content: flex-start !important;
    gap: 0 !important;
  }

  /* 2. FORCE SINGLE LINE BLOCKS: Prevents links from layout bleeding side-by-side */
  .dropdown-content li {
    display: block !important;
    width: 100% !important;
    float: none !important;
  }

  /* 3. WRAP TEXT RESPONSIVELY: Safely aligns long text paths inside the side panel */
  .dropdown-content li a {
    display: block !important;
    padding: 12px 40px !important; /* Indent sublinks nicely */
    white-space: normal !important; /* Snaps text line wraps cleanly */
    width: 100% !important;
    box-sizing: border-box !important;
  }

  /* 4. OPEN TRIGGER: Smoothly force display block only when the button checkbox is checked */
  .submenu-toggle-cb:checked ~ .dropdown-content {
    display: flex !important; /* Changes to vertical flex layer stack upon touch */
  }

  /* Open dropdown lists when inner sub checkbox is ticked */
  .submenu-toggle-cb:checked ~ .dropdown-content {
    display: block !important;
  }

  /* Keep mobile dropdown from executing desktop hovers */
  .dropdown:hover .dropdown-content {
    display: none;
  }

  /* Secure Mobile login module exactly at the absolute bottom */
  .mobile-auth {
    position: sticky;
    bottom: 0;
    z-index: 1;
    display: flex !important;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    box-sizing: border-box;
    background-color: rgb(36, 35, 35);
    margin-top: auto; /* Pushes auth wrapper to the bottom of the drawer when content is short */
  }

  .mobile-auth .user-chip {
    margin-right: 0;
    margin-bottom: 5px;
  }

  .mobile-auth .login {
    width: 90%;
    text-align: center;
    padding: 10px;
  }

  /* Morph hamburger lines to 'X' exit glyph */
  .header #menu-toggle:checked + .hamburger-label span:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  .header #menu-toggle:checked + .hamburger-label span:nth-child(2) {
    opacity: 0;
  }

  .header #menu-toggle:checked + .hamburger-label span:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  .menu-backdrop {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;
    z-index: 100240;
  }

  .header #menu-toggle:checked ~ .menu-backdrop {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
  }
.dropdown-caret {
    display: inline-flex;
    align-items: center;

    margin-left: 6px;

    /* key fix: vertical alignment with text */
    position: relative;
    top: 1px;

    width: 11px;
    height: 11px;
}
.dropdown-caret svg {
    width: 11px;
    height: 11px;
    display: block;
}
  .submenu-toggle-cb:checked ~ .dropdown-label-mobile .dropdown-caret {
    transform: rotate(180deg);
}
}