.app-nav {
  background: var(--nav-bg);
  border-bottom: 1px solid #1f1f1f;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
}

.app-nav-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  min-height: var(--app-nav-height);
  padding: 0 1rem;
}

.app-nav-brand {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  text-decoration: none;
  padding: 0.25rem 0;
  border-radius: 6px;
}

.app-nav-brand img {
  height: 1.625rem;
  width: auto;
}

.app-nav-brand .app-nav-logo-full {
  display: block;
  max-width: 11.5rem;
}

.app-nav-brand .app-nav-logo-mark {
  display: none;
  height: 1.5rem;
}

.app-nav-brand:focus-visible {
  outline: 3px solid var(--nav-active);
  outline-offset: 2px;
}

.app-nav-links {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.125rem;
  margin-left: auto;
}

.app-nav-has-tooltip {
  position: relative;
}

.app-nav-has-tooltip::after {
  content: attr(data-tooltip);
  position: absolute;
  top: calc(100% + 0.5rem);
  left: 50%;
  transform: translateX(-50%);
  background: #1a1a1a;
  color: #ffffff;
  padding: 0.3rem 0.55rem;
  border-radius: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
  z-index: 60;
  border: 1px solid #333;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}

.app-nav-has-tooltip:hover::after,
.app-nav-has-tooltip:focus-visible::after {
  opacity: 1;
}

.app-nav-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--nav-muted);
  transition: color 0.15s, background 0.15s;
}

.app-nav-link svg {
  width: 1.125rem;
  height: 1.125rem;
  flex-shrink: 0;
}

.app-nav-link .nav-label,
.app-nav-contrast .nav-label {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.app-nav-link:hover,
.app-nav-link:focus-visible {
  color: var(--nav-text);
  background: var(--nav-hover-bg);
}

.app-nav-link:focus-visible {
  outline: 3px solid var(--nav-active);
  outline-offset: 2px;
}

.app-nav-contrast {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.06);
  color: var(--nav-muted);
  cursor: pointer;
  padding: 0;
  font: inherit;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
}

.app-nav-contrast svg {
  width: 1.125rem;
  height: 1.125rem;
}

.app-nav-contrast:hover {
  color: var(--nav-text);
  background: var(--nav-hover-bg);
  border-color: rgba(255, 255, 255, 0.35);
}

.app-nav-contrast:focus-visible {
  outline: 3px solid var(--nav-active);
  outline-offset: 2px;
}

.app-nav-contrast.is-active {
  color: var(--nav-active);
  border-color: var(--nav-active);
  background: rgba(255, 255, 255, 0.12);
}

html[data-contrast="high"] .app-nav-contrast {
  border-color: #ffffff;
}

html[data-contrast="high"] .app-nav-contrast.is-active {
  background: #333333;
}

.app-nav-link[aria-current="page"] {
  color: var(--nav-active);
  background: rgba(94, 179, 255, 0.12);
}

.nav-save-status {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--nav-muted);
  white-space: nowrap;
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  max-width: 11rem;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}

.nav-save-status.saving {
  color: #93c9ff;
  border-color: rgba(94, 179, 255, 0.35);
  background: rgba(94, 179, 255, 0.1);
}

.nav-save-status.saved {
  color: #c8e4ff;
  border-color: rgba(94, 179, 255, 0.3);
  background: rgba(94, 179, 255, 0.08);
}

.nav-save-status.unsaved {
  color: #ffd666;
  border-color: rgba(255, 214, 102, 0.35);
  background: rgba(255, 214, 102, 0.1);
}

.nav-save-status.offline {
  color: #ffb4b4;
  border-color: rgba(255, 180, 180, 0.3);
  background: rgba(255, 100, 100, 0.08);
}

html[data-contrast="high"] .nav-save-status {
  color: #ffffff;
  border-color: #ffffff;
  background: #000000;
}

html[data-contrast="high"] .nav-save-status.saving,
html[data-contrast="high"] .nav-save-status.saved,
html[data-contrast="high"] .nav-save-status.unsaved,
html[data-contrast="high"] .nav-save-status.offline {
  color: #ffff00;
  border-color: #ffff00;
  background: #000000;
}

@media (max-width: 640px) {
  .app-nav-brand .app-nav-logo-full {
    display: none;
  }

  .app-nav-brand .app-nav-logo-mark {
    display: block;
  }
}

@media (max-width: 520px) {
  .nav-save-status {
    max-width: 5.5rem;
    font-size: 0.625rem;
    padding: 0.25rem 0.45rem;
  }
}
