/* =========================================================
   Life OS — items.css
   To-dos, notes, the note editor, small menus and messages.
   ========================================================= */

/* ---------- Sections ---------- */
.section { margin-top: 36px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.section-title {
  font-size: 1.1rem; font-weight: 600; margin: 0 0 8px; padding-bottom: 6px;
  border-bottom: 1px solid var(--border); flex: 1;
}
.section-head .section-title { margin-bottom: 8px; }
.section-count { font-size: 0.8rem; font-weight: 400; color: var(--text-faint); margin-left: 6px; }

.empty-state {
  color: var(--text-faint); font-size: 0.9rem; padding: 10px 8px;
}

.btn-small { display: inline-flex; align-items: center; gap: 4px; font-size: 0.8rem; padding: 3px 9px; margin-bottom: 8px; }
.btn-small .icon svg { width: 14px; height: 14px; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- Sidebar badge ---------- */
.sb-badge {
  margin-left: auto; font-size: 0.7rem; font-weight: 600; line-height: 1;
  padding: 3px 6px; border-radius: 999px; background: var(--hover); color: var(--text-muted);
}
.sb-badge[hidden] { display: none; }
@media (min-width: 769px) { html.sidebar-compact .sb-badge { display: none; } }

/* ---------- New to-do line ---------- */
.task-add {
  display: flex; align-items: center; gap: 10px; padding: 4px 6px; border-radius: var(--radius);
  color: var(--text-faint); cursor: text;
}
.task-add:hover { background: var(--hover); }
.task-add-plus { width: 18px; display: inline-flex; justify-content: center; color: var(--text-faint); }
.task-add-plus svg { width: 16px; height: 16px; }
.task-add-input {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 3px 0;
  font-size: 0.95rem; color: var(--text);
}
.task-add-input::placeholder { color: var(--text-faint); }

/* ---------- To-do row ---------- */
.task-row {
  display: flex; align-items: center; gap: 10px; padding: 3px 6px; border-radius: var(--radius);
  transition: background-color var(--dur);
  animation: pageIn 0.2s var(--ease) both;
}
.task-row:hover, .task-row:focus-within { background: var(--hover); }

.task-check {
  flex: 0 0 auto; width: 18px; height: 18px; padding: 0; border-radius: 50%;
  border: 1.5px solid var(--text-faint); background: transparent; color: transparent;
  display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background-color var(--dur), border-color var(--dur), color var(--dur);
}
.task-check svg { width: 12px; height: 12px; stroke-width: 3; }
.task-check:hover { border-color: var(--accent); color: var(--accent); }
.task-row.done .task-check { background: var(--accent); border-color: var(--accent); color: #fff; }

.task-title {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent;
  font-size: 0.95rem; padding: 4px 0; color: var(--text); text-overflow: ellipsis;
}
.task-row.done .task-title { color: var(--text-faint); text-decoration: line-through; }

.task-chips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 4px; flex: 0 1 auto; }
.chip {
  font-size: 0.72rem; line-height: 1; padding: 4px 7px; border-radius: 4px; white-space: nowrap;
  background: var(--hover); color: var(--text-muted); text-decoration: none;
}
a.chip:hover { color: var(--text); background: var(--active); }
.chip-today { color: var(--accent); background: var(--accent-soft); }
.chip-overdue { color: var(--danger); background: color-mix(in srgb, var(--danger) 12%, transparent); }
.chip-high { color: #d9363e; background: color-mix(in srgb, #e5484d 13%, transparent); }
.chip-medium { color: #c76a1c; background: color-mix(in srgb, #e8833a 15%, transparent); }
.chip-low { color: #2f6fca; background: color-mix(in srgb, #2f80ed 13%, transparent); }
:root[data-theme="dark"] .chip-high { color: #ff8589; }
:root[data-theme="dark"] .chip-medium { color: #f3a568; }
:root[data-theme="dark"] .chip-low { color: #7fb0f5; }
.chip-star { color: #d4a106; background: color-mix(in srgb, #f5c518 16%, transparent); }

.task-more, .note-more { opacity: 0; width: 26px; height: 26px; }
.task-row:hover .task-more, .task-row:focus-within .task-more, .task-more:focus-visible,
.note-row:hover .note-more, .note-more:focus-visible { opacity: 1; }
@media (hover: none) { .task-more, .note-more { opacity: 1; } }

.completed-toggle {
  border: 0; background: transparent; cursor: pointer; color: var(--text-muted);
  font-size: 0.82rem; padding: 8px 6px 4px; border-radius: var(--radius);
}
.completed-toggle:hover { color: var(--text); }

/* ---------- Notes list ---------- */
.new-note-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: transparent; cursor: pointer; color: var(--text-faint);
  padding: 7px 6px; border-radius: var(--radius); font-size: 0.95rem;
}
.new-note-btn:hover { background: var(--hover); color: var(--text-muted); }

.note-row {
  display: flex; align-items: center; gap: 10px; padding: 7px 6px; border-radius: var(--radius);
  text-decoration: none; color: var(--text); transition: background-color var(--dur);
  animation: pageIn 0.2s var(--ease) both;
}
.note-row:hover { background: var(--hover); }
.note-row-icon { color: var(--text-faint); display: inline-flex; width: 18px; justify-content: center; }
.note-row-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.note-row-title { font-size: 0.95rem; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-row-title.untitled { color: var(--text-faint); }
.note-row-snippet { font-size: 0.8rem; color: var(--text-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.note-row-date { font-size: 0.75rem; color: var(--text-faint); white-space: nowrap; }

/* ---------- Note editor ---------- */
.note-topbar { display: flex; align-items: center; justify-content: space-between; margin: -24px 0 20px; }
.back-link { font-size: 0.85rem; color: var(--text-muted); text-decoration: none; padding: 3px 6px; margin-left: -6px; border-radius: var(--radius); }
.back-link:hover { background: var(--hover); color: var(--text); }

.note-title { outline: none; word-break: break-word; }
.note-title:empty::before { content: attr(data-placeholder); color: var(--text-faint); }

.blocks { margin-top: 18px; }
.block { display: flex; align-items: flex-start; gap: 8px; padding: 2px 0; }
.block-text {
  flex: 1; min-width: 0; outline: none; white-space: pre-wrap; word-break: break-word;
  min-height: 1.6em; line-height: 1.6; padding: 1px 2px;
}
.block-text:empty:focus::before,
.blocks.single-empty .block-text:empty::before {
  content: attr(data-placeholder); color: var(--text-faint); pointer-events: none;
}
.type-heading { margin-top: 0.9em; }
.type-heading .block-text { font-size: 1.45rem; font-weight: 600; line-height: 1.35; }
.block-dot { width: 18px; flex: 0 0 18px; text-align: center; line-height: 1.6; padding-top: 1px; color: var(--text-muted); }
.block-check { margin: 0.45em 2px 0; width: 15px; height: 15px; accent-color: var(--accent); cursor: pointer; flex: 0 0 auto; }
.block.checked .block-text { color: var(--text-faint); text-decoration: line-through; }
.blocks-tail { min-height: 120px; cursor: text; }

/* ---------- Small menus (popovers) ---------- */
.popover {
  position: fixed; z-index: 60; min-width: 230px; max-width: calc(100vw - 16px);
  max-height: calc(100vh - 16px); overflow-y: auto;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px; box-shadow: var(--shadow);
  animation: popIn 0.14s var(--ease) both;
}
@keyframes popIn { from { opacity: 0; transform: translateY(-4px) scale(0.98); } to { opacity: 1; transform: none; } }

.pop-menu { padding: 8px; width: 260px; display: flex; flex-direction: column; gap: 8px; }
.pop-field { display: flex; flex-direction: column; gap: 4px; }
.pop-label { font-size: 0.72rem; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.05em; }
.pop-inline { display: flex; align-items: center; gap: 8px; }
.pop-input, .pop-select {
  width: 100%; font-size: 0.86rem; padding: 5px 8px;
  border: 1px solid var(--border); border-radius: var(--radius); background: var(--panel); color: var(--text);
}
.pop-inline .pop-input { flex: 1; }
.pop-clear { font-size: 0.8rem; }
.pop-divider { height: 1px; background: var(--border); margin: 2px -8px; }

.seg { display: flex; border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.seg-btn {
  flex: 1; border: 0; background: transparent; cursor: pointer; font-size: 0.78rem; padding: 5px 4px;
  color: var(--text-muted); border-right: 1px solid var(--border);
}
.seg-btn:last-child { border-right: 0; }
.seg-btn:hover { background: var(--hover); }
.seg-btn.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }

.pop-action {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  border: 0; background: transparent; cursor: pointer; font-size: 0.86rem;
  padding: 6px 8px; border-radius: var(--radius); color: var(--text);
}
.pop-action:hover:not(:disabled) { background: var(--hover); }
.pop-action:disabled { color: var(--text-faint); cursor: default; }
.pop-action .icon svg { width: 16px; height: 16px; }
.pop-danger { color: var(--danger); }

/* Picker for Today's top 3 */
.picker { width: 300px; }
.picker-list { display: flex; flex-direction: column; max-height: 280px; overflow-y: auto; }
.picker-item {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; text-align: left;
  border: 0; background: transparent; cursor: pointer; padding: 6px 8px; border-radius: var(--radius);
  font-size: 0.88rem; color: var(--text);
}
.picker-item:hover, .picker-item:focus-visible { background: var(--hover); }
.picker-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker-place { font-size: 0.75rem; color: var(--text-faint); white-space: nowrap; }
.picker-empty { font-size: 0.85rem; color: var(--text-faint); padding: 8px; }

/* ---------- Messages ---------- */
.toast-root {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 70;
  display: flex; justify-content: center; pointer-events: none; width: max-content; max-width: calc(100vw - 24px);
}
.toast {
  pointer-events: auto; display: flex; align-items: center; gap: 12px;
  background: #2f2f2f; color: #f1f1ef; border-radius: 8px; padding: 8px 8px 8px 14px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25); font-size: 0.88rem;
  animation: toastIn 0.22s var(--ease) both;
}
:root[data-theme="dark"] .toast { background: #3a3a3a; }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.toast-action {
  border: 0; background: transparent; color: #8ab8ff; font-weight: 600; cursor: pointer;
  padding: 4px 8px; border-radius: 4px; font-size: 0.88rem;
}
.toast-action:hover { background: rgba(255, 255, 255, 0.1); }
.toast-close { border: 0; background: transparent; color: #aaa; cursor: pointer; display: inline-flex; padding: 4px; border-radius: 4px; }
.toast-close:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.toast-close svg { width: 14px; height: 14px; }

.banner {
  position: fixed; top: 10px; left: 12px; right: 12px; margin: 0 auto; z-index: 80;
  display: flex; align-items: center; gap: 10px; width: fit-content; max-width: 640px;
  background: var(--danger); color: #fff; border-radius: 8px; padding: 8px 8px 8px 14px;
  box-shadow: var(--shadow); font-size: 0.88rem; animation: toastIn 0.22s var(--ease) both;
}
.banner .icon-btn { color: #fff; }
.banner .icon-btn:hover { background: rgba(255, 255, 255, 0.18); color: #fff; }

/* ---------- Page heading with + and pin ---------- */
.page-heading { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.page-heading .page-title { margin-bottom: 6px; }
.page-actions { display: flex; align-items: center; gap: 6px; }
.page-heading .page-actions { margin-left: auto; }
.pin-btn {
  display: inline-flex; align-items: center; gap: 5px; height: 28px; padding: 0 10px;
  border: 1px solid var(--border); border-radius: 999px; background: transparent; cursor: pointer;
  font-size: 0.78rem; color: var(--text-muted); white-space: nowrap;
  transition: background-color var(--dur), color var(--dur), border-color var(--dur);
}
.pin-btn .icon svg { width: 14px; height: 14px; }
.pin-btn:hover { background: var(--hover); color: var(--text); }
.pin-btn.on { color: var(--accent); border-color: color-mix(in srgb, var(--accent) 45%, transparent); background: var(--accent-soft); }

/* Sidebar + (shows on hover) */
.sb-plus { width: 22px; height: 22px; margin-left: auto; opacity: 0; flex: 0 0 auto; }
.sb-plus .icon svg { width: 14px; height: 14px; }
.sb-badge + .sb-plus { margin-left: 4px; }
.sb-item:hover .sb-plus, .sb-plus:focus-visible { opacity: 1; }
@media (hover: none) { .sb-plus { opacity: 0.7; } }
@media (min-width: 769px) { html.sidebar-compact .sb-plus { display: none; } }

/* Sidebar: Modules heading +, module ⋯, new-module field, dragging */
.sb-heading { display: flex; align-items: center; justify-content: space-between; }
.sb-heading-plus { width: 20px; height: 20px; opacity: 0.35; }
.sb-heading-plus .icon svg { width: 13px; height: 13px; }
.sb-heading:hover .sb-heading-plus, .sb-heading-plus:focus-visible { opacity: 1; }
.sb-more { width: 22px; height: 22px; opacity: 0; flex: 0 0 auto; margin-left: 2px; }
.sb-more .icon svg { width: 14px; height: 14px; }
.sb-item:hover .sb-more, .sb-more:focus-visible { opacity: 1; }
@media (hover: none) { .sb-more { opacity: 0.7; } .sb-heading-plus { opacity: 0.8; } }
@media (min-width: 769px) {
  html.sidebar-compact .sb-more, html.sidebar-compact .sb-heading-plus, html.sidebar-compact .sb-new-module { display: none; }
}
.sb-new-module { display: flex; align-items: center; gap: 10px; padding: 3px 8px; margin: 2px 0; }
.sb-new-module input {
  flex: 1; min-width: 0; font-size: 0.88rem; padding: 4px 6px;
  border: 1px solid var(--accent); border-radius: var(--radius); background: var(--panel); color: var(--text); outline: none;
}
.sb-item.dragging { opacity: 0.4; }
.sb-item.drop-target { box-shadow: inset 0 2px 0 var(--accent); }

/* Module menu */
.module-menu { width: 280px; }
.icon-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; margin-bottom: 6px; }
.icon-choice {
  border: 0; background: transparent; cursor: pointer; font-size: 1.05rem; line-height: 1;
  padding: 5px 0; border-radius: var(--radius);
}
.icon-choice:hover { background: var(--hover); }
.icon-choice.active { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.swatches-left { justify-content: flex-start; }
.pop-row { display: flex; gap: 4px; }
.pop-row .pop-action { flex: 1; }

/* Plus menu */
.plus-menu { width: 240px; gap: 4px; }
.plus-list { display: flex; flex-direction: column; }
.plus-item {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  border: 0; background: transparent; cursor: pointer; padding: 6px 8px; border-radius: var(--radius); color: var(--text);
}
.plus-item:hover, .plus-item:focus-visible { background: var(--hover); outline: none; }
.plus-icon { font-size: 1.15rem; width: 26px; text-align: center; }
.plus-text { display: flex; flex-direction: column; }
.plus-label { font-size: 0.9rem; }
.plus-hint { font-size: 0.75rem; color: var(--text-faint); }

.note-row-pin { display: inline-flex; margin-left: 6px; color: var(--accent); vertical-align: -2px; }
.note-row-pin svg { width: 12px; height: 12px; }
.checklist-progress { font-size: 0.85rem; color: var(--text-muted); margin-top: 2px; }

/* ---------- Projects ---------- */
.proj-header { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; margin: 10px 0 4px; }
.proj-status-row { display: flex; align-items: center; gap: 8px; font-size: 0.85rem; color: var(--text-muted); }
.proj-select { width: auto; }
.proj-progress { display: inline-flex; align-items: center; gap: 8px; font-size: 0.78rem; color: var(--text-muted); }
.proj-bar { display: inline-block; width: 80px; height: 6px; border-radius: 999px; background: var(--hover); overflow: hidden; box-shadow: inset 0 0 0 1px var(--border); }
.proj-bar-fill { display: block; height: 100%; background: var(--accent); border-radius: 999px; transition: width 0.3s var(--ease); }
.proj-row .note-row-text { gap: 3px; }
.proj-status { white-space: nowrap; }
.proj-status.st-active { color: var(--accent); background: var(--accent-soft); }
.proj-status.st-done { color: #1f8a57; background: color-mix(in srgb, #22a06b 15%, transparent); }
.proj-status.st-onhold { color: #b8650f; background: color-mix(in srgb, #e8833a 16%, transparent); }
.project-notes-title { margin-top: 30px; }

/* "+" beside each note line */
.block-plus {
  flex: 0 0 auto; width: 18px; height: 18px; margin-left: -46px; margin-right: 2px; margin-top: 0.15em;
  border: 0; background: transparent; color: var(--text-faint); cursor: pointer; border-radius: 4px; opacity: 0;
  display: inline-flex; align-items: center; justify-content: center; transition: opacity var(--dur), background-color var(--dur);
}
.block-plus .icon svg { width: 14px; height: 14px; }
.block-plus:hover { background: var(--hover); color: var(--text); }
.block:hover .block-plus, .block:focus-within .block-plus, .block-plus:focus-visible { opacity: 1; }
.block .drag-handle { margin-left: 2px; }
.type-heading .block-plus { margin-top: 0.55em; }
@media (hover: none) { .block-plus { display: none; } }
.block-menu { width: 210px; gap: 2px; }

/* ---------- Pinned cards ---------- */
.pin-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.pin-grid > .empty-state { grid-column: 1 / -1; }
.pin-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px 12px;
  min-height: 120px; cursor: pointer; display: flex; flex-direction: column; gap: 6px;
  transition: box-shadow var(--dur), transform var(--dur) var(--ease), border-color var(--dur), opacity var(--dur);
  animation: pageIn 0.22s var(--ease) both;
}
.pin-card:hover { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08); border-color: color-mix(in srgb, var(--text) 18%, transparent); }
.pin-card.dragging { opacity: 0.4; }
.pin-card.drop-target { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.card-head { display: flex; align-items: center; gap: 6px; }
.card-title { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--text); font-weight: 600; font-size: 0.95rem; }
.card-title:hover .card-title-text { text-decoration: underline; text-underline-offset: 2px; }
.card-title-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-icon { font-size: 1.05rem; }
.card-more-btn { width: 24px; height: 24px; opacity: 0; }
.pin-card:hover .card-more-btn, .card-more-btn:focus-visible { opacity: 1; }
@media (hover: none) { .card-more-btn { opacity: 1; } }
.card-body { display: flex; flex-direction: column; gap: 3px; font-size: 0.85rem; color: var(--text-muted); min-width: 0; }
.card-meta { font-size: 0.75rem; color: var(--text-faint); margin-bottom: 2px; }
.card-line { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-heading { font-weight: 600; color: var(--text); }
.card-dot { margin-right: 6px; color: var(--text-faint); }
.card-more { font-size: 0.75rem; color: var(--text-faint); }
.card-check { display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--text); }
.card-check input { accent-color: var(--accent); cursor: pointer; margin: 0; flex: 0 0 auto; }
.card-check span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card-check.checked span { color: var(--text-faint); text-decoration: line-through; }

/* ---------- Phones ---------- */
@media (max-width: 768px) {
  .task-row { flex-wrap: wrap; }
  .task-title { flex: 1 1 50%; }
  .task-more { order: 3; }
  .task-chips { order: 4; width: 100%; justify-content: flex-start; padding-left: 28px; }
  .task-chips:empty { display: none; }
  .note-row-date { display: none; }
  .note-topbar { margin-top: -8px; }
}
