/* ============================================================
   Palettes, help modal, toasts
   ============================================================ */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 0 16px;
}
.overlay-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 4, 9, .62);
  backdrop-filter: blur(7px);
  animation: fadeIn .2s ease both;
}
[data-theme="light"] .overlay-backdrop { background: rgba(26, 20, 52, .32); }
@keyframes fadeIn { from { opacity: 0; } }

.palette-wrap {
  position: relative;
  width: min(620px, 100%);
  margin-top: 11vh;
  animation: paletteIn .28s var(--ease) both;
}
@keyframes paletteIn { from { opacity: 0; transform: translateY(-10px) scale(.985); } }

.palette {
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 17px;
  box-shadow: 0 40px 100px -20px rgba(0, 0, 0, .7), inset 0 1px 0 rgba(255, 255, 255, .04);
  overflow: hidden;
}
.palette-search {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 17px;
  border-bottom: 1px solid var(--line);
}
.palette-search .icon { width: 18px; height: 18px; color: var(--faint); flex: none; }
.palette-search input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  font-size: 14.5px;
  color: var(--text);
}
.palette-search input::placeholder { color: var(--faint); }
.palette-search kbd { flex: none; }

.palette-results { max-height: min(400px, 52vh); overflow-y: auto; padding: 7px; }
.palette-group { padding: 10px 10px 5px; font-size: 9.5px; text-transform: uppercase; letter-spacing: .16em; color: var(--faint); font-weight: 600; }
.palette-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 11px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  transition: background .12s;
}
.palette-item:hover { background: var(--panel-2); }
.palette-item.active { background: var(--panel-2); box-shadow: inset 0 0 0 1px var(--line); }
.palette-item-icon {
  width: 28px; height: 28px; flex: none;
  display: grid; place-items: center;
  border-radius: 7px;
  background: var(--panel-3);
  color: var(--muted);
}
.palette-item-icon .icon { width: 14px; height: 14px; }
.palette-item.active .palette-item-icon { color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, transparent); }
.palette-item-label { font-size: 13px; font-weight: 500; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.palette-item-hint { font-size: 10px; color: var(--faint); flex: none; }
.palette-item-hint kbd { font-size: 9px; height: 18px; }
.palette-item.ask .palette-item-icon { color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 12%, transparent); }
.palette-empty { padding: 26px 18px; text-align: center; font-size: 12px; color: var(--faint); }
.palette-foot {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 9px 15px;
  border-top: 1px solid var(--line);
  font-size: 9.5px;
  color: var(--faint);
  background: color-mix(in srgb, var(--bg) 35%, transparent);
}
.palette-foot span { display: flex; align-items: center; gap: 4px; }
.palette-foot kbd { height: 17px; min-width: 17px; font-size: 9px; padding: 0 4px; }

/* ---------- help ---------- */

.help-modal {
  position: relative;
  width: min(780px, 100%);
  max-height: 84vh;
  margin-top: 7vh;
  background: var(--panel);
  border: 1px solid var(--line-strong);
  border-radius: 20px;
  box-shadow: 0 50px 120px -30px rgba(0, 0, 0, .75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: paletteIn .3s var(--ease) both;
}
.help-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 26px 18px;
  border-bottom: 1px solid var(--line);
  flex: none;
}
.help-head h2 { font-size: 1.55rem; font-weight: 640; letter-spacing: -.04em; margin-top: 5px; }
.help-body { padding: 22px 26px; overflow-y: auto; }
.help-section + .help-section { margin-top: 22px; padding-top: 20px; border-top: 1px solid var(--line); }
.help-section h3 { font-size: 12px; text-transform: uppercase; letter-spacing: .13em; color: var(--muted); font-weight: 600; margin-bottom: 11px; }
.help-grid { display: flex; flex-wrap: wrap; gap: 6px; }
.help-example {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  transition: color .15s, border-color .15s;
}
.help-example:hover { color: var(--text); border-color: var(--line-strong); }
.help-example .icon { width: 12px; height: 12px; color: var(--accent); }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px 22px; }
.shortcut-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 11.5px; color: var(--muted); padding: 4px 0; }
.shortcut-row span:last-child { display: flex; gap: 4px; flex: none; }
.help-note { font-size: 11.5px; color: var(--faint); line-height: 1.7; }
.help-note strong { color: var(--muted); }
.help-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 26px;
  border-top: 1px solid var(--line);
  font-size: 10.5px;
  color: var(--faint);
  flex: none;
}

/* ---------- toasts ---------- */

.toasts {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 140;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  max-width: min(360px, calc(100vw - 32px));
}
.toast {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 14px;
  border-radius: 11px;
  border: 1px solid var(--line-strong);
  background: var(--panel);
  box-shadow: 0 18px 44px -16px rgba(0, 0, 0, .55);
  font-size: 12px;
  color: var(--text);
  pointer-events: auto;
  animation: toastIn .28s var(--ease) both;
  max-width: 100%;
}
@keyframes toastIn { from { opacity: 0; transform: translateY(8px) scale(.98); } }
.toast.out { animation: toastOut .2s ease both; }
@keyframes toastOut { to { opacity: 0; transform: translateY(5px); } }
.toast-icon { color: var(--good); flex: none; display: grid; }
.toast-icon .icon { width: 15px; height: 15px; }
.toast-msg { flex: 1; min-width: 0; }
.toast-action {
  flex: none;
  border: 0;
  background: transparent;
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 600;
  padding: 2px 4px;
}
.toast-action:hover { text-decoration: underline; }

/* ---------- responsive overlays ---------- */

@media (max-width: 640px) {
  .palette-wrap { margin-top: 8vh; }
  .palette-foot { display: none; }
  .palette-search { padding: 13px 14px; }
  .palette-search kbd { display: none; }
  .help-modal { margin-top: 4vh; max-height: 90vh; border-radius: 16px; }
  .help-head { padding: 18px 18px 14px; }
  .help-head h2 { font-size: 1.3rem; }
  .help-body { padding: 16px 18px; }
  .help-foot { padding: 12px 18px; }
  .help-foot > span { display: none; }
  .shortcut-grid { grid-template-columns: 1fr; }
  .toasts { right: 12px; bottom: 12px; left: 12px; align-items: stretch; }
  .toast { justify-content: space-between; }
}
