:root {
  --bg: #f4f7fb;
  --panel: #ffffff;
  --text: #172033;
  --muted: #64748b;
  --line: #e2e8f0;
  --brand: #2563eb;
  --brand-soft: #eff4ff;
  --ok: #16a34a;
  --warn: #b45309;
  --warn-bg: #fff8ed;
  --warn-line: #fcd9a4;
  --header: rgba(255, 255, 255, .86);
  --shadow: 0 10px 30px rgba(23, 32, 51, .07);
  --radius: 16px;
}
html[data-theme="dark"] {
  --bg: #0a111f;
  --panel: #111a2b;
  --text: #e6ecf7;
  --muted: #93a3ba;
  --line: #223048;
  --brand: #6ea0ff;
  --brand-soft: #16233c;
  --ok: #4ade80;
  --warn: #fbbf24;
  --warn-bg: #2a2110;
  --warn-line: #5c4720;
  --header: rgba(10, 17, 31, .86);
  --shadow: 0 12px 32px rgba(0, 0, 0, .35);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.75 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
button, select, input { font: inherit; color: inherit; }
code { background: var(--brand-soft); border-radius: 5px; padding: 1px 5px; font-size: .9em; }

/* header */
.site-header {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 14px;
  padding: 12px clamp(14px, 3vw, 34px);
  background: var(--header);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand-mark {
  width: 36px; height: 36px; border-radius: 11px; flex: 0 0 auto;
  background: linear-gradient(135deg, #2563eb, #0ea5e9 60%, #22d3ee);
  display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px rgba(37, 99, 235, .35);
}
.brand-mark svg { width: 20px; height: 20px; }
.brand-text { min-width: 0; }
.brand-text strong { display: block; font-size: 15px; line-height: 1.2; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-text span { display: block; color: var(--muted); font-size: 12px; line-height: 1.3; }
.header-tools { margin-inline-start: auto; display: flex; align-items: center; gap: 8px; }
.search-box { position: relative; display: flex; align-items: center; }
.search-box svg { position: absolute; inset-inline-start: 10px; width: 16px; height: 16px; color: var(--muted); pointer-events: none; }
#search {
  width: min(28vw, 260px); padding: 9px 12px 9px 34px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--panel); outline: none;
}
[dir="rtl"] #search { padding: 9px 34px 9px 12px; }
#search:focus { border-color: var(--brand); box-shadow: 0 0 0 3px rgba(37, 99, 235, .15); }
.icon-btn {
  width: 36px; height: 36px; display: grid; place-items: center;
  border: 1px solid var(--line); border-radius: 10px; background: var(--panel); cursor: pointer;
}
.icon-btn:hover { border-color: var(--brand); color: var(--brand); }
.icon-btn svg { width: 18px; height: 18px; }
.back-link {
  display: inline-flex; align-items: center; gap: 6px;
  height: 36px; padding: 0 12px; white-space: nowrap;
  border: 1px solid var(--line); border-radius: 10px;
  background: var(--panel); color: inherit; text-decoration: none; font-size: 13px;
}
.back-link:hover { border-color: var(--brand); color: var(--brand); }
.back-link svg { width: 16px; height: 16px; }
.lang-select {
  border: 1px solid var(--line); background: var(--panel); border-radius: 10px;
  padding: 8px 10px; max-width: 190px; cursor: pointer;
}
.toc-toggle { display: none; }

/* shell */
.shell {
  display: grid;
  grid-template-columns: 268px minmax(0, 1fr);
  gap: clamp(18px, 3vw, 38px);
  max-width: 1480px; margin: 0 auto; padding: clamp(18px, 3vw, 34px);
}
.toc {
  position: sticky; top: 82px; align-self: start;
  max-height: calc(100vh - 100px); overflow: auto;
  padding: 16px; border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow);
}
.toc h2 { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--muted); margin: 0 0 10px; }
.toc ol { list-style: none; margin: 0; padding: 0; counter-reset: toc; }
.toc li { counter-increment: toc; }
.toc a {
  display: flex; gap: 9px; padding: 7px 9px; border-radius: 8px; color: var(--text);
  font-size: 13px; line-height: 1.45;
}
.toc a::before { content: counter(toc, decimal-leading-zero); color: var(--muted); font-variant-numeric: tabular-nums; }
.toc a:hover, .toc a.active { background: var(--brand-soft); color: var(--brand); text-decoration: none; }
.toc .faq-link { margin-top: 8px; padding-top: 8px; border-top: 1px dashed var(--line); }
.toc .faq-link a::before { content: "?"; }

main { min-width: 0; }
.hero {
  padding: clamp(22px, 4vw, 40px); border: 1px solid var(--line); border-radius: var(--radius);
  background:
    radial-gradient(900px 300px at 88% -10%, rgba(14, 165, 233, .16), transparent 60%),
    radial-gradient(700px 260px at 8% 0%, rgba(37, 99, 235, .13), transparent 55%),
    var(--panel);
  box-shadow: var(--shadow);
}
.hero .eyebrow { display: inline-flex; align-items: center; gap: 7px; color: var(--brand); font-size: 12px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.hero h1 { margin: 12px 0 10px; font-size: clamp(26px, 3.6vw, 40px); line-height: 1.2; letter-spacing: -.02em; }
.hero p { margin: 0; max-width: 760px; color: var(--muted); font-size: 15.5px; }
.hero-meta { margin-top: 18px; display: flex; flex-wrap: wrap; gap: 8px; }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px; border-radius: 999px; background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; }

