:root {
  color-scheme: light dark;
  --page: #f4f1ea;
  --surface: #fffdf8;
  --text: #171714;
  --muted: #6d6a62;
  --line: #d9d3c7;
  --accent: #245f4d;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  min-width: 320px;
  margin: 0;
  background: var(--page);
  color: var(--text);
  line-height: 1.5;
}

a:focus-visible, button:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* Top bar: stays pinned so account search is always one tap away. */
.topbar {
  position: sticky;
  z-index: 20;
  top: 0;
  padding: .75rem;
  border-bottom: 1px solid var(--line);
  background: var(--page);
}
.topbar-inner {
  display: flex;
  gap: .75rem;
  align-items: flex-start;
  width: min(100%, 640px);
  margin-inline: auto;
}
.wordmark {
  display: inline-flex;
  flex: none;
  gap: .5rem;
  align-items: center;
  height: 2.875rem;
  color: var(--text);
  font-size: 1.125rem;
  font-weight: 700;
  text-decoration: none;
}
.wordmark svg { width: 1.75rem; height: 1.75rem; }

.account-search { flex: 1; min-width: 0; }
.combo { position: relative; }
.combo input {
  width: 100%;
  padding: .75rem 1rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: 1rem;
}
.combo input:focus-visible { outline: 3px solid var(--accent); outline-offset: 1px; }
.search-status { margin: .375rem 0 0; color: var(--muted); font-size: .8125rem; }
.search-status:empty { display: none; }
.account-results {
  position: absolute;
  z-index: 10;
  top: calc(100% + .25rem);
  right: 0;
  left: 0;
  max-height: min(22rem, 60vh);
  margin: 0;
  padding: .25rem;
  overflow-y: auto;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--surface);
  box-shadow: 0 .75rem 2rem rgb(0 0 0 / .18);
}
.account-option {
  display: flex;
  gap: .625rem;
  align-items: center;
  padding: .5rem .625rem;
  border-radius: .5rem;
  cursor: pointer;
}
.account-option:hover, .account-option[aria-selected="true"] { background: color-mix(in srgb, var(--accent) 14%, transparent); }
.account-option img { flex: none; border-radius: 50%; }
.option-text { display: flex; flex-direction: column; min-width: 0; }
.option-name, .option-handle { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.option-name { font-weight: 700; }
.option-handle { color: var(--muted); font-size: .875rem; }

/* Feed button, then the saved accounts. */
.saved-nav {
  display: flex;
  gap: .5rem;
  align-items: flex-start;
  width: min(100% - 1.5rem, 640px);
  margin: .75rem auto 0;
}
.saved-accounts {
  display: flex;
  flex: 1;
  gap: .5rem;
  min-width: 0;
  margin: 0;
  padding: 0 0 .25rem;
  overflow-x: auto;
  list-style: none;
  scrollbar-width: thin;
}
.saved-accounts li { flex: none; }
.saved-account {
  display: inline-flex;
  gap: .375rem;
  align-items: center;
  padding: .375rem .75rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
  color: var(--text);
  font: inherit;
  font-size: .875rem;
  white-space: nowrap;
  cursor: pointer;
}
.saved-account:has(img) { padding-left: .375rem; }
.saved-account img { border-radius: 50%; }
.saved-account[aria-current="page"] {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, var(--surface));
  font-weight: 700;
}
.feed-link { flex: none; text-decoration: none; }

.reader {
  width: min(100% - 1.5rem, 640px);
  margin: .75rem auto 2rem;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 1rem;
  background: var(--surface);
}

