/* =========================================================
   Life OS — tools.css
   Search, Quick add, tags, drag handles, backup section.
   ========================================================= */

/* ---------- Centered box (Search, Quick add) ---------- */
.overlay-root { position: fixed; inset: 0; z-index: 65; }
.overlay-backdrop { position: absolute; inset: 0; background: var(--backdrop); opacity: 0; transition: opacity 0.16s var(--ease); }
.overlay-box {
  position: absolute; left: 50%; top: 12vh; transform: translate(-50%, -8px);
  width: min(600px, calc(100vw - 24px)); max-height: 72vh; display: flex; flex-direction: column;
  background: var(--panel); border: 1px solid var(--border); border-radius: 12px; box-shadow: var(--shadow);
  opacity: 0; transition: opacity 0.16s var(--ease), transform 0.16s var(--ease); overflow: hidden;
}
.overlay-root.open .overlay-backdrop { opacity: 1; }
.overlay-root.open .overlay-box { opacity: 1; transform: translate(-50%, 0); }

.search-box { display: flex; flex-direction: column; min-height: 0; }
.search-input {
  width: 100%; border: 0; border-bottom: 1px solid var(--border); outline: none; background: transparent;
  font-size: 1.05rem; padding: 14px 16px; color: var(--text);
}
.search-results { overflow-y: auto; padding: 6px; min-height: 0; }
.search-hint { font-size: 0.82rem; color: var(--text-faint); padding: 10px 12px; }
.search-group { font-size: 0.7rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: var(--text-faint); padding: 10px 10px 4px; }
.search-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: transparent; border-radius: var(--radius); padding: 7px 10px; cursor: pointer; color: var(--text);
}
.search-item.active { background: var(--hover); }
.search-icon { width: 22px; text-align: center; flex: 0 0 auto; color: var(--text-muted); }
.search-text { display: flex; flex-direction: column; min-width: 0; }
.search-title { font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-sub { font-size: 0.75rem; color: var(--text-faint); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.quick-box { padding-bottom: 6px; }
.quick-title { font-size: 0.8rem; font-weight: 600; color: var(--text-muted); padding: 12px 16px 0; }
.quick-box .search-input { border-bottom: 0; padding-top: 8px; }
.quick-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; padding: 4px 16px 8px; }
.quick-kind { width: auto; flex: 0 0 auto; }
.quick-kind .seg-btn { padding: 5px 12px; white-space: nowrap; }
.quick-where { display: flex; align-items: center; gap: 6px; font-size: 0.85rem; color: var(--text-muted); flex: 1; min-width: 160px; }
.quick-where .pop-select { width: auto; flex: 1; }
.quick-row .btn-small { margin: 0; }
.quick-box .pop-error { padding: 0 16px; }
.quick-box .search-hint { padding: 2px 16px 6px; }

/* ---------- Tags ---------- */
.tag-chips { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.tag-chip {
  font-size: 0.72rem; line-height: 1; padding: 4px 7px; border-radius: 4px; text-decoration: none;
  color: var(--accent); background: var(--accent-soft);
}
.tag-chip:hover { text-decoration: underline; }
.note-tags { margin: 4px 0 0; min-height: 0; }
.tag-hero { font-weight: 700; color: var(--accent); }
.tag-events { display: flex; flex-direction: column; }
.tag-event {
  display: flex; align-items: center; gap: 6px; text-align: left; border: 0; background: transparent; cursor: pointer;
  padding: 7px 6px; border-radius: var(--radius); font-size: 0.95rem; color: var(--text);
}
.tag-event:hover { background: var(--hover); }

/* ---------- Drag handles ---------- */
.drag-handle {
  flex: 0 0 auto; width: 20px; margin-left: -24px; margin-right: 4px; text-align: center; border-radius: 4px;
  font-size: 0.95rem; letter-spacing: -2px; color: var(--text-faint); cursor: grab; opacity: 0;
  user-select: none; transition: opacity var(--dur);
}
.drag-handle:active { cursor: grabbing; }
.drag-handle:hover { background: var(--hover); color: var(--text); }
.task-row:hover .drag-handle, .note-row:hover .drag-handle, .block:hover .drag-handle { opacity: 1; }
.drag-handle { touch-action: none; }   /* on phones, the grip drags right away instead of scrolling */
@media (hover: none) {
  .task-row .drag-handle, .note-row .drag-handle { display: none; }   /* phones: press and hold the row */
  .block .drag-handle { opacity: 0.45; }                             /* note lines: use the grip */
}
.block .drag-handle { line-height: 1.6; padding-top: 2px; }
.type-heading .drag-handle { line-height: 1.35; padding-top: 0.5em; }
.dragging { opacity: 0.35; }
.drop-before { box-shadow: inset 0 2px 0 var(--accent); }
.drop-after { box-shadow: inset 0 -2px 0 var(--accent); }
.task-row.can-drag, .note-row { -webkit-touch-callout: none; }

/* While dragging: a floating copy follows the mouse/finger */
html.is-dragging, html.is-dragging * { cursor: grabbing !important; user-select: none !important; -webkit-user-select: none !important; }
.drag-ghost {
  position: fixed; left: 0; top: 0; z-index: 200; pointer-events: none; margin: 0;
  background: var(--panel); border-radius: 8px; box-shadow: var(--shadow); opacity: 0.95;
  rotate: 1deg;
}
.drag-ghost .drag-handle { opacity: 1; }
/* Places you can drop onto (sidebar modules, Inbox, calendar days, Today's top 3) */
[data-drop].drop-hover {
  outline: 2px dashed var(--accent); outline-offset: -2px; border-radius: 8px;
  background: color-mix(in srgb, var(--accent) 12%, transparent) !important;
}
html.is-dragging .sb-item[data-drop] { transition: background-color 0.1s; }

/* Highlight when Search opens a to-do */
@keyframes flash { 0%, 100% { background: transparent; } 30% { background: var(--accent-soft); } }
.flash { animation: flash 1.5s var(--ease); }

/* ---------- Backup section in Settings ---------- */
.set-backup .set-hint { margin-top: 0; }
.set-msg { font-size: 0.8rem; color: var(--text-muted); padding: 4px 0; }
.set-msg:empty { display: none; }
.set-msg.error { color: var(--danger); }
.set-confirm-actions.wrap { flex-wrap: wrap; }
.set-check { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; margin: 2px 0 6px; cursor: pointer; }
.set-check input { accent-color: var(--accent); margin: 0; }
.set-check .set-hint { display: inline; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* ---------- Header on small phones: stack date over time ---------- */
@media (max-width: 420px) {
  .clock { flex-direction: column; align-items: flex-end; gap: 0; line-height: 1.15; font-size: 0.72rem; }
  .header-right { gap: 2px; }
  .header-right .icon-btn { width: 28px; }
}
