/* Reusable pieces: buttons, chips, cards, boxes, tags, overlays. */
/* ---------- common ---------- */
.page-head { display: flex; align-items: flex-end; gap: 16px; flex-wrap: wrap; margin: 4px 0 18px; }
.page-head h1 { font-size: var(--font-size-3xl); font-weight: var(--font-weight-bold); margin: 0; letter-spacing: .01em; }
.page-head .sub { color: var(--muted); font-size: var(--font-size-md); padding-bottom: 3px; }
.crumbs { font-size: var(--font-size-sm); color: var(--muted); margin-bottom: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.crumbs a:hover { color: var(--accent-text); }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin: 0 0 22px; }
.chip { border: 1px solid var(--border); background: var(--surface); padding: 6px 14px; border-radius: var(--radius-pill); cursor: pointer;
  font-size: var(--font-size-md); white-space: nowrap; color: var(--text); }
.chip:hover { border-color: var(--faint); }
.chip.active { background: var(--text); color: var(--bg); border-color: var(--text); }
.chip .n { color: var(--faint); margin-left: 4px; font-size: var(--font-size-xs); }
.chip.active .n { color: inherit; opacity: .7; }
.spacer { flex: 1; }
select.sort { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: var(--radius-pill); padding: 6px 12px; font: inherit; font-size: var(--font-size-md); }
.empty { color: var(--muted); padding: 60px 0; text-align: center; line-height: 1.9; }
.loading { color: var(--muted); padding: 80px 0; text-align: center; }
.btn { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  padding: 8px 16px; border-radius: var(--radius-pill); cursor: pointer; font-size: var(--font-size-md); }
.btn:hover { border-color: var(--faint); }
.btn svg { width: 18px; height: 18px; }
.btn.on { background: var(--accent-soft); color: var(--accent-text); border-color: transparent; }
.btn.on svg { fill: currentColor; }
.btn.small { padding: 5px 12px; font-size: var(--font-size-sm); }
.btn.ghost { border-color: transparent; background: none; color: var(--muted); }
.btn.ghost:hover { color: var(--text); background: var(--surface-2); }

/* ---------- cards ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(var(--card-min), 1fr)); gap: 28px 20px; }
.card { display: block; min-width: 0; cursor: pointer; }
.thumb { position: relative; aspect-ratio: 16 / 9; border-radius: var(--radius-lg); overflow: hidden; background: var(--surface-2); }
.thumb img { width: 100%; height: 100%; object-fit: cover; transition: transform var(--motion-slow) ease; }
.card:hover .thumb img { transform: scale(1.035); }
.thumb.portrait img { object-fit: contain; background: var(--surface-2); }
.badge { position: absolute; right: 8px; bottom: 8px; background: var(--badge-bg); color: var(--on-media); font-size: var(--font-size-xs); font-weight: var(--font-weight-semibold);
  padding: 3px 7px; border-radius: var(--radius-xs); font-variant-numeric: tabular-nums; letter-spacing: .02em; display: flex; gap: 5px; align-items: center; }
.badge svg { width: 13px; height: 13px; stroke-width: 2.2; }
.fav-dot { position: absolute; left: 8px; top: 8px; width: 28px; height: 28px; border-radius: 50%; background: var(--badge-bg); color: var(--favorite);
  display: grid; place-items: center; }
.fav-dot svg { width: 15px; height: 15px; fill: currentColor; stroke: none; }
.card-body { display: flex; gap: 10px; padding: 12px 2px 0; }
.card-title { font-size: var(--font-size-base); font-weight: var(--font-weight-semibold); line-height: 1.45; margin: 0 0 4px; display: -webkit-box; -webkit-line-clamp: 2;
  -webkit-box-orient: vertical; overflow: hidden; }
.card-meta { font-size: var(--font-size-sm); color: var(--muted); line-height: 1.5; }
.card-meta .dot::before { content: "·"; margin: 0 5px; }
.ph { width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: flex-end; padding: 16px; gap: 6px;
  background: linear-gradient(135deg, var(--placeholder-from), var(--placeholder-to)); color: var(--placeholder-text); }
.ph svg { width: 26px; height: 26px; opacity: .55; }
.ph .ph-title { font-weight: var(--font-weight-bold); font-size: var(--font-size-base); line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }

.box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 18px 22px; margin: 16px 0; }
.box h3 { margin: 0 0 10px; font-size: var(--font-size-base); font-weight: var(--font-weight-bold); display: flex; align-items: center; gap: 8px; }
.box h3 svg { width: 18px; height: 18px; color: var(--muted); }
.box h3 .hint { margin-left: auto; font-weight: var(--font-weight-regular); color: var(--faint); font-size: var(--font-size-xs); }
.summary-text { color: var(--text); line-height: 1.8; white-space: pre-wrap; margin: 0; }
/* notes & tags */
.tags-edit { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.tag { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent-text); padding: 4px 6px 4px 12px;
  border-radius: var(--radius-pill); font-size: var(--font-size-sm); font-weight: var(--font-weight-medium); }
.tag button { border: 0; background: none; cursor: pointer; color: inherit; opacity: .6; width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; padding: 0; }
.tag button:hover { opacity: 1; background: var(--hover-tint); }
.tag button svg { width: 12px; height: 12px; stroke-width: 2.4; }
.tag-link { padding: 4px 12px; }
.tags-edit input { border: 1px dashed var(--border); background: none; border-radius: var(--radius-pill); padding: 5px 12px; font: inherit; font-size: var(--font-size-sm);
  color: var(--text); min-width: 140px; outline: none; }
.tags-edit input:focus { border-style: solid; border-color: var(--accent); }
textarea.note { width: 100%; min-height: 120px; resize: vertical; border: 1px solid var(--border); border-radius: var(--radius-md); background: var(--bg);
  color: var(--text); font: inherit; font-size: var(--font-size-base); line-height: 1.75; padding: 12px 14px; outline: none; }
textarea.note:focus { border-color: var(--accent); }
/* ---------- lightbox / toast ---------- */
.lightbox { position: fixed; inset: 0; z-index: 100; background: var(--scrim); display: grid; place-items: center; }
.lightbox[hidden] { display: none; }
.lightbox img { max-width: 94vw; max-height: 92vh; object-fit: contain; }
.lightbox .nav { position: fixed; top: 50%; width: 52px; height: 52px; border-radius: 50%; border: 0; background: var(--scrim-control); color: var(--on-media);
  cursor: pointer; display: grid; place-items: center; transform: translateY(-50%); }
.lightbox .prev { left: 24px; } .lightbox .next { right: 24px; }
.lightbox .close { position: fixed; top: 18px; right: 22px; color: var(--on-media); }
.lightbox .close:hover { background: var(--scrim-control-hover); color: var(--on-media); }
.lightbox .count { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); color: var(--on-media-soft); font-size: var(--font-size-md); font-variant-numeric: tabular-nums; }
.toast { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); background: var(--text); color: var(--bg); padding: 10px 18px;
  border-radius: var(--radius-pill); font-size: var(--font-size-md); z-index: 120; box-shadow: var(--shadow); }
.toast[hidden] { display: none; }
.grid > .empty { grid-column: 1 / -1; }

/* small helpers used by templates */
.fill { min-width: 0; }
.faint { color: var(--faint); }
.expand-row { text-align: center; margin-top: 10px; }
