:root {
  --bg: #0a0a0a;
  --bg-soft: #161616;
  --bg-hover: #141414;
  --ink: #f5f5f5;
  --ink-soft: #d6d6d6;
  --muted: #9a9a9a;
  --faint: #6a6a6a;
  --line: #262626;
  --line-soft: #1b1b1b;
  --radius: 6px;
  --max: 1000px;
  --read: 680px;
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}
body { min-height: 100vh; }

.wrap { width: 100%; max-width: var(--max); margin: 0 auto; padding: 0 22px; }
a { color: inherit; text-decoration: none; }

::selection { background: var(--ink); color: var(--bg); }
a:focus-visible, button:focus-visible, input:focus-visible {
  outline: 2px solid var(--muted); outline-offset: 3px; border-radius: 3px;
}

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 50;
  background: var(--ink); color: var(--bg); padding: 10px 16px; border-radius: var(--radius);
}
.skip:focus { left: 16px; top: 12px; }

/* ---------- Top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(10, 10, 10, 0.85);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}
.topbar .wrap { display: flex; align-items: center; gap: 24px; height: 70px; position: relative; }
.brand {
  font-family: var(--serif); font-size: 23px; font-weight: 500; letter-spacing: -0.2px;
  color: var(--ink); flex: none;
}
.topnav { flex: 1; display: flex; justify-content: center; gap: 36px; }
.topnav a {
  position: relative; font-size: 14px; color: var(--muted); padding: 6px 1px;
  letter-spacing: .2px; transition: color .15s;
}
.topnav a::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1.5px;
  background: var(--ink); transform: scaleX(0); transform-origin: left; transition: transform .2s ease;
}
.topnav a:hover { color: var(--ink); }
.topnav a:hover::after { transform: scaleX(1); }
.status { flex: none; display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 13px; }
/* Fixed width so the changing status text ("Live" -> "Updated 5m ago") never
   reflows the centered nav. */
#updated { display: inline-block; min-width: 108px; text-align: right; font-variant-numeric: tabular-nums; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); display: inline-block; }
.dot.live { background: var(--ink); }
.ghost-btn {
  background: var(--bg-soft); border: 1px solid var(--line); color: var(--ink-soft);
  cursor: pointer; font-family: var(--sans); font-size: 13px; padding: 7px 14px;
  border-radius: var(--radius); transition: .15s; line-height: 1;
}
.ghost-btn:hover { color: var(--ink); border-color: var(--muted); background: #1d1d1d; }

/* Hamburger (mobile only) */
.navtoggle {
  display: none; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; width: 36px; height: 36px; padding: 0; cursor: pointer;
  background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius);
}
.navtoggle span { width: 16px; height: 1.5px; background: var(--ink-soft); transition: transform .2s, opacity .2s; }
.navtoggle[aria-expanded="true"] span:nth-child(1) { transform: translateY(5.5px) rotate(45deg); }
.navtoggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.navtoggle[aria-expanded="true"] span:nth-child(3) { transform: translateY(-5.5px) rotate(-45deg); }

/* ---------- Hero / controls ---------- */
.hero { padding: 56px 0 8px; }
.hero h1 {
  font-family: var(--serif); font-weight: 500; font-size: 42px; line-height: 1.1;
  letter-spacing: -0.6px; margin: 0 0 14px;
}
.hero p { margin: 0; color: var(--muted); font-size: 16px; }
.hero .count { color: var(--ink); font-weight: 600; }
.yearnav { margin: 18px 0 0; font-size: 13px; color: var(--muted); }
.yearnav a { color: var(--ink-soft); border-bottom: 1px solid var(--line); margin: 0 4px; padding-bottom: 1px; }
.yearnav a:hover { border-bottom-color: var(--ink); color: var(--ink); }

.controls { margin: 40px 0 0; }
.search {
  width: 100%;
  background: transparent; border: none; border-bottom: 1px solid var(--line);
  color: var(--ink); padding: 10px 2px; font-size: 16px; font-family: var(--sans);
  outline: none; transition: .15s;
}
.search:focus { border-bottom-color: var(--ink); }
.search::placeholder { color: var(--faint); }

.chips { display: flex; flex-wrap: wrap; gap: 4px 20px; margin: 22px 0 0; }
.chip {
  background: none; border: none; cursor: pointer; padding: 4px 0;
  font-family: var(--sans); font-size: 13px; color: var(--muted);
  border-bottom: 1.5px solid transparent; transition: .15s;
}
.chip:hover { color: var(--ink); }
.chip.active { color: var(--ink); font-weight: 600; border-bottom-color: var(--ink); }

