/* Ctrl K 命令面板：搜题目/错因/帖子，或输入页面名跳转。颜色全部走主题变量。 */

.palette {
  position: fixed;
  inset: 0;
  z-index: 55;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 12vh var(--space-3) var(--space-3);
}
.palette[hidden] { display: none; }
.palette-backdrop { position: absolute; inset: 0; background: rgba(var(--shadow-rgb), .5); }
.palette-panel {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(640px, 100%);
  max-height: min(580px, 78dvh);
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: 0 24px 60px rgba(var(--shadow-rgb), .28);
}
.palette-input-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 58px;
  padding: 0 var(--space-3) 0 var(--space-4);
  border-bottom: 1px solid var(--line);
}
.palette-input-row:focus-within { box-shadow: inset 0 -3px 0 var(--accent); }
.palette-search-icon { flex: 0 0 20px; width: 20px; height: 20px; color: var(--ink-2); }
.palette-input {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: var(--space-4) 0;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  color: var(--ink);
  font-size: 16px;
}
.palette-input:hover, .palette-input:focus { border: 0; box-shadow: none; }
.palette-input:focus-visible { outline: none; }
.palette-close {
  flex: 0 0 auto;
  min-height: 28px;
  padding: 0 var(--space-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-compact);
  background: var(--paper-2);
  color: var(--ink-2);
  font-family: inherit;
  font-size: var(--text-meta);
  font-weight: 600;
}
.palette-close:hover:not(:disabled) { transform: none; }
.palette-list { flex: 1; min-height: 0; padding: var(--space-2); overflow-y: auto; overscroll-behavior: contain; }
.palette-group + .palette-group { margin-top: var(--space-1); }
.palette-group-title { padding: var(--space-2) var(--space-3) var(--space-1); color: var(--ink-2); font-size: var(--text-xs); font-weight: 600; letter-spacing: .06em; }
.palette-option {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-height: 46px;
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-option);
  cursor: pointer;
}
.palette-option[aria-selected="true"] { background: var(--soft); box-shadow: inset 3px 0 var(--accent); }
.palette-icon { flex: 0 0 18px; width: 18px; height: 18px; color: var(--ink-2); }
.palette-option[aria-selected="true"] .palette-icon { color: var(--accent); }
.palette-option-text { display: grid; flex: 1; gap: 1px; min-width: 0; }
.palette-option-label { overflow: hidden; font-size: var(--text-md); font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.palette-option-sub { overflow: hidden; color: var(--ink-2); font-size: var(--text-xs); text-overflow: ellipsis; white-space: nowrap; }
.palette-badge { flex: 0 0 auto; padding: 0 var(--space-2); border: 1px solid var(--line); border-radius: var(--radius-pill); color: var(--ink-2); font-size: var(--text-xs); line-height: 20px; }
.palette mark { padding: 0 1px; border-radius: 3px; background: var(--selection); color: inherit; }
.palette-empty, .palette-loading { margin: 0; padding: var(--space-4) var(--space-3); color: var(--ink-2); font-size: var(--text-sm); text-align: center; }
.palette-foot { display: flex; flex-wrap: wrap; gap: var(--space-4); padding: var(--space-2) var(--space-4); border-top: 1px solid var(--line); background: var(--paper-2); color: var(--ink-2); font-size: var(--text-xs); }
.palette-sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; border: 0; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
body.palette-open { overflow: hidden; }
.palette-close:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

@media (max-width: 599px) {
  .palette { padding-top: var(--space-3); }
  .palette-panel { max-height: calc(100dvh - 2 * var(--space-3)); }
  .palette-option { min-height: 52px; }
}
@media (hover: none), (pointer: coarse) {
  .palette-foot { display: none; }
}
@media (prefers-reduced-motion: no-preference) {
  .palette:not([hidden]) .palette-panel { animation: palette-in var(--motion-enter) var(--motion-ease); }
}
@keyframes palette-in { from { opacity: .6; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