.chapter {
  margin-top: 26px; padding: clamp(20px, 3vw, 34px);
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--panel); box-shadow: var(--shadow);
  scroll-margin-top: 90px;
}
.chapter-head { display: flex; gap: 14px; align-items: baseline; }
.chapter-index {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center; font-weight: 800; font-size: 15px;
  color: var(--brand); background: var(--brand-soft); font-variant-numeric: tabular-nums;
}
.chapter h2 { margin: 0; font-size: clamp(20px, 2.4vw, 25px); line-height: 1.3; letter-spacing: -.01em; }
.chapter .intro { margin: 12px 0 0; color: var(--muted); font-size: 15px; }
.points { margin: 18px 0 0; padding: 0; list-style: none; display: grid; gap: 9px; }
.points li { position: relative; padding-inline-start: 26px; font-size: 14.5px; }
.points li::before {
  content: ""; position: absolute; inset-inline-start: 0; top: .55em;
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--brand); box-shadow: 0 0 0 4px var(--brand-soft);
}
.note {
  margin: 18px 0 0; padding: 12px 14px; border: 1px solid var(--warn-line);
  border-radius: 12px; background: var(--warn-bg); color: var(--warn); font-size: 13.5px;
}
.note strong { font-weight: 700; }

.shots { margin-top: 20px; display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); }
.shot { margin: 0; border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg); }
.shot a { display: block; }
.shot img { display: block; width: 100%; height: auto; }
.shot figcaption { padding: 10px 12px; font-size: 12.5px; color: var(--muted); border-top: 1px solid var(--line); background: var(--panel); }
.shots figure:only-child { grid-column: 1 / -1; }

/* faq */
.faq { margin-top: 26px; }
.faq h2 { font-size: clamp(20px, 2.4vw, 25px); margin: 0 0 14px; }
.faq details {
  border: 1px solid var(--line); border-radius: 12px; background: var(--panel);
  padding: 4px 16px; margin-bottom: 10px;
}
.faq summary { cursor: pointer; padding: 10px 0; font-weight: 600; list-style: none; display: flex; gap: 10px; align-items: center; }
.faq summary::-webkit-details-marker { display: none; }
.faq summary::before { content: "+"; color: var(--brand); font-weight: 800; width: 14px; }
.faq details[open] summary::before { content: "−"; }
.faq details p { margin: 0 0 14px; color: var(--muted); font-size: 14px; padding-inline-start: 24px; }

.site-footer {
  max-width: 1480px; margin: 0 auto; padding: 10px clamp(18px, 3vw, 34px) 40px;
  color: var(--muted); font-size: 12.5px;
}
.to-top {
  position: fixed; inset-inline-end: 22px; bottom: 22px; z-index: 40;
  width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--panel); box-shadow: var(--shadow); cursor: pointer;
  display: none; place-items: center;
}
.to-top.show { display: grid; }
.empty { display: none; padding: 26px; text-align: center; color: var(--muted); }

/* responsive */
@media (max-width: 980px) {
  .shell { grid-template-columns: 1fr; }
  .toc {
    position: fixed; inset: 64px 12px auto 12px; z-index: 45; max-height: 70vh;
    display: none;
  }
  .toc.open { display: block; }
  .toc-toggle { display: grid; }
  #search { width: 140px; }
  .brand-text span { display: none; }
}
@media (max-width: 620px) {
  .header-tools .search-box { display: none; }
  .lang-select { max-width: 120px; }
  .shots { grid-template-columns: 1fr; }
}

/* lightbox */
.shot a { cursor: zoom-in; }
.lightbox {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 12, 20, .88);
}
.lightbox.open { display: flex; }
.lightbox img {
  max-width: 95vw;
  max-height: 92vh;
  width: auto;
  height: auto;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .5);
}
.lightbox-close {
  position: absolute;
  top: 14px;
  right: 18px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-close:hover { background: rgba(255, 255, 255, .18); }
.lightbox-prev,
.lightbox-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .35);
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
}
.lightbox-prev { left: 18px; }
.lightbox-next { right: 18px; }
.lightbox-prev:hover,
.lightbox-next:hover { background: rgba(255, 255, 255, .18); }
.lightbox-count {
  position: absolute;
  top: 22px;
  left: 22px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(0, 0, 0, .35);
  color: #fff;
  font-size: 13px;
  letter-spacing: .04em;
}
.lightbox.single .lightbox-prev,
.lightbox.single .lightbox-next,
.lightbox.single .lightbox-count { display: none; }
body.lb-open { overflow: hidden; }

/* print */
@media print {
  body { background: #fff; }
  .lightbox { display: none !important; }
  .site-header, .toc, .to-top, .toc-toggle, .search-box { display: none !important; }
  .shell { display: block; max-width: none; padding: 0; }
  .hero, .chapter { box-shadow: none; border-color: #ddd; break-inside: avoid; }
  .shots { grid-template-columns: 1fr 1fr; }
  .shot { break-inside: avoid; }
  a { color: inherit; }
}