/* ---------- Timeline (editorial list) ---------- */
.timeline { padding: 18px 0 60px; }
.day-label {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px;
  color: var(--faint); font-weight: 600; margin: 38px 0 6px; padding-bottom: 8px;
  border-bottom: 1px solid var(--line);
}
.day-items { display: block; }

.card {
  display: flex; gap: 18px; align-items: flex-start;
  padding: 24px 0; border-bottom: 1px solid var(--line-soft);
  transition: .12s; border-radius: var(--radius);
}
.card:hover { background: var(--bg-hover); padding-left: 14px; padding-right: 14px; margin: 0 -14px; }
.card-body { flex: 1; min-width: 0; }

.card-top { display: flex; align-items: baseline; gap: 10px; margin-bottom: 7px; flex-wrap: wrap; }
.badge {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.2px;
  color: var(--ink);
}
.badge.news { color: var(--faint); font-weight: 600; }
.src { font-size: 13px; color: var(--muted); }
.time { font-size: 12.5px; color: var(--faint); margin-left: auto; white-space: nowrap; }

.card h3 {
  font-family: var(--serif); font-weight: 500; font-size: 21px; line-height: 1.3;
  margin: 0 0 6px; letter-spacing: -0.2px; color: var(--ink);
}
.card:hover h3 { text-decoration: underline; text-underline-offset: 3px; }
.card p { margin: 0; color: var(--muted); font-size: 14.5px; line-height: 1.55; }
.card .meta { margin-top: 10px; display: flex; gap: 18px; flex-wrap: wrap; font-size: 12.5px; color: var(--faint); }
.card .meta b { color: var(--ink-soft); font-weight: 600; }

.logo {
  width: 46px; height: 46px; border-radius: var(--radius); object-fit: contain;
  background: #fff; padding: 5px; flex: none; border: 1px solid var(--line);
}

/* ---------- Detail ---------- */
.back {
  display: inline-flex; align-items: center; gap: 7px; color: var(--muted);
  font-size: 13.5px; margin: 40px 0 28px; cursor: pointer; transition: .15s;
}
.back:hover { color: var(--ink); }

.detail { padding-bottom: 70px; max-width: var(--read); }
.detail-head { display: flex; gap: 20px; align-items: flex-start; }
.detail .logo { width: 64px; height: 64px; border-radius: var(--radius); }
.detail h1 {
  font-family: var(--serif); font-weight: 500; font-size: 34px; line-height: 1.15;
  letter-spacing: -0.5px; margin: 0 0 14px;
}
.detail-meta { display: flex; flex-wrap: wrap; gap: 8px 10px; align-items: center; }
.pill {
  font-size: 12.5px; padding: 4px 11px; border-radius: var(--radius);
  background: var(--bg-soft); color: var(--muted);
}
.pill b { color: var(--ink); font-weight: 600; }
.pill.danger { background: var(--ink); color: var(--bg); }
.pill.danger b { color: var(--bg); }

.section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 1.4px; color: var(--faint);
  font-weight: 600; margin: 40px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--line);
}
.detail-desc { font-family: var(--serif); color: var(--ink-soft); font-size: 18px; line-height: 1.75; }
.advice { margin: 0; padding-left: 1.15em; }
.advice li { color: var(--ink-soft); font-size: 15.5px; line-height: 1.7; margin-bottom: 8px; }
.related { list-style: none; margin: 0; padding: 0; }
.related li { padding: 12px 0; border-bottom: 1px solid var(--line-soft); }
.related a { font-family: var(--serif); font-size: 16px; color: var(--ink); }
.related a:hover { text-decoration: underline; text-underline-offset: 3px; }
.rel-src { color: var(--faint); font-size: 12.5px; margin-left: 10px; }

/* FAQ */
.faq-item { padding: 14px 0; border-bottom: 1px solid var(--line-soft); }
.faq-q { font-family: var(--sans); font-size: 15.5px; font-weight: 600; color: var(--ink); margin: 0 0 6px; }
.faq-a { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.65; }

/* Home "showing recent" note */
.more-note { margin: 18px 0 50px; color: var(--muted); font-size: 14px; }
.more-note a { color: var(--ink); border-bottom: 1px solid var(--line); }
.more-note a:hover { border-bottom-color: var(--ink); }

