.app-shell {
  min-height: 100vh;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  align-items: center;
  gap: 24px;
  padding: 16px 28px;
  background: rgba(255, 255, 255, 0.92);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  min-width: 0;
  flex-direction: column;
  justify-self: start;
  gap: 2px;
  text-decoration: none;
}

.brand strong {
  font-size: 18px;
  letter-spacing: -0.02em;
}

.brand span {
  color: var(--muted);
  font-size: 12px;
}

.nav {
  display: flex;
  min-width: 0;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.nav a,
.auth-actions a,
.auth-actions button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 8px 12px;
  background: transparent;
  color: var(--muted);
  text-decoration: none;
  cursor: pointer;
}

.nav a.active,
.profile-line-button.active,
.nav a:hover,
.auth-actions a:hover,
.auth-actions > button:not(.header-search-button):hover,
.profile-line-button:hover {
  border-color: var(--border);
  background: var(--surface-muted);
  color: var(--text);
}

.auth-actions,
.profile-actions {
  display: flex;
  min-width: 0;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.auth-actions {
  width: 100%;
  max-width: 360px;
  justify-self: end;
}

.auth-actions--guest {
  width: auto;
  max-width: none;
}

.auth-actions--guest .profile-actions {
  flex: 0 0 auto;
}

.auth-actions--guest .header-search-button {
  animation: guest-search-align 500ms ease-out both;
}

@keyframes guest-search-align {
  from { transform: translateX(-18px); }
  to { transform: translateX(0); }
}

.profile-actions {
  flex: 1 1 auto;
}

.auth-actions #logout-button:hover {
  border-color: rgba(180, 35, 24, 0.3);
  background: #fff1f0;
  color: var(--danger);
}

.auth-actions #logout-button:focus-visible {
  border-color: var(--danger);
  outline: 3px solid rgba(180, 35, 24, 0.16);
  outline-offset: 2px;
}

.profile-actions-loading {
  pointer-events: none;
  filter: blur(6px);
}

.auth-loading-profile,
.auth-loading-logout {
  display: block;
  height: 34px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface-muted);
}

.auth-loading-profile {
  width: min(100%, 220px);
  flex: 1 1 auto;
}

.auth-loading-logout {
  width: 56px;
  flex: 0 0 56px;
}

.auth-actions .header-search-button {
  display: inline-grid;
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  place-items: center;
  border-color: rgba(37, 99, 235, 0.3);
  color: var(--accent);
  padding: 0;
}

.auth-actions .header-search-button:hover {
  border-color: rgba(37, 99, 235, 0.4);
  background: #eff6ff;
  color: var(--accent-dark);
}

.header-search-button svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.header-search-button:focus-visible,
.profile-line-button:focus-visible {
  border-color: var(--accent);
  outline: 3px solid rgba(37, 99, 235, 0.16);
  outline-offset: 2px;
}

.profile-line-button {
  min-width: 0;
  flex: 1 1 auto;
  flex-wrap: nowrap;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 6px 10px;
  background: transparent;
  color: var(--muted);
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.profile-name {
  min-width: 0;
  max-width: 172px;
  flex: 1 1 auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1040px) {
  .profile-name {
    max-width: 116px;
  }
}

.main {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 44px 0 64px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(280px, 0.75fr);
  gap: 24px;
  align-items: stretch;
}

.page-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 18px;
  margin-top: 24px;
}

@media (prefers-reduced-motion: reduce) {
  .auth-actions--guest .header-search-button {
    animation: none;
  }
}

@media (max-width: 860px) {
  .topbar {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
  }

  .nav {
    width: 100%;
    justify-content: center;
  }

  .auth-actions {
    max-width: none;
  }

  .hero {
    grid-template-columns: 1fr;
  }
}

