.site-header {
  position: sticky;
  top: 0;
  z-index: 5;
  min-height: 4.45rem;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2rem;
  padding: 0 var(--gutter);
  background: var(--page);
  border-inline: 1px solid var(--hairline-soft);
  border-bottom: 1px solid var(--hairline);
}

.site-brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  color: var(--ink);
  font: 600 0.7rem/1 var(--font-mono);
  letter-spacing: 0.26em;
  text-decoration: none;
}

.site-brand img {
  width: 1rem;
  height: 1rem;
  flex: none;
}

.header-tools {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  justify-self: end;
}

.language-switch {
  display: flex;
  gap: 0.45rem;
  color: var(--text-muted);
  font: 600 0.62rem/1 var(--font-mono);
  letter-spacing: 0.1em;
}

.language-switch a {
  padding: 0.48rem 0.05rem 0.42rem;
  text-decoration: none;
}

.language-switch a[aria-current="page"] {
  color: var(--teal);
  border-bottom: 1px solid var(--teal);
}

.theme-switch {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  margin: 0;
  padding: 0;
  border: 0;
  color: var(--text-muted);
  font: 500 0.62rem/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.theme-switch legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.theme-switch label {
  display: inline-flex;
  min-height: 1.9rem;
  align-items: center;
  padding: 0 0.65rem;
  border: 1px solid var(--hairline);
  cursor: pointer;
  transition:
    background 160ms ease,
    color 160ms ease,
    border-color 160ms ease;
}

.theme-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.theme-switch input:checked + label {
  border-color: var(--teal);
  background: var(--teal);
  color: var(--page);
}

.theme-switch label:focus-within,
.language-switch a:focus-visible {
  outline: 2px solid var(--coral);
  outline-offset: 2px;
}

@media (max-width: 680px) {
  .site-header {
    min-height: 4rem;
    grid-template-columns: 1fr auto;
    gap: 0.7rem;
    padding-inline: var(--gutter);
  }

  .site-brand {
    font-size: 0.64rem;
  }

  .header-tools {
    gap: 0.35rem;
  }

  .language-switch {
    gap: 0.3rem;
  }

  .theme-switch label {
    min-height: 1.8rem;
    width: 1.65rem;
    justify-content: center;
    padding-inline: 0;
    font-size: 0;
  }

  .theme-switch label::after {
    font: 600 0.54rem/1 var(--font-mono);
  }

  .theme-switch label[for="theme-deep"]::after {
    content: "D";
  }

  .theme-switch label[for="theme-chalk"]::after {
    content: "C";
  }
}
