/* Public alert library: list, detail, import. Tokens + base.css only. */
.lib { display: flex; flex-direction: column; gap: var(--s-5); }
.lib [hidden] { display: none !important; }
.lib-head { display: flex; flex-direction: column; gap: var(--s-2); }
.lib-head h1 { font-size: clamp(var(--text-3xl), 4vw, var(--text-4xl)); }
.lib-back { color: var(--fg-muted); font-weight: 650; }
.lib-back::before { content: "‹ "; }

/* ---- Tools ---- */
.lib-tools { display: flex; flex-wrap: wrap; gap: var(--s-3); align-items: center; }
.lib-search { display: flex; gap: var(--s-2); flex: 1 1 320px; min-width: 0; }
.lib-search .input { flex: 1; min-width: 0; }
.lib-types { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.lib-type {
  display: inline-flex; align-items: center; min-height: 36px; padding: 0 var(--s-3);
  border-radius: var(--r-full); border: var(--line-w) solid var(--border-strong);
  color: var(--fg-muted); font-weight: 700; font-size: var(--text-sm); text-decoration: none;
}
.lib-type:hover { color: var(--fg); border-color: var(--fg-subtle); }
.lib-type[aria-current="page"] { background: var(--pop); color: var(--on-pop); border-color: var(--ink); }

/* ---- Grid ---- */
.lib-grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 240px), 1fr));
}
.lib-card {
  height: 100%; display: flex; flex-direction: column; overflow: hidden;
  color: inherit; text-decoration: none;
  background: var(--surface-1); border: var(--line-w) solid var(--ink); border-radius: var(--r-lg); box-shadow: var(--e-1);
  transition: transform var(--dur-fast) var(--ease-out), box-shadow var(--dur-fast) var(--ease-out);
}
.lib-card:hover { color: inherit; transform: translate(-2px, -2px); box-shadow: var(--e-2); }
.lib-card:active { transform: translate(2px, 2px); box-shadow: 0 0 0 var(--ink); }
.lib-card:focus-visible { outline-offset: 3px; border-radius: var(--r-lg); }

/* The thumb is a tiny stage: dark like the stream it plays over, in both themes. */
.lib-thumb {
  position: relative; aspect-ratio: 16 / 10; overflow: hidden;
  display: grid; place-items: center; padding: var(--s-3);
  background: var(--ink); border-bottom: var(--line-w) solid var(--ink);
}
.lib-thumb img { width: 100%; height: 100%; object-fit: contain; }
.lib-thumb-text {
  position: absolute; left: var(--s-2); right: var(--s-2); bottom: var(--s-2);
  font-size: var(--text-md); line-height: 1.2; text-align: center;
  overflow: hidden; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2;
}
.lib-media-tag {
  display: inline-flex; align-items: center; gap: 6px; padding: 4px 12px; border-radius: var(--r-full);
  background: var(--surface-2); color: var(--fg); font-weight: 700; font-size: var(--text-sm);
}
.lib-media-tag svg { width: 16px; height: 16px; }
.lib-meta { display: flex; flex-direction: column; gap: 4px; padding: var(--s-3) var(--s-4) var(--s-4); min-width: 0; }
.lib-title { font-weight: 750; font-size: var(--text-lg); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-by { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lib-badges { gap: var(--s-2); margin-top: 2px; }
.lib-pager { display: flex; justify-content: center; gap: var(--s-3); }
.lib-pager:empty { display: none; }

/* ---- Detail ---- */
.lib-detail { display: grid; gap: var(--s-6); align-items: start; }
@media (min-width: 860px) { .lib-detail { grid-template-columns: minmax(0, 1.4fr) minmax(300px, 1fr); } }
.lib-stage {
  position: relative; min-height: 320px; padding: var(--s-8) var(--s-4) var(--s-12);
  display: grid; place-items: center;
  background: var(--ink); border: var(--line-w) solid var(--ink); border-radius: var(--r-xl); box-shadow: var(--e-2);
}
.lib-stage-inner { display: flex; flex-direction: column; align-items: center; gap: var(--s-3); max-width: 100%; }
.lib-stage img, .lib-stage video { max-width: 100%; max-height: 420px; object-fit: contain; }
.lib-preview-text { text-align: center; overflow-wrap: anywhere; max-width: 100%; }
.lib-stage-label {
  position: absolute; left: var(--s-4); bottom: var(--s-3);
  color: var(--fg-subtle); background: var(--surface-1); padding: 2px 10px; border-radius: var(--r-full);
}
.lib-panel { display: flex; flex-direction: column; gap: var(--s-4); }
.lib-panel h1 { font-size: var(--text-3xl); overflow-wrap: anywhere; }
.lib-panel .badge { align-self: flex-start; }
.lib-desc { color: var(--fg-muted); white-space: pre-wrap; overflow-wrap: anywhere; }
.lib-sound { align-self: flex-start; }
.lib-sound.is-playing { --btn-bg: var(--pop-soft); }
.lib-spec { display: grid; grid-template-columns: auto 1fr; gap: 6px var(--s-4); margin: 0; font-size: var(--text-sm); }
.lib-spec dt { color: var(--fg-muted); }
.lib-spec dd { margin: 0; font-weight: 650; }
.lib-credit { display: flex; flex-direction: column; gap: var(--s-3); padding-top: var(--s-4); border-top: var(--line-w) dashed var(--border); }
.lib-credit-name { font-weight: 750; overflow-wrap: anywhere; }
.lib-report { align-self: flex-start; color: var(--fg-muted); }

/* ---- Import ---- */
.lib-import { max-width: 560px; display: flex; flex-direction: column; gap: var(--s-4); }
.lib-import h1 { font-size: var(--text-2xl); overflow-wrap: anywhere; }
