:root {
  --header-paper: #f4f4f8;
  --header-blue: #2387ff;
  --header-red: #e53f64;
  --header-acid: #7557ff;
}

.site-header,
.profile-header {
  position: relative;
  z-index: 300;
  width: 100%;
  height: 84px;
  padding: 0 max(36px, calc((100vw - 1248px) / 2));
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  border-bottom: 1px solid #ffffff17;
  background: #090a18f2;
  backdrop-filter: blur(18px);
}

.site-header .logo,
.profile-header .brand {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--header-paper);
  text-decoration: none;
  font: 800 18px Arial, sans-serif;
  letter-spacing: -.8px;
}

.site-header .logo-mark,
.profile-header .brand b {
  width: 31px;
  height: 31px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--header-blue), var(--header-red));
  color: #fff;
  font: 700 10px monospace;
  letter-spacing: -1px;
}

.site-header .main-nav,
.profile-header .profile-main-nav {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 0;
}

.site-header .main-nav a,
.profile-header .profile-main-nav a {
  position: relative;
  display: block;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: #d9dbea;
  text-decoration: none;
  font: 700 13px Arial, sans-serif;
  transition: color .2s, border-color .2s, background .2s, transform .2s;
}

.site-header .main-nav a:hover,
.site-header .main-nav a:focus-visible,
.profile-header .profile-main-nav a:hover,
.profile-header .profile-main-nav a:focus-visible {
  color: #fff;
  border-color: #ffffff2e;
  background: #ffffff0a;
  outline: 0;
  transform: translateY(-1px);
}

.site-header .main-nav .nav-active,
.profile-header .profile-main-nav [aria-current="page"] {
  color: #9ec9ff;
  border-color: transparent;
  background: transparent;
  text-shadow: 0 0 16px #7557ff70;
}

.site-header .main-nav .nav-active::after,
.profile-header .profile-main-nav [aria-current="page"]::after,
.profile-header .profile-user::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 5px;
  height: 1px;
  background: linear-gradient(90deg, var(--header-blue), var(--header-red));
}

.header-actions,
.profile-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 16px;
}

.language-toggle,
.profile-actions .lang {
  min-width: 28px;
  min-height: 28px;
  display: grid;
  place-items: center;
  padding: 5px 7px;
  border: 1px solid #ffffff59;
  border-radius: 0;
  background: transparent;
  color: var(--header-paper);
  text-decoration: none;
  font: 500 10px monospace;
  cursor: pointer;
}

