.library-wrap {
  max-width: 960px;
  margin: 0 auto;
  padding: 48px 24px 96px;
}

.library-header {
  margin-bottom: 24px;
}

.library-header h1 {
  margin: 0 0 4px;
  font-size: 1.75rem;
  color: var(--fg);
}

.library-header .subtitle {
  margin: 0;
  color: var(--fg-dim);
  font-size: 0.9rem;
}

.library-controls {
  display: flex;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.lib-search {
  flex: 1 1 280px;
  min-width: 240px;
  display: block;
}

.lib-search input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 14px;
  font-size: 0.95rem;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  outline: none;
  transition: border-color 120ms ease;
}

.lib-search input:focus {
  border-color: var(--accent);
}

.lib-filters {
  display: inline-flex;
  padding: 4px;
  gap: 2px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 10px;
}

.lib-filter {
  padding: 6px 14px;
  font-size: 0.85rem;
  color: var(--fg-dim);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease, color 120ms ease;
}

.lib-filter:hover {
  color: var(--fg);
}

.lib-filter--active {
  background: var(--bg);
  color: var(--fg);
  box-shadow: 0 0 0 1px var(--border);
}

.library-results {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.lib-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 18px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: 12px;
  text-decoration: none;
  color: inherit;
  transition: background 120ms ease, border-color 120ms ease;
}

.lib-row:hover {
  background: var(--bg-elev-hover);
  border-color: var(--accent);
}

.lib-row-main {
  min-width: 0;  /* let text ellipsis work */
  flex: 1;
}

.lib-row-title {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 2px;
}

.lib-row-title strong {
  color: var(--fg);
  font-size: 1rem;
  font-weight: 600;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lib-row-creator {
  color: var(--fg-dim);
  font-size: 0.85rem;
}

.lib-row-meta {
  margin-top: 4px;
  color: var(--fg-dim);
  font-size: 0.78rem;
}

.lib-row-side {
  flex-shrink: 0;
  color: var(--fg-dim);
  font-size: 0.8rem;
}

.lib-role {
  display: inline-block;
  padding: 2px 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 6px;
}

.lib-role--owner {
  background: rgba(124, 92, 255, 0.15);
  color: var(--accent);
}

.lib-role--collab {
  background: rgba(245, 245, 247, 0.08);
  color: var(--fg-dim);
}

.lib-empty {
  color: var(--fg-dim);
  text-align: center;
  padding: 48px 16px;
  font-size: 0.95rem;
  margin: 0;
}

.lib-empty--err {
  color: #ff6b6b;
}

.library-paging {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 24px;
}

.lib-page-indicator {
  color: var(--fg-dim);
  font-size: 0.85rem;
}

.secondary-button {
  padding: 8px 16px;
  font-size: 0.85rem;
  background: var(--bg-elev);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: background 120ms ease;
}

.secondary-button:hover:not(:disabled) {
  background: var(--bg-elev-hover);
}

.secondary-button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Brief glow on rows that arrived via background poll, so the
   user notices their fresh bounce landed without scanning the
   list. Animation auto-fades after ~3 s; class is set fresh on
   each render() that detects new arrivals, so a re-render of the
   same row won't re-pulse. */
@keyframes lib-row-pulse {
  0%   { background-color: rgba(120, 200, 140, 0.22); }
  100% { background-color: transparent; }
}

.lib-row--new {
  animation: lib-row-pulse 3s ease-out;
}

/* Optimistic placeholder row — visible immediately when the
   plugin's encode POST hits the Pages Function, swapped in-place
   for the real row when the manifest event arrives. */
@keyframes lib-placeholder-shimmer {
  0%   { opacity: 0.55; }
  50%  { opacity: 0.95; }
  100% { opacity: 0.55; }
}

.lib-row--placeholder {
  animation: lib-placeholder-shimmer 1.4s ease-in-out infinite;
  pointer-events: none;           /* can't click until the real row arrives */
  background: rgba(120, 200, 140, 0.10);
}

.lib-row--placeholder .lib-row-meta {
  font-style: italic;
}
