/* Overlays: modals, slide-over editor, command palette, menus, popovers, toasts and the bulk action bar. */

/* ---- Overlay + modal ---- */
.overlay {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  padding: 20px;
  background: rgba(6, 8, 14, .6);
  backdrop-filter: blur(4px);
  opacity: 0; visibility: hidden;
  transition: opacity .24s ease, visibility .24s;
}
html[data-theme="light"] .overlay { background: rgba(30, 40, 80, .35); }
.overlay.show { opacity: 1; visibility: visible; }
.overlay.top { place-items: start center; }
.overlay .modal, .overlay .cmd {
  transform: translateY(16px) scale(.97);
  opacity: 0;
  transition: transform .28s var(--ease), opacity .28s;
}
.overlay.show .modal, .overlay.show .cmd { transform: none; opacity: 1; }
.modal {
  width: 100%; max-width: 520px; max-height: 88vh; overflow: auto;
  padding: 22px;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: var(--r-xl);
  box-shadow: var(--inset-top), var(--shadow-lg);
}
.modal h2 { margin: 0 0 4px; font-size: 19px; letter-spacing: -.01em; }
.modal .hint, .hint { color: var(--muted); font-size: 13px; margin-bottom: 16px; }
.field { margin-bottom: 12px; }
.field label { display: block; font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .06em; color: var(--faint); margin-bottom: 6px; }
.modal .row { margin-bottom: 12px; }
.field-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 6px; }
.field-head label { margin-bottom: 0; }
.modal-actions {
  position: sticky; bottom: -22px; z-index: 2;
  display: flex; gap: 10px; justify-content: flex-end; align-items: center;
  margin: 18px -22px -22px; padding: 14px 22px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-soft);
}
#ask-input { margin-bottom: 4px; }

/* editor slides in from the right */
#editor-overlay { place-items: stretch end; padding: 0; }
#editor-overlay .modal {
  height: 100%; max-height: 100%; max-width: 480px; margin: 0;
  border-radius: var(--r-xl) 0 0 var(--r-xl);
  border-top: none; border-bottom: none; border-right: none;
  transform: translateX(28px);
}
#editor-overlay.show .modal { transform: none; }

/* editor sub-rows */
.subedit { display: flex; align-items: center; gap: 8px; margin-bottom: 6px; }
.subedit input[type="checkbox"] { width: 16px; height: 16px; flex: 0 0 auto; accent-color: var(--low); cursor: pointer; }
.subedit input[type="text"] { flex: 1; width: auto; height: 34px; }
.subedit button { flex: 0 0 auto; }
.att-edit { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.6fr) auto; gap: 6px; margin-bottom: 6px; align-items: center; }
.att-edit input { height: 34px; }
#tags-list { max-height: 46vh; overflow-y: auto; margin: 2px 0; padding-right: 2px; }
.tag-edit { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 8px; align-items: center; margin-bottom: 7px; }
.tag-edit input { height: 34px; }
.tag-edit .tagcount { color: var(--faint); font-size: 12.5px; white-space: nowrap; }

/* ---- Help ---- */
.help-grid { display: grid; gap: 18px; }
.help-sec h3 { margin: 0 0 8px; font-size: 13px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); }
.help-sec ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.help-sec li { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: 14px; }
.help-sec li span:first-child { color: var(--text); }
.help-sec li .keys { display: flex; gap: 6px; }

/* ---- Command palette ---- */
.cmd {
  width: 100%; max-width: 580px; margin-top: 11vh; overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--inset-top), var(--shadow-lg);
}
#cmd-input {
  width: 100%; height: 52px; padding: 0 18px;
  border: none; border-bottom: 1px solid var(--border);
  background: transparent; color: var(--text);
  font: inherit; font-size: 16px; outline: none;
}
.cmd-list { max-height: 54vh; overflow: auto; padding: 6px; }
.cmd-item { display: flex; align-items: center; gap: 12px; min-height: 40px; padding: 0 12px; border-radius: var(--r-md); cursor: pointer; font-size: 14px; }
.cmd-item .ci { width: 22px; text-align: center; font-size: 15px; flex-shrink: 0; }
.cmd-item .cl { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cmd-item .ch { font-size: 11px; color: var(--faint); text-transform: capitalize; }
.cmd-item.sel { background: var(--accent-soft); }
.cmd-item.sel .cl { color: var(--text); }
.cmd-empty { padding: 22px; text-align: center; color: var(--muted); font-size: 13px; }

/* ---- Settings menu ---- */
.menu {
  position: absolute; right: 0; top: calc(100% + 10px); z-index: 60;
  width: 268px; max-height: calc(100vh - 96px); overflow-y: auto; padding: 8px;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--inset-top), var(--shadow-lg);
  transform-origin: top right; transform: translateY(-6px) scale(.97);
  opacity: 0; visibility: hidden;
  transition: transform .2s var(--ease), opacity .2s, visibility .2s;
}
.menu.show { transform: none; opacity: 1; visibility: visible; }
.menu-narrow { width: 300px; }
.menu-narrow .history { padding: 2px 2px 4px; }
.menu-sec + .menu-sec { border-top: 1px solid var(--border-soft); margin-top: 6px; padding-top: 6px; }
.menu-title { font-size: 11px; text-transform: uppercase; letter-spacing: .08em; color: var(--faint); padding: 6px 10px 4px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: var(--h-md);
  padding: 0 10px; border: none; border-radius: var(--r-sm);
  background: none; color: var(--text); font: inherit; font-size: 14px; text-align: left;
  cursor: pointer; transition: background .16s, color .16s;
}
.menu-item:hover { background: var(--panel-2); }
.menu-item.danger:hover { background: rgba(229, 72, 77, .13); color: var(--high); }
.menu-item .mi { width: 18px; height: 18px; flex-shrink: 0; color: var(--muted); }
.menu-item.danger .mi { color: inherit; }
.storage { padding: 2px 10px 8px; }
.storage-bar { height: 7px; background: var(--panel-3); border-radius: 20px; overflow: hidden; }
.storage-bar i { display: block; height: 100%; width: 0; border-radius: 20px; background: var(--accent); transition: width .35s ease; }
.storage-text { font-size: 12px; color: var(--faint); margin-top: 7px; }
.storage-text.warn { color: var(--medium); }