.socials-label,
.profile-actions .socials-label {
  color: #ffffff99;
  font: 600 10px monospace;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.instagram-cta,
.social-cta,
.profile-actions .instagram-cta,
.profile-actions .social-cta {
  width: 32px;
  height: 32px;
  display: grid;
  flex: none;
  place-items: center;
  padding: 0;
  border: 1px solid #ffffff45;
  border-radius: 50%;
  background: transparent;
  color: var(--header-paper);
  text-decoration: none;
  transition: transform .25s, border-color .25s, background .25s;
}

.instagram-cta:hover,
.instagram-cta:focus-visible,
.social-cta:hover,
.social-cta:focus-visible {
  transform: translateY(-2px);
  border-color: #e53f64aa;
  background: linear-gradient(135deg, #2387ff24, #e53f6430);
  outline: 0;
}

.instagram-glyph {
  width: 15px;
  height: 15px;
  position: relative;
  display: block;
  border: 1.5px solid currentColor;
  border-radius: 4px;
}

.instagram-glyph::before {
  content: "";
  position: absolute;
  width: 5px;
  height: 5px;
  left: 3.5px;
  top: 3.5px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}

.instagram-glyph::after {
  content: "";
  position: absolute;
  width: 2px;
  height: 2px;
  right: 2px;
  top: 2px;
  border-radius: 50%;
  background: currentColor;
}

.instagram-glyph i { display: none; }
.facebook-glyph { font: 700 21px/1 Arial, sans-serif; transform: translateY(2px); }

.account-cta,
.profile-user {
  position: relative;
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid #7557ff80;
  border-radius: 999px;
  background: linear-gradient(135deg, #2387ff1f, #7557ff24);
  color: var(--header-paper);
  text-decoration: none;
  font: 700 11px Arial, sans-serif;
  cursor: pointer;
}

.account-icon {
  position: relative;
  width: 15px;
  height: 15px;
  border: 1.5px solid currentColor;
  border-radius: 50%;
}
.account-icon::before {
  content: ""; position: absolute; width: 4px; height: 4px; left: 3.8px; top: 2px; border: 1.3px solid currentColor; border-radius: 50%;
}
.account-icon::after {
  content: ""; position: absolute; width: 8px; height: 4px; left: 2px; bottom: 1.5px; border: 1.3px solid currentColor; border-bottom: 0; border-radius: 7px 7px 0 0;
}

.profile-user {
  border-color: transparent;
  background: transparent;
  color: #9ec9ff;
  text-shadow: 0 0 16px #7557ff70;
}

.profile-user::after { bottom: 3px; }
.profile-user > span:first-child {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #57d69b;
  box-shadow: 0 0 0 4px #57d69b1d;
}

.profile-actions form { margin: 0; }
.profile-actions .logout-button {
  min-height: 34px;
  padding: 8px 13px;
  border: 1px solid #ffffff2b;
  border-radius: 999px;
  background: #ffffff08;
  color: #a7abc0;
  font: 700 11px Arial, sans-serif;
  cursor: pointer;
}
.profile-actions .logout-button:hover,
.profile-actions .logout-button:focus-visible {
  color: #fff;
  border-color: #7557ff75;
  background: #7557ff1a;
  outline: 0;
}

.menu-toggle,
.profile-header .profile-menu-toggle {
  width: 38px;
  height: 38px;
  display: none;
  place-content: center;
  gap: 4px;
  padding: 0;
  border: 1px solid #ffffff38;
  border-radius: 50%;
  background: #ffffff08;
  color: #fff;
  appearance: none;
  cursor: pointer;
}

.menu-toggle span,
.profile-menu-toggle i {
  display: block;
  width: 15px;
  height: 1px;
  background: currentColor;
  transition: transform .2s, opacity .2s;
}

.menu-toggle.is-open span:nth-child(1),
.profile-menu-toggle.is-open i:nth-child(1) { transform: translateY(5px) rotate(45deg); }
.menu-toggle.is-open span:nth-child(2),
.profile-menu-toggle.is-open i:nth-child(2) { opacity: 0; }
.menu-toggle.is-open span:nth-child(3),
.profile-menu-toggle.is-open i:nth-child(3) { transform: translateY(-5px) rotate(-45deg); }

.menu-backdrop,
.menu-backdrop[hidden] { display: none; }

.account-popover {
  position: fixed;
  z-index: 500;
  top: 84px;
  right: max(14px, calc((100vw - 1248px) / 2));
  width: min(390px, calc(100vw - 28px));
  animation: shared-account-in .2s ease-out both;
}

.account-popover[hidden],
.account-authenticated[hidden],
.account-login-form[hidden] { display: none !important; }

.account-popover::before {
  content: "";
  position: absolute;
  z-index: 2;
  top: -7px;
  right: 19px;
  width: 13px;
  height: 13px;
  border-top: 1px solid #ffffff2e;
  border-left: 1px solid #ffffff2e;
  background: #171926;
  transform: rotate(45deg);
}

.account-dialog {
  position: relative;
  width: 100%;
  padding: 30px;
  border: 1px solid #ffffff2e;
  background: linear-gradient(145deg, #171926f7, #0a0c13fa), url("database-ecu-tuner.png") center / cover;
  color: var(--header-paper);
  box-shadow: 0 24px 70px #0000009e, 0 0 42px #7557ff1a;
}

.account-dialog .eyebrow {
  margin: 0 0 22px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: #aeb2aa;
  font: 500 11px monospace;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.account-dialog .eyebrow > span:first-child {
  width: 8px;
  height: 8px;
  display: inline-block;
  border-radius: 50%;
  background: var(--header-blue);
  box-shadow: 0 0 0 4px #2387ff2e;
}

.account-dialog h2 {
  margin: 8px 0 24px;
  font-size: clamp(30px, 5vw, 42px);
  letter-spacing: -.045em;
}

.account-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 38px;
  height: 38px;
  border: 1px solid #ffffff2e;
  border-radius: 50%;
  background: #ffffff0d;
  color: #fff;
  font-size: 23px;
  cursor: pointer;
}

.account-authenticated { display: grid; gap: 16px; }
.account-login-form { display: grid; gap: 18px; }
.account-login-form label { display: grid; gap: 8px; color: #c7cada; font-size: 12px; font-weight: 700; }
.account-login-form input {
  width: 100%; padding: 14px 15px; border: 1px solid #ffffff2e; background: #05070ca6; color: #fff; outline: 0;
}
.account-login-form input:focus { border-color: var(--header-acid); box-shadow: 0 0 0 3px #7557ff24; }
.account-message { min-height: 18px; margin: 0; color: #aeb6d4; font-size: 11px; }
.account-signed-in {
  margin: 0;
  color: #9da3ba;
  font: 600 10px monospace;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.account-profile-link {
  padding: 16px 0;
  border-top: 1px solid #ffffff24;
  border-bottom: 1px solid #ffffff24;
  color: #fff;
  text-decoration: none;
  font-size: 18px;
  font-weight: 800;
}
.account-profile-link::after { content: " →"; color: #9ec9ff; }
.account-logout-form { margin: 0; }
.account-dialog .button-primary {
  width: 100%;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: linear-gradient(100deg, #3449c7, #b73e78);
  color: #fff;
  font: 700 13px Arial, sans-serif;
  cursor: pointer;
}

@keyframes shared-account-in {
  from { opacity: 0; transform: translateY(-7px) scale(.985); }
}

@media (max-width: 1080px) {
  .site-header,
  .profile-header { padding-inline: 18px; gap: 10px; }
  .site-header .main-nav a,
  .profile-header .profile-main-nav a { padding-inline: 8px; }
  .socials-label,
  .account-label { display: none; }
  .account-cta { padding: 8px; }
  .profile-user { font-size: 0; padding: 10px; }
}

@media (max-width: 960px) {
  .site-header,
  .profile-header {
    height: 70px;
    gap: 8px;
    padding-inline: 14px;
  }
  .site-header .logo,
  .profile-header .brand { order: 1; }
  .profile-header .brand span { display: inline; }
  .header-actions,
  .profile-actions { order: 2; margin-left: auto; gap: 7px; }
  .menu-toggle,
  .profile-header .profile-menu-toggle { order: 3; display: grid; flex: none; }
  .site-header .main-nav,
  .profile-header .profile-main-nav {
    position: absolute;
    z-index: 302;
    top: calc(100% + 8px);
    left: 12px;
    right: 12px;
    transform: none;
    display: none;
    margin: 0;
    padding: 10px;
    gap: 4px;
    border: 1px solid #ffffff26;
    background: #0d0f1bf7;
    box-shadow: 0 28px 70px #00000085;
    backdrop-filter: blur(14px);
  }
  .site-header .main-nav.menu-open,
  .profile-header .profile-main-nav.open { display: grid; }
  .site-header .main-nav a,
  .profile-header .profile-main-nav a {
    display: block !important;
    padding: 14px 15px;
    border-radius: 3px;
  }
  .site-header .main-nav .nav-active::after,
  .profile-header .profile-main-nav [aria-current="page"]::after {
    left: 15px;
    right: auto;
    width: 44px;
    bottom: 8px;
  }
  .menu-backdrop:not([hidden]) {
    position: fixed;
    inset: 70px 0 0;
    z-index: 299;
    display: block;
    border: 0;
    background: #03040a75;
    backdrop-filter: blur(3px);
  }
  .profile-actions .logout-button {
    width: 32px;
    height: 32px;
    min-height: 0;
    padding: 0;
    display: grid;
    place-items: center;
    font-size: 0;
  }
  .profile-actions .logout-button::before { content: "↪"; font-size: 15px; }
  .account-popover { top: 66px; left: 12px; right: 12px; width: auto; }
}

@media (max-width: 430px) {
  .site-header .logo-name,
  .profile-header .brand span { display: none; }
  .language-toggle,
  .profile-actions .lang { padding: 5px 6px; }
  .instagram-cta,
  .social-cta,
  .profile-actions .instagram-cta,
  .profile-actions .social-cta { width: 30px; height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .site-header *,
  .profile-header * { transition: none !important; }
}
