
    nav {
      position: fixed;
      top: 0;
      left: 0;
      right: 0;
      z-index: 700;
      padding: 22px 64px;
      display: flex;
      justify-content: space-between;
      align-items: center;
      backdrop-filter: blur(28px);
      -webkit-backdrop-filter: blur(28px);
      background: var(--navBg);
      border-bottom: 1px solid var(--border);
      transition: padding .3s, transform .4s cubic-bezier(.16, 1, .3, 1);
    }

    nav.scrolled {
      padding: 14px 64px;
    }

    nav.hidden {
      transform: translateY(0);
    }

    .nav-logo {
      font-family: var(--font-display);
      font-weight: 700;
      font-size: .95rem;
      color: var(--text);
      text-decoration: none;
      letter-spacing: var(--heading-tracking);
    }

    .nav-logo .dot {
      color: var(--cyan);
    }

    .nav-links {
      display: flex;
      gap: 32px;
      list-style: none;
    }

    .nav-links a {
      color: var(--muted2);
      text-decoration: none;
      font-size: .72rem;
      letter-spacing: .12em;
      text-transform: uppercase;
      font-weight: 500;
      transition: color .2s;
      position: relative;
      padding-bottom: 3px;
    }

    .nav-links a::after {
      content: '';
      position: absolute;
      bottom: 0;
      left: 0;
      width: 0;
      height: 1px;
      background: linear-gradient(90deg, var(--cyan), var(--steel-blue));
      transition: width .35s;
    }

    .nav-links a:hover {
      color: var(--text);
    }

    .nav-links a.is-active {
      color: var(--text);
      font-weight: 850;
      text-shadow: 0 0 14px color-mix(in srgb, var(--chapter-accent) 62%, transparent);
    }

    .nav-links a:hover::after {
      width: 100%;
    }

    .nav-links a.is-active::after {
      width: 100%;
      height: 2px;
      background: linear-gradient(90deg, var(--chapter-accent), rgba(255, 255, 255, .72));
      box-shadow: 0 0 14px color-mix(in srgb, var(--chapter-accent) 56%, transparent);
    }

    /* --- Navigation Projects Dropdown --- */
    .nav-dropdown {
      position: relative;
      list-style: none;
    }

    .nav-dropdown:hover > a,
    .nav-dropdown.is-open > a,
    .nav-dropdown.is-active > a {
      color: var(--text);
    }

    .nav-dropdown:hover > a::after,
    .nav-dropdown.is-open > a::after,
    .nav-dropdown.is-active > a::after {
      width: 100%;
    }

    .nav-dropdown-menu {
      position: absolute;
      top: calc(100% + 14px);
      left: 50%;
      transform: translateX(-50%) translateY(8px);
      min-width: 290px;
      background: rgba(11, 15, 22, 0.90);
      backdrop-filter: blur(16px) url(#glass-refraction);
      -webkit-backdrop-filter: blur(16px);
      border: 1px solid rgba(255, 255, 255, 0.14);
      border-top: 1.5px solid rgba(255, 255, 255, 0.45);
      box-shadow:
        0 24px 54px rgba(0, 0, 0, 0.65),
        0 0 24px rgba(0, 229, 255, 0.08),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.35);
      border-radius: 14px;
      padding: 8px;
      opacity: 0;
      visibility: hidden;
      pointer-events: none;
      transition: opacity .22s cubic-bezier(.16,1,.3,1), transform .22s cubic-bezier(.16,1,.3,1), visibility .22s;
      z-index: 900;
    }

    /* Hover safety bridge */
    .nav-dropdown-menu::before {
      content: '';
      position: absolute;
      top: -14px;
      left: 0;
      right: 0;
      height: 14px;
    }

    .nav-dropdown:hover .nav-dropdown-menu,
    .nav-dropdown:focus-within .nav-dropdown-menu,
    .nav-dropdown.is-open .nav-dropdown-menu {
      opacity: 1;
      visibility: visible;
      pointer-events: auto;
      transform: translateX(-50%) translateY(0);
    }

    .dropdown-item {
      display: flex !important;
      align-items: flex-start !important;
      gap: 12px !important;
      padding: 10px 12px !important;
      border-radius: 9px !important;
      text-decoration: none !important;
      transition: background .2s ease, transform .15s ease !important;
      position: relative;
    }

    .dropdown-item::after {
      display: none !important;
    }

    .dropdown-item:hover,
    .dropdown-item:focus {
      background: rgba(0, 229, 255, 0.08) !important;
      transform: translateX(2px);
    }

    .dd-item-icon {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 28px;
      height: 28px;
      border-radius: 7px;
      background: rgba(255, 255, 255, 0.05);
      border: 1px solid rgba(255, 255, 255, 0.1);
      color: var(--cyan);
      flex-shrink: 0;
      margin-top: 2px;
      transition: all .2s ease;
    }

    .dropdown-item:hover .dd-item-icon {
      background: rgba(0, 229, 255, 0.15);
      border-color: rgba(0, 229, 255, 0.35);
      box-shadow: 0 0 10px rgba(0, 229, 255, 0.25);
    }

    .dd-item-text {
      display: flex;
      flex-direction: column;
      gap: 2px;
    }

    .dd-title {
      font-family: var(--font-body) !important;
      font-size: 0.82rem !important;
      font-weight: 600 !important;
      color: #f1f5f9 !important;
      letter-spacing: 0 !important;
      text-transform: none !important;
      display: flex;
      align-items: center;
      gap: 6px;
      transition: color .2s;
    }

    .dropdown-item:hover .dd-title {
      color: var(--cyan) !important;
    }

    .dd-desc {
      font-family: var(--font-body) !important;
      font-size: 0.71rem !important;
      color: #94a3b8 !important;
      letter-spacing: 0 !important;
      text-transform: none !important;
      line-height: 1.35 !important;
    }

    .dd-arrow {
      transition: transform .2s ease;
    }

    .dropdown-item:hover .dd-arrow {
      transform: translateX(3px);
    }

    .dd-badge {
      display: inline-block;
      font-size: 0.62rem;
      font-weight: 700;
      padding: 1px 6px;
      border-radius: 999px;
      background: rgba(0, 229, 255, 0.15);
      color: var(--cyan);
      border: 1px solid rgba(0, 229, 255, 0.3);
    }

    .dropdown-divider {
      height: 1px;
      background: rgba(255, 255, 255, 0.08);
      margin: 4px 6px;
    }

    /* Light Theme Dropdown Overrides */
    html[data-theme="light"] .nav-dropdown-menu {
      background: rgba(255, 255, 255, 0.94);
      border-color: rgba(148, 163, 184, 0.35);
      border-top-color: rgba(255, 255, 255, 0.95);
      box-shadow:
        0 20px 48px rgba(15, 23, 42, 0.14),
        inset 0 1px 0 0 rgba(255, 255, 255, 0.9);
    }

    html[data-theme="light"] .dd-title {
      color: #0f172a !important;
    }

    html[data-theme="light"] .dd-desc {
      color: #64748b !important;
    }

    html[data-theme="light"] .dd-item-icon {
      background: rgba(15, 23, 42, 0.04);
      border-color: rgba(15, 23, 42, 0.1);
      color: #0284c7;
    }

    html[data-theme="light"] .dropdown-item:hover {
      background: rgba(2, 132, 199, 0.08) !important;
    }

    html[data-theme="light"] .dropdown-divider {
      background: rgba(15, 23, 42, 0.08);
    }

    #themeToggle {
      background: var(--themeToggleBg);
      border: 1px solid var(--border);
      color: var(--muted2);
      border-radius: 999px;
      padding: 10px 14px;
      cursor: pointer;
      font-size: .72rem;
      letter-spacing: .10em;
      text-transform: uppercase;
      font-weight: 600;
      transition: background .2s, border-color .2s, color .2s, transform .2s;
      user-select: none;
    }

    #themeToggle:hover {
      background: var(--themeToggleBgHover);
      border-color: rgba(0, 229, 255, .45);
      color: var(--text);
    }

    #themeToggle:focus-visible {
      outline: 2px solid var(--cyan);
      outline-offset: 3px;
    }

    /* Circular View Transition for Theme Switch */
    ::view-transition-old(root),
    ::view-transition-new(root) {
      animation: none;
      mix-blend-mode: normal;
    }

    ::view-transition-old(root) {
      z-index: 1;
    }

    ::view-transition-new(root) {
      z-index: 9999;
    }

    @media (prefers-reduced-motion: reduce) {
      ::view-transition-old(root),
      ::view-transition-new(root) {
        animation: none !important;
      }
    }

    .ham {
      appearance: none;
      -webkit-appearance: none;
      display: none;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      gap: 5px;
      width: 44px;
      height: 44px;
      padding: 11px;
      border: 0;
      border-radius: 4px;
      background: transparent;
      color: var(--text);
      cursor: pointer;
      z-index: 800;
    }

    .ham:focus-visible {
      outline: 2px solid var(--cyan);
      outline-offset: 3px;
    }

    .ham span {
      display: block;
      width: 22px;
      height: 2px;
      background: currentColor;
      transition: transform .3s, opacity .3s;
    }

    .ham.open span:nth-child(1) {
      transform: rotate(45deg) translate(5px, 5px);
    }

    .ham.open span:nth-child(2) {
      opacity: 0;
    }

    .ham.open span:nth-child(3) {
      transform: rotate(-45deg) translate(5px, -5px);
    }

    .mob {
      display: none;
      position: fixed;
      inset: 0;
      background: var(--mobBg);
      z-index: 600;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      gap: 40px;
    }

    .mob.open {
      display: flex;
    }

    .mob a {
      font-family: var(--font-display);
      font-size: 1.8rem;
      font-weight: 700;
      color: var(--muted2);
      text-decoration: none;
      transition: color .2s;
    }

    .mob a:hover {
      color: var(--cyan);
    }

    .hero-wrap {
      position: relative;
      overflow: visible;
      min-height: auto;
      z-index: 1;
    }


