* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: #0a0a0a;
  color: #e5e5e5;
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}
a { color: #f4b942; }
a:hover { color: #ffd680; }
code, pre { font-family: ui-monospace, monospace; }

.hidden { display: none !important; }
.muted { color: #6b7280; font-size: 12px; }

/* Slim translucent top bar — pinned, never scrolls. The brand stays
   minimal so the gallery dominates the viewport. */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  background: rgba(10, 10, 10, 0.78);
  backdrop-filter: saturate(140%) blur(12px);
  -webkit-backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid #1a1a1a;
}
.topbar-brand {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.01em;
  color: #f3f4f6;
}
.topbar-brand .accent { color: #f4b942; }
.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  position: relative;
}
.topbar-actions #library-count {
  font-size: 12px;
  color: #6b7280;
  margin-right: 4px;
}
.topbar .iconbtn {
  width: 32px;
  height: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

.settings-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  min-width: 220px;
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 6px;
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 60;
}
.settings-line {
  font-size: 11px;
  padding: 6px 8px;
  border-bottom: 1px solid #1a1a1a;
  margin-bottom: 4px;
  white-space: normal;
  line-height: 1.35;
}
.settings-item {
  background: none;
  border: none;
  color: #cbd5e1;
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  text-align: left;
  border-radius: 3px;
  cursor: pointer;
}
.settings-item:hover { background: #1a1a1a; color: #f87171; }
.settings-item:not(#reset-app):hover { color: #f4b942; }

.page-main {
  width: 100%;
  margin: 0;
  padding: 0 0 90px;
  display: block;
}

#form input[type="url"],
#form textarea#url {
  width: 100%;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  color: #e5e7eb;
  padding: 10px 12px;
  font-family: ui-monospace, monospace;
  font-size: 13px;
  margin-bottom: 12px;
  resize: vertical;
  min-height: 40px;
  max-height: 60vh;
  line-height: 1.4;
}
#form input[type="url"]:focus,
#form textarea#url:focus { outline: none; border-color: #f4b942; }
.form-row { display: flex; gap: 8px; align-items: stretch; }
.select-label { display: flex; align-items: center; gap: 8px; color: #9ca3af; font-size: 12px; }
.select-label select {
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  color: #e5e7eb;
  padding: 8px 10px;
  font-size: 13px;
  font-family: inherit;
}

.btn {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid #2d2d2d;
  background: transparent;
  color: #e5e7eb;
  font-family: inherit;
  font-size: 14px;
  border-radius: 4px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
  display: inline-block;
}
.btn:hover:not(:disabled) { background: #1a1a1a; }
.btn.primary { border-color: #f4b942; color: #f4b942; }
.btn.primary:hover:not(:disabled) { background: #f4b94215; color: #ffd680; }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.iconbtn {
  padding: 4px 10px;
  border: 1px solid #2a2a2a;
  background: transparent;
  color: #cbd5e1;
  font-family: inherit;
  font-size: 12px;
  border-radius: 3px;
  cursor: pointer;
}
.iconbtn:hover { background: #1a1a1a; }
.iconbtn.danger:hover { background: #2a1010; color: #f87171; border-color: #5a2020; }

.progress {
  margin-top: 14px;
  padding: 12px 14px;
  border-radius: 6px;
  background: #0a0a0a;
  border: 1px solid #1f1f1f;
  transition: border-color 200ms, background 200ms;
}
.progress.busy { border-color: #f4b94240; background: #100c08; }
.progress.done { border-color: #22c55e40; background: #0a1610; }
.progress.fail { border-color: #f8717140; background: #16100f; }
.progress-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 13px;
  color: #e5e7eb;
  margin-bottom: 8px;
}
.progress.busy #progress-title { color: #f4b942; }
.progress.done #progress-title { color: #4ade80; }
.progress.fail #progress-title { color: #f87171; }
.progress-bar {
  height: 6px;
  background: #1a1a1a;
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  height: 100%;
  width: 0%;
  background: #f4b942;
  border-radius: 3px;
  transition: width 250ms ease-out, background 200ms;
}
.progress.done .progress-fill { background: #22c55e; }
.progress.fail .progress-fill { background: #f87171; }
.progress.indeterminate .progress-fill {
  width: 35%;
  animation: progress-indeterminate 1.4s ease-in-out infinite;
}
@keyframes progress-indeterminate {
  0% { transform: translateX(-100%); }
  100% { transform: translateX(286%); }
}
.progress-detail {
  margin-top: 6px;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  min-height: 14px;
  /* Preserve newlines in error messages — several thrown errors include
     `\n` between examples / instructions and they should render on
     separate lines, not collapse into one wall of text. `pre-line`
     keeps newlines while still wrapping long lines. */
  white-space: pre-line;
}

.batch { margin-top: 12px; }
.batch.hidden { display: none; }
.batch-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 6px;
}
.batch-tile {
  position: relative;
  aspect-ratio: 1;
  background: #161616;
  border-radius: 4px;
  overflow: hidden;
  transition: opacity 200ms ease, transform 200ms ease;
  /* Pop-in entrance: items appear with a quick rise. */
  animation: tile-in 200ms ease-out backwards;
}
@keyframes tile-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: none; }
}
.batch-tile img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.batch-tile .tile-fallback {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  color: #6b7280;
}
.batch-tile[data-state="pending"] { opacity: 0.55; }
.batch-tile[data-state="uploading"] { opacity: 1; }
.batch-tile[data-state="done"]     { opacity: 1; }
.batch-tile[data-state="error"]    {
  opacity: 0.85;
  outline: 2px solid #f87171;
  outline-offset: -2px;
}
.tile-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: rgba(0, 0, 0, 0.45);
}
.tile-fill {
  height: 100%;
  width: 0%;
  background: #f4b942;
  transition: width 180ms ease-out;
}
.batch-tile[data-state="done"] .tile-fill { background: #22c55e; width: 100%; }
.batch-tile[data-state="error"] .tile-fill { background: #f87171; }
.tile-badge {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.65);
  color: #fff;
  font-size: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: background-color 180ms ease, transform 180ms ease;
}
.batch-tile[data-state="done"] .tile-badge {
  background: #22c55e;
  transform: scale(1.05);
}
.batch-tile[data-state="error"] .tile-badge {
  background: #f87171;
}

.result-card {
  margin-top: 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  background:
    radial-gradient(circle at top left, rgba(74, 222, 128, 0.18), transparent 42%),
    linear-gradient(180deg, #0d1c13 0%, #0a1610 100%);
  border: 1px solid rgba(74, 222, 128, 0.28);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}
.result-icon {
  width: 42px;
  height: 42px;
  flex: 0 0 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 222, 128, 0.14);
  border: 1px solid rgba(74, 222, 128, 0.28);
  color: #4ade80;
  font-size: 22px;
  font-weight: 700;
}
.result-text {
  flex: 1;
  min-width: 0;
}
.result-title {
  color: #f0fdf4;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
}
.result-subtitle {
  margin-top: 2px;
  color: rgba(220, 252, 231, 0.82);
  font-size: 13px;
  line-height: 1.4;
}
.result-card .btn {
  flex: 0 0 auto;
  align-self: center;
  min-width: 138px;
}
@media (max-width: 640px) {
  .result-card {
    align-items: flex-start;
    flex-wrap: wrap;
  }
  .result-card .btn {
    width: 100%;
  }
}

.fail-card {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px;
  background:
    radial-gradient(circle at top left, rgba(248, 113, 113, 0.16), transparent 42%),
    linear-gradient(180deg, #1c0f10 0%, #160b0c 100%);
  border: 1px solid rgba(248, 113, 113, 0.32);
  border-radius: 14px;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.28);
}
.fail-card.hidden { display: none; }
.fail-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
}
.fail-card-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: rgba(248, 113, 113, 0.18);
  border: 1px solid rgba(248, 113, 113, 0.32);
  color: #fca5a5;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.fail-card-title {
  color: #fee2e2;
  font-size: 15px;
  font-weight: 700;
}
.fail-card-message {
  color: rgba(254, 226, 226, 0.82);
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
}
.fail-card-site.hidden { display: none; }
.fail-card-site-heading {
  color: rgba(254, 226, 226, 0.78);
  font-size: 12px;
  margin-bottom: 6px;
}
.fail-card-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.fail-card-actions .btn { flex: 1 1 auto; min-width: 140px; }
.fail-card-note {
  font-size: 11px;
  line-height: 1.45;
}

.library-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 2px;
}
.library-list:empty { display: none; }
@media (min-width: 1200px) { .library-list { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1600px) { .library-list { grid-template-columns: repeat(6, 1fr); } }
@media (max-width: 720px)  { .library-list { grid-template-columns: repeat(3, 1fr); } }

.library-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 80px 20px;
  gap: 8px;
  color: #6b7280;
}
.library-empty-icon { font-size: 48px; opacity: 0.6; }
.library-empty-hint { font-size: 12px; color: #4b5563; }

.library-entry {
  position: relative;
  aspect-ratio: 1;
  background: #1a1a1a;
  border: none;
  border-radius: 0;
  overflow: hidden;
  cursor: pointer;
  transition: filter 160ms ease;
}
.library-entry:hover { filter: brightness(1.05); }

/* Hover-revealed remove button. Reachable on every tile regardless
   of whether openViewer would work for that entry — covers the
   stuck-orphan case where a synced-from-Sia entry is missing fields
   and the viewer silently bails. */
.entry-remove {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.7);
  color: #f3f4f6;
  font-size: 18px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: opacity 160ms ease, background-color 160ms ease;
  z-index: 3;
}
.library-entry:hover .entry-remove { opacity: 1; }
.entry-remove:hover { background: #f87171; }
@media (hover: none) {
  /* Touch devices have no hover — keep it faintly visible so the
     affordance is reachable. */
  .entry-remove { opacity: 0.55; }
}

.library-entry .thumb {
  position: absolute;
  inset: 0;
  background: #1a1a1a;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  color: #6b7280;
}
/* Pin the img to fill the cell regardless of its intrinsic size — without
   absolute positioning, small thumbnails (TikTok oEmbed returns ~150px
   images) get centered at natural size by the flex layout instead of
   stretching to fill. `contain` preserves portrait (TikTok 9:16, IG
   Reels) and landscape (16:9 video) framings inside the square cell —
   the alternative `cover` crops top/bottom off portraits aggressively.
   The cell's dark background fills the unused space. */
.library-entry .thumb img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.thumb-stack {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  font-variant-numeric: tabular-nums;
  z-index: 2;
}

/* Reddit-flavored post card used as the library tile for text-only
   thread archives. Structural conventions match a Reddit feed card —
   header line with subreddit + score, multi-line title, footer with
   author + relative time + comment count — so a Reddit user can scan
   the grid like they're scrolling a subreddit. Background uses
   Reddit-orange tinted into the dark theme rather than full white-
   on-light, which would clash visually with the surrounding tiles. */
.reddit-post-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 12px 12px 10px;
  background: linear-gradient(165deg, #1f140a 0%, #161616 100%);
  text-align: left;
  overflow: hidden;
}
.reddit-post-card-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}
.reddit-post-card-sub {
  font-size: 11px;
  font-weight: 700;
  color: #ff4500;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reddit-post-card-score {
  font-size: 11px;
  font-weight: 600;
  color: #ff8b60;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.reddit-post-card-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: #f3f4f6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 5;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reddit-post-card-meta {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.reddit-post-card-comments {
  font-size: 11px;
  color: #cbd5e1;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
}
.reddit-post-card-archived {
  font-size: 10px;
  color: #9ca3af;
  margin-top: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Webpage-snapshot library tile. Used for archives whose only payload
   is a captured sia-site bundle (no media, no thread). Hostname stripe
   on top, page title in the body, file count + bundle size on the
   bottom. */
.webpage-snapshot-card {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 14px 14px 12px;
  background: linear-gradient(165deg, #0e1a24 0%, #16161e 100%);
  text-align: left;
  overflow: hidden;
}
.webpage-snapshot-host {
  font-size: 11px;
  font-weight: 700;
  color: #60a5fa;
  letter-spacing: 0.01em;
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.webpage-snapshot-title {
  font-size: 14px;
  font-weight: 600;
  line-height: 1.3;
  color: #f3f4f6;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.webpage-snapshot-meta {
  font-size: 11px;
  color: #9ca3af;
  margin-top: 6px;
  font-variant-numeric: tabular-nums;
}

/* Small "has comments archived" badge overlaid on media thumbnails for
   media-bearing thread archives — distinguishes a Reddit photo post
   that ALSO archived its comment thread from one that's photo-only. */
.thumb-thread-badge {
  position: absolute;
  bottom: 6px;
  right: 6px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 3px;
  z-index: 2;
}
.thumb-play {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
  color: rgba(255, 255, 255, 0.95);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.7);
  pointer-events: none;
  opacity: 0.85;
  transition: opacity 160ms ease, transform 160ms ease;
  z-index: 2;
}
.library-entry:hover .thumb-play { opacity: 1; transform: scale(1.06); }

.entry-meta {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 32px 10px 8px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.92));
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 1;
  pointer-events: none;
  opacity: 0;
  transition: opacity 180ms ease;
}
.library-entry:hover .entry-meta { opacity: 1; }

/* Text-only Reddit thread tiles render the post card with all the
   info baked in (title, author, posted-at, archived-at, comments) —
   suppress the redundant entry-meta overlay so it doesn't darken the
   card or duplicate the title at the bottom. */
.library-entry[data-type="thread"] .entry-meta { display: none; }
.entry-title {
  font-size: 12px;
  font-weight: 500;
  color: #fff;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  text-overflow: ellipsis;
}
.entry-handle { font-size: 11px; color: #e5e7eb; }
.entry-date {
  font-size: 10px;
  color: #d1d5db;
  opacity: 0.88;
}
.entry-source { display: none; }
.entry-actions { display: none; }
.platform-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  align-self: auto !important;
  z-index: 2;
  font-size: 9px;
  padding: 1px 5px;
  opacity: 0.85;
  transition: opacity 180ms ease;
}
.library-entry:hover .platform-badge { opacity: 1; }

/* Floating action button — bottom-left circle with + that opens the
   add-link modal. Sized + colored to feel native to a mobile-first
   gallery app, matches Instagram's compose / Twitter's tweet button
   ergonomics. */
.fab {
  position: fixed;
  left: 22px;
  bottom: 22px;
  z-index: 80;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: #f4b942;
  color: #0a0a0a;
  font-size: 32px;
  font-weight: 300;
  line-height: 1;
  cursor: pointer;
  box-shadow:
    0 8px 24px rgba(244, 185, 66, 0.32),
    0 2px 6px rgba(0, 0, 0, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}
.fab:hover {
  background: #ffd680;
  transform: translateY(-1px);
  box-shadow:
    0 10px 28px rgba(244, 185, 66, 0.45),
    0 3px 8px rgba(0, 0, 0, 0.5);
}
.fab:active { transform: translateY(0); }
.fab .fab-plus {
  display: block;
  margin-top: -2px;
}

/* Add-URL modal. Uses the same overlay pattern as the viewer so the
   visual language is consistent. */
.modal.hidden { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.modal-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
.modal-frame {
  position: relative;
  z-index: 1;
  background: #0c0c0c;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  display: flex;
  flex-direction: column;
  max-width: 640px;
  width: 100%;
  max-height: 92vh;
  overflow: hidden;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #1a1a1a;
}
.modal-title {
  font-size: 14px;
  font-weight: 600;
  color: #f3f4f6;
}
.modal-body {
  padding: 18px 18px 20px;
  overflow-y: auto;
}
.modal-body .hint {
  margin: 0 0 12px;
  color: #9ca3af;
  font-size: 13px;
}

/* Setup overlay — shown when no app key. Centered card on a dimmed
   backdrop; gallery is empty behind it anyway, so it dominates. */
.setup-overlay.hidden { display: none; }
.setup-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(10, 10, 10, 0.92);
  backdrop-filter: blur(6px);
}
.setup-card {
  background: #111;
  border: 1px solid #1f1f1f;
  border-radius: 8px;
  padding: 28px 30px;
  max-width: 440px;
  text-align: center;
}
.setup-card h2 { margin: 0 0 8px; font-size: 20px; font-weight: 600; }
.setup-card p { margin: 0 0 18px; color: #9ca3af; }
.setup-card .actions { justify-content: center; }

/* Viewer / lightbox */
.viewer.hidden { display: none; }
.viewer {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.viewer-bg {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.94);
  backdrop-filter: blur(6px);
  cursor: pointer;
}
.viewer-frame {
  position: relative;
  z-index: 1;
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  max-width: min(1200px, 95vw);
  /* `height: 92vh` (not `max-height: 92vh`) so the frame always fills
     a definite height. Without that, when the media is positioned
     absolute (or the stage is otherwise out-of-flow content) the
     frame collapses to header+post+footer and the stage's `flex: 1`
     has no growth room — the media ends up rendering at intrinsic
     size into a 24px-tall stage. */
  height: 92vh;
  width: 100%;
  overflow: hidden;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
/* Full-bleed on mobile — feels like a native app, not a dialog. Use
   100dvh (dynamic viewport height) so iOS Safari's collapsing URL bar
   doesn't clip the footer; falls back to 100vh on older browsers. */
@media (max-width: 720px) {
  .viewer { padding: 0; }
  .viewer-frame {
    max-width: 100vw;
    max-height: 100vh;
    max-height: 100dvh;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    border: none;
    border-radius: 0;
    box-shadow: none;
  }
  /* Reserve room for the iOS home-indicator + browser chrome. */
  .viewer-footer {
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}
.viewer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid #1a1a1a;
}
/* When the post block already shows site/author/caption, suppress the
   top title bar's text and just keep the close button. Avoids stacking
   "Instagram / Instagram / Instagram." */
.viewer-header.compact {
  padding: 6px 8px;
  border-bottom: none;
  justify-content: flex-end;
}
.viewer-header.compact .viewer-title { display: none; }
.viewer-title {
  font-size: 13px;
  color: #f3f4f6;
  font-weight: 500;
  word-break: break-word;
}
.viewer-post {
  padding: 12px 14px 10px;
  border-bottom: 1px solid #1a1a1a;
  background: #0c0c0c;
}
.viewer-post.hidden { display: none; }
.viewer-post-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #9ca3af;
  margin-bottom: 4px;
}
.viewer-site {
  font-weight: 600;
  color: #d1d5db;
}
.viewer-author:not(:empty)::before {
  content: '· ';
  margin-right: 2px;
  color: #6b7280;
}
.viewer-archived {
  color: #9ca3af;
  white-space: nowrap;
}
.viewer-archived.hidden { display: none; }
.viewer-archived:not(:empty)::before {
  content: '· ';
  margin-right: 2px;
  color: #6b7280;
}
.viewer-pagetitle {
  font-size: 15px;
  color: #f3f4f6;
  font-weight: 600;
  line-height: 1.3;
  margin: 2px 0 6px;
  word-break: break-word;
}
.viewer-pagetitle.hidden { display: none; }
.viewer-caption {
  font-size: 13px;
  color: #d1d5db;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
  max-height: 30vh;
  overflow-y: auto;
}
.viewer-caption.hidden { display: none; }
.viewer-stage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #050505;
  /* CSS flex-overflow gotcha: a flex item's `min-height` defaults to
     `auto` (its intrinsic content size). When the child is a <video>
     with a large native resolution (e.g. 1920×1080), the stage will
     grow past its flex parent and push the rest of the viewer UI off
     screen. Forcing min-height/min-width to 0 lets the stage shrink to
     whatever the parent gives it, and the video's max-* rules then
     scale it down. */
  min-height: 0;
  min-width: 0;
  position: relative;
  overflow: hidden;
  padding: 12px;
  box-sizing: border-box;
}
/* Absolute positioning + explicit calc dimensions. For replaced
   elements (<img>, <video>) with `width: auto; height: auto` the
   browser uses the element's INTRINSIC size and ignores top/left/
   right/bottom inset constraints — that's why the video kept
   rendering at 576×1024 even though `inset: 12px` was set. Forcing
   width/height via calc() removes the auto-from-intrinsic fallback
   and locks the element to the stage's content area; object-fit:
   contain then letterboxes the actual frame inside that box. */
.viewer-stage > img.viewer-media,
.viewer-stage > video.viewer-media {
  position: absolute;
  top: 12px;
  left: 12px;
  width: calc(100% - 24px);
  height: calc(100% - 24px);
  object-fit: contain;
  display: block;
  transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1);
  touch-action: pan-y pinch-zoom;
}
.viewer-stage > video.viewer-media {
  background: #000;
}
@media (max-width: 720px) {
  /* Mobile stage has no padding, so the media goes edge-to-edge. */
  .viewer-stage > img.viewer-media,
  .viewer-stage > video.viewer-media {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
  }
}

/* Webpage archive — clickable preview card in the viewer. Click
   opens the reconstructed page in a new tab; the viewer itself
   stays available so the user can hit Share / Source / Remove. */
.viewer-stage.viewer-stage-webpage {
  padding: clamp(16px, 4vw, 36px);
  align-items: center;
  justify-content: center;
}
.viewer-stage > .viewer-webpage-card {
  width: 100%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: #131313;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font: inherit;
  color: inherit;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.viewer-stage > .viewer-webpage-card:hover {
  border-color: #f4b942;
  box-shadow: 0 6px 22px rgba(244, 185, 66, 0.18);
  transform: translateY(-1px);
}
.viewer-webpage-card-thumb {
  width: 100%;
  aspect-ratio: 1.91 / 1;          /* og:image standard ratio */
  background: #0c0c0c;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.viewer-webpage-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.viewer-webpage-card-thumb-empty {
  font-size: 48px;
  color: #4b5563;
}
.viewer-webpage-card-body {
  padding: 16px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.viewer-webpage-card-host {
  font-size: 12px;
  font-weight: 600;
  color: #60a5fa;
  letter-spacing: 0.02em;
}
.viewer-webpage-card-title {
  font-size: 18px;
  font-weight: 600;
  color: #f3f4f6;
  line-height: 1.3;
}
.viewer-webpage-card-meta {
  font-size: 11px;
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
}
.viewer-webpage-card-cta {
  margin-top: 8px;
  font-size: 12px;
  font-weight: 500;
  color: #f4b942;
}
@media (max-width: 720px) {
  .viewer-stage {
    padding: 0;
  }
}

/* Reddit-flavored post card surface in the viewer. The same card
   used as the library tile is reused here, just sized up: full-bleed
   for text-only archives (where it's the primary content), more
   compact below the media stage for media+thread archives. The
   entire card is wrapped in a <button> so clicking anywhere opens
   the full thread reader. */
.viewer-thread {
  flex: 0 0 auto;
  padding: 12px 16px;
  background: #0c0c0c;
  border-top: 1px solid #1a1a1a;
  display: flex;
  justify-content: center;
}
.viewer-thread.hidden { display: none; }
/* Primary mode: text-only thread archives. The card IS the viewer
   content (header is compact and hidden, stage is hidden) so let it
   fill the available area between the up/down peek strips. The 96px
   top/bottom padding carves out clickable zones for the peeks (which
   are absolutely-positioned on viewer-frame at top:48px / bottom:56px)
   without letting them overlap the card — that way clicks on the
   card's body open the full thread reader as the user expects, and
   clicks on the strips above/below navigate the feed. */
.viewer-thread.viewer-thread-primary {
  flex: 1;
  align-items: stretch;
  padding: 96px 0;
  border-top: none;
}
@media (max-width: 720px) {
  /* Mobile peeks are 72px tall — match the padding to that. */
  .viewer-thread.viewer-thread-primary { padding: 72px 0; }
}

.viewer-thread-button {
  position: relative;
  display: block;
  width: 100%;
  max-width: 720px;
  padding: 0;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  background: transparent;
  font: inherit;
  color: inherit;
  text-align: left;
  cursor: pointer;
  overflow: hidden;
  transition: border-color 160ms ease, transform 160ms ease, box-shadow 160ms ease;
}
.viewer-thread.viewer-thread-primary .viewer-thread-button {
  max-width: none;
  flex: 1;
  display: flex;
  flex-direction: column;
  border-radius: 0;
  border: none;
  border-top: 1px solid #1a1a1a;
}
.viewer-thread.viewer-thread-primary .viewer-thread-button:hover:not(:disabled) {
  border-color: transparent;
  border-top-color: #ff4500;
  box-shadow: inset 0 0 60px rgba(255, 69, 0, 0.06);
  transform: none;
}
.viewer-thread.viewer-thread-primary .viewer-thread-button .reddit-post-card {
  flex: 1;
}
.viewer-thread-button:hover:not(:disabled) {
  border-color: #ff4500;
  box-shadow: 0 4px 18px rgba(255, 69, 0, 0.18);
  transform: translateY(-1px);
}
.viewer-thread-button:disabled { cursor: default; opacity: 0.7; }
.viewer-thread-button.loading { pointer-events: none; }

/* When the card is in the viewer (vs the library tile), it's no
   longer absolutely-positioned inside an aspect:1 container — it
   relaxes to its natural content height with bigger fonts. */
.viewer-thread-button .reddit-post-card {
  position: relative;
  inset: auto;
  padding: 16px 18px 14px;
}
.viewer-thread-primary .viewer-thread-button .reddit-post-card {
  padding: 22px 24px 18px;
}
.viewer-thread-button .reddit-post-card-sub {
  font-size: 12px;
}
.viewer-thread-button .reddit-post-card-score {
  font-size: 12px;
}
.viewer-thread-button .reddit-post-card-title {
  font-size: 17px;
  -webkit-line-clamp: unset;
  display: block;
  overflow: visible;
}
.viewer-thread-primary .viewer-thread-button .reddit-post-card-title {
  font-size: 22px;
  line-height: 1.25;
}
.viewer-thread-button .reddit-post-card-meta,
.viewer-thread-button .reddit-post-card-comments {
  font-size: 12px;
}

.viewer-thread-hint {
  padding: 10px 18px 12px;
  font-size: 11px;
  color: #f4b942;
  border-top: 1px solid #1a1a1a;
  background: #0a0a0a;
  font-weight: 500;
}
.viewer-thread-primary .viewer-thread-hint {
  padding: 12px 24px 14px;
  font-size: 12px;
}
.viewer-thread-hint-error { color: #f87171; }

/* Synthetic thread slide: the last carousel page when a Reddit archive
   has both media and an attached comments thread. Centers the post card
   in the same stage area used by media so prev/next/swipe behaviour
   stays uniform across slides. */
.viewer-thread-slide {
  position: absolute;
  inset: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  overflow-y: auto;
}
.viewer-thread-slide .viewer-thread-button {
  width: 100%;
  max-width: 560px;
}
@media (max-width: 720px) {
  .viewer-thread-slide { inset: 0; padding: 16px; }
}

/* Stage gets fully hidden for text-only archives so the post card
   above takes the entire viewer body. The header (post block) and
   footer (action buttons) still flank it. */
.viewer-stage.viewer-stage-hidden { display: none; }

/* Old.reddit.com-flavored thread reader. Full overlay above the
   viewer; threaded comments use indented vertical-line indicators
   per nesting level — old reddit's hallmark. Dark-themed to match
   the rest of ambrosia, but the structural conventions (meta on its
   own line above body, depth-indicator borders, OP-author tint) are
   old-reddit. */
.thread-reader {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: #0a0a0a;
  display: flex;
  flex-direction: column;
}
.thread-reader.hidden { display: none; }
.thread-reader-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid #1a1a1a;
  background: rgba(10, 10, 10, 0.95);
}
.thread-reader-back,
.thread-reader-close {
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid #2a2a2a;
  background: transparent;
  color: #d1d5db;
  font-size: 16px;
  border-radius: 4px;
  cursor: pointer;
}
.thread-reader-back:hover,
.thread-reader-close:hover { background: #1a1a1a; }
.thread-reader-title-text {
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  color: #f4b942;
}
.thread-reader-content {
  flex: 1;
  overflow-y: auto;
  padding: 18px clamp(16px, 5vw, 40px) 60px;
  font-size: 14px;
  line-height: 1.55;
  color: #d1d5db;
}
.reader-root { max-width: 880px; margin: 0 auto; }

.reader-post {
  padding-bottom: 16px;
  border-bottom: 1px solid #1a1a1a;
  margin-bottom: 18px;
}
.reader-post-title {
  font-size: 20px;
  font-weight: 600;
  color: #f3f4f6;
  margin: 0 0 6px;
  line-height: 1.3;
}
.reader-post-meta {
  font-size: 11px;
  color: #9ca3af;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: baseline;
}
.reader-post-score {
  background: #1a1a1a;
  border-radius: 3px;
  padding: 1px 6px;
  font-weight: 600;
  color: #f4b942;
  font-variant-numeric: tabular-nums;
}
.reader-post-archived {
  margin-left: auto;
  font-style: italic;
  color: #6b7280;
}
.reader-post-body {
  margin-top: 12px;
  font-size: 14px;
  color: #e5e7eb;
}
.reader-post-body p { margin: 0 0 10px; }
.reader-post-body p:last-child { margin-bottom: 0; }

.reader-comments-header {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #9ca3af;
  margin-bottom: 12px;
  padding-bottom: 6px;
  border-bottom: 1px solid #1a1a1a;
}

.reader-comments {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.reader-comments .reader-comments {
  margin-top: 8px;
  padding-left: 14px;
  border-left: 2px solid #2a2a2a;
  gap: 10px;
}
.reader-comment { font-size: 13px; color: #d1d5db; }
.reader-comment.depth-1 .reader-comments { border-left-color: #2f2a1a; }
.reader-comment.depth-2 .reader-comments { border-left-color: #2a1f1f; }
.reader-comment.depth-3 .reader-comments { border-left-color: #1f2a2a; }
.reader-comment-meta {
  font-size: 11px;
  color: #9ca3af;
  display: flex;
  gap: 8px;
  margin-bottom: 3px;
  align-items: baseline;
}
.reader-comment-author {
  color: #cbd5e1;
  font-weight: 500;
  text-decoration: none;
}
.reader-comment-author:hover { text-decoration: underline; }
.reader-comment-author.is-op {
  color: #60a5fa;
  font-weight: 600;
}
.reader-comment-score {
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
}
.reader-comment-tag {
  background: #1a3a1a;
  color: #4ade80;
  font-size: 10px;
  padding: 0 5px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.reader-comment-tag.tag-admin { background: #3a1a1a; color: #f87171; }
.reader-comment-body { color: #e5e7eb; }
.reader-comment-body p { margin: 0 0 6px; }
.reader-comment-body p:last-child { margin-bottom: 0; }

.reader-author,
.reader-sub {
  color: #cbd5e1;
  text-decoration: none;
}
.reader-author:hover,
.reader-sub:hover { text-decoration: underline; }
.reader-sub { color: #f4b942; font-weight: 500; }

.thread-md-blockquote {
  border-left: 3px solid #2a2a2a;
  padding-left: 10px;
  margin: 0 0 8px;
  color: #9ca3af;
}
.thread-md-blockquote p { margin: 0 0 6px; }
.thread-md-blockquote p:last-child { margin-bottom: 0; }
.thread-reader-content a { color: #f4b942; }
.thread-reader-content a:hover { color: #ffd680; }
.thread-reader-content code {
  background: #1a1a1a;
  padding: 1px 5px;
  border-radius: 3px;
  font-size: 12px;
}
.viewer-stage .viewer-loading,
.viewer-stage .viewer-error {
  color: #9ca3af;
  font-size: 13px;
  padding: 20px;
}
.viewer-stage .viewer-error { color: #f87171; }
.viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.55);
  border: none;
  color: #f3f4f6;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.18s ease, background 0.18s ease;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 0 3px;
}
.viewer-nav-prev { left: 14px; }
.viewer-nav-next { right: 14px; }
.viewer-stage:hover .viewer-nav:not(.hidden):not(:disabled) { opacity: 1; }
.viewer-nav:hover { background: rgba(0, 0, 0, 0.8); }
.viewer-nav:disabled { opacity: 0 !important; pointer-events: none; }
.viewer-nav.hidden { display: none; }
/* Touch devices have no hover state — keep arrows half-visible always
   so the affordance is obvious. Tapping/hovering bumps to full opacity. */
@media (hover: none), (max-width: 720px) {
  .viewer-nav:not(.hidden):not(:disabled) { opacity: 0.7; }
}
/* Vertical-feed navigation zones — full-width strips at the top and
   bottom of the stage. Invisible by default; the entire zone fades in
   on hover with a centered arrow + thumbnail preview. Clicking
   anywhere within the zone navigates. Bigger tap target than a small
   button, less visually intrusive when not hovered. */
.viewer-peek {
  position: absolute;
  left: 0;
  right: 0;
  height: 96px;
  z-index: 5;
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 220ms ease;
  /* The peek's gradient overlay covers a wide strip near the top/
     bottom of the viewer — including where a <video controls> bar
     lives. Without pointer-events:none here, hovering down to touch
     the volume slider lands on the peek button instead of the video,
     and the video's auto-hiding controls vanish. Make the gradient
     transparent to events; only the thumbnail and arrow children
     remain interactive (their click bubbles to the button's
     handler). */
  pointer-events: none;
}
.viewer-peek-thumb,
.viewer-peek-arrow {
  pointer-events: auto;
}
/* Top/bottom offsets to clear the viewer header (close button) and
   footer (Share/Source/Remove). Peeks now live on the viewer-frame
   directly so they remain available when the stage is hidden for
   text-only thread archives — the up/down feed-navigation arrows
   should always be visible regardless of archive type. */
.viewer-peek-prev {
  top: 48px;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
}
.viewer-peek-next {
  bottom: 56px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0));
}
.viewer-peek:hover { opacity: 1; }
.viewer-peek.hidden { display: none; }
.viewer-peek-arrow {
  font-size: 22px;
  color: #fff;
  font-weight: 700;
  line-height: 1;
  margin: 0 12px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.8);
}
.viewer-peek-thumb {
  width: 64px;
  height: 64px;
  object-fit: cover;
  border-radius: 8px;
  display: block;
  background: linear-gradient(135deg, #1a1a1a, #2a2a2a);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.18);
}
/* Touch devices have no hover — make the zones gently visible so the
   affordance is discoverable, since you can't reveal them by hovering. */
@media (hover: none), (max-width: 720px) {
  .viewer-peek { opacity: 0.4; height: 72px; }
  .viewer-peek-thumb { width: 48px; height: 48px; }
}

.viewer-counter {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  padding: 5px 12px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  z-index: 4;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.viewer-counter.hidden { display: none; }

/* Instagram-style dot indicators along the bottom of the stage. Only
   shown for small-to-medium carousels (>= 2, <= MAX_DOTS); large
   collections fall back to just the counter pill since 30 dots get
   visually noisy. */
.viewer-dots {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 6px 10px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 999px;
  /* Above the bottom feed-nav zone (z-index 5) so the strip can't
     swallow clicks meant for the dots, and the pill stays visible
     even when the user hovers the bottom zone. */
  z-index: 6;
  pointer-events: auto;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.viewer-dots.hidden { display: none; }
.viewer-dot {
  cursor: pointer;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.4);
  transition: background 180ms ease, transform 180ms ease;
}
.viewer-dot.active {
  background: #fff;
  transform: scale(1.3);
}
.viewer-loading-overlay {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.18);
  border-top-color: rgba(255, 255, 255, 0.72);
  animation: viewer-spin 0.8s linear infinite;
  z-index: 6;
  pointer-events: none;
}
.viewer-loading-overlay.hidden { display: none; }
@keyframes viewer-spin {
  to { transform: translate(-50%, -50%) rotate(360deg); }
}
.viewer-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid #1a1a1a;
}
.viewer-spacer { flex: 1; }
.viewer-footer .iconbtn { padding: 5px 12px; font-size: 12px; }

.platform-badge {
  display: inline-block;
  align-self: flex-start;
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  padding: 2px 7px;
  border-radius: 3px;
  background: #2a2a2a;
  color: #d1d5db;
  margin-bottom: 1px;
}
.platform-badge-instagram {
  background: linear-gradient(45deg, #f09433, #e6683c, #dc2743, #cc2366, #bc1888);
  color: #fff;
}
.platform-badge-tiktok    { background: #111; color: #fff; box-shadow: inset 0 0 0 1px #25f4ee, 1px 1px 0 #fe2c55; }
.platform-badge-twitter   { background: #000; color: #fff; }
.platform-badge-reddit    { background: #ff4500; color: #fff; }
.platform-badge-vimeo     { background: #1ab7ea; color: #fff; }
.platform-badge-twitch    { background: #9146ff; color: #fff; }
.platform-badge-bluesky   { background: #1185fe; color: #fff; }
.platform-badge-default   { background: #2a2a2a; color: #d1d5db; }

/* Platform-specific accents only — no per-platform layout overrides.
   The grid stays uniform (Instagram-style), badges and hover effects
   give each platform its identity without breaking tile shape. */
.library-entry.platform-twitter .entry-title { font-weight: 600; }
.library-entry.platform-twitch:hover { filter: brightness(1.1) saturate(1.1); }

.actions { display: flex; gap: 8px; margin-top: 14px; }

.supported-sites-frame {
  width: min(760px, calc(100vw - 28px));
  max-height: min(780px, calc(100vh - 40px));
}
.supported-sites-body {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 0;
}
.supported-sites-search {
  width: 100%;
  min-height: 38px;
  padding: 9px 11px;
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  background: #0a0a0a;
  color: #e5e7eb;
  font: inherit;
}
.supported-sites-search:focus {
  outline: none;
  border-color: #f4b942;
}
.supported-sites-count {
  font-size: 12px;
}
.supported-sites-results {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 2px;
}
.supported-site-card {
  border: 1px solid #222;
  border-radius: 6px;
  padding: 10px;
  background: #0f0f0f;
}
.supported-site-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
}
.supported-site-title {
  color: #f3f4f6;
  font-size: 13px;
  font-weight: 700;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.supported-site-extractor {
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 3px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.supported-site-extractor.extractor-cobalt {
  background: rgba(244, 185, 66, 0.15);
  color: #f4b942;
  border: 1px solid rgba(244, 185, 66, 0.3);
}
.supported-site-extractor.extractor-gallery-dl {
  background: rgba(96, 165, 250, 0.15);
  color: #60a5fa;
  border: 1px solid rgba(96, 165, 250, 0.3);
}
.supported-site-meta {
  margin-top: 1px;
  color: #9ca3af;
  font-size: 11px;
}
.supported-site-caps {
  margin-top: 7px;
  color: #d1d5db;
  font-size: 12px;
  line-height: 1.4;
}
.supported-site-examples {
  display: grid;
  gap: 5px;
  margin-top: 8px;
}
.supported-site-example {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  align-items: center;
}
.supported-site-example-url {
  min-width: 0;
  color: #9ca3af;
  font-family: ui-monospace, monospace;
  font-size: 11px;
  overflow-wrap: anywhere;
}
.supported-site-use {
  border: 1px solid #2a2a2a;
  border-radius: 4px;
  background: transparent;
  color: #f4b942;
  font: inherit;
  font-size: 11px;
  padding: 4px 8px;
  cursor: pointer;
}
.supported-site-use:hover { background: #f4b94215; }

@media (max-width: 540px) {
  .form-row { flex-direction: column; }
  .fab { left: 16px; bottom: 16px; width: 54px; height: 54px; font-size: 28px; }
  .topbar { padding: 8px 12px; }
  .topbar-brand { font-size: 16px; }
}

/* "Copy all source URLs" modal — a flat textarea + copy button so the
   user can grab every archive's sourceUrl before nuking the account
   via Reset, then re-paste them back into the multi-URL Add form to
   selectively re-archive. */
.urls-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.urls-modal-frame {
  background: #0a0a0a;
  border: 1px solid #2a2a2a;
  border-radius: 10px;
  width: 100%;
  max-width: 820px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.urls-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #1a1a1a;
  font-size: 13px;
  color: #d1d5db;
}
.urls-modal-text {
  flex: 1;
  width: 100%;
  border: none;
  background: #0c0c0c;
  color: #e5e7eb;
  font-family: ui-monospace, monospace;
  font-size: 12px;
  line-height: 1.5;
  padding: 14px 16px;
  resize: none;
  outline: none;
}
.urls-modal-footer {
  padding: 10px 16px;
  border-top: 1px solid #1a1a1a;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}
