:root {
  --bg: #0c0d11;
  --bg-elev: #14161c;
  --bg-elev-2: #1b1e27;
  --line: rgba(255, 255, 255, 0.08);
  --text: #eef1f6;
  --muted: #9aa3b2;
  --faint: #6b7382;
  --gold: #e8c27a;
  --gold-dim: rgba(232, 194, 122, 0.16);
  --mint: #7ee0c6;
  --rose: #ff8fa3;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --radius: 18px;
  --rank-w: 272px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 10% -10%, rgba(232, 194, 122, 0.08), transparent 50%),
    radial-gradient(900px 500px at 100% 0%, rgba(126, 224, 198, 0.06), transparent 46%),
    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: 18px;
  padding: 12px 4px 22px;
}

.kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--gold);
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.kicker::before {
  content: "";
  width: 18px;
  height: 1px;
  background: var(--gold);
}

h1 {
  margin: 0;
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(36px, 6vw, 68px);
  line-height: 0.95;
  letter-spacing: -0.035em;
  font-weight: 600;
}

.lede {
  max-width: 760px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.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(12,13,17,0.96), rgba(12,13,17,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: rgba(20, 22, 28, 0.9);
  color: var(--text);
  padding: 0 18px 0 42px;
  font: inherit;
  outline: none;
}

.search input:focus {
  border-color: rgba(232, 194, 122, 0.45);
  box-shadow: 0 0 0 4px var(--gold-dim);
}

.search svg {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0.6;
}

.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: #1a1408;
  background: var(--gold);
  border-color: transparent;
}

.count {
  cursor: default;
  color: var(--text);
  background: var(--bg-elev-2);
}

.author-clear {
  color: var(--gold);
  background: var(--gold-dim);
  border-color: rgba(232, 194, 122, 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;
  letter-spacing: 0.04em;
}

.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: rgba(255, 255, 255, 0.04); }
.rank-item.active {
  background: var(--gold-dim);
  box-shadow: inset 0 0 0 1px rgba(232, 194, 122, 0.28);
}

