/* Command palette (command-palette.jsx): the ⌘K overlay, its top-bar trigger
   and the undo toast. Uses base.css tokens. */

/* ─── Palette ─────────────────────────────────────────────────────── */
.cp-overlay {
  position: fixed; inset: 0; z-index: 500;
  background: color-mix(in oklab, var(--bg) 55%, transparent);
  backdrop-filter: blur(3px);
  display: flex; justify-content: center; align-items: flex-start;
  padding: 12vh 16px 16px;
  animation: cp-fade 120ms ease-out;
}
@keyframes cp-fade { from { opacity: 0; } }
@keyframes cp-rise { from { opacity: 0; transform: translateY(-6px) scale(0.99); } }

.cp-panel {
  width: min(640px, 100%);
  max-height: min(72vh, 620px);
  display: flex; flex-direction: column;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 64px rgba(0,0,0,0.45), 0 1px 0 oklch(0.32 0.008 65) inset;
  overflow: hidden;
  animation: cp-rise 140ms cubic-bezier(0.2, 0.8, 0.2, 1);
}

.cp-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 0 12px 0 16px; min-height: 52px;
  border-bottom: 1px solid var(--border);
}
.cp-input-glyph { color: var(--text-muted); font-size: 15px; flex-shrink: 0; }
.cp-input {
  flex: 1; min-width: 0; height: 50px;
  border: 0; outline: 0; background: transparent;
  color: var(--text-primary); font: inherit; font-size: 15px;
}
.cp-input:hover, .cp-input:focus { border: 0; background: transparent; }
.cp-input::placeholder { color: var(--text-faint); }
.cp-crumb {
  flex-shrink: 1; min-width: 0; max-width: 200px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  font-size: 11px; padding: 3px 8px; border-radius: var(--radius-sm);
  border: 1px solid color-mix(in oklab, var(--accent) 35%, var(--border));
  background: color-mix(in oklab, var(--accent) 12%, var(--surface-2));
  color: var(--accent-text); cursor: pointer;
}
.cp-crumb:hover { background: color-mix(in oklab, var(--accent) 20%, var(--surface-2)); }
.cp-esc {
  flex-shrink: 0; font-size: 10px; letter-spacing: 0.04em;
  padding: 3px 6px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface-2);
  color: var(--text-muted); cursor: pointer;
}
.cp-esc:hover { color: var(--text-primary); }

.cp-list { overflow-y: auto; padding: 6px; flex: 1; overscroll-behavior: contain; }
.cp-group + .cp-group { margin-top: 4px; padding-top: 4px; border-top: 1px solid var(--border); }
.cp-group-head {
  display: flex; justify-content: space-between; align-items: baseline;
  font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase;
  color: var(--text-muted); padding: 8px 10px 4px;
}
.cp-more { color: var(--text-faint); text-transform: none; letter-spacing: 0; }