/* The standalone error page keeps its three links readable without a mobile menu. */
@media (max-width: 600px) {
  .error-page nav { padding: 16px; gap: 12px; }
  .error-page .nav-links { gap: 12px; }
  .error-page .nav-links a { font-size: .64rem; letter-spacing: .04em; }
}

/* Scrollable navigation also works on short phones and in landscape. */
@media (max-width: 800px) {
  .mob {
    height: 100dvh;
    justify-content: flex-start;
    gap: 4px;
    padding: 104px 20px max(24px, env(safe-area-inset-bottom));
    overflow-y: auto;
    overscroll-behavior: contain;
  }
  .mob a {
    display: flex;
    align-items: center;
    justify-content: center;
    width: min(100%, 360px);
    min-height: 44px;
    flex: 0 0 auto;
    padding: 8px 12px;
    font-size: 1.2rem !important;
    line-height: 1.3;
    text-align: center;
  }
  body:has(.mob.open) .portfolio-chatbot-icon { visibility: hidden; }
}

@media (max-width: 640px) {
  .error-page .error-container { padding: 96px 16px 32px; }
  .error-page .error-card { padding: 24px 20px; }
  .error-page .error-desc { margin-bottom: 20px; font-size: .94rem; }
  .error-page .diagnostic-panel { margin-bottom: 20px; padding: 12px; overflow-wrap: anywhere; }
  .error-page .actions-row { gap: 10px; }
  .error-page .actions-row a { min-height: 44px; }
  .error-page nav { gap: 8px; }
  .error-page .nav-links { gap: 8px; }
  .error-page .nav-logo { display: inline-flex; align-items: center; min-height: 44px; }
  .error-page #themeToggle { min-height: 44px; padding: 8px 10px; }
  .error-page .nav-links a { display: flex; align-items: center; min-height: 44px; font-size: .68rem; }
}