.account-heading {
  display: flex;
  gap: .875rem;
  align-items: center;
  padding: 1rem;
  border-bottom: 1px solid var(--line);
}
.view-avatar { flex: none; width: 3rem; height: 3rem; border-radius: 50%; object-fit: cover; }
.view-names { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.view-names h1 { margin: 0; font-size: 1.5rem; line-height: 1.25; }
#view-subtitle { margin: 0; color: var(--muted); }

.save-toggle {
  flex: none;
  padding: .5rem .875rem;
  border: 1px solid var(--accent);
  border-radius: 999px;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.save-toggle[aria-pressed="true"] { background: var(--accent); color: var(--surface); }

#feed-status, .fallback { padding: 1rem; }
#feed-status { margin: 0; color: var(--muted); }
.fallback { margin: 1rem; border: 1px solid var(--line); border-radius: .75rem; }
.fallback h2 { margin-top: 0; }
.fallback a { color: var(--accent); font-weight: 700; }

.profile-card { padding: 1rem; border-bottom: 1px solid var(--line); }
.profile-bio { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.profile-bio a { color: var(--accent); }
.profile-bio a.mention { text-decoration: none; }
.profile-bio a:hover { text-decoration: underline; }

.post-list { margin: 0; padding: 0; list-style: none; }
.post-list > li { padding: 1rem; border-bottom: 1px solid var(--line); }
.post { min-width: 0; overflow-wrap: anywhere; }
.post-repost { margin: 0 0 .5rem; color: var(--muted); font-size: .8125rem; font-weight: 600; }
.post-repost a { color: inherit; }
.post-author { display: flex; gap: .625rem; align-items: center; }
.post .post-author-link {
  display: flex;
  gap: .625rem;
  align-items: center;
  min-width: 0;
  color: inherit;
  text-decoration: none;
}
.post a.post-author-link:hover .post-name { text-decoration: underline; }
.post-author img { flex: none; border-radius: 50%; }
.post-author div { display: flex; flex-wrap: wrap; column-gap: .375rem; min-width: 0; }
.post-name { font-weight: 700; }
.post-handle { color: var(--muted); }
.post-text { margin: .625rem 0 0; white-space: pre-wrap; }
.post-text.is-clamped {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 9;
}
.post a { color: var(--accent); }
.post a.mention { text-decoration: none; }
.post a.mention:hover { text-decoration: underline; }
.show-more {
  padding: .25rem 0;
  border: 0;
  background: none;
  color: var(--accent);
  font: inherit;
  font-size: .875rem;
  font-weight: 700;
  cursor: pointer;
}

.post-media { display: grid; gap: .375rem; margin-top: .75rem; }
.post-media > a { display: block; min-width: 0; }
.post-media img, .post-media video {
  display: block;
  width: 100%;
  height: auto;
  max-height: 32rem;
  object-fit: cover;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: var(--line);
}
.post-media:not([data-count="1"]) { grid-template-columns: 1fr 1fr; }
.post-media:not([data-count="1"]) img, .post-media:not([data-count="1"]) video { aspect-ratio: 1 / 1; height: 100%; }
.post-media[data-count="3"] > :last-child { grid-column: span 2; }
.post-media[data-count="3"] > :last-child img, .post-media[data-count="3"] > video:last-child { aspect-ratio: 2 / 1; }

.post-quote { margin: .75rem 0 0; padding: .75rem; border: 1px solid var(--line); border-radius: .75rem; }
.post-quote .post-author img { width: 24px; height: 24px; }
.post-unavailable { margin: 0; color: var(--muted); font-style: italic; }
.post-meta { margin-top: .625rem; color: var(--muted); font-size: .8125rem; }
.feed-empty { margin: 0; padding: 1rem; color: var(--muted); }

/* The combined feed's ending. */
.feed-notice { margin: 0; padding: .75rem 1rem; border-bottom: 1px solid var(--line); color: var(--muted); font-size: .875rem; }
.caught-up { padding: 1.5rem 1rem; text-align: center; }
.caught-up-title { margin: 0; font-size: 1.0625rem; font-weight: 700; }
.caught-up-detail { margin: .25rem 0 0; color: var(--muted); font-size: .9375rem; }
.caught-up + .load-more { margin-top: 0; }

.load-more {
  display: block;
  width: calc(100% - 2rem);
  margin: 1rem;
  padding: .75rem;
  border: 1px solid var(--line);
  border-radius: .75rem;
  background: transparent;
  color: var(--accent);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}
.load-more:disabled { color: var(--muted); cursor: progress; }
.load-more + .post-list { border-top: 1px solid var(--line); }

.source-note {
  width: min(100% - 1.5rem, 640px);
  margin: 0 auto 2rem;
  color: var(--muted);
  font-size: .8125rem;
}
.source-note a { color: inherit; }

/* Back to top. */
.to-top {
  position: fixed;
  z-index: 30;
  right: 1rem;
  bottom: calc(1rem + env(safe-area-inset-bottom));
  display: grid;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--surface);
  color: var(--accent);
  box-shadow: 0 .25rem .75rem rgb(0 0 0 / .12);
  cursor: pointer;
}
.to-top svg { width: 1.25rem; height: 1.25rem; }

@media (prefers-color-scheme: dark) {
  :root {
    --page: #111412;
    --surface: #181d1a;
    --text: #f2f0e9;
    --muted: #aaa9a3;
    --line: #343a36;
    --accent: #7bc8aa;
  }
}

@media (max-width: 520px) {
  .topbar { padding-inline: 1rem; }
  .saved-nav, .reader { width: 100%; }
  .saved-nav { padding-inline: 1rem; }
  .reader { margin-bottom: 0; border-inline: 0; border-radius: 0; }
  .source-note { width: 100%; padding: 1rem; }
}

@media (max-width: 420px) {
  .wordmark span { display: none; }
}
