nav {
  background-color: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  height: var(--nav-height);
  min-height: var(--nav-height);
  max-height: var(--nav-height);
  padding: 0 2rem;
  box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 1000;
  border-bottom: 1px solid rgba(226, 232, 240, 0.8);
}

@media (max-width: 640px) {
  nav {
    padding: 0 0.75rem;
    height: 60px;
    min-height: 60px;
  }
}

@media (max-width: 400px) {
  .logo {
    font-size: 1.1rem;
  }
  .nav-logo {
    height: 28px;
    width: 28px;
    margin-right: 8px;
  }
}

.nav-left, .nav-center, .nav-right {
  display: flex;
  align-items: center;
  min-width: 0;
}

.nav-left { flex: 1; }
.nav-center { flex: 0 1 auto; justify-content: center; gap: 0.5rem; }
.nav-right { flex: 1; justify-content: flex-end; gap: 0.5rem; }

.logo-link {
  text-decoration: none;
  display: flex;
  align-items: center;
}

.logo {
  font-size: 1.4rem;
  font-weight: 800;
  color: transparent;
  background: linear-gradient(135deg, var(--primary-color), #8b5cf6);
  -webkit-background-clip: text;
  background-clip: text;
  letter-spacing: -0.03em;
}

.nav-logo {
  height: 32px;
  width: 32px;
  margin-right: 12px;
  border-radius: 8px;
  flex-shrink: 0;
}

@media (max-width: 600px) {
  .logo {
    display: none;
  }
  .nav-logo {
    margin-right: 0;
  }
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  height: 100%;
}

.nav-links a,
.nav-links button {
  text-decoration: none;
  color: var(--text-muted);
  font-weight: 600;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  font-size: 0.9rem;
  padding: 0.6rem 1.1rem;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 640px) {
  .nav-links a,
  .nav-links button {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
    border-radius: 8px;
  }
}

@media (max-width: 380px) {
  .nav-links a,
  .nav-links button {
    padding: 0.4rem 0.4rem;
    font-size: 0.75rem;
  }
}

.nav-links button {
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
}

.nav-links a:hover,
.nav-links button:hover {
  color: var(--primary-color);
  background-color: rgba(59, 130, 246, 0.06);
}

.nav-links a.active,
.nav-links button.active {
  color: var(--primary-color);
  background-color: rgba(59, 130, 246, 0.1);
}

#logout-link:hover {
  color: #ef4444;
  background-color: rgba(239, 68, 68, 0.06);
}

/* User Menu */
.user-menu {
  position: relative;
  display: flex;
  align-items: center;
}

#user-menu-btn {
  border: none;
  background: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
}

#user-avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  min-height: 36px;
  border-radius: 50%;
  background: rgba(59, 130, 246, 0.08); /* Only visible for initials */
  color: var(--primary-color);
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-sizing: border-box;
  /* Use a box-shadow ring instead of a border to avoid sub-pixel bleed */
  box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.05);
  transition: all 0.2s;
}

#user-avatar img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

#user-menu-btn:hover #user-avatar {
  box-shadow: inset 0 0 0 1px var(--primary-color), 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.user-menu-dropdown {
  position: absolute;
  right: 0;
  top: calc(100% + 10px);
  background: var(--surface-white);
  border: 1px solid rgba(226, 232, 240, 0.9);
  box-shadow: var(--shadow-md);
  border-radius: 12px;
  padding: 12px;
  min-width: 220px;
  display: none;
  flex-direction: column;
  gap: 6px;
  z-index: 1200;
}

.user-menu-dropdown.show { display: flex; }
.user-menu-name { font-weight: 700; color: var(--text-main); }
.user-menu-email { font-size: 0.85rem; color: var(--text-muted); }

.user-menu-dropdown button {
  margin-top: 8px;
  width: 100%;
  border: none;
  background: #fee2e2;
  color: #b91c1c;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
}
.user-menu-dropdown button:hover { background: #fecaca; }

/* Footer */
.app-footer {
  margin-top: auto;
  padding: 2.5rem 1.5rem;
  background: white;
  border-top: 1px solid #e2e8f0;
  text-align: center;
  padding-bottom: calc(2.5rem + env(safe-area-inset-bottom));
}

.footer-content {
  max-width: 1000px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  align-items: center;
}

.footer-links {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.footer-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  transition: color 0.2s;
}

.footer-links a:hover { color: var(--primary-color); }
.footer-copyright { color: var(--text-muted); font-size: 0.8rem; font-weight: 400; }

@media (max-width: 640px) {
  .app-footer {
    padding: 2rem 1rem;
    padding-bottom: calc(2rem + env(safe-area-inset-bottom));
  }
  .footer-links { gap: 1rem; }
}
