.header-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 8px;
}

.search-trigger {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 32px;
  padding: 0 10px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--r-pill);
  background: var(--surface-translucent);
  color: var(--ink-2);
  font-size: var(--type-meta-size);
  cursor: pointer;
  transition: color var(--motion-switch) var(--motion-ease), background-color var(--motion-switch) var(--motion-ease);
}

.search-trigger:hover {
  color: var(--ink);
  background: var(--surface);
}

.search-trigger-key {
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: var(--r-keycap);
  color: var(--ink-3);
  font: var(--type-eyebrow-size) var(--font-mono);
}

body.search-open {
  overflow: hidden;
}

.search-root {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: grid;
  place-items: start center;
  padding: 10vh 20px 20px;
}

.search-root[hidden] {
  display: none;
}

.search-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 20, 24, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}

.search-dialog {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(680px, 100%);
  max-height: 70vh;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.18);
}

.search-root.is-open .search-dialog {
  animation: search-in var(--motion-switch) var(--motion-ease-switch);
}

@keyframes search-in {
  from {
    transform: translateY(-8px) scale(0.99);
  }
  to {
    transform: none;
  }
}

.search-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
}

.search-head:focus-within {
  box-shadow: inset 0 -2px 0 var(--accent);
}

.search-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: var(--type-body-size);
}

.search-input::placeholder {
  color: var(--ink-3);
}

.search-key {
  padding: 3px 6px;
  border: 1px solid var(--line);
  border-radius: var(--r-keycap);
  color: var(--ink-3);
  font: var(--type-eyebrow-size) var(--font-mono);
  white-space: nowrap;
}

.search-results {
  overflow-y: auto;
  padding: 8px;
}

.search-group-label {
  padding: 12px 12px 6px;
}

.search-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 11px 12px;
  border-radius: var(--r-sm);
  color: var(--ink);
  text-decoration: none;
}

.search-item:hover,
.search-item[data-active="true"] {
  background: var(--surface-3);
  text-decoration: none;
}

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

.search-item-main {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.search-item-title {
  font-size: var(--type-small-size);
  font-weight: 600;
}

.search-item-sub {
  overflow: hidden;
  color: var(--ink-2);
  font-size: var(--type-meta-size);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search-empty {
  padding: 30px 18px;
  color: var(--ink-2);
  font-size: var(--type-small-size);
}

.search-foot {
  display: flex;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid var(--line);
  color: var(--ink-3);
  font-size: var(--type-meta-size);
}

.search-foot kbd {
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: var(--r-keycap);
  font: var(--type-eyebrow-size) var(--font-mono);
}

@media (max-width: 880px) {
  .search-trigger-key {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .search-root.is-open .search-dialog {
    animation: none;
  }
}

:root[data-motion="reduced"] .search-root.is-open .search-dialog {
  animation: none;
}
