:root {
  --ink: #0f172a;
  --ink-soft: #475569;
  --muted: #94a3b8;
  --line: #e2e8f0;
  --bg: #ffffff;
  --bg-soft: #f8fafc;
  --card-bg: #ffffff;
  --header-bg: rgba(255,255,255,.85);
  --accent: #4f46e5;
  --accent-soft: #eef2ff;
  --accent-ink: #4338ca;
  --radius: 14px;
  --maxw: 1080px;
  --shadow: 0 1px 2px rgba(15,23,42,.04), 0 8px 24px rgba(15,23,42,.06);
}

[data-theme="dark"] {
  --ink: #e5e9f0;
  --ink-soft: #aab4c5;
  --muted: #7b879c;
  --line: #26314a;
  --bg: #0b1120;
  --bg-soft: #111a2e;
  --card-bg: #111a2e;
  --header-bg: rgba(11,17,32,.82);
  --accent: #818cf8;
  --accent-soft: #1c2542;
  --accent-ink: #a5b4fc;
  --shadow: 0 1px 2px rgba(0,0,0,.3), 0 10px 30px rgba(0,0,0,.4);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--ink);
  background: var(--bg);
  line-height: 1.7;
  font-size: 17px;
  -webkit-font-smoothing: antialiased;
  transition: background .3s ease, color .3s ease;
}

a { color: var(--accent-ink); text-decoration: none; }
a:hover { text-decoration: underline; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }

/* Reading progress bar */
.progress { position: fixed; top: 0; left: 0; height: 3px; width: 0; z-index: 100;
  background: linear-gradient(90deg, var(--accent), #a855f7); transition: width .08s linear; }

/* Header */
header.site {
  position: sticky; top: 0; z-index: 50;
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
  border-bottom: 1px solid var(--line);
}
.site-inner { display: flex; align-items: center; justify-content: space-between; height: 64px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 19px; color: var(--ink); letter-spacing: -.02em; }
.brand .logo {
  width: 30px; height: 30px; border-radius: 8px;
  background: linear-gradient(135deg, var(--accent), #7c3aed);
  display: grid; place-items: center; color: #fff; font-weight: 800; font-size: 16px;
}
.nav { display: flex; gap: 22px; align-items: center; }
.nav a { color: var(--ink-soft); font-weight: 600; font-size: 15px; }
.nav a:hover { color: var(--ink); text-decoration: none; }
form.search { display: flex; align-items: center; }
form.search input[type="search"] {
  width: 150px; padding: 7px 12px; border: 1px solid var(--line);
  border-radius: 999px; font-size: 14px; background: var(--bg-soft); color: var(--ink);
  outline: none; transition: border-color .15s ease, width .15s ease;
}
form.search input[type="search"]:focus { border-color: var(--accent); width: 180px; }

/* Icon buttons: theme toggle + hamburger */
.icon-btn {
  width: 38px; height: 38px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--bg-soft); color: var(--ink-soft); display: grid; place-items: center;
  cursor: pointer; padding: 0; transition: background .15s ease, color .15s ease, border-color .15s ease;
}
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }
.icon-btn svg { width: 18px; height: 18px; }
.theme-toggle .moon { display: none; }
[data-theme="dark"] .theme-toggle .sun { display: none; }
[data-theme="dark"] .theme-toggle .moon { display: block; }
.hamburger { display: none; }

@media (max-width: 760px) {
  .hamburger { display: grid; }
  .nav {
    position: fixed; top: 64px; left: 0; right: 0; background: var(--bg);
    border-bottom: 1px solid var(--line); flex-direction: column; align-items: stretch;
    gap: 0; padding: 8px 22px 18px; box-shadow: var(--shadow);
    transform: translateY(-12px); opacity: 0; pointer-events: none; transition: transform .2s ease, opacity .2s ease;
  }
  .nav.open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav a { padding: 12px 0; border-bottom: 1px solid var(--line); font-size: 16px; }
  form.search { padding-top: 12px; }
  form.search input[type="search"], form.search input[type="search"]:focus { width: 100%; }
}

/* Search hero on search page */
.search-hero { margin: 18px 0 8px; }
.search-hero-input {
  width: 100%; padding: 16px 18px; font-size: 18px; border: 1px solid var(--line);
  border-radius: 12px; background: var(--card-bg); color: var(--ink); outline: none;
  box-shadow: var(--shadow);
}
.search-hero-input:focus { border-color: var(--accent); }

/* Newsletter */
.news { background: linear-gradient(135deg, var(--accent-soft), var(--bg-soft)); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.news-inner { display: flex; align-items: center; justify-content: space-between; gap: 28px; padding: 38px 22px; flex-wrap: wrap; }
.news-copy { max-width: 540px; }
.news-copy h2 { font-size: 24px; letter-spacing: -.02em; margin: 0 0 8px; }
.news-copy p { color: var(--ink-soft); font-size: 16px; margin: 0; }
.news-form { display: flex; gap: 10px; flex-wrap: wrap; }
.news-form input[type="email"] {
  padding: 12px 16px; border: 1px solid var(--line); border-radius: 10px;
  font-size: 15px; min-width: 240px; background: var(--card-bg); color: var(--ink); outline: none;
}
.news-form input[type="email"]:focus { border-color: var(--accent); }
@media (max-width: 640px) { .news-form input[type="email"] { min-width: 0; flex: 1; } }

/* Hero */
.hero { padding: 64px 0 40px; background: radial-gradient(1200px 400px at 50% -120px, var(--accent-soft), transparent); }
.hero h1 { font-size: clamp(30px, 5vw, 48px); line-height: 1.1; letter-spacing: -.03em; margin: 0 0 14px; }
.hero p { font-size: 19px; color: var(--ink-soft); max-width: 620px; margin: 0 0 26px; }
.hero-cta { display: flex; gap: 12px; flex-wrap: wrap; }
.hero-stats { display: flex; gap: 32px; margin-top: 30px; flex-wrap: wrap; }
.hero-stats .stat { display: flex; flex-direction: column; }
.hero-stats .num { font-size: 28px; font-weight: 800; color: var(--ink); letter-spacing: -.02em; }
.hero-stats .lbl { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }

.btn {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--accent); color: #fff; font-weight: 700;
  padding: 12px 20px; border-radius: 10px; font-size: 15px;
  border: 0; cursor: pointer; transition: transform .12s ease, background .12s ease, box-shadow .12s ease;
}
.btn:hover { background: var(--accent-ink); text-decoration: none; transform: translateY(-1px); box-shadow: var(--shadow); }
.btn.ghost { background: var(--card-bg); color: var(--ink); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--bg-soft); }