/* Stats */
.statgrid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin: 28px 0 10px; }
.stat { background: var(--bg-soft); border-radius: var(--radius); padding: 18px 16px; }
.stat-n { font-family: var(--serif); font-size: 28px; font-weight: 500; color: var(--ink); line-height: 1.1; }
.stat-l { font-size: 12.5px; color: var(--muted); margin-top: 4px; }
.ranklist { list-style: none; margin: 0; padding: 0; }
.ranklist li { display: flex; align-items: center; gap: 12px; padding: 11px 0; border-bottom: 1px solid var(--line-soft); font-size: 14.5px; }
.ranklist li a { color: var(--ink); }
.ranklist li a:hover { text-decoration: underline; text-underline-offset: 3px; }
.ranklist li b { margin-left: auto; color: var(--ink); font-variant-numeric: tabular-nums; }
.ranklist li .rank { color: var(--faint); font-variant-numeric: tabular-nums; min-width: 26px; flex: none; }
.pill-link:hover { background: #1d1d1d; color: var(--ink); }
.ranklist li .bar { height: 6px; border-radius: 3px; background: var(--ink); width: var(--w); max-width: 45%; opacity: .35; }
.ranklist.plain li .bar { display: none; }

/* Prose pages (About, Methodology) */
.prose { max-width: var(--read); }
.prose p { color: var(--ink-soft); font-size: 16.5px; line-height: 1.75; margin: 0 0 18px; }
.prose h2 { font-family: var(--serif); font-weight: 500; font-size: 22px; margin: 32px 0 12px; }
.prose ul { margin: 0 0 18px; padding-left: 1.2em; }
.prose li { color: var(--ink-soft); font-size: 16px; line-height: 1.7; margin-bottom: 8px; }
.prose a { color: var(--ink); border-bottom: 1px solid var(--line); }
.prose a:hover { border-bottom-color: var(--ink); }

/* Footer nav */
.footnav { margin: 0 0 14px; font-size: 12.5px; color: var(--faint); }
.footnav a { color: var(--ink-soft); }
.footnav a:hover { color: var(--ink); }

@media (max-width: 640px) {
  .statgrid { grid-template-columns: repeat(2, 1fr); }

  /* Mobile header: brand left, Refresh centered, hamburger right. */
  .topbar .wrap { gap: 0; justify-content: space-between; }
  /* Smaller brand, capped so it never reaches the centered Refresh button. */
  .brand { font-size: 16px; max-width: calc(50% - 66px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .navtoggle { display: flex; }
  .status { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); gap: 0; }
  .status .dot, #updated { display: none; }

  /* Nav links collapse into a dropdown panel toggled by the hamburger. */
  .topnav {
    display: none; position: absolute; top: 100%; left: 0; right: 0;
    flex-direction: column; gap: 0; padding: 4px 22px 14px;
    background: var(--bg); border-bottom: 1px solid var(--line);
  }
  .topnav.open { display: flex; }
  .topnav a { padding: 14px 0; border-bottom: 1px solid var(--line-soft); font-size: 15px; color: var(--ink-soft); }
  .topnav a::after { display: none; }
}
.exposed { display: flex; flex-wrap: wrap; gap: 8px; }
.exposed .tag {
  background: var(--bg-soft); color: var(--ink-soft); border: 1px solid var(--line);
  padding: 5px 12px; border-radius: var(--radius); font-size: 13px;
}

.cta {
  display: inline-flex; align-items: center; gap: 8px; margin-top: 36px;
  background: var(--ink); color: var(--bg); font-weight: 600; font-size: 14px;
  font-family: var(--sans); padding: 12px 20px; border-radius: var(--radius); transition: .15s;
}
.cta:hover { background: #fff; }

/* ---------- States ---------- */
.loading, .empty { text-align: center; color: var(--muted); padding: 80px 0; font-size: 16px; font-family: var(--serif); }
.err { background: var(--bg-soft); color: var(--ink-soft); border: 1px solid var(--line); padding: 14px 18px; border-radius: var(--radius); margin: 20px 0; font-size: 14px; }
.foot { color: var(--faint); font-size: 12.5px; padding-top: 26px; padding-bottom: 56px; border-top: 1px solid var(--line); margin-top: 20px; }
.foot p { margin: 0; line-height: 1.6; max-width: 56ch; }

@media (max-width: 560px) {
  .hero { padding: 40px 0 4px; }
  .hero h1 { font-size: 32px; }
  .detail h1 { font-size: 26px; }
  .detail-desc { font-size: 16px; }
  .card { gap: 14px; }
  .logo { width: 40px; height: 40px; }
}
