:root {
  --bg: #ffffff;
  --text: #0f1419;
  --muted: #536471;
  --border: #eff3f4;
  --hover: #f7f9f9;
  --accent: #1d9bf0;
  --accent-text: #ffffff;
  --card: #ffffff;
  --repost: #00ba7c;
  --warn-bg: #fff8e1;
  --line: #cfd9de;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --text: #e7e9ea;
    --muted: #71767b;
    --border: #2f3336;
    --hover: #080808;
    --card: #000000;
    --warn-bg: #2a2410;
    --line: #333639;
  }
}

* { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

.column {
  max-width: 600px;
  min-height: 100vh;
  margin: 0 auto;
  border-left: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 8px 16px;
  background: color-mix(in srgb, var(--bg) 85%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.topbar-title { flex: 1; min-width: 0; }
.topbar h1 { margin: 0; font-size: 20px; font-weight: 800; cursor: pointer; }
.sub { margin: 0; color: var(--muted); font-size: 13px; }
.back { color: var(--text); font-size: 20px; padding: 4px 8px; border-radius: 999px; }
.back:hover { background: var(--hover); text-decoration: none; }

.refresh, .more button {
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  background: var(--text);
  color: var(--bg);
}
/* Header menu: the list syncs, tucked away from stray clicks. */
.menu { position: relative; }
.menu-btn {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: none;
  color: var(--text);
  cursor: pointer;
}
.menu-btn:hover, .menu-btn[aria-expanded="true"] { background: var(--hover); }
.menu-btn svg { width: 22px; height: 22px; }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  z-index: 5;
  min-width: 230px;
  padding: 6px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  box-shadow: 0 4px 16px rgb(0 0 0 / 18%);
}
.menu-panel[hidden] { display: none; }
.menu-item {
  display: block;
  width: 100%;
  padding: 10px 16px;
  border: 0;
  background: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}
.menu-item:hover { background: var(--hover); }
.menu-item[hidden] { display: none; }
.menu-item:disabled { opacity: 0.5; cursor: wait; }
.menu-item small { display: block; margin-top: 2px; color: var(--muted); font-weight: 400; font-size: 13px; }
.topbar { gap: 8px; }
.link { border: 0; padding: 0; background: none; color: var(--accent); font: inherit; cursor: pointer; }
.link:disabled { opacity: 0.5; cursor: wait; }
.refresh:disabled { opacity: 0.5; cursor: wait; }
.more { padding: 16px; text-align: center; }
.more button { background: transparent; color: var(--accent); }
.end { color: var(--muted); margin: 0; }

.newposts {
  position: sticky;
  top: 72px;
  z-index: 3;
  display: block;
  margin: 8px auto -44px;
  padding: 8px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font: inherit;
  font-weight: 700;
  box-shadow: 0 2px 8px rgb(0 0 0 / 25%);
  cursor: pointer;
}
.newposts[hidden] { display: none; }

/* Pull to refresh, for the home-screen web app (Safari's own is unavailable there). */
.ptr {
  height: 0;
  overflow: hidden;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  color: var(--muted);
  font-size: 13px;
  transition: height 0.2s ease;
}
.ptr.dragging { transition: none; }
.ptr span { padding-bottom: 14px; }

.notice {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--warn-bg);
  font-size: 14px;
}

.profile { padding: 16px; border-bottom: 1px solid var(--border); }
.profile img { width: 80px; height: 80px; border-radius: 50%; }
.profile h2 { margin: 8px 0 0; font-size: 20px; }
.profile p { margin: 2px 0 0; color: var(--muted); }

.post {
  position: relative;
  display: grid;
  grid-template-columns: 40px 1fr;
  gap: 0 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.post:hover { background: var(--hover); }
.social {
  grid-column: 1 / -1;
  margin: 0 0 4px 28px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.social a { color: inherit; }
.avatar { width: 40px; height: 40px; border-radius: 50%; background: var(--border); }
.body { min-width: 0; }
.meta { display: flex; gap: 4px; align-items: baseline; color: var(--muted); white-space: nowrap; overflow: hidden; }
.meta .name { color: var(--text); font-weight: 700; overflow: hidden; text-overflow: ellipsis; }
.meta .handle { overflow: hidden; text-overflow: ellipsis; }
.meta a { color: inherit; }
.badge { color: var(--accent); font-size: 13px; }
.text { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }

.media {
  display: grid;
  gap: 2px;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
}
.media.n2, .media.n3, .media.n4 { grid-template-columns: 1fr 1fr; aspect-ratio: 16 / 9; }
.media.n3 > :first-child { grid-row: span 2; }
.media img, .media video { display: block; width: 100%; height: 100%; object-fit: cover; background: var(--border); }
.media.n1 img, .media.n1 video { max-height: 510px; object-fit: contain; }
.video-fallback { position: relative; display: block; background: #000; }
/* GIFs: silent looping video (or the GIF itself), labeled like on Bluesky. */
.gif-box { position: relative; display: block; margin-top: 12px; max-height: 510px; background: var(--border); }
.gif-box .gif { display: block; width: 100%; height: 100%; object-fit: contain; }
.gif-tag {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 1px 5px;
  border-radius: 4px;
  background: rgb(0 0 0 / 70%);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
}
/* YouTube: a thumbnail that swaps in YouTube's player on tap. */
.yt, .yt-frame { position: relative; display: block; width: 100%; aspect-ratio: 16 / 9; padding: 0; border: 0; background: #000; cursor: pointer; }
.yt img { width: 100%; height: 100%; object-fit: cover; }
.yt-frame.yt-short { aspect-ratio: 9 / 16; max-height: 640px; }
.yt-play {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  width: 64px;
  height: 44px;
  border-radius: 12px;
  background: #f00;
  color: #fff;
  font-size: 20px;
}
.yt-len {
  position: absolute;
  right: 8px;
  bottom: 8px;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgb(0 0 0 / 80%);
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}
.pf-youtube:hover { color: #f00; }
.video-fallback img { opacity: 0.6; }
.video-fallback span {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
}

.quote {
  display: block;
  margin-top: 12px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  color: var(--text);
}
.quote-main { display: block; color: var(--text); }
.quote-main:hover { text-decoration: none; }
.quote:has(.quote-main:hover) { background: var(--hover); }
.quote .card, .quote .gif-box { margin-top: 8px; }
.quote .meta img { width: 20px; height: 20px; border-radius: 50%; align-self: center; }
.quote .media { margin-top: 8px; }

.platforms {
  position: absolute;
  top: 12px;
  right: 16px;
  display: flex;
  gap: 6px;
}
.pf { display: block; width: 15px; height: 15px; color: var(--muted); }
.pf svg { display: block; width: 100%; height: 100%; }
.pf-bsky:hover { color: #1185fe; }
.pf-x:hover { color: var(--text); }
.pf-instagram:hover { color: #d62976; }
.post .meta { padding-right: 48px; }
.quote .meta { padding-right: 0; }

.card {
  display: block;
  margin-top: 12px;
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: hidden;
  color: var(--text);
}
.card:hover { background: var(--hover); text-decoration: none; }
.card img { display: block; width: 100%; aspect-ratio: 1.91 / 1; object-fit: cover; background: var(--border); }
.card-body { padding: 10px 12px; }
.card-host { color: var(--muted); font-size: 13px; }
.card-title { font-weight: 500; overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }

.profile .acct { display: flex; align-items: center; gap: 6px; }
.profile .acct svg { width: 14px; height: 14px; flex: none; }

/* Threads: a line joins the avatars of consecutive posts. */
.thread { border-bottom: 1px solid var(--border); }
.thread .post { border-bottom: 0; }
.thread .post.has-next::before,
.thread .post.has-prev::after,
.thread-more::before {
  content: '';
  position: absolute;
  left: 35px;
  width: 2px;
  background: var(--line);
}
.thread .post.has-next::before { top: 56px; bottom: 0; }
.thread .post.has-prev::after { top: 0; height: 8px; }
.thread .post.has-prev { padding-top: 8px; }
.thread .post.collapsed { display: none; }
.thread-more {
  position: relative;
  display: block;
  width: 100%;
  padding: 6px 16px 6px 68px;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  text-align: left;
  cursor: pointer;
}
.thread-more::before { top: 0; bottom: 0; }
.thread-more:hover { background: var(--hover); }

.skeleton { padding: 24px 16px; color: var(--muted); text-align: center; }

/* Star: mark a post as useful. */
.actions { display: flex; justify-content: flex-end; margin: 4px -8px -6px 0; }
.star { display: grid; place-items: center; width: 34px; height: 34px; padding: 0; border: 0; border-radius: 999px; background: none; color: var(--muted); cursor: pointer; }
.star svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; }
.star:hover { background: color-mix(in srgb, #f5b400 12%, transparent); color: #f5b400; }
.star[aria-pressed="true"] { color: #f5b400; }
.star[aria-pressed="true"] svg { fill: currentColor; }

/* Star report. */
.report-note { margin: 0; padding: 12px 16px; color: var(--muted); font-size: 14px; border-bottom: 1px solid var(--border); }
.report-wrap { overflow-x: auto; }
.report { width: 100%; border-collapse: collapse; font-size: 14px; }
.report th, .report td { padding: 10px 6px; border-bottom: 1px solid var(--border); text-align: right; white-space: nowrap; }
.report th:first-child, .report td:first-child { padding-left: 16px; text-align: left; white-space: normal; }
.report th:last-child, .report td:last-child { padding-right: 16px; }
.report th { color: var(--muted); font-weight: 700; font-size: 13px; }
.report td a { color: var(--text); font-weight: 700; }
.report td small { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 12px; }
.report td small svg { width: 11px; height: 11px; }

/* Admin page (/admin). */
.admin section { padding: 16px; border-bottom: 1px solid var(--border); }
.admin section:last-child { padding: 16px 0 0; border-bottom: 0; }
.admin section:last-child h2 { padding: 0 16px; }
.admin h2 { margin: 0 0 8px; font-size: 17px; }
.admin p { margin: 0 0 12px; color: var(--muted); font-size: 14px; }
.admin-row { display: flex; align-items: center; gap: 12px; margin-top: 8px; color: var(--muted); font-size: 14px; }
.admin-btn { border: 1px solid var(--border); border-radius: 999px; padding: 7px 14px; background: none; color: var(--text); font: inherit; font-weight: 700; cursor: pointer; }
.admin-btn:hover { background: var(--hover); }
.admin-btn:disabled { opacity: 0.5; cursor: wait; }
a.admin-btn { display: inline-block; text-decoration: none; }
.admin .admin-warn { color: #c0392b; }
.admin input { min-width: 0; flex: 0 1 140px; border: 1px solid var(--border); border-radius: 8px; padding: 7px 10px; background: none; color: var(--text); font: inherit; }
#threads-test, #ig-test { flex-wrap: wrap; margin-bottom: 12px; }
.test-out:not(:empty) { margin-bottom: 12px; }
.admin-test p { margin: 0 0 6px; overflow-wrap: anywhere; }
#threads-test-out:not(:empty) { margin-bottom: 12px; }

/* Accounts list (uses the report table styles). */
.report.accounts td { white-space: normal; }
.report.accounts td.num, .report.accounts th.num { text-align: right; font-variant-numeric: tabular-nums; }
.acct-row { display: flex; align-items: center; gap: 10px; color: var(--text); }
.acct-row:hover { text-decoration: none; }
.acct-row strong { display: block; }
.acct-avatar { width: 36px; height: 36px; flex: none; border-radius: 50%; background: var(--border); }
.sort { padding: 0; border: 0; background: none; color: inherit; font: inherit; cursor: pointer; }
.report th[aria-sort="ascending"], .report th[aria-sort="descending"] { color: var(--text); }

/* Photo lightbox. */
html.lb-open { overflow: hidden; }
.lightbox {
  width: 100vw;
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0;
  padding: 0;
  border: 0;
  background: rgb(0 0 0 / 96%);
  color: #fff;
  overscroll-behavior: contain;
}
.lightbox::backdrop { background: transparent; }
.lightbox[open] { display: grid; place-items: center; }
.lb-img {
  max-width: 100vw;
  max-height: 100dvh;
  object-fit: contain;
  user-select: none;
  -webkit-user-select: none;
}
.lb-btn {
  position: absolute;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  padding: 0;
  border: 0;
  border-radius: 999px;
  background: rgb(0 0 0 / 55%);
  color: #fff;
  font: 400 28px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  cursor: pointer;
}
.lb-btn:hover { background: rgb(60 60 60 / 75%); }
.lb-btn[hidden] { display: none; }
.lb-close { top: max(12px, env(safe-area-inset-top)); left: 12px; font-size: 20px; }
.lb-prev { left: 12px; top: 50%; transform: translateY(-50%); }
.lb-next { right: 12px; top: 50%; transform: translateY(-50%); }
.lb-count {
  position: absolute;
  top: max(12px, env(safe-area-inset-top));
  right: 16px;
  margin: 0;
  line-height: 44px;
  font-size: 14px;
  font-weight: 700;
}
.lb-alt {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0;
  padding: 12px 16px max(12px, env(safe-area-inset-bottom));
  background: linear-gradient(transparent, rgb(0 0 0 / 70%));
  font-size: 14px;
  text-align: center;
}
.lb-alt[hidden] { display: none; }