/* Section */
section.block { padding: 40px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 22px; }
.section-head h2 { font-size: 26px; letter-spacing: -.02em; margin: 0; }
.section-head a { font-weight: 600; font-size: 14px; }

/* Grid + cards */
.grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
@media (max-width: 880px) { .grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 560px) { .grid { grid-template-columns: 1fr; } }

.card {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--card-bg); padding: 20px; display: flex; flex-direction: column;
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
.card:hover { box-shadow: var(--shadow); transform: translateY(-2px); border-color: var(--accent); }
.card .cat { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--accent); }
.card h3 { font-size: 19px; margin: 8px 0 8px; letter-spacing: -.01em; line-height: 1.25; }
.card h3 a { color: var(--ink); }
.card p { color: var(--ink-soft); font-size: 15px; margin: 0 0 16px; flex: 1; }
.card .meta { font-size: 13px; color: var(--muted); }
.card.hide { display: none; }
.card-empty { grid-column: 1 / -1; text-align: center; color: var(--muted); padding: 40px 0; }

/* Fade-in on scroll */
.reveal { opacity: 0; transform: translateY(14px); transition: opacity .5s ease, transform .5s ease; }
.reveal.in { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) { .reveal { opacity: 1; transform: none; transition: none; } html { scroll-behavior: auto; } }

/* Article layout with TOC */
.article-layout { display: grid; grid-template-columns: 1fr; gap: 40px; }
@media (min-width: 1024px) { .article-layout { grid-template-columns: 1fr 240px; align-items: start; } }
.breadcrumb { font-size: 14px; color: var(--muted); margin-bottom: 14px; }
.breadcrumb a { color: var(--ink-soft); }
.article { max-width: 760px; margin: 0 auto; padding: 36px 0 60px; width: 100%; }
.article h1 { font-size: clamp(28px, 4.5vw, 42px); line-height: 1.12; letter-spacing: -.03em; margin: 6px 0 10px; }
.article .byline { color: var(--muted); font-size: 14px; margin-bottom: 8px; }
.article .byline .dot { margin: 0 8px; opacity: .5; }
.article h2 { font-size: 26px; letter-spacing: -.02em; margin: 38px 0 12px; scroll-margin-top: 84px; }
.article h3 { font-size: 20px; margin: 26px 0 8px; scroll-margin-top: 84px; }
.article p { margin: 0 0 18px; }
.article ul, .article ol { margin: 0 0 18px; padding-left: 22px; }
.article li { margin-bottom: 8px; }
.article blockquote {
  margin: 22px 0; padding: 14px 18px; border-left: 4px solid var(--accent);
  background: var(--accent-soft); border-radius: 0 10px 10px 0; color: var(--ink-soft);
}
.article table { width: 100%; border-collapse: collapse; margin: 20px 0; font-size: 15px; }
.article th, .article td { border: 1px solid var(--line); padding: 10px 12px; text-align: left; }
.article th { background: var(--bg-soft); font-weight: 700; }
.article code { background: var(--bg-soft); padding: 2px 6px; border-radius: 6px; font-size: 14px; }
.anchor { color: var(--muted); margin-left: 8px; opacity: 0; font-weight: 400; text-decoration: none; }
.article h2:hover .anchor, .article h3:hover .anchor { opacity: 1; }

