.topbar {
  position: relative;
  z-index: 10;
  width: 100%;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  box-sizing: border-box;
  border-bottom: 1px solid var(--border);
  background: color-mix(in srgb, var(--surface) 82%, transparent);
  backdrop-filter: blur(16px);
  flex-shrink: 0;
}

.topbar-logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 18px;
  font-weight: 700;
  color: var(--text);
  text-decoration: none;
}

.topbar-logo-icon {
  width: 30px;
  height: 30px;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.topbar-logo span {
  color: var(--text);
}

.topbar-logo:hover,
.topbar-logo:visited,
.topbar-logo:active {
  color: var(--text);
  text-decoration: none;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: nowrap;
  justify-content: flex-end;
  min-width: 0;
}

.topbar .language-dropdown.topbar-language {
  position: static;
  top: auto;
  right: auto;
  z-index: auto;
  display: inline-block;
  background: transparent;
  border: none;
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
  border-radius: 0;
}

.topbar .topbar-language .language-trigger {
  width: auto;
  min-width: 118px;
  box-shadow: var(--shadow-sm);
}

.topbar .topbar-language .language-menu {
  top: calc(100% + 0.5rem);
  right: 0;
}

.topbar-link {
  padding: 4px 0;
  background: transparent;
  border: none;
  border-radius: 0;
  color: var(--text-muted);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  transition: color 0.2s, opacity 0.2s;
  white-space: nowrap;
}

.topbar-link:hover {
  color: var(--text);
}

.topbar-link-primary {
  color: var(--accent);
}

.topbar-link-primary:hover {
  color: var(--accent2);
  opacity: 1;
}

@media (min-width: 1440px) {
  .topbar {
    width: min(1600px, calc(100vw - 32px));
    margin-inline: auto;
    margin-top: 16px;
    padding-inline: 24px;
    border: 1px solid color-mix(in srgb, var(--border) 88%, transparent);
    border-radius: 20px;
  }

  .theme-toggle-fab {
    right: calc(max(16px, (100vw - 1600px) / 2) + 24px);
  }
}

@media (min-width: 1680px) {
  .topbar {
    width: min(1720px, calc(100vw - 40px));
    padding-inline: 28px;
  }

  .theme-toggle-fab {
    right: calc(max(20px, (100vw - 1720px) / 2) + 28px);
  }
}

@media (max-width: 640px) {
  .topbar {
    padding: 10px 12px;
    height: auto;
    min-height: 56px;
    align-items: flex-start;
  }

  .topbar-right {
    gap: 8px;
    max-width: 58%;
    align-items: center;
  }

  .topbar-link {
    padding: 4px 0;
    font-size: 12px;
  }

  .topbar .topbar-language .language-trigger {
    min-width: 104px;
    font-size: 0.75rem;
  }
}

@media (max-width: 900px) {
  body.auth-shell .topbar-right {
    gap: 8px;
  }

  body.auth-shell .topbar-link {
    display: none;
  }
}
