:root {
  --bg: #FAF9F5;
  --bg-elevated: #FFFFFF;
  --ink: #1A1A1A;
  --ink-2: #3C3C3C;
  --muted: #6B6B6B;
  --line: #E8E6DF;
  --line-strong: #D8D5CC;
  --accent: #CC785C;
  --accent-soft: rgba(204, 120, 92, 0.08);
  --accent-strong: #B55E42;

  --x-brand: #0F0F0F;
  --reddit-brand: #FF4500;
  --github-brand: #24292F;
  --hn-brand: #FF6600;

  --radius: 12px;
  --radius-sm: 8px;
  --shadow-sm: 0 1px 2px rgba(26, 26, 26, 0.03);
  --shadow: 0 1px 4px rgba(26, 26, 26, 0.04);
  --shadow-lg: 0 8px 20px -16px rgba(26, 26, 26, 0.10);

  --font-serif: "Source Serif 4", "Tiempos", Georgia, "Noto Serif SC", "Songti SC", "Source Han Serif SC", "PingFang SC", serif;
  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Noto Sans SC", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Arial, sans-serif;

  color-scheme: light;
}

*, *::before, *::after {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
}

h1, h2, h3 {
  margin: 0;
  font-family: var(--font-serif);
  font-weight: 600;
  letter-spacing: -0.015em;
  color: var(--ink);
}

/* ---------- hero ---------- */
.hero {
  border-bottom: 1px solid var(--line);
  background:
    radial-gradient(ellipse 80% 60% at 20% 0%, rgba(204, 120, 92, 0.07), transparent 60%),
    radial-gradient(ellipse 60% 40% at 100% 0%, rgba(204, 120, 92, 0.05), transparent 60%),
    var(--bg);
}

.hero__inner {
  max-width: 1240px;
  margin: 0 auto;
  padding: 56px 32px 40px;
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
  margin-bottom: 20px;
  letter-spacing: 0.02em;
}

.eyebrow__dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px rgba(204, 120, 92, 0.18);
}

.hero h1 {
  font-size: clamp(34px, 5vw, 54px);
  line-height: 1.08;
  margin-bottom: 16px;
  max-width: 900px;
}

.hero h1 em {
  font-style: normal;
  color: var(--accent);
  font-weight: 600;
}

.lede {
  font-size: 17px;
  color: var(--ink-2);
  max-width: 640px;
  margin: 0 0 28px;
  line-height: 1.55;
}

.hero__sources {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.src-chip {
  display: inline-flex;
  align-items: center;
  height: 28px;
  padding: 0 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
}
.src-chip.src-x { background: var(--x-brand); }
.src-chip.src-reddit { background: var(--reddit-brand); }
.src-chip.src-github { background: var(--github-brand); }
.src-chip.src-hn { background: var(--hn-brand); }

/* ---------- page ---------- */
.page {
  max-width: 1240px;
  margin: 0 auto;
  padding: 28px 32px 80px;
}

/* ---------- toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(250, 249, 245, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.toolbar__row {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.search {
  flex: 1;
  min-width: 240px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.search input {
  border: 0;
  outline: 0;
  flex: 1;
  font-size: 14px;
  font-family: inherit;
  background: transparent;
  color: var(--ink);
}

.search svg {
  width: 16px;
  height: 16px;
  fill: var(--muted);
}

.toolbar__right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort {
  font-size: 13px;
  color: var(--muted);
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.sort select {
  border: 1px solid var(--line);
  background: #fff;
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13px;
  color: var(--ink);
  font-family: inherit;
}

.chips {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink-2);
  font-weight: 500;
  font-size: 13px;
  transition: all .15s ease;
}
.chip:hover {
  border-color: var(--line-strong);
}
.chip.active {
  background: var(--ink);
  color: #fff;
  border-color: var(--ink);
}

.chip__count {
  display: inline-block;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.06);
  color: var(--muted);
  font-weight: 600;
}
.chip.active .chip__count {
  background: rgba(255, 255, 255, 0.18);
  color: rgba(255, 255, 255, 0.92);
}

.stat {
  margin-top: 12px;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 0.01em;
}

/* ---------- grid ---------- */
.grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: start;
}

@media (max-width: 960px) {
  .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero__inner { padding: 40px 24px 32px; }
  .page { padding: 20px 24px 60px; }
}

@media (max-width: 640px) {
  .grid { grid-template-columns: 1fr; }
  .hero__inner { padding: 32px 20px 24px; }
  .page { padding: 16px 20px 48px; }
}

.empty {
  grid-column: 1 / -1;
  padding: 60px 24px;
  text-align: center;
  color: var(--muted);
  border: 1px dashed var(--line-strong);
  border-radius: var(--radius);
  background: #fff;
}
.empty strong {
  display: block;
  color: var(--ink);
  font-family: var(--font-serif);
  font-size: 20px;
  margin-bottom: 6px;
}

