[data-cmdk-open] { display: none; }

@media (min-width: 1024px) and (hover: hover) and (pointer: fine) {
  .top__k {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    min-height: 30px;
    padding: .4rem .6rem;
    border: 1px solid var(--rule-c);
    border-radius: 6px;
    background: transparent;
    color: var(--fg-2);
    font: 500 .76rem/1 var(--mono);
    cursor: pointer;
    transition: color 140ms ease;
  }
  .top__k:hover { color: var(--fg); }
}

.cmdk {
  position: fixed;
  inset-block-start: 14vh;
  inset-inline: 0;
  width: min(640px, calc(100vw - 2rem));
  max-width: none;
  max-height: 72vh;
  margin: 0 auto;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--rule-c);
  border-radius: 14px;
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 24px 80px rgba(0, 0, 0, .24);
  font-family: var(--font);
}

.cmdk::backdrop {
  background: rgba(0, 0, 0, .35);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
}

.cmdk[open] { animation: cmdk-open 160ms ease-out both; }

@keyframes cmdk-open {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.cmdk__panel {
  display: flex;
  max-height: 72vh;
  flex-direction: column;
}

.cmdk__search-wrap { padding: 1rem 1.25rem 0; }

.cmdk__input {
  display: block;
  width: 100%;
  padding: .25rem 0 .85rem;
  border: 0;
  border-bottom: 1px solid var(--rule-c);
  border-radius: 0;
  outline: 0;
  background: transparent;
  color: var(--fg);
  font: 450 var(--step-1)/1.35 var(--font);
}

.cmdk__input::placeholder { color: var(--fg-3); opacity: 1; }
/* the caret and the open dialog already show where focus is; a ring around the only field is noise */
.cmdk__input:focus-visible { outline: 0; border-bottom-color: var(--fg-3); }
.cmdk__input::-webkit-search-cancel-button { -webkit-appearance: none; appearance: none; }

.cmdk__list {
  max-height: min(420px, 60vh);
  padding: .55rem .65rem .85rem;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-color: var(--fg-3) var(--bg);
}

.cmdk__group + .cmdk__group { margin-top: .45rem; }

.cmdk__group-title {
  margin: .45rem .65rem .3rem;
  color: var(--fg-3);
  font-size: var(--step--1);
  font-weight: 540;
  line-height: 1.35;
}

.cmdk__option {
  display: flex;
  min-height: 40px;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: .5rem .65rem;
  border-radius: 8px;
  color: var(--fg);
  cursor: pointer;
}

.cmdk__option[aria-selected="true"] { background: color-mix(in srgb, var(--fg) 8%, transparent); }
.cmdk__option:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }

.cmdk__label { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cmdk__hint { flex: 0 0 auto; color: var(--fg-2); font-size: .82em; white-space: nowrap; }
.cmdk__hint[hidden] { display: none; }
.cmdk__empty { padding: 1.1rem .65rem 1.35rem; color: var(--fg-2); }

@media (max-width: 600px) {
  .cmdk {
    inset-block-start: 1rem;
    width: calc(100vw - 2rem);
    max-height: calc(100vh - 2rem);
    margin: 0 auto;
  }
  .cmdk__panel { max-height: calc(100vh - 2rem); }
  .cmdk__search-wrap { padding-inline: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .cmdk[open] { animation: none; }
}