/* TOC */
.toc { position: sticky; top: 84px; font-size: 14px; display: none; }
@media (min-width: 1024px) { .toc { display: block; } }
.toc .toc-title { font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); margin-bottom: 12px; font-weight: 700; }
.toc a { display: block; color: var(--ink-soft); padding: 5px 0 5px 12px; border-left: 2px solid var(--line); line-height: 1.4; }
.toc a:hover { color: var(--ink); text-decoration: none; }
.toc a.active { color: var(--accent-ink); border-left-color: var(--accent); font-weight: 600; }
.toc a.lvl-3 { padding-left: 24px; font-size: 13px; }

/* Share row */
.share-row { display: flex; align-items: center; gap: 10px; margin: 24px 0 4px; flex-wrap: wrap; }
.share-row .share-label { font-size: 13px; color: var(--muted); font-weight: 600; }
.share-btn {
  display: inline-flex; align-items: center; gap: 6px; font-size: 13px; font-weight: 600;
  padding: 7px 13px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--card-bg); color: var(--ink-soft); cursor: pointer; transition: all .15s ease;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
.share-btn svg { width: 14px; height: 14px; }

.pick-box {
  border: 1px solid var(--accent); background: var(--accent-soft);
  border-radius: var(--radius); padding: 18px 20px; margin: 22px 0;
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
}
.pick-box .label { font-weight: 700; color: var(--accent-ink); }
.pick-box .desc { color: var(--ink-soft); font-size: 15px; flex: 1; min-width: 200px; }

.disclosure {
  margin-top: 36px; padding: 14px 16px; border-radius: 10px;
  background: var(--bg-soft); color: var(--ink-soft); font-size: 13px; border: 1px solid var(--line);
}

/* Ad slots */
.ad-slot { margin: 28px 0; text-align: center; min-height: 90px; }
.ad-slot ins { display: block; margin: 0 auto; }

/* Related reviews */
.related { margin: 36px 0 8px; border-top: 1px solid var(--line); padding-top: 22px; }
.related h2 { font-size: 20px; margin: 0 0 14px; }
.rel-list { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 22px; }
.rel-list li a { color: var(--accent-ink); font-weight: 600; font-size: 15px; }
.rel-list li a:hover { text-decoration: underline; }
@media (max-width: 640px) { .rel-list { grid-template-columns: 1fr; } }

/* Categories / filter chips */
.chips { display: flex; gap: 10px; flex-wrap: wrap; margin: 8px 0 28px; }
.chip { border: 1px solid var(--line); border-radius: 999px; padding: 7px 14px; font-size: 14px; font-weight: 600; color: var(--ink-soft); background: var(--card-bg); cursor: pointer; transition: all .15s ease; }
.chip:hover { border-color: var(--accent); color: var(--accent-ink); text-decoration: none; }
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

/* Back to top */
.to-top {
  position: fixed; right: 22px; bottom: 22px; z-index: 60;
  width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--card-bg); color: var(--ink); display: grid; place-items: center;
  cursor: pointer; box-shadow: var(--shadow); opacity: 0; pointer-events: none;
  transform: translateY(10px); transition: opacity .2s ease, transform .2s ease;
}
.to-top.show { opacity: 1; pointer-events: auto; transform: none; }
.to-top svg { width: 20px; height: 20px; }

/* Footer */
footer.site { border-top: 1px solid var(--line); margin-top: 40px; background: var(--bg-soft); }
.foot-inner { padding: 36px 0; display: flex; justify-content: space-between; gap: 24px; flex-wrap: wrap; }
.foot-inner .col h4 { font-size: 14px; text-transform: uppercase; letter-spacing: .06em; color: var(--muted); margin: 0 0 12px; }
.foot-inner .col a { display: block; color: var(--ink-soft); font-size: 14px; margin-bottom: 8px; }
.foot-bottom { border-top: 1px solid var(--line); padding: 18px 0; color: var(--muted); font-size: 13px; }

.prose-page { max-width: 760px; margin: 0 auto; padding: 40px 0 60px; }
.prose-page h1 { font-size: 38px; letter-spacing: -.02em; margin-bottom: 8px; }
.prose-page h2 { font-size: 24px; margin-top: 34px; }
.prose-page p { color: var(--ink-soft); }

/* Toast */
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%) translateY(20px);
  background: var(--ink); color: var(--bg); padding: 10px 18px; border-radius: 999px;
  font-size: 14px; font-weight: 600; z-index: 200; opacity: 0; pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
