.site-header {
  border-bottom: 1px solid var(--line);
}

.header-content {
  display: grid;
  grid-template-columns: auto auto minmax(180px, 1fr) auto;
  align-items: center;
  gap: 22px;
  width: min(1440px, calc(100% - 64px));
  min-height: 88px;
  padding-block: 16px;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 20px;
  font-size: 0.82rem;
  white-space: nowrap;
}

.header-nav a {
  text-decoration: none;
}

.header-nav a:hover {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

.search-widget {
  position: relative;
  min-width: 0;
}

.header-search {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  height: 44px;
  padding-left: 15px;
  border: 1px solid var(--accent);
  border-radius: 24px;
  background: var(--paper);
  overflow: hidden;
}

.header-search-icon {
  flex: 0 0 15px;
  width: 15px;
  height: 15px;
  color: var(--muted);
}

.header-search input {
  flex: 1;
  min-width: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  opacity: 1;
}

.header-search input::placeholder {
  color: var(--muted);
  opacity: 1;
}

.header-search button {
  display: grid;
  place-items: center;
  flex: 0 0 48px;
  align-self: stretch;
  padding: 0;
  border: 0;
  background: var(--ink);
  color: var(--paper);
  cursor: pointer;
}

.header-search:has(input:focus-visible) {
  border-color: var(--ink);
}

.header-search input:focus-visible {
  outline: none;
}

.header-search button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -3px;
}

.header-search button svg {
  width: 17px;
  height: 17px;
}

.search-suggestions {
  position: absolute;
  z-index: 5;
  inset: calc(100% + 5px) 0 auto;
  max-height: min(420px, 52dvh);
  padding: 12px;
  overflow: auto;
  scrollbar-width: none;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 14px 32px rgb(0 0 0 / 18%);
}

@media (prefers-reduced-motion: no-preference) {
  .search-suggestions:not([hidden]) {
    animation: search-suggestions-enter 180ms ease-out both;
  }

  @keyframes search-suggestions-enter {
    from {
      opacity: 0;
      transform: translateY(-5px);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }
}

.search-suggestion-terms {
  display: grid;
  gap: 2px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.search-suggestion-terms a {
  display: block;
  padding: 5px 9px;
  border-radius: 7px;
  text-decoration: none;
}

.search-suggestion-terms a::before {
  margin-right: 10px;
  color: var(--muted);
  content: '↗' / '';
}

.search-suggestion-heading {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 10px;
  margin-top: 9px;
  padding-block: 9px 4px;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
}

.search-suggestion-heading a {
  font-size: 0.78rem;
  font-weight: 700;
}

.search-suggestion-product {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
  padding: 6px 9px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--soft);
  text-decoration: none;
}

.search-suggestion-product figure {
  margin: 0;
  text-align: center;
}

.search-suggestion-product img {
  display: block;
  width: 100%;
  height: 40px;
  object-fit: contain;
}

.search-suggestion-product figcaption {
  color: var(--muted);
  font-size: 0.57rem;
  line-height: 1.15;
}

.search-suggestion-details {
  display: grid;
  font-size: 0.85rem;
  line-height: 1.3;
  overflow-wrap: anywhere;
}

.search-suggestion-details small {
  color: var(--muted);
}

.search-suggestion-arrow {
  padding: 2px 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.search-suggestion-terms a:hover,
.search-suggestion-product:hover {
  background: color-mix(in srgb, var(--surface) 90%, var(--accent));
}

.search-suggestions a:focus-visible {
  outline-offset: -2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-theme-switch {
  display: flex;
  align-items: center;
  flex: 0 0 50px;
  width: 50px;
  height: 28px;
  margin-right: 8px;
  padding: 3px;
  border: 1px solid var(--ink);
  border-radius: 18px;
  background: var(--ink);
  box-shadow: inset 0 1px 3px rgb(0 0 0 / 10%);
  opacity: 1;
  cursor: pointer;
}

.header-theme-switch span {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: 0 1px 3px rgb(0 0 0 / 18%);
  transition: transform 180ms ease;
}

.header-theme-switch[aria-checked='true'] span {
  transform: translateX(22px);
}
.header-theme-switch:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 4px;
}

.header-sign-in,
.header-sign-up {
  min-height: 40px;
  padding: 9px 17px;
  border: 1px solid var(--ink);
  border-radius: 9px;
  background: var(--account-button-background);
  color: var(--account-button-text);
  font: inherit;
  font-size: 0.79rem;
  font-weight: 600;
  white-space: nowrap;
  opacity: 1;
}

.header-sign-in:enabled,
.header-sign-up:enabled {
  cursor: pointer;
}

.header-sign-in {
  --account-button-background: var(--paper);
  --account-button-text: var(--ink);
}

.header-sign-up {
  --account-button-background: var(--ink);
  --account-button-text: var(--paper);
}

.header-nav a[aria-current='page'] {
  text-decoration: underline;
  text-decoration-color: var(--accent);
}

@media (max-width: 1280px) {
  .header-content {
    grid-template-columns: auto minmax(180px, 1fr) auto;
    gap: 16px 24px;
  }

  .header-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-content: center;
  }
}
@media (max-width: 800px) {
  .header-content {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: clamp(8px, 2.3vh, 18px);
    padding-block: clamp(8px, 2vh, 16px);
    width: calc(100% - 36px);
  }

  .header-content > .brand {
    align-self: center;
  }

  .header-nav {
    flex-wrap: wrap;
    gap: 12px 20px;
  }

  .header-actions {
    justify-content: center;
  }

  .header-content nav {
    gap: 14px;
    font-size: 0.74rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .header-theme-switch span { transition: none; }
}