/* ---- Popover (status / card / project menus) ---- */
.pop-backdrop { position: fixed; inset: 0; z-index: 85; background: transparent; }
.pop {
  position: fixed; left: 0; top: 0; z-index: 90;
  min-width: 190px; max-width: min(300px, calc(100vw - 24px)); max-height: 340px; overflow-y: auto; padding: 5px;
  background: var(--panel);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  box-shadow: var(--inset-top), var(--shadow-lg);
  opacity: 0; transform: translateY(-4px) scale(.97); transform-origin: top left;
  transition: transform .16s var(--ease), opacity .16s;
}
.pop.show { opacity: 1; transform: none; }
.pop-title { font-size: 11px; text-transform: uppercase; letter-spacing: .07em; color: var(--faint); padding: 6px 10px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pop-item {
  display: flex; align-items: center; gap: 9px; width: 100%; min-height: 34px;
  padding: 0 10px; border: none; border-radius: var(--r-sm);
  background: none; color: var(--text); font: inherit; font-size: 13.5px; text-align: left; white-space: nowrap;
  cursor: pointer; transition: background .14s, color .14s;
}
.pop-item:hover, .pop-item:focus-visible { background: var(--panel-2); outline: none; }
.pop-item.on { color: var(--accent); font-weight: 600; }
.pop-item.danger { color: var(--high); }
.pop-item.danger:hover { background: rgba(229, 72, 77, .13); }
.pop-sep { height: 1px; background: var(--border-soft); margin: 5px 6px; }
.pop-swatches { display: grid; grid-template-columns: repeat(4, 28px); gap: 8px; padding: 8px 10px 10px; }
.pop-swatches button { width: 28px; height: 28px; padding: 0; border-radius: var(--r-sm); border: 2px solid transparent; cursor: pointer; transition: transform .15s, box-shadow .15s, border-color .15s; }
.pop-swatches button:hover { transform: scale(1.12); }
.pop-swatches button.on { border-color: var(--text); box-shadow: 0 0 0 4px var(--panel-3); }

/* ---- Toasts ---- */
.toast-wrap { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 80; pointer-events: none; }
.toast {
  pointer-events: auto; max-width: 90vw;
  display: flex; align-items: center; gap: 12px;
  padding: 8px 10px 8px 14px; min-height: 44px;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--border-2);
  border-radius: var(--r-md);
  box-shadow: var(--inset-top), var(--shadow-lg);
  font-size: 14px;
  animation: toastIn .32s var(--ease);
}
.toast.out { animation: toastOut .25s ease forwards; }
@keyframes toastIn { from { opacity: 0; transform: translateY(16px) scale(.96); } to { opacity: 1; transform: none; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(10px) scale(.97); } }
.toast button {
  height: var(--h-sm); padding: 0 11px;
  background: var(--panel-2); border: 1px solid var(--border); border-radius: var(--r-xs);
  color: var(--accent); font-size: 12.5px; font-weight: 600;
}
.toast button:hover { border-color: var(--accent); }
.toast button.toast-close { width: var(--h-sm); padding: 0; background: none; border-color: transparent; color: var(--faint); font-size: 18px; line-height: 1; font-weight: 400; }
.toast button.toast-close:hover { color: var(--text); background: var(--panel-2); border-color: transparent; }

/* ---- Bulk action bar ---- */
.bulkbar {
  position: sticky; bottom: 16px; z-index: 40;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  margin-top: 14px; padding: 10px 12px;
  background: color-mix(in srgb, var(--panel) 94%, transparent);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-2);
  border-radius: var(--r-lg);
  box-shadow: var(--inset-top), var(--shadow-lg);
}
#bulk-count { font-size: 13px; font-weight: 600; padding: 0 8px; }
