/* Quick search window (Cmd+K / Ctrl+K, or Search in the sidebar) and the list
   of keyboard shortcuts (?), quick-search.js. Colours come from the theme
   tokens (base.css), so both themes follow. */

.qs-overlay {
  position: fixed; inset: 0;
  z-index: 300;
  display: flex; align-items: flex-start; justify-content: center;
  padding: max(12vh, calc(env(safe-area-inset-top) + 12px)) 16px 16px;
  background: var(--modal-overlay);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
}
.qs-overlay[hidden] { display: none; }

.qs-dialog {
  width: min(620px, 100%);
  max-height: min(560px, calc(100dvh - max(12vh, calc(env(safe-area-inset-top) + 12px)) - 16px));
  box-sizing: border-box;
  display: flex; flex-direction: column;
  overflow: hidden;
  background: var(--glass-bg-strong);
  color: var(--text);
  border: 1px solid var(--btn-secondary-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--glass-highlight);
  backdrop-filter: var(--glass-blur);
  -webkit-backdrop-filter: var(--glass-blur);
  animation: qs-in 0.14s ease-out;
}
@keyframes qs-in {
  from { opacity: 0; transform: translateY(-6px) scale(0.985); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) { .qs-dialog { animation: none; } }

.qs-head {
  display: flex; align-items: center; gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
.qs-head .icon { flex: none; }
.qs-input {
  flex: 1; min-width: 0;
  border: none; outline: none;
  background: transparent;
  color: var(--text);
  font: inherit;
  /* 16px or more: iOS Safari does not zoom into the field. */
  font-size: 17px;
  padding: 4px 0;
}
.qs-input::placeholder { color: var(--field-placeholder); }

.qs-close {
  flex: none;
  padding: 3px 8px;
  border: 1px solid var(--tone-neutral-ring);
  border-radius: 6px;
  background: var(--tone-neutral-bg);
  color: var(--tone-neutral-text);
  font: inherit; font-size: 12px; font-weight: 700;
  cursor: pointer;
}
.qs-close:hover { color: var(--text); }
.qs-close:focus-visible { outline: none; border-color: var(--field-focus-border); box-shadow: var(--field-focus-ring); }
.qs-close-x { display: none; }
/* Touch screens have no Esc key: the button shows a cross. */
@media (hover: none) {
  .qs-close-key { display: none; }
  .qs-close-x { display: inline; }
}

.qs-note { padding: 0 16px; color: var(--tone-warning-text); font-size: 13px; }
.qs-note:empty { display: none; }
.qs-note:not(:empty) { padding: 10px 16px 0; }

.qs-list {
  flex: 1; min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
}
.qs-group + .qs-group { margin-top: 4px; }
.qs-group-label {
  padding: 10px 12px 4px;
  font-size: 11px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.12em;
  color: var(--text-dim);
}

.qs-option {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  scroll-margin: 6px;
}
.qs-option.active { background: var(--tab-active-bg); box-shadow: inset 0 0 0 1px var(--tab-active-ring); }
.qs-option-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.qs-option-label {
  font-size: 14px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qs-option-detail,
.qs-option-where {
  font-size: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.qs-option-detail { color: var(--text-dim); }
.qs-option-where { color: var(--tone-accent-text); font-weight: 600; }
.qs-option-meta { flex: none; color: var(--text-dim); font-size: 12px; white-space: nowrap; }
.qs-option-hint { flex: none; display: flex; gap: 4px; }
.qs-option mark {
  background: var(--accent-subtle);
  color: inherit;
  border-radius: 2px;
  box-shadow: inset 0 -1px 0 var(--accent);
}

.qs-status { padding: 6px 10px 8px; color: var(--text-dim); font-size: 13px; }
.qs-empty { padding: 18px 10px; text-align: center; }

.qs-overlay kbd {
  display: inline-block;
  min-width: 1.6em;
  box-sizing: border-box;
  padding: 1px 5px;
  border: 1px solid var(--tone-neutral-ring);
  border-radius: 5px;
  background: var(--tone-neutral-bg);
  color: var(--tone-neutral-text);
  font: inherit; font-size: 11px; font-weight: 700;
  text-align: center;
}

.qs-foot {
  display: flex; flex-wrap: wrap; gap: 6px 16px;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12px;
}
.qs-foot kbd + kbd { margin-left: 3px; }
.qs-foot-end { margin-left: auto; }
/* No keyboard on touch screens: no key hints. */
@media (hover: none) {
  .qs-foot, .qs-option-hint { display: none; }
}

/* The list of shortcuts */
.qs-help { padding: 0 0 6px; }
.qs-help-head {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 16px 18px 10px;
}
.qs-help-head h2 { margin: 0; font-size: 18px; color: var(--text); }
.qs-help-list { margin: 0; padding: 0 18px; overflow-y: auto; }
.qs-help-row {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 7px 0;
  border-top: 1px solid var(--border);
}
.qs-help-row dt { flex: none; display: flex; gap: 4px; order: 2; }
.qs-help-row dd { margin: 0; color: var(--text); font-size: 14px; }
.qs-help-note { margin: 8px 18px 6px; color: var(--text-dim); font-size: 13px; }

@media (max-width: 520px) {
  .qs-overlay { padding: calc(env(safe-area-inset-top) + 8px) 8px 8px; }
  .qs-dialog { max-height: calc(100dvh - env(safe-area-inset-top) - 16px); }
}
