:root {
  --bg: #f6f7f9;
  --bg-elev: #ffffff;
  --bg-elev-2: #f3f4f6;
  --line: rgba(15, 23, 42, 0.10);
  --text: #111827;
  --muted: #4b5563;
  --faint: #6b7280;
  --accent: #0f766e;
  --accent-dim: rgba(15, 118, 110, 0.10);
  --ink: #111827;
  --shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
  --radius: 16px;
  --rank-w: 268px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", Arial, sans-serif;
}
a { color: inherit; }

.app {
  width: min(1560px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 80px;
}

.hero { display: grid; gap: 14px; padding: 8px 4px 18px; }
.kicker {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--accent); font-size: 12px; letter-spacing: 0.16em; text-transform: uppercase;
}
.kicker::before { content: ""; width: 18px; height: 1px; background: var(--accent); }
h1 {
  margin: 0;
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(34px, 5.6vw, 60px);
  line-height: 0.95;
  letter-spacing: -0.035em;
  font-weight: 600;
}
.hero-stats { display: flex; flex-wrap: wrap; gap: 10px 18px; align-items: baseline; }
.stat-headline { margin: 0; font-size: 18px; font-weight: 650; }
.stat-sub { margin: 0; color: var(--muted); font-size: 14px; }
.lede { max-width: 760px; margin: 0; color: var(--muted); font-size: 16px; line-height: 1.55; }

.sitenav {
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 4px 0 16px;
}
.nav-link {
  height: 36px; display: inline-flex; align-items: center;
  padding: 0 14px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--bg-elev);
  text-decoration: none; font-size: 13px; color: var(--muted);
}
.nav-link.active, .nav-link:hover { color: var(--ink); border-color: rgba(15,118,110,0.28); }
.nav-stat { margin-left: auto; color: var(--faint); font-size: 13px; }

.repo-source {
  display: block; margin: 4px 0 14px; padding: 16px 18px;
  text-decoration: none; background: var(--bg-elev);
  border: 1px solid var(--line); border-radius: 16px; box-shadow: var(--shadow);
}
.repo-source:hover { border-color: rgba(15,118,110,0.35); }
.repo-source-kicker { color: var(--accent); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; margin-bottom: 6px; }
.repo-source-title { font-size: 18px; font-weight: 650; letter-spacing: -0.02em; }
.repo-source-desc { margin: 6px 0 10px; color: var(--muted); font-size: 14px; line-height: 1.5; }
.repo-source-meta { display: flex; gap: 12px; color: var(--faint); font-size: 12px; }

.toolbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; flex-wrap: wrap; gap: 12px; align-items: center;
  padding: 14px 0 16px;
  background: linear-gradient(to bottom, rgba(246,247,249,0.96), rgba(246,247,249,0.86) 70%, transparent);
  backdrop-filter: blur(10px);
}
.search { flex: 1 1 320px; position: relative; }
.search input {
  width: 100%; height: 46px; border: 1px solid var(--line); border-radius: 999px;
  background: var(--bg-elev); color: var(--text); padding: 0 18px 0 42px; font: inherit; outline: none;
}
.search input:focus { border-color: rgba(15,118,110,0.45); box-shadow: 0 0 0 4px var(--accent-dim); }
.search svg { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); opacity: 0.55; }
.sorts, .meta { display: flex; align-items: center; gap: 8px; }
.chip, .count {
  height: 38px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--bg-elev); color: var(--muted); padding: 0 14px; font: inherit; font-size: 13px; cursor: pointer;
}
.chip.active { color: #fff; background: var(--accent); border-color: transparent; }
.count { cursor: default; color: var(--text); background: var(--bg-elev-2); }
.author-clear { color: var(--accent); background: var(--accent-dim); border-color: rgba(15,118,110,0.28); }

.layout {
  display: grid;
  grid-template-columns: var(--rank-w) minmax(0, 1fr);
  gap: 22px; align-items: start;
}
.rank {
  position: sticky; top: 76px;
  background: var(--bg-elev); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 16px 12px 12px;
  max-height: calc(100vh - 100px); overflow: auto;
}
.rank-head h2 { margin: 0 8px 4px; font-size: 16px; }
.rank-sub { margin: 0 8px 12px; color: var(--faint); font-size: 12px; }
.rank-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.rank-item {
  display: grid; grid-template-columns: 28px 36px minmax(0, 1fr) auto;
  gap: 8px; align-items: center; width: 100%;
  border: 0; background: transparent; color: inherit; text-align: left;
  padding: 7px 8px; border-radius: 12px; cursor: pointer; font: inherit;
}
.rank-item:hover { background: #f3f4f6; }
.rank-item.active { background: var(--accent-dim); box-shadow: inset 0 0 0 1px rgba(15,118,110,0.22); }
.rank-n { color: var(--faint); font-size: 12px; font-variant-numeric: tabular-nums; text-align: center; }
.rank-item:nth-child(1) .rank-n { color: #b45309; font-weight: 700; }
.rank-item:nth-child(2) .rank-n { color: #4b5563; font-weight: 700; }
.rank-item:nth-child(3) .rank-n { color: #92400e; font-weight: 700; }
.rank-item .avatar { width: 36px; height: 36px; }
.rank-who { min-width: 0; }
.rank-who strong, .rank-who span {
  display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.rank-who strong { font-size: 13px; }
.rank-who span { color: var(--faint); font-size: 11px; }
.rank-count { color: var(--accent); font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.rank-more {
  width: 100%; margin-top: 10px; height: 36px;
  border: 1px solid var(--line); background: var(--bg-elev-2); color: var(--muted);
  border-radius: 999px; font: inherit; font-size: 12px; cursor: pointer;
}

.xfeed {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  align-items: start;
  width: 100%;
}
.xpost {
  display: block; margin: 0; min-width: 0;
  padding: 14px 14px 10px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: 16px;
  box-shadow: var(--shadow);
}
.xpost-head { display: flex; align-items: center; gap: 10px; margin-bottom: 12px; }
.avatar {
  width: 44px; height: 44px; border-radius: 50%; object-fit: cover;
  background: #e5e7eb; flex: 0 0 auto;
}
.who { min-width: 0; }
.who strong { display: block; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who span, .date { color: var(--faint); font-size: 12px; }

.xpost-media {
  display: block; width: 100%; margin: 0 0 12px;
  border-radius: 12px; overflow: hidden; background: #eef1f4;
}
.xpost-row {
  display: block; width: 100%;
  overflow-x: auto; overflow-y: hidden; white-space: nowrap;
  -webkit-overflow-scrolling: touch;
}
.xpost-img {
  display: block;
  width: 100%;
  height: auto;
  max-width: 100%;
  border: 0;
  background: #eef1f4;
}
.xpost-row.multi .xpost-img {
  display: inline-block; vertical-align: top;
  width: 86%; max-width: 86%; height: auto; margin-right: 6px;
}

.xpost-body { display: block; margin: 0 0 10px; }
.post-body, .prompt {
  margin: 0 0 10px;
  color: #1f2937;
  font-size: 13.5px;
  line-height: 1.65;
  white-space: pre-wrap;
  word-break: break-word;
}
.prompt-block {
  display: grid; gap: 8px; padding: 10px 12px; border-radius: 14px;
  background: #f0fdfa; border: 1px solid rgba(15,118,110,0.14);
}
.prompt-kicker { color: var(--accent); font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; }
.prompt-block .prompt { color: #111827; margin: 0; }

.xpost-actions {
  position: sticky; bottom: 0; z-index: 2;
  display: flex; flex-wrap: wrap; gap: 8px; align-items: center;
  padding: 10px 0 4px;
  background: linear-gradient(to top, #fff 70%, transparent);
}
.btn {
  height: 32px; border: 1px solid var(--line); background: var(--bg-elev-2);
  color: var(--text); border-radius: 999px; padding: 0 12px;
  font: inherit; font-size: 12px; cursor: pointer;
}
.btn:hover { border-color: rgba(15,118,110,0.4); }
.btn.copied { background: #0f766e; color: #fff; border-color: transparent; }
.xlink { color: var(--accent); text-decoration: none; font-size: 12px; }
.xpost-stats { margin-left: auto; color: var(--faint); font-size: 12px; display: flex; gap: 8px; }

.empty { padding: 80px 20px; text-align: center; color: var(--muted); }
.wf-sentinel { padding: 18px; text-align: center; color: var(--faint); font-size: 13px; }
.footnote { margin: 36px 4px 0; color: var(--faint); font-size: 12px; line-height: 1.6; max-width: 820px; }

.lightbox {
  position: fixed; inset: 0; z-index: 50;
  background: rgba(17, 24, 39, 0.86);
  display: none; align-items: center; justify-content: center; padding: 20px;
}
.lightbox.open { display: flex; }
.lb-stage { max-width: min(1100px, 100%); max-height: calc(100vh - 40px); }
.lb-stage img { display: block; width: 100%; height: auto; max-height: calc(100vh - 40px); object-fit: contain; }
.lb-close {
  position: absolute; top: 16px; right: 16px; width: 40px; height: 40px;
  border: 0; border-radius: 999px; background: #fff; color: #111; font-size: 24px; cursor: pointer;
}
.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 14px; border-radius: 999px; font-size: 13px;
}

@media (max-width: 980px) {
  .layout { grid-template-columns: 1fr; }
  .rank { position: static; max-height: none; }
}
@media (max-width: 720px) {
  .xfeed { grid-template-columns: 1fr; }
  .app { width: calc(100% - 20px); }
}
