/* The quick search. Only the shared palette tokens, so it follows every theme
   without a rule of its own per palette. */

.qs-launch {
  position: fixed;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  z-index: 45;
  display: inline-flex;
  gap: 0.5rem;
  align-items: center;
  padding: 0.5rem 0.6rem 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  color: var(--text);
  background: var(--surface-raised);
  box-shadow: var(--shadow);
  font: inherit;
  font-size: 0.9rem;
  cursor: pointer;
}
.qs-launch[hidden] { display: none; }
.qs-launch:hover { border-color: var(--accent); }
.qs-launch:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; }

.qs-icon {
  flex: none;
  width: 1.1rem;
  height: 1.1rem;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

.qs-kbd {
  display: inline-block;
  min-width: 1.4em;
  padding: 0.05rem 0.35rem;
  border: 1px solid var(--border);
  border-bottom-width: 2px;
  border-radius: 0.3rem;
  color: var(--muted);
  background: var(--field-bg);
  font-family: inherit;
  font-size: 0.72rem;
  line-height: 1.4;
  text-align: center;
  white-space: nowrap;
}

.qs-dialog {
  width: min(40rem, calc(100vw - 2rem));
  max-height: min(36rem, calc(100dvh - 4rem));
  margin: 12vh auto auto;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--surface);
  box-shadow: var(--shadow), 0 1.5rem 4rem rgb(0 0 0 / 0.35);
  overflow: hidden;
}
.qs-dialog[open] {
  display: flex;
  flex-direction: column;
  animation: qs-appear 120ms ease-out;
}
.qs-dialog::backdrop { background: rgb(0 0 0 / 0.5); }

@keyframes qs-appear {
  from { opacity: 0; transform: translateY(-0.5rem) scale(0.98); }
}

.qs-field {
  display: flex;
  gap: 0.6rem;
  align-items: center;
  padding: 0.75rem 0.9rem;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
}
.qs-input {
  flex: 1;
  min-width: 0;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  background: var(--field-bg);
  font: inherit;
  font-size: 1.05rem;
}
.qs-input:focus { outline: 2px solid var(--focus); outline-offset: 1px; }
.qs-close {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
}
.qs-close:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.qs-results {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.qs-results:empty { display: none; }
.qs-group { padding: 0.35rem 0.45rem 0.5rem; }
.qs-group + .qs-group { border-top: 1px solid var(--border); }
.qs-group-label {
  margin: 0.35rem 0.5rem 0.25rem;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.qs-option {
  display: grid;
  gap: 0.1rem;
  padding: 0.45rem 0.6rem;
  border-radius: calc(var(--radius) - 0.15rem);
  color: var(--text);
  text-decoration: none;
}
.qs-option[aria-selected="true"] {
  background: color-mix(in srgb, var(--accent) 16%, transparent);
  box-shadow: inset 3px 0 var(--accent);
}
.qs-option-title,
.qs-option-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.qs-option-title { font-weight: 600; }
.qs-option-detail { color: var(--muted); font-size: 0.82rem; }

.qs-status {
  margin: 0;
  padding: 0.7rem 1rem;
  color: var(--muted);
  font-size: 0.9rem;
}
.qs-results:not(:empty) + .qs-status {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
}

.qs-footer {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.1rem;
  margin: 0;
  padding: 0.55rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--muted);
  background: var(--surface-raised);
  font-size: 0.78rem;
}
.qs-footer .qs-kbd + .qs-kbd { margin-left: 0.2rem; }

/* On a phone the button is a round icon at the thumb, and the keyboard hints
   describe keys that are not there. */
@media (max-width: 40rem) {
  .qs-launch { width: 3rem; height: 3rem; justify-content: center; padding: 0; }
  .qs-launch-label,
  .qs-launch .qs-kbd,
  .qs-footer { display: none; }
  .qs-dialog {
    width: calc(100vw - 1rem);
    max-height: calc(100dvh - 2rem);
    margin-top: 0.75rem;
  }
}

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

@media print {
  .qs-launch { display: none; }
}

/* A song plays where it is chosen; the triangle says so before Enter does. */
.qs-play-mark { margin-right: 0.45rem; color: var(--success); font-size: 0.75em; }
