/* ==========================================================================
   Nexos — Paleta de busca e comandos (N.palette) · prefixo .pal-
   ========================================================================== */

.pal-back {
  position: fixed; inset: 0; z-index: var(--z-modal);
  display: flex; justify-content: center; align-items: flex-start;
  padding: max(9vh, 40px) 16px 24px;
  background: var(--overlay);
  backdrop-filter: blur(3px);
  animation: fade .14s ease;
}
.pal-back.pal-out { animation: palOut .13s ease forwards; }
.pal-back.pal-out .pal { animation: palPanelOut .13s ease forwards; }

.pal {
  width: min(640px, 100%);
  max-height: min(600px, calc(100vh - max(9vh, 40px) - 32px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  box-shadow: var(--shadow-window);
  animation: pop .2s var(--spring);
}

/* ---- Campo ---- */
.pal-head {
  display: flex; align-items: center; gap: 8px;
  height: 60px; flex-shrink: 0;
  padding: 0 10px 0 18px;
  border-bottom: 1px solid var(--border);
}
.pal-search-ic { display: inline-grid; color: var(--text-3); transition: color var(--dur); }
.pal-has-q .pal-search-ic { color: var(--accent); }
.pal-input {
  flex: 1; min-width: 0; height: 100%;
  border: 0; outline: 0; background: transparent;
  font-size: 16.5px; font-weight: 450; color: var(--text);
  padding: 0 4px;
}
.pal-input::placeholder { color: var(--text-3); }
.pal-input:focus-visible { outline: none; }
.pal-clear { color: var(--text-3); }

/* ---- Lista ---- */
.pal-list {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 4px 8px 10px;
  overscroll-behavior: contain;
  scroll-padding: 36px 0 10px;
}
.pal-group { padding-top: 2px; }
.pal-glabel {
  display: flex; align-items: center; justify-content: space-between;
  padding: 11px 10px 5px;
  font-size: 11px; font-weight: 650; letter-spacing: .065em; text-transform: uppercase;
  color: var(--text-3);
}
.pal-gmeta { font-weight: 600; letter-spacing: 0; color: var(--text-3); opacity: .8; }

.pal-opt {
  position: relative;
  display: flex; align-items: center; gap: 12px;
  min-height: 48px; padding: 6px 10px;
  border-radius: var(--r);
  cursor: pointer; user-select: none;
}
.pal-opt.on { background: var(--accent-soft); }
.pal-opt.on .pal-title { color: var(--text); }

.pal-tile {
  width: 32px; height: 32px; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 10px;
  background: var(--surface-3); color: var(--text-2);
}
.pal-tile svg.lucide { width: 16px; height: 16px; }
.pal-tile.tint { background: var(--c-bg); color: var(--c-ink); }
.pal-tile-accent { background: var(--accent-soft); color: var(--accent-ink); }
.pal-tile-adv { background: var(--surface-2); color: var(--text-2); box-shadow: inset 0 0 0 1px var(--border); }
.pal-tile-person { background: transparent; box-shadow: none; }
.pal-tile-person .avatar { box-shadow: 0 0 0 2px var(--surface); }
.pal-tile-done { color: var(--success); }
.pal-tile-claude { background: var(--accent); color: var(--on-accent); box-shadow: 0 4px 12px var(--accent-ring); }
.pal-emoji { font-size: 16px; line-height: 1; }

.pal-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.pal-title {
  font-size: 14px; font-weight: 560; line-height: 1.35; color: var(--text);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pal-title b { font-weight: 650; }
.pal-sub {
  font-size: 12.3px; line-height: 1.35; color: var(--text-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pal-sub svg.lucide { width: 12px; height: 12px; vertical-align: -2px; }
.pal-dot { margin: 0 5px; opacity: .7; }
.pal-snip { color: var(--text-2); }
.pal-qty { font-weight: 500; font-size: 12.5px; color: var(--text-3); margin-left: 2px; }
.pal-lock { display: inline-flex; vertical-align: -1px; color: var(--text-3); }
.pal-lock svg.lucide { width: 12px; height: 12px; }

.pal-right { flex-shrink: 0; display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-3); }
.pal-right .avatar-stack .avatar { box-shadow: 0 0 0 2px var(--surface); }
.pal-time { display: inline-flex; align-items: center; gap: 4px; white-space: nowrap; }
.pal-time svg.lucide { width: 12px; height: 12px; }
.pal-swatch { width: 14px; height: 14px; border-radius: 50%; box-shadow: inset 0 0 0 1px var(--border); }
.pal-enter {
  display: inline-grid; place-items: center; flex-shrink: 0;
  width: 22px; height: 22px; border-radius: 6px;
  color: var(--accent-ink); opacity: 0;
  transition: opacity var(--dur);
}
.pal-opt.on .pal-enter { opacity: 1; }

.pal-hl {
  background: color-mix(in srgb, var(--c-yellow-s) 34%, transparent);
  color: inherit; border-radius: 3px; padding: 0 1px;
}

.pal-done .pal-title { color: var(--text-3); text-decoration: line-through; text-decoration-color: var(--border-2); }
.pal-more .pal-title { color: var(--text-2); font-weight: 520; }
.pal-unlock .pal-title { color: var(--accent-ink); }

/* ---- Fichas (espaços, etiquetas) ---- */
.pal-g-chips .pal-gbody { display: flex; flex-wrap: wrap; gap: 6px; padding: 2px 6px 6px; }
.pal-opt.pal-chip {
  min-height: 34px; padding: 0 13px 0 10px; gap: 6px;
  border-radius: var(--r-full);
  background: var(--c-bg); color: var(--c-ink);
  font-size: 13px; font-weight: 600;
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--c-s) 18%, transparent);
  transition: box-shadow var(--dur), transform .12s var(--ease);
}
.pal-opt.pal-chip:hover { transform: translateY(-1px); }
.pal-opt.pal-chip.on { background: var(--c-bg); box-shadow: 0 0 0 2px var(--accent); }
.pal-opt.pal-chip.pal-chip-on { box-shadow: inset 0 0 0 2px var(--c-s); }
.pal-chip-emoji { font-size: 15px; line-height: 1; }
.pal-chip-label { white-space: nowrap; }

/* ---- Blocos "Ir para" ---- */
.pal-g-tiles .pal-gbody {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 8px; padding: 2px 4px 6px;
}
.pal-opt.pal-tileopt {
  flex-direction: column; align-items: flex-start; gap: 9px;
  min-height: 0; padding: 11px 12px 10px;
  border: 1px solid var(--border); border-radius: var(--r-lg);
  background: var(--surface-2);
  transition: border-color var(--dur), background var(--dur), transform .14s var(--ease);
}
.pal-opt.pal-tileopt:hover { transform: translateY(-1px); border-color: var(--border-2); }
.pal-opt.pal-tileopt.on { border-color: var(--accent); background: var(--accent-soft); }
.pal-tileopt-ic {
  width: 32px; height: 32px; border-radius: 10px;
  display: grid; place-items: center;
  background: var(--c-bg); color: var(--c-ink);
}
.pal-tileopt-label { font-size: 13px; font-weight: 600; color: var(--text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pal-tileopt-badge {
  position: absolute; top: 10px; right: 10px;
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: var(--r-full);
  display: grid; place-items: center;
  font-size: 11px; font-weight: 700; color: var(--text-2); background: var(--surface-3);
}

/* ---- Claude (última linha) ---- */
.pal-claude-group { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--border-2); }
.pal-claude .pal-title { color: var(--text); }
.pal-claude .pal-title b { color: var(--accent-ink); font-weight: 650; }
.pal-opt.pal-claude.on { background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }

/* ---- Nada encontrado ---- */
.pal-none {
  display: flex; align-items: flex-start; gap: 12px;
  margin: 10px 4px 2px; padding: 14px 16px;
  border-radius: var(--r-lg);
  background: var(--surface-2); border: 1px dashed var(--border-2);
  font-size: 13.2px; line-height: 1.45; color: var(--text-2);
}
.pal-none > svg.lucide { margin-top: 2px; color: var(--text-3); }
.pal-none b { color: var(--text); font-weight: 620; }

/* ---- Rodapé ---- */
.pal-foot {
  display: flex; align-items: center; gap: 14px; flex-shrink: 0;
  padding: 9px 16px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  font-size: 11.8px; color: var(--text-3);
  white-space: nowrap; overflow: hidden;
}
.pal-keys { display: inline-flex; align-items: center; gap: 5px; }
.pal-keys .kbd { padding: 2px 5px; }
.pal-prefix .kbd + .kbd, .pal-prefix .kbd:not(:first-child) { margin-left: 6px; }
.pal-foot-sp { flex: 1; }

@keyframes palOut { to { opacity: 0; } }
@keyframes palPanelOut { to { opacity: 0; transform: scale(.98) translateY(-4px); } }

/* rodapé enxuto em telas médias */
@media (max-width: 900px) and (min-width: 761px) {
  .pal-prefix { display: none; }
}

/* ---- Celular: tela cheia ---- */
@media (max-width: 760px) {
  .pal-back { padding: 0; align-items: stretch; backdrop-filter: none; }
  .pal {
    width: 100%; height: 100%; max-height: none;
    border: 0; border-radius: 0;
    padding-top: env(safe-area-inset-top);
    animation: viewIn .22s var(--ease);
  }
  .pal-head { height: 60px; padding: 0 6px 0 16px; gap: 4px; }
  .pal-input { font-size: 16px; }
  .pal-clear { width: 40px; height: 40px; }
  .pal-cancel { height: 40px; color: var(--accent-ink); font-weight: 600; }
  .pal-list { padding: 4px 8px calc(20px + env(safe-area-inset-bottom)); }
  .pal-opt { min-height: 54px; padding: 8px 10px; }
  .pal-foot { display: none; }
  .pal-enter, .pal-hide-m { display: none !important; }
  .pal-right .pal-time { display: none; }
  .pal-opt.pal-chip { min-height: 40px; }
  .pal-g-tiles .pal-gbody { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 6px; }
  .pal-opt.pal-tileopt { align-items: center; text-align: center; padding: 12px 4px 10px; gap: 7px; }
  .pal-tileopt-label { font-size: 12px; }
  .pal-tileopt-badge { top: 6px; right: 6px; }
}
