.nav-toggle {
  display: none;
  margin-left: auto;
  width: 48px;
  height: 48px;
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.12));
  border-radius: 16px;
  background: var(--bg-secondary, rgba(255, 255, 255, 0.92));
  color: var(--text-primary, #171717);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
  cursor: pointer;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 5px;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.nav-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.16);
}

.nav-toggle:focus-visible {
  outline: 2px solid var(--primary-red, #c8102e);
  outline-offset: 3px;
}

.nav-toggle-bar {
  width: 20px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

.auth-slot {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-link {
  text-decoration: none;
  padding: 10px 18px;
  border-radius: 999px;
  font-weight: 600;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
  color: var(--text-primary, #171717);
  background: var(--bg-secondary, rgba(255, 255, 255, 0.92));
  border: 1px solid var(--border-color, rgba(0, 0, 0, 0.12));
}

.auth-link:hover {
  background: var(--primary-red, #c8102e);
  color: var(--text-on-primary, #ffffff);
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(200, 16, 46, 0.18);
}

.profile-toggle {
  border: 1px solid rgba(200, 16, 46, 0.14);
  position: relative;
  background:
    radial-gradient(circle at 30% 28%, rgba(200, 16, 46, 0.18), transparent 42%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(245, 240, 241, 0.92));
  border-radius: 999px;
  padding: 5px;
  display: inline-flex;
  align-items: center;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.9),
    0 10px 22px var(--shadow-color-heavy, rgba(0, 0, 0, 0.12));
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

[data-theme="dark"] .profile-toggle {
  background:
    radial-gradient(circle at 30% 28%, rgba(229, 57, 53, 0.2), transparent 42%),
    linear-gradient(145deg, rgba(42, 42, 42, 0.96), rgba(27, 27, 27, 0.96));
  border-color: rgba(255, 255, 255, 0.08);
}

.profile-toggle:hover {
  transform: translateY(-2px);
  border-color: rgba(200, 16, 46, 0.26);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.95),
    0 14px 28px var(--shadow-color-heavy, rgba(0, 0, 0, 0.16));
}

.profile-avatar,
.profile-fallback {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.16),
    0 6px 14px rgba(17, 24, 39, 0.18);
}

.profile-avatar {
  object-fit: cover;
  background: var(--bg-secondary, #ffffff);
}

.profile-fallback {
  background: var(--button-bg, rgba(0, 0, 0, 0.05));
  color: var(--primary-red, #c8102e);
}

.profile-fallback svg {
  width: 18px;
  height: 18px;
}

.profile-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 12px);
  width: 220px;
  background: var(--bg-secondary, #ffffff);
  border-radius: 16px;
  box-shadow: 0 16px 40px var(--shadow-color-heavy, rgba(0, 0, 0, 0.16));
  padding: 12px;
  display: none;
  z-index: 1002;
}

.profile-menu.open {
  display: block;
}

.profile-menu-name {
  font-weight: 700;
  margin-bottom: 4px;
  color: var(--text-primary, #171717);
}

.profile-menu-email {
  font-size: 13px;
  color: var(--text-secondary, #666666);
  margin-bottom: 12px;
  word-break: break-word;
}

.profile-menu button,
.profile-menu-link {
  width: 100%;
  border: none;
  background: var(--button-bg, rgba(0, 0, 0, 0.05));
  color: var(--text-primary, #171717);
  padding: 10px 14px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  margin-top: 8px;
  font-size: 14px;
  font-family: inherit;
  text-decoration: none;
  text-align: left;
  line-height: 1;
}

.profile-menu button:hover,
.profile-menu-link:hover {
  background: var(--button-hover-bg, rgba(200, 16, 46, 0.08));
  color: var(--button-hover-text, var(--text-primary, #171717));
}

@media (max-width: 640px) {
  nav[data-nav-ready="true"] {
    align-items: center;
  }

  nav[data-nav-ready="true"] .logo-area {
    width: auto;
    flex: 1 1 auto;
    min-width: 0;
  }

  nav[data-nav-ready="true"] .church-name {
    min-width: 0;
  }

  nav[data-nav-ready="true"] .nav-toggle {
    display: inline-flex;
    flex-shrink: 0;
  }

  nav[data-nav-ready="true"] .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(1) {
    transform: translateY(7px) rotate(45deg);
  }

  nav[data-nav-ready="true"] .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(2) {
    opacity: 0;
  }

  nav[data-nav-ready="true"] .nav-toggle[aria-expanded="true"] .nav-toggle-bar:nth-child(3) {
    transform: translateY(-7px) rotate(-45deg);
  }

  nav[data-nav-ready="true"] .nav-links {
    display: none;
    width: 100%;
    margin-left: 0;
    padding: 12px;
    border-radius: 20px;
    border: 1px solid var(--border-color, rgba(0, 0, 0, 0.08));
    background: var(--bg-secondary, rgba(255, 255, 255, 0.96));
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.12);
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    overflow: visible;
  }

  nav[data-nav-ready="true"] .nav-links.open {
    display: flex;
  }

  nav[data-nav-ready="true"] .nav-links a {
    width: 100%;
    padding: 14px 16px;
    white-space: normal;
  }

  nav[data-nav-ready="true"] .auth-slot {
    width: 100%;
    justify-content: flex-start;
  }

  nav[data-nav-ready="true"] .auth-link {
    width: 100%;
    justify-content: center;
  }

  nav[data-nav-ready="true"] .profile-toggle {
    align-self: flex-start;
  }

  nav[data-nav-ready="true"] .profile-menu {
    position: fixed;
  }
}

@media (min-width: 641px) {
  nav[data-nav-ready="true"] .nav-links {
    display: flex !important;
  }
}
