/* Global search palette (scripts/bc-palette.js). Uses tokens from styles/modern.css with fallbacks. */
.bc-pal {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: min(14vh, 120px) 16px 16px;
  font-family: var(--bc-font, system-ui, -apple-system, "Segoe UI", sans-serif);
}
.bc-pal[hidden] { display: none; }

.bc-pal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(11, 11, 16, 0.32);
  -webkit-backdrop-filter: blur(6px) saturate(120%);
  backdrop-filter: blur(6px) saturate(120%);
  opacity: 0;
  transition: opacity 0.18s var(--bc-ease, ease);
}

.bc-pal-dialog {
  position: relative;
  width: 100%;
  max-width: 620px;
  max-height: min(560px, calc(100vh - min(14vh, 120px) - 32px));
  max-height: min(560px, calc(100dvh - min(14vh, 120px) - 32px));
  display: flex;
  flex-direction: column;
  background: var(--bc-surface, #fff);
  border: 1px solid var(--bc-line, rgba(15, 15, 25, 0.07));
  border-radius: var(--bc-r-lg, 22px);
  box-shadow: var(--bc-shadow-3, 0 18px 48px -12px rgba(16, 16, 30, 0.18)), 0 0 0 1px rgba(15, 15, 25, 0.03);
  overflow: hidden;
  opacity: 0;
  transform: translateY(-6px) scale(0.97);
  transform-origin: 50% 0;
  transition: opacity 0.18s var(--bc-ease, ease), transform 0.22s var(--bc-ease, ease);
}

.bc-pal.is-open .bc-pal-backdrop { opacity: 1; }
.bc-pal.is-open .bc-pal-dialog { opacity: 1; transform: none; }

/* head / input */
.bc-pal-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 14px 0 18px;
  border-bottom: 1px solid var(--bc-line, rgba(15, 15, 25, 0.07));
  flex: 0 0 auto;
}
.bc-pal-icon { color: var(--bc-muted, #6b6b76); font-size: 15px; }
.bc-pal-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 58px;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 0 !important;
  margin: 0 !important;
  font: inherit;
  font-size: 17px !important;
  line-height: 1.2;
  color: var(--bc-ink, #0b0b10) !important;
  -webkit-appearance: none;
  appearance: none;
}
.bc-pal-input::placeholder { color: var(--bc-faint, #9a9aa5); opacity: 1; }
.bc-pal-esc {
  flex: 0 0 auto;
  font: 600 11px/1 var(--bc-font, system-ui, sans-serif);
  color: var(--bc-muted, #6b6b76);
  background: var(--bc-surface-2, #f6f6f8);
  border: 1px solid var(--bc-line-strong, rgba(15, 15, 25, 0.12));
  border-radius: 7px;
  padding: 5px 7px;
  cursor: pointer;
  transition: background-color 0.15s var(--bc-ease, ease), color 0.15s var(--bc-ease, ease);
}
.bc-pal-esc:hover { color: var(--bc-ink, #0b0b10); background: var(--bc-surface-3, #eeeef2); }
.bc-pal-esc:focus-visible { outline: none; box-shadow: var(--bc-ring, 0 0 0 4px rgba(91, 75, 209, 0.16)); }

.bc-pal-spinner {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
  border-radius: 50%;
  border: 2px solid var(--bc-line-strong, rgba(15, 15, 25, 0.12));
  border-top-color: var(--bc-accent, #5b4bd1);
  opacity: 0;
  transition: opacity 0.15s ease;
  animation: bc-pal-spin 0.7s linear infinite;
  animation-play-state: paused;
}
.bc-pal.is-loading .bc-pal-spinner { opacity: 1; animation-play-state: running; }
@keyframes bc-pal-spin { to { transform: rotate(360deg); } }

/* list */
.bc-pal-list {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 6px 8px 8px;
  scroll-padding: 8px;
}
.bc-pal-list:empty { display: none; }
.bc-pal-group + .bc-pal-group,
.bc-pal-note + .bc-pal-group { margin-top: 4px; }
.bc-pal-group-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 10px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--bc-faint, #9a9aa5);
}
.bc-pal-clear {
  border: 0;
  background: none;
  padding: 2px 4px;
  font: inherit;
  letter-spacing: 0.04em;
  color: var(--bc-muted, #6b6b76);
  cursor: pointer;
  border-radius: 6px;
}
.bc-pal-clear:hover { color: var(--bc-accent, #5b4bd1); }

.bc-pal-item {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 7px 10px;
  border-radius: var(--bc-r-sm, 10px);
  color: var(--bc-ink-2, #3a3a44) !important;
  text-decoration: none !important;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background-color 0.12s var(--bc-ease, ease);
}
.bc-pal-item.is-active { background: var(--bc-surface-2, #f6f6f8); color: var(--bc-ink, #0b0b10) !important; }
.bc-pal-item.is-active .bc-pal-glyph { color: var(--bc-accent, #5b4bd1); background: rgba(91, 75, 209, 0.1); }

.bc-pal-avatar {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  border-radius: 50%;
  object-fit: cover;
  background: var(--bc-surface-3, #eeeef2);
}
.bc-pal-avatar.is-academy { border-radius: 9px; }
.bc-pal-avatar.is-video { width: 64px; flex-basis: 64px; border-radius: 8px; }
.bc-pal-glyph {
  width: 36px;
  height: 36px;
  flex: 0 0 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  background: var(--bc-surface-2, #f6f6f8);
  color: var(--bc-muted, #6b6b76);
  font-size: 14px;
  transition: background-color 0.12s var(--bc-ease, ease), color 0.12s var(--bc-ease, ease);
}
.bc-pal-copy {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1 1 auto;
  gap: 2px;
}
.bc-pal-name {
  font-size: 14.5px;
  font-weight: 500;
  color: var(--bc-ink, #0b0b10);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bc-pal-nick { color: var(--bc-muted, #6b6b76); font-weight: 400; }
.bc-pal-meta {
  font-size: 12.5px;
  color: var(--bc-muted, #6b6b76);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.bc-pal-belt { display: block; line-height: 0; max-width: 140px; }
.bc-pal-belt img, .bc-pal-belt svg { max-height: 12px; }
.bc-pal-name mark {
  background: rgba(91, 75, 209, 0.14);
  color: inherit;
  border-radius: 3px;
  padding: 0 1px;
}
.bc-pal-item.is-all .bc-pal-name { font-weight: 400; color: var(--bc-ink-2, #3a3a44); }
.bc-pal-item.is-all strong { color: var(--bc-ink, #0b0b10); font-weight: 600; }

.bc-pal-note {
  margin: 6px 10px 2px;
  font-size: 13px;
  color: var(--bc-muted, #6b6b76);
}
.bc-pal-note .fa { margin-right: 4px; opacity: 0.7; }

/* footer hints */
.bc-pal-foot {
  flex: 0 0 auto;
  display: flex;
  gap: 16px;
  padding: 9px 16px;
  border-top: 1px solid var(--bc-line, rgba(15, 15, 25, 0.07));
  background: var(--bc-surface-2, #f6f6f8);
  font-size: 12px;
  color: var(--bc-muted, #6b6b76);
}
.bc-pal-foot kbd {
  display: inline-block;
  min-width: 18px;
  margin-right: 2px;
  padding: 1px 5px;
  font: 600 11px/16px var(--bc-font, system-ui, sans-serif);
  text-align: center;
  color: var(--bc-ink-2, #3a3a44);
  background: var(--bc-surface, #fff);
  border: 1px solid var(--bc-line-strong, rgba(15, 15, 25, 0.12));
  border-radius: 5px;
  box-shadow: 0 1px 0 var(--bc-line-strong, rgba(15, 15, 25, 0.12));
}

/* phones: sheet near the top so the keyboard never covers the input */
@media (max-width: 640px) {
  .bc-pal { padding: 10px 10px 0; }
  .bc-pal-dialog {
    max-width: none;
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: var(--bc-r, 14px);
  }
  .bc-pal-input { height: 54px; font-size: 16px !important; } /* 16px avoids iOS zoom */
  .bc-pal-foot { display: none; }
  .bc-pal-item { min-height: 48px; }
}
@media (hover: none) {
  .bc-pal-foot { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .bc-pal-backdrop,
  .bc-pal-dialog,
  .bc-pal-item,
  .bc-pal-glyph { transition: none !important; }
  .bc-pal-dialog { transform: none !important; }
  .bc-pal-spinner { animation-duration: 1.6s; }
}