/* ---------- card ---------- */
.card {
  display: block;
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  transition: border-color .14s ease, box-shadow .14s ease;
  color: var(--ink);
  contain: layout paint style;
  content-visibility: auto;
  contain-intrinsic-size: 420px;
}

@media (hover: hover) and (pointer: fine) {
  .card:hover {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-lg);
  }
}

.cover {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #EFEDE5;
}

.cover img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
}

.sentinel {
  width: 100%;
  height: 1px;
}

.loadmore {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 12px 0 4px;
}

.loadmore__hint {
  font-size: 12px;
  color: var(--muted);
  text-align: center;
}

/* fallback covers (no image) — per platform brand block */
.cover.fallback {
  aspect-ratio: 16 / 10;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-family: var(--font-serif);
  font-weight: 600;
  font-size: 22px;
  letter-spacing: -0.01em;
  text-align: center;
  padding: 20px;
  position: relative;
}
.cover.fallback::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 120% 80% at 0% 0%, rgba(255, 255, 255, 0.18), transparent 60%),
    radial-gradient(ellipse 120% 80% at 100% 100%, rgba(0, 0, 0, 0.15), transparent 60%);
  pointer-events: none;
}
.cover.fallback .fallback__text {
  position: relative;
  z-index: 1;
  line-height: 1.35;
  max-width: 92%;
  display: -webkit-box;
  -webkit-line-clamp: 6;
  line-clamp: 6;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
/* long-text fallback: drop font-size so a whole tweet/comment still fits the cover block */
.cover.fallback--long {
  font-size: 15px;
  padding: 22px 24px;
  text-align: left;
  align-items: flex-start;
  font-weight: 500;
  font-family: var(--font-sans);
  letter-spacing: normal;
}
.cover.fallback--long .fallback__text {
  -webkit-line-clamp: 8;
  line-clamp: 8;
  max-width: 100%;
}
.cover.fallback.platform-x { background: var(--x-brand); }
.cover.fallback.platform-reddit { background: linear-gradient(135deg, #FF5722, #FF4500); }
.cover.fallback.platform-github { background: linear-gradient(135deg, #2B3137, #1A1E22); }
.cover.fallback.platform-hn { background: linear-gradient(135deg, #FF8A3D, #FF6600); }

/* platform badge over cover */
.badge {
  position: absolute;
  top: 10px;
  right: 10px;
  z-index: 2;
  height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #fff;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}
.badge.platform-x { background: rgba(15, 15, 15, 0.92); }
.badge.platform-reddit { background: rgba(255, 69, 0, 0.94); }
.badge.platform-github { background: rgba(36, 41, 47, 0.94); }
.badge.platform-hn { background: rgba(255, 102, 0, 0.94); }

.card__body {
  padding: 14px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card__title {
  font-family: var(--font-serif);
  font-size: 18px;
  font-weight: 600;
  line-height: 1.3;
  letter-spacing: -0.01em;
  color: var(--ink);
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__summary {
  font-size: 14px;
  color: var(--ink-2);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.card__tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 2px;
}

.tag {
  font-size: 11px;
  padding: 3px 8px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-weight: 500;
  letter-spacing: 0.01em;
}
.tag.neutral {
  background: rgba(0, 0, 0, 0.04);
  color: var(--muted);
}

.card__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  padding-top: 6px;
  border-top: 1px solid var(--line);
  margin-top: 2px;
  flex-wrap: wrap;
}

.card__foot .author {
  color: var(--ink-2);
  font-weight: 500;
}

.card__foot .dot {
  opacity: 0.5;
}

.card__foot .score {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  color: var(--muted);
}

.card__foot .score::before {
  content: "▲";
  font-size: 9px;
  color: var(--accent);
}

.card__foot .comments::before {
  content: "💬 ";
  font-size: 11px;
  opacity: 0.7;
}

/* ---------- button ---------- */
.btn {
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-weight: 500;
  font-size: 13.5px;
  transition: background .15s ease, border-color .15s ease, color .15s ease;
}

.btn.small {
  padding: 7px 12px;
  font-size: 12.5px;
}

.btn.primary {
  background: var(--ink);
  color: #fff;
}
.btn.primary:hover { background: #000; }

.btn.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--line);
}
.btn.ghost:hover {
  color: var(--ink);
  border-color: var(--line-strong);
}

/* ---------- foot ---------- */
.foot {
  max-width: 1240px;
  margin: 0 auto;
  padding: 32px 32px 48px;
  font-size: 13px;
  color: var(--muted);
  border-top: 1px solid var(--line);
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.foot a {
  color: var(--ink-2);
  border-bottom: 1px solid var(--line-strong);
}
.foot a:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.foot__sep {
  opacity: 0.5;
}
