.navbar {
  position: fixed;
  inset-inline: 0;
  top: 0;
  z-index: 1000;
  height: var(--nav-height);
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid transparent;
  transition: background-color var(--dur-base) ease, box-shadow var(--dur-base) ease, border-color var(--dur-base) ease;
}
.navbar.scrolled {
  background: var(--glass-bg-scrolled);
  border-bottom-color: var(--border);
  box-shadow: var(--shadow-md);
}

.navbar__inner {
  height: var(--nav-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-weight: 800;
  font-size: 19px;
  color: var(--text);
  white-space: nowrap;
  min-width: 0;
  overflow: hidden;
  flex-shrink: 1;
}
.brand__icon {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary-gradient);
  display: grid;
  place-items: center;
  color: #fff;
  flex-shrink: 0;
  box-shadow: var(--shadow-md);
}
.brand__icon svg { width: 24px; height: 24px; }
.brand__text {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.brand small {
  display: block;
  font-size: 11.5px;
  font-weight: 500;
  color: var(--muted);
  line-height: 1.5;
}

.nav-links { display: flex; align-items: center; gap: var(--space-2); }
.nav-links a {
  position: relative;
  padding: var(--space-2) var(--space-4);
  font-weight: 600;
  font-size: 15px;
  color: var(--body);
  border-radius: var(--radius-full);
  transition: color var(--dur-fast) ease, background var(--dur-fast) ease;
}
.nav-links a:hover { color: var(--primary-500); background: var(--primary-50); }
.nav-links a.active { color: var(--primary-500); background: var(--primary-50); }
.nav-links a.active::after {
  content: "";
  position: absolute;
  bottom: 4px;
  right: 50%;
  transform: translateX(50%);
  width: 18px;
  height: 3px;
  border-radius: 99px;
  background: var(--accent-500);
}

.navbar__actions { display: flex; align-items: center; gap: var(--space-3); flex-shrink: 0; margin-inline-start: auto; }

.nav-toggle {
  display: none;
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  place-items: center;
  flex-direction: column;
  gap: 5px;
}
.nav-toggle span {
  display: block;
  width: 20px;
  height: 2.5px;
  border-radius: 99px;
  background: var(--text);
  transition: transform var(--dur-base) var(--ease-out), opacity var(--dur-fast) ease;
}
.nav-toggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(7.5px) rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-7.5px) rotate(-45deg); }

@media (max-width: 900px) {
  .navbar__inner { gap: 12px; }
  .brand { font-size: 17px; gap: 10px; }
  .brand__icon { width: 38px; height: 38px; border-radius: 11px; }
  .brand__icon svg { width: 21px; height: 21px; }
  .brand small { font-size: 11px; }
  .navbar__actions { gap: 10px; }
  .nav-links {
    position: fixed;
    top: calc(var(--nav-height) + 8px);
    inset-inline: 16px;
    flex-direction: column;
    align-items: stretch;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    padding: var(--space-4);
    padding-bottom: calc(var(--space-4) + env(safe-area-inset-bottom, 0px));
    padding-inline-start: calc(var(--space-4) + env(safe-area-inset-right, 0px));
    padding-inline-end: calc(var(--space-4) + env(safe-area-inset-left, 0px));
    gap: var(--space-1);
    opacity: 0;
    transform: translateY(-12px);
    pointer-events: none;
    transition: opacity var(--dur-base) var(--ease-out), transform var(--dur-base) var(--ease-out);
    max-height: calc(100dvh - var(--nav-height) - 24px);
    max-height: calc(100vh - var(--nav-height) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
  .nav-links.open { opacity: 1; transform: none; pointer-events: auto; }
  .nav-links a { padding: var(--space-3) var(--space-4); font-size: 16px; }
  .nav-links__cta {
    display: flex;
    width: 100%;
    margin-top: var(--space-3);
    padding-top: var(--space-3);
    border-top: 1px solid var(--border-soft);
  }
  .nav-links__cta .btn { width: 100%; }
  .nav-toggle { display: grid; flex-shrink: 0; }
  .theme-toggle { flex-shrink: 0; }
  .navbar__cta { display: none; }
}

.nav-links__cta { display: none; }

@media (max-width: 767px) {
  .navbar__inner { overflow: hidden; }
  .brand { flex-shrink: 1; min-width: 0; }
  .brand__text {
    font-size: 13px;
    max-width: 32vw;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  .brand small { display: none; }
}

@media (max-width: 480px) {
  .navbar__inner { gap: 8px; overflow: hidden; }
  .brand { font-size: 15.5px; gap: 8px; }
  .brand__text { display: none; }
  .brand__icon { width: 34px; height: 34px; border-radius: 10px; }
  .brand__icon svg { width: 19px; height: 19px; }
  .navbar__actions { gap: 8px; }
  .theme-toggle { width: 42px; height: 42px; border-radius: 12px; }
  .nav-toggle { width: 42px; height: 42px; border-radius: 12px; }
  .nav-links { inset-inline: 12px; }
}

@media (max-width: 360px) {
  .brand { font-size: 14.5px; }
  .brand__icon { width: 32px; height: 32px; }
  .brand__icon svg { width: 18px; height: 18px; }
  .theme-toggle, .nav-toggle { width: 40px; height: 40px; }
}

@media (prefers-reduced-motion: reduce) {
  .nav-links { transition: none; }
}