.rank-n {
  color: var(--faint);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

.rank-item:nth-child(1) .rank-n { color: var(--gold); font-weight: 700; }
.rank-item:nth-child(2) .rank-n { color: #cfd6e2; font-weight: 700; }
.rank-item:nth-child(3) .rank-n { color: #d4a574; font-weight: 700; }

.rank-item .avatar {
  width: 36px;
  height: 36px;
}

.rank-who {
  min-width: 0;
}

.rank-who strong {
  display: block;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-who span {
  display: block;
  color: var(--faint);
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.rank-count {
  color: var(--gold);
  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;
}

.rank-more:hover { border-color: rgba(232, 194, 122, 0.4); color: var(--text); }

.grid {
  columns: 3 240px;
  column-gap: 16px;
}

.card {
  break-inside: avoid;
  margin: 0 0 16px;
  background: var(--bg-elev);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}

.media {
  position: relative;
  display: grid;
  gap: 2px;
  background: #0a0b0e;
}

.media img {
  width: 100%;
  height: auto;
  display: block;
  cursor: zoom-in;
}

.media.multi {
  grid-template-columns: 1fr 1fr;
}

.media.multi img:first-child:nth-last-child(odd) {
  grid-column: 1 / -1;
}

.body {
  padding: 14px 14px 12px;
  display: grid;
  gap: 12px;
}

.author {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  background: #2a2e38;
  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;
}

.post-body,
.prompt {
  margin: 0;
  color: #d7dce6;
  font-size: 13.5px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
  max-width: 46em;
}

.prompt-block {
  display: grid;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(232, 194, 122, 0.06);
  border: 1px solid rgba(232, 194, 122, 0.14);
}

.prompt-kicker {
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.prompt-block .prompt {
  color: #eef1f6;
}

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

.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(232, 194, 122, 0.4); }
.btn.copied { background: var(--mint); color: #08231c; border-color: transparent; }

.stats {
  margin-left: auto;
  display: flex;
  gap: 10px;
  color: var(--faint);
  font-size: 12px;
}

.xlink {
  color: var(--gold);
  text-decoration: none;
  font-size: 12px;
}

.empty {
  padding: 80px 20px;
  text-align: center;
  color: var(--muted);
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 6, 8, 0.92);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.lightbox.open { display: flex; }

.lightbox img {
  max-width: min(92vw, 1400px);
  max-height: 88vh;
  object-fit: contain;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.lb-nav, .lb-close {
  position: absolute;
  border: 0;
  background: rgba(255,255,255,0.08);
  color: white;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 22px;
}

.lb-close { top: 18px; right: 18px; }
.lb-prev { left: 18px; }
.lb-next { right: 18px; }
.lb-nav { top: 50%; transform: translateY(-50%); }

.footnote {
  margin-top: 28px;
  color: var(--faint);
  font-size: 12px;
  line-height: 1.5;
}

@media (max-width: 1100px) {
  .grid { columns: 2 240px; }
}

@media (max-width: 900px) {
  .layout { grid-template-columns: 1fr; }
  .rank {
    position: static;
    max-height: none;
    overflow: visible;
  }
  .rank-list:not(.expanded) {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 6px;
  }
  .rank-list:not(.expanded) .rank-item {
    min-width: 220px;
    flex: 0 0 auto;
    background: var(--bg-elev-2);
  }
}

@media (max-width: 720px) {
  .app { width: min(100% - 20px, 1560px); }
  h1 { font-size: 40px; }
  .stats { margin-left: 0; width: 100%; }
  .grid { columns: 1; }
}


/* ----- SPA chrome ----- */
.hero-stats {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 10px 18px;
}

.stat-headline {
  margin: 0;
  color: var(--gold);
  font-family: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  font-size: clamp(20px, 3vw, 30px);
  letter-spacing: -0.02em;
  font-weight: 600;
}

.stat-sub {
  margin: 0;
  color: var(--faint);
  font-size: 13px;
}

.sitenav {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 10px 0 12px;
  margin: 0 0 6px;
  background: linear-gradient(to bottom, rgba(12,13,17,0.98), rgba(12,13,17,0.88) 80%, transparent);
  backdrop-filter: blur(12px);
}

.nav-link {
  height: 36px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 0 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev);
  color: var(--muted);
  text-decoration: none;
  font-size: 13px;
}

.nav-link:hover { border-color: rgba(232, 194, 122, 0.4); color: var(--text); }
.nav-link.active {
  color: #1a1408;
  background: var(--gold);
  border-color: transparent;
}

.nav-badge {
  min-width: 18px;
  height: 18px;
  padding: 0 6px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.18);
  color: inherit;
  font-size: 11px;
  line-height: 18px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.nav-link.active .nav-badge { background: rgba(26, 20, 8, 0.16); }
.nav-badge.zero { opacity: 0.55; }

.nav-stat {
  margin-left: auto;
  color: var(--gold);
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.view-posts .toolbar { top: 52px; }
.view-posts .rank { top: 128px; }

.view-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 0 16px;
}

.view-head h2 {
  margin: 0 0 4px;
  font-size: 20px;
  letter-spacing: 0.02em;
}

.view-sub {
  margin: 0;
  color: var(--faint);
  font-size: 13px;
  max-width: 640px;
  line-height: 1.5;
}

/* ----- waterfall ----- */
.waterfall {
  columns: 8 110px;
  column-gap: 6px;
}

.wf-tile {
  position: relative;
  break-inside: avoid;
  margin: 0 0 6px;
  border-radius: 8px;
  overflow: hidden;
  background: #0a0b0e;
  border: 1px solid var(--line);
  cursor: pointer;
}

.wf-tile img {
  width: 100%;
  height: auto;
  display: block;
  vertical-align: middle;
}

.wf-overlay {
  position: absolute;
  inset: auto 0 0 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 28px 10px 8px;
  background: linear-gradient(to top, rgba(0,0,0,0.72), transparent);
  color: #fff;
  font-size: 12px;
  opacity: 0;
  transition: opacity 0.16s ease;
  pointer-events: none;
}

.wf-tile:hover .wf-overlay,
.wf-tile.faved .wf-overlay,
.wf-tile:focus-within .wf-overlay { opacity: 1; }

.wf-author {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  opacity: 0.9;
}

.wf-heart {
  font-size: 18px;
  color: rgba(255,255,255,0.7);
  text-shadow: 0 1px 4px rgba(0,0,0,0.5);
}

.wf-tile.faved .wf-heart { color: var(--rose); }

.wf-view {
  position: absolute;
  top: 8px;
  right: 8px;
  height: 28px;
  padding: 0 10px;
  border: 0;
  border-radius: 999px;
  background: rgba(12,13,17,0.72);
  color: #fff;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.16s ease;
}

.wf-tile:hover .wf-view,
.wf-tile:focus-within .wf-view { opacity: 1; }

.wf-sentinel {
  text-align: center;
  color: var(--faint);
  padding: 18px 0 8px;
  font-size: 13px;
}

/* ----- favorites ----- */
.tag-cloud {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 0 12px;
}

.tag-pill span {
  color: inherit;
  opacity: 0.7;
  font-variant-numeric: tabular-nums;
}

.fav-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  padding: 0 0 16px;
}

.batch-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.batch-n {
  color: var(--muted);
  font-size: 13px;
}

.tag-input input {
  height: 38px;
  min-width: 180px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 22, 28, 0.9);
  color: var(--text);
  padding: 0 14px;
  font: inherit;
  font-size: 13px;
  outline: none;
}

.tag-input input:focus {
  border-color: rgba(232, 194, 122, 0.45);
  box-shadow: 0 0 0 4px var(--gold-dim);
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 8px 0 10px;
  border-radius: 999px;
  border: 1px solid rgba(126, 224, 198, 0.22);
  background: rgba(126, 224, 198, 0.08);
  color: var(--mint);
  font-size: 12px;
}

.tag.ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--muted);
  cursor: pointer;
  font: inherit;
  font-size: 12px;
}

.tag.ghost:hover { border-color: rgba(232, 194, 122, 0.4); color: var(--text); }

.tag-x {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 14px;
  line-height: 1;
  padding: 0 0 0 2px;
  opacity: 0.7;
}

.tag-x:hover { opacity: 1; }

.card {
  position: relative;
}

.card-check {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 2;
  width: 22px;
  height: 22px;
  border-radius: 6px;
  background: rgba(12,13,17,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
}

.card-check input { accent-color: var(--gold); cursor: pointer; }

.heart-btn.on {
  background: var(--rose);
  color: #2a0810;
  border-color: transparent;
}

.fav-section { margin-bottom: 22px; }

.fav-h {
  margin: 0 0 12px;
  font-size: 15px;
  color: var(--gold);
}

.fav-h span {
  color: var(--faint);
  font-weight: 400;
  margin-left: 6px;
}

.empty a { color: var(--gold); }

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%) translateY(8px);
  z-index: 80;
  padding: 10px 16px;
  border-radius: 999px;
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: var(--shadow);
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 1400px) {
  .waterfall { columns: 7 110px; }
}

@media (max-width: 1100px) {
  .waterfall { columns: 6 100px; }
}

@media (max-width: 900px) {
  .waterfall { columns: 4 90px; }
  .nav-stat { margin-left: 0; width: 100%; }
  .view-posts .rank { top: auto; }
}

@media (max-width: 720px) {
  .waterfall { columns: 3 80px; }
  .nav-link { font-size: 12px; padding: 0 12px; }
  .stat-headline { font-size: 22px; }
}

body.view-images .app,
.view-images .app {
  width: min(1920px, calc(100% - 16px));
}