.cp-row {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  min-height: 42px; padding: 6px 8px 6px 10px;
  border-radius: var(--radius); cursor: pointer;
}
.cp-row.hi { background: var(--surface-3); }
.cp-row.hi::before {
  content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 2px;
  border-radius: 2px; background: var(--accent);
}
.cp-row.muted .cp-row-label { color: var(--text-secondary); }
.cp-row-glyph {
  width: 22px; height: 22px; flex-shrink: 0;
  display: grid; place-items: center;
  font-size: 12px; color: var(--text-muted);
  background: var(--surface-2); border: 1px solid var(--border); border-radius: var(--radius-sm);
}
.cp-row.hi .cp-row-glyph { color: var(--accent-text); border-color: color-mix(in oklab, var(--accent) 40%, var(--border)); }
.cp-row-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.cp-row-label {
  font-size: 13.5px; color: var(--text-primary);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cp-row-sub {
  font-size: 11.5px; color: var(--text-muted);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cp-tag {
  display: inline-block; margin-right: 8px;
  font-size: 9.5px; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 3px; vertical-align: 1px;
  color: var(--accent-text); background: color-mix(in oklab, var(--accent) 14%, transparent);
}
.cp-badge {
  flex-shrink: 0; display: inline-flex; align-items: center; gap: 5px;
  font-size: 10px; color: var(--text-secondary); text-transform: capitalize;
  padding: 2px 6px; border: 1px solid var(--border); border-radius: 999px;
}
.cp-badge.write { color: var(--green); border-color: color-mix(in oklab, var(--green) 35%, var(--border)); text-transform: none; }
.cp-badge-dot { width: 6px; height: 6px; border-radius: 50%; }
.cp-row-more {
  flex-shrink: 0; min-width: 28px; height: 26px; padding: 0 6px;
  font-size: 10px; color: var(--text-faint);
  border: 1px solid transparent; background: transparent; border-radius: var(--radius-sm); cursor: pointer;
}
.cp-row.hi .cp-row-more { color: var(--text-secondary); border-color: var(--border); background: var(--surface-2); }
.cp-row-more:hover { color: var(--text-primary); }
.cp-empty { padding: 18px 12px; font-size: 13px; color: var(--text-muted); }

.cp-confirm { padding: 22px 20px 18px; }
.cp-confirm-title { font-size: 16px; font-weight: 600; margin-bottom: 10px; }
.cp-confirm-lines { list-style: none; margin: 0 0 12px; padding: 0; font-size: 12px; color: var(--text-secondary); display: grid; gap: 4px; }
.cp-confirm-note { font-size: 12px; color: var(--text-muted); margin-bottom: 18px; }
.cp-confirm-actions { display: flex; justify-content: flex-end; gap: 8px; }

.cp-btn {
  display: inline-flex; align-items: center; gap: 8px;
  height: 34px; padding: 0 14px; border-radius: var(--radius);
  font: inherit; font-size: 13px; cursor: pointer;
  border: 1px solid var(--border); background: var(--surface-2); color: var(--text-primary);
}
.cp-btn .mono { font-size: 10px; opacity: 0.7; }
.cp-btn.ghost:hover { background: var(--surface-3); }
.cp-btn.primary {
  background: var(--accent); border-color: var(--accent);
  color: oklch(0.2 0.02 60); font-weight: 600;
}
.cp-btn.primary:hover { filter: brightness(1.06); }
.cp-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.cp-foot {
  display: flex; justify-content: space-between; gap: 12px;
  font-size: 10px; color: var(--text-faint);
  padding: 8px 14px; border-top: 1px solid var(--border); background: var(--bg-rail);
}

@media (pointer: coarse) {
  .cp-row { min-height: 50px; }
  .cp-row-more { min-width: 44px; height: 36px; }
}
@media (max-width: 560px) {
  .cp-overlay { padding-top: 16px; }
  .cp-panel { max-height: calc(100vh - 32px); }
  .cp-badge { display: none; }
  .cp-foot > span:first-child { display: none; }
}

/* Anchored: the panel sits exactly over the top-bar search box (command-palette.jsx
   passes its position), so searching happens where the box is. No dimming. */
.cp-overlay--anchored { background: none; backdrop-filter: none; display: block; padding: 0; animation: none; }
.cp-overlay--anchored .cp-panel {
  position: fixed;
  border-color: var(--accent);
  box-shadow: 0 14px 36px rgba(0,0,0,0.28);
  animation: cp-fade 100ms ease-out;
}
.cp-overlay--anchored .cp-input-row { min-height: 32px; padding: 0 8px 0 10px; }
.cp-overlay--anchored .cp-input { height: 32px; font-size: 13px; }
.cp-overlay--anchored .cp-input-glyph { font-size: 14px; }

/* ─── Top-bar trigger ─────────────────────────────────────────────── */
/* Same box as the old search field (.topbar-search), as a button. */
.cp-trigger { cursor: pointer; font: inherit; color: var(--text-muted); text-align: left; }
.cp-trigger:hover { border-color: var(--border-strong); background: var(--surface-2); }
.cp-trigger:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.cp-trigger-text { flex: 1; min-width: 0; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 560px) { .cp-trigger .kbd { display: none; } }

/* ─── Undo toast ──────────────────────────────────────────────────── */
.cp-toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 600;
  display: flex; align-items: center; gap: 12px; width: max-content; max-width: calc(100vw - 32px);
  padding: 8px 8px 8px 14px; font-size: 13px; color: var(--text-primary);
  background: var(--surface-3); border: 1px solid var(--border-strong); border-radius: var(--radius-lg);
  box-shadow: 0 12px 32px rgba(0,0,0,0.35);
  animation: cp-rise 160ms ease-out;
}
.cp-toast-mark { color: var(--green); }
.cp-toast-undo {
  font: inherit; font-size: 12px; font-weight: 600; cursor: pointer;
  color: var(--accent-text); background: transparent; border: 1px solid var(--border); border-radius: var(--radius);
  padding: 4px 10px;
}
.cp-toast-undo:hover { background: var(--surface-2); }

@media (prefers-reduced-motion: reduce) {
  .cp-overlay, .cp-panel, .cp-toast { animation: none; }
}
