:root {
  --bg: #fff;
  --fg: #1a1a1a;
  --muted: #555;
  --border: #e2e2e2;
  --surface: #fafafa;
  --link: #0b5fff;
  --link-fg: #fff;
  --placeholder-bg: #eee;
  --skeleton-a: #eee;
  --skeleton-b: #f6f6f6;
  --input-border: #b5b5b5;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #121212;
    --fg: #f0f0f0;
    --muted: #b3b3b3;
    --border: #333;
    --surface: #1c1c1c;
    --link: #7aa8ff;
    --link-fg: #0b1220;
    --placeholder-bg: #2a2a2a;
    --skeleton-a: #262626;
    --skeleton-b: #323232;
    --input-border: #4a4a4a;
  }
}

body {
  margin: 0;
  padding: 0;
  font-family: system-ui, sans-serif;
  line-height: 1.6;
  color: var(--fg);
  background: var(--bg);
}

main {
  max-width: 72rem;
  margin: 0 auto;
  padding: 1.5rem 2rem 3rem;
}

a {
  color: var(--link);
}

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

/* Skip link: off-screen until it receives focus, then jumps to the front. */
.skip-link {
  position: absolute;
  top: -3rem;
  left: 0.5rem;
  z-index: 100;
  padding: 0.6rem 1rem;
  background: var(--link);
  color: var(--link-fg);
  border-radius: 0 0 0.4rem 0.4rem;
  transition: top 0.15s ease;
}

.skip-link:focus {
  top: 0;
}

:focus-visible {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}

.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 1rem;
  padding: 1rem 2rem;
  border-bottom: 1px solid var(--border);
}

.brand a {
  font-size: 1.25rem;
  font-weight: 700;
  text-decoration: none;
  color: var(--fg);
}

.site-header nav {
  display: flex;
  gap: 1rem;
}

.site-header nav a {
  padding: 0.5rem 0.25rem;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  text-decoration: none;
  color: var(--fg);
}

.search-form {
  display: flex;
  gap: 0.5rem;
  margin-left: auto;
}

.search-form input {
  min-height: 44px;
  padding: 0 0.75rem;
  border: 1px solid var(--input-border);
  border-radius: 0.3rem;
  font-size: 1rem;
  background: var(--bg);
  color: var(--fg);
}

.search-form button {
  min-height: 44px;
  min-width: 44px;
  padding: 0 1rem;
  border: 1px solid var(--link);
  background: var(--link);
  color: var(--link-fg);
  border-radius: 0.3rem;
  cursor: pointer;
}

h1,
h2 {
  line-height: 1.2;
}

.channels-section,
.shortform-section,
.feed-section {
  margin-top: 2.5rem;
}

.channels-rail {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 0.25rem 0.25rem 1rem;
}

.channel-card {
  flex: 0 0 9rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 1rem 0.75rem;
  text-align: center;
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  background: var(--surface);
}

.channel-avatar {
  border-radius: 50%;
  width: 48px;
  height: 48px;
}

.channel-name {
  margin: 0.2rem 0 0;
  font-size: 0.9rem;
  font-weight: 600;
}

.channel-topic {
  margin: 0;
  font-size: 0.8rem;
  color: var(--muted);
}

.follow-btn {
  margin-top: 0.4rem;
  min-height: 44px;
  min-width: 44px;
  padding: 0 1rem;
  border: 1px solid var(--link);
  border-radius: 999px;
  background: var(--link);
  color: var(--link-fg);
  font-size: 0.85rem;
  cursor: pointer;
}

.follow-btn[aria-pressed="true"] {
  background: transparent;
  color: var(--link);
}

/* Sort chips: real radio inputs (native keyboard support, screen-reader
   group semantics for free) visually hidden in favour of pill-styled
   labels. :has() drives the checked/focus look off the input's own state
   instead of duplicating it in JS. */
.sort-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  align-items: center;
  border: none;
  padding: 0;
  margin: 0 0 1.5rem;
}

.sort-chips input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.sort-chips label {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0.4rem 1rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.9rem;
}

.sort-chips label:has(input:checked) {
  background: var(--link);
  color: var(--link-fg);
  border-color: var(--link);
}

.sort-chips label:has(input:focus-visible) {
  outline: 3px solid var(--link);
  outline-offset: 2px;
}

/* The shared thumbnail component: one aspect ratio per kind, applied
   identically wherever a card appears, so "unified sizing" is enforced by
   this rule rather than eyeballed per page. */
.thumb {
  position: relative;
  min-width: 44px;
  min-height: 44px;
}

.thumb-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

.thumb-media {
  position: relative;
}

.thumb-img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 0.5rem;
  background: var(--placeholder-bg);
}

.thumb-img-hover {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.thumb:hover .thumb-img-hover,
.thumb:focus-within .thumb-img-hover {
  opacity: 1;
}

.thumb-title {
  margin: 0.4rem 0 0;
  font-size: 0.95rem;
}

.thumb-creator {
  margin: 0.15rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
}

.bookmark-btn {
  position: absolute;
  top: 0.4rem;
  right: 0.4rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(0 0 0 / 50%);
  color: #fff;
  border: none;
  border-radius: 50%;
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
}

.bookmark-btn[aria-pressed="true"] {
  background: var(--link);
  color: var(--link-fg);
}

.thumb-short {
  flex: 0 0 9.5rem;
  scroll-snap-align: start;
}

.thumb-short .thumb-img {
  aspect-ratio: 9 / 16;
  object-fit: cover;
}

.shortform-rail {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 0.25rem 0.25rem 1rem;
  scroll-snap-type: x proximity;
}

.thumb-long .thumb-img {
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 1.5rem;
}

.thumb-skeleton {
  aspect-ratio: 16 / 9;
  border-radius: 0.5rem;
  background: linear-gradient(90deg, var(--skeleton-a) 25%, var(--skeleton-b) 50%, var(--skeleton-a) 75%);
  background-size: 200% 100%;
  animation: thumb-shimmer 1.2s ease-in-out infinite;
}

@keyframes thumb-shimmer {
  from {
    background-position: 200% 0;
  }

  to {
    background-position: -200% 0;
  }
}

.feed-sentinel {
  height: 1px;
}

.feed-status {
  min-height: 1.5rem;
  margin-top: 1rem;
  text-align: center;
  color: var(--muted);
}

.site-footer {
  margin-top: 3rem;
  padding: 2rem;
  border-top: 1px solid var(--border);
  background: var(--surface);
  color: var(--fg);
  font-size: 0.95rem;
}

.site-footer address {
  font-style: normal;
}

@media (prefers-reduced-motion: reduce) {
  .skip-link {
    transition: none;
  }

  /* A hover-triggered frame swap reads as an unexpected animation under
     reduced motion, so the feature backs off entirely rather than just
     dropping the transition. */
  .thumb-img-hover {
    display: none;
  }

  .thumb-skeleton {
    animation: none;
    background-position: 0 0;
  }
}
